source: mainline/uspace/lib/cpp/include/__bits/locale/locale_misc.hpp@ b57ba05

Last change on this file since b57ba05 was b57ba05, checked in by Jiří Zárevúcky <zarevucky.jiri@…>, 3 years ago

Update headers in C++ files

  • Property mode set to 100644
File size: 3.1 KB
Line 
1/*
2 * SPDX-FileCopyrightText: 2018 Jaroslav Jindrak
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#ifndef LIBCPP_BITS_LOCALE_MISC
8#define LIBCPP_BITS_LOCALE_MISC
9
10#include <__bits/locale/locale.hpp>
11#include <__bits/locale/ctype.hpp>
12#include <__bits/locale/num_get.hpp>
13#include <__bits/locale/num_put.hpp>
14#include <__bits/locale/numpunct.hpp>
15#include <cstdlib>
16#include <ios>
17#include <iosfwd>
18#include <string>
19
20namespace std
21{
22 /**
23 * Note: This is a very simplistic implementation of <locale>.
24 * We have a single locale that has all of its facets.
25 * This should behave correctly on the outside but will prevent
26 * us from using multiple locales so if that becomes necessary
27 * in the future, TODO: implement :)
28 */
29
30 /**
31 * 22.3.3, convenience interfaces:
32 */
33
34 /**
35 * 22.3.3.1, character classification:
36 */
37
38 template<class Char>
39 bool isspace(Char c, const locale& loc)
40 {
41 return use_facet<ctype<Char>>(loc).is(ctype_base::space, c);
42 }
43
44 template<class Char>
45 bool isprint(Char c, const locale& loc)
46 {
47 return use_facet<ctype<Char>>(loc).is(ctype_base::print, c);
48 }
49
50 template<class Char>
51 bool iscntrl(Char c, const locale& loc)
52 {
53 return use_facet<ctype<Char>>(loc).is(ctype_base::cntrl, c);
54 }
55
56 template<class Char>
57 bool isupper(Char c, const locale& loc)
58 {
59 return use_facet<ctype<Char>>(loc).is(ctype_base::upper, c);
60 }
61
62 template<class Char>
63 bool islower(Char c, const locale& loc)
64 {
65 return use_facet<ctype<Char>>(loc).is(ctype_base::lower, c);
66 }
67
68 template<class Char>
69 bool isalpha(Char c, const locale& loc)
70 {
71 return use_facet<ctype<Char>>(loc).is(ctype_base::alpha, c);
72 }
73
74 template<class Char>
75 bool isdigit(Char c, const locale& loc)
76 {
77 return use_facet<ctype<Char>>(loc).is(ctype_base::digit, c);
78 }
79
80 template<class Char>
81 bool ispunct(Char c, const locale& loc)
82 {
83 return use_facet<ctype<Char>>(loc).is(ctype_base::punct, c);
84 }
85
86 template<class Char>
87 bool isxdigit(Char c, const locale& loc)
88 {
89 return use_facet<ctype<Char>>(loc).is(ctype_base::xdigit, c);
90 }
91
92 template<class Char>
93 bool isalnum(Char c, const locale& loc)
94 {
95 return use_facet<ctype<Char>>(loc).is(ctype_base::alnum, c);
96 }
97
98 template<class Char>
99 bool isgraph(Char c, const locale& loc)
100 {
101 return use_facet<ctype<Char>>(loc).is(ctype_base::graph, c);
102 }
103
104 template<class Char>
105 bool isblank(Char c, const locale& loc)
106 {
107 return use_facet<ctype<Char>>(loc).is(ctype_base::blank, c);
108 }
109
110 /**
111 * 22.3.3.2, conversions:
112 */
113
114 /**
115 * 22.3.3.2.1, character conversions:
116 */
117
118 template<class Char>
119 Char toupper(Char c, const locale& loc)
120 {
121 return use_facet<ctype<Char>>(loc).toupper(c);
122 }
123
124 template<class Char>
125 Char tolower(Char c, const locale& loc)
126 {
127 return use_facet<ctype<Char>>(loc).tolower(c);
128 }
129
130 /**
131 * 22.3.3.2.2, string conversions:
132 */
133
134 // TODO: implement
135}
136
137#endif
Note: See TracBrowser for help on using the repository browser.