|
|
This thread is locked; no one can reply to it.
|
1
2
|
| Sane string conversion in C++11 |
|
Chris Katko
Member #1,881
January 2002
|
D: literally_anything.toString(); Because all objects inherit from the object class and have a toString method. Also, to!anything_else(almost_anything);
It makes (un)serializing really easy to a file for loading/saving maps. -----sig: |
|
Audric
Member #907
January 2001
|
I haven't seen it mentioned so far, but GNU's and BSD's libc include asprintf() : It's a sprintf() variant where you don't pass your own target buffer. It computes how long the string will be, performs a malloc(), fills it, and returns the address to you. It's then your responsibility to free() it when you're done with it. |
|
Edgar Reynaldo
Major Reynaldo
May 2007
|
Is that just an GNU C extension? I doubt Micro$oft supports it. Otherwise I would make StringPrintF use it. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
|
bamccaig
Member #7,536
July 2006
|
The implementations would be free software. Could include the definition with CPP. -- acc.js | al4anim - Allegro 4 Animation library | Allegro 5 VS/NuGet Guide | Allegro.cc Mockup | Allegro.cc <code> Tag | Allegro 4 Timer Example (w/ Semaphores) | Allegro 5 "Winpkg" (MSVC readme) | Bambot | Blog | C++ STL Container Flowchart | Castopulence Software | Check Return Values | Derail? | Is This A Discussion? Flow Chart | Filesystem Hierarchy Standard | Clean Code Talks - Global State and Singletons | How To Use Header Files | GNU/Linux (Debian, Fedora, Gentoo) | rot (rot13, rot47, rotN) | Streaming |
|
Edgar Reynaldo
Major Reynaldo
May 2007
|
bamccaig said: Looks like you can't pass a std::string to StringPrintF though. Not currently. It might be possible with a bit of a hack, but you would have to find a non-reserved format specifier to use and be consistent with it. There's a bit of a problem with StringPrintF though, and that is when you create a temporary string with it like so : printf("%s\n" , StringPrintF("Hello my name is dangling pointer").c_str());
My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
|
|
1
2
|