// 王智泉 2012/06/13
#ifndef __StringHelper__H__
#define __StringHelper__H__
#include
#include
#define iToStdS(v) ValueToString
#define fToStdS(v) ValueToString
#define dToStdS(v) ValueToString
#define StdSToI(v) StringToValue
#define StdSToF(v) StringToValue
#define StdSToD(v) StringToValue
// 数值转字符串
template
class ValueToString
{
public:
ValueToString(T v)
{
std::stringstream strem;
strem << v;
_str = strem.str();
}
std::string& str()
private:
std::string _str;
};
// 字符串转数值
template
class StringToValue
{
public:
StringToValue(const std::string& s)
{
std::stringstream strem(s);
strem >> _val;
}
T value()
{
return _val;
}
private: www.2cto.com
T _val;
};
#endif
作者:xuhongwei0411