I want to parse string snippets to a tuple: example string: "Dolly Davenell,8809903417,1 Toban Circle,Luozhou" tuple<string, unsigned int, string, string>
i read the strings from a file and store them with getline in a vector (myPersVec), where each vector element is a string as dscribed above.
Now my problem is that i don't know how to seperate each string element and fill it into each tuple element.
I know i can seperate the string elements with a delimeter character but how do i parse it into the tuple? I then want to save each tuple into another Vector (my2ndVec)
My question is: Once i have the string tokens, how can i parse them to ONE tuple in the correct order?
auto makeT([](std::string line, std::vector<std::tuple<std::string, unsigned int, std::string, std::string>>& my2ndVec, std::vector<std::string> myPersVec) {
std::string token;
std::string deli = ",";
int pos = 0;
while ((pos = line.find(deli)) != std::string::npos) {
token = line.substr(0, pos);
std::cout << token << std::endl;
line.erase(0, pos + deli.length());
}
//how can i parse the tokens now into the tuple? and how do i parse them since i need to get multiple tokens
});
- edit: typo