Welcome to the new platform of Programmers Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use it's exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.
Efficient text file parsing
I want to make a parser that will load info into a struct from a file. The format looks like this:
%Block Number One%
Where the first line (%Block Number One%) is loaded into an std::string, 3 is the number of block lines, and each block line is subdivided into cells. The cells are divided by .s, with + denoting a newline. I would actually rather just eliminate the + and use newline insead. Anyway, it is supposed to load each 'cell' into a struct containing three integers, and each number (like each 0 in 000, or the ones and the two in 112) is loaded into one of the three integers, to if we had
int one, two, three;
if we loaded 152 into it, one would equal 1, two would equal 5, and three would equal 2. Also, it needs to set one, two and three to -1 if the separator is a + sign (or a newline, which would be better). Sorry about the huge post, but I have no idea how to do this efficiently. Thanks.