source: mainline/uspace/lib/cpp/include/impl/locale.hpp@ b3b8405

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since b3b8405 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: 4.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_LOCALE
30#define LIBCPP_LOCALE
31
32#include <cstdlib>
33#include <ios>
34#include <iosfwd>
35#include <string>
36
37#include <__bits/locale.hpp>
38#include <__bits/locale/ctype.hpp>
39#include <__bits/locale/num_get.hpp>
40#include <__bits/locale/num_put.hpp>
41#include <__bits/locale/numpunct.hpp>
42
43namespace std
44{
45 /**
46 * Note: This is a very simplistic implementation of <locale>.
47 * We have a single locale that has all of its facets.
48 * This should behave correctly on the outside but will prevent
49 * us from using multiple locales so if that becomes necessary
50 * in the future, TODO: implement :)
51 */
52
53 /**
54 * 22.3.3, convenience interfaces:
55 */
56
57 /**
58 * 22.3.3.1, character classification:
59 */
60
61 template<class Char>
62 bool isspace(Char c, const locale& loc)
63 {
64 return use_facet<ctype<Char>>(loc).is(ctype_base::space, c);
65 }
66
67 template<class Char>
68 bool isprint(Char c, const locale& loc)
69 {
70 return use_facet<ctype<Char>>(loc).is(ctype_base::print, c);
71 }
72
73 template<class Char>
74 bool iscntrl(Char c, const locale& loc)
75 {
76 return use_facet<ctype<Char>>(loc).is(ctype_base::cntrl, c);
77 }
78
79 template<class Char>
80 bool isupper(Char c, const locale& loc)
81 {
82 return use_facet<ctype<Char>>(loc).is(ctype_base::upper, c);
83 }
84
85 template<class Char>
86 bool islower(Char c, const locale& loc)
87 {
88 return use_facet<ctype<Char>>(loc).is(ctype_base::lower, c);
89 }
90
91 template<class Char>
92 bool isalpha(Char c, const locale& loc)
93 {
94 return use_facet<ctype<Char>>(loc).is(ctype_base::alpha, c);
95 }
96
97 template<class Char>
98 bool isdigit(Char c, const locale& loc)
99 {
100 return use_facet<ctype<Char>>(loc).is(ctype_base::digit, c);
101 }
102
103 template<class Char>
104 bool ispunct(Char c, const locale& loc)
105 {
106 return use_facet<ctype<Char>>(loc).is(ctype_base::punct, c);
107 }
108
109 template<class Char>
110 bool isxdigit(Char c, const locale& loc)
111 {
112 return use_facet<ctype<Char>>(loc).is(ctype_base::xdigit, c);
113 }
114
115 template<class Char>
116 bool isalnum(Char c, const locale& loc)
117 {
118 return use_facet<ctype<Char>>(loc).is(ctype_base::alnum, c);
119 }
120
121 template<class Char>
122 bool isgraph(Char c, const locale& loc)
123 {
124 return use_facet<ctype<Char>>(loc).is(ctype_base::graph, c);
125 }
126
127 template<class Char>
128 bool isblank(Char c, const locale& loc)
129 {
130 return use_facet<ctype<Char>>(loc).is(ctype_base::blank, c);
131 }
132
133 /**
134 * 22.3.3.2, conversions:
135 */
136
137 /**
138 * 22.3.3.2.1, character conversions:
139 */
140
141 template<class Char>
142 Char toupper(Char c, const locale& loc)
143 {
144 return use_facet<ctype<Char>>(loc).toupper(c);
145 }
146
147 template<class Char>
148 Char tolower(Char c, const locale& loc)
149 {
150 return use_facet<ctype<Char>>(loc).tolower(c);
151 }
152
153 /**
154 * 22.3.3.2.2, string conversions:
155 */
156
157 // TODO: implement
158}
159
160#endif
Note: See TracBrowser for help on using the repository browser.