source: mainline/uspace/lib/cpp/include/__bits/locale/numpunct.hpp@ 4f461384

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 4f461384 was 7bbf91e, checked in by Dzejrou <dzejrou@…>, 7 years ago

cpp: changed internal to bits to avoid include space pollusion, fixed old std::hel:: bugs in files that weren't touched since

  • Property mode set to 100644
File size: 5.4 KB
Line 
1/*
2 * Copyright (c) 2017 Jaroslav Jindrak
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#ifndef LIBCPP_BITS_LOCALE_NUMPUNCT
30#define LIBCPP_BITS_LOCALE_NUMPUNCT
31
32#include <__bits/locale.hpp>
33#include <string>
34
35namespace std
36{
37 /**
38 * 22.4.3.1, class template numpunct:
39 */
40
41 template<class Char>
42 class numpunct: public locale::facet
43 {
44 public:
45 using char_type = Char;
46 using string_type = basic_string<Char>;
47
48 explicit numpunct(size_t refs = 0);
49
50 char_type decimal_point() const
51 {
52 return do_decimal_point();
53 }
54
55 char_type thousands_sep() const
56 {
57 return do_thousands_sep();
58 }
59
60 string_type grouping() const
61 {
62 return do_grouping();
63 }
64
65 string_type truename() const
66 {
67 return do_truename();
68 }
69
70 string_type falsename() const
71 {
72 return do_falsename();
73 }
74
75 ~numpunct();
76
77 protected:
78 char_type do_decimal_point() const;
79 char_type do_thousands_sep() const;
80 string_type do_grouping() const;
81 string_type do_truename() const;
82 string_type do_falsename() const;
83 };
84
85 template<>
86 class numpunct<char>: public locale::facet
87 {
88 public:
89 using char_type = char;
90 using string_type = basic_string<char>;
91
92 explicit numpunct(size_t refs = 0)
93 { /* DUMMY BODY */ }
94
95 char_type decimal_point() const
96 {
97 return do_decimal_point();
98 }
99
100 char_type thousands_sep() const
101 {
102 return do_thousands_sep();
103 }
104
105 string_type grouping() const
106 {
107 return do_grouping();
108 }
109
110 string_type truename() const
111 {
112 return do_truename();
113 }
114
115 string_type falsename() const
116 {
117 return do_falsename();
118 }
119
120 ~numpunct()
121 { /* DUMMY BODY */ }
122
123 protected:
124 char_type do_decimal_point() const
125 {
126 return '.';
127 }
128
129 char_type do_thousands_sep() const
130 {
131 return ',';
132 }
133
134 string_type do_grouping() const
135 {
136 return "";
137 }
138
139 string_type do_truename() const
140 {
141 return "true";
142 }
143
144 string_type do_falsename() const
145 {
146 return "false";
147 }
148 };
149
150 template<>
151 class numpunct<wchar_t>: public locale::facet
152 {
153 public:
154 using char_type = wchar_t;
155 using string_type = basic_string<wchar_t>;
156
157 explicit numpunct(size_t refs = 0);
158
159 char_type decimal_point() const
160 {
161 return do_decimal_point();
162 }
163
164 char_type thousands_sep() const
165 {
166 return do_thousands_sep();
167 }
168
169 string_type grouping() const
170 {
171 return do_grouping();
172 }
173
174 string_type truename() const
175 {
176 return do_truename();
177 }
178
179 string_type falsename() const
180 {
181 return do_falsename();
182 }
183
184 ~numpunct();
185
186 protected:
187 char_type do_decimal_point() const
188 {
189 return L'.';
190 }
191
192 char_type do_thousands_sep() const
193 {
194 return L',';
195 }
196
197 string_type do_grouping() const
198 {
199 return L"";
200 }
201
202 string_type do_truename() const
203 {
204 return L"true";
205 }
206
207 string_type do_falsename() const
208 {
209 return L"false";
210 }
211 };
212}
213
214#endif
Note: See TracBrowser for help on using the repository browser.