[xsd-users] toString() method for basic datatypes

Boris Kolpackov boris at codesynthesis.com
Fri Feb 22 08:29:06 EST 2013


Hi Harald,

H.Klingel at gmx.net <H.Klingel at gmx.net> writes:

> what do you think about a toString() method for the datatype, e.g 
> xsd::cxx::date_time?

You can already do this if you pass the --generate-ostream XSD
compiler option and then do:

#include <sstream>

xml_schema::date_time dt (...);

std::ostringstream ostr;
ostr << dt;
std::string str (ostr.str ());

If you are using Boost, you could also use lexical_cast:

std::string str (boost::lexical_cast<std::string> (dt));

Boris



More information about the xsd-users mailing list