I am working mostly with CEGUI and strings right now, but I am having trouble figuring out the best way to get numbers and other datatypes into strings
I want to be able to do:
setStatusText("Setting the text here: "+ img->getHeight());
and have the function setup as
setStatusText(const CEGUI::String &txt) { ...}
I have tried lots of stuff but I just can't seem to find the right way to do this, its very basic I am sure, but I could use some help.
I am pretty sure if I can figure out the proper way to get it into a standard string I can go from that to CEGUIL::String but whatever is the most proper way is what I would like to use.
[type] to string
-
temas
- OGRE Retired Team Member

- Posts: 390
- Joined: Sun Oct 06, 2002 11:19 pm
- Location: The Woodlands, TX
You'll probably want to use a string stream from <sstream>
An example:
An example:
Code: Select all
ostringstream os;
os << "Setting the text here: " << img->getHeight();
setStatusText(os.str());
-
epopov
- Halfling
- Posts: 85
- Joined: Tue Jun 10, 2003 2:57 pm
boost (http://www.boost.org) also has some useful string util functions:
It also works with more than one parameter:
Code: Select all
setStatusText(boost::str(boost::format("Setting the text here:%d") % img->getHeight()));
Code: Select all
boost::str(boost::format("Height is %d and width %d") % img->getHeight() % img->getWidth()));