source: mainline/uspace/lib/cpp/include/internal/locale/numpunct.hpp@ 9cb221b

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

cpp: reorganized <locale> to avoid circular dependencies with ios_base

  • Property mode set to 100644
File size: 5.3 KB
RevLine 
[8cce80b4]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_INTERNAL_LOCALE_NUMPUNCT
30#define LIBCPP_INTERNAL_LOCALE_NUMPUNCT
31
32#include <internal/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
94 char_type decimal_point() const
95 {
96 return do_decimal_point();
97 }
98
99 char_type thousands_sep() const
100 {
101 return do_thousands_sep();
102 }
103
104 string_type grouping() const
105 {
106 return do_grouping();
107 }
108
109 string_type truename() const
110 {
111 return do_truename();
112 }
113
114 string_type falsename() const
115 {
116 return do_falsename();
117 }
118
119 ~numpunct();
120
121 protected:
122 char_type do_decimal_point() const
123 {
124 return '.';
125 }
126
127 char_type do_thousands_sep() const
128 {
129 return ',';
130 }
131
132 string_type do_grouping() const
133 {
134 return "";
135 }
136
137 string_type do_truename() const
138 {
139 return "true";
140 }
141
142 string_type do_falsename() const
143 {
144 return "false";
145 }
146 };
147
148 template<>
149 class numpunct<wchar_t>: public locale::facet
150 {
151 public:
152 using char_type = wchar_t;
153 using string_type = basic_string<wchar_t>;
154
155 explicit numpunct(size_t refs = 0);
156
157 char_type decimal_point() const
158 {
159 return do_decimal_point();
160 }
161
162 char_type thousands_sep() const
163 {
164 return do_thousands_sep();
165 }
166
167 string_type grouping() const
168 {
169 return do_grouping();
170 }
171
172 string_type truename() const
173 {
174 return do_truename();
175 }
176
177 string_type falsename() const
178 {
179 return do_falsename();
180 }
181
182 ~numpunct();
183
184 protected:
185 char_type do_decimal_point() const
186 {
187 return L'.';
188 }
189
190 char_type do_thousands_sep() const
191 {
192 return L',';
193 }
194
195 string_type do_grouping() const
196 {
197 return L"";
198 }
199
200 string_type do_truename() const
201 {
202 return L"true";
203 }
204
205 string_type do_falsename() const
206 {
207 return L"false";
208 }
209 };
210}
211
212#endif
Note: See TracBrowser for help on using the repository browser.