Splitting and storing config file lines
I wrote the following code to read a config file line by line and split each line into 2 parts and store them separately.


So there are two parts on each line, the stuff before the =, which is stored as a string, and the stuff after the =, which shall be parsed as an integer and stored as a long long.

Thus you can handle each line on its own completely, without using a flag to determine at which part of the line you currently are:

for (int i =0; i&lt;linesOfConfigFile.size(); i++)
{
    std::stringstream singleLine(linesOfConfigFile[i]);

    // get first part of the line
    std::getline(singleLine, currentItem, delimeter);
    // store it
    RHS.push_back(currentItem);

    // Now get the next part of the line
    std::getline(singleLine, currentItem, delimeter);
    // parse it
    long long orderbookId = 0;
    &lt;some library class&gt;::toNumeric(currentItem, orderbookId);
    // and store the result
    LHS.push_back(orderbookId);

    // done with this line :D
}


This supposes of course that the config file is well-formed, and the format requires that each name = value is on a separate line.

If the config file is malformed, or the file format is not as simple, this version may fail where yours wouldn't (for example

name =
value


would work with yours), but neither version does robust error handling, and both would fail on most malformed inputs. Config files can generally be assumed to follow the required format, so the absence of error handling probably isn't a serious problem.