Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
_moneypunct.h
Go to the documentation of this file.
1
32#ifndef _RWSTD_LOC_MONEYPUNCT_H_INCLUDED
33#define _RWSTD_LOC_MONEYPUNCT_H_INCLUDED
34
35
36#if __GNUG__ >= 3
37# pragma GCC system_header
38#endif // gcc >= 3
39
40
41#include <string>
42#include <loc/_facet.h>
43#include <loc/_punct.h>
44#include <rw/_defs.h>
45
46
48
49
50// 22.2.6.3
51struct money_base
52{
53 enum part { none, space, symbol, sign, value };
54 struct pattern { char field [4]; };
55};
56
57
58// 22.2.6.3
60template <class _CharT, bool _Intl = false>
61struct moneypunct: _RW::__rw_facet, public money_base
62{
63 typedef _CharT char_type;
64 typedef
65 basic_string<char_type, char_traits<char_type>, allocator<char_type> >
66 string_type;
67
68 explicit moneypunct (_RWSTD_SIZE_T __refs = 0)
69 : _RW::__rw_facet (__refs) { }
70
71 virtual ~moneypunct () _RWSTD_ATTRIBUTE_NOTHROW;
72
73 char_type decimal_point () const {
74 return do_decimal_point ();
75 }
76
77 char_type thousands_sep () const {
78 return do_thousands_sep ();
79 }
80
81 string grouping () const {
82 return do_grouping ();
83 }
84
85 string_type curr_symbol () const {
86 return do_curr_symbol ();
87 }
88
89 string_type positive_sign () const {
90 return do_positive_sign ();
91 }
92
93 string_type negative_sign () const {
94 return do_negative_sign ();
95 }
96
97 int frac_digits () const {
98 return do_frac_digits ();
99 }
100
101 pattern pos_format () const {
102 return do_pos_format ();
103 }
104
105 pattern neg_format () const {
106 return do_neg_format ();
107 }
108
109 static _RW::__rw_facet_id id;
110
111 _RWSTD_STATIC_CONST (bool, intl = _Intl);
112
113protected:
114
115 // 22.2.6.3.1, p1
116 virtual char_type do_decimal_point () const {
117 return *_C_get (this, _RW::__rw_dp);
118 }
119
120 // 22.2.6.3.1, p2
121 virtual char_type do_thousands_sep () const {
122 return *_C_get (this, _RW::__rw_ts);
123 }
124
125 // 22.2.6.3.1, p3
126 virtual string do_grouping () const {
127 return
128 _RWSTD_REINTERPRET_CAST (const char*, _C_get (this, _RW::__rw_gr));
129 }
130
131 // 22.2.6.3.1, p4
132 virtual string_type do_curr_symbol () const {
133 return _C_get (this, _RW::__rw_cs);
134 }
135
136 // 22.2.6.3.1, p5
137 virtual string_type do_positive_sign () const {
138 return _C_get (this, _RW::__rw_ps);
139 }
140
141 // 22.2.6.3.1, p5
142 virtual string_type do_negative_sign () const {
143 return _C_get (this, _RW::__rw_ns);
144 }
145
146 // 22.2.6.3.1, p6
147 virtual int do_frac_digits () const {
148 return _RWSTD_STATIC_CAST(int, _RWSTD_REINTERPRET_CAST (_RWSTD_SIZE_T,
149 _C_get (this, _RW::__rw_fd)));
150 }
151
152 // 22.2.6.3.1, p7
153 virtual pattern do_pos_format () const {
154 return *_RWSTD_REINTERPRET_CAST (const pattern*,
155 _C_get (this, _RW::__rw_pf));
156 }
157
158 // 22.2.6.3.1, p5
159 virtual pattern do_neg_format () const {
160 return *_RWSTD_REINTERPRET_CAST (const pattern*,
161 _C_get (this, _RW::__rw_nf));
162 }
163
164private:
165
166 static const char_type* _C_get (const _RW::__rw_facet*, int);
167};
168
169
170#ifndef _RWSTD_NO_SPECIALIZED_FACET_ID
171
173_RW::__rw_facet_id moneypunct<char, false>::id;
174
176_RW::__rw_facet_id moneypunct<char, true>::id;
177
178# ifndef _RWSTD_NO_WCHAR_T
179
181_RW::__rw_facet_id moneypunct<wchar_t, false>::id;
182
184_RW::__rw_facet_id moneypunct<wchar_t, true>::id;
185
186# endif // _RWSTD_NO_WCHAR_T
187#endif // _RWSTD_NO_SPECIALIZED_FACET_ID
188
189
190template <class _CharT, bool _Intl /* = false */>
191inline const _CharT*
192moneypunct<_CharT, _Intl>::_C_get (const _RW::__rw_facet *__pf, int __fl)
193{
194 if (intl)
195 __fl |= _RW::__rw_intl;
196
197 __fl |= _RW::__rw_mon;
198
199 return _RWSTD_STATIC_CAST (const char_type*,
200 _RW::__rw_get_punct(__pf, __fl, char_type()));
201}
202
203
204// 22.2.6.4
205template <class _CharT, bool _Intl = false>
206class moneypunct_byname: public moneypunct<_CharT, _Intl>
207{
208 char _C_namebuf [32];
209
210public:
211
212 explicit moneypunct_byname (const char *__name, _RWSTD_SIZE_T __ref = 0)
213 : moneypunct<_CharT, _Intl>(__ref) {
214 this->_C_set_name (__name, _C_namebuf, sizeof _C_namebuf);
215 }
216
217 virtual ~moneypunct_byname () _RWSTD_ATTRIBUTE_NOTHROW;
218};
219
220
221} // namespace std
222
223
224#if _RWSTD_DEFINE_TEMPLATE_FIRST (_MONEYPUNCT)
225# include <loc/_moneypunct.cc>
226#endif // _RWSTD_DEFINE_TEMPLATE_FIRST (_MONEYPUNCT)
227
228
229#ifdef _RWSTD_MSVC
230# pragma warning (push)
231# pragma warning (disable: 4231)
232#endif // _RWSTD_MSVC
233
234
236
237#if _RWSTD_INSTANTIATE (_MONEYPUNCT, _CHAR)
238
239_RWSTD_INSTANTIATE_2 (struct _RWSTD_TI_EXPORT moneypunct<char, true>);
240_RWSTD_INSTANTIATE_2 (struct _RWSTD_TI_EXPORT moneypunct<char, false>);
241
242#endif // _RWSTD_INSTANTIATE (_MONEYPUNCT, _CHAR)
243
244#if _RWSTD_INSTANTIATE (_MONEYPUNCT, _WCHAR_T)
245
246_RWSTD_INSTANTIATE_2 (struct _RWSTD_TI_EXPORT moneypunct<wchar_t, true>);
247_RWSTD_INSTANTIATE_2 (struct _RWSTD_TI_EXPORT moneypunct<wchar_t, false>);
248
249#endif // _RWSTD_INSTANTIATE (_MONEYPUNCT, _WCHAR_T)
250
251} // namespace std
252
253
254#ifdef _RWSTD_MSVC
255# pragma warning (pop)
256#endif // _RWSTD_MSVC
257
258
259#if _RWSTD_DEFINE_TEMPLATE_LAST (_MONEYPUNCT)
260# include <loc/_moneypunct.cc>
261#endif // _RWSTD_DEFINE_TEMPLATE_LAST (_MONEYPUNCT)
262
263
264#endif // _RWSTD_LOC_MONEYPUNCT_H_INCLUDED
T value(const T &val)
#define _RWSTD_SPECIALIZED_CLASS
#define _RWSTD_INSTANTIATE_2(a1, a2)
Definition _defs.h:1375
#define _RWSTD_REINTERPRET_CAST(T, x)
Definition _defs.h:535
#define _RWSTD_STATIC_CAST(T, x)
Definition _defs.h:534
#define _RWSTD_NAMESPACE(name)
Definition _defs.h:567
#define _RWSTD_ATTRIBUTE_NOTHROW
Definition _defs.h:1179
#define _EXPORT
Definition _defs.h:498
#define _RWSTD_STATIC_CONST(type, init)
Definition _defs.h:989
#define _RWSTD_TI_EXPORT
Definition _defs.h:1331
Definition json.h:5363