I’m trying to create a simple parser and a small text file which follows the following structure:
Variable_name = Value;
VARIABLE_2 = SECOND_VALUE;
Found methods that work, however, use many librarys like Boost. I wonder if you can make a simple, preferably with only the librarys of STD.
Thanks, Bruno Alano.
If your format will be staying like you have listed, and there will be no spaces in either the variable names or the values, this is can be done easily using a combination of
std::stringandstd::istringstream. You could simply do the following:You can change the types of
variableandvalueto properly fit your needs … they don’t need to becharbuffers, but can be any other type provided thatistream& operator>>(istream&, type&)is defined for the data-type you want to use.