Wednesday, December 26, 2012

string.split( container, delimiters, numOfDelimiters )

Man, writing simple save and load functions friggin took forever.  Like most things with c++ what seemed like it would be straightforward was not.  Anyway, finally got something working, and I'm rather proud of my function, if I may say so. 
Certainly there are many ways to skin this particular cat, but I was trying not to use any external libraries.  Why doesn’t Irrlicht use the STL?
"Simply because Irrlicht is quite portable. Irrlicht compiles with 7 (or even more) different compilers and on 4 different platforms/operating systems, without a single warning."
I was trying to use only Irrlicht's implementations to accomplish writing and reading my own save file format.  I got most of the way there, but I had to pull one trick out of the stdio.h :

int kx::String2Int (stringc& str)
{
    int i;
    sscanf( str.c_str(), "%i", &i );
    return i;
}


Probably I'll write a similar one for floats, too, but I'm quite happy with the simplicity of this conversion.  But I'm getting ahead of myself.  Here are my save and load functions:



No comments:

Post a Comment