Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
_facet.h
Go to the documentation of this file.
1
32#ifndef _RWSTD_LOC_FACET_H_INCLUDED
33#define _RWSTD_LOC_FACET_H_INCLUDED
34
35
36#include <rw/_mutex.h>
37#include <rw/_defs.h>
38
39
41
42struct _RWSTD_CLASS_EXPORT locale;
43
44} // namespace std
45
46
48
49class _RWSTD_EXPORT __rw_locale;
50
51struct __rw_access;
52
53struct _RWSTD_EXPORT __rw_facet: __rw_synchronized
54{
55 // the type of a "constructor" function used to create facet objects
56 // of standard types by the library
57 typedef __rw_facet* (_C_ctor_t)(_RWSTD_SIZE_T, const char*);
58
59#if !defined (_MSC_VER) || 5 <= _RWSTD_VER_MAJOR
60
61 // disabled for binary compatibility with stdcxx 4.1.x for MSVC
62 // (the compiler mangles access specifiers into class members)
63protected:
64
65#endif // !MSVC || 5 <= stdcxx version
66
67 explicit __rw_facet (_RWSTD_SIZE_T = 0);
68
69 virtual ~__rw_facet ();
70
71public:
72
73 // types of standard facets; only globally managed facets (i.e.,
74 // standard facets created internally) set this member, user-created
75 // facet objects of any types set their type to _C_unknown
76
77 // NOTE: the values and order of all the enumerators below are important
78 // any changes may affect the binary compatibility of the library
79
80 enum _C_facet_type {
81 /* -1 */ _C_invalid = -1, // marked e.g., when deleted
82 /* 0 */ _C_unknown = 0, // user-defined
83
84 // narrow character specializations
85
86 // classic versions // byname versions
87 //
88 /* id */ // <-- facet id, i.e. the value of Facet::id._C_val
89
90 // collate category
91 /* 1 */ _C_collate, _C_collate_byname,
92 // ctype category
93 /* 3 */ _C_codecvt, _C_codecvt_byname,
94 /* 5 */ _C_ctype, _C_ctype_byname,
95 // monetary category
96 /* 7 */ _C_moneypunct, _C_moneypunct_byname,
97 /* 9 */ _C_moneypunct_intl, _C_moneypunct_intl_byname,
98 /* 11 */ _C_money_get, _C_nonexistent_0,
99 /* 13 */ _C_money_put, _C_nonexistent_1,
100 // numeric category
101 /* 15 */ _C_numpunct, _C_numpunct_byname,
102 /* 17 */ _C_num_get, _C_nonexistent_2,
103 /* 19 */ _C_num_put, _C_nonexistent_3,
104 // time category
105 /* 21 */ _C_time_get, _C_time_get_byname,
106 /* 23 */ _C_time_put, _C_time_put_byname,
107 // messages category
108 /* 25 */ _C_messages, _C_messages_byname,
109
110 // wide character specializations
111
112 // classic versions // byname versions
113 /* 27 */ _C_wcollate, _C_wcollate_byname,
114 /* 29 */ _C_wcodecvt, _C_wcodecvt_byname,
115 /* 31 */ _C_wctype, _C_wctype_byname,
116 /* 33 */ _C_wmoneypunct, _C_wmoneypunct_byname,
117 /* 35 */ _C_wmoneypunct_intl, _C_wmoneypunct_intl_byname,
118 /* 37 */ _C_wmoney_get, _C_nonexistent_4,
119 /* 39 */ _C_wmoney_put, _C_nonexistent_5,
120 /* 41 */ _C_wnumpunct, _C_wnumpunct_byname,
121 /* 43 */ _C_wnum_get, _C_nonexistent_6,
122 /* 45 */ _C_wnum_put, _C_nonexistent_7,
123 /* 47 */ _C_wtime_get, _C_wtime_get_byname,
124 /* 49 */ _C_wtime_put, _C_wtime_put_byname,
125 /* 51 */ _C_wmessages, _C_wmessages_byname,
126
127 // the value of each standard facet's id is computed
128 // as (facet_type + 1) / 2; the value is stored in
129 // each facet's *__rw_facet::_C_pid member
130
131 // the value of the first available (non-standard)
132 // facet's id is computed as (_C_last_type / 2 + 1)
133
134 // note that this value determines the binary footprint of each facet
135 // changing it affects the binary compatibility of the localization
136 // library
137 /* 52 */ _C_last_type = _C_wmessages_byname
138 };
139
140 // unique fundamental type id
141 enum _C_type_id {
142 _C_signed = 0x100, _C_ptr = 0x200, _C_cont = 0x400,
143 _C_integral = 0x800, _C_floating = 0x1000, _C_typemask = 0x00ff,
144 _C_bool = 0,
145 _C_char = 1 | _C_integral,
146 _C_uchar = 2 | _C_integral, _C_schar = _C_uchar | _C_signed,
147 _C_ushort = 3 | _C_integral, _C_short = _C_ushort | _C_signed,
148 _C_uint = 4 | _C_integral, _C_int = _C_uint | _C_signed,
149 _C_ulong = 5 | _C_integral, _C_long = _C_ulong | _C_signed,
150 _C_ullong = 6 | _C_integral, _C_llong = _C_ullong | _C_signed,
151 _C_float = 7 | _C_floating,
152 _C_double = 8 | _C_floating,
153 _C_ldouble = 9 | _C_floating,
154 _C_void = 10, _C_pvoid = _C_void | _C_ptr,
155 _C_wchar_t = 11
156 };
157
158 enum {
159 // SunOS prepends the separator charater to the beginning
160 // of locale names, e.g., "/en_US/de_DE/fr_FR/..."
161 _C_prepend_cat_sep = 0x01,
162
163 // Linux uses the names of LC_XXX constants in combined
164 // locale names,
165 // e.g., "LC_CYPE=en_US;LC_COLLATE=de_DE;LC_MONETARY=fr_FR..."
166 _C_use_cat_names = 0x02,
167
168 // HP-UX, for instance, keeps even trivial locale names
169 // fully expanded
170 // (e.g., setlocale ("C") will return "C C C C C C")
171 // and doesn't include category names in (combined or others)
172 // locale names
173 _C_condensed_name = 0x04,
174
175 // bits to determine whether and when libc locale will be
176 // used as an implementation of C++ locale functionality
177 //
178 // libc libstd effect
179 // 0 0 use own implementation, fall back on libc if that fails
180 // 0 1 use own implementation only, never libc
181 // 1 0 use libc implementation only, never own
182 // 1 1 try libc implementation first, own if that fails
183 _C_use_libc = 0x08,
184 _C_use_libstd = 0x10
185 };
186
187 // global options controlling the behavior of locale and facets
188 static int _C_opts;
189
190 // returns a pointer to the facet's implementation data
191 // if it exists, 0 otherwise
192 const void* _C_data () const {
193 return _C_impsize ? _C_impdata
194 : _RWSTD_CONST_CAST (__rw_facet*, this)->_C_get_data ();
195 }
196
197 const char* _C_get_name () const {
198 return _C_name ? _C_name : "C";
199 }
200
201protected:
202
203 // set facet locale name (will allocate if bufsize is too small)
204 void _C_set_name (const char*, char*, _RWSTD_SIZE_T);
205
206 const char *_C_name; // name of locale associated with facet
207 char *_C_buf; // character buffer name may be stored in
208 const void *_C_impdata; // implementation data (e.g., punct)
209 _RWSTD_SIZE_T _C_impsize; // size of implementation data
210
211private:
212
213 _C_facet_type _C_type; // facet type (see above)
214 _RWSTD_SIZE_T _C_ref; // reference count (> 0)
215 _RWSTD_SIZE_T *_C_pid; // pointer to the static Facet::id._C_id
216
217 // standard facets' id's are computed as (_C_type + 1) / 2
218 // standard facet's base type is computed as 2 * Facet::id._C_id - 1
219
220 __rw_facet (const __rw_facet&); // not defined
221 void operator= (const __rw_facet&); // not defined
222
223 const void* _C_get_data ();
224
225 static __rw_facet*
226 _C_manage (__rw_facet*, _C_facet_type, const char*, _C_ctor_t*);
227
228 friend struct _STD::locale;
229 friend class __rw_locale;
230 friend struct __rw_facet_id;
231 friend struct __rw_access;
232};
233
234
235struct _RWSTD_EXPORT __rw_facet_id
236{
237#ifdef _RWSTD_NO_SPECIALIZED_FACET_ID
238
239 __rw_facet_id () {
240 // _C_id member zero-initialized (i.e., invalidated) by the system
241 // for __rw_facet_id objects with static storage duration, the only
242 // ones locale ever references
243 }
244
245#else // if !defined (_RWSTD_NO_SPECIALIZED_FACET_ID)
246
247 enum _C_init_id { _C_Init };
248
249 __rw_facet_id (_C_init_id = _C_Init) {
250 // same as above except that Facet::id is explicitly specialized
251 // for all standard facet base classes in order to guarantee one
252 // instance of each in a program; the definition of the explicit
253 // specialization is distinguished from the declaration by the
254 // presence of an initializer
255 }
256
257#endif // _RWSTD_NO_SPECIALIZED_FACET_ID
258
259private:
260
261 __rw_facet_id (const __rw_facet_id&); // not defined
262 void operator= (const __rw_facet_id&); // not defined
263
264 // initialize id to the given value if within the valid range
265 // otherwise to the next value generated by the id generator
266 _RWSTD_SIZE_T _C_init () const;
267
268 _MUTABLE _RWSTD_SIZE_T _C_id; // unique id > 0
269
270 friend class __rw_locale;
271 friend struct _STD::locale;
272 friend struct __rw_access;
273};
274
275
276// does the necessary path calculations and mapping of locale databases
277const void*
278__rw_get_facet_data (int, _RWSTD_SIZE_T&, const char*, const char* = 0);
279
280// its counterpart - does the database unmapping
281void __rw_release_facet_data (const void*, _RWSTD_SIZE_T);
282
283} // namespace __rw
284
285
286#endif // _RWSTD_LOC_FACET_H_INCLUDED
#define _RWSTD_CLASS_EXPORT
Definition _defs.h:486
#define _RWSTD_EXPORT
Definition _defs.h:485
#define _RWSTD_NAMESPACE(name)
Definition _defs.h:567
#define _MUTABLE
Definition _defs.h:505
#define _RWSTD_CONST_CAST(T, x)
Definition _defs.h:536
Definition json.h:5363