vendredi 6 mars 2015

Is there a good C++ tool for parsing a decimal?

I have a place in my code where I have an element iter of type std::string::const_iterator and if *iter is the beginning of a decimal (i.e. the beginning of a string of the form -00.01, .60, 12319.1, 99, etc.) then I want to advance iter until it has passed through the decimal string and I want to store the decimal string.


For a concrete setup of the scenario:



for (std::string::const_iterator iter(str.begin()), offend(str.end()); iter != offend; ++iter)
{
if (iter == '(')
{
//... blah blah blah
}
else if (iter is the beginning of a decimal representation)
{
parse the decimal representation, store it in a string, advance iter to the character at the end of the decimal representation (or to offend -- whichever comes first)
}
else if (some other condition involving iter)
{
// ... blah blah blah
}
//...
}


Is there a C++ tool that I can exploit for this scenario?


Aucun commentaire:

Enregistrer un commentaire