Functions | |
virtual const char * | conversion_error::what () const =0 throw () |
template<class T > | |
static void | conversion_error::raise (const std::string &str, const std::string &extrainfo="") |
Raise an exception for an invalid string conversion to the given type. | |
Basic type string conversion functions | |
| |
std::string | convertToString (const int &val) |
int -> string via stringstream | |
void | convertFromString (const std::string &str, int &val) |
string -> int via stringstream | |
std::string | convertToString (const long int &val) |
long int -> string via stringstream | |
void | convertFromString (const std::string &str, long int &val) |
string -> long int via stringstream | |
std::string | convertToString (const long long int &val) |
long long int -> string via stringstream | |
void | convertFromString (const std::string &str, long long int &val) |
string -> long long int via stringstream | |
std::string | convertToString (const short int &val) |
short int -> string via stringstream | |
void | convertFromString (const std::string &str, short int &val) |
string -> short int via stringstream | |
std::string | convertToString (const unsigned int &val) |
unsigned int -> string via stringstream | |
void | convertFromString (const std::string &str, unsigned int &val) |
string -> unsigned int via stringstream | |
std::string | convertToString (const unsigned long int &val) |
unsigned long int -> string via stringstream | |
void | convertFromString (const std::string &str, unsigned long int &val) |
string -> unsigned long int via stringstream | |
std::string | convertToString (const unsigned long long int &val) |
unsigned long long int -> string via stringstream | |
void | convertFromString (const std::string &str, unsigned long long int &val) |
string -> unsigned long long int via stringstream | |
std::string | convertToString (const unsigned short int &val) |
unsigned short int -> string via stringstream | |
void | convertFromString (const std::string &str, unsigned short int &val) |
string -> unsigned short int via stringstream | |
std::string | convertToString (const unsigned char &val) |
unsigned char -> string via stringstream | |
void | convertFromString (const std::string &str, unsigned char &val) |
string -> unsigned char via stringstream | |
std::string | convertToString (const float &val) |
float -> string via stringstream | |
void | convertFromString (const std::string &str, float &val) |
string -> float via stringstream | |
std::string | convertToString (const double &val) |
double -> string via stringstream | |
void | convertFromString (const std::string &str, double &val) |
string -> double stringstream | |
std::string | convertToString (const std::string &val) |
std::string overload | |
void | convertFromString (const std::string &str, std::string &val) |
std::string overload | |
std::string | convertToString (const bool &val) |
bool overload: format is "true|false" | |
void | convertFromString (const std::string &str, bool &val) |
bool overload | |
Overloaded implementations of string conversion functions | |
| |
std::string | convertToString (const in_addr &val) |
in_addr overload: format is "<int>.<int>.<int>.<int>" | |
void | convertFromString (const std::string &str, in_addr &val) |
in_addr overload: format is "<int>.<int>.<int>.<int>" | |
std::string | convertToString (const rutz::time &val) |
rutz::time overload: format is "<h>:<m>:<s>.<ms>" | |
void | convertFromString (const std::string &str, rutz::time &val) |
rutz::time overload: format is "<h>:<m>:<s>.<ms>" | |
Easier-syntax functions to convert to/from string | |
| |
template<class T > | |
std::string | toStr (const T &val) |
converts val into a string and returns the string | |
template<class T > | |
T | fromStr (const std::string &str) |
converts str into a T value and returns the T value |
We define a number of string conversion helpers here just so that we don't require each type that we may want to instantiate into a ModelParam derivative to define operator<< and operator>>. The main reason is that this definition requires including <sstream> (especially if the class is all-inline like Point2D<int>), which would largely increase the compile time if we did it for all our simple types like Dims, Point2D<int>, etc. But the code below may some day migrate into proper definitions of operator<< and operator>> for those data types.
void convertFromString | ( | const std::string & | str, | |
rutz::time & | val | |||
) |
rutz::time overload: format is "<h>:<m>:<s>.<ms>"
Definition at line 298 of file StringConversions.C.
References rutz::time::reset().
void convertFromString | ( | const std::string & | str, | |
in_addr & | val | |||
) |
in_addr overload: format is "<int>.<int>.<int>.<int>"
Definition at line 274 of file StringConversions.C.
void convertFromString | ( | const std::string & | str, | |
bool & | val | |||
) |
bool overload
Anything with a first letter 't', T', 'y', 'Y', or '1' will convert to true; anything with a first letter 'f', F', 'n', 'N', or '0' will convert to false
Definition at line 250 of file StringConversions.C.
void convertFromString | ( | const std::string & | str, | |
std::string & | val | |||
) |
std::string overload
Definition at line 239 of file StringConversions.C.
void convertFromString | ( | const std::string & | str, | |
double & | val | |||
) |
string -> double stringstream
Definition at line 228 of file StringConversions.C.
void convertFromString | ( | const std::string & | str, | |
float & | val | |||
) |
string -> float via stringstream
Definition at line 220 of file StringConversions.C.
void convertFromString | ( | const std::string & | str, | |
unsigned char & | val | |||
) |
string -> unsigned char via stringstream
Definition at line 200 of file StringConversions.C.
References max().
void convertFromString | ( | const std::string & | str, | |
unsigned short int & | val | |||
) |
string -> unsigned short int via stringstream
Definition at line 189 of file StringConversions.C.
void convertFromString | ( | const std::string & | str, | |
unsigned long long int & | val | |||
) |
string -> unsigned long long int via stringstream
Definition at line 181 of file StringConversions.C.
void convertFromString | ( | const std::string & | str, | |
unsigned long int & | val | |||
) |
string -> unsigned long int via stringstream
Definition at line 173 of file StringConversions.C.
void convertFromString | ( | const std::string & | str, | |
unsigned int & | val | |||
) |
string -> unsigned int via stringstream
Definition at line 165 of file StringConversions.C.
void convertFromString | ( | const std::string & | str, | |
short int & | val | |||
) |
string -> short int via stringstream
Definition at line 157 of file StringConversions.C.
void convertFromString | ( | const std::string & | str, | |
long long int & | val | |||
) |
string -> long long int via stringstream
Definition at line 149 of file StringConversions.C.
void convertFromString | ( | const std::string & | str, | |
long int & | val | |||
) |
string -> long int via stringstream
Definition at line 141 of file StringConversions.C.
void convertFromString | ( | const std::string & | str, | |
int & | val | |||
) |
string -> int via stringstream
Definition at line 133 of file StringConversions.C.
std::string convertToString | ( | const rutz::time & | val | ) |
rutz::time overload: format is "<h>:<m>:<s>.<ms>"
Definition at line 287 of file StringConversions.C.
References rutz::time::sec(), and sformat().
std::string convertToString | ( | const in_addr & | val | ) |
in_addr overload: format is "<int>.<int>.<int>.<int>"
Definition at line 266 of file StringConversions.C.
std::string convertToString | ( | const bool & | val | ) |
bool overload: format is "true|false"
Definition at line 247 of file StringConversions.C.
std::string convertToString | ( | const std::string & | val | ) |
std::string overload
Definition at line 236 of file StringConversions.C.
std::string convertToString | ( | const double & | val | ) |
double -> string via stringstream
Definition at line 225 of file StringConversions.C.
std::string convertToString | ( | const float & | val | ) |
float -> string via stringstream
Definition at line 217 of file StringConversions.C.
std::string convertToString | ( | const unsigned char & | val | ) |
unsigned char -> string via stringstream
Definition at line 194 of file StringConversions.C.
std::string convertToString | ( | const unsigned short int & | val | ) |
unsigned short int -> string via stringstream
Definition at line 186 of file StringConversions.C.
std::string convertToString | ( | const unsigned long long int & | val | ) |
unsigned long long int -> string via stringstream
Definition at line 178 of file StringConversions.C.
std::string convertToString | ( | const unsigned long int & | val | ) |
unsigned long int -> string via stringstream
Definition at line 170 of file StringConversions.C.
std::string convertToString | ( | const unsigned int & | val | ) |
unsigned int -> string via stringstream
Definition at line 162 of file StringConversions.C.
std::string convertToString | ( | const short int & | val | ) |
short int -> string via stringstream
Definition at line 154 of file StringConversions.C.
std::string convertToString | ( | const long long int & | val | ) |
long long int -> string via stringstream
Definition at line 146 of file StringConversions.C.
std::string convertToString | ( | const long int & | val | ) |
long int -> string via stringstream
Definition at line 138 of file StringConversions.C.
std::string convertToString | ( | const int & | val | ) |
int -> string via stringstream
Definition at line 130 of file StringConversions.C.
T fromStr | ( | const std::string & | str | ) | [inline] |
converts str into a T value and returns the T value
Definition at line 206 of file StringConversions.H.
References convertFromString().
static void conversion_error::raise | ( | const std::string & | str, | |
const std::string & | extrainfo = "" | |||
) | [inline, static, inherited] |
Raise an exception for an invalid string conversion to the given type.
The exception thrown will be derived from conversion_error.
Definition at line 64 of file StringConversions.H.
Referenced by convertFromString().
std::string toStr | ( | const T & | val | ) | [inline] |
converts val into a string and returns the string
Definition at line 198 of file StringConversions.H.
Referenced by DirectFeedChannel::DirectFeedChannel(), DirectFeedChannel::doInput(), VisualEventSet::drawTokens(), and main().