View Full Version : Just ran across the TextScanner class

04-19-2011, 05:53 AM
Looks like it could be used for general (readable) app settings and strings. Any pointers?

04-19-2011, 06:55 AM
Also, have you ever used this?


Looks pretty flexible.

04-21-2011, 03:07 AM
Hey, yep, that's exactly what I use it for, it's basic but gets the job done.

Here is an example of use:

Assume a simple text file, settings.txt holds the following:


You could parse it like this:

TextScanner t("settings.txt");

//Or, if you've downloaded the file, you can just pass in the memory location:
//TextScanner t(pPointerToMem);

if (!t.IsLoaded())
LogError("Oh damn");

//Note: returns a blank string if the parm is missing
string name = t.GetParmString("name", 1, "|");

//Note: the number says which section to return, you can have multiple delimiters in the same line
int lives = atoi( t.GetParmString("lives",1,"|") );

Haven't messed with libconfig.