]>
gcc.gnu.org Git - gcc.git/blob - libstdc++-v3/include/bits/localefwd.h
1 // Locale support -*- C++ -*-
3 // Copyright (C) 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
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)
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.
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,
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.
31 // ISO C++ 14882: 22.1 Locales
35 * This is an internal header file, included by other library headers.
36 * You should not attempt to use it directly.
39 #ifndef _CPP_BITS_LOCCORE_H
40 #define _CPP_BITS_LOCCORE_H 1
42 #pragma GCC system_header
44 #include <bits/c++config.h>
45 #include <bits/c++locale.h> // Defines __c_locale, config-specific includes
46 #include <bits/std_climits.h> // For CHAR_BIT
47 #include <bits/std_string.h> // For string
48 #include <bits/std_cctype.h> // For isspace, etc.
49 #include <bits/functexcept.h>
53 // NB: Don't instantiate required wchar_t facets if no wchar_t support.
54 #ifdef _GLIBCPP_USE_WCHAR_T
55 # define _GLIBCPP_NUM_FACETS 28
57 # define _GLIBCPP_NUM_FACETS 14
61 template<typename _Tp
, typename _Alloc
>
65 // 22.1.3 Convenience interfaces
66 template<typename _CharT
>
68 isspace(_CharT
, const locale
&);
70 template<typename _CharT
>
72 isprint(_CharT
, const locale
&);
74 template<typename _CharT
>
76 iscntrl(_CharT
, const locale
&);
78 template<typename _CharT
>
80 isupper(_CharT
, const locale
&);
82 template<typename _CharT
>
84 islower(_CharT
, const locale
&);
86 template<typename _CharT
>
88 isalpha(_CharT
, const locale
&);
90 template<typename _CharT
>
92 isdigit(_CharT
, const locale
&);
94 template<typename _CharT
>
96 ispunct(_CharT
, const locale
&);
98 template<typename _CharT
>
100 isxdigit(_CharT
, const locale
&);
102 template<typename _CharT
>
104 isalnum(_CharT
, const locale
&);
106 template<typename _CharT
>
108 isgraph(_CharT
, const locale
&);
110 template<typename _CharT
>
112 toupper(_CharT
, const locale
&);
114 template<typename _CharT
>
116 tolower(_CharT
, const locale
&);
119 // 22.2.1 and 22.2.1.3 ctype
121 template<typename _CharT
>
123 template<> class ctype
<char>;
124 #ifdef _GLIBCPP_USE_WCHAR_T
125 template<> class ctype
<wchar_t>;
127 template<typename _CharT
>
129 // NB: Specialized for char and wchar_t in locale_facets.h.
133 template<typename _InternT
, typename _ExternT
, typename _StateT
>
135 template<> class codecvt
<char, char, mbstate_t>;
136 #ifdef _GLIBCPP_USE_WCHAR_T
137 template<> class codecvt
<wchar_t, char, mbstate_t>;
139 template<typename _InternT
, typename _ExternT
, typename _StateT
>
140 class codecvt_byname
;
142 // 22.2.2 and 22.2.3 numeric
143 template<typename _CharT
, typename _InIter
= istreambuf_iterator
<_CharT
> >
145 template<typename _CharT
, typename _OutIter
= ostreambuf_iterator
<_CharT
> >
147 template<typename _CharT
> class numpunct
;
148 template<typename _CharT
> class numpunct_byname
;
151 template<typename _CharT
>
153 template<typename _CharT
> class
156 // 22.2.5 date and time
158 template<typename _CharT
, typename _InIter
= istreambuf_iterator
<_CharT
> >
160 template<typename _CharT
, typename _InIter
= istreambuf_iterator
<_CharT
> >
161 class time_get_byname
;
162 template<typename _CharT
, typename _OutIter
= ostreambuf_iterator
<_CharT
> >
164 template<typename _CharT
, typename _OutIter
= ostreambuf_iterator
<_CharT
> >
165 class time_put_byname
;
169 template<typename _CharT
, typename _InIter
= istreambuf_iterator
<_CharT
> >
171 template<typename _CharT
, typename _OutIter
= ostreambuf_iterator
<_CharT
> >
173 template<typename _CharT
, bool _Intl
= false>
175 template<typename _CharT
, bool _Intl
= false>
176 class moneypunct_byname
;
178 // 22.2.7 message retrieval
180 template<typename _CharT
>
182 template<typename _CharT
>
183 class messages_byname
;
185 // 22.1.1 Class locale
190 typedef unsigned int category
;
192 // Forward decls and friends:
200 template<typename _Facet
>
202 use_facet(const locale
&);
204 template<typename _Facet
>
206 has_facet(const locale
&) throw();
209 // NB: Order must match _S_facet_categories definition in locale.cc
210 static const category none
= 0;
211 static const category ctype
= 1L << 0;
212 static const category numeric
= 1L << 1;
213 static const category collate
= 1L << 2;
214 static const category time
= 1L << 3;
215 static const category monetary
= 1L << 4;
216 static const category messages
= 1L << 5;
217 static const category all
= (collate
| ctype
| monetary
|
218 numeric
| time
| messages
);
220 // Construct/copy/destroy:
223 locale(const locale
& __other
) throw();
226 locale(const char* __std_name
);
228 locale(const locale
& __base
, const char* __s
, category __cat
);
230 locale(const locale
& __base
, const locale
& __add
, category __cat
);
232 template<typename _Facet
>
233 locale(const locale
& __other
, _Facet
* __f
);
238 operator=(const locale
& __other
) throw();
240 template<typename _Facet
>
242 combine(const locale
& __other
) const;
244 // Locale operations:
249 operator==(const locale
& __other
) const throw ();
252 operator!=(const locale
& __other
) const throw ()
253 { return !(this->operator==(__other
)); }
255 template<typename _Char
, typename _Traits
, typename _Alloc
>
257 operator()(const basic_string
<_Char
, _Traits
, _Alloc
>& __s1
,
258 const basic_string
<_Char
, _Traits
, _Alloc
>& __s2
) const;
260 // Global locale objects:
262 global(const locale
&);
268 // The (shared) implementation
271 // The "C" reference locale
272 static _Impl
* _S_classic
;
274 // Current global reference locale
275 static _Impl
* _S_global
;
277 static const size_t _S_num_categories
= 6;
278 static const size_t _S_num_facets
= _GLIBCPP_NUM_FACETS
;
281 locale(_Impl
*) throw();
291 _S_normalize_category(category
);
294 _M_coalesce(const locale
& __base
, const locale
& __add
, category __cat
);
298 // locale implementation object
303 typedef vector
<facet
*, allocator
<facet
*> > __vec_facet
;
307 friend class locale::facet
;
309 template<typename _Facet
>
311 use_facet(const locale
&);
313 template<typename _Facet
>
315 has_facet(const locale
&) throw();
319 size_t _M_references
;
320 __vec_facet
* _M_facets
;
321 string _M_names
[_S_num_categories
];
322 static const locale::id
* const _S_id_ctype
[];
323 static const locale::id
* const _S_id_numeric
[];
324 static const locale::id
* const _S_id_collate
[];
325 static const locale::id
* const _S_id_time
[];
326 static const locale::id
* const _S_id_monetary
[];
327 static const locale::id
* const _S_id_messages
[];
328 static const locale::id
* const* const _S_facet_categories
[];
331 _M_add_reference() throw()
332 { ++_M_references
; } // XXX MT
335 _M_remove_reference() throw()
337 if (--_M_references
== 0) // XXX MT
346 _Impl(const _Impl
&, size_t);
347 _Impl(string __name
, size_t);
354 for (size_t i
= 0; i
< _S_num_categories
- 1; ++i
)
355 __ret
&= _M_names
[i
] == _M_names
[i
+ 1];
360 _M_replace_categories(const _Impl
*, category
);
363 _M_replace_category(const _Impl
*, const locale::id
* const*);
366 _M_replace_facet(const _Impl
*, const locale::id
*);
369 _M_install_facet(const locale::id
*, facet
*);
371 template<typename _Facet
>
373 _M_init_facet(_Facet
* __facet
)
374 { _M_install_facet(&_Facet::id
, __facet
); }
377 template<typename _Facet
>
378 locale::locale(const locale
& __other
, _Facet
* __f
)
380 _M_impl
= new _Impl(*__other
._M_impl
, 1);
381 _M_impl
->_M_install_facet(&_Facet::id
, __f
);
382 for (size_t __i
= 0; __i
< _S_num_categories
; ++__i
)
383 _M_impl
->_M_names
[__i
] = "*";
386 // 22.1.1.1.2 Class locale::facet
390 friend class locale::_Impl
;
391 friend class __enc_traits
;
394 // Contains data from the underlying "C" library for default "C"
395 // and "POSIX" locales.
396 static __c_locale _S_c_locale
;
399 facet(size_t __refs
= 0) throw();
405 _S_create_c_locale(__c_locale
& __cloc
, const char* __s
);
408 _S_clone_c_locale(__c_locale
& __cloc
);
411 _S_destroy_c_locale(__c_locale
& __cloc
);
414 size_t _M_references
;
417 _M_add_reference() throw();
420 _M_remove_reference() throw();
422 facet(const facet
&); // not defined
425 operator=(const facet
&); // not defined
429 // 22.1.1.1.3 Class locale::id
434 friend class locale::_Impl
;
435 template<typename _Facet
>
437 use_facet(const locale
&);
438 template<typename _Facet
>
440 has_facet(const locale
&) throw ();
442 // NB: There is no accessor for _M_index because it may be used
443 // before the constructor is run; the effect of calling a member
444 // function (even an inline) would be undefined.
445 mutable size_t _M_index
;
447 // Last id number assigned
448 static size_t _S_highwater
;
451 operator=(const id
&); // not defined
453 id(const id
&); // not defined
456 // NB: This class is always a static data member, and thus can be
457 // counted on to be zero-initialized.
461 template<typename _Facet
>
463 use_facet(const locale
& __loc
);
465 template<typename _Facet
>
467 has_facet(const locale
& __loc
) throw();
This page took 0.059351 seconds and 5 git commands to generate.