/* * string.cpp * * Created on: Apr 1, 2013 * Author: Jan Travnicek */ #include <string> #include <sstream> namespace ext { std::string to_string ( const std::string & value ) { return value; } std::string to_string ( int value ) { return std::to_string__private ( value ); } std::string to_string ( bool value ) { return std::to_string__private ( value ); } std::string to_string ( long value ) { return std::to_string__private ( value ); } std::string to_string ( long long value ) { return std::to_string__private ( value ); } std::string to_string ( unsigned value ) { return std::to_string__private ( value ); } std::string to_string ( unsigned long value ) { return std::to_string__private ( value ); } std::string to_string ( unsigned long long value ) { return std::to_string__private ( value ); } std::string to_string ( double value ) { return std::to_string__private ( value ); } template < > std::string from_string ( const std::string & value ) { return value; } template < > int from_string ( const std::string & value ) { return std::stoi__private ( value.c_str() ); } template < > bool from_string ( const std::string & value ) { if ( value == "true" || value == "1" ) return true; else return false; } template < > long from_string ( const std::string & value ) { return std::stol__private ( value.c_str() ); } template < > long long from_string ( const std::string & value ) { return std::stoll__private ( value.c_str() ); } template < > unsigned from_string ( const std::string & value ) { return std::stoul__private ( value.c_str() ); } template < > unsigned long from_string ( const std::string & value ) { return std::stoul__private ( value.c_str() ); } template < > unsigned long long from_string ( const std::string & value ) { return std::stoull__private ( value.c_str() ); } template < > double from_string ( const std::string & value ) { return std::stod__private ( value.c_str() ); } std::string cstringToString ( char * param ) { std::string res ( param ); free ( param ); return res; } } /* namespace ext */