Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
_localedef.h
Go to the documentation of this file.
1
29#ifndef _RWSTD_LOC_LOCALEDEF_H_INCLUDED
30#define _RWSTD_LOC_LOCALEDEF_H_INCLUDED
31
32
33#include <rw/_defs.h>
34
35
36#if 6 <= _RWSTD_HP_aCC_MAJOR
37 // suppress HP aCC 6 remarks
38 // 4298: addition result truncated before cast to bigger sized type
39 // 4299: multiply result truncated before cast to bigger sized type
40# pragma diag_suppress 4298, 4299
41#endif // aCC >= 6.0
42
43
45
46// LC_CTYPE structures
47struct __rw_mask_elm
48{
49 wchar_t ch; // the wide character value
50 _RWSTD_UINT32_T mask; // the mask for that character
51};
52
53struct __rw_upper_elm
54{
55 wchar_t lower; // the lower case wide character
56 wchar_t upper; // the upper case wide character that the lower maps to
57};
58
59struct __rw_lower_elm
60{
61 wchar_t upper; // the upper case wide character
62 wchar_t lower; // the lower case wide character that the upper maps to
63};
64
65
66// returns a pointer to a character at the given byte offset
67// from the end of the structure
68#define _RWSTD_CHAR_ARRAY(off) \
69 (_RWSTD_REINTERPRET_CAST (const char*, this + 1) + (off))
70
71// returns a pointer to a wide character at the given byte offset
72// from the end of the structure
73#define _RWSTD_WCHAR_T_ARRAY(off) \
74 _RWSTD_REINTERPRET_CAST (const wchar_t*, _RWSTD_CHAR_ARRAY (off))
75
76#define _RWSTD_UINT_ARRAY(off) \
77 _RWSTD_REINTERPRET_CAST (const _RWSTD_UINT32_T*, _RWSTD_CHAR_ARRAY (off))
78
79// returns a pointer to the i-th element of an array
80// at the given byte offset from the end of the structure
81#define _RWSTD_ARRAY_ELM(T, off, i) \
82 _RWSTD_REINTERPRET_CAST (const T*, \
83 ( _RWSTD_REINTERPRET_CAST (const char*, this + 1) \
84 + (off) + (i) * sizeof (T)))
85
86
87struct __rw_codecvt_t
88{
89 // offsets from the end of *this
90 _RWSTD_UINT32_T codeset_off;
91 _RWSTD_UINT32_T charmap_off;
92 _RWSTD_UINT32_T n_to_w_tab_off;
93 _RWSTD_UINT32_T w_to_n_tab_off;
94 _RWSTD_UINT32_T utf8_to_ext_tab_off;
95 _RWSTD_UINT32_T wchar_off;
96 _RWSTD_UINT32_T xliteration_off;
97 _RWSTD_UINT32_T codecvt_ext_off;
98
99 // the size of the longest multibyte character
100 _RWSTD_UINT8_T mb_cur_max;
101
102 // the name of the codeset and its database file
103 const char* codeset_name () const {
104 return _RWSTD_CHAR_ARRAY (codeset_off);
105 }
106
107 // the name of the character map description file
108 const char* charmap_name () const {
109 return _RWSTD_CHAR_ARRAY (charmap_off);
110 }
111
112 // pointer to the first table for wide to narrow conversions
113 const _RWSTD_UINT32_T* w_to_n_tab () const {
114 return _RWSTD_UINT_ARRAY (w_to_n_tab_off);
115 }
116
117 // pointer to the first table for narrow to wide conversions
118 const _RWSTD_UINT32_T* n_to_w_tab () const {
119 return _RWSTD_UINT_ARRAY (n_to_w_tab_off);
120 }
121
122 // pointer to the first table for utf8 to external conversions
123 const _RWSTD_UINT32_T* utf8_to_ext_tab () const {
124 return _RWSTD_UINT_ARRAY (utf8_to_ext_tab_off);
125 }
126
127 // returns the value of the wide character at a given offset
128 // obtained from one of the n_to_w_tab() tables
129 wchar_t get_internal_at_offset (_RWSTD_UINT32_T off) const {
130 return *(_RWSTD_ARRAY_ELM (wchar_t, wchar_off, off * 2));
131
132 }
133
134 // returns the value of the UCS character at a given offset
135 wchar_t get_ucs4_at_offset (_RWSTD_UINT32_T off) const {
136 return *(_RWSTD_ARRAY_ELM (wchar_t, wchar_off, off * 2 + 1));
137 }
138
139 const void* get_ext () const {
140 return _RWSTD_CHAR_ARRAY (codecvt_ext_off);
141 }
142
143 const _RWSTD_UINT32_T* get_xliteration_tab () const {
144 return _RWSTD_UINT_ARRAY (xliteration_off);
145 }
146};
147
148
149// LC_CTYPE structure
150struct __rw_ctype_t
151{
152 _RWSTD_UINT32_T codeset_off; // byte offset of the codeset_name
153 _RWSTD_UINT32_T charmap_off; // byte offset of the charmap name
154 _RWSTD_UINT32_T wmask_s;
155 _RWSTD_UINT32_T wtoupper_off; // byte offset of the wtoupper_tab
156 _RWSTD_UINT32_T wtolower_off; // byte offset of the wtolower_tab
157 _RWSTD_UINT32_T wmask_off; // byte offset of the wmask_tab_tab
158
159 // this is added to allow for future extensions
160 _RWSTD_UINT32_T ctype_ext_off; // extended ctype data offset
161
162 _RWSTD_UINT8_T toupper_tab[256]; // the narrow char to_upper table
163 _RWSTD_UINT8_T tolower_tab[256]; // the narrow char to_lower table
164 _RWSTD_UINT32_T mask_tab[256]; // the narrow char mask table
165 _RWSTD_UINT8_T mb_cur_max; // max number of bytes per MB character
166
167 _RWSTD_SIZE_T wtoupper_s () const {
168 return (wtolower_off - wtoupper_off) / sizeof (__rw_upper_elm);
169 }
170
171 _RWSTD_SIZE_T wtolower_s () const {
172 return (wmask_off - wtolower_off) / sizeof (__rw_lower_elm);
173 }
174
175 _RWSTD_SIZE_T codeset_s () const {
176 return charmap_off - codeset_off;
177 }
178
179 _RWSTD_SIZE_T charmap_s () const {
180 return wtoupper_off - charmap_off;
181 }
182
183 const char* codeset_name () const {
184 return _RWSTD_CHAR_ARRAY (codeset_off);
185 }
186
187 const char* charmap_name () const {
188 return _RWSTD_CHAR_ARRAY (charmap_off);
189 }
190
191 __rw_upper_elm wtoupper_tab (_RWSTD_SIZE_T idx) const {
192 return *_RWSTD_ARRAY_ELM (__rw_upper_elm, wtoupper_off, idx);
193 }
194
195 __rw_lower_elm wtolower_tab (_RWSTD_SIZE_T idx) const {
196 return *_RWSTD_ARRAY_ELM (__rw_lower_elm, wtolower_off, idx);
197 }
198
199 __rw_mask_elm wmask_tab (_RWSTD_SIZE_T idx) const {
200 return *_RWSTD_ARRAY_ELM (__rw_mask_elm, wmask_off, idx);
201 }
202
203 const void* get_ext () const {
204 return _RWSTD_CHAR_ARRAY (ctype_ext_off);
205 }
206
207};
208
209
210// LC_COLLATE structure
211struct __rw_collate_t
212{
213 _RWSTD_UINT32_T codeset_off; // byte offset of the codeset_name
214 _RWSTD_UINT32_T charmap_off; // byte offset to the charmap name
215
216 _RWSTD_UINT32_T n_ce_tab_off;
217 _RWSTD_UINT32_T w_ce_tab_off;
218
219 _RWSTD_UINT32_T weight_tab_off; // offset to the weight information
220
221 _RWSTD_UINT32_T n_char_tab_off; // offset to the first nchar table
222 _RWSTD_UINT32_T n_char_off_tab_off; // offset to offset table for nchars
223 _RWSTD_UINT32_T n_char_first_char_off; // offset to first character info
224
225 _RWSTD_UINT32_T w_char_tab_off; // offset to the first wide character table
226 _RWSTD_UINT32_T w_char_off_tab_off; // offset to offset table for wchars
227 _RWSTD_UINT32_T w_char_first_char_off; // offset to first character info
228
229 _RWSTD_UINT32_T n_ce_off_tab_off;
230 _RWSTD_UINT32_T w_ce_off_tab_off;
231 _RWSTD_UINT32_T n_ce_first_char_off;
232 _RWSTD_UINT32_T w_ce_first_char_off;
233 _RWSTD_UINT32_T n_ce_last_char_off;
234 _RWSTD_UINT32_T w_ce_last_char_off;
235
236 _RWSTD_UINT32_T undefined_weight_idx;
237
238 _RWSTD_UINT32_T elm_size; // number of bytes in each coll array elem
239 _RWSTD_UINT32_T num_elms; // numer of elements in coll array
240
241 _RWSTD_UINT32_T num_wchars; // number of wide chars in wchar mapping
242
243 // this is added to allow for future extensions
244 _RWSTD_UINT32_T collate_ext_off; // extended collate data offset
245
246 _RWSTD_UINT32_T undefined_optimization;
247
248 _RWSTD_UINT8_T longest_weight; // the longest weight value
249 _RWSTD_UINT8_T num_weights; // number of weights
250 _RWSTD_UINT8_T largest_ce;
251
252 _RWSTD_UINT8_T weight_type[256]; // weight types (ex. forward)
253
254 // get the offset of a table number `tabno'
255 _RWSTD_UINT32_T get_n_tab_off (_RWSTD_UINT32_T tabno) const {
256 return (_RWSTD_UINT32_T)
257 (sizeof (_RWSTD_UINT32_T) * (*(const _RWSTD_UINT32_T*)(
258 (_RWSTD_SIZE_T)((const char*)this + sizeof *this
259 + n_char_off_tab_off
260 + (tabno * sizeof (_RWSTD_UINT32_T))))));
261 }
262 _RWSTD_UINT32_T get_n_ce_tab_off (_RWSTD_UINT32_T tabno) const {
263 return (_RWSTD_UINT32_T)
264 (sizeof (_RWSTD_UINT32_T) * (*(const _RWSTD_UINT32_T*)(
265 (_RWSTD_SIZE_T)((const char*)this + sizeof *this
266 + n_ce_off_tab_off
267 + (tabno * sizeof (_RWSTD_UINT32_T))))));
268 }
269
270 _RWSTD_UINT32_T get_w_ce_tab_off (_RWSTD_UINT32_T tabno) const {
271 return (_RWSTD_UINT32_T)
272 (sizeof (_RWSTD_UINT32_T) * (*(const _RWSTD_UINT32_T*)(
273 (_RWSTD_SIZE_T)((const char*)this + sizeof *this
274 + w_ce_off_tab_off
275 + (tabno * sizeof (_RWSTD_UINT32_T))))));
276 }
277
278 _RWSTD_UINT8_T get_first_char_in_n_tab (_RWSTD_UINT32_T tabno) const {
279 return *((const _RWSTD_UINT8_T*)this + sizeof *this
280 + n_char_first_char_off + tabno);
281
282 }
283
284 _RWSTD_UINT8_T get_first_char_in_n_ce_tab (_RWSTD_UINT32_T tabno) const {
285 return *((const _RWSTD_UINT8_T*)this + sizeof *this
286 + n_ce_first_char_off + tabno);
287 }
288
289 _RWSTD_UINT8_T get_first_char_in_w_ce_tab (_RWSTD_UINT32_T tabno) const {
290 return *((const _RWSTD_UINT8_T*)this + sizeof *this
291 + w_ce_first_char_off + tabno);
292 }
293
294 _RWSTD_UINT8_T get_last_char_in_n_ce_tab (_RWSTD_UINT32_T tabno) const {
295 return *((const _RWSTD_UINT8_T*)this + sizeof *this
296 + n_ce_last_char_off + tabno);
297 }
298
299 _RWSTD_UINT8_T get_last_char_in_w_ce_tab (_RWSTD_UINT32_T tabno) const {
300 return *((const _RWSTD_UINT8_T*)this + sizeof *this
301 + w_ce_last_char_off + tabno);
302 }
303
304 const _RWSTD_UINT32_T* get_n_tab (_RWSTD_UINT32_T tabno) const {
305 return (const _RWSTD_UINT32_T*)
306 ((_RWSTD_SIZE_T)((const char*)this + sizeof *this
307 + n_char_tab_off + get_n_tab_off (tabno)));
308
309 }
310 const _RWSTD_UINT32_T* get_n_ce_tab (_RWSTD_UINT32_T tabno) const {
311 return (const _RWSTD_UINT32_T*)
312 ((_RWSTD_SIZE_T)((const char*)this + sizeof *this
313 + n_ce_tab_off + get_n_ce_tab_off (tabno)));
314 }
315
316 const _RWSTD_UINT32_T* get_w_ce_tab (_RWSTD_UINT32_T tabno) const {
317 return (const _RWSTD_UINT32_T*)
318 ((_RWSTD_SIZE_T)((const char*)this + sizeof *this
319 + w_ce_tab_off + get_w_ce_tab_off (tabno)));
320 }
321
322 _RWSTD_UINT32_T get_w_tab_off (_RWSTD_UINT32_T tabno) const {
323 return (_RWSTD_UINT32_T)
324 (sizeof (_RWSTD_UINT32_T) * (*(const _RWSTD_UINT32_T*)(
325 (_RWSTD_SIZE_T)((const char*)this + sizeof *this
326 + w_char_off_tab_off
327 + (tabno * sizeof (_RWSTD_UINT32_T))))));
328 }
329
330 _RWSTD_UINT8_T get_first_char_in_w_tab (_RWSTD_UINT32_T tabno) const {
331 return *((const _RWSTD_UINT8_T*)this + sizeof *this
332 + w_char_first_char_off + tabno);
333
334 }
335
336 const _RWSTD_UINT32_T* get_w_tab (_RWSTD_UINT32_T tabno) const {
337 return (const _RWSTD_UINT32_T*)
338 ((_RWSTD_SIZE_T)((const char*)this + sizeof *this
339 + w_char_tab_off + get_w_tab_off (tabno)));
340
341 }
342
343 const _RWSTD_UINT32_T* coll () const {
344 return _RWSTD_UINT_ARRAY (weight_tab_off);
345 }
346
347 const char* codeset_name () const {
348 return _RWSTD_CHAR_ARRAY (codeset_off);
349 }
350
351 const char* charmap_name () const {
352 return _RWSTD_CHAR_ARRAY (charmap_off);
353 }
354
355 const _RWSTD_UINT32_T* get_weight (_RWSTD_UINT32_T idx) const {
356 return (const _RWSTD_UINT32_T*)((_RWSTD_SIZE_T)((const char*)coll ()
357 + elm_size * idx));
358 }
359
360 const void* get_ext () const {
361 return _RWSTD_CHAR_ARRAY (collate_ext_off);
362 }
363};
364
365
366// punct structure for monetary and numeric facets
367struct __rw_punct_t
368{
369 _RWSTD_UINT32_T decimal_point_off [2]; // narrow and wide decimal_point
370 _RWSTD_UINT32_T thousands_sep_off [2]; // narrow and wide thousands_sep
371 _RWSTD_UINT32_T grouping_off; // grouping string
372 _RWSTD_UINT32_T punct_ext_off; // offset of extended data
373
374 // decimal_point (0) points to a char*, decimal_point (1) to wchar_t*
375 const void* decimal_point (bool wide) const {
376 return _RWSTD_CHAR_ARRAY (decimal_point_off [wide]);
377 }
378
379 // thousands_sep (0) points to a char*, thousands_sep (1) to wchar_t*
380 const void* thousands_sep (bool wide) const {
381 return _RWSTD_CHAR_ARRAY (thousands_sep_off [wide]);
382 }
383
384 const void* grouping () const {
385 return _RWSTD_CHAR_ARRAY (grouping_off);
386 }
387
388 const void* get_ext () const {
389 return _RWSTD_CHAR_ARRAY (punct_ext_off);
390 }
391};
392
393
394// LC_MONETARY structure
395struct __rw_mon_t
396{
397 _RWSTD_UINT32_T codeset_off; // byte offset of the codeset_name
398 _RWSTD_UINT32_T charmap_off; // byte offset to the charmap name
399
400 _RWSTD_UINT32_T curr_symbol_off [2][2]; // byte offset of curr_symbol
401 _RWSTD_UINT32_T positive_sign_off [2]; // byte offset of positive_sign
402 _RWSTD_UINT32_T negative_sign_off [2]; // byte offset of negative_sign
403
404 // this is added to allow for future extensions
405 _RWSTD_UINT32_T monetary_ext_off; // extended monetary data offset
406
407 // monetary format pattern for positive values
408 char pos_format[2][4];
409
410 // monetary format pattern for negative values
411 char neg_format[2][4];
412
413 // num of frac digits to write using currency_symbol
414 char frac_digits[2];
415
416 // 0 = currency symbol then pos value
417 // 1 = pos value then currency symbol
418 char p_cs_precedes[2];
419
420
421 // separation of curr symbol and value
422 // 0 - no separation
423 // 1 = if the symbol and sign are adjacent, a space separates them from
424 // the value; otherwise, a space separates the symbol from the value
425 // 2 = if the symbol and sign are adjacent, a space separates them;
426 // otherwise, a space separates the sign from the value
427 char p_sep_by_space[2];
428
429 // 0 = currency symbol succeeds the neg value
430 // 1 = currency symbol precedes the neg value
431 char n_cs_precedes[2];
432
433 // 0 = no space seperates curr sym from neg value
434 // 1 = space seperates symbol from neg value
435 // 2 = space seperates symbol and sign string
436 char n_sep_by_space[2];
437
438 // 0 = Parentheses enclose the quantity of the curr sym
439 // 1 = Sign string precedes the quantity and curr sym
440 // 2 = sign string succeeds the quantity and curr sym
441 // 3 = sign string precedes the curr symbol
442 // 4 = sign string succeeds the curr symbol
443 char p_sign_posn[2];
444
445 // 0 = Parentheses enclose the quantity of the curr sym
446 // 1 = Sign string precedes the quantity and curr sym
447 // 2 = sign string succeeds the quantity and curr sym
448 // 3 = sign string precedes the curr symbol
449 // 4 = sign string succeeds the curr symbol
450 char n_sign_posn[2];
451
452 const void* curr_symbol (bool intl, bool wide) const {
453 return _RWSTD_CHAR_ARRAY (curr_symbol_off [intl][wide]);
454 }
455
456 const void* positive_sign (bool wide) const {
457 return _RWSTD_CHAR_ARRAY (positive_sign_off [wide]);
458 }
459
460 const void* negative_sign (bool wide) const {
461 return _RWSTD_CHAR_ARRAY (negative_sign_off [wide]);
462 }
463
464 const char* codeset_name () const {
465 return _RWSTD_CHAR_ARRAY (codeset_off);
466 }
467
468 const char* charmap_name () const {
469 return _RWSTD_CHAR_ARRAY (charmap_off);
470 }
471
472 const void* get_ext () const {
473 return _RWSTD_CHAR_ARRAY (monetary_ext_off);
474 }
475};
476
477
478// LC_NUMERIC structure
479struct __rw_num_t
480{
481 _RWSTD_UINT32_T codeset_off; // byte offset of the codeset_name
482 _RWSTD_UINT32_T charmap_off; // byte offset to the charmap name
483
484 _RWSTD_UINT32_T truename_off [2]; // offset of narrow and wide truename
485 _RWSTD_UINT32_T falsename_off [2]; // offset of narrow and wide falsename
486
487 _RWSTD_UINT32_T numeric_ext_off; // extended numeric data offset
488
489 const void* truename (bool wide) const {
490 return _RWSTD_CHAR_ARRAY (truename_off [wide]);
491 }
492
493 const void* falsename (bool wide) const {
494 return _RWSTD_CHAR_ARRAY (falsename_off [wide]);
495 }
496
497 const char* codeset_name () const {
498 return _RWSTD_CHAR_ARRAY (codeset_off);
499 }
500
501 const char* charmap_name () const {
502 return _RWSTD_CHAR_ARRAY (charmap_off);
503 }
504
505 const void* get_ext () const {
506 return _RWSTD_CHAR_ARRAY (numeric_ext_off);
507 }
508};
509
510
511// LC_MESSAGES structure
512struct __rw_messages_t
513{
514 _RWSTD_UINT32_T codeset_off;
515 _RWSTD_UINT32_T charmap_off;
516
517 _RWSTD_UINT32_T yesexpr_off[2];
518 _RWSTD_UINT32_T noexpr_off[2];
519
520 _RWSTD_UINT32_T messages_ext_off;
521
522 const void* yesexpr (bool wide) const {
523 return _RWSTD_CHAR_ARRAY (yesexpr_off[wide]);
524 }
525
526 const void* noexpr (bool wide) const {
527 return _RWSTD_CHAR_ARRAY (noexpr_off[wide]);
528 }
529
530 const char* codeset_name () const {
531 return _RWSTD_CHAR_ARRAY (codeset_off);
532 }
533
534 const char* charmap_name () const {
535 return _RWSTD_CHAR_ARRAY (charmap_off);
536 }
537
538 const void* get_ext () const {
539 return _RWSTD_CHAR_ARRAY (messages_ext_off);
540 }
541
542};
543
544
545// LC_TIME structure
546struct __rw_time_t
547{
548 _RWSTD_UINT32_T codeset_off; // byte offset of the codeset_name
549 _RWSTD_UINT32_T charmap_off; // byte offset to the charmap name
550 _RWSTD_UINT32_T num_eras; // the number of eras
551 _RWSTD_UINT32_T num_alt_digits; // the number of alt_digits
552
553 _RWSTD_UINT32_T era_off; // bute offset of the first era
554 _RWSTD_UINT32_T alt_digits_off; // byte offset to offset array
555 _RWSTD_UINT32_T abday_off[2][7]; // byte offset of each abday
556 _RWSTD_UINT32_T day_off[2][7]; // byte offset of each day
557 _RWSTD_UINT32_T abmon_off[2][12]; // byte offset of each abmon
558 _RWSTD_UINT32_T mon_off[2][12]; // byte offset of each mon
559 _RWSTD_UINT32_T am_pm_off[2][2]; // byte offset of am and pm
560 _RWSTD_UINT32_T d_t_fmt_off[2]; // byte offset of d_t_fmt
561 _RWSTD_UINT32_T d_fmt_off[2]; // byte offset of d_fmt
562 _RWSTD_UINT32_T t_fmt_off[2]; // byte offset of t_fmt
563 _RWSTD_UINT32_T t_fmt_ampm_off[2]; // byte offset of t_fmt_ampm
564 _RWSTD_UINT32_T era_d_t_fmt_off[2]; // byte offset of era_d_t_fmt
565 _RWSTD_UINT32_T era_d_fmt_off[2]; // byte offset of era_d_fmt
566 _RWSTD_UINT32_T era_t_fmt_off[2]; // byte offset of era_t_fmt
567
568 // this is added to allow for future extensions
569 _RWSTD_UINT32_T time_ext_off; // extended time data offset
570
571 // %a: abbreviated weekday name [tm_wday]
572 const void* abday (_RWSTD_SIZE_T idx, bool wide) const {
573 return _RWSTD_CHAR_ARRAY (abday_off [wide][idx]);
574 }
575
576 // %A: full weekday name [tm_wday]
577 const void* day (_RWSTD_SIZE_T idx, bool wide) const {
578 return _RWSTD_CHAR_ARRAY (day_off [wide][idx]);
579 }
580
581 // %b: abbreviated month name [tm_mon]
582 const void* abmon (_RWSTD_SIZE_T idx, bool wide) const {
583 return _RWSTD_CHAR_ARRAY (abmon_off [wide][idx]);
584 }
585
586 // %B: full month name [tm_mon]
587 const void* mon (_RWSTD_SIZE_T idx, bool wide) const {
588 return _RWSTD_CHAR_ARRAY (mon_off [wide][idx]);
589 }
590
591 // %p: the locale's equivalent of the AM/PM designations
592 // associated with a 12-hour clock [tm_hour]
593 const void* am_pm (_RWSTD_SIZE_T idx, bool wide) const {
594 return _RWSTD_CHAR_ARRAY (am_pm_off [wide][idx]);
595 }
596
597 // %c: the appropriate date and time representation
598 const void* d_t_fmt (bool wide) const {
599 return _RWSTD_CHAR_ARRAY (d_t_fmt_off[wide]);
600 }
601
602 // %x: the appropriate date representation
603 const void* d_fmt (bool wide) const {
604 return _RWSTD_CHAR_ARRAY (d_fmt_off[wide]);
605 }
606
607 // %X: the appropriate time representation
608 const void* t_fmt (bool wide) const {
609 return _RWSTD_CHAR_ARRAY (t_fmt_off[wide]);
610 }
611
612 const void* t_fmt_ampm (bool wide) const {
613 return _RWSTD_CHAR_ARRAY (t_fmt_ampm_off[wide]);
614 }
615
616 struct era_t {
617 _RWSTD_UINT32_T name_off [2]; // narrow and wide era names
618 _RWSTD_UINT32_T fmt_off [2]; // narrow and wide format of the year
619
620 // negative offset represents direction of '-', otherwise '+'
621 _RWSTD_INT32_T offset; // year closest to start_date
622
623 // the beginning of time is represented by INT_MIN stored in
624 // year [1], and CHAR_MIN in month [1] and day [1]
625 // the end of time is represented by INT_MAX stored in
626 // year [1], and CHAR_MAX in month [1] and day [1]
627 _RWSTD_INT32_T year [2]; // start and end year
628 char month [2]; // start and end month [0..11]
629 char day [2]; // start and end day [1..31]
630 };
631
632 // era description segment
633 const era_t* era (_RWSTD_SIZE_T idx) const {
634 return _RWSTD_ARRAY_ELM (era_t, era_off, idx);
635 }
636
637 // the number of era description segments
638 _RWSTD_SIZE_T era_count () const {
639 return num_eras;
640 }
641
642 const void* era_name (_RWSTD_SIZE_T idx, bool wide) const {
643 return _RWSTD_CHAR_ARRAY (era (idx)->name_off[wide]);
644 }
645
646 const void* era_fmt (_RWSTD_SIZE_T idx, bool wide) const {
647 return _RWSTD_CHAR_ARRAY (era (idx)->fmt_off[wide]);
648 }
649
650 // %Ec: the locale's alternate date and time representation
651 const void* era_d_t_fmt (bool wide) const {
652 return _RWSTD_CHAR_ARRAY (era_d_t_fmt_off[wide]);
653 }
654
655 // %Ex: the locale's alternative date representation
656 const void* era_d_fmt (bool wide) const {
657 return _RWSTD_CHAR_ARRAY (era_d_fmt_off[wide]);
658 }
659
660 // %EX: the locale's alternative time representation
661 const void* era_t_fmt (bool wide) const {
662 return _RWSTD_CHAR_ARRAY (era_t_fmt_off[wide]);
663 }
664
665 // alternative symbols for digits, corresponding to the %O modifier
666 const void* alt_digits (_RWSTD_SIZE_T idx, bool wide) const {
668 (_RWSTD_UINT32_T, alt_digits_off,
669 idx * 2 + wide));
670 }
671
672 // number of alternative digits
673 _RWSTD_UINT32_T alt_digits_count () const {
674 return num_alt_digits;
675 }
676
677 const char* codeset_name () const {
678 return _RWSTD_CHAR_ARRAY (codeset_off);
679 }
680
681 const char* charmap_name () const {
682 return _RWSTD_CHAR_ARRAY (charmap_off);
683 }
684
685 const void* get_ext () const {
686 return _RWSTD_CHAR_ARRAY (time_ext_off);
687 }
688};
689
690
691#if 6 <= _RWSTD_aCC_MAJOR
692 // restore HP aCC 6 remarks suppressed above to their default state
693# pragma diag_default 4298, 4299
694#endif // aCC >= 6
695
696
697static inline _RWSTD_SIZE_T
698__rw_itoutf8 (_RWSTD_UINT32_T wchar, char *to)
699{
700 typedef _RWSTD_UINT8_T _UChar;
701
702 if (wchar < 0x80U) {
703 to [0] = _UChar (wchar);
704 return 1U;
705 }
706 if (wchar < 0x800U) {
707 to [0] = _UChar (0xc0U | (wchar >> 6));
708 to [1] = _UChar (0x80U | (wchar & 0x3fU));
709 return 2U;
710 }
711 if (wchar < 0x10000U) {
712 to [0] = _UChar (0xe0U | (wchar >> 12));
713 to [1] = _UChar (0x80U | (wchar >> 6 & 0x3fU));
714 to [2] = _UChar (0x80U | (wchar & 0x3fU));
715 return 3U;
716 }
717 if (wchar < 0x200000U) {
718 to [0] = _UChar (0xf0U | (wchar >> 18));
719 to [1] = _UChar (0x80U | (wchar >> 12 & 0x3fU));
720 to [2] = _UChar (0x80U | (wchar >> 6 & 0x3fU));
721 to [3] = _UChar (0x80U | (wchar & 0x3fU));
722 return 4U;
723 }
724 if (wchar < 0x4000000U) {
725 to [0] = _UChar (0xf8U | (wchar >> 24));
726 to [1] = _UChar (0x80U | (wchar >> 18 & 0x3fU));
727 to [2] = _UChar (0x80U | (wchar >> 12 & 0x3fU));
728 to [3] = _UChar (0x80U | (wchar >> 6 & 0x3fU));
729 to [4] = _UChar (0x80U | (wchar & 0x3fU));
730 return 5U;
731 }
732 to [0] = _UChar (0xfcU | (wchar >> 30));
733 to [1] = _UChar (0x80U | (wchar >> 24 & 0x3fU));
734 to [2] = _UChar (0x80U | (wchar >> 18 & 0x3fU));
735 to [3] = _UChar (0x80U | (wchar >> 12 & 0x3fU));
736 to [4] = _UChar (0x80U | (wchar >> 6 & 0x3fU));
737 to [5] = _UChar (0x80U | (wchar & 0x3fU));
738 return 6U;
739}
740
741
742// converts a single UTF-8 character starting at `from' to its UCS-4
743// representation and, if successful, stores the result in `*ret'
744// returns a pointer to the beginning of the next UTF-8 character
745// or 0 on error
746// returns `from' when the sequence in the range [`from', `from_end')
747// forms an incomplete UTF-8 character
748static inline const char*
749__rw_utf8toucs4 (_RWSTD_INT32_T *ret, const char *from, const char *from_end)
750{
751 _RWSTD_ASSERT (0 != ret);
752 _RWSTD_ASSERT (0 != from);
753 _RWSTD_ASSERT (from <= from_end);
754
755 typedef _RWSTD_INT32_T _Int32;
756
757 const _RWSTD_UINT8_T* const byte =
758 _RWSTD_REINTERPRET_CAST (const _RWSTD_UINT8_T*, from);
759
760 if (byte [0] < 0x80U) {
761 *ret = _Int32 (byte [0]);
762 return from + 1;
763 }
764
765 if (byte [0] < 0xc2U) {
766 // sequences beginning with a byte in the range [0x80, 0xc2)
767 // do not form a valid UTF-8 character
768 return 0;
769 }
770
771 const _RWSTD_PTRDIFF_T len = from_end - from;
772
773 if (byte [0] < 0xe0U) {
774 if (len < 2)
775 return from;
776
777 *ret = _Int32 ((byte [0] & 0x1fU) << 6 | byte [1] & 0x3fU);
778 return from + 2;
779 }
780
781 if (byte [0] < 0xf0U) {
782 if (len < 3)
783 return from;
784
785 *ret = _Int32 ( (byte [0] & 0x0fU) << 12
786 | (byte [1] & 0x3fU) << 6
787 | (byte [2] & 0x3fU));
788 return from + 3;
789 }
790
791 if (byte [0] < 0xf8U) {
792 if (len < 4)
793 return from;
794
795 *ret = _Int32 ( (byte [0] & 0x07U) << 18
796 | (byte [1] & 0x3fU) << 12
797 | (byte [2] & 0x3fU) << 6
798 | (byte [3] & 0x3fU));
799 return from + 4;
800 }
801
802 if (byte [0] < 0xfcU) {
803 if (len < 5)
804 return from;
805
806 *ret = _Int32 ( (byte [0] & 0x03U) << 24
807 | (byte [1] & 0x3fU) << 18
808 | (byte [2] & 0x3fU) << 12
809 | (byte [3] & 0x3fU) << 6
810 | (byte [4] & 0x3fU));
811 return from + 5;
812 }
813
814 if (byte [0] < 0xfeU) {
815 if (len < 6)
816 return from;
817
818 *ret = _Int32 ( (byte [0] & 0x01U) << 30
819 | (byte [1] & 0x3fU) << 24
820 | (byte [2] & 0x3fU) << 18
821 | (byte [3] & 0x3fU) << 12
822 | (byte [4] & 0x3fU) << 6
823 | (byte [5] & 0x3fU));
824 return from + 6;
825 }
826
827 return 0;
828}
829
830
831// looks up the offset of the wide character corresponing to the multibyte
832// character starting at `from'; returns the offset on success, UINT_MAX if
833// no such wide character exists (i.e., on conversion error), or any value
834// with bit 31 set if the the range [`from', `from_end') forms an incomplete
835// multibyte character (i.e., if it's an initial subsequence of one)
836static inline
837unsigned __rw_mbtowco (const unsigned *cvtbl,
838 const char *&from,
839 const char *from_end)
840{
841 typedef _RWSTD_UINT8_T _UChar;
842
843 // `bit31' has the most significant bit set and all others clear
844 const unsigned bit31 = 0x80000000U;
845
846 const char *next = from;
847
848 unsigned wc;
849
850 for (const unsigned *ptbl = cvtbl; (wc = ptbl [_UChar (*next)]) & bit31; ) {
851
852 // check if it is valid and if so, whether we have reached the
853 // end of the source sequence and found an incomplete character
854 // note, however, that an incomplete character does not mean
855 // partial conversion
856 if (wc == _RWSTD_UINT_MAX || ++next == from_end)
857 return wc;
858
859 // use the `wc' value to compute the address of the next table
860 ptbl = cvtbl + 256 * (wc & ~bit31);
861 }
862
863 from = next + 1;
864
865 return wc;
866}
867
868
869} // namespace __rw
870
871
872#endif // _RWSTD_LOC_LOCALEDEF_H_INCLUDED
const char lower[]
const char upper[]
#define off
Definition 17.names.cpp:507
#define offset
Definition 17.names.cpp:508
#define len
Definition 17.names.cpp:488
#define _RWSTD_REINTERPRET_CAST(T, x)
Definition _defs.h:535
#define _RWSTD_NAMESPACE(name)
Definition _defs.h:567
#define _RWSTD_ASSERT(ignore)
Definition _defs.h:1108
#define _RWSTD_UINT_ARRAY(off)
#define _RWSTD_ARRAY_ELM(T, off, i)
#define _RWSTD_CHAR_ARRAY(off)