Results 1 to 3 of 3

Thread: Just ran across the TextScanner class

  1. #1
    Lesser Wizard
    Join Date
    Nov 2010
    Location
    Los Angeles, California, United States, United States
    Posts
    126

    Default Just ran across the TextScanner class

    Looks like it could be used for general (readable) app settings and strings. Any pointers?

  2. #2
    Lesser Wizard
    Join Date
    Nov 2010
    Location
    Los Angeles, California, United States, United States
    Posts
    126

    Default

    Also, have you ever used this?

    http://www.hyperrealm.com/libconfig/

    Looks pretty flexible.

  3. #3
    Administrator Seth's Avatar
    Join Date
    Jul 2002
    Location
    Japan
    Posts
    5,343

    Default

    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:

    name|Jeff
    lives|3

    You could parse it like this:

    Code:
    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.
    Seth A. Robinson
    Robinson Technologies

Similar Threads

  1. A cleaner/easier class idiom in Lua
    By Ian in forum Novashell Game Creation System
    Replies: 7
    Last Post: 11-03-2012, 04:58 PM
  2. CL_Random Class
    By rombust in forum Official ClanLib SDK Forums
    Replies: 0
    Last Post: 07-21-2009, 07:54 AM
  3. Is there 2D camera class in clanLib?
    By alexv1 in forum Official ClanLib SDK Forums
    Replies: 1
    Last Post: 02-18-2009, 08:59 PM
  4. Example of CL_SpanLayout class in ClanLib 0.9
    By rombust in forum Official ClanLib SDK Forums
    Replies: 0
    Last Post: 02-03-2009, 03:03 PM
  5. CL 0.8 pixel data deleter class
    By Trigve in forum Official ClanLib SDK Forums
    Replies: 0
    Last Post: 10-27-2007, 11:33 AM

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •