I want to use CEGUI::String to contain a number as follows:
int a = 5;
CEGUI::String myString;
myString << 5;
I can tell by looking at the code and by trying that this is not supported. The sample just used sprintf for the FPS display, Before I go off and write my own thing, I was wondering how the CEGUI team does this? Do you also just use sprintf?
Also, suppose that I allow users in my game to choose their own names, and they happen to use %s in their name, such as "John the %s master". If I pass this to CEGUI::String, is it going to get confused and treat %s as a token?
String and ...
Moderators: CEGUI MVP, CEGUI Team
Another approach is the following:
Code: Select all
template<class T> bool stringToValue(const char* s, T &value)
{
std::istringstream i(s);
return (i >> value);
}
template<class T> std::string valueToString(const T &value)
{
std::ostringstream o;
o << value;
return o.str();
}
Who is online
Users browsing this forum: No registered users and 30 guests