00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef _STD_EX_H_
00026 #define _STD_EX_H_
00027
00028 #include <string>
00029 #include <vector>
00030 #include <limits>
00031 #include <stdexcept>
00032
00033 namespace stdex
00034 {
00035
00039 std::wstring itoa(const int iValue);
00040
00044 std::wstring ltoa(const long lValue);
00045
00049 std::wstring ftoa(const float fValue);
00050
00054 std::wstring dtoa(const double dValue);
00055
00059 int atoi(const std::wstring& sValue);
00060
00064 long int atol(const std::wstring& sValue);
00065
00069 float atof(const std::wstring& sValue);
00070
00074 double atod(const std::wstring& sValue);
00075
00079 std::wstring TrimString(const std::wstring& sString);
00080
00084 std::wstring ToWString(const char* sString);
00085
00089 std::string ToMbString(const std::wstring& sWString);
00090
00095 std::vector<std::wstring> DetokenizeString(const std::wstring& sString, const std::wstring& sDelimiters);
00096
00099 #ifdef WIN32
00100 #pragma warning (push)
00101 #pragma warning (disable : 4018) // temporarily disable signed/unsigned comparison warning
00102 #endif // WIN32
00103 template<typename TDest, typename TSrc>
00104 TDest safe_static_cast(const TSrc& Value)
00105 {
00106 #ifndef MSVC6
00107 bool bSpecialized = std::numeric_limits<TDest>::is_specialized && std::numeric_limits<TDest>::is_bounded;
00108 bool bNotSigned = ! std::numeric_limits<TDest>::is_signed;
00109 if (bSpecialized && ((bNotSigned && Value < std::numeric_limits<TDest>::min()) || Value > std::numeric_limits<TDest>::max()))
00110 {
00111 throw std::out_of_range("safe_static_cast : Out of range!");
00112 }
00113 #endif
00114 return static_cast<TDest>(Value);
00115 }
00116 #ifdef WIN32
00117 #pragma warning (default : 4018) // reenable signed/unsigned comparison warning
00118 #pragma warning (pop)
00119 #endif // WIN32
00120
00121 }
00122
00123 #endif // _STD_EX_H_