33 #ifndef YB_INC_libdefect_string_h_
34 #define YB_INC_libdefect_string_h_ 1
41 #if defined(__GLIBCXX__) \
42 && (defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L) \
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
53 extern "C" long long int
54 (strtoll)(
const char* __restrict,
char** __restrict, int)
throw();
55 extern "C" unsigned long long int
56 (strtoull)(
const char* __restrict,
char** __restrict, int)
throw();
59 (vsnprintf)(
char* __restrict,
std::size_t,
const char* __restrict,
60 __gnuc_va_list)
throw();
80 _GLIBCXX_BEGIN_NAMESPACE_VERSION
84 #define YB_LIBDEFECT_STOI(_s, _n, _t, _cfname) \
86 _n(const _s& __str, size_t* __idx = {}, int __base = 10) \
88 return __gnu_cxx::__stoa(&_cfname, #_n, __str.c_str(), __idx, __base); \
92 stoi(
const string& __str,
size_t* __idx = {},
int __base = 10)
94 return __gnu_cxx::__stoa<long, int>(&std::strtol,
"stoi", __str.c_str(),
97 YB_LIBDEFECT_STOI(
string, stol,
long, std::strtol)
98 YB_LIBDEFECT_STOI(
string, stoul,
unsigned long, std::strtoul)
100 YB_LIBDEFECT_STOI(
string, stoll,
long long, std::strtoll)
101 YB_LIBDEFECT_STOI(
string, stoull,
unsigned long long, std::strtoull)
103 #ifdef _GLIBCXX_USE_WCHAR_T
105 stoi(
const wstring& __str,
size_t* __idx = {},
int __base = 10)
107 return __gnu_cxx::__stoa<long, int>(&std::wcstol,
"stoi", __str.c_str(),
110 YB_LIBDEFECT_STOI(wstring, stol,
long, std::wcstol)
111 YB_LIBDEFECT_STOI(wstring, stoul,
unsigned long, std::wcstoul)
113 YB_LIBDEFECT_STOI(wstring, stoll,
long long, std::wcstoll)
114 YB_LIBDEFECT_STOI(wstring, stoull,
unsigned long long, std::wcstoull)
118 #undef YB_LIBDEFECT_STOI
121 #define YB_LIBDEFECT_STOF(_s, _n, _t, _cfname) \
123 _n(const _s& __str, size_t* __idx = {}) \
125 return __gnu_cxx::__stoa(&_cfname, #_n, __str.c_str(), __idx); \
131 YB_LIBDEFECT_STOF(
string, stof,
float, std::strtof)
132 YB_LIBDEFECT_STOF(
string, stod,
double, std::strtod)
133 YB_LIBDEFECT_STOF(
string, stold,
long double, std::strtold)
134 #ifdef _GLIBCXX_USE_WCHAR_T
136 YB_LIBDEFECT_STOF(wstring, stof,
float, std::wcstof)
137 YB_LIBDEFECT_STOF(wstring, stod,
double, std::wcstod)
138 YB_LIBDEFECT_STOF(wstring, stold,
long double, std::wcstold)
142 #undef YB_LIBDEFECT_STOF
146 #define YB_LIBDEFECT_TOSTRI(_s, _t, _fmt, _cfname) \
150 return __gnu_cxx::__to_xstring<_s>(&_cfname, \
151 sizeof(_t) * 4, _fmt, __val); \
155 YB_LIBDEFECT_TOSTRI(
string,
int,
"%d", std::vsnprintf)
156 YB_LIBDEFECT_TOSTRI(
string,
unsigned, "%u", std::vsnprintf)
157 YB_LIBDEFECT_TOSTRI(
string,
long, "%ld", std::vsnprintf)
158 YB_LIBDEFECT_TOSTRI(
string,
unsigned long, "%lu", std::vsnprintf)
159 YB_LIBDEFECT_TOSTRI(
string,
long long, "%lld", std::vsnprintf)
160 YB_LIBDEFECT_TOSTRI(
string,
unsigned long long, "%llu", std::vsnprintf)
161 #if !defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF) && defined(_GLIBCXX_USE_WCHAR_T)
162 YB_LIBDEFECT_TOSTRI(wstring,
int, L
"%d", std::vswprintf)
163 YB_LIBDEFECT_TOSTRI(wstring,
unsigned, L"%u", std::vswprintf)
164 YB_LIBDEFECT_TOSTRI(wstring,
long, L"%ld", std::vswprintf)
165 YB_LIBDEFECT_TOSTRI(wstring,
unsigned long, L"%lu", std::vswprintf)
166 YB_LIBDEFECT_TOSTRI(wstring,
long long, L"%lld", std::vswprintf)
167 YB_LIBDEFECT_TOSTRI(wstring,
unsigned long long, L"%llu", std::vswprintf)
170 #undef YB_LIBDEFECT_TOSTRI
173 #define YB_LIBDEFECT_TOSTRF(_s, _t, _fmt, _cfname) \
177 return __gnu_cxx::__to_xstring<_s>(&_cfname, \
178 __gnu_cxx::__numeric_traits<_t>::__max_exponent10 + 20, \
182 YB_LIBDEFECT_TOSTRF(
string,
float,
"%f", std::vsnprintf)
183 YB_LIBDEFECT_TOSTRF(
string,
double, "%
f", std::vsnprintf)
184 YB_LIBDEFECT_TOSTRF(
string,
long double, "%f", std::vsnprintf)
185 #if !defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF) && defined(_GLIBCXX_USE_WCHAR_T)
186 YB_LIBDEFECT_TOSTRF(wstring,
float, L
"%f", std::vswprintf)
187 YB_LIBDEFECT_TOSTRF(wstring,
double, L"%f", std::vswprintf)
188 YB_LIBDEFECT_TOSTRF(wstring,
long double, L"%f", std::vswprintf)
191 #undef YB_LIBDEFECT_TOSTRF
193 _GLIBCXX_END_NAMESPACE_VERSION