1 locale |
1 /* |
|
2 * © Portions copyright (c) 2006-2007 Nokia Corporation. All rights reserved. |
|
3 * |
|
4 * Copyright (c) 1999 |
|
5 * Silicon Graphics Computer Systems, Inc. |
|
6 * |
|
7 * Copyright (c) 1999 |
|
8 * Boris Fomitchev |
|
9 * |
|
10 * This material is provided "as is", with absolutely no warranty expressed |
|
11 * or implied. Any use is at your own risk. |
|
12 * |
|
13 * Permission to use or copy this software for any purpose is hereby granted |
|
14 * without fee, provided the above notices are retained on all copies. |
|
15 * Permission to modify the code and to distribute modified code is granted, |
|
16 * provided the above notices are retained, and a notice that the code was |
|
17 * modified is included with the above copyright notice. |
|
18 * |
|
19 */ |
|
20 #ifndef _STLP_LOCALE |
|
21 #define _STLP_LOCALE |
|
22 |
|
23 // Basic framework: class locale and class locale::facet |
|
24 |
|
25 # ifndef _STLP_OUTERMOST_HEADER_ID |
|
26 # define _STLP_OUTERMOST_HEADER_ID 0x1041 |
|
27 # include <stl/_prolog.h> |
|
28 # endif |
|
29 |
|
30 # ifdef _STLP_PRAGMA_ONCE |
|
31 # pragma once |
|
32 # endif |
|
33 # if defined (__SYMBIAN32__) |
|
34 # include <clocale> |
|
35 # endif |
|
36 |
|
37 # if defined (_STLP_OWN_IOSTREAMS) |
|
38 |
|
39 // Individual facets |
|
40 #ifndef _STLP_INTERNAL_CTYPE_H |
|
41 #include <stl/_ctype.h> |
|
42 #endif |
|
43 #ifndef _STLP_INTERNAL_CODECVT_H |
|
44 #include <stl/_codecvt.h> |
|
45 #endif |
|
46 #ifndef _STLP_INTERNAL_COLLATE_H |
|
47 #include <stl/_collate.h> |
|
48 #endif |
|
49 #ifndef _STLP_INTERNAL_NUM_PUT_H |
|
50 # include <stl/_num_put.h> |
|
51 #endif |
|
52 |
|
53 #ifndef _STLP_INTERNAL_NUM_GET_H |
|
54 # include <stl/_num_get.h> |
|
55 #endif |
|
56 |
|
57 // those never included separately anyway |
|
58 #include <stl/_monetary.h> |
|
59 #include <stl/_time_facets.h> |
|
60 #include <stl/_messages_facets.h> |
|
61 |
|
62 // some stuff for streambuf iterators ended up defined there |
|
63 // Strictly speaking, _istream.h portion is only required for <iterator>, but it may break too many |
|
64 // programs if we omit it |
|
65 #ifndef _STLP_ISTREAM_H |
|
66 # include <stl/_istream.h> |
|
67 #endif |
|
68 |
|
69 // Convenience interfaces |
|
70 #undef isspace |
|
71 #undef isprint |
|
72 #undef iscntrl |
|
73 #undef isupper |
|
74 #undef islower |
|
75 #undef isalpha |
|
76 #undef isdigit |
|
77 #undef ispunct |
|
78 #undef isxdigit |
|
79 #undef isalnum |
|
80 #undef isgraph |
|
81 #undef toupper |
|
82 #undef tolower |
|
83 |
|
84 _STLP_BEGIN_NAMESPACE |
|
85 |
|
86 template <class _CharT> |
|
87 inline bool isspace (_CharT c, const locale& loc) { |
|
88 return (use_facet<ctype<_CharT> >(loc)).is(ctype_base::space, c); |
|
89 } |
|
90 |
|
91 template <class _CharT> |
|
92 inline bool isprint (_CharT c, const locale& loc) { |
|
93 return (use_facet<ctype<_CharT> >(loc)).is(ctype_base::print, c); |
|
94 } |
|
95 |
|
96 template <class _CharT> |
|
97 inline bool iscntrl (_CharT c, const locale& loc) { |
|
98 return (use_facet<ctype<_CharT> >(loc)).is(ctype_base::cntrl, c); |
|
99 } |
|
100 |
|
101 template <class _CharT> |
|
102 inline bool isupper (_CharT c, const locale& loc) { |
|
103 return (use_facet<ctype<_CharT> >(loc)).is(ctype_base::upper, c); |
|
104 } |
|
105 |
|
106 template <class _CharT> |
|
107 inline bool islower (_CharT c, const locale& loc) { |
|
108 return (use_facet<ctype<_CharT> >(loc)).is(ctype_base::lower, c); |
|
109 } |
|
110 |
|
111 template <class _CharT> |
|
112 inline bool isalpha (_CharT c, const locale& loc) { |
|
113 return (use_facet<ctype<_CharT> >(loc)).is(ctype_base::alpha, c); |
|
114 } |
|
115 |
|
116 template <class _CharT> |
|
117 inline bool isdigit (_CharT c, const locale& loc) { |
|
118 return (use_facet<ctype<_CharT> >(loc)).is(ctype_base::digit, c); |
|
119 } |
|
120 |
|
121 template <class _CharT> |
|
122 inline bool ispunct (_CharT c, const locale& loc) { |
|
123 return (use_facet<ctype<_CharT> >(loc)).is(ctype_base::punct, c); |
|
124 } |
|
125 |
|
126 template <class _CharT> |
|
127 inline bool isxdigit (_CharT c, const locale& loc) { |
|
128 return (use_facet<ctype<_CharT> >(loc)).is(ctype_base::xdigit, c); |
|
129 } |
|
130 |
|
131 template <class _CharT> |
|
132 inline bool isalnum (_CharT c, const locale& loc) { |
|
133 return (use_facet<ctype<_CharT> >(loc)).is(ctype_base::alnum, c); |
|
134 } |
|
135 |
|
136 template <class _CharT> |
|
137 inline bool isgraph (_CharT c, const locale& loc) { |
|
138 return (use_facet<ctype<_CharT> >(loc)).is(ctype_base::graph, c); |
|
139 } |
|
140 |
|
141 template <class _CharT> |
|
142 inline _CharT toupper(_CharT c, const locale& loc) { |
|
143 return (use_facet<ctype<_CharT> >(loc)).toupper(c); |
|
144 } |
|
145 |
|
146 template <class _CharT> |
|
147 inline _CharT tolower(_CharT c, const locale& loc) { |
|
148 return (use_facet<ctype<_CharT> >(loc)).tolower(c); |
|
149 } |
|
150 |
|
151 # ifndef __LOCALE_INITIALIZED |
|
152 # define __LOCALE_INITIALIZED |
|
153 # if !defined(__LIBSTD_CPP_SYMBIAN32_WSD__) && !defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_) |
|
154 // Global initializer object, to ensure initialization of locale subsystem. |
|
155 static ios_base::_Loc_init _LocInit; |
|
156 # endif |
|
157 # endif |
|
158 |
|
159 _STLP_END_NAMESPACE |
|
160 |
|
161 # elif !defined (_STLP_USE_NO_IOSTREAMS) |
|
162 # include <wrap_std/locale> |
|
163 # endif |
|
164 |
|
165 # if (_STLP_OUTERMOST_HEADER_ID == 0x1041) |
|
166 # include <stl/_epilog.h> |
|
167 # undef _STLP_OUTERMOST_HEADER_ID |
|
168 # endif |
|
169 |
|
170 #endif /* _STLP_LOCALE */ |
|
171 |
|
172 |
|
173 // Local Variables: |
|
174 // mode:C++ |
|
175 // End: |