33 #include <Pt/String.h>
34 #include <Pt/Locale.h>
42 struct __numpunct_cache;
46 class PT_API numpunct<Pt::Char> :
public locale::facet {
49 typedef basic_string<Pt::Char> string_type;
52 typedef __numpunct_cache<Pt::Char> __cache_type;
57 virtual locale::id& __get_id (
void)
const {
return id; }
60 explicit numpunct(std::size_t refs = 0);
62 char_type decimal_point()
const;
64 char_type thousands_sep()
const;
66 string grouping()
const;
68 string_type truename()
const;
70 string_type falsename()
const;
73 virtual char_type do_decimal_point()
const;
75 virtual char_type do_thousands_sep()
const;
77 virtual string do_grouping()
const;
79 virtual string_type do_truename()
const;
81 virtual string_type do_falsename()
const;
86 class PT_API num_put< Pt::Char,
87 ostreambuf_iterator<Pt::Char> > :
public locale::facet
91 typedef ostreambuf_iterator<Pt::Char> iter_type;
92 typedef basic_ostream<Pt::Char> stream_type;
94 explicit num_put(std::size_t refs = 0)
98 iter_type put(iter_type s, stream_type& f, char_type fill,
bool val)
const
99 {
return this->do_put( s, f, fill, val ); }
102 iter_type put(iter_type s, stream_type& f, char_type fill,
int val)
const
103 {
return this->do_put( s, f, fill,
long(val) ); }
106 iter_type put(iter_type s, stream_type& f, char_type fill,
unsigned val)
const
107 {
return this->do_put( s, f, fill, (
unsigned long)(val) ); }
109 iter_type put(iter_type s, stream_type& f, char_type fill,
long val)
const
110 {
return this->do_put( s, f, fill, val ); }
112 iter_type put(iter_type s, stream_type& f, char_type fill,
unsigned long val)
const
113 {
return this->do_put( s, f, fill, val ); }
115 iter_type put(iter_type s, stream_type& f, char_type fill,
long long val)
const
116 {
return this->do_put( s, f, fill, val ); }
118 iter_type put(iter_type s, stream_type& f, char_type fill,
unsigned long long val)
const
119 {
return this->do_put( s, f, fill, val ); }
121 iter_type put(iter_type s, stream_type& f, char_type fill,
double val)
const
122 {
return this->do_put( s, f, fill, val ); }
124 iter_type put(iter_type s, stream_type& f, char_type fill,
long double val)
const
125 {
return this->do_put( s, f, fill, val ); }
127 iter_type put(iter_type s, stream_type& f, char_type fill,
const void* val)
const
128 {
return this->do_put( s, f, fill, val ); }
130 static locale::id id;
133 virtual locale::id& __get_id (
void)
const
137 virtual iter_type do_put(iter_type s, stream_type& f, char_type fill,
bool val)
const;
139 virtual iter_type do_put(iter_type s, stream_type& f, char_type fill,
long val)
const;
141 virtual iter_type do_put(iter_type s, stream_type& f, char_type fill,
unsigned long val)
const;
143 virtual iter_type do_put(iter_type s, stream_type& f, char_type fill,
long long val)
const;
145 virtual iter_type do_put(iter_type s, stream_type& f, char_type fill,
unsigned long long val)
const;
147 virtual iter_type do_put(iter_type s, stream_type& f, char_type fill,
double val)
const;
149 virtual iter_type do_put(iter_type s, stream_type& f, char_type fill,
long double val)
const;
151 virtual iter_type do_put(iter_type s, stream_type& f, char_type fill,
const void*)
const;
156 class PT_API num_get< Pt::Char,
157 istreambuf_iterator<Pt::Char> > :
public locale::facet
161 typedef istreambuf_iterator<Pt::Char> iter_type;
162 typedef basic_istream<Pt::Char> stream_type;
164 explicit num_get(std::size_t refs = 0)
165 : locale::facet(refs)
168 iter_type
get(iter_type it, iter_type end, stream_type& f, ios_base::iostate& s,
bool& val)
const
169 {
return this->do_get(it, end, f, s, val); }
171 iter_type
get(iter_type it, iter_type end, stream_type& f, ios_base::iostate& s,
long& val)
const
172 {
return this->do_get(it, end, f, s, val); }
174 iter_type
get(iter_type it, iter_type end, stream_type& f, ios_base::iostate& s,
long long int& val)
const
175 {
return this->do_get(it, end, f, s, val); }
177 iter_type
get(iter_type it, iter_type end, stream_type& f, ios_base::iostate& s,
unsigned short& val)
const
178 {
return this->do_get(it, end, f, s, val); }
180 iter_type
get(iter_type it, iter_type end, stream_type& f, ios_base::iostate& s,
unsigned int& val)
const
181 {
return this->do_get(it, end, f, s, val); }
183 iter_type
get(iter_type it, iter_type end, stream_type& f, ios_base::iostate& s,
unsigned long& val)
const
184 {
return this->do_get(it, end, f, s, val); }
186 iter_type
get(iter_type it, iter_type end, stream_type& f, ios_base::iostate& s,
unsigned long long & val)
const
187 {
return this->do_get(it, end, f, s, val); }
189 iter_type
get(iter_type it, iter_type end, stream_type& f, ios_base::iostate& s,
float& val)
const
190 {
return this->do_get(it, end, f, s, val); }
192 iter_type
get(iter_type it, iter_type end, stream_type& f, ios_base::iostate& s,
double& val)
const
193 {
return this->do_get(it, end, f, s, val); }
195 iter_type
get(iter_type it, iter_type end, stream_type& f, ios_base::iostate& s,
long double& val)
const
196 {
return this->do_get(it, end, f, s, val); }
198 iter_type
get(iter_type it, iter_type end, stream_type& f, ios_base::iostate& s,
void*& val)
const
199 {
return this->do_get(it, end, f, s, val); }
201 static locale::id id;
204 virtual locale::id& __get_id (
void)
const
208 virtual iter_type do_get(iter_type, iter_type, stream_type&, ios_base::iostate&,
bool&)
const;
210 virtual iter_type do_get(iter_type, iter_type, stream_type&, ios_base::iostate&,
long&)
const;
212 virtual iter_type do_get(iter_type, iter_type, stream_type&, ios_base::iostate&,
long long&)
const;
214 virtual iter_type do_get(iter_type, iter_type, stream_type&, ios_base::iostate&,
unsigned short&)
const;
216 virtual iter_type do_get(iter_type, iter_type, stream_type&, ios_base::iostate&,
unsigned int&)
const;
218 virtual iter_type do_get(iter_type, iter_type, stream_type&, ios_base::iostate&,
unsigned long&)
const;
220 virtual iter_type do_get(iter_type, iter_type, stream_type&, ios_base::iostate&,
unsigned long long&)
const;
222 virtual iter_type do_get(iter_type, iter_type, stream_type&, ios_base::iostate&,
float&)
const;
224 virtual iter_type do_get(iter_type, iter_type, stream_type&, ios_base::iostate&,
double&)
const;
226 virtual iter_type do_get(iter_type, iter_type, stream_type&, ios_base::iostate&,
long double&)
const;
228 virtual iter_type do_get(iter_type, iter_type, stream_type&, ios_base::iostate&,
void*&)
const;
231 #if (defined _MSC_VER || defined __QNX__ || defined __xlC__)
233 class PT_API ctype< Pt::Char > :
public ctype_base {
236 class PT_API ctype<Pt::Char> :
public ctype_base,
public locale::facet {
240 typedef ctype_base::mask mask;
242 static locale::id id;
245 virtual locale::id& __get_id (
void)
const {
return id; }
248 explicit ctype(std::size_t refs = 0);
251 {
return this->do_is(m, c); }
254 {
return this->do_is(lo, hi, vec); }
257 {
return this->do_scan_is(m, lo, hi); }
260 {
return this->do_scan_not(m, lo, hi); }
263 {
return this->do_toupper(c); }
266 {
return this->do_toupper(lo, hi); }
269 {
return this->do_tolower(c); }
272 {
return this->do_tolower(lo, hi); }
275 {
return this->do_widen(c); }
277 const char* widen(
const char* lo,
const char* hi,
Pt::Char* to)
const
278 {
return this->do_widen(lo, hi, to); }
281 {
return this->do_narrow(c, dfault); }
284 char dfault,
char *to)
const
285 {
return this->do_narrow(lo, hi, dfault, to); }
288 virtual bool do_is(mask m,
Pt::Char c)
const;
307 virtual Pt::Char do_widen(
char)
const;
309 virtual const char* do_widen(
const char* lo,
const char* hi,
312 virtual char do_narrow(
Pt::Char,
char dfault)
const;
315 char dfault,
char* dest)
const;
319 #if (defined _MSC_VER || defined __QNX__)
321 class PT_API codecvt<Pt::Char, char, Pt::MBState> :
public codecvt_base {
324 class PT_API codecvt<Pt::Char, char, Pt::MBState> :
public codecvt_base,
public locale::facet {
328 static locale::id id;
331 virtual locale::id& __get_id (
void)
const {
return id; }
334 explicit codecvt(std::size_t ref = 0);
336 codecvt_base::result out(Pt::MBState& state,
342 char*& to_next)
const
343 {
return this->do_out(state, from, from_end, from_next, to, to_end, to_next); }
345 codecvt_base::result unshift(Pt::MBState& state,
348 char*& to_next)
const
349 {
return this->do_unshift(state, to, to_end, to_next); }
351 codecvt_base::result in(Pt::MBState& state,
353 const char* from_end,
354 const char*& from_next,
358 {
return this->do_in(state, from, from_end, from_next, to, to_end, to_next); }
361 {
return this->do_encoding(); }
363 bool always_noconv()
const
364 {
return this->do_always_noconv(); }
366 int length(Pt::MBState& state,
const char* from,
367 const char* end, std::size_t max)
const
368 {
return this->do_length(state, from, end, max); }
370 int max_length()
const
371 {
return this->do_max_length(); }
374 virtual codecvt_base::result do_out(Pt::MBState& state,
380 char*& to_next)
const = 0;
382 virtual codecvt_base::result do_unshift(Pt::MBState& state,
385 char*& to_next)
const = 0;
387 virtual codecvt_base::result do_in(Pt::MBState& state,
389 const char* from_end,
390 const char*& from_next,
395 virtual int do_encoding()
const throw() = 0;
397 virtual
bool do_always_noconv() const throw() = 0;
399 virtual
int do_length(Pt::MBState&,
402 std::
size_t max) const = 0;
404 virtual
int do_max_length() const throw() = 0;
407 #if (defined _MSC_VER || defined __QNX__)
409 class PT_API codecvt<char, char, Pt::MBState> :
public codecvt_base {
412 class PT_API codecvt<char, char, Pt::MBState> :
public codecvt_base,
public locale::facet {
416 static locale::id id;
419 virtual locale::id& __get_id (
void)
const {
return id; }
422 explicit codecvt(std::size_t ref = 0);
424 codecvt_base::result out(Pt::MBState& state,
426 const char* from_end,
427 const char*& from_next,
430 char*& to_next)
const
431 {
return this->do_out(state, from, from_end, from_next, to, to_end, to_next); }
433 codecvt_base::result unshift(Pt::MBState& state,
436 char*& to_next)
const
437 {
return this->do_unshift(state, to, to_end, to_next); }
439 codecvt_base::result in(Pt::MBState& state,
441 const char* from_end,
442 const char*& from_next,
443 char* to,
char* to_end,
444 char*& to_next)
const
445 {
return this->do_in(state, from, from_end, from_next, to, to_end, to_next); }
448 {
return this->do_encoding(); }
450 bool always_noconv()
const
451 {
return this->do_always_noconv(); }
453 int length(Pt::MBState& state,
const char* from,
454 const char* end, std::size_t max)
const
455 {
return this->do_length(state, from, end, max); }
457 int max_length()
const
458 {
return this->do_max_length(); }
461 virtual codecvt_base::result do_out(Pt::MBState& state,
463 const char* from_end,
464 const char*& from_next,
467 char*& to_next)
const = 0;
469 virtual codecvt_base::result do_unshift(Pt::MBState& state,
472 char*& to_next)
const = 0;
474 virtual codecvt_base::result do_in(Pt::MBState& state,
476 const char* from_end,
477 const char*& from_next,
480 char*& to_next)
const = 0;
482 virtual int do_encoding()
const throw() = 0;
484 virtual
bool do_always_noconv() const throw() = 0;
486 virtual
int do_length(Pt::MBState&,
489 std::
size_t max) const = 0;
491 virtual
int do_max_length() const throw() = 0;
498 PT_API
const std::ctype<Pt::Char>& useCType(
const std::locale& loc);
500 PT_API
const std::numpunct<Pt::Char>& useNumPunct(
const std::locale& loc);
502 PT_API
const std::num_get<Pt::Char>& useNumGet(
const std::locale& loc);
504 PT_API
const std::num_put<Pt::Char>& useNumPut(
const std::locale& loc);
511 inline bool has_facet< ctype<Pt::Char> >(
const locale& )
throw()
517 inline const ctype<Pt::Char>& use_facet(
const locale& loc)
519 return Pt::useCType(loc);
524 inline bool has_facet< numpunct<Pt::Char> >(
const locale& )
throw()
530 inline const numpunct<Pt::Char>& use_facet(
const locale& loc)
532 return Pt::useNumPunct(loc);
537 inline bool has_facet< num_get<Pt::Char> >(
const locale& )
throw()
543 inline const num_get<Pt::Char>& use_facet(
const locale& loc)
545 return Pt::useNumGet(loc);
550 inline bool has_facet< num_put<Pt::Char> >(
const locale& )
throw()
556 inline const num_put<Pt::Char>& use_facet(
const locale& loc)
558 return Pt::useNumPut(loc);
R narrow(T from)
Checked numeric conversion.
Definition: Convert.h:112
Unicode character type.
Definition: String.h:66