1// -*- C++ -*-
2//===----------------------------------------------------------------------===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP_LOCALE
11#define _LIBCPP_LOCALE
12
13/*
14 locale synopsis
15
16namespace std
17{
18
19class locale
20{
21public:
22 // types:
23 class facet;
24 class id;
25
26 typedef int category;
27 static const category // values assigned here are for exposition only
28 none = 0x000,
29 collate = 0x010,
30 ctype = 0x020,
31 monetary = 0x040,
32 numeric = 0x080,
33 time = 0x100,
34 messages = 0x200,
35 all = collate | ctype | monetary | numeric | time | messages;
36
37 // construct/copy/destroy:
38 locale() noexcept;
39 locale(const locale& other) noexcept;
40 explicit locale(const char* std_name);
41 explicit locale(const string& std_name);
42 locale(const locale& other, const char* std_name, category);
43 locale(const locale& other, const string& std_name, category);
44 template <class Facet> locale(const locale& other, Facet* f);
45 locale(const locale& other, const locale& one, category);
46
47 ~locale(); // not virtual
48
49 const locale& operator=(const locale& other) noexcept;
50
51 template <class Facet> locale combine(const locale& other) const;
52
53 // locale operations:
54 basic_string<char> name() const;
55 bool operator==(const locale& other) const;
56 bool operator!=(const locale& other) const; // removed C++20
57 template <class charT, class Traits, class Allocator>
58 bool operator()(const basic_string<charT,Traits,Allocator>& s1,
59 const basic_string<charT,Traits,Allocator>& s2) const;
60
61 // global locale objects:
62 static locale global(const locale&);
63 static const locale& classic();
64};
65
66template <class Facet> const Facet& use_facet(const locale&);
67template <class Facet> bool has_facet(const locale&) noexcept;
68
69// 22.3.3, convenience interfaces:
70template <class charT> bool isspace (charT c, const locale& loc);
71template <class charT> bool isprint (charT c, const locale& loc);
72template <class charT> bool iscntrl (charT c, const locale& loc);
73template <class charT> bool isupper (charT c, const locale& loc);
74template <class charT> bool islower (charT c, const locale& loc);
75template <class charT> bool isalpha (charT c, const locale& loc);
76template <class charT> bool isdigit (charT c, const locale& loc);
77template <class charT> bool ispunct (charT c, const locale& loc);
78template <class charT> bool isxdigit(charT c, const locale& loc);
79template <class charT> bool isalnum (charT c, const locale& loc);
80template <class charT> bool isgraph (charT c, const locale& loc);
81template <class charT> charT toupper(charT c, const locale& loc);
82template <class charT> charT tolower(charT c, const locale& loc);
83
84template<class Codecvt, class Elem = wchar_t,
85 class Wide_alloc = allocator<Elem>,
86 class Byte_alloc = allocator<char>>
87class wstring_convert // Removed in C++26
88{
89public:
90 typedef basic_string<char, char_traits<char>, Byte_alloc> byte_string;
91 typedef basic_string<Elem, char_traits<Elem>, Wide_alloc> wide_string;
92 typedef typename Codecvt::state_type state_type;
93 typedef typename wide_string::traits_type::int_type int_type;
94
95 wstring_convert() : wstring_convert(new Codecvt) {}
96 explicit wstring_convert(Codecvt* pcvt);
97
98 wstring_convert(Codecvt* pcvt, state_type state);
99 explicit wstring_convert(const byte_string& byte_err,
100 const wide_string& wide_err = wide_string());
101 wstring_convert(const wstring_convert&) = delete;
102 wstring_convert & operator=(const wstring_convert &) = delete;
103 ~wstring_convert();
104
105 wide_string from_bytes(char byte);
106 wide_string from_bytes(const char* ptr);
107 wide_string from_bytes(const byte_string& str);
108 wide_string from_bytes(const char* first, const char* last);
109
110 byte_string to_bytes(Elem wchar);
111 byte_string to_bytes(const Elem* wptr);
112 byte_string to_bytes(const wide_string& wstr);
113 byte_string to_bytes(const Elem* first, const Elem* last);
114
115 size_t converted() const; // noexcept in C++14
116 state_type state() const;
117};
118
119template <class Codecvt, class Elem = wchar_t, class Tr = char_traits<Elem>>
120class wbuffer_convert // Removed in C++26
121 : public basic_streambuf<Elem, Tr>
122{
123public:
124 typedef typename Tr::state_type state_type;
125
126 wbuffer_convert() : wbuffer_convert(nullptr) {}
127 explicit wbuffer_convert(streambuf* bytebuf, Codecvt* pcvt = new Codecvt,
128 state_type state = state_type());
129
130 wbuffer_convert(const wbuffer_convert&) = delete;
131 wbuffer_convert & operator=(const wbuffer_convert &) = delete;
132 ~wbuffer_convert();
133
134 streambuf* rdbuf() const;
135 streambuf* rdbuf(streambuf* bytebuf);
136
137 state_type state() const;
138};
139
140// 22.4.1 and 22.4.1.3, ctype:
141class ctype_base;
142template <class charT> class ctype;
143template <> class ctype<char>; // specialization
144template <class charT> class ctype_byname;
145template <> class ctype_byname<char>; // specialization
146
147class codecvt_base;
148template <class internT, class externT, class stateT> class codecvt;
149template <class internT, class externT, class stateT> class codecvt_byname;
150
151// 22.4.2 and 22.4.3, numeric:
152template <class charT, class InputIterator> class num_get;
153template <class charT, class OutputIterator> class num_put;
154template <class charT> class numpunct;
155template <class charT> class numpunct_byname;
156
157// 22.4.4, col lation:
158template <class charT> class collate;
159template <class charT> class collate_byname;
160
161// 22.4.5, date and time:
162class time_base;
163template <class charT, class InputIterator> class time_get;
164template <class charT, class InputIterator> class time_get_byname;
165template <class charT, class OutputIterator> class time_put;
166template <class charT, class OutputIterator> class time_put_byname;
167
168// 22.4.6, money:
169class money_base;
170template <class charT, class InputIterator> class money_get;
171template <class charT, class OutputIterator> class money_put;
172template <class charT, bool Intl> class moneypunct;
173template <class charT, bool Intl> class moneypunct_byname;
174
175// 22.4.7, message retrieval:
176class messages_base;
177template <class charT> class messages;
178template <class charT> class messages_byname;
179
180} // std
181
182*/
183
184#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
185# include <__cxx03/locale>
186#else
187# include <__config>
188
189# if _LIBCPP_HAS_LOCALIZATION
190
191# include <__locale_dir/codecvt.h>
192# include <__locale_dir/collate.h>
193# include <__locale_dir/ctype.h>
194# include <__locale_dir/ctype_base.h>
195# include <__locale_dir/locale.h>
196# include <__locale_dir/messages.h>
197# include <__locale_dir/money.h>
198# include <__locale_dir/num.h>
199# include <__locale_dir/time.h>
200# include <__locale_dir/wbuffer_convert.h>
201# include <__locale_dir/wstring_convert.h>
202# include <ios>
203# include <streambuf>
204# include <version>
205
206# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
207# pragma GCC system_header
208# endif
209
210# endif // _LIBCPP_HAS_LOCALIZATION
211
212#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
213
214#endif // _LIBCPP_LOCALE
215