33 #ifndef YB_INC_libdefect_string_h_
34 #define YB_INC_libdefect_string_h_ 1
41 #if defined(__GLIBCXX__) && __GLIBCXX__ <= 20120920 \
42 && defined(__GXX_EXPERIMENTAL_CXX0X__) \
43 && !(defined(_GLIBCXX_USE_C99) && !defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF))
45 #include <ext/string_conversions.h>
47 namespace std _GLIBCXX_VISIBILITY(default)
50 #ifndef _GLIBCXX_USE_C99
52 extern "C" long long int
53 (strtoll)(
const char* __restrict,
char** __restrict, int)
throw();
54 extern "C" unsigned long long int
55 (strtoull)(
const char* __restrict,
char** __restrict, int)
throw();
59 (vsnprintf)(
char* __restrict, std::size_t,
const char* __restrict,
60 __gnuc_va_list)
throw();
72 _GLIBCXX_BEGIN_NAMESPACE_VERSION
76 #define YB_LIBDEFECT_STOI(_s, _n, _t, _cfname) \
78 _n(const _s& __str, size_t* __idx = 0, int __base = 10) \
80 return __gnu_cxx::__stoa(&_cfname, #_n, __str.c_str(), __idx, __base); \
84 stoi(
const string& __str,
size_t* __idx = 0,
int __base = 10)
86 return __gnu_cxx::__stoa<long, int>(&std::strtol,
"stoi", __str.c_str(),
89 YB_LIBDEFECT_STOI(
string, stol,
long, std::strtol)
90 YB_LIBDEFECT_STOI(
string, stoul,
unsigned long, std::strtoul)
91 YB_LIBDEFECT_STOI(
string, stoll,
long long, std::strtoll)
92 YB_LIBDEFECT_STOI(
string, stoull,
unsigned long long, std::strtoull)
93 #ifdef _GLIBCXX_USE_WCHAR_T
95 stoi(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
97 return __gnu_cxx::__stoa<long, int>(&std::wcstol,
"stoi", __str.c_str(),
100 YB_LIBDEFECT_STOI(wstring, stol,
long, std::wcstol)
101 YB_LIBDEFECT_STOI(wstring, stoul,
unsigned long, std::wcstoul)
102 YB_LIBDEFECT_STOI(wstring, stoll,
long long, std::wcstoll)
103 YB_LIBDEFECT_STOI(wstring, stoull,
unsigned long long, std::wcstoull)
106 #undef YB_LIBDEFECT_STOI
109 #define YB_LIBDEFECT_STOF(_s, _n, _t, _cfname) \
111 _n(const _s& __str, size_t* __idx = 0) \
113 return __gnu_cxx::__stoa(&_cfname, #_n, __str.c_str(), __idx); \
117 YB_LIBDEFECT_STOF(
string, stof,
float, std::strtof)
118 YB_LIBDEFECT_STOF(
string, stod,
double, std::strtod)
119 YB_LIBDEFECT_STOF(
string, stold,
long double, std::strtold)
120 #ifdef _GLIBCXX_USE_WCHAR_T
122 YB_LIBDEFECT_STOF(wstring, stof,
float, std::wcstof)
123 YB_LIBDEFECT_STOF(wstring, stod,
double, std::wcstod)
124 YB_LIBDEFECT_STOF(wstring, stold,
long double, std::wcstold)
127 #undef YB_LIBDEFECT_STOF
131 #define YB_LIBDEFECT_TOSTRI(_s, _t, _fmt, _cfname) \
135 return __gnu_cxx::__to_xstring<_s>(&_cfname, \
136 sizeof(_t) * 4, _fmt, __val); \
140 YB_LIBDEFECT_TOSTRI(
string,
int,
"%d", std::vsnprintf)
141 YB_LIBDEFECT_TOSTRI(
string,
unsigned, "%u", std::vsnprintf)
142 YB_LIBDEFECT_TOSTRI(
string,
long, "%ld", std::vsnprintf)
143 YB_LIBDEFECT_TOSTRI(
string,
unsigned long, "%lu", std::vsnprintf)
144 YB_LIBDEFECT_TOSTRI(
string,
long long, "%lld", std::vsnprintf)
145 YB_LIBDEFECT_TOSTRI(
string,
unsigned long long, "%llu", std::vsnprintf)
146 #if !defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF) && defined(_GLIBCXX_USE_WCHAR_T)
147 YB_LIBDEFECT_TOSTRI(wstring,
int,
L"%d", std::vswprintf)
148 YB_LIBDEFECT_TOSTRI(wstring,
unsigned,
L"%u", std::vswprintf)
149 YB_LIBDEFECT_TOSTRI(wstring,
long,
L"%ld", std::vswprintf)
150 YB_LIBDEFECT_TOSTRI(wstring,
unsigned long,
L"%lu", std::vswprintf)
151 YB_LIBDEFECT_TOSTRI(wstring,
long long,
L"%lld", std::vswprintf)
152 YB_LIBDEFECT_TOSTRI(wstring,
unsigned long long,
L"%llu", std::vswprintf)
155 #undef YB_LIBDEFECT_TOSTRI
158 #define YB_LIBDEFECT_TOSTRF(_s, _t, _fmt, _cfname) \
162 return __gnu_cxx::__to_xstring<_s>(&_cfname, \
163 __gnu_cxx::__numeric_traits<_t>::__max_exponent10 + 20, \
167 YB_LIBDEFECT_TOSTRF(
string,
float,
"%f", std::vsnprintf)
168 YB_LIBDEFECT_TOSTRF(
string,
double, "%f", std::vsnprintf)
169 YB_LIBDEFECT_TOSTRF(
string,
long double, "%f", std::vsnprintf)
170 #if !defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF) && defined(_GLIBCXX_USE_WCHAR_T)
171 YB_LIBDEFECT_TOSTRF(wstring,
float,
L"%f", std::vswprintf)
172 YB_LIBDEFECT_TOSTRF(wstring,
double,
L"%f", std::vswprintf)
173 YB_LIBDEFECT_TOSTRF(wstring,
long double,
L"%f", std::vswprintf)
176 #undef YB_LIBDEFECT_TOSTRF
178 _GLIBCXX_END_NAMESPACE_VERSION