OverSim
StringConvert.h File Reference
#include <cexception.h>
#include <iostream>
#include <sstream>
#include <string>

Go to the source code of this file.

Functions

template<class t >
convertString (const std::string &str)
template<class t >
std::string convertToString (const t &val)

Detailed Description

Author
Stephan Krause

Definition in file StringConvert.h.

Function Documentation

template<class t >
t convertString ( const std::string &  str)

Definition at line 29 of file StringConvert.h.

{
std::istringstream s(str);
t buf;
if (!(s >> buf)) {
throw( cException("convertString: parsing of string %s failed", str.c_str()) );
}
return buf;
}
template<class t >
std::string convertToString ( const t &  val)

Definition at line 38 of file StringConvert.h.

{
std::ostringstream s;
if (!(s << val)) {
throw( cException("convertToString: cannot convert value to string") );
}
return s.str();
}