32 #include <Pt/String.h>
33 #include <Pt/Locale.h>
41 struct __numpunct_cache;
45 class PT_API numpunct<Pt::Char> :
public locale::facet {
48 typedef basic_string<Pt::Char> string_type;
51 typedef __numpunct_cache<Pt::Char> __cache_type;
56 virtual locale::id& __get_id (
void)
const {
return id; }
59 explicit numpunct(std::size_t refs = 0);
63 char_type decimal_point()
const;
65 char_type thousands_sep()
const;
67 string grouping()
const;
69 string_type truename()
const;
71 string_type falsename()
const;
74 virtual char_type do_decimal_point()
const;
76 virtual char_type do_thousands_sep()
const;
78 virtual string do_grouping()
const;
80 virtual string_type do_truename()
const;
82 virtual string_type do_falsename()
const;
87 class PT_API num_put< Pt::Char,
88 ostreambuf_iterator<Pt::Char> > :
public locale::facet
92 typedef ostreambuf_iterator<Pt::Char> iter_type;
94 explicit num_put(std::size_t refs = 0)
98 iter_type put(iter_type s, ios_base& f, char_type fill,
bool val)
const
99 {
return this->do_put( s, f, fill, val ); }
102 iter_type put(iter_type s, ios_base& f, char_type fill,
int val)
const
103 {
return this->do_put( s, f, fill,
long(val) ); }
106 iter_type put(iter_type s, ios_base& 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, ios_base& f, char_type fill,
long val)
const
110 {
return this->do_put( s, f, fill, val ); }
112 iter_type put(iter_type s, ios_base& f, char_type fill,
unsigned long val)
const
113 {
return this->do_put( s, f, fill, val ); }
115 iter_type put(iter_type s, ios_base& f, char_type fill,
long long val)
const
116 {
return this->do_put( s, f, fill, val ); }
118 iter_type put(iter_type s, ios_base& 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, ios_base& f, char_type fill,
double val)
const
122 {
return this->do_put( s, f, fill, val ); }
124 iter_type put(iter_type s, ios_base& f, char_type fill,
long double val)
const
125 {
return this->do_put( s, f, fill, val ); }
127 iter_type put(iter_type s, ios_base& 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
140 virtual iter_type do_put(iter_type s, ios_base& f, char_type fill,
bool val)
const;
142 virtual iter_type do_put(iter_type s, ios_base& f, char_type fill,
long val)
const;
144 virtual iter_type do_put(iter_type s, ios_base& f, char_type fill,
unsigned long val)
const;
146 virtual iter_type do_put(iter_type s, ios_base& f, char_type fill,
long long val)
const;
148 virtual iter_type do_put(iter_type s, ios_base& f, char_type fill,
unsigned long long val)
const;
150 virtual iter_type do_put(iter_type s, ios_base& f, char_type fill,
double val)
const;
152 virtual iter_type do_put(iter_type s, ios_base& f, char_type fill,
long double val)
const;
154 virtual iter_type do_put(iter_type s, ios_base& f, char_type fill,
const void*)
const;
159 class PT_API num_get< Pt::Char,
160 istreambuf_iterator<Pt::Char> > :
public locale::facet
164 typedef istreambuf_iterator<Pt::Char> iter_type;
166 explicit num_get(std::size_t refs = 0)
167 : locale::facet(refs)
170 iter_type
get(iter_type it, iter_type end, ios_base& f, ios_base::iostate& s,
bool& val)
const
171 {
return this->do_get(it, end, f, s, val); }
173 iter_type
get(iter_type it, iter_type end, ios_base& f, ios_base::iostate& s,
long& val)
const
174 {
return this->do_get(it, end, f, s, val); }
176 iter_type
get(iter_type it, iter_type end, ios_base& f, ios_base::iostate& s,
long long int& val)
const
177 {
return this->do_get(it, end, f, s, val); }
179 iter_type
get(iter_type it, iter_type end, ios_base& f, ios_base::iostate& s,
unsigned short& val)
const
180 {
return this->do_get(it, end, f, s, val); }
182 iter_type
get(iter_type it, iter_type end, ios_base& f, ios_base::iostate& s,
unsigned int& val)
const
183 {
return this->do_get(it, end, f, s, val); }
185 iter_type
get(iter_type it, iter_type end, ios_base& f, ios_base::iostate& s,
unsigned long& val)
const
186 {
return this->do_get(it, end, f, s, val); }
188 iter_type
get(iter_type it, iter_type end, ios_base& f, ios_base::iostate& s,
unsigned long long & val)
const
189 {
return this->do_get(it, end, f, s, val); }
191 iter_type
get(iter_type it, iter_type end, ios_base& f, ios_base::iostate& s,
float& val)
const
192 {
return this->do_get(it, end, f, s, val); }
194 iter_type
get(iter_type it, iter_type end, ios_base& f, ios_base::iostate& s,
double& val)
const
195 {
return this->do_get(it, end, f, s, val); }
197 iter_type
get(iter_type it, iter_type end, ios_base& f, ios_base::iostate& s,
long double& val)
const
198 {
return this->do_get(it, end, f, s, val); }
200 iter_type
get(iter_type it, iter_type end, ios_base& f, ios_base::iostate& s,
void*& val)
const
201 {
return this->do_get(it, end, f, s, val); }
203 static locale::id id;
206 virtual locale::id& __get_id (
void)
const
210 virtual iter_type do_get(iter_type, iter_type, ios_base&, ios_base::iostate&,
bool&)
const;
212 virtual iter_type do_get(iter_type, iter_type, ios_base&, ios_base::iostate&,
long&)
const;
214 virtual iter_type do_get(iter_type, iter_type, ios_base&, ios_base::iostate&,
long long&)
const;
216 virtual iter_type do_get(iter_type, iter_type, ios_base&, ios_base::iostate&,
unsigned short&)
const;
218 virtual iter_type do_get(iter_type, iter_type, ios_base&, ios_base::iostate&,
unsigned int&)
const;
220 virtual iter_type do_get(iter_type, iter_type, ios_base&, ios_base::iostate&,
unsigned long&)
const;
222 virtual iter_type do_get(iter_type, iter_type, ios_base&, ios_base::iostate&,
unsigned long long&)
const;
224 virtual iter_type do_get(iter_type, iter_type, ios_base&, ios_base::iostate&,
float&)
const;
226 virtual iter_type do_get(iter_type, iter_type, ios_base&, ios_base::iostate&,
double&)
const;
228 virtual iter_type do_get(iter_type, iter_type, ios_base&, ios_base::iostate&,
long double&)
const;
230 virtual iter_type do_get(iter_type, iter_type, ios_base&, ios_base::iostate&,
void*&)
const;
234 #if (defined _MSC_VER || defined __QNX__ || defined __xlC__)
236 class PT_API ctype< Pt::Char > :
public ctype_base {
239 class PT_API ctype<Pt::Char> :
public ctype_base,
public locale::facet {
243 typedef ctype_base::mask mask;
245 static locale::id id;
248 virtual locale::id& __get_id (
void)
const {
return id; }
251 explicit ctype(std::size_t refs = 0);
256 {
return this->do_is(m, c); }
259 {
return this->do_is(lo, hi, vec); }
262 {
return this->do_scan_is(m, lo, hi); }
265 {
return this->do_scan_not(m, lo, hi); }
268 {
return this->do_toupper(c); }
271 {
return this->do_toupper(lo, hi); }
274 {
return this->do_tolower(c); }
277 {
return this->do_tolower(lo, hi); }
280 {
return this->do_widen(c); }
282 const char* widen(
const char* lo,
const char* hi,
Pt::Char* to)
const
283 {
return this->do_widen(lo, hi, to); }
286 {
return this->do_narrow(c, dfault); }
289 char dfault,
char *to)
const
290 {
return this->do_narrow(lo, hi, dfault, to); }
293 virtual bool do_is(mask m,
Pt::Char c)
const;
312 virtual Pt::Char do_widen(
char)
const;
314 virtual const char* do_widen(
const char* lo,
const char* hi,
317 virtual char do_narrow(
Pt::Char,
char dfault)
const;
320 char dfault,
char* dest)
const;
324 #if (defined _MSC_VER || defined __QNX__)
326 class PT_API codecvt<Pt::Char, char, Pt::MBState> :
public codecvt_base {
329 class PT_API codecvt<Pt::Char, char, Pt::MBState> :
public codecvt_base,
public locale::facet {
333 static locale::id id;
336 virtual locale::id& __get_id (
void)
const {
return id; }
339 explicit codecvt(std::size_t ref = 0);
343 codecvt_base::result out(Pt::MBState& state,
349 char*& to_next)
const
350 {
return this->do_out(state, from, from_end, from_next, to, to_end, to_next); }
352 codecvt_base::result unshift(Pt::MBState& state,
355 char*& to_next)
const
356 {
return this->do_unshift(state, to, to_end, to_next); }
358 codecvt_base::result in(Pt::MBState& state,
360 const char* from_end,
361 const char*& from_next,
365 {
return this->do_in(state, from, from_end, from_next, to, to_end, to_next); }
368 {
return this->do_encoding(); }
370 bool always_noconv()
const
371 {
return this->do_always_noconv(); }
373 int length(Pt::MBState& state,
const char* from,
374 const char* end, std::size_t max)
const
375 {
return this->do_length(state, from, end, max); }
377 int max_length()
const
378 {
return this->do_max_length(); }
381 virtual codecvt_base::result do_out(Pt::MBState& state,
387 char*& to_next)
const = 0;
389 virtual codecvt_base::result do_unshift(Pt::MBState& state,
392 char*& to_next)
const = 0;
394 virtual codecvt_base::result do_in(Pt::MBState& state,
396 const char* from_end,
397 const char*& from_next,
402 virtual int do_encoding()
const throw() = 0;
404 virtual
bool do_always_noconv() const throw() = 0;
406 virtual
int do_length(Pt::MBState&,
409 std::
size_t max) const = 0;
411 virtual
int do_max_length() const throw() = 0;
414 #if (defined _MSC_VER || defined __QNX__)
416 class PT_API codecvt<char, char, Pt::MBState> :
public codecvt_base {
419 class PT_API codecvt<char, char, Pt::MBState> :
public codecvt_base,
public locale::facet {
423 static locale::id id;
426 virtual locale::id& __get_id (
void)
const {
return id; }
429 explicit codecvt(std::size_t ref = 0);
433 codecvt_base::result out(Pt::MBState& state,
435 const char* from_end,
436 const char*& from_next,
439 char*& to_next)
const
440 {
return this->do_out(state, from, from_end, from_next, to, to_end, to_next); }
442 codecvt_base::result unshift(Pt::MBState& state,
445 char*& to_next)
const
446 {
return this->do_unshift(state, to, to_end, to_next); }
448 codecvt_base::result in(Pt::MBState& state,
450 const char* from_end,
451 const char*& from_next,
452 char* to,
char* to_end,
453 char*& to_next)
const
454 {
return this->do_in(state, from, from_end, from_next, to, to_end, to_next); }
457 {
return this->do_encoding(); }
459 bool always_noconv()
const
460 {
return this->do_always_noconv(); }
462 int length(Pt::MBState& state,
const char* from,
463 const char* end, std::size_t max)
const
464 {
return this->do_length(state, from, end, max); }
466 int max_length()
const
467 {
return this->do_max_length(); }
470 virtual codecvt_base::result do_out(Pt::MBState& state,
472 const char* from_end,
473 const char*& from_next,
476 char*& to_next)
const = 0;
478 virtual codecvt_base::result do_unshift(Pt::MBState& state,
481 char*& to_next)
const = 0;
483 virtual codecvt_base::result do_in(Pt::MBState& state,
485 const char* from_end,
486 const char*& from_next,
489 char*& to_next)
const = 0;
491 virtual int do_encoding()
const throw() = 0;
493 virtual
bool do_always_noconv() const throw() = 0;
495 virtual
int do_length(Pt::MBState&,
498 std::
size_t max) const = 0;
500 virtual
int do_max_length() const throw() = 0;
508 static std::ios_base::Init pt_stream_init;
510 static struct PT_API InitLocale
514 std::locale::global( std::locale(std::locale(),
new std::ctype<Pt::Char>) );
515 std::locale::global( std::locale(std::locale(),
new std::numpunct<Pt::Char>) );
516 std::locale::global( std::locale(std::locale(),
new std::num_get<Pt::Char>) );
517 std::locale::global( std::locale(std::locale(),
new std::num_put<Pt::Char>) );
R narrow(T from)
Checked numeric conversion.
Definition: Convert.h:112
Unicode character type.
Definition: String.h:66