I am trying to scroll a two dimensional list with an iterator and I know that I'm missing something but I don't know what.
So the idea is that I'll have some commands to parse.
I put them on a list then I want to check if a member of the list is equal to "data.txt" for example. So I did an iterator for this, but as it is a two dimensional list with an std::pair inside it, I don't know how to implement this iterator. I did this but it isn't good, I can't read both list.
typedef std::list<std::string> listStr;
std::list <std::pair<listStr, int> > _execCmd;
int Parser::execCmd()
{
std::list<std::string>::const_iterator i;
for (i = _execCmd.front().first.begin(); i != _execCmd.back().first.end(); ++i)
{
if (*i == "Search.txt")
execSearch();
else if (*i == "data.txt")
execData();
}
return (0);
}
In that case, I stay on the first list "File.txt data.txt contact.txt" (cf: schema) and I can go through the second list "Search.txt employe.csv".
I've tried this too:
int Parser::execCmd()
{
std::list<std::pair<listStr, int> >::const_iterator i;
for (i = _execCmd.begin(); i != _execCmd.end(); ++i)
{
if (*i == "Search.txt")
execSearch();
else if (*i == "data.txt")
execData();
}
return (0);
}
But I can't compile this because I don't know how to compare the iterator with a string (*i == "help"
)
Somebody can help me please ?