Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / c++ value changes partion bools,int, or doubles and return a vector

Author
Message
3d point in space
14
Years of Service
User Offline
Joined: 30th Jun 2009
Location: Idaho
Posted: 4th Aug 2012 18:46
Here are some quite use-full functions to part-ion a list of values
for example.
1,0,0,0,0,1,0
will part-ion to a vector of bools
255,255,255,255,255
will part-ion to a vector of ints
1.5,2.5,3.6
will part-ion to a vector of floats.



Developer of Space Chips, pianobasic, zipzapzoom, and vet pinball apps. Developed the tiled map engine seen on the showcase. Veteran for the military.
Dar13
15
Years of Service
User Offline
Joined: 12th May 2008
Location: Microsoft VisualStudio 2010 Professional
Posted: 4th Aug 2012 19:39 Edited at: 4th Aug 2012 19:40
@3d point in space
Nice set of functions, though it looks a bit complex.

Here's a somewhat cleaner implementation using Boost.Tokenizer and a template function.
Assumes that the data is valid for the given type, and has no exception handling or data verification.


Disclaimer: I haven't tested this whatsoever, so use at own risk.

3d point in space
14
Years of Service
User Offline
Joined: 30th Jun 2009
Location: Idaho
Posted: 4th Aug 2012 21:08 Edited at: 4th Aug 2012 21:34
Hu I didn't know you can you can use boost with agk. I might look into it some time. So does boost use lexical parsing library with out making something with lex and yacc. I need to read about boost sounds very good. I noticed in the example you left the space out of the part-ion example. Sometimes programs use spaces instead of comma when using xml.

Developer of Space Chips, pianobasic, zipzapzoom, and vet pinball apps. Developed the tiled map engine seen on the showcase. Veteran for the military.
Dar13
15
Years of Service
User Offline
Joined: 12th May 2008
Location: Microsoft VisualStudio 2010 Professional
Posted: 5th Aug 2012 05:13
Boost can be used with just about any library and is cross-platform.

To fix the issue with the spaces and such, try this small modification:

That way you can pass in whatever delimiting character you want, either commas or spaces.

Boost isn't a true standalone lexical parser like bison or yacc, it just has a lexical_cast template function that acts like a mixture of atoi() and itoa() plus some other conversions.

erebusman
12
Years of Service
User Offline
Joined: 23rd Jul 2011
Location: Sacramento, CA
Posted: 13th Aug 2012 05:46
@Dar13 ; if you did use boost with a Tier2 VS 2010 project in AppGameKit -- when you go to convert the project to iOS or Android; do you then have to go and put the boost libraries over there as well? or this step is not necessary?

I'ts my first time coding in C++ so I'm worried about having nasty surprises if I use such a library?
Dar13
15
Years of Service
User Offline
Joined: 12th May 2008
Location: Microsoft VisualStudio 2010 Professional
Posted: 13th Aug 2012 06:41 Edited at: 13th Aug 2012 06:44
Quote: "@Dar13 ; if you did use boost with a Tier2 VS 2010 project in AppGameKit -- when you go to convert the project to iOS or Android; do you then have to go and put the boost libraries over there as well? or this step is not necessary?

I'ts my first time coding in C++ so I'm worried about having nasty surprises if I use such a library?"

One of the good (and bad) things about Boost is that it is mainly a header-only library. If it's compiled into the executable, then you don't have to copy over any extra files along with the executable. The downside is that it's compiled everytime the application is compiled unless it's in a precompiled header. As for crossplatform development using Boost, it's probably the only library more suited for cross platform application development other than the standard libraries.

Edit: Although if you use a heavier library like threads expect to statically link to a precompiled Boost .lib library. I hope that made sense, I'm at the point where I either need sleep or more caffeine.

Login to post a reply

Server time is: 2024-05-06 12:33:21
Your offset time is: 2024-05-06 12:33:21