]>
Commit | Line | Data |
---|---|---|
725dc051 BK |
1 | // Locale support -*- C++ -*- |
2 | ||
3 | // Copyright (C) 1997-2000 Free Software Foundation, Inc. | |
4 | // | |
5 | // This file is part of the GNU ISO C++ Library. This library is free | |
6 | // software; you can redistribute it and/or modify it under the | |
7 | // terms of the GNU General Public License as published by the | |
8 | // Free Software Foundation; either version 2, or (at your option) | |
9 | // any later version. | |
10 | ||
11 | // This library is distributed in the hope that it will be useful, | |
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | // GNU General Public License for more details. | |
15 | ||
16 | // You should have received a copy of the GNU General Public License along | |
17 | // with this library; see the file COPYING. If not, write to the Free | |
18 | // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
19 | // USA. | |
20 | ||
21 | // As a special exception, you may use this file as part of a free software | |
22 | // library without restriction. Specifically, if other files instantiate | |
23 | // templates or use macros or inline functions from this file, or you compile | |
24 | // this file and link it with other files to produce an executable, this | |
25 | // file does not by itself cause the resulting executable to be covered by | |
26 | // the GNU General Public License. This exception does not however | |
27 | // invalidate any other reasons why the executable file might be covered by | |
28 | // the GNU General Public License. | |
29 | ||
30 | // | |
31 | // ISO C++ 14882: 22.1 Locales | |
32 | // | |
33 | ||
34 | // Warning: this file is not meant for user inclusion. Use <locale>. | |
35 | ||
36 | #ifndef _CPP_BITS_LOCFACETS_H | |
37 | #define _CPP_BITS_LOCFACETS_H 1 | |
38 | ||
39 | #include <bits/std_ctime.h> // For struct tm | |
a6863e25 | 40 | #include <typeinfo> // For bad_cast, which shouldn't be here. |
725dc051 | 41 | #include <bits/std_ios.h> // For ios_base |
3c97056f | 42 | #ifdef _GLIBCPP_USE_WCHAR_T |
167ed88f BK |
43 | # include <bits/std_cwctype.h> // For wctype_t |
44 | #endif | |
725dc051 BK |
45 | |
46 | namespace std | |
47 | { | |
48 | // XXX This function is to be specialized for the "required" facets to | |
49 | // be constructed lazily. The specializations must be declared after | |
50 | // the definitions of the facets themselves; but they shouldn't be | |
51 | // inline. Corresponding new's in locale::classic() should then be | |
52 | // eliminated. Note that ctype<> should not get this treatment; | |
53 | // see the use_facet<> specializations below. | |
54 | // | |
55 | struct _Bad_use_facet : public bad_cast | |
56 | { | |
57 | _Bad_use_facet() throw() {} | |
58 | ||
59 | _Bad_use_facet(_Bad_use_facet const& __b) throw() | |
60 | : bad_cast(__b) { } | |
61 | ||
62 | _Bad_use_facet& | |
63 | operator=(_Bad_use_facet const& __b) throw() | |
64 | { | |
65 | static_cast<bad_cast*>(this)->operator=(__b); | |
66 | return *this; | |
67 | } | |
68 | ||
69 | virtual char const* | |
70 | what() const throw(); | |
71 | ||
72 | virtual | |
73 | ~_Bad_use_facet() throw(); | |
74 | }; | |
75 | ||
76 | template<typename _Facet> | |
77 | const _Facet& | |
78 | _Use_facet_failure_handler(const locale&) | |
79 | { throw _Bad_use_facet(); } | |
80 | ||
81 | // 22.2.1 The ctype category | |
82 | // Include host-specific ctype enums for ctype_base. | |
83 | #include <bits/ctype_base.h> | |
84 | ||
85 | // 22.2.1.1 Template class ctype | |
167ed88f | 86 | // __ctype_abstract_base is the common base for ctype<_CharT>. |
725dc051 | 87 | template<typename _CharT> |
167ed88f | 88 | class __ctype_abstract_base : public locale::facet, public ctype_base |
725dc051 BK |
89 | { |
90 | public: | |
91 | // Types: | |
92 | typedef _CharT char_type; | |
93 | ||
167ed88f BK |
94 | bool |
95 | is(mask __m, char_type __c) const | |
96 | { return this->do_is(__m, __c); } | |
97 | ||
98 | const char_type* | |
99 | is(const char_type *__lo, const char_type *__hi, mask *__vec) const | |
100 | { return this->do_is(__lo, __hi, __vec); } | |
101 | ||
102 | const char_type* | |
103 | scan_is(mask __m, const char_type* __lo, const char_type* __hi) const | |
104 | { return this->do_scan_is(__m, __lo, __hi); } | |
105 | ||
106 | const char_type* | |
107 | scan_not(mask __m, const char_type* __lo, const char_type* __hi) const | |
108 | { return this->do_scan_not(__m, __lo, __hi); } | |
109 | ||
725dc051 BK |
110 | char_type |
111 | toupper(char_type __c) const | |
112 | { return this->do_toupper(__c); } | |
113 | ||
114 | const char_type* | |
115 | toupper(char_type *__low, const char_type* __high) const | |
116 | { return this->do_toupper(__low, __high); } | |
117 | ||
118 | char_type | |
119 | tolower(char_type __c) const | |
120 | { return this->do_tolower(__c); } | |
121 | ||
122 | const char_type* | |
123 | tolower(char_type* __low, const char_type* __high) const | |
124 | { return this->do_tolower(__low, __high); } | |
125 | ||
126 | char_type | |
127 | widen(char __c) const | |
128 | { return this->do_widen(__c); } | |
129 | ||
130 | const char* | |
131 | widen(const char* __low, const char* __high, char_type* __to) const | |
132 | { return this->do_widen(__low, __high, __to); } | |
133 | ||
134 | char | |
135 | narrow(char_type __c, char __dfault) const | |
136 | { return this->do_narrow(__c, __dfault); } | |
137 | ||
138 | const char_type* | |
139 | narrow(const char_type* __low, const char_type* __high, | |
140 | char __dfault, char *__to) const | |
141 | { return this->do_narrow(__low, __high, __dfault, __to); } | |
142 | ||
143 | protected: | |
144 | explicit | |
167ed88f | 145 | __ctype_abstract_base(size_t __refs = 0): locale::facet(__refs) { } |
725dc051 BK |
146 | |
147 | virtual | |
167ed88f | 148 | ~__ctype_abstract_base() { } |
725dc051 | 149 | |
167ed88f BK |
150 | virtual bool |
151 | do_is(mask __m, char_type __c) const = 0; | |
152 | ||
153 | virtual const char_type* | |
154 | do_is(const char_type* __lo, const char_type* __hi, | |
155 | mask* __vec) const = 0; | |
156 | ||
157 | virtual const char_type* | |
158 | do_scan_is(mask __m, const char_type* __lo, | |
159 | const char_type* __hi) const = 0; | |
160 | ||
161 | virtual const char_type* | |
162 | do_scan_not(mask __m, const char_type* __lo, | |
163 | const char_type* __hi) const = 0; | |
164 | ||
725dc051 BK |
165 | virtual char_type |
166 | do_toupper(char_type) const = 0; | |
167 | ||
168 | virtual const char_type* | |
169 | do_toupper(char_type* __low, const char_type* __high) const = 0; | |
170 | ||
171 | virtual char_type | |
172 | do_tolower(char_type) const = 0; | |
173 | ||
174 | virtual const char_type* | |
175 | do_tolower(char_type* __low, const char_type* __high) const = 0; | |
176 | ||
177 | virtual char_type | |
178 | do_widen(char) const = 0; | |
179 | ||
180 | virtual const char* | |
181 | do_widen(const char* __low, const char* __high, | |
182 | char_type* __dest) const = 0; | |
183 | ||
184 | virtual char | |
185 | do_narrow(char_type, char __dfault) const = 0; | |
186 | ||
187 | virtual const char_type* | |
188 | do_narrow(const char_type* __low, const char_type* __high, | |
189 | char __dfault, char* __dest) const = 0; | |
190 | }; | |
191 | ||
167ed88f | 192 | // NB: Generic, mostly useless implementation. |
725dc051 | 193 | template<typename _CharT> |
167ed88f | 194 | class ctype : public __ctype_abstract_base<_CharT> |
725dc051 BK |
195 | { |
196 | public: | |
197 | // Types: | |
167ed88f BK |
198 | typedef _CharT char_type; |
199 | typedef typename ctype::mask mask; | |
725dc051 BK |
200 | |
201 | explicit | |
167ed88f | 202 | ctype(size_t __refs = 0) : __ctype_abstract_base<_CharT>(__refs) { } |
725dc051 BK |
203 | |
204 | static locale::id id; | |
205 | ||
206 | protected: | |
207 | virtual | |
208 | ~ctype() { } | |
725dc051 BK |
209 | }; |
210 | ||
725dc051 | 211 | // 22.2.1.3 ctype specializations |
725dc051 | 212 | template<> |
167ed88f | 213 | class ctype<char> : public __ctype_abstract_base<char> |
725dc051 BK |
214 | { |
215 | public: | |
216 | // Types: | |
217 | typedef char char_type; | |
218 | typedef ctype::mask mask; | |
219 | ||
220 | private: | |
221 | // Data Members: | |
222 | bool _M_del; | |
223 | __to_type const& _M_toupper; | |
224 | __to_type const& _M_tolower; | |
225 | const mask* const& _M_ctable; | |
4716be24 | 226 | const mask* _M_table; |
725dc051 BK |
227 | |
228 | public: | |
229 | static locale::id id; | |
230 | static const size_t table_size = 1 + static_cast<unsigned char>(-1); | |
231 | ||
232 | explicit | |
233 | ctype(const mask* __table = 0, bool __del = false, size_t __refs = 0); | |
234 | ||
235 | inline bool | |
236 | is(mask __m, char __c) const throw(); | |
237 | ||
238 | inline const char* | |
239 | is(const char* __low, const char* __high, mask* __vec) const throw(); | |
240 | ||
241 | inline const char* | |
242 | scan_is(mask __m, const char* __low, const char* __high) const throw(); | |
243 | ||
244 | inline const char* | |
245 | scan_not(mask __m, const char* __low, const char* __high) const throw(); | |
246 | ||
247 | protected: | |
248 | virtual | |
249 | ~ctype(); | |
250 | ||
251 | // XXX | |
252 | const mask* | |
253 | table() const throw() | |
254 | { return _M_table; } | |
255 | ||
256 | // XXX | |
257 | const mask* | |
258 | classic_table() throw() | |
259 | { return _M_ctable; } | |
260 | ||
167ed88f BK |
261 | virtual bool |
262 | do_is(mask __m, char_type __c) const; | |
263 | ||
264 | virtual const char_type* | |
265 | do_is(const char_type* __lo, const char_type* __hi, | |
266 | mask* __vec) const; | |
267 | ||
268 | virtual const char_type* | |
269 | do_scan_is(mask __m, const char_type* __lo, | |
270 | const char_type* __hi) const; | |
271 | ||
272 | virtual const char_type* | |
273 | do_scan_not(mask __m, const char_type* __lo, | |
274 | const char_type* __hi) const; | |
275 | ||
725dc051 BK |
276 | virtual char_type |
277 | do_toupper(char_type) const; | |
278 | ||
279 | virtual const char_type* | |
280 | do_toupper(char_type* __low, const char_type* __high) const; | |
281 | ||
282 | virtual char_type | |
283 | do_tolower(char_type) const; | |
284 | ||
285 | virtual const char_type* | |
286 | do_tolower(char_type* __low, const char_type* __high) const; | |
287 | ||
288 | virtual char_type | |
289 | do_widen(char) const; | |
290 | ||
291 | virtual const char* | |
292 | do_widen(const char* __low, const char* __high, | |
293 | char_type* __dest) const; | |
294 | ||
295 | virtual char | |
296 | do_narrow(char_type, char __dfault) const; | |
297 | ||
298 | virtual const char_type* | |
299 | do_narrow(const char_type* __low, const char_type* __high, | |
300 | char __dfault, char* __dest) const; | |
301 | }; | |
302 | ||
303 | template<> | |
304 | const ctype<char>& | |
697649ea | 305 | use_facet<ctype<char> >(const locale& __loc); |
725dc051 BK |
306 | |
307 | #ifdef _GLIBCPP_USE_WCHAR_T | |
308 | // ctype<wchar_t> specialization | |
309 | template<> | |
167ed88f | 310 | class ctype<wchar_t> : public __ctype_abstract_base<wchar_t> |
725dc051 BK |
311 | { |
312 | public: | |
313 | // Types: | |
314 | typedef wchar_t char_type; | |
315 | typedef ctype::mask mask; | |
316 | typedef wctype_t __wmask_type; | |
317 | ||
318 | // Data Members: | |
319 | static locale::id id; | |
320 | ||
321 | explicit | |
322 | ctype(size_t __refs = 0); | |
323 | ||
324 | protected: | |
325 | __wmask_type | |
167ed88f | 326 | _M_convert_to_wmask(const mask __m) const; |
725dc051 BK |
327 | |
328 | virtual | |
329 | ~ctype(); | |
330 | ||
331 | virtual bool | |
332 | do_is(mask __m, char_type __c) const; | |
333 | ||
334 | virtual const char_type* | |
335 | do_is(const char_type* __lo, const char_type* __hi, | |
336 | mask* __vec) const; | |
337 | ||
338 | virtual const char_type* | |
339 | do_scan_is(mask __m, const char_type* __lo, | |
340 | const char_type* __hi) const; | |
341 | ||
342 | virtual const char_type* | |
343 | do_scan_not(mask __m, const char_type* __lo, | |
344 | const char_type* __hi) const; | |
345 | ||
346 | virtual char_type | |
347 | do_toupper(char_type) const; | |
348 | ||
349 | virtual const char_type* | |
350 | do_toupper(char_type* __low, const char_type* __high) const; | |
351 | ||
352 | virtual char_type | |
353 | do_tolower(char_type) const; | |
354 | ||
355 | virtual const char_type* | |
356 | do_tolower(char_type* __low, const char_type* __high) const; | |
357 | ||
358 | virtual char_type | |
359 | do_widen(char) const; | |
360 | ||
361 | virtual const char* | |
362 | do_widen(const char* __low, const char* __high, | |
363 | char_type* __dest) const; | |
364 | ||
365 | virtual char | |
366 | do_narrow(char_type, char __dfault) const; | |
367 | ||
368 | virtual const char_type* | |
369 | do_narrow(const char_type* __low, const char_type* __high, | |
370 | char __dfault, char* __dest) const; | |
371 | ||
372 | }; | |
373 | ||
374 | template<> | |
375 | const ctype<wchar_t>& | |
697649ea | 376 | use_facet<ctype<wchar_t> >(const locale& __loc); |
725dc051 BK |
377 | #endif //_GLIBCPP_USE_WCHAR_T |
378 | ||
e974e9cc BK |
379 | // Include host-specific ctype inlines. |
380 | #include <bits/ctype_inline.h> | |
725dc051 BK |
381 | |
382 | // 22.2.1.2 Template class ctype_byname | |
383 | template<typename _CharT> | |
384 | class ctype_byname : public ctype<_CharT> | |
385 | { | |
386 | public: | |
387 | typedef _CharT char_type; | |
388 | ||
389 | explicit | |
390 | ctype_byname(const char*, size_t __refs = 0); | |
391 | ||
392 | protected: | |
393 | virtual | |
394 | ~ctype_byname() { } | |
395 | }; | |
396 | ||
167ed88f | 397 | // 22.2.1.4 Class ctype_byname specialization |
725dc051 BK |
398 | template<> |
399 | ctype_byname<char>::ctype_byname(const char*, size_t refs); | |
725dc051 BK |
400 | |
401 | ||
402 | template<typename _CharT, typename _InIter> | |
403 | class _Numeric_get; // forward | |
404 | ||
405 | // _Format_cache holds the information extracted from the numpunct<> | |
406 | // and moneypunct<> facets in a form optimized for parsing and | |
407 | // formatting. It is stored via a void* pointer in the pword() | |
408 | // array of an iosbase object passed to the _get and _put facets. | |
409 | // NB: contains no user-serviceable parts. | |
410 | template<typename _CharT> | |
411 | class _Format_cache | |
412 | { | |
413 | public: | |
414 | // Types: | |
415 | typedef _CharT char_type; | |
416 | typedef char_traits<_CharT> traits_type; | |
417 | typedef basic_string<_CharT> string_type; | |
418 | typedef typename string_type::size_type size_type; | |
419 | ||
420 | // Forward decls and Friends: | |
421 | friend class locale; | |
422 | template<typename _Char, typename _InIter> | |
423 | friend class _Numeric_get; | |
424 | friend class num_get<_CharT>; | |
425 | friend class num_put<_CharT>; | |
426 | friend class time_get<_CharT>; | |
427 | friend class money_get<_CharT>; | |
428 | friend class time_put<_CharT>; | |
429 | friend class money_put<_CharT>; | |
430 | ||
431 | // Data Members: | |
432 | ||
433 | // ios_base::pword() reserved cell | |
434 | static int _S_pword_ix; | |
435 | ||
436 | // True iff data members are consistent with the current locale, | |
437 | // ie imbue sets this to false. | |
438 | bool _M_valid; | |
439 | ||
440 | // A list of valid numeric literals: for the standard "C" locale, | |
441 | // this would usually be: "-+xX0123456789abcdef0123456789ABCDEF" | |
442 | static const char _S_literals[]; | |
443 | ||
444 | // NB: Code depends on the order of definitions of the names | |
445 | // these are indices into _S_literals, above. | |
446 | // This string is formatted for putting, not getting. (output, not input) | |
447 | enum | |
448 | { | |
449 | _S_minus, | |
450 | _S_plus, | |
451 | _S_x, | |
452 | _S_X, | |
453 | _S_digits, | |
454 | _S_digits_end = _S_digits + 16, | |
455 | _S_udigits = _S_digits_end, | |
456 | _S_udigits_end = _S_udigits + 16, | |
457 | _S_ee = _S_digits + 14, // For scientific notation, 'E' | |
458 | _S_Ee = _S_udigits + 14 // For scientific notation, 'e' | |
459 | }; | |
460 | ||
461 | // The sign used to separate decimal values: for standard US | |
462 | // locales, this would usually be: "." | |
463 | // Abstracted from numpunct::decimal_point(). | |
464 | char_type _M_decimal_point; | |
465 | ||
466 | // The sign used to separate groups of digits into smaller | |
467 | // strings that the eye can parse with less difficulty: for | |
468 | // standard US locales, this would usually be: "," | |
469 | // Abstracted from numpunct::thousands_sep(). | |
470 | char_type _M_thousands_sep; | |
471 | ||
472 | // However the US's "false" and "true" are translated. | |
473 | // From numpunct::truename() and numpunct::falsename(), respectively. | |
474 | string_type _M_truename; | |
475 | string_type _M_falsename; | |
476 | ||
477 | // If we are checking groupings. This should be equivalent to | |
478 | // numpunct::groupings().size() != 0 | |
479 | bool _M_use_grouping; | |
480 | ||
481 | // If we are using numpunct's groupings, this is the current | |
482 | // grouping string in effect (from numpunct::grouping()). | |
483 | string _M_grouping; | |
484 | ||
485 | _Format_cache(); | |
486 | ||
487 | ~_Format_cache() throw() { } | |
488 | ||
489 | // Given a member of the ios heirarchy as an argument, extract | |
490 | // out all the current formatting information into a | |
491 | // _Format_cache object and return a pointer to it. | |
492 | static _Format_cache<_CharT>* | |
493 | _S_get(ios_base& __ios); | |
494 | ||
495 | void | |
496 | _M_populate(ios_base&); | |
497 | ||
498 | static void | |
499 | _S_callback(ios_base::event __event, ios_base& __ios, int __ix) throw(); | |
500 | }; | |
501 | ||
502 | template<> _Format_cache<char>::_Format_cache(); | |
503 | #ifdef _GLIBCPP_USE_WCHAR_T | |
504 | template<> _Format_cache<wchar_t>::_Format_cache(); | |
505 | #endif | |
506 | ||
507 | // _Numeric_get is used by num_get, money_get, and time_get to help | |
508 | // in parsing out numbers. | |
509 | template<typename _CharT, typename _InIter> | |
510 | class _Numeric_get | |
511 | { | |
512 | public: | |
513 | // Types: | |
514 | typedef _CharT char_type; | |
515 | typedef _InIter iter_type; | |
516 | ||
517 | // Forward decls and Friends: | |
518 | template<typename _Char, typename _InIterT> | |
519 | friend class num_get; | |
520 | template<typename _Char, typename _InIterT> | |
521 | friend class time_get; | |
522 | template<typename _Char, typename _InIterT> | |
523 | friend class money_get; | |
524 | template<typename _Char, typename _InIterT> | |
525 | friend class num_put; | |
526 | template<typename _Char, typename _InIterT> | |
527 | friend class time_put; | |
528 | template<typename _Char, typename _InIterT> | |
529 | friend class money_put; | |
530 | ||
531 | private: | |
532 | explicit | |
533 | _Numeric_get() { } | |
534 | ||
535 | virtual | |
536 | ~_Numeric_get() { } | |
537 | ||
538 | iter_type | |
539 | _M_get_digits(iter_type __in, iter_type __end) const; | |
540 | }; | |
541 | ||
542 | template<typename _CharT, typename _InIter> | |
543 | class num_get : public locale::facet | |
544 | { | |
545 | public: | |
546 | // Types: | |
547 | typedef _CharT char_type; | |
548 | typedef _InIter iter_type; | |
549 | typedef char_traits<_CharT> __traits_type; | |
550 | ||
551 | static locale::id id; | |
552 | ||
553 | explicit | |
554 | num_get(size_t __refs = 0) : locale::facet(__refs) { } | |
555 | ||
556 | iter_type | |
557 | get(iter_type __in, iter_type __end, ios_base& __io, | |
558 | ios_base::iostate& __err, bool& __v) const | |
559 | { return do_get(__in, __end, __io, __err, __v); } | |
560 | ||
561 | #ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS | |
562 | iter_type | |
563 | get(iter_type __in, iter_type __end, ios_base& __io, | |
564 | ios_base::iostate& __err, short& __v) const | |
565 | { return do_get(__in, __end, __io, __err, __v); } | |
566 | ||
567 | iter_type | |
568 | get(iter_type __in, iter_type __end, ios_base& __io, | |
569 | ios_base::iostate& __err, int& __v) const | |
570 | { return do_get(__in, __end, __io, __err, __v); } | |
571 | #endif | |
572 | ||
573 | iter_type | |
574 | get(iter_type __in, iter_type __end, ios_base& __io, | |
575 | ios_base::iostate& __err, long& __v) const | |
576 | { return do_get(__in, __end, __io, __err, __v); } | |
577 | ||
578 | #ifdef _GLIBCPP_USE_LONG_LONG | |
579 | iter_type | |
580 | get(iter_type __in, iter_type __end, ios_base& __io, | |
581 | ios_base::iostate& __err, long long& __v) const | |
582 | { return do_get(__in, __end, __io, __err, __v); } | |
583 | #endif | |
584 | ||
585 | iter_type | |
586 | get(iter_type __in, iter_type __end, ios_base& __io, | |
587 | ios_base::iostate& __err, unsigned short& __v) const | |
588 | { return do_get(__in, __end, __io, __err, __v); } | |
589 | ||
590 | iter_type | |
591 | get(iter_type __in, iter_type __end, ios_base& __io, | |
592 | ios_base::iostate& __err, unsigned int& __v) const | |
593 | { return do_get(__in, __end, __io, __err, __v); } | |
594 | ||
595 | iter_type | |
596 | get(iter_type __in, iter_type __end, ios_base& __io, | |
597 | ios_base::iostate& __err, unsigned long& __v) const | |
598 | { return do_get(__in, __end, __io, __err, __v); } | |
599 | ||
600 | #ifdef _GLIBCPP_USE_LONG_LONG | |
601 | iter_type | |
602 | get(iter_type __in, iter_type __end, ios_base& __io, | |
603 | ios_base::iostate& __err, unsigned long long& __v) const | |
604 | { return do_get(__in, __end, __io, __err, __v); } | |
605 | #endif | |
606 | ||
607 | iter_type | |
608 | get(iter_type __in, iter_type __end, ios_base& __io, | |
609 | ios_base::iostate& __err, float& __v) const | |
610 | { return do_get(__in, __end, __io, __err, __v); } | |
611 | ||
612 | iter_type | |
613 | get(iter_type __in, iter_type __end, ios_base& __io, | |
614 | ios_base::iostate& __err, double& __v) const | |
615 | { return do_get(__in, __end, __io, __err, __v); } | |
616 | ||
617 | iter_type | |
618 | get(iter_type __in, iter_type __end, ios_base& __io, | |
619 | ios_base::iostate& __err, long double& __v) const | |
620 | { return do_get(__in, __end, __io, __err, __v); } | |
621 | ||
622 | iter_type | |
623 | get(iter_type __in, iter_type __end, ios_base& __io, | |
624 | ios_base::iostate& __err, void*& __v) const | |
625 | { return do_get(__in, __end, __io, __err, __v); } | |
626 | ||
627 | protected: | |
628 | virtual ~num_get() { } | |
629 | ||
630 | // This consolidates the extraction, storage and | |
631 | // error-processing parts of the do_get(...) overloaded member | |
632 | // functions. | |
633 | // NB: This is specialized for char. | |
634 | void | |
635 | _M_extract(iter_type __beg, iter_type __end, ios_base& __io, | |
636 | ios_base::iostate& __err, char* __xtrc, | |
637 | int& __base, bool __fp = true) const; | |
638 | ||
639 | virtual iter_type | |
640 | do_get(iter_type, iter_type, ios_base&, ios_base::iostate&, bool&) const; | |
641 | ||
642 | #ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS | |
643 | virtual iter_type | |
644 | do_get(iter_type, iter_type, ios_base&, ios_base::iostate&, short&) const; | |
645 | virtual iter_type | |
646 | do_get(iter_type, iter_type, ios_base&, ios_base::iostate&, int&) const; | |
647 | #endif | |
648 | virtual iter_type | |
649 | do_get (iter_type, iter_type, ios_base&, ios_base::iostate&, long&) const; | |
650 | #ifdef _GLIBCPP_USE_LONG_LONG | |
651 | virtual iter_type | |
652 | do_get(iter_type, iter_type, ios_base&, ios_base::iostate& __err, | |
653 | long long&) const; | |
654 | #endif | |
655 | virtual iter_type | |
656 | do_get(iter_type, iter_type, ios_base&, ios_base::iostate& __err, | |
657 | unsigned short&) const; | |
658 | virtual iter_type | |
659 | do_get(iter_type, iter_type, ios_base&, | |
660 | ios_base::iostate& __err, unsigned int&) const; | |
661 | virtual iter_type | |
662 | do_get(iter_type, iter_type, ios_base&, | |
663 | ios_base::iostate& __err, unsigned long&) const; | |
664 | #ifdef _GLIBCPP_USE_LONG_LONG | |
665 | virtual iter_type | |
666 | do_get(iter_type, iter_type, ios_base&, | |
667 | ios_base::iostate& __err, unsigned long long&) const; | |
668 | #endif | |
669 | virtual iter_type | |
670 | do_get(iter_type, iter_type, ios_base&, ios_base::iostate& __err, | |
671 | float&) const; | |
672 | ||
673 | virtual iter_type | |
674 | do_get(iter_type, iter_type, ios_base&, ios_base::iostate& __err, | |
675 | double&) const; | |
676 | ||
677 | virtual iter_type | |
678 | do_get(iter_type, iter_type, ios_base&, | |
679 | ios_base::iostate& __err, long double&) const; | |
680 | ||
681 | virtual iter_type | |
682 | do_get(iter_type, iter_type, ios_base&, ios_base::iostate& __err, | |
683 | void*&) const; | |
684 | }; | |
685 | ||
686 | // Declare specialized extraction member function. | |
687 | template<> | |
688 | void | |
689 | num_get<char, istreambuf_iterator<char> >:: | |
690 | _M_extract(istreambuf_iterator<char> __beg, | |
691 | istreambuf_iterator<char> __end, ios_base& __io, | |
692 | ios_base::iostate& __err, char* __xtrc, | |
693 | int& __base, bool __fp) const; | |
694 | ||
695 | // _Numeric_put is used by num_put, money_put, and time_put | |
696 | // to help in formatting out numbers. | |
697 | template<typename _CharT, typename _OutIter> | |
698 | class _Numeric_put | |
699 | { | |
700 | public: | |
701 | typedef _CharT char_type; | |
702 | typedef _OutIter iter_type; | |
703 | protected: | |
704 | explicit | |
705 | _Numeric_put() { } | |
706 | ||
707 | virtual | |
708 | ~_Numeric_put() { } | |
709 | }; | |
710 | ||
711 | template<typename _CharT, typename _OutIter> | |
712 | class num_put : public locale::facet | |
713 | { | |
714 | public: | |
715 | // Types: | |
716 | typedef _CharT char_type; | |
717 | typedef _OutIter iter_type; | |
718 | ||
719 | static locale::id id; | |
720 | ||
721 | explicit | |
722 | num_put(size_t __refs = 0) : locale::facet(__refs) { } | |
723 | ||
724 | iter_type | |
725 | put(iter_type __s, ios_base& __f, char_type __fill, bool __v) const | |
726 | { return do_put(__s, __f, __fill, __v); } | |
727 | ||
728 | iter_type | |
729 | put(iter_type __s, ios_base& __f, char_type __fill, long __v) const | |
730 | { return do_put(__s, __f, __fill, __v); } | |
731 | ||
732 | iter_type | |
733 | put(iter_type __s, ios_base& __f, char_type __fill, | |
734 | unsigned long __v) const | |
735 | { return do_put(__s, __f, __fill, __v); } | |
736 | ||
737 | #ifdef _GLIBCPP_USE_LONG_LONG | |
738 | iter_type | |
739 | put(iter_type __s, ios_base& __f, char_type __fill, long long __v) const | |
740 | { return do_put(__s, __f, __fill, __v); } | |
741 | ||
742 | iter_type | |
743 | put(iter_type __s, ios_base& __f, char_type __fill, | |
744 | unsigned long long __v) const | |
745 | { return do_put(__s, __f, __fill, __v); } | |
746 | #endif | |
747 | ||
748 | iter_type | |
749 | put(iter_type __s, ios_base& __f, char_type __fill, double __v) const | |
750 | { return do_put(__s, __f, __fill, __v); } | |
751 | ||
752 | iter_type | |
753 | put(iter_type __s, ios_base& __f, char_type __fill, | |
754 | long double __v) const | |
755 | { return do_put(__s, __f, __fill, __v); } | |
756 | ||
757 | iter_type | |
758 | put(iter_type __s, ios_base& __f, char_type __fill, | |
759 | const void* __v) const | |
760 | { return do_put(__s, __f, __fill, __v); } | |
761 | ||
762 | protected: | |
763 | virtual | |
764 | ~num_put() { }; | |
765 | ||
766 | virtual iter_type | |
767 | do_put(iter_type, ios_base&, char_type __fill, bool __v) const; | |
768 | ||
769 | virtual iter_type | |
770 | do_put(iter_type, ios_base&, char_type __fill, long __v) const; | |
771 | ||
772 | #ifdef _GLIBCPP_USE_LONG_LONG | |
773 | virtual iter_type | |
774 | do_put(iter_type, ios_base&, char_type __fill, long long __v) const; | |
775 | #endif | |
776 | ||
777 | virtual iter_type | |
778 | do_put(iter_type, ios_base&, char_type __fill, unsigned long) const; | |
779 | ||
780 | #ifdef _GLIBCPP_USE_LONG_LONG | |
781 | virtual iter_type | |
782 | do_put(iter_type, ios_base&, char_type __fill, unsigned long long) const; | |
783 | #endif | |
784 | ||
785 | virtual iter_type | |
786 | do_put(iter_type, ios_base&, char_type __fill, double __v) const; | |
787 | ||
788 | virtual iter_type | |
789 | do_put(iter_type, ios_base&, char_type __fill, long double __v) const; | |
790 | ||
791 | virtual iter_type | |
792 | do_put(iter_type, ios_base&, char_type __fill, const void* __v) const; | |
793 | }; | |
794 | ||
795 | template<typename _CharT> | |
796 | class _Punct : public locale::facet | |
797 | { | |
798 | public: | |
799 | // Types: | |
800 | typedef _CharT char_type; | |
801 | typedef basic_string<_CharT> string_type; | |
802 | ||
803 | char_type | |
804 | decimal_point() const | |
805 | { return do_decimal_point(); } | |
806 | ||
807 | char_type | |
808 | thousands_sep() const | |
809 | { return do_thousands_sep(); } | |
810 | ||
811 | string | |
812 | grouping() const | |
813 | { return do_grouping(); } | |
814 | protected: | |
815 | ||
816 | explicit | |
817 | _Punct(size_t __refs = 0) : locale::facet(__refs) { } | |
818 | ||
819 | virtual | |
820 | ~_Punct() { } | |
821 | ||
822 | virtual char_type | |
823 | do_decimal_point() const | |
824 | { return _M_decimal_point; } | |
825 | ||
826 | virtual char_type | |
827 | do_thousands_sep() const | |
828 | { return _M_thousands_sep; } | |
829 | ||
830 | virtual string | |
831 | do_grouping() const | |
832 | { return _M_grouping; } | |
833 | ||
834 | private: | |
835 | char_type _M_decimal_point; | |
836 | char_type _M_thousands_sep; | |
837 | string _M_grouping; | |
838 | ||
839 | protected: | |
840 | // for use at construction time only: | |
841 | void | |
842 | _M_init(char_type __d, char_type __t, const string& __g) | |
843 | { | |
844 | _M_decimal_point = __d; | |
845 | _M_thousands_sep = __t; | |
846 | _M_grouping = __g; | |
847 | } | |
848 | ||
849 | }; | |
850 | ||
851 | template<typename _CharT> | |
852 | class _Numpunct : public _Punct<_CharT> | |
853 | { | |
854 | public: | |
855 | // Types: | |
856 | typedef _CharT char_type; | |
857 | typedef basic_string<_CharT> string_type; | |
858 | ||
859 | string_type | |
860 | truename() const | |
861 | { return do_truename(); } | |
862 | ||
863 | string_type | |
864 | falsename() const | |
865 | { return do_falsename(); } | |
866 | ||
867 | protected: | |
868 | explicit | |
869 | _Numpunct(size_t __refs = 0) : _Punct<_CharT> (__refs) { } | |
870 | ||
871 | virtual | |
872 | ~_Numpunct() { } | |
873 | ||
874 | virtual string_type | |
875 | do_truename() const | |
876 | { return _M_truename; } | |
877 | ||
878 | virtual string_type | |
879 | do_falsename() const | |
880 | { return _M_falsename; } | |
881 | ||
882 | private: | |
883 | string_type _M_truename; | |
884 | string_type _M_falsename; | |
885 | ||
886 | protected: | |
887 | // For use only during construction | |
888 | void | |
889 | _M_boolnames_init(const string_type& __t, const string_type& __f) | |
890 | { | |
891 | _M_truename = __t; | |
892 | _M_falsename = __f; | |
893 | } | |
894 | ||
895 | }; | |
896 | ||
897 | template<typename _CharT> | |
898 | class numpunct : public _Numpunct<_CharT> | |
899 | { | |
900 | public: | |
901 | typedef _CharT char_type; | |
902 | typedef basic_string<_CharT> string_type; | |
903 | ||
904 | static locale::id id; | |
905 | ||
906 | explicit | |
907 | numpunct(size_t __refs = 0) : _Numpunct<_CharT>(__refs) { } | |
908 | protected: | |
909 | ||
910 | virtual | |
911 | ~numpunct() { } | |
912 | }; | |
913 | ||
914 | template<> | |
915 | numpunct<char>::numpunct(size_t __refs): _Numpunct<char>(__refs) | |
916 | { | |
917 | _M_init('.', ',', ""); | |
918 | _M_boolnames_init("true", "false"); | |
919 | } | |
920 | ||
921 | #ifdef _GLIBCPP_USE_WCHAR_T | |
922 | template<> | |
923 | numpunct<wchar_t>::numpunct(size_t __refs): _Numpunct<wchar_t>(__refs) | |
924 | { | |
925 | _M_init(L'.', L',', ""); | |
926 | _M_boolnames_init(L"true", L"false"); | |
927 | } | |
928 | #endif | |
929 | ||
930 | template<typename _CharT> | |
931 | class numpunct_byname : public numpunct<_CharT> | |
932 | { | |
933 | public: | |
934 | typedef _CharT char_type; | |
935 | typedef basic_string<_CharT> string_type; | |
936 | ||
937 | explicit | |
938 | numpunct_byname(const char*, size_t __refs = 0); | |
939 | ||
940 | protected: | |
941 | virtual | |
942 | ~numpunct_byname() { } | |
943 | }; | |
944 | ||
945 | template<> | |
946 | numpunct_byname<char>::numpunct_byname(const char*, size_t __refs); | |
947 | #ifdef _GLIBCPP_USE_WCHAR_T | |
948 | template<> | |
949 | numpunct_byname<wchar_t>::numpunct_byname(const char*, size_t __refs); | |
950 | #endif | |
951 | ||
952 | template<typename _CharT> | |
953 | class _Collate : public locale::facet | |
954 | { | |
955 | public: | |
956 | // Types: | |
957 | typedef _CharT char_type; | |
958 | typedef basic_string<_CharT> string_type; | |
959 | ||
960 | int | |
961 | compare(const _CharT* __lo1, const _CharT* __hi1, | |
962 | const _CharT* __lo2, const _CharT* __hi2) const | |
963 | { return do_compare(__lo1, __hi1, __lo2, __hi2); } | |
964 | ||
965 | string_type | |
966 | transform(const _CharT* __lo, const _CharT* __hi) const | |
967 | { return do_transform(__lo, __hi); } | |
968 | ||
969 | long | |
970 | hash(const _CharT* __lo, const _CharT* __hi) const | |
971 | { return do_hash(__lo, __hi); } | |
972 | ||
973 | protected: | |
974 | explicit | |
975 | _Collate(size_t __refs = 0) : locale::facet(__refs) { } | |
976 | ||
977 | ~_Collate() { } // virtual | |
978 | ||
979 | virtual int | |
980 | do_compare(const _CharT* __lo1, const _CharT* __hi1, | |
981 | const _CharT* __lo2, const _CharT* __hi2) const = 0; | |
982 | ||
983 | virtual string_type | |
984 | do_transform(const _CharT* __lo, const _CharT* __hi) const = 0; | |
985 | ||
986 | virtual long | |
987 | do_hash(const _CharT* __lo, const _CharT* __hi) const = 0; | |
988 | }; | |
989 | ||
990 | template<typename _CharT> | |
991 | class collate : public _Collate<_CharT> | |
992 | { | |
993 | public: | |
994 | // Types: | |
995 | typedef _CharT char_type; | |
996 | typedef basic_string<_CharT> string_type; | |
997 | ||
998 | explicit | |
999 | collate(size_t __refs = 0) : _Collate<_CharT> (__refs) { } | |
1000 | ||
1001 | static locale::id id; | |
1002 | ||
1003 | protected: | |
1004 | virtual | |
1005 | ~collate() { } | |
1006 | }; | |
1007 | ||
1008 | template<> | |
1009 | class collate<char> : public _Collate<char> | |
1010 | { | |
1011 | public: | |
1012 | // Types: | |
1013 | typedef char char_type; | |
1014 | typedef basic_string<char> string_type; | |
1015 | ||
1016 | explicit | |
1017 | collate(size_t __refs = 0); | |
1018 | ||
1019 | static locale::id id; | |
1020 | ||
1021 | protected: | |
1022 | virtual | |
1023 | ~collate(); | |
1024 | ||
1025 | virtual int | |
1026 | do_compare(const char* __lo1, const char* __hi1, | |
1027 | const char* __lo2, const char* __hi2) const; | |
1028 | ||
1029 | virtual string_type | |
1030 | do_transform(const char* __lo, const char* __hi) const; | |
1031 | ||
1032 | virtual long | |
1033 | do_hash(const char* __lo, const char* __hi) const; | |
1034 | }; | |
1035 | ||
1036 | #ifdef _GLIBCPP_USE_WCHAR_T | |
1037 | template<> | |
1038 | class collate<wchar_t> : public _Collate<wchar_t> | |
1039 | { | |
1040 | public: | |
1041 | // Types: | |
1042 | typedef wchar_t char_type; | |
1043 | typedef basic_string<wchar_t> string_type; | |
1044 | ||
1045 | explicit | |
1046 | collate(size_t __refs = 0); | |
1047 | ||
1048 | static locale::id id; | |
1049 | ||
1050 | protected: | |
1051 | virtual | |
1052 | ~collate(); | |
1053 | ||
1054 | virtual int | |
1055 | do_compare(const wchar_t* __lo1, const wchar_t* __hi1, | |
1056 | const wchar_t* __lo2, const wchar_t* __hi2) const; | |
1057 | ||
1058 | virtual string_type | |
1059 | do_transform(const wchar_t* __lo, const wchar_t* __hi) const; | |
1060 | ||
1061 | virtual long | |
1062 | do_hash(const wchar_t* __lo, const wchar_t* __hi) const; | |
1063 | }; | |
1064 | #endif | |
1065 | ||
1066 | template<typename _CharT> | |
1067 | class collate_byname : public collate<_CharT> | |
1068 | { | |
1069 | public: | |
1070 | // Types: | |
1071 | typedef _CharT char_type; | |
1072 | typedef basic_string<_CharT> string_type; | |
1073 | ||
1074 | explicit | |
1075 | collate_byname(const char*, size_t __refs = 0); | |
1076 | ||
1077 | protected: | |
1078 | virtual | |
1079 | ~collate_byname() { } | |
1080 | }; | |
1081 | ||
1082 | template<> | |
1083 | collate_byname<char>::collate_byname(const char*, size_t __refs); | |
1084 | #ifdef _GLIBCPP_USE_WCHAR_T | |
1085 | template<> | |
1086 | collate_byname<wchar_t>::collate_byname(const char*, size_t __refs); | |
1087 | #endif | |
1088 | ||
1089 | class time_base | |
1090 | { | |
1091 | public: | |
1092 | enum dateorder { no_order, dmy, mdy, ymd, ydm }; | |
1093 | }; | |
1094 | ||
1095 | template<typename _CharT, typename _InIter> | |
1096 | class time_get : public locale::facet, public time_base | |
1097 | { | |
1098 | public: | |
1099 | // Types: | |
1100 | typedef _CharT char_type; | |
1101 | typedef _InIter iter_type; | |
1102 | ||
1103 | static locale::id id; | |
1104 | ||
1105 | explicit | |
1106 | time_get(size_t __refs = 0) | |
1107 | : locale::facet (__refs), _M_daynames(0), _M_monthnames(0) { } | |
1108 | ||
1109 | dateorder | |
1110 | date_order() const | |
1111 | { return do_date_order(); } | |
1112 | ||
1113 | iter_type | |
1114 | get_time(iter_type __s, iter_type __end, ios_base& __f, | |
1115 | ios_base::iostate& __err, tm* __t) const | |
1116 | { return do_get_time(__s, __end, __f, __err, __t); } | |
1117 | ||
1118 | iter_type | |
1119 | get_date(iter_type __s, iter_type __end, ios_base& __f, | |
1120 | ios_base::iostate& __err, tm* __t) const | |
1121 | { return do_get_date(__s, __end, __f, __err, __t); } | |
1122 | ||
1123 | iter_type | |
1124 | get_weekday(iter_type __s, iter_type __end, ios_base& __f, | |
1125 | ios_base::iostate& __err, tm* __t) const | |
1126 | { return do_get_weekday(__s,__end,__f,__err,__t); } | |
1127 | ||
1128 | iter_type | |
1129 | get_monthname(iter_type __s, iter_type __end, ios_base& __f, | |
1130 | ios_base::iostate& __err, tm* __t) const | |
1131 | { return do_get_monthname(__s,__end,__f,__err,__t); } | |
1132 | ||
1133 | iter_type | |
1134 | get_year(iter_type __s, iter_type __end, ios_base& __f, | |
1135 | ios_base::iostate& __err, tm* __t) const | |
1136 | { return do_get_year(__s,__end,__f,__err,__t); } | |
1137 | ||
1138 | protected: | |
1139 | virtual | |
1140 | ~time_get() | |
1141 | { | |
1142 | delete [] _M_monthnames; | |
1143 | delete [] _M_daynames; | |
1144 | } | |
1145 | ||
1146 | virtual dateorder | |
1147 | do_date_order() const | |
1148 | { return time_base::ymd; } | |
1149 | ||
1150 | virtual iter_type | |
1151 | do_get_time(iter_type __s, iter_type /*__end*/, ios_base&, | |
1152 | ios_base::iostate& /*__err*/, tm* /*__t*/) const | |
1153 | { return __s; } | |
1154 | ||
1155 | virtual iter_type | |
1156 | do_get_date(iter_type __s, iter_type /*__end*/, ios_base&, | |
1157 | ios_base::iostate& /*__err*/, tm* /*__t*/) const | |
1158 | { return __s; } | |
1159 | ||
1160 | virtual iter_type | |
1161 | do_get_weekday(iter_type __s, iter_type __end, ios_base&, | |
1162 | ios_base::iostate& __err, tm* __t) const; | |
1163 | ||
1164 | virtual iter_type | |
1165 | do_get_monthname(iter_type __s, iter_type __end, ios_base&, | |
1166 | ios_base::iostate& __err, tm* __t) const; | |
1167 | ||
1168 | virtual iter_type | |
1169 | do_get_year(iter_type __s, iter_type /*__end*/, ios_base&, | |
1170 | ios_base::iostate& /*__err*/, tm* /*__t*/) const | |
1171 | { return __s; } | |
1172 | ||
1173 | mutable basic_string<_CharT>* _M_daynames; | |
1174 | mutable basic_string<_CharT>* _M_monthnames; | |
1175 | }; | |
1176 | ||
1177 | template<typename _CharT, typename _InIter> | |
1178 | class time_get_byname : public time_get<_CharT, _InIter> | |
1179 | { | |
1180 | public: | |
1181 | typedef _CharT char_type; | |
1182 | typedef _InIter iter_type; | |
1183 | ||
1184 | explicit | |
1185 | time_get_byname(const char*, size_t __refs = 0) | |
1186 | : time_get<_CharT, _InIter>(__refs) { } | |
1187 | protected: | |
1188 | virtual | |
1189 | ~time_get_byname() { } | |
1190 | }; | |
1191 | ||
1192 | template<typename _CharT, typename _OutIter> | |
1193 | class time_put : public locale::facet, public time_base | |
1194 | { | |
1195 | public: | |
1196 | typedef _CharT char_type; | |
1197 | typedef _OutIter iter_type; | |
1198 | ||
1199 | static locale::id id; | |
1200 | ||
1201 | explicit | |
1202 | time_put(size_t __refs = 0) : locale::facet (__refs) { } | |
1203 | ||
1204 | // NB: this is a nonvirtual, calls do_put in a loop. | |
1205 | iter_type | |
1206 | put(iter_type __s, ios_base& /*__f*/, char_type /*__fill*/, | |
1207 | const tm* /*__tmb*/, const _CharT* /*__pattern*/, | |
1208 | const _CharT* /*__pat_end*/) const | |
1209 | { return __s; } | |
1210 | ||
1211 | iter_type | |
1212 | put(iter_type __s, ios_base& __f, char_type __fill, | |
1213 | const tm* __tmb, char __format, char __modifier = 0) const | |
1214 | { return do_put(__s, __f, __fill, __tmb, __format, __modifier); } | |
1215 | ||
1216 | protected: | |
1217 | virtual | |
1218 | ~time_put() { } | |
1219 | ||
1220 | virtual iter_type | |
1221 | do_put(iter_type __s, ios_base&, char_type, const tm* /*__t*/, | |
1222 | char /*__format*/, char /*__mod*/) const | |
1223 | { return __s; } | |
1224 | }; | |
1225 | ||
1226 | template<typename _CharT, typename _OutIter> | |
1227 | class time_put_byname : public time_put<_CharT, _OutIter> | |
1228 | { | |
1229 | public: | |
1230 | typedef _CharT char_type; | |
1231 | typedef _OutIter iter_type; | |
1232 | ||
1233 | explicit | |
1234 | time_put_byname(const char*, size_t __refs = 0) | |
1235 | : time_put<_CharT, _OutIter> (__refs) { } | |
1236 | ||
1237 | protected: | |
1238 | virtual | |
1239 | ~time_put_byname() { } | |
1240 | }; | |
1241 | ||
1242 | ||
1243 | template<typename _CharT, typename _InIter> | |
1244 | class money_get : public locale::facet | |
1245 | { | |
1246 | public: | |
1247 | typedef _CharT char_type; | |
1248 | typedef _InIter iter_type; | |
1249 | typedef basic_string<_CharT> string_type; | |
1250 | ||
1251 | static locale::id id; | |
1252 | ||
1253 | explicit | |
1254 | money_get(size_t __refs = 0) : locale::facet(__refs) { } | |
1255 | ||
1256 | iter_type | |
1257 | get(iter_type __s, iter_type __end, bool __intl, | |
1258 | ios_base& __f, ios_base::iostate& __err, long double& __units) const | |
1259 | { return do_get(__s, __end, __intl, __f, __err, __units); } | |
1260 | ||
1261 | iter_type | |
1262 | get(iter_type __s, iter_type __end, bool __intl, ios_base& __f, | |
1263 | ios_base::iostate& __err, string_type& __digits) const | |
1264 | { return do_get(__s, __end, __intl, __f, __err, __digits); } | |
1265 | ||
1266 | protected: | |
1267 | virtual | |
1268 | ~money_get() { } | |
1269 | ||
1270 | virtual iter_type | |
1271 | do_get(iter_type __s, iter_type /*__end*/, bool /*__intl*/, | |
1272 | ios_base& /*__io*/, ios_base::iostate& /*__err*/, | |
1273 | long double& /*__units*/) const | |
1274 | { return __s; } | |
1275 | ||
1276 | virtual iter_type | |
1277 | do_get(iter_type __s, iter_type /*__end*/, bool /*__intl*/, | |
1278 | ios_base& /*__io*/, ios_base::iostate& /*__err*/, | |
1279 | string_type& /*__digits*/) const | |
1280 | { return __s; } | |
1281 | }; | |
1282 | ||
1283 | template<typename _CharT, typename _OutIter> | |
1284 | class money_put : public locale::facet | |
1285 | { | |
1286 | public: | |
1287 | typedef _CharT char_type; | |
1288 | typedef _OutIter iter_type; | |
1289 | typedef basic_string<_CharT> string_type; | |
1290 | ||
1291 | static locale::id id; | |
1292 | ||
1293 | explicit | |
1294 | money_put(size_t __refs = 0) : locale::facet(__refs) { } | |
1295 | ||
1296 | iter_type | |
1297 | put(iter_type __s, bool __intl, ios_base& __f, | |
1298 | char_type __fill, long double __units) const | |
1299 | { return do_put(__s, __intl, __f, __fill, __units); } | |
1300 | ||
1301 | iter_type | |
1302 | put(iter_type __s, bool __intl, ios_base& __f, | |
1303 | char_type __fill, const string_type& __digits) const | |
1304 | { return do_put(__s, __intl, __f, __fill, __digits); } | |
1305 | ||
1306 | protected: | |
1307 | virtual | |
1308 | ~money_put() { } | |
1309 | ||
1310 | virtual iter_type | |
1311 | do_put(iter_type __s, bool, ios_base& /*__io*/, char_type /*__fill*/, | |
1312 | long double /*__units*/) const | |
1313 | { return __s; } | |
1314 | ||
1315 | virtual iter_type | |
1316 | do_put(iter_type __s, bool, ios_base& /*__io*/, char_type /*__fill*/, | |
1317 | const string_type& /*__digits*/) const | |
1318 | { return __s; } | |
1319 | }; | |
1320 | ||
1321 | struct money_base | |
1322 | { | |
1323 | enum part { none, space, symbol, sign, value }; | |
1324 | struct pattern { char field[4]; }; | |
1325 | ||
1326 | static const pattern _S_default_pattern; | |
1327 | }; | |
1328 | ||
1329 | template<typename _CharT> | |
1330 | class _Moneypunct : public _Punct<_CharT>, public money_base | |
1331 | { | |
1332 | public: | |
1333 | typedef _CharT char_type; | |
1334 | typedef basic_string<_CharT> string_type; | |
1335 | ||
1336 | string_type | |
1337 | curr_symbol() const | |
1338 | { return do_curr_symbol(); } | |
1339 | ||
1340 | string_type | |
1341 | positive_sign() const | |
1342 | { return do_positive_sign(); } | |
1343 | ||
1344 | string_type | |
1345 | negative_sign() const | |
1346 | { return do_negative_sign(); } | |
1347 | ||
1348 | int | |
1349 | frac_digits() const | |
1350 | { return do_frac_digits(); } | |
1351 | ||
1352 | pattern | |
1353 | pos_format() const | |
1354 | { return do_pos_format(); } | |
1355 | ||
1356 | pattern | |
1357 | neg_format() const | |
1358 | { return do_neg_format(); } | |
1359 | ||
1360 | protected: | |
1361 | explicit | |
1362 | _Moneypunct(size_t __refs = 0) : _Punct<_CharT> (__refs) { } | |
1363 | ||
1364 | virtual | |
1365 | ~_Moneypunct() { } | |
1366 | ||
1367 | virtual string_type | |
1368 | do_curr_symbol() const | |
1369 | { return basic_string<_CharT>(); } | |
1370 | ||
1371 | virtual string_type | |
1372 | do_positive_sign() const | |
1373 | { return basic_string<_CharT>(); } | |
1374 | ||
1375 | virtual string_type | |
1376 | do_negative_sign() const | |
1377 | { return basic_string<_CharT>(); } | |
1378 | ||
1379 | virtual int | |
1380 | do_frac_digits() const | |
1381 | { return 0; } | |
1382 | ||
1383 | virtual pattern | |
1384 | do_pos_format() const | |
1385 | { return money_base::_S_default_pattern; } | |
1386 | ||
1387 | virtual pattern | |
1388 | do_neg_format() const | |
1389 | { return money_base::_S_default_pattern; } | |
1390 | }; | |
1391 | ||
1392 | template<typename _CharT, bool _Intl> | |
1393 | class moneypunct : public _Moneypunct<_CharT> | |
1394 | { | |
1395 | public: | |
1396 | // Types: | |
1397 | typedef _CharT char_type; | |
1398 | typedef basic_string<_CharT> string_type; | |
1399 | ||
1400 | static const bool intl = _Intl; | |
1401 | static locale::id id; | |
1402 | ||
1403 | explicit | |
1404 | moneypunct(size_t __refs = 0) : _Moneypunct<_CharT> (__refs) { } | |
1405 | ||
1406 | protected: | |
1407 | virtual | |
1408 | ~moneypunct() { } | |
1409 | }; | |
1410 | ||
1411 | template<typename _CharT, bool _Intl> | |
1412 | class moneypunct_byname : public moneypunct<_CharT,_Intl> | |
1413 | { | |
1414 | public: | |
1415 | typedef _CharT char_type; | |
1416 | typedef basic_string<_CharT> string_type; | |
1417 | static const bool intl = _Intl; | |
1418 | ||
1419 | explicit | |
1420 | moneypunct_byname(const char*, size_t __refs = 0); | |
1421 | ||
1422 | protected: | |
1423 | virtual | |
1424 | ~moneypunct_byname() { } | |
1425 | }; | |
1426 | ||
1427 | template<> | |
1428 | moneypunct_byname<char, false>:: | |
1429 | moneypunct_byname(const char*, size_t __refs); | |
1430 | template<> | |
1431 | moneypunct_byname<char, true>:: | |
1432 | moneypunct_byname(const char*, size_t __refs); | |
1433 | #ifdef _GLIBCPP_USE_WCHAR_T | |
1434 | template<> | |
1435 | moneypunct_byname<wchar_t,false>:: | |
1436 | moneypunct_byname(const char*, size_t __refs); | |
1437 | template<> | |
1438 | moneypunct_byname<wchar_t,true>:: | |
1439 | moneypunct_byname (const char*, size_t __refs); | |
1440 | #endif | |
1441 | ||
1442 | struct messages_base | |
1443 | { | |
1444 | typedef int catalog; | |
1445 | }; | |
1446 | ||
1447 | template<typename _CharT> | |
1448 | class _Messages : public locale::facet, public messages_base | |
1449 | { | |
1450 | public: | |
1451 | typedef _CharT char_type; | |
1452 | typedef basic_string<_CharT> string_type; | |
1453 | ||
1454 | catalog | |
1455 | open(const basic_string<char>& __s, const locale& __loc) const | |
1456 | { return do_open(__s, __loc); } | |
1457 | ||
1458 | string_type | |
1459 | get(catalog __c, int __set, int __msgid, const string_type& __s) const | |
1460 | { return do_get(__c,__set,__msgid,__s); } | |
1461 | ||
1462 | void | |
1463 | close(catalog __c) const | |
1464 | { return do_close(__c); } | |
1465 | ||
1466 | protected: | |
1467 | explicit | |
1468 | _Messages(size_t __refs = 0) : locale::facet(__refs) { } | |
1469 | ||
1470 | virtual | |
1471 | ~_Messages() { } | |
1472 | ||
1473 | // NB: Probably these should be pure, and implemented only in | |
1474 | // specializations of messages<>. But for now... | |
1475 | virtual catalog | |
1476 | do_open(const basic_string<char>&, const locale&) const | |
1477 | { return 0; } | |
1478 | ||
1479 | virtual string_type | |
1480 | do_get(catalog, int, int /*__msgid*/, const string_type& __dfault) const | |
1481 | { return __dfault; } | |
1482 | ||
1483 | virtual void | |
1484 | do_close (catalog) const { } | |
1485 | }; | |
1486 | ||
1487 | template<typename _CharT> | |
1488 | class messages : public _Messages<_CharT> | |
1489 | { | |
1490 | public: | |
1491 | typedef _CharT char_type; | |
1492 | typedef basic_string<_CharT> string_type; | |
1493 | static locale::id id; | |
1494 | ||
1495 | explicit | |
1496 | messages(size_t __refs = 0) : _Messages<_CharT> (__refs) { } | |
1497 | protected: | |
1498 | virtual | |
1499 | ~messages() { } | |
1500 | }; | |
1501 | ||
1502 | template<typename _CharT> | |
1503 | class messages_byname : public messages<_CharT> | |
1504 | { | |
1505 | public: | |
1506 | typedef _CharT char_type; | |
1507 | typedef basic_string<_CharT> string_type; | |
1508 | ||
1509 | explicit | |
1510 | messages_byname(const char*, size_t __refs = 0); | |
1511 | ||
1512 | protected: | |
1513 | virtual | |
1514 | ~messages_byname() { } | |
1515 | }; | |
1516 | ||
1517 | template<> | |
1518 | messages_byname<char>::messages_byname(const char*, size_t __refs); | |
1519 | #ifdef _GLIBCPP_USE_WCHAR_T | |
1520 | template<> | |
1521 | messages_byname<wchar_t>::messages_byname(const char*, size_t __refs); | |
1522 | #endif | |
1523 | ||
1524 | // Subclause convenience interfaces, inlines | |
1525 | // NB: these are inline | |
1526 | // because, when used in a loop, some compilers can hoist the body | |
1527 | // out of the loop; then it's just as fast as the C is*() function. | |
1528 | template<typename _CharT> | |
1529 | inline bool | |
1530 | isspace(_CharT __c, const locale& __loc) | |
1531 | { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::space, __c); } | |
1532 | ||
1533 | template<typename _CharT> | |
1534 | inline bool | |
1535 | isprint(_CharT __c, const locale& __loc) | |
1536 | { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::print, __c); } | |
1537 | ||
1538 | template<typename _CharT> | |
1539 | inline bool | |
1540 | iscntrl(_CharT __c, const locale& __loc) | |
1541 | { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::cntrl, __c); } | |
1542 | ||
1543 | template<typename _CharT> | |
1544 | inline bool | |
1545 | isupper(_CharT __c, const locale& __loc) | |
1546 | { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::upper, __c); } | |
1547 | ||
1548 | template<typename _CharT> | |
1549 | inline bool islower(_CharT __c, const locale& __loc) | |
1550 | { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::lower, __c); } | |
1551 | ||
1552 | template<typename _CharT> | |
1553 | inline bool | |
1554 | isalpha(_CharT __c, const locale& __loc) | |
1555 | { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::alpha, __c); } | |
1556 | ||
1557 | template<typename _CharT> | |
1558 | inline bool | |
1559 | isdigit(_CharT __c, const locale& __loc) | |
1560 | { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::digit, __c); } | |
1561 | ||
1562 | template<typename _CharT> | |
1563 | inline bool | |
1564 | ispunct(_CharT __c, const locale& __loc) | |
1565 | { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::punct, __c); } | |
1566 | ||
1567 | template<typename _CharT> | |
1568 | inline bool | |
1569 | isxdigit(_CharT __c, const locale& __loc) | |
1570 | { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::xdigit, __c); } | |
1571 | ||
1572 | template<typename _CharT> | |
1573 | inline bool | |
1574 | isalnum(_CharT __c, const locale& __loc) | |
1575 | { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::alnum, __c); } | |
1576 | ||
1577 | template<typename _CharT> | |
1578 | inline bool | |
1579 | isgraph(_CharT __c, const locale& __loc) | |
1580 | { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::graph, __c); } | |
1581 | ||
1582 | template<typename _CharT> | |
1583 | inline _CharT | |
1584 | toupper(_CharT __c, const locale& __loc) | |
1585 | { return use_facet<ctype<_CharT> >(__loc).toupper(__c); } | |
1586 | ||
1587 | template<typename _CharT> | |
1588 | inline _CharT | |
1589 | tolower(_CharT __c, const locale& __loc) | |
1590 | { return use_facet<ctype<_CharT> >(__loc).tolower(__c); } | |
1591 | ||
1592 | } // namespace std | |
1593 | ||
1594 | #endif /* _CPP_BITS_LOCFACETS_H */ | |
1595 | ||
1596 | // Local Variables: | |
1597 | // mode:c++ | |
1598 | // End: | |
1599 |