Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenc_locale.h
Go to the documentation of this file.
00001 /* 00002 * Copyright (c) 1999 00003 * Silicon Graphics Computer Systems, Inc. 00004 * 00005 * Copyright (c) 1999 00006 * Boris Fomitchev 00007 * 00008 * This material is provided "as is", with absolutely no warranty expressed 00009 * or implied. Any use is at your own risk. 00010 * 00011 * Permission to use or copy this software for any purpose is hereby granted 00012 * without fee, provided the above notices are retained on all copies. 00013 * Permission to modify the code and to distribute modified code is granted, 00014 * provided the above notices are retained, and a notice that the code was 00015 * modified is included with the above copyright notice. 00016 * 00017 */ 00018 00019 /* 00020 * It is impossible to write the C++ locale library in terms of locales 00021 * as defined in the C standard. Instead, we write the C++ locale and I/O 00022 * library in terms of a low level C-like interface. This file defines 00023 * that interface. 00024 * 00025 * The low-level locale interface can't be written portably; there 00026 * must be a version of it for each platform that the C++ library 00027 * is ported to. On many systems this interface may be a thin wrapper 00028 * for existing functionality. 00029 */ 00030 00031 #ifndef _STLP_C_LOCALE_IMPL_H 00032 #define _STLP_C_LOCALE_IMPL_H 00033 00034 #include "stlport_prefix.h" 00035 00036 #include <wchar.h> /* for mbstate_t */ 00037 #include <stl/c_locale.h> 00038 00039 struct _Locale_name_hint; 00040 00041 #if defined (_GNU_SOURCE) && defined (__GLIBC__) && \ 00042 ((__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2)) 00043 # define _STLP_USE_GLIBC2_LOCALIZATION 00044 # include <nl_types.h> 00045 typedef nl_catd nl_catd_type; 00046 #else 00047 typedef int nl_catd_type; 00048 #endif 00049 00050 /* 00051 * A number: the maximum length of a simple locale name. 00052 * (i.e. a name like like en_US, as opposed to a name like 00053 * en_US/de_AT/de_AT/es_MX/en_US/en_US) */ 00054 #define _Locale_MAX_SIMPLE_NAME 256 00055 00056 #ifdef __cplusplus 00057 extern "C" { 00058 #endif 00059 00060 /* 00061 * Typedefs: 00062 */ 00063 typedef unsigned short int _Locale_mask_t; 00064 00065 /* Function called during STLport library load phase. Might contain any 00066 * code necessary to the platform localization layer. 00067 */ 00068 void _Locale_init(void); 00069 00070 /* Function called during STLport library unload. Might contain any 00071 * code necessary to the platform localization layer. 00072 */ 00073 void _Locale_final(void); 00074 00075 /* Create a category of the locale with the given name. 00076 * 00077 * The char* argument is a simple (not a composite) locale name, which may 00078 * neither be an empty string nor a null pointer. 00079 * 00080 * These functions return NULL to indicate failure. Failure reason should be reported 00081 * using the __err_code pointer. 00082 */ 00083 struct _Locale_ctype* _Locale_ctype_create(const char *, struct _Locale_name_hint*, int * /* __err_code */); 00084 struct _Locale_codecvt* _Locale_codecvt_create(const char *, struct _Locale_name_hint*, int * /* __err_code */); 00085 struct _Locale_numeric* _Locale_numeric_create(const char *, struct _Locale_name_hint*, int * /* __err_code */); 00086 struct _Locale_time* _Locale_time_create(const char *, struct _Locale_name_hint*, int * /* __err_code */); 00087 struct _Locale_collate* _Locale_collate_create(const char *, struct _Locale_name_hint*, int * /* __err_code */); 00088 struct _Locale_monetary* _Locale_monetary_create(const char *, struct _Locale_name_hint*, int * /* __err_code */); 00089 struct _Locale_messages* _Locale_messages_create(const char *, struct _Locale_name_hint*, int * /* __err_code */); 00090 00091 /* Give error reason on failure of one of the _Locale_*_create functions. Available 00092 * reasons are: 00093 * 0: No specific error reason has been reported. 00094 * 1: No platform support for the given facet. 00095 * 2: Unknown locale name 00096 * 3: No platform API for localization support. 00097 * 4: No more memory 00098 */ 00099 #define _STLP_LOC_UNDEFINED 0 00100 #define _STLP_LOC_UNSUPPORTED_FACET_CATEGORY 1 00101 #define _STLP_LOC_UNKNOWN_NAME 2 00102 #define _STLP_LOC_NO_PLATFORM_SUPPORT 3 00103 #define _STLP_LOC_NO_MEMORY 4 00104 00105 /* Release a category of a locale 00106 * 00107 * These functions are used to release a category acquired with the 00108 * according _Locale_*_create() functions. 00109 */ 00110 void _Locale_ctype_destroy(struct _Locale_ctype *); 00111 void _Locale_codecvt_destroy(struct _Locale_codecvt *); 00112 void _Locale_numeric_destroy(struct _Locale_numeric *); 00113 void _Locale_time_destroy(struct _Locale_time *); 00114 void _Locale_collate_destroy(struct _Locale_collate *); 00115 void _Locale_monetary_destroy(struct _Locale_monetary *); 00116 void _Locale_messages_destroy(struct _Locale_messages *); 00117 00118 /* 00119 * Returns the name of the user's default locale in each 00120 * category, as a null-terminated string. A NULL value 00121 * means the default "C" locale. 00122 */ 00123 const char * _Locale_ctype_default(char * __buf); 00124 const char * _Locale_numeric_default(char * __buf); 00125 const char * _Locale_time_default(char * __buf); 00126 const char * _Locale_collate_default(char * __buf); 00127 const char * _Locale_monetary_default(char * __buf); 00128 const char * _Locale_messages_default(char * __buf); 00129 00130 /* Retrieve the name of the given category 00131 * 00132 * __buf points to a buffer that can hold at least _Locale_MAX_SIMPLE_NAME 00133 * characters. These functions store the name, as a null-terminated 00134 * string, in __buf. This function can't fail, at worst name is truncated. 00135 */ 00136 char const* _Locale_ctype_name(const struct _Locale_ctype *, char* __buf); 00137 char const* _Locale_codecvt_name(const struct _Locale_codecvt *, char* __buf); 00138 char const* _Locale_numeric_name(const struct _Locale_numeric *, char* __buf); 00139 char const* _Locale_time_name(const struct _Locale_time *, char* __buf); 00140 char const* _Locale_collate_name(const struct _Locale_collate *, char* __buf); 00141 char const* _Locale_monetary_name(const struct _Locale_monetary *, char* __buf); 00142 char const* _Locale_messages_name(const struct _Locale_messages *, char* __buf); 00143 00144 /* 00145 * cname is a (possibly composite) locale name---i.e. a name that can 00146 * be passed to setlocale. __buf points to an array large enough to 00147 * store at least _Locale_MAX_SIMPLE_NAME characters, and each of these 00148 * functions extracts the name of a single category, stores it in buf 00149 * as a null-terminated string, and returns buf. 00150 */ 00151 char const* _Locale_extract_ctype_name(const char *cname, char *__buf, 00152 struct _Locale_name_hint* __hint, int *__err_code); 00153 char const* _Locale_extract_numeric_name(const char *cname, char *__buf, 00154 struct _Locale_name_hint* __hint, int *__err_code); 00155 char const* _Locale_extract_time_name(const char *cname, char *__buf, 00156 struct _Locale_name_hint* __hint, int *__err_code); 00157 char const* _Locale_extract_collate_name(const char *cname, char *__buf, 00158 struct _Locale_name_hint* __hint, int *__err_code); 00159 char const* _Locale_extract_monetary_name(const char *cname, char *__buf, 00160 struct _Locale_name_hint* __hint, int *__err_code); 00161 char const* _Locale_extract_messages_name(const char *cname, char *__buf, 00162 struct _Locale_name_hint* __hint, int *__err_code); 00163 00164 /* Functions to improve locale creation process. For some locale API (Win32) 00165 * you need to find a locale identification from the name which can be a 00166 * rather expensive operation especially if you do so for all facets of a 00167 * locale. Those functions can be used to extract from a API dependent facet 00168 * struct the information necessary to skip this lookup process for other 00169 * facets creation. If not supported those function should return NULL. 00170 */ 00171 struct _Locale_name_hint* _Locale_get_ctype_hint(struct _Locale_ctype*); 00172 struct _Locale_name_hint* _Locale_get_numeric_hint(struct _Locale_numeric*); 00173 struct _Locale_name_hint* _Locale_get_time_hint(struct _Locale_time*); 00174 struct _Locale_name_hint* _Locale_get_collate_hint(struct _Locale_collate*); 00175 struct _Locale_name_hint* _Locale_get_monetary_hint(struct _Locale_monetary*); 00176 struct _Locale_name_hint* _Locale_get_messages_hint(struct _Locale_messages*); 00177 00178 /* 00179 * FUNCTIONS THAT USE CTYPE 00180 */ 00181 00182 /* 00183 * Narrow character functions: 00184 */ 00185 00186 /* 00187 * Returns a pointer to the beginning of the ctype table. The table is 00188 * at least 257 bytes long; if p is the pointer returned by this 00189 * function, then p[c] is valid if c is EOF or if p is any value of 00190 * type unsigned char. 00191 */ 00192 const _Locale_mask_t * _Locale_ctype_table(struct _Locale_ctype *); 00193 00194 /* 00195 * c is either EOF, or an unsigned char value. 00196 */ 00197 int _Locale_toupper(struct _Locale_ctype *, int /* c */); 00198 int _Locale_tolower(struct _Locale_ctype *, int /* c */); 00199 00200 00201 #ifndef _STLP_NO_WCHAR_T 00202 /* 00203 * Wide character functions: 00204 */ 00205 _Locale_mask_t _WLocale_ctype(struct _Locale_ctype *, wint_t, _Locale_mask_t); 00206 wint_t _WLocale_tolower(struct _Locale_ctype *, wint_t); 00207 wint_t _WLocale_toupper(struct _Locale_ctype *, wint_t); 00208 00209 /* 00210 * Multibyte functions: 00211 */ 00212 00213 /* 00214 * Returns the number of bytes of the longest allowed multibyte 00215 * character in the current encoding. 00216 */ 00217 int _WLocale_mb_cur_max(struct _Locale_codecvt *); 00218 00219 /* 00220 * Returns the number of bytes of the shortest allowed multibyte 00221 * character in the current encoding. 00222 */ 00223 int _WLocale_mb_cur_min(struct _Locale_codecvt *); 00224 00225 /* 00226 * Returns 1 if the current multibyte encoding is stateless 00227 * and does not require the use of an mbstate_t value. 00228 */ 00229 int _WLocale_is_stateless(struct _Locale_codecvt *); 00230 00231 /* 00232 * Almost identical to mbrtowc, from 4.6.5.3.2 of NA1. The only 00233 * important difference is that mbrtowc treats null wide characters 00234 * as special, and we don't. Specifically: examines the characters 00235 * in [from, from + n), extracts a single wide character, and stores 00236 * it in *to. Modifies shift_state if appropriate. The return value, 00237 * which is always positive, is the number of characters extracted from 00238 * the input sequence. Return value is (size_t) -1 if there was an 00239 * encoding error in the input sequence, and (size_t) -2 if 00240 * [from, from + n) is correct but not complete. None of the pointer 00241 * arguments may be null pointers. 00242 */ 00243 size_t _WLocale_mbtowc(struct _Locale_codecvt *, 00244 wchar_t * /* to */, 00245 const char * /* from */, size_t /* n */, 00246 mbstate_t *); 00247 00248 /* 00249 * Again, very similar to wcrtomb. The differences are that (1) it 00250 * doesn't treat null characters as special; and (2) it stores at most 00251 * n characters. Converts c to a multibyte sequence, stores that 00252 * sequence in the array 'to', and returns the length of the sequence. 00253 * Modifies shift_state if appropriate. The return value is (size_t) -1 00254 * if c is not a valid wide character, and (size_t) -2 if the length of 00255 * the multibyte character sequence is greater than n. 00256 */ 00257 size_t _WLocale_wctomb(struct _Locale_codecvt *, 00258 char *, size_t, 00259 const wchar_t, 00260 mbstate_t *); 00261 00262 /* 00263 * Inserts whatever characters are necessary to restore st to an 00264 * initial shift state. Sets *next to buf + m, where m is the number 00265 * of characters inserted. (0 <= m <= n.) Returns m to indicate 00266 * success, (size_t) -1 to indicate error, (size_t) -2 to indicate 00267 * partial success (more than n characters needed). For success or partial 00268 * success, sets *next to buf + m. 00269 */ 00270 size_t _WLocale_unshift(struct _Locale_codecvt *, 00271 mbstate_t *, 00272 char *, size_t, char **); 00273 #endif 00274 00275 /* 00276 * FUNCTIONS THAT USE COLLATE 00277 */ 00278 00279 /* 00280 * Compares the two sequences [s1, s1 + n1) and [s2, s2 + n2). Neither 00281 * sequence is assumed to be null-terminated, and null characters 00282 * aren't special. If the two sequences are the same up through 00283 * min(n1, n2), then the sequence that compares less is whichever one 00284 * is shorter. 00285 */ 00286 int _Locale_strcmp(struct _Locale_collate *, 00287 const char * /* s1 */, size_t /* n1 */, 00288 const char * /* s2 */, size_t /* n2 */); 00289 #ifndef _STLP_NO_WCHAR_T 00290 int _WLocale_strcmp(struct _Locale_collate *, 00291 const wchar_t * /* s1 */, size_t /* n1 */, 00292 const wchar_t * /* s2 */, size_t /* n2 */); 00293 #endif 00294 00295 /* 00296 * Creates a transformed version of the string [s2, s2 + n2). The 00297 * string may contain embedded null characters; nulls aren't special. 00298 * The transformed string begins at s1, and contains at most n1 00299 * characters. The return value is the length of the transformed 00300 * string. If the return value is greater than n1 then this is an 00301 * error condition: it indicates that there wasn't enough space. In 00302 * that case, the contents of [s1, s1 + n1) is unspecified. 00303 */ 00304 size_t _Locale_strxfrm(struct _Locale_collate *, 00305 char * /* s1 */, size_t /* n1 */, 00306 const char * /* s2 */, size_t /* n2 */); 00307 00308 #ifndef _STLP_NO_WCHAR_T 00309 size_t _WLocale_strxfrm(struct _Locale_collate *, 00310 wchar_t * /* s1 */, size_t /* n1 */, 00311 const wchar_t * /* s2 */, size_t /* n2 */); 00312 #endif 00313 00314 00315 /* 00316 * FUNCTIONS THAT USE NUMERIC 00317 */ 00318 00319 /* 00320 * Equivalent to the first three fields in struct lconv. (C standard, 00321 * section 7.4.) 00322 */ 00323 char _Locale_decimal_point(struct _Locale_numeric *); 00324 char _Locale_thousands_sep(struct _Locale_numeric *); 00325 const char * _Locale_grouping(struct _Locale_numeric *); 00326 00327 #ifndef _STLP_NO_WCHAR_T 00328 wchar_t _WLocale_decimal_point(struct _Locale_numeric *); 00329 wchar_t _WLocale_thousands_sep(struct _Locale_numeric *); 00330 #endif 00331 00332 /* 00333 * Return "true" and "false" in English locales, and something 00334 * appropriate in non-English locales. 00335 */ 00336 const char * _Locale_true(struct _Locale_numeric *); 00337 const char * _Locale_false(struct _Locale_numeric *); 00338 00339 #ifndef _STLP_NO_WCHAR_T 00340 const wchar_t * _WLocale_true(struct _Locale_numeric *, wchar_t* /* buf */, size_t /* bufSize */); 00341 const wchar_t * _WLocale_false(struct _Locale_numeric *, wchar_t* /* buf */, size_t /* bufSize */); 00342 #endif 00343 00344 /* 00345 * FUNCTIONS THAT USE MONETARY 00346 */ 00347 00348 /* 00349 * Return the obvious fields of struct lconv. 00350 */ 00351 const char * _Locale_int_curr_symbol(struct _Locale_monetary *); 00352 const char * _Locale_currency_symbol(struct _Locale_monetary *); 00353 char _Locale_mon_decimal_point(struct _Locale_monetary *); 00354 char _Locale_mon_thousands_sep(struct _Locale_monetary *); 00355 const char * _Locale_mon_grouping(struct _Locale_monetary *); 00356 const char * _Locale_positive_sign(struct _Locale_monetary *); 00357 const char * _Locale_negative_sign(struct _Locale_monetary *); 00358 char _Locale_int_frac_digits(struct _Locale_monetary *); 00359 char _Locale_frac_digits(struct _Locale_monetary *); 00360 int _Locale_p_cs_precedes(struct _Locale_monetary *); 00361 int _Locale_p_sep_by_space(struct _Locale_monetary *); 00362 int _Locale_p_sign_posn(struct _Locale_monetary *); 00363 int _Locale_n_cs_precedes(struct _Locale_monetary *); 00364 int _Locale_n_sep_by_space(struct _Locale_monetary *); 00365 int _Locale_n_sign_posn(struct _Locale_monetary *); 00366 00367 #ifndef _STLP_NO_WCHAR_T 00368 const wchar_t * _WLocale_int_curr_symbol(struct _Locale_monetary *, wchar_t* /* buf */, size_t /* bufSize */); 00369 const wchar_t * _WLocale_currency_symbol(struct _Locale_monetary *, wchar_t* /* buf */, size_t /* bufSize */); 00370 wchar_t _WLocale_mon_decimal_point(struct _Locale_monetary *); 00371 wchar_t _WLocale_mon_thousands_sep(struct _Locale_monetary *); 00372 const wchar_t * _WLocale_positive_sign(struct _Locale_monetary *, wchar_t* /* buf */, size_t /* bufSize */); 00373 const wchar_t * _WLocale_negative_sign(struct _Locale_monetary *, wchar_t* /* buf */, size_t /* bufSize */); 00374 #endif 00375 00376 /* 00377 * FUNCTIONS THAT USE TIME 00378 */ 00379 00380 /* 00381 * month is in the range [0, 12). 00382 */ 00383 const char * _Locale_full_monthname(struct _Locale_time *, int /* month */); 00384 const char * _Locale_abbrev_monthname(struct _Locale_time *, int /* month */); 00385 00386 #ifndef _STLP_NO_WCHAR_T 00387 const wchar_t * _WLocale_full_monthname(struct _Locale_time *, int /* month */, 00388 wchar_t* /* buf */, size_t /* bufSize */); 00389 const wchar_t * _WLocale_abbrev_monthname(struct _Locale_time *, int /* month */, 00390 wchar_t* /* buf */, size_t /* bufSize */); 00391 #endif 00392 00393 /* 00394 * day is in the range [0, 7). Sunday is 0. 00395 */ 00396 const char * _Locale_full_dayofweek(struct _Locale_time *, int /* day */); 00397 const char * _Locale_abbrev_dayofweek(struct _Locale_time *, int /* day */); 00398 00399 #ifndef _STLP_NO_WCHAR_T 00400 const wchar_t * _WLocale_full_dayofweek(struct _Locale_time *, int /* day */, 00401 wchar_t* /* buf */, size_t /* bufSize */); 00402 const wchar_t * _WLocale_abbrev_dayofweek(struct _Locale_time *, int /* day */, 00403 wchar_t* /* buf */, size_t /* bufSize */); 00404 #endif 00405 00406 const char * _Locale_d_t_fmt(struct _Locale_time *); 00407 const char * _Locale_d_fmt(struct _Locale_time *); 00408 const char * _Locale_t_fmt(struct _Locale_time *); 00409 const char * _Locale_long_d_t_fmt(struct _Locale_time*); 00410 const char * _Locale_long_d_fmt(struct _Locale_time*); 00411 00412 const char * _Locale_am_str(struct _Locale_time *); 00413 const char * _Locale_pm_str(struct _Locale_time *); 00414 00415 #ifndef _STLP_NO_WCHAR_T 00416 const wchar_t * _WLocale_am_str(struct _Locale_time *, 00417 wchar_t* /* buf */, size_t /* bufSize */); 00418 const wchar_t * _WLocale_pm_str(struct _Locale_time *, 00419 wchar_t* /* buf */, size_t /* bufSize */); 00420 #endif 00421 00422 /* 00423 * FUNCTIONS THAT USE MESSAGES 00424 */ 00425 00426 /* 00427 * Very similar to catopen, except that it uses the given message 00428 * category to determine which catalog to open. 00429 */ 00430 nl_catd_type _Locale_catopen(struct _Locale_messages*, const char*); 00431 00432 /* Complementary to _Locale_catopen. 00433 * The catalog must be a value that was returned by a previous call 00434 * to _Locale_catopen. 00435 */ 00436 void _Locale_catclose(struct _Locale_messages*, nl_catd_type); 00437 00438 /* 00439 * Returns a string, identified by a set index and a message index, 00440 * from an opened message catalog. Returns the supplied default if 00441 * no such string exists. 00442 */ 00443 const char * _Locale_catgets(struct _Locale_messages *, nl_catd_type, 00444 int, int,const char *); 00445 00446 #ifdef __cplusplus 00447 } 00448 #endif 00449 00450 #endif /* _STLP_C_LOCALE_IMPL_H */ Generated on Sat May 26 2012 04:28:23 for ReactOS by
1.7.6.1
|