Page 1 of 1

CEGUI::String

Posted: Sat Nov 12, 2005 12:56
by shmrod
Hi,

How do you transform a CEGUI::String to std::string.
I 'm trying to catch an Cegui::exception, and write it in my log...

thanks

Re: CEGUI::String

Posted: Sat Nov 12, 2005 15:36
by lindquist
Use the "CEGUI::String::c_str" member to get a C string version of the "CEGUI::String" content.

Code: Select all

CEGUI::String cs("test");
std::string s(cs.c_str());
cout << s << endl;


HTH

edit:

Code: Select all

catch (CEGUI::Exception& e)
{
    std::string s(e.getMessage.c_str());
    std::cout << s << std::endl;
}

Posted: Fri Feb 24, 2006 13:34
by Pacome
This method only works for CeGUI generated exceptions, but it doesn't work for general CEGUI::String to std::string conversion.

You can see the details here with a small source code to test it : http://www.cegui.org.uk/phpBB2/viewtopic.php?t=1206

Regards,

PacĂ´me