xref: /aosp_15_r20/external/libcxx/include/__locale (revision 58b9f456b02922dfdb1fad8a988d5fd8765ecb80)
1*58b9f456SAndroid Build Coastguard Worker// -*- C++ -*-
2*58b9f456SAndroid Build Coastguard Worker//===----------------------------------------------------------------------===//
3*58b9f456SAndroid Build Coastguard Worker//
4*58b9f456SAndroid Build Coastguard Worker//                     The LLVM Compiler Infrastructure
5*58b9f456SAndroid Build Coastguard Worker//
6*58b9f456SAndroid Build Coastguard Worker// This file is dual licensed under the MIT and the University of Illinois Open
7*58b9f456SAndroid Build Coastguard Worker// Source Licenses. See LICENSE.TXT for details.
8*58b9f456SAndroid Build Coastguard Worker//
9*58b9f456SAndroid Build Coastguard Worker//===----------------------------------------------------------------------===//
10*58b9f456SAndroid Build Coastguard Worker
11*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP___LOCALE
12*58b9f456SAndroid Build Coastguard Worker#define _LIBCPP___LOCALE
13*58b9f456SAndroid Build Coastguard Worker
14*58b9f456SAndroid Build Coastguard Worker#include <__config>
15*58b9f456SAndroid Build Coastguard Worker#include <string>
16*58b9f456SAndroid Build Coastguard Worker#include <memory>
17*58b9f456SAndroid Build Coastguard Worker#include <utility>
18*58b9f456SAndroid Build Coastguard Worker#include <mutex>
19*58b9f456SAndroid Build Coastguard Worker#include <cstdint>
20*58b9f456SAndroid Build Coastguard Worker#include <cctype>
21*58b9f456SAndroid Build Coastguard Worker#include <locale.h>
22*58b9f456SAndroid Build Coastguard Worker#if defined(_LIBCPP_MSVCRT_LIKE)
23*58b9f456SAndroid Build Coastguard Worker# include <support/win32/locale_win32.h>
24*58b9f456SAndroid Build Coastguard Worker#elif defined(_AIX)
25*58b9f456SAndroid Build Coastguard Worker# include <support/ibm/xlocale.h>
26*58b9f456SAndroid Build Coastguard Worker#elif defined(__ANDROID__)
27*58b9f456SAndroid Build Coastguard Worker# include <support/android/locale_bionic.h>
28*58b9f456SAndroid Build Coastguard Worker#elif defined(__sun__)
29*58b9f456SAndroid Build Coastguard Worker# include <xlocale.h>
30*58b9f456SAndroid Build Coastguard Worker# include <support/solaris/xlocale.h>
31*58b9f456SAndroid Build Coastguard Worker#elif defined(_NEWLIB_VERSION)
32*58b9f456SAndroid Build Coastguard Worker# include <support/newlib/xlocale.h>
33*58b9f456SAndroid Build Coastguard Worker#elif (defined(__APPLE__)      || defined(__FreeBSD__) \
34*58b9f456SAndroid Build Coastguard Worker    || defined(__EMSCRIPTEN__) || defined(__IBMCPP__))
35*58b9f456SAndroid Build Coastguard Worker# include <xlocale.h>
36*58b9f456SAndroid Build Coastguard Worker#elif defined(__Fuchsia__)
37*58b9f456SAndroid Build Coastguard Worker# include <support/fuchsia/xlocale.h>
38*58b9f456SAndroid Build Coastguard Worker#elif defined(_LIBCPP_HAS_MUSL_LIBC)
39*58b9f456SAndroid Build Coastguard Worker# include <support/musl/xlocale.h>
40*58b9f456SAndroid Build Coastguard Worker#endif
41*58b9f456SAndroid Build Coastguard Worker
42*58b9f456SAndroid Build Coastguard Worker#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
43*58b9f456SAndroid Build Coastguard Worker#pragma GCC system_header
44*58b9f456SAndroid Build Coastguard Worker#endif
45*58b9f456SAndroid Build Coastguard Worker
46*58b9f456SAndroid Build Coastguard Worker_LIBCPP_BEGIN_NAMESPACE_STD
47*58b9f456SAndroid Build Coastguard Worker
48*58b9f456SAndroid Build Coastguard Worker#if !defined(_LIBCPP_LOCALE__L_EXTENSIONS)
49*58b9f456SAndroid Build Coastguard Workerstruct __libcpp_locale_guard {
50*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
51*58b9f456SAndroid Build Coastguard Worker  __libcpp_locale_guard(locale_t& __loc) : __old_loc_(uselocale(__loc)) {}
52*58b9f456SAndroid Build Coastguard Worker
53*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
54*58b9f456SAndroid Build Coastguard Worker  ~__libcpp_locale_guard() {
55*58b9f456SAndroid Build Coastguard Worker    if (__old_loc_)
56*58b9f456SAndroid Build Coastguard Worker      uselocale(__old_loc_);
57*58b9f456SAndroid Build Coastguard Worker  }
58*58b9f456SAndroid Build Coastguard Worker
59*58b9f456SAndroid Build Coastguard Worker  locale_t __old_loc_;
60*58b9f456SAndroid Build Coastguard Workerprivate:
61*58b9f456SAndroid Build Coastguard Worker  __libcpp_locale_guard(__libcpp_locale_guard const&);
62*58b9f456SAndroid Build Coastguard Worker  __libcpp_locale_guard& operator=(__libcpp_locale_guard const&);
63*58b9f456SAndroid Build Coastguard Worker};
64*58b9f456SAndroid Build Coastguard Worker#elif defined(_LIBCPP_MSVCRT_LIKE)
65*58b9f456SAndroid Build Coastguard Workerstruct __libcpp_locale_guard {
66*58b9f456SAndroid Build Coastguard Worker    __libcpp_locale_guard(locale_t __l) :
67*58b9f456SAndroid Build Coastguard Worker        __status(_configthreadlocale(_ENABLE_PER_THREAD_LOCALE)),
68*58b9f456SAndroid Build Coastguard Worker        __locale_collate(setlocale(LC_COLLATE, __l.__get_locale())),
69*58b9f456SAndroid Build Coastguard Worker        __locale_ctype(setlocale(LC_CTYPE, __l.__get_locale())),
70*58b9f456SAndroid Build Coastguard Worker        __locale_monetary(setlocale(LC_MONETARY, __l.__get_locale())),
71*58b9f456SAndroid Build Coastguard Worker        __locale_numeric(setlocale(LC_NUMERIC, __l.__get_locale())),
72*58b9f456SAndroid Build Coastguard Worker        __locale_time(setlocale(LC_TIME, __l.__get_locale()))
73*58b9f456SAndroid Build Coastguard Worker        // LC_MESSAGES is not supported on Windows.
74*58b9f456SAndroid Build Coastguard Worker    {}
75*58b9f456SAndroid Build Coastguard Worker    ~__libcpp_locale_guard() {
76*58b9f456SAndroid Build Coastguard Worker        setlocale(LC_COLLATE, __locale_collate);
77*58b9f456SAndroid Build Coastguard Worker        setlocale(LC_CTYPE, __locale_ctype);
78*58b9f456SAndroid Build Coastguard Worker        setlocale(LC_MONETARY, __locale_monetary);
79*58b9f456SAndroid Build Coastguard Worker        setlocale(LC_NUMERIC, __locale_numeric);
80*58b9f456SAndroid Build Coastguard Worker        setlocale(LC_TIME, __locale_time);
81*58b9f456SAndroid Build Coastguard Worker        _configthreadlocale(__status);
82*58b9f456SAndroid Build Coastguard Worker    }
83*58b9f456SAndroid Build Coastguard Worker    int __status;
84*58b9f456SAndroid Build Coastguard Worker    char* __locale_collate;
85*58b9f456SAndroid Build Coastguard Worker    char* __locale_ctype;
86*58b9f456SAndroid Build Coastguard Worker    char* __locale_monetary;
87*58b9f456SAndroid Build Coastguard Worker    char* __locale_numeric;
88*58b9f456SAndroid Build Coastguard Worker    char* __locale_time;
89*58b9f456SAndroid Build Coastguard Worker};
90*58b9f456SAndroid Build Coastguard Worker#endif
91*58b9f456SAndroid Build Coastguard Worker
92*58b9f456SAndroid Build Coastguard Worker
93*58b9f456SAndroid Build Coastguard Workerclass _LIBCPP_TYPE_VIS locale;
94*58b9f456SAndroid Build Coastguard Worker
95*58b9f456SAndroid Build Coastguard Workertemplate <class _Facet>
96*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
97*58b9f456SAndroid Build Coastguard Workerbool
98*58b9f456SAndroid Build Coastguard Workerhas_facet(const locale&) _NOEXCEPT;
99*58b9f456SAndroid Build Coastguard Worker
100*58b9f456SAndroid Build Coastguard Workertemplate <class _Facet>
101*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
102*58b9f456SAndroid Build Coastguard Workerconst _Facet&
103*58b9f456SAndroid Build Coastguard Workeruse_facet(const locale&);
104*58b9f456SAndroid Build Coastguard Worker
105*58b9f456SAndroid Build Coastguard Workerclass _LIBCPP_TYPE_VIS locale
106*58b9f456SAndroid Build Coastguard Worker{
107*58b9f456SAndroid Build Coastguard Workerpublic:
108*58b9f456SAndroid Build Coastguard Worker    // types:
109*58b9f456SAndroid Build Coastguard Worker    class _LIBCPP_TYPE_VIS facet;
110*58b9f456SAndroid Build Coastguard Worker    class _LIBCPP_TYPE_VIS id;
111*58b9f456SAndroid Build Coastguard Worker
112*58b9f456SAndroid Build Coastguard Worker    typedef int category;
113*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_AVAILABILITY_LOCALE_CATEGORY
114*58b9f456SAndroid Build Coastguard Worker    static const category // values assigned here are for exposition only
115*58b9f456SAndroid Build Coastguard Worker        none     = 0,
116*58b9f456SAndroid Build Coastguard Worker        collate  = LC_COLLATE_MASK,
117*58b9f456SAndroid Build Coastguard Worker        ctype    = LC_CTYPE_MASK,
118*58b9f456SAndroid Build Coastguard Worker        monetary = LC_MONETARY_MASK,
119*58b9f456SAndroid Build Coastguard Worker        numeric  = LC_NUMERIC_MASK,
120*58b9f456SAndroid Build Coastguard Worker        time     = LC_TIME_MASK,
121*58b9f456SAndroid Build Coastguard Worker        messages = LC_MESSAGES_MASK,
122*58b9f456SAndroid Build Coastguard Worker        all = collate | ctype | monetary | numeric | time | messages;
123*58b9f456SAndroid Build Coastguard Worker
124*58b9f456SAndroid Build Coastguard Worker    // construct/copy/destroy:
125*58b9f456SAndroid Build Coastguard Worker    locale()  _NOEXCEPT;
126*58b9f456SAndroid Build Coastguard Worker    locale(const locale&)  _NOEXCEPT;
127*58b9f456SAndroid Build Coastguard Worker    explicit locale(const char*);
128*58b9f456SAndroid Build Coastguard Worker    explicit locale(const string&);
129*58b9f456SAndroid Build Coastguard Worker    locale(const locale&, const char*, category);
130*58b9f456SAndroid Build Coastguard Worker    locale(const locale&, const string&, category);
131*58b9f456SAndroid Build Coastguard Worker    template <class _Facet>
132*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_INLINE_VISIBILITY locale(const locale&, _Facet*);
133*58b9f456SAndroid Build Coastguard Worker    locale(const locale&, const locale&, category);
134*58b9f456SAndroid Build Coastguard Worker
135*58b9f456SAndroid Build Coastguard Worker    ~locale();
136*58b9f456SAndroid Build Coastguard Worker
137*58b9f456SAndroid Build Coastguard Worker    const locale& operator=(const locale&)  _NOEXCEPT;
138*58b9f456SAndroid Build Coastguard Worker
139*58b9f456SAndroid Build Coastguard Worker    template <class _Facet>
140*58b9f456SAndroid Build Coastguard Worker      _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
141*58b9f456SAndroid Build Coastguard Worker      locale combine(const locale&) const;
142*58b9f456SAndroid Build Coastguard Worker
143*58b9f456SAndroid Build Coastguard Worker    // locale operations:
144*58b9f456SAndroid Build Coastguard Worker    string name() const;
145*58b9f456SAndroid Build Coastguard Worker    bool operator==(const locale&) const;
146*58b9f456SAndroid Build Coastguard Worker    bool operator!=(const locale& __y) const {return !(*this == __y);}
147*58b9f456SAndroid Build Coastguard Worker    template <class _CharT, class _Traits, class _Allocator>
148*58b9f456SAndroid Build Coastguard Worker      _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
149*58b9f456SAndroid Build Coastguard Worker      bool operator()(const basic_string<_CharT, _Traits, _Allocator>&,
150*58b9f456SAndroid Build Coastguard Worker                      const basic_string<_CharT, _Traits, _Allocator>&) const;
151*58b9f456SAndroid Build Coastguard Worker
152*58b9f456SAndroid Build Coastguard Worker    // global locale objects:
153*58b9f456SAndroid Build Coastguard Worker    static locale global(const locale&);
154*58b9f456SAndroid Build Coastguard Worker    static const locale& classic();
155*58b9f456SAndroid Build Coastguard Worker
156*58b9f456SAndroid Build Coastguard Workerprivate:
157*58b9f456SAndroid Build Coastguard Worker    class __imp;
158*58b9f456SAndroid Build Coastguard Worker    __imp* __locale_;
159*58b9f456SAndroid Build Coastguard Worker
160*58b9f456SAndroid Build Coastguard Worker    void __install_ctor(const locale&, facet*, long);
161*58b9f456SAndroid Build Coastguard Worker    static locale& __global();
162*58b9f456SAndroid Build Coastguard Worker    bool has_facet(id&) const;
163*58b9f456SAndroid Build Coastguard Worker    const facet* use_facet(id&) const;
164*58b9f456SAndroid Build Coastguard Worker
165*58b9f456SAndroid Build Coastguard Worker    template <class _Facet> friend bool has_facet(const locale&)  _NOEXCEPT;
166*58b9f456SAndroid Build Coastguard Worker    template <class _Facet> friend const _Facet& use_facet(const locale&);
167*58b9f456SAndroid Build Coastguard Worker};
168*58b9f456SAndroid Build Coastguard Worker
169*58b9f456SAndroid Build Coastguard Workerclass _LIBCPP_TYPE_VIS locale::facet
170*58b9f456SAndroid Build Coastguard Worker    : public __shared_count
171*58b9f456SAndroid Build Coastguard Worker{
172*58b9f456SAndroid Build Coastguard Workerprotected:
173*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
174*58b9f456SAndroid Build Coastguard Worker    explicit facet(size_t __refs = 0)
175*58b9f456SAndroid Build Coastguard Worker        : __shared_count(static_cast<long>(__refs)-1) {}
176*58b9f456SAndroid Build Coastguard Worker
177*58b9f456SAndroid Build Coastguard Worker    virtual ~facet();
178*58b9f456SAndroid Build Coastguard Worker
179*58b9f456SAndroid Build Coastguard Worker//    facet(const facet&) = delete;     // effectively done in __shared_count
180*58b9f456SAndroid Build Coastguard Worker//    void operator=(const facet&) = delete;
181*58b9f456SAndroid Build Coastguard Workerprivate:
182*58b9f456SAndroid Build Coastguard Worker    virtual void __on_zero_shared() _NOEXCEPT;
183*58b9f456SAndroid Build Coastguard Worker};
184*58b9f456SAndroid Build Coastguard Worker
185*58b9f456SAndroid Build Coastguard Workerclass _LIBCPP_TYPE_VIS locale::id
186*58b9f456SAndroid Build Coastguard Worker{
187*58b9f456SAndroid Build Coastguard Worker    once_flag      __flag_;
188*58b9f456SAndroid Build Coastguard Worker    int32_t        __id_;
189*58b9f456SAndroid Build Coastguard Worker
190*58b9f456SAndroid Build Coastguard Worker    static int32_t __next_id;
191*58b9f456SAndroid Build Coastguard Workerpublic:
192*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR id() :__id_(0) {}
193*58b9f456SAndroid Build Coastguard Workerprivate:
194*58b9f456SAndroid Build Coastguard Worker    void __init();
195*58b9f456SAndroid Build Coastguard Worker    void operator=(const id&); // = delete;
196*58b9f456SAndroid Build Coastguard Worker    id(const id&); // = delete;
197*58b9f456SAndroid Build Coastguard Workerpublic:  // only needed for tests
198*58b9f456SAndroid Build Coastguard Worker    long __get();
199*58b9f456SAndroid Build Coastguard Worker
200*58b9f456SAndroid Build Coastguard Worker    friend class locale;
201*58b9f456SAndroid Build Coastguard Worker    friend class locale::__imp;
202*58b9f456SAndroid Build Coastguard Worker};
203*58b9f456SAndroid Build Coastguard Worker
204*58b9f456SAndroid Build Coastguard Workertemplate <class _Facet>
205*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
206*58b9f456SAndroid Build Coastguard Workerlocale::locale(const locale& __other, _Facet* __f)
207*58b9f456SAndroid Build Coastguard Worker{
208*58b9f456SAndroid Build Coastguard Worker    __install_ctor(__other, __f, __f ? __f->id.__get() : 0);
209*58b9f456SAndroid Build Coastguard Worker}
210*58b9f456SAndroid Build Coastguard Worker
211*58b9f456SAndroid Build Coastguard Workertemplate <class _Facet>
212*58b9f456SAndroid Build Coastguard Workerlocale
213*58b9f456SAndroid Build Coastguard Workerlocale::combine(const locale& __other) const
214*58b9f456SAndroid Build Coastguard Worker{
215*58b9f456SAndroid Build Coastguard Worker    if (!_VSTD::has_facet<_Facet>(__other))
216*58b9f456SAndroid Build Coastguard Worker        __throw_runtime_error("locale::combine: locale missing facet");
217*58b9f456SAndroid Build Coastguard Worker
218*58b9f456SAndroid Build Coastguard Worker    return locale(*this, &const_cast<_Facet&>(_VSTD::use_facet<_Facet>(__other)));
219*58b9f456SAndroid Build Coastguard Worker}
220*58b9f456SAndroid Build Coastguard Worker
221*58b9f456SAndroid Build Coastguard Workertemplate <class _Facet>
222*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
223*58b9f456SAndroid Build Coastguard Workerbool
224*58b9f456SAndroid Build Coastguard Workerhas_facet(const locale& __l)  _NOEXCEPT
225*58b9f456SAndroid Build Coastguard Worker{
226*58b9f456SAndroid Build Coastguard Worker    return __l.has_facet(_Facet::id);
227*58b9f456SAndroid Build Coastguard Worker}
228*58b9f456SAndroid Build Coastguard Worker
229*58b9f456SAndroid Build Coastguard Workertemplate <class _Facet>
230*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
231*58b9f456SAndroid Build Coastguard Workerconst _Facet&
232*58b9f456SAndroid Build Coastguard Workeruse_facet(const locale& __l)
233*58b9f456SAndroid Build Coastguard Worker{
234*58b9f456SAndroid Build Coastguard Worker    return static_cast<const _Facet&>(*__l.use_facet(_Facet::id));
235*58b9f456SAndroid Build Coastguard Worker}
236*58b9f456SAndroid Build Coastguard Worker
237*58b9f456SAndroid Build Coastguard Worker// template <class _CharT> class collate;
238*58b9f456SAndroid Build Coastguard Worker
239*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT>
240*58b9f456SAndroid Build Coastguard Workerclass _LIBCPP_TEMPLATE_VIS collate
241*58b9f456SAndroid Build Coastguard Worker    : public locale::facet
242*58b9f456SAndroid Build Coastguard Worker{
243*58b9f456SAndroid Build Coastguard Workerpublic:
244*58b9f456SAndroid Build Coastguard Worker    typedef _CharT char_type;
245*58b9f456SAndroid Build Coastguard Worker    typedef basic_string<char_type> string_type;
246*58b9f456SAndroid Build Coastguard Worker
247*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
248*58b9f456SAndroid Build Coastguard Worker    explicit collate(size_t __refs = 0)
249*58b9f456SAndroid Build Coastguard Worker        : locale::facet(__refs) {}
250*58b9f456SAndroid Build Coastguard Worker
251*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
252*58b9f456SAndroid Build Coastguard Worker    int compare(const char_type* __lo1, const char_type* __hi1,
253*58b9f456SAndroid Build Coastguard Worker                const char_type* __lo2, const char_type* __hi2) const
254*58b9f456SAndroid Build Coastguard Worker    {
255*58b9f456SAndroid Build Coastguard Worker        return do_compare(__lo1, __hi1, __lo2, __hi2);
256*58b9f456SAndroid Build Coastguard Worker    }
257*58b9f456SAndroid Build Coastguard Worker
258*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
259*58b9f456SAndroid Build Coastguard Worker    string_type transform(const char_type* __lo, const char_type* __hi) const
260*58b9f456SAndroid Build Coastguard Worker    {
261*58b9f456SAndroid Build Coastguard Worker        return do_transform(__lo, __hi);
262*58b9f456SAndroid Build Coastguard Worker    }
263*58b9f456SAndroid Build Coastguard Worker
264*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
265*58b9f456SAndroid Build Coastguard Worker    long hash(const char_type* __lo, const char_type* __hi) const
266*58b9f456SAndroid Build Coastguard Worker    {
267*58b9f456SAndroid Build Coastguard Worker        return do_hash(__lo, __hi);
268*58b9f456SAndroid Build Coastguard Worker    }
269*58b9f456SAndroid Build Coastguard Worker
270*58b9f456SAndroid Build Coastguard Worker    static locale::id id;
271*58b9f456SAndroid Build Coastguard Worker
272*58b9f456SAndroid Build Coastguard Workerprotected:
273*58b9f456SAndroid Build Coastguard Worker    ~collate();
274*58b9f456SAndroid Build Coastguard Worker    virtual int do_compare(const char_type* __lo1, const char_type* __hi1,
275*58b9f456SAndroid Build Coastguard Worker                           const char_type* __lo2, const char_type* __hi2) const;
276*58b9f456SAndroid Build Coastguard Worker    virtual string_type do_transform(const char_type* __lo, const char_type* __hi) const
277*58b9f456SAndroid Build Coastguard Worker        {return string_type(__lo, __hi);}
278*58b9f456SAndroid Build Coastguard Worker    virtual long do_hash(const char_type* __lo, const char_type* __hi) const;
279*58b9f456SAndroid Build Coastguard Worker};
280*58b9f456SAndroid Build Coastguard Worker
281*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT> locale::id collate<_CharT>::id;
282*58b9f456SAndroid Build Coastguard Worker
283*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT>
284*58b9f456SAndroid Build Coastguard Workercollate<_CharT>::~collate()
285*58b9f456SAndroid Build Coastguard Worker{
286*58b9f456SAndroid Build Coastguard Worker}
287*58b9f456SAndroid Build Coastguard Worker
288*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT>
289*58b9f456SAndroid Build Coastguard Workerint
290*58b9f456SAndroid Build Coastguard Workercollate<_CharT>::do_compare(const char_type* __lo1, const char_type* __hi1,
291*58b9f456SAndroid Build Coastguard Worker                            const char_type* __lo2, const char_type* __hi2) const
292*58b9f456SAndroid Build Coastguard Worker{
293*58b9f456SAndroid Build Coastguard Worker    for (; __lo2 != __hi2; ++__lo1, ++__lo2)
294*58b9f456SAndroid Build Coastguard Worker    {
295*58b9f456SAndroid Build Coastguard Worker        if (__lo1 == __hi1 || *__lo1 < *__lo2)
296*58b9f456SAndroid Build Coastguard Worker            return -1;
297*58b9f456SAndroid Build Coastguard Worker        if (*__lo2 < *__lo1)
298*58b9f456SAndroid Build Coastguard Worker            return 1;
299*58b9f456SAndroid Build Coastguard Worker    }
300*58b9f456SAndroid Build Coastguard Worker    return __lo1 != __hi1;
301*58b9f456SAndroid Build Coastguard Worker}
302*58b9f456SAndroid Build Coastguard Worker
303*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT>
304*58b9f456SAndroid Build Coastguard Workerlong
305*58b9f456SAndroid Build Coastguard Workercollate<_CharT>::do_hash(const char_type* __lo, const char_type* __hi) const
306*58b9f456SAndroid Build Coastguard Worker{
307*58b9f456SAndroid Build Coastguard Worker    size_t __h = 0;
308*58b9f456SAndroid Build Coastguard Worker    const size_t __sr = __CHAR_BIT__ * sizeof(size_t) - 8;
309*58b9f456SAndroid Build Coastguard Worker    const size_t __mask = size_t(0xF) << (__sr + 4);
310*58b9f456SAndroid Build Coastguard Worker    for(const char_type* __p = __lo; __p != __hi; ++__p)
311*58b9f456SAndroid Build Coastguard Worker    {
312*58b9f456SAndroid Build Coastguard Worker        __h = (__h << 4) + static_cast<size_t>(*__p);
313*58b9f456SAndroid Build Coastguard Worker        size_t __g = __h & __mask;
314*58b9f456SAndroid Build Coastguard Worker        __h ^= __g | (__g >> __sr);
315*58b9f456SAndroid Build Coastguard Worker    }
316*58b9f456SAndroid Build Coastguard Worker    return static_cast<long>(__h);
317*58b9f456SAndroid Build Coastguard Worker}
318*58b9f456SAndroid Build Coastguard Worker
319*58b9f456SAndroid Build Coastguard Worker_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS collate<char>)
320*58b9f456SAndroid Build Coastguard Worker_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS collate<wchar_t>)
321*58b9f456SAndroid Build Coastguard Worker
322*58b9f456SAndroid Build Coastguard Worker// template <class CharT> class collate_byname;
323*58b9f456SAndroid Build Coastguard Worker
324*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT> class _LIBCPP_TEMPLATE_VIS collate_byname;
325*58b9f456SAndroid Build Coastguard Worker
326*58b9f456SAndroid Build Coastguard Workertemplate <>
327*58b9f456SAndroid Build Coastguard Workerclass _LIBCPP_TYPE_VIS collate_byname<char>
328*58b9f456SAndroid Build Coastguard Worker    : public collate<char>
329*58b9f456SAndroid Build Coastguard Worker{
330*58b9f456SAndroid Build Coastguard Worker    locale_t __l;
331*58b9f456SAndroid Build Coastguard Workerpublic:
332*58b9f456SAndroid Build Coastguard Worker    typedef char char_type;
333*58b9f456SAndroid Build Coastguard Worker    typedef basic_string<char_type> string_type;
334*58b9f456SAndroid Build Coastguard Worker
335*58b9f456SAndroid Build Coastguard Worker    explicit collate_byname(const char* __n, size_t __refs = 0);
336*58b9f456SAndroid Build Coastguard Worker    explicit collate_byname(const string& __n, size_t __refs = 0);
337*58b9f456SAndroid Build Coastguard Worker
338*58b9f456SAndroid Build Coastguard Workerprotected:
339*58b9f456SAndroid Build Coastguard Worker    ~collate_byname();
340*58b9f456SAndroid Build Coastguard Worker    virtual int do_compare(const char_type* __lo1, const char_type* __hi1,
341*58b9f456SAndroid Build Coastguard Worker                           const char_type* __lo2, const char_type* __hi2) const;
342*58b9f456SAndroid Build Coastguard Worker    virtual string_type do_transform(const char_type* __lo, const char_type* __hi) const;
343*58b9f456SAndroid Build Coastguard Worker};
344*58b9f456SAndroid Build Coastguard Worker
345*58b9f456SAndroid Build Coastguard Workertemplate <>
346*58b9f456SAndroid Build Coastguard Workerclass _LIBCPP_TYPE_VIS collate_byname<wchar_t>
347*58b9f456SAndroid Build Coastguard Worker    : public collate<wchar_t>
348*58b9f456SAndroid Build Coastguard Worker{
349*58b9f456SAndroid Build Coastguard Worker    locale_t __l;
350*58b9f456SAndroid Build Coastguard Workerpublic:
351*58b9f456SAndroid Build Coastguard Worker    typedef wchar_t char_type;
352*58b9f456SAndroid Build Coastguard Worker    typedef basic_string<char_type> string_type;
353*58b9f456SAndroid Build Coastguard Worker
354*58b9f456SAndroid Build Coastguard Worker    explicit collate_byname(const char* __n, size_t __refs = 0);
355*58b9f456SAndroid Build Coastguard Worker    explicit collate_byname(const string& __n, size_t __refs = 0);
356*58b9f456SAndroid Build Coastguard Worker
357*58b9f456SAndroid Build Coastguard Workerprotected:
358*58b9f456SAndroid Build Coastguard Worker    ~collate_byname();
359*58b9f456SAndroid Build Coastguard Worker
360*58b9f456SAndroid Build Coastguard Worker    virtual int do_compare(const char_type* __lo1, const char_type* __hi1,
361*58b9f456SAndroid Build Coastguard Worker                           const char_type* __lo2, const char_type* __hi2) const;
362*58b9f456SAndroid Build Coastguard Worker    virtual string_type do_transform(const char_type* __lo, const char_type* __hi) const;
363*58b9f456SAndroid Build Coastguard Worker};
364*58b9f456SAndroid Build Coastguard Worker
365*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT, class _Traits, class _Allocator>
366*58b9f456SAndroid Build Coastguard Workerbool
367*58b9f456SAndroid Build Coastguard Workerlocale::operator()(const basic_string<_CharT, _Traits, _Allocator>& __x,
368*58b9f456SAndroid Build Coastguard Worker                   const basic_string<_CharT, _Traits, _Allocator>& __y) const
369*58b9f456SAndroid Build Coastguard Worker{
370*58b9f456SAndroid Build Coastguard Worker    return _VSTD::use_facet<_VSTD::collate<_CharT> >(*this).compare(
371*58b9f456SAndroid Build Coastguard Worker                                       __x.data(), __x.data() + __x.size(),
372*58b9f456SAndroid Build Coastguard Worker                                       __y.data(), __y.data() + __y.size()) < 0;
373*58b9f456SAndroid Build Coastguard Worker}
374*58b9f456SAndroid Build Coastguard Worker
375*58b9f456SAndroid Build Coastguard Worker// template <class charT> class ctype
376*58b9f456SAndroid Build Coastguard Worker
377*58b9f456SAndroid Build Coastguard Workerclass _LIBCPP_TYPE_VIS ctype_base
378*58b9f456SAndroid Build Coastguard Worker{
379*58b9f456SAndroid Build Coastguard Workerpublic:
380*58b9f456SAndroid Build Coastguard Worker#if defined(__GLIBC__)
381*58b9f456SAndroid Build Coastguard Worker    typedef unsigned short mask;
382*58b9f456SAndroid Build Coastguard Worker    static const mask space  = _ISspace;
383*58b9f456SAndroid Build Coastguard Worker    static const mask print  = _ISprint;
384*58b9f456SAndroid Build Coastguard Worker    static const mask cntrl  = _IScntrl;
385*58b9f456SAndroid Build Coastguard Worker    static const mask upper  = _ISupper;
386*58b9f456SAndroid Build Coastguard Worker    static const mask lower  = _ISlower;
387*58b9f456SAndroid Build Coastguard Worker    static const mask alpha  = _ISalpha;
388*58b9f456SAndroid Build Coastguard Worker    static const mask digit  = _ISdigit;
389*58b9f456SAndroid Build Coastguard Worker    static const mask punct  = _ISpunct;
390*58b9f456SAndroid Build Coastguard Worker    static const mask xdigit = _ISxdigit;
391*58b9f456SAndroid Build Coastguard Worker    static const mask blank  = _ISblank;
392*58b9f456SAndroid Build Coastguard Worker#elif defined(_LIBCPP_MSVCRT_LIKE)
393*58b9f456SAndroid Build Coastguard Worker    typedef unsigned short mask;
394*58b9f456SAndroid Build Coastguard Worker    static const mask space  = _SPACE;
395*58b9f456SAndroid Build Coastguard Worker    static const mask print  = _BLANK|_PUNCT|_ALPHA|_DIGIT;
396*58b9f456SAndroid Build Coastguard Worker    static const mask cntrl  = _CONTROL;
397*58b9f456SAndroid Build Coastguard Worker    static const mask upper  = _UPPER;
398*58b9f456SAndroid Build Coastguard Worker    static const mask lower  = _LOWER;
399*58b9f456SAndroid Build Coastguard Worker    static const mask alpha  = _ALPHA;
400*58b9f456SAndroid Build Coastguard Worker    static const mask digit  = _DIGIT;
401*58b9f456SAndroid Build Coastguard Worker    static const mask punct  = _PUNCT;
402*58b9f456SAndroid Build Coastguard Worker    static const mask xdigit = _HEX;
403*58b9f456SAndroid Build Coastguard Worker    static const mask blank  = _BLANK;
404*58b9f456SAndroid Build Coastguard Worker# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_PRINT
405*58b9f456SAndroid Build Coastguard Worker#elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__)
406*58b9f456SAndroid Build Coastguard Worker# ifdef __APPLE__
407*58b9f456SAndroid Build Coastguard Worker    typedef __uint32_t mask;
408*58b9f456SAndroid Build Coastguard Worker# elif defined(__FreeBSD__)
409*58b9f456SAndroid Build Coastguard Worker    typedef unsigned long mask;
410*58b9f456SAndroid Build Coastguard Worker# elif defined(__EMSCRIPTEN__) || defined(__NetBSD__)
411*58b9f456SAndroid Build Coastguard Worker    typedef unsigned short mask;
412*58b9f456SAndroid Build Coastguard Worker# endif
413*58b9f456SAndroid Build Coastguard Worker    static const mask space  = _CTYPE_S;
414*58b9f456SAndroid Build Coastguard Worker    static const mask print  = _CTYPE_R;
415*58b9f456SAndroid Build Coastguard Worker    static const mask cntrl  = _CTYPE_C;
416*58b9f456SAndroid Build Coastguard Worker    static const mask upper  = _CTYPE_U;
417*58b9f456SAndroid Build Coastguard Worker    static const mask lower  = _CTYPE_L;
418*58b9f456SAndroid Build Coastguard Worker    static const mask alpha  = _CTYPE_A;
419*58b9f456SAndroid Build Coastguard Worker    static const mask digit  = _CTYPE_D;
420*58b9f456SAndroid Build Coastguard Worker    static const mask punct  = _CTYPE_P;
421*58b9f456SAndroid Build Coastguard Worker    static const mask xdigit = _CTYPE_X;
422*58b9f456SAndroid Build Coastguard Worker
423*58b9f456SAndroid Build Coastguard Worker# if defined(__NetBSD__)
424*58b9f456SAndroid Build Coastguard Worker    static const mask blank  = _CTYPE_BL;
425*58b9f456SAndroid Build Coastguard Worker# else
426*58b9f456SAndroid Build Coastguard Worker    static const mask blank  = _CTYPE_B;
427*58b9f456SAndroid Build Coastguard Worker# endif
428*58b9f456SAndroid Build Coastguard Worker#elif defined(__sun__) || defined(_AIX)
429*58b9f456SAndroid Build Coastguard Worker    typedef unsigned int mask;
430*58b9f456SAndroid Build Coastguard Worker    static const mask space  = _ISSPACE;
431*58b9f456SAndroid Build Coastguard Worker    static const mask print  = _ISPRINT;
432*58b9f456SAndroid Build Coastguard Worker    static const mask cntrl  = _ISCNTRL;
433*58b9f456SAndroid Build Coastguard Worker    static const mask upper  = _ISUPPER;
434*58b9f456SAndroid Build Coastguard Worker    static const mask lower  = _ISLOWER;
435*58b9f456SAndroid Build Coastguard Worker    static const mask alpha  = _ISALPHA;
436*58b9f456SAndroid Build Coastguard Worker    static const mask digit  = _ISDIGIT;
437*58b9f456SAndroid Build Coastguard Worker    static const mask punct  = _ISPUNCT;
438*58b9f456SAndroid Build Coastguard Worker    static const mask xdigit = _ISXDIGIT;
439*58b9f456SAndroid Build Coastguard Worker    static const mask blank  = _ISBLANK;
440*58b9f456SAndroid Build Coastguard Worker#elif defined(_NEWLIB_VERSION)
441*58b9f456SAndroid Build Coastguard Worker    // Same type as Newlib's _ctype_ array in newlib/libc/include/ctype.h.
442*58b9f456SAndroid Build Coastguard Worker    typedef char mask;
443*58b9f456SAndroid Build Coastguard Worker    static const mask space  = _S;
444*58b9f456SAndroid Build Coastguard Worker    static const mask print  = _P | _U | _L | _N | _B;
445*58b9f456SAndroid Build Coastguard Worker    static const mask cntrl  = _C;
446*58b9f456SAndroid Build Coastguard Worker    static const mask upper  = _U;
447*58b9f456SAndroid Build Coastguard Worker    static const mask lower  = _L;
448*58b9f456SAndroid Build Coastguard Worker    static const mask alpha  = _U | _L;
449*58b9f456SAndroid Build Coastguard Worker    static const mask digit  = _N;
450*58b9f456SAndroid Build Coastguard Worker    static const mask punct  = _P;
451*58b9f456SAndroid Build Coastguard Worker    static const mask xdigit = _X | _N;
452*58b9f456SAndroid Build Coastguard Worker    static const mask blank  = _B;
453*58b9f456SAndroid Build Coastguard Worker# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_PRINT
454*58b9f456SAndroid Build Coastguard Worker# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_ALPHA
455*58b9f456SAndroid Build Coastguard Worker# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_XDIGIT
456*58b9f456SAndroid Build Coastguard Worker#else
457*58b9f456SAndroid Build Coastguard Worker    typedef unsigned long mask;
458*58b9f456SAndroid Build Coastguard Worker    static const mask space  = 1<<0;
459*58b9f456SAndroid Build Coastguard Worker    static const mask print  = 1<<1;
460*58b9f456SAndroid Build Coastguard Worker    static const mask cntrl  = 1<<2;
461*58b9f456SAndroid Build Coastguard Worker    static const mask upper  = 1<<3;
462*58b9f456SAndroid Build Coastguard Worker    static const mask lower  = 1<<4;
463*58b9f456SAndroid Build Coastguard Worker    static const mask alpha  = 1<<5;
464*58b9f456SAndroid Build Coastguard Worker    static const mask digit  = 1<<6;
465*58b9f456SAndroid Build Coastguard Worker    static const mask punct  = 1<<7;
466*58b9f456SAndroid Build Coastguard Worker    static const mask xdigit = 1<<8;
467*58b9f456SAndroid Build Coastguard Worker    static const mask blank  = 1<<9;
468*58b9f456SAndroid Build Coastguard Worker#endif
469*58b9f456SAndroid Build Coastguard Worker    static const mask alnum  = alpha | digit;
470*58b9f456SAndroid Build Coastguard Worker    static const mask graph  = alnum | punct;
471*58b9f456SAndroid Build Coastguard Worker
472*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY ctype_base() {}
473*58b9f456SAndroid Build Coastguard Worker};
474*58b9f456SAndroid Build Coastguard Worker
475*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT> class _LIBCPP_TEMPLATE_VIS ctype;
476*58b9f456SAndroid Build Coastguard Worker
477*58b9f456SAndroid Build Coastguard Workertemplate <>
478*58b9f456SAndroid Build Coastguard Workerclass _LIBCPP_TYPE_VIS ctype<wchar_t>
479*58b9f456SAndroid Build Coastguard Worker    : public locale::facet,
480*58b9f456SAndroid Build Coastguard Worker      public ctype_base
481*58b9f456SAndroid Build Coastguard Worker{
482*58b9f456SAndroid Build Coastguard Workerpublic:
483*58b9f456SAndroid Build Coastguard Worker    typedef wchar_t char_type;
484*58b9f456SAndroid Build Coastguard Worker
485*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
486*58b9f456SAndroid Build Coastguard Worker    explicit ctype(size_t __refs = 0)
487*58b9f456SAndroid Build Coastguard Worker        : locale::facet(__refs) {}
488*58b9f456SAndroid Build Coastguard Worker
489*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
490*58b9f456SAndroid Build Coastguard Worker    bool is(mask __m, char_type __c) const
491*58b9f456SAndroid Build Coastguard Worker    {
492*58b9f456SAndroid Build Coastguard Worker        return do_is(__m, __c);
493*58b9f456SAndroid Build Coastguard Worker    }
494*58b9f456SAndroid Build Coastguard Worker
495*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
496*58b9f456SAndroid Build Coastguard Worker    const char_type* is(const char_type* __low, const char_type* __high, mask* __vec) const
497*58b9f456SAndroid Build Coastguard Worker    {
498*58b9f456SAndroid Build Coastguard Worker        return do_is(__low, __high, __vec);
499*58b9f456SAndroid Build Coastguard Worker    }
500*58b9f456SAndroid Build Coastguard Worker
501*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
502*58b9f456SAndroid Build Coastguard Worker    const char_type* scan_is(mask __m, const char_type* __low, const char_type* __high) const
503*58b9f456SAndroid Build Coastguard Worker    {
504*58b9f456SAndroid Build Coastguard Worker        return do_scan_is(__m, __low, __high);
505*58b9f456SAndroid Build Coastguard Worker    }
506*58b9f456SAndroid Build Coastguard Worker
507*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
508*58b9f456SAndroid Build Coastguard Worker    const char_type* scan_not(mask __m, const char_type* __low, const char_type* __high) const
509*58b9f456SAndroid Build Coastguard Worker    {
510*58b9f456SAndroid Build Coastguard Worker        return do_scan_not(__m, __low, __high);
511*58b9f456SAndroid Build Coastguard Worker    }
512*58b9f456SAndroid Build Coastguard Worker
513*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
514*58b9f456SAndroid Build Coastguard Worker    char_type toupper(char_type __c) const
515*58b9f456SAndroid Build Coastguard Worker    {
516*58b9f456SAndroid Build Coastguard Worker        return do_toupper(__c);
517*58b9f456SAndroid Build Coastguard Worker    }
518*58b9f456SAndroid Build Coastguard Worker
519*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
520*58b9f456SAndroid Build Coastguard Worker    const char_type* toupper(char_type* __low, const char_type* __high) const
521*58b9f456SAndroid Build Coastguard Worker    {
522*58b9f456SAndroid Build Coastguard Worker        return do_toupper(__low, __high);
523*58b9f456SAndroid Build Coastguard Worker    }
524*58b9f456SAndroid Build Coastguard Worker
525*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
526*58b9f456SAndroid Build Coastguard Worker    char_type tolower(char_type __c) const
527*58b9f456SAndroid Build Coastguard Worker    {
528*58b9f456SAndroid Build Coastguard Worker        return do_tolower(__c);
529*58b9f456SAndroid Build Coastguard Worker    }
530*58b9f456SAndroid Build Coastguard Worker
531*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
532*58b9f456SAndroid Build Coastguard Worker    const char_type* tolower(char_type* __low, const char_type* __high) const
533*58b9f456SAndroid Build Coastguard Worker    {
534*58b9f456SAndroid Build Coastguard Worker        return do_tolower(__low, __high);
535*58b9f456SAndroid Build Coastguard Worker    }
536*58b9f456SAndroid Build Coastguard Worker
537*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
538*58b9f456SAndroid Build Coastguard Worker    char_type widen(char __c) const
539*58b9f456SAndroid Build Coastguard Worker    {
540*58b9f456SAndroid Build Coastguard Worker        return do_widen(__c);
541*58b9f456SAndroid Build Coastguard Worker    }
542*58b9f456SAndroid Build Coastguard Worker
543*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
544*58b9f456SAndroid Build Coastguard Worker    const char* widen(const char* __low, const char* __high, char_type* __to) const
545*58b9f456SAndroid Build Coastguard Worker    {
546*58b9f456SAndroid Build Coastguard Worker        return do_widen(__low, __high, __to);
547*58b9f456SAndroid Build Coastguard Worker    }
548*58b9f456SAndroid Build Coastguard Worker
549*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
550*58b9f456SAndroid Build Coastguard Worker    char narrow(char_type __c, char __dfault) const
551*58b9f456SAndroid Build Coastguard Worker    {
552*58b9f456SAndroid Build Coastguard Worker        return do_narrow(__c, __dfault);
553*58b9f456SAndroid Build Coastguard Worker    }
554*58b9f456SAndroid Build Coastguard Worker
555*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
556*58b9f456SAndroid Build Coastguard Worker    const char_type* narrow(const char_type* __low, const char_type* __high, char __dfault, char* __to) const
557*58b9f456SAndroid Build Coastguard Worker    {
558*58b9f456SAndroid Build Coastguard Worker        return do_narrow(__low, __high, __dfault, __to);
559*58b9f456SAndroid Build Coastguard Worker    }
560*58b9f456SAndroid Build Coastguard Worker
561*58b9f456SAndroid Build Coastguard Worker    static locale::id id;
562*58b9f456SAndroid Build Coastguard Worker
563*58b9f456SAndroid Build Coastguard Workerprotected:
564*58b9f456SAndroid Build Coastguard Worker    ~ctype();
565*58b9f456SAndroid Build Coastguard Worker    virtual bool do_is(mask __m, char_type __c) const;
566*58b9f456SAndroid Build Coastguard Worker    virtual const char_type* do_is(const char_type* __low, const char_type* __high, mask* __vec) const;
567*58b9f456SAndroid Build Coastguard Worker    virtual const char_type* do_scan_is(mask __m, const char_type* __low, const char_type* __high) const;
568*58b9f456SAndroid Build Coastguard Worker    virtual const char_type* do_scan_not(mask __m, const char_type* __low, const char_type* __high) const;
569*58b9f456SAndroid Build Coastguard Worker    virtual char_type do_toupper(char_type) const;
570*58b9f456SAndroid Build Coastguard Worker    virtual const char_type* do_toupper(char_type* __low, const char_type* __high) const;
571*58b9f456SAndroid Build Coastguard Worker    virtual char_type do_tolower(char_type) const;
572*58b9f456SAndroid Build Coastguard Worker    virtual const char_type* do_tolower(char_type* __low, const char_type* __high) const;
573*58b9f456SAndroid Build Coastguard Worker    virtual char_type do_widen(char) const;
574*58b9f456SAndroid Build Coastguard Worker    virtual const char* do_widen(const char* __low, const char* __high, char_type* __dest) const;
575*58b9f456SAndroid Build Coastguard Worker    virtual char do_narrow(char_type, char __dfault) const;
576*58b9f456SAndroid Build Coastguard Worker    virtual const char_type* do_narrow(const char_type* __low, const char_type* __high, char __dfault, char* __dest) const;
577*58b9f456SAndroid Build Coastguard Worker};
578*58b9f456SAndroid Build Coastguard Worker
579*58b9f456SAndroid Build Coastguard Workertemplate <>
580*58b9f456SAndroid Build Coastguard Workerclass _LIBCPP_TYPE_VIS ctype<char>
581*58b9f456SAndroid Build Coastguard Worker    : public locale::facet, public ctype_base
582*58b9f456SAndroid Build Coastguard Worker{
583*58b9f456SAndroid Build Coastguard Worker    const mask* __tab_;
584*58b9f456SAndroid Build Coastguard Worker    bool        __del_;
585*58b9f456SAndroid Build Coastguard Workerpublic:
586*58b9f456SAndroid Build Coastguard Worker    typedef char char_type;
587*58b9f456SAndroid Build Coastguard Worker
588*58b9f456SAndroid Build Coastguard Worker    explicit ctype(const mask* __tab = 0, bool __del = false, size_t __refs = 0);
589*58b9f456SAndroid Build Coastguard Worker
590*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
591*58b9f456SAndroid Build Coastguard Worker    bool is(mask __m, char_type __c) const
592*58b9f456SAndroid Build Coastguard Worker    {
593*58b9f456SAndroid Build Coastguard Worker        return isascii(__c) ? (__tab_[static_cast<int>(__c)] & __m) !=0 : false;
594*58b9f456SAndroid Build Coastguard Worker    }
595*58b9f456SAndroid Build Coastguard Worker
596*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
597*58b9f456SAndroid Build Coastguard Worker    const char_type* is(const char_type* __low, const char_type* __high, mask* __vec) const
598*58b9f456SAndroid Build Coastguard Worker    {
599*58b9f456SAndroid Build Coastguard Worker        for (; __low != __high; ++__low, ++__vec)
600*58b9f456SAndroid Build Coastguard Worker            *__vec = isascii(*__low) ? __tab_[static_cast<int>(*__low)] : 0;
601*58b9f456SAndroid Build Coastguard Worker        return __low;
602*58b9f456SAndroid Build Coastguard Worker    }
603*58b9f456SAndroid Build Coastguard Worker
604*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
605*58b9f456SAndroid Build Coastguard Worker    const char_type* scan_is (mask __m, const char_type* __low, const char_type* __high) const
606*58b9f456SAndroid Build Coastguard Worker    {
607*58b9f456SAndroid Build Coastguard Worker        for (; __low != __high; ++__low)
608*58b9f456SAndroid Build Coastguard Worker            if (isascii(*__low) && (__tab_[static_cast<int>(*__low)] & __m))
609*58b9f456SAndroid Build Coastguard Worker                break;
610*58b9f456SAndroid Build Coastguard Worker        return __low;
611*58b9f456SAndroid Build Coastguard Worker    }
612*58b9f456SAndroid Build Coastguard Worker
613*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
614*58b9f456SAndroid Build Coastguard Worker    const char_type* scan_not(mask __m, const char_type* __low, const char_type* __high) const
615*58b9f456SAndroid Build Coastguard Worker    {
616*58b9f456SAndroid Build Coastguard Worker        for (; __low != __high; ++__low)
617*58b9f456SAndroid Build Coastguard Worker            if (!(isascii(*__low) && (__tab_[static_cast<int>(*__low)] & __m)))
618*58b9f456SAndroid Build Coastguard Worker                break;
619*58b9f456SAndroid Build Coastguard Worker        return __low;
620*58b9f456SAndroid Build Coastguard Worker    }
621*58b9f456SAndroid Build Coastguard Worker
622*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
623*58b9f456SAndroid Build Coastguard Worker    char_type toupper(char_type __c) const
624*58b9f456SAndroid Build Coastguard Worker    {
625*58b9f456SAndroid Build Coastguard Worker        return do_toupper(__c);
626*58b9f456SAndroid Build Coastguard Worker    }
627*58b9f456SAndroid Build Coastguard Worker
628*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
629*58b9f456SAndroid Build Coastguard Worker    const char_type* toupper(char_type* __low, const char_type* __high) const
630*58b9f456SAndroid Build Coastguard Worker    {
631*58b9f456SAndroid Build Coastguard Worker        return do_toupper(__low, __high);
632*58b9f456SAndroid Build Coastguard Worker    }
633*58b9f456SAndroid Build Coastguard Worker
634*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
635*58b9f456SAndroid Build Coastguard Worker    char_type tolower(char_type __c) const
636*58b9f456SAndroid Build Coastguard Worker    {
637*58b9f456SAndroid Build Coastguard Worker        return do_tolower(__c);
638*58b9f456SAndroid Build Coastguard Worker    }
639*58b9f456SAndroid Build Coastguard Worker
640*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
641*58b9f456SAndroid Build Coastguard Worker    const char_type* tolower(char_type* __low, const char_type* __high) const
642*58b9f456SAndroid Build Coastguard Worker    {
643*58b9f456SAndroid Build Coastguard Worker        return do_tolower(__low, __high);
644*58b9f456SAndroid Build Coastguard Worker    }
645*58b9f456SAndroid Build Coastguard Worker
646*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
647*58b9f456SAndroid Build Coastguard Worker    char_type widen(char __c) const
648*58b9f456SAndroid Build Coastguard Worker    {
649*58b9f456SAndroid Build Coastguard Worker        return do_widen(__c);
650*58b9f456SAndroid Build Coastguard Worker    }
651*58b9f456SAndroid Build Coastguard Worker
652*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
653*58b9f456SAndroid Build Coastguard Worker    const char* widen(const char* __low, const char* __high, char_type* __to) const
654*58b9f456SAndroid Build Coastguard Worker    {
655*58b9f456SAndroid Build Coastguard Worker        return do_widen(__low, __high, __to);
656*58b9f456SAndroid Build Coastguard Worker    }
657*58b9f456SAndroid Build Coastguard Worker
658*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
659*58b9f456SAndroid Build Coastguard Worker    char narrow(char_type __c, char __dfault) const
660*58b9f456SAndroid Build Coastguard Worker    {
661*58b9f456SAndroid Build Coastguard Worker        return do_narrow(__c, __dfault);
662*58b9f456SAndroid Build Coastguard Worker    }
663*58b9f456SAndroid Build Coastguard Worker
664*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
665*58b9f456SAndroid Build Coastguard Worker    const char* narrow(const char_type* __low, const char_type* __high, char __dfault, char* __to) const
666*58b9f456SAndroid Build Coastguard Worker    {
667*58b9f456SAndroid Build Coastguard Worker        return do_narrow(__low, __high, __dfault, __to);
668*58b9f456SAndroid Build Coastguard Worker    }
669*58b9f456SAndroid Build Coastguard Worker
670*58b9f456SAndroid Build Coastguard Worker    static locale::id id;
671*58b9f456SAndroid Build Coastguard Worker
672*58b9f456SAndroid Build Coastguard Worker#ifdef _CACHED_RUNES
673*58b9f456SAndroid Build Coastguard Worker    static const size_t table_size = _CACHED_RUNES;
674*58b9f456SAndroid Build Coastguard Worker#else
675*58b9f456SAndroid Build Coastguard Worker    static const size_t table_size = 256;  // FIXME: Don't hardcode this.
676*58b9f456SAndroid Build Coastguard Worker#endif
677*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY const mask* table() const  _NOEXCEPT {return __tab_;}
678*58b9f456SAndroid Build Coastguard Worker    static const mask* classic_table()  _NOEXCEPT;
679*58b9f456SAndroid Build Coastguard Worker#if defined(__GLIBC__) || defined(__EMSCRIPTEN__)
680*58b9f456SAndroid Build Coastguard Worker    static const int* __classic_upper_table() _NOEXCEPT;
681*58b9f456SAndroid Build Coastguard Worker    static const int* __classic_lower_table() _NOEXCEPT;
682*58b9f456SAndroid Build Coastguard Worker#endif
683*58b9f456SAndroid Build Coastguard Worker#if defined(__NetBSD__)
684*58b9f456SAndroid Build Coastguard Worker    static const short* __classic_upper_table() _NOEXCEPT;
685*58b9f456SAndroid Build Coastguard Worker    static const short* __classic_lower_table() _NOEXCEPT;
686*58b9f456SAndroid Build Coastguard Worker#endif
687*58b9f456SAndroid Build Coastguard Worker
688*58b9f456SAndroid Build Coastguard Workerprotected:
689*58b9f456SAndroid Build Coastguard Worker    ~ctype();
690*58b9f456SAndroid Build Coastguard Worker    virtual char_type do_toupper(char_type __c) const;
691*58b9f456SAndroid Build Coastguard Worker    virtual const char_type* do_toupper(char_type* __low, const char_type* __high) const;
692*58b9f456SAndroid Build Coastguard Worker    virtual char_type do_tolower(char_type __c) const;
693*58b9f456SAndroid Build Coastguard Worker    virtual const char_type* do_tolower(char_type* __low, const char_type* __high) const;
694*58b9f456SAndroid Build Coastguard Worker    virtual char_type do_widen(char __c) const;
695*58b9f456SAndroid Build Coastguard Worker    virtual const char* do_widen(const char* __low, const char* __high, char_type* __to) const;
696*58b9f456SAndroid Build Coastguard Worker    virtual char do_narrow(char_type __c, char __dfault) const;
697*58b9f456SAndroid Build Coastguard Worker    virtual const char* do_narrow(const char_type* __low, const char_type* __high, char __dfault, char* __to) const;
698*58b9f456SAndroid Build Coastguard Worker};
699*58b9f456SAndroid Build Coastguard Worker
700*58b9f456SAndroid Build Coastguard Worker// template <class CharT> class ctype_byname;
701*58b9f456SAndroid Build Coastguard Worker
702*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT> class _LIBCPP_TEMPLATE_VIS ctype_byname;
703*58b9f456SAndroid Build Coastguard Worker
704*58b9f456SAndroid Build Coastguard Workertemplate <>
705*58b9f456SAndroid Build Coastguard Workerclass _LIBCPP_TYPE_VIS ctype_byname<char>
706*58b9f456SAndroid Build Coastguard Worker    : public ctype<char>
707*58b9f456SAndroid Build Coastguard Worker{
708*58b9f456SAndroid Build Coastguard Worker    locale_t __l;
709*58b9f456SAndroid Build Coastguard Worker
710*58b9f456SAndroid Build Coastguard Workerpublic:
711*58b9f456SAndroid Build Coastguard Worker    explicit ctype_byname(const char*, size_t = 0);
712*58b9f456SAndroid Build Coastguard Worker    explicit ctype_byname(const string&, size_t = 0);
713*58b9f456SAndroid Build Coastguard Worker
714*58b9f456SAndroid Build Coastguard Workerprotected:
715*58b9f456SAndroid Build Coastguard Worker    ~ctype_byname();
716*58b9f456SAndroid Build Coastguard Worker    virtual char_type do_toupper(char_type) const;
717*58b9f456SAndroid Build Coastguard Worker    virtual const char_type* do_toupper(char_type* __low, const char_type* __high) const;
718*58b9f456SAndroid Build Coastguard Worker    virtual char_type do_tolower(char_type) const;
719*58b9f456SAndroid Build Coastguard Worker    virtual const char_type* do_tolower(char_type* __low, const char_type* __high) const;
720*58b9f456SAndroid Build Coastguard Worker};
721*58b9f456SAndroid Build Coastguard Worker
722*58b9f456SAndroid Build Coastguard Workertemplate <>
723*58b9f456SAndroid Build Coastguard Workerclass _LIBCPP_TYPE_VIS ctype_byname<wchar_t>
724*58b9f456SAndroid Build Coastguard Worker    : public ctype<wchar_t>
725*58b9f456SAndroid Build Coastguard Worker{
726*58b9f456SAndroid Build Coastguard Worker    locale_t __l;
727*58b9f456SAndroid Build Coastguard Worker
728*58b9f456SAndroid Build Coastguard Workerpublic:
729*58b9f456SAndroid Build Coastguard Worker    explicit ctype_byname(const char*, size_t = 0);
730*58b9f456SAndroid Build Coastguard Worker    explicit ctype_byname(const string&, size_t = 0);
731*58b9f456SAndroid Build Coastguard Worker
732*58b9f456SAndroid Build Coastguard Workerprotected:
733*58b9f456SAndroid Build Coastguard Worker    ~ctype_byname();
734*58b9f456SAndroid Build Coastguard Worker    virtual bool do_is(mask __m, char_type __c) const;
735*58b9f456SAndroid Build Coastguard Worker    virtual const char_type* do_is(const char_type* __low, const char_type* __high, mask* __vec) const;
736*58b9f456SAndroid Build Coastguard Worker    virtual const char_type* do_scan_is(mask __m, const char_type* __low, const char_type* __high) const;
737*58b9f456SAndroid Build Coastguard Worker    virtual const char_type* do_scan_not(mask __m, const char_type* __low, const char_type* __high) const;
738*58b9f456SAndroid Build Coastguard Worker    virtual char_type do_toupper(char_type) const;
739*58b9f456SAndroid Build Coastguard Worker    virtual const char_type* do_toupper(char_type* __low, const char_type* __high) const;
740*58b9f456SAndroid Build Coastguard Worker    virtual char_type do_tolower(char_type) const;
741*58b9f456SAndroid Build Coastguard Worker    virtual const char_type* do_tolower(char_type* __low, const char_type* __high) const;
742*58b9f456SAndroid Build Coastguard Worker    virtual char_type do_widen(char) const;
743*58b9f456SAndroid Build Coastguard Worker    virtual const char* do_widen(const char* __low, const char* __high, char_type* __dest) const;
744*58b9f456SAndroid Build Coastguard Worker    virtual char do_narrow(char_type, char __dfault) const;
745*58b9f456SAndroid Build Coastguard Worker    virtual const char_type* do_narrow(const char_type* __low, const char_type* __high, char __dfault, char* __dest) const;
746*58b9f456SAndroid Build Coastguard Worker};
747*58b9f456SAndroid Build Coastguard Worker
748*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT>
749*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
750*58b9f456SAndroid Build Coastguard Workerbool
751*58b9f456SAndroid Build Coastguard Workerisspace(_CharT __c, const locale& __loc)
752*58b9f456SAndroid Build Coastguard Worker{
753*58b9f456SAndroid Build Coastguard Worker    return use_facet<ctype<_CharT> >(__loc).is(ctype_base::space, __c);
754*58b9f456SAndroid Build Coastguard Worker}
755*58b9f456SAndroid Build Coastguard Worker
756*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT>
757*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
758*58b9f456SAndroid Build Coastguard Workerbool
759*58b9f456SAndroid Build Coastguard Workerisprint(_CharT __c, const locale& __loc)
760*58b9f456SAndroid Build Coastguard Worker{
761*58b9f456SAndroid Build Coastguard Worker    return use_facet<ctype<_CharT> >(__loc).is(ctype_base::print, __c);
762*58b9f456SAndroid Build Coastguard Worker}
763*58b9f456SAndroid Build Coastguard Worker
764*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT>
765*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
766*58b9f456SAndroid Build Coastguard Workerbool
767*58b9f456SAndroid Build Coastguard Workeriscntrl(_CharT __c, const locale& __loc)
768*58b9f456SAndroid Build Coastguard Worker{
769*58b9f456SAndroid Build Coastguard Worker    return use_facet<ctype<_CharT> >(__loc).is(ctype_base::cntrl, __c);
770*58b9f456SAndroid Build Coastguard Worker}
771*58b9f456SAndroid Build Coastguard Worker
772*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT>
773*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
774*58b9f456SAndroid Build Coastguard Workerbool
775*58b9f456SAndroid Build Coastguard Workerisupper(_CharT __c, const locale& __loc)
776*58b9f456SAndroid Build Coastguard Worker{
777*58b9f456SAndroid Build Coastguard Worker    return use_facet<ctype<_CharT> >(__loc).is(ctype_base::upper, __c);
778*58b9f456SAndroid Build Coastguard Worker}
779*58b9f456SAndroid Build Coastguard Worker
780*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT>
781*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
782*58b9f456SAndroid Build Coastguard Workerbool
783*58b9f456SAndroid Build Coastguard Workerislower(_CharT __c, const locale& __loc)
784*58b9f456SAndroid Build Coastguard Worker{
785*58b9f456SAndroid Build Coastguard Worker    return use_facet<ctype<_CharT> >(__loc).is(ctype_base::lower, __c);
786*58b9f456SAndroid Build Coastguard Worker}
787*58b9f456SAndroid Build Coastguard Worker
788*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT>
789*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
790*58b9f456SAndroid Build Coastguard Workerbool
791*58b9f456SAndroid Build Coastguard Workerisalpha(_CharT __c, const locale& __loc)
792*58b9f456SAndroid Build Coastguard Worker{
793*58b9f456SAndroid Build Coastguard Worker    return use_facet<ctype<_CharT> >(__loc).is(ctype_base::alpha, __c);
794*58b9f456SAndroid Build Coastguard Worker}
795*58b9f456SAndroid Build Coastguard Worker
796*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT>
797*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
798*58b9f456SAndroid Build Coastguard Workerbool
799*58b9f456SAndroid Build Coastguard Workerisdigit(_CharT __c, const locale& __loc)
800*58b9f456SAndroid Build Coastguard Worker{
801*58b9f456SAndroid Build Coastguard Worker    return use_facet<ctype<_CharT> >(__loc).is(ctype_base::digit, __c);
802*58b9f456SAndroid Build Coastguard Worker}
803*58b9f456SAndroid Build Coastguard Worker
804*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT>
805*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
806*58b9f456SAndroid Build Coastguard Workerbool
807*58b9f456SAndroid Build Coastguard Workerispunct(_CharT __c, const locale& __loc)
808*58b9f456SAndroid Build Coastguard Worker{
809*58b9f456SAndroid Build Coastguard Worker    return use_facet<ctype<_CharT> >(__loc).is(ctype_base::punct, __c);
810*58b9f456SAndroid Build Coastguard Worker}
811*58b9f456SAndroid Build Coastguard Worker
812*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT>
813*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
814*58b9f456SAndroid Build Coastguard Workerbool
815*58b9f456SAndroid Build Coastguard Workerisxdigit(_CharT __c, const locale& __loc)
816*58b9f456SAndroid Build Coastguard Worker{
817*58b9f456SAndroid Build Coastguard Worker    return use_facet<ctype<_CharT> >(__loc).is(ctype_base::xdigit, __c);
818*58b9f456SAndroid Build Coastguard Worker}
819*58b9f456SAndroid Build Coastguard Worker
820*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT>
821*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
822*58b9f456SAndroid Build Coastguard Workerbool
823*58b9f456SAndroid Build Coastguard Workerisalnum(_CharT __c, const locale& __loc)
824*58b9f456SAndroid Build Coastguard Worker{
825*58b9f456SAndroid Build Coastguard Worker    return use_facet<ctype<_CharT> >(__loc).is(ctype_base::alnum, __c);
826*58b9f456SAndroid Build Coastguard Worker}
827*58b9f456SAndroid Build Coastguard Worker
828*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT>
829*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
830*58b9f456SAndroid Build Coastguard Workerbool
831*58b9f456SAndroid Build Coastguard Workerisgraph(_CharT __c, const locale& __loc)
832*58b9f456SAndroid Build Coastguard Worker{
833*58b9f456SAndroid Build Coastguard Worker    return use_facet<ctype<_CharT> >(__loc).is(ctype_base::graph, __c);
834*58b9f456SAndroid Build Coastguard Worker}
835*58b9f456SAndroid Build Coastguard Worker
836*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT>
837*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
838*58b9f456SAndroid Build Coastguard Worker_CharT
839*58b9f456SAndroid Build Coastguard Workertoupper(_CharT __c, const locale& __loc)
840*58b9f456SAndroid Build Coastguard Worker{
841*58b9f456SAndroid Build Coastguard Worker    return use_facet<ctype<_CharT> >(__loc).toupper(__c);
842*58b9f456SAndroid Build Coastguard Worker}
843*58b9f456SAndroid Build Coastguard Worker
844*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT>
845*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
846*58b9f456SAndroid Build Coastguard Worker_CharT
847*58b9f456SAndroid Build Coastguard Workertolower(_CharT __c, const locale& __loc)
848*58b9f456SAndroid Build Coastguard Worker{
849*58b9f456SAndroid Build Coastguard Worker    return use_facet<ctype<_CharT> >(__loc).tolower(__c);
850*58b9f456SAndroid Build Coastguard Worker}
851*58b9f456SAndroid Build Coastguard Worker
852*58b9f456SAndroid Build Coastguard Worker// codecvt_base
853*58b9f456SAndroid Build Coastguard Worker
854*58b9f456SAndroid Build Coastguard Workerclass _LIBCPP_TYPE_VIS codecvt_base
855*58b9f456SAndroid Build Coastguard Worker{
856*58b9f456SAndroid Build Coastguard Workerpublic:
857*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY codecvt_base() {}
858*58b9f456SAndroid Build Coastguard Worker    enum result {ok, partial, error, noconv};
859*58b9f456SAndroid Build Coastguard Worker};
860*58b9f456SAndroid Build Coastguard Worker
861*58b9f456SAndroid Build Coastguard Worker// template <class internT, class externT, class stateT> class codecvt;
862*58b9f456SAndroid Build Coastguard Worker
863*58b9f456SAndroid Build Coastguard Workertemplate <class _InternT, class _ExternT, class _StateT> class _LIBCPP_TEMPLATE_VIS codecvt;
864*58b9f456SAndroid Build Coastguard Worker
865*58b9f456SAndroid Build Coastguard Worker// template <> class codecvt<char, char, mbstate_t>
866*58b9f456SAndroid Build Coastguard Worker
867*58b9f456SAndroid Build Coastguard Workertemplate <>
868*58b9f456SAndroid Build Coastguard Workerclass _LIBCPP_TYPE_VIS codecvt<char, char, mbstate_t>
869*58b9f456SAndroid Build Coastguard Worker    : public locale::facet,
870*58b9f456SAndroid Build Coastguard Worker      public codecvt_base
871*58b9f456SAndroid Build Coastguard Worker{
872*58b9f456SAndroid Build Coastguard Workerpublic:
873*58b9f456SAndroid Build Coastguard Worker    typedef char      intern_type;
874*58b9f456SAndroid Build Coastguard Worker    typedef char      extern_type;
875*58b9f456SAndroid Build Coastguard Worker    typedef mbstate_t state_type;
876*58b9f456SAndroid Build Coastguard Worker
877*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
878*58b9f456SAndroid Build Coastguard Worker    explicit codecvt(size_t __refs = 0)
879*58b9f456SAndroid Build Coastguard Worker        : locale::facet(__refs) {}
880*58b9f456SAndroid Build Coastguard Worker
881*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
882*58b9f456SAndroid Build Coastguard Worker    result out(state_type& __st,
883*58b9f456SAndroid Build Coastguard Worker               const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
884*58b9f456SAndroid Build Coastguard Worker               extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const
885*58b9f456SAndroid Build Coastguard Worker    {
886*58b9f456SAndroid Build Coastguard Worker        return do_out(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
887*58b9f456SAndroid Build Coastguard Worker    }
888*58b9f456SAndroid Build Coastguard Worker
889*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
890*58b9f456SAndroid Build Coastguard Worker    result unshift(state_type& __st,
891*58b9f456SAndroid Build Coastguard Worker                   extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const
892*58b9f456SAndroid Build Coastguard Worker    {
893*58b9f456SAndroid Build Coastguard Worker        return do_unshift(__st, __to, __to_end, __to_nxt);
894*58b9f456SAndroid Build Coastguard Worker    }
895*58b9f456SAndroid Build Coastguard Worker
896*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
897*58b9f456SAndroid Build Coastguard Worker    result in(state_type& __st,
898*58b9f456SAndroid Build Coastguard Worker              const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
899*58b9f456SAndroid Build Coastguard Worker              intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const
900*58b9f456SAndroid Build Coastguard Worker    {
901*58b9f456SAndroid Build Coastguard Worker        return do_in(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
902*58b9f456SAndroid Build Coastguard Worker    }
903*58b9f456SAndroid Build Coastguard Worker
904*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
905*58b9f456SAndroid Build Coastguard Worker    int encoding() const  _NOEXCEPT
906*58b9f456SAndroid Build Coastguard Worker    {
907*58b9f456SAndroid Build Coastguard Worker        return do_encoding();
908*58b9f456SAndroid Build Coastguard Worker    }
909*58b9f456SAndroid Build Coastguard Worker
910*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
911*58b9f456SAndroid Build Coastguard Worker    bool always_noconv() const  _NOEXCEPT
912*58b9f456SAndroid Build Coastguard Worker    {
913*58b9f456SAndroid Build Coastguard Worker        return do_always_noconv();
914*58b9f456SAndroid Build Coastguard Worker    }
915*58b9f456SAndroid Build Coastguard Worker
916*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
917*58b9f456SAndroid Build Coastguard Worker    int length(state_type& __st, const extern_type* __frm, const extern_type* __end, size_t __mx) const
918*58b9f456SAndroid Build Coastguard Worker    {
919*58b9f456SAndroid Build Coastguard Worker        return do_length(__st, __frm, __end, __mx);
920*58b9f456SAndroid Build Coastguard Worker    }
921*58b9f456SAndroid Build Coastguard Worker
922*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
923*58b9f456SAndroid Build Coastguard Worker    int max_length() const  _NOEXCEPT
924*58b9f456SAndroid Build Coastguard Worker    {
925*58b9f456SAndroid Build Coastguard Worker        return do_max_length();
926*58b9f456SAndroid Build Coastguard Worker    }
927*58b9f456SAndroid Build Coastguard Worker
928*58b9f456SAndroid Build Coastguard Worker    static locale::id id;
929*58b9f456SAndroid Build Coastguard Worker
930*58b9f456SAndroid Build Coastguard Workerprotected:
931*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
932*58b9f456SAndroid Build Coastguard Worker    explicit codecvt(const char*, size_t __refs = 0)
933*58b9f456SAndroid Build Coastguard Worker        : locale::facet(__refs) {}
934*58b9f456SAndroid Build Coastguard Worker
935*58b9f456SAndroid Build Coastguard Worker    ~codecvt();
936*58b9f456SAndroid Build Coastguard Worker
937*58b9f456SAndroid Build Coastguard Worker    virtual result do_out(state_type& __st,
938*58b9f456SAndroid Build Coastguard Worker                          const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
939*58b9f456SAndroid Build Coastguard Worker                          extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
940*58b9f456SAndroid Build Coastguard Worker    virtual result do_in(state_type& __st,
941*58b9f456SAndroid Build Coastguard Worker                         const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
942*58b9f456SAndroid Build Coastguard Worker                         intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
943*58b9f456SAndroid Build Coastguard Worker    virtual result do_unshift(state_type& __st,
944*58b9f456SAndroid Build Coastguard Worker                              extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
945*58b9f456SAndroid Build Coastguard Worker    virtual int do_encoding() const  _NOEXCEPT;
946*58b9f456SAndroid Build Coastguard Worker    virtual bool do_always_noconv() const  _NOEXCEPT;
947*58b9f456SAndroid Build Coastguard Worker    virtual int do_length(state_type& __st, const extern_type* __frm, const extern_type* __end, size_t __mx) const;
948*58b9f456SAndroid Build Coastguard Worker    virtual int do_max_length() const  _NOEXCEPT;
949*58b9f456SAndroid Build Coastguard Worker};
950*58b9f456SAndroid Build Coastguard Worker
951*58b9f456SAndroid Build Coastguard Worker// template <> class codecvt<wchar_t, char, mbstate_t>
952*58b9f456SAndroid Build Coastguard Worker
953*58b9f456SAndroid Build Coastguard Workertemplate <>
954*58b9f456SAndroid Build Coastguard Workerclass _LIBCPP_TYPE_VIS codecvt<wchar_t, char, mbstate_t>
955*58b9f456SAndroid Build Coastguard Worker    : public locale::facet,
956*58b9f456SAndroid Build Coastguard Worker      public codecvt_base
957*58b9f456SAndroid Build Coastguard Worker{
958*58b9f456SAndroid Build Coastguard Worker    locale_t __l;
959*58b9f456SAndroid Build Coastguard Workerpublic:
960*58b9f456SAndroid Build Coastguard Worker    typedef wchar_t   intern_type;
961*58b9f456SAndroid Build Coastguard Worker    typedef char      extern_type;
962*58b9f456SAndroid Build Coastguard Worker    typedef mbstate_t state_type;
963*58b9f456SAndroid Build Coastguard Worker
964*58b9f456SAndroid Build Coastguard Worker    explicit codecvt(size_t __refs = 0);
965*58b9f456SAndroid Build Coastguard Worker
966*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
967*58b9f456SAndroid Build Coastguard Worker    result out(state_type& __st,
968*58b9f456SAndroid Build Coastguard Worker               const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
969*58b9f456SAndroid Build Coastguard Worker               extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const
970*58b9f456SAndroid Build Coastguard Worker    {
971*58b9f456SAndroid Build Coastguard Worker        return do_out(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
972*58b9f456SAndroid Build Coastguard Worker    }
973*58b9f456SAndroid Build Coastguard Worker
974*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
975*58b9f456SAndroid Build Coastguard Worker    result unshift(state_type& __st,
976*58b9f456SAndroid Build Coastguard Worker                   extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const
977*58b9f456SAndroid Build Coastguard Worker    {
978*58b9f456SAndroid Build Coastguard Worker        return do_unshift(__st, __to, __to_end, __to_nxt);
979*58b9f456SAndroid Build Coastguard Worker    }
980*58b9f456SAndroid Build Coastguard Worker
981*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
982*58b9f456SAndroid Build Coastguard Worker    result in(state_type& __st,
983*58b9f456SAndroid Build Coastguard Worker              const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
984*58b9f456SAndroid Build Coastguard Worker              intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const
985*58b9f456SAndroid Build Coastguard Worker    {
986*58b9f456SAndroid Build Coastguard Worker        return do_in(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
987*58b9f456SAndroid Build Coastguard Worker    }
988*58b9f456SAndroid Build Coastguard Worker
989*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
990*58b9f456SAndroid Build Coastguard Worker    int encoding() const  _NOEXCEPT
991*58b9f456SAndroid Build Coastguard Worker    {
992*58b9f456SAndroid Build Coastguard Worker        return do_encoding();
993*58b9f456SAndroid Build Coastguard Worker    }
994*58b9f456SAndroid Build Coastguard Worker
995*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
996*58b9f456SAndroid Build Coastguard Worker    bool always_noconv() const  _NOEXCEPT
997*58b9f456SAndroid Build Coastguard Worker    {
998*58b9f456SAndroid Build Coastguard Worker        return do_always_noconv();
999*58b9f456SAndroid Build Coastguard Worker    }
1000*58b9f456SAndroid Build Coastguard Worker
1001*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1002*58b9f456SAndroid Build Coastguard Worker    int length(state_type& __st, const extern_type* __frm, const extern_type* __end, size_t __mx) const
1003*58b9f456SAndroid Build Coastguard Worker    {
1004*58b9f456SAndroid Build Coastguard Worker        return do_length(__st, __frm, __end, __mx);
1005*58b9f456SAndroid Build Coastguard Worker    }
1006*58b9f456SAndroid Build Coastguard Worker
1007*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1008*58b9f456SAndroid Build Coastguard Worker    int max_length() const  _NOEXCEPT
1009*58b9f456SAndroid Build Coastguard Worker    {
1010*58b9f456SAndroid Build Coastguard Worker        return do_max_length();
1011*58b9f456SAndroid Build Coastguard Worker    }
1012*58b9f456SAndroid Build Coastguard Worker
1013*58b9f456SAndroid Build Coastguard Worker    static locale::id id;
1014*58b9f456SAndroid Build Coastguard Worker
1015*58b9f456SAndroid Build Coastguard Workerprotected:
1016*58b9f456SAndroid Build Coastguard Worker    explicit codecvt(const char*, size_t __refs = 0);
1017*58b9f456SAndroid Build Coastguard Worker
1018*58b9f456SAndroid Build Coastguard Worker    ~codecvt();
1019*58b9f456SAndroid Build Coastguard Worker
1020*58b9f456SAndroid Build Coastguard Worker    virtual result do_out(state_type& __st,
1021*58b9f456SAndroid Build Coastguard Worker                          const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
1022*58b9f456SAndroid Build Coastguard Worker                          extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
1023*58b9f456SAndroid Build Coastguard Worker    virtual result do_in(state_type& __st,
1024*58b9f456SAndroid Build Coastguard Worker                         const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
1025*58b9f456SAndroid Build Coastguard Worker                         intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
1026*58b9f456SAndroid Build Coastguard Worker    virtual result do_unshift(state_type& __st,
1027*58b9f456SAndroid Build Coastguard Worker                              extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
1028*58b9f456SAndroid Build Coastguard Worker    virtual int do_encoding() const  _NOEXCEPT;
1029*58b9f456SAndroid Build Coastguard Worker    virtual bool do_always_noconv() const  _NOEXCEPT;
1030*58b9f456SAndroid Build Coastguard Worker    virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const;
1031*58b9f456SAndroid Build Coastguard Worker    virtual int do_max_length() const  _NOEXCEPT;
1032*58b9f456SAndroid Build Coastguard Worker};
1033*58b9f456SAndroid Build Coastguard Worker
1034*58b9f456SAndroid Build Coastguard Worker// template <> class codecvt<char16_t, char, mbstate_t>
1035*58b9f456SAndroid Build Coastguard Worker
1036*58b9f456SAndroid Build Coastguard Workertemplate <>
1037*58b9f456SAndroid Build Coastguard Workerclass _LIBCPP_TYPE_VIS codecvt<char16_t, char, mbstate_t>
1038*58b9f456SAndroid Build Coastguard Worker    : public locale::facet,
1039*58b9f456SAndroid Build Coastguard Worker      public codecvt_base
1040*58b9f456SAndroid Build Coastguard Worker{
1041*58b9f456SAndroid Build Coastguard Workerpublic:
1042*58b9f456SAndroid Build Coastguard Worker    typedef char16_t  intern_type;
1043*58b9f456SAndroid Build Coastguard Worker    typedef char      extern_type;
1044*58b9f456SAndroid Build Coastguard Worker    typedef mbstate_t state_type;
1045*58b9f456SAndroid Build Coastguard Worker
1046*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1047*58b9f456SAndroid Build Coastguard Worker    explicit codecvt(size_t __refs = 0)
1048*58b9f456SAndroid Build Coastguard Worker        : locale::facet(__refs) {}
1049*58b9f456SAndroid Build Coastguard Worker
1050*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1051*58b9f456SAndroid Build Coastguard Worker    result out(state_type& __st,
1052*58b9f456SAndroid Build Coastguard Worker               const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
1053*58b9f456SAndroid Build Coastguard Worker               extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const
1054*58b9f456SAndroid Build Coastguard Worker    {
1055*58b9f456SAndroid Build Coastguard Worker        return do_out(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
1056*58b9f456SAndroid Build Coastguard Worker    }
1057*58b9f456SAndroid Build Coastguard Worker
1058*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1059*58b9f456SAndroid Build Coastguard Worker    result unshift(state_type& __st,
1060*58b9f456SAndroid Build Coastguard Worker                   extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const
1061*58b9f456SAndroid Build Coastguard Worker    {
1062*58b9f456SAndroid Build Coastguard Worker        return do_unshift(__st, __to, __to_end, __to_nxt);
1063*58b9f456SAndroid Build Coastguard Worker    }
1064*58b9f456SAndroid Build Coastguard Worker
1065*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1066*58b9f456SAndroid Build Coastguard Worker    result in(state_type& __st,
1067*58b9f456SAndroid Build Coastguard Worker              const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
1068*58b9f456SAndroid Build Coastguard Worker              intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const
1069*58b9f456SAndroid Build Coastguard Worker    {
1070*58b9f456SAndroid Build Coastguard Worker        return do_in(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
1071*58b9f456SAndroid Build Coastguard Worker    }
1072*58b9f456SAndroid Build Coastguard Worker
1073*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1074*58b9f456SAndroid Build Coastguard Worker    int encoding() const  _NOEXCEPT
1075*58b9f456SAndroid Build Coastguard Worker    {
1076*58b9f456SAndroid Build Coastguard Worker        return do_encoding();
1077*58b9f456SAndroid Build Coastguard Worker    }
1078*58b9f456SAndroid Build Coastguard Worker
1079*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1080*58b9f456SAndroid Build Coastguard Worker    bool always_noconv() const  _NOEXCEPT
1081*58b9f456SAndroid Build Coastguard Worker    {
1082*58b9f456SAndroid Build Coastguard Worker        return do_always_noconv();
1083*58b9f456SAndroid Build Coastguard Worker    }
1084*58b9f456SAndroid Build Coastguard Worker
1085*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1086*58b9f456SAndroid Build Coastguard Worker    int length(state_type& __st, const extern_type* __frm, const extern_type* __end, size_t __mx) const
1087*58b9f456SAndroid Build Coastguard Worker    {
1088*58b9f456SAndroid Build Coastguard Worker        return do_length(__st, __frm, __end, __mx);
1089*58b9f456SAndroid Build Coastguard Worker    }
1090*58b9f456SAndroid Build Coastguard Worker
1091*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1092*58b9f456SAndroid Build Coastguard Worker    int max_length() const  _NOEXCEPT
1093*58b9f456SAndroid Build Coastguard Worker    {
1094*58b9f456SAndroid Build Coastguard Worker        return do_max_length();
1095*58b9f456SAndroid Build Coastguard Worker    }
1096*58b9f456SAndroid Build Coastguard Worker
1097*58b9f456SAndroid Build Coastguard Worker    static locale::id id;
1098*58b9f456SAndroid Build Coastguard Worker
1099*58b9f456SAndroid Build Coastguard Workerprotected:
1100*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1101*58b9f456SAndroid Build Coastguard Worker    explicit codecvt(const char*, size_t __refs = 0)
1102*58b9f456SAndroid Build Coastguard Worker        : locale::facet(__refs) {}
1103*58b9f456SAndroid Build Coastguard Worker
1104*58b9f456SAndroid Build Coastguard Worker    ~codecvt();
1105*58b9f456SAndroid Build Coastguard Worker
1106*58b9f456SAndroid Build Coastguard Worker    virtual result do_out(state_type& __st,
1107*58b9f456SAndroid Build Coastguard Worker                          const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
1108*58b9f456SAndroid Build Coastguard Worker                          extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
1109*58b9f456SAndroid Build Coastguard Worker    virtual result do_in(state_type& __st,
1110*58b9f456SAndroid Build Coastguard Worker                         const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
1111*58b9f456SAndroid Build Coastguard Worker                         intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
1112*58b9f456SAndroid Build Coastguard Worker    virtual result do_unshift(state_type& __st,
1113*58b9f456SAndroid Build Coastguard Worker                              extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
1114*58b9f456SAndroid Build Coastguard Worker    virtual int do_encoding() const  _NOEXCEPT;
1115*58b9f456SAndroid Build Coastguard Worker    virtual bool do_always_noconv() const  _NOEXCEPT;
1116*58b9f456SAndroid Build Coastguard Worker    virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const;
1117*58b9f456SAndroid Build Coastguard Worker    virtual int do_max_length() const  _NOEXCEPT;
1118*58b9f456SAndroid Build Coastguard Worker};
1119*58b9f456SAndroid Build Coastguard Worker
1120*58b9f456SAndroid Build Coastguard Worker// template <> class codecvt<char32_t, char, mbstate_t>
1121*58b9f456SAndroid Build Coastguard Worker
1122*58b9f456SAndroid Build Coastguard Workertemplate <>
1123*58b9f456SAndroid Build Coastguard Workerclass _LIBCPP_TYPE_VIS codecvt<char32_t, char, mbstate_t>
1124*58b9f456SAndroid Build Coastguard Worker    : public locale::facet,
1125*58b9f456SAndroid Build Coastguard Worker      public codecvt_base
1126*58b9f456SAndroid Build Coastguard Worker{
1127*58b9f456SAndroid Build Coastguard Workerpublic:
1128*58b9f456SAndroid Build Coastguard Worker    typedef char32_t  intern_type;
1129*58b9f456SAndroid Build Coastguard Worker    typedef char      extern_type;
1130*58b9f456SAndroid Build Coastguard Worker    typedef mbstate_t state_type;
1131*58b9f456SAndroid Build Coastguard Worker
1132*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1133*58b9f456SAndroid Build Coastguard Worker    explicit codecvt(size_t __refs = 0)
1134*58b9f456SAndroid Build Coastguard Worker        : locale::facet(__refs) {}
1135*58b9f456SAndroid Build Coastguard Worker
1136*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1137*58b9f456SAndroid Build Coastguard Worker    result out(state_type& __st,
1138*58b9f456SAndroid Build Coastguard Worker               const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
1139*58b9f456SAndroid Build Coastguard Worker               extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const
1140*58b9f456SAndroid Build Coastguard Worker    {
1141*58b9f456SAndroid Build Coastguard Worker        return do_out(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
1142*58b9f456SAndroid Build Coastguard Worker    }
1143*58b9f456SAndroid Build Coastguard Worker
1144*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1145*58b9f456SAndroid Build Coastguard Worker    result unshift(state_type& __st,
1146*58b9f456SAndroid Build Coastguard Worker                   extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const
1147*58b9f456SAndroid Build Coastguard Worker    {
1148*58b9f456SAndroid Build Coastguard Worker        return do_unshift(__st, __to, __to_end, __to_nxt);
1149*58b9f456SAndroid Build Coastguard Worker    }
1150*58b9f456SAndroid Build Coastguard Worker
1151*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1152*58b9f456SAndroid Build Coastguard Worker    result in(state_type& __st,
1153*58b9f456SAndroid Build Coastguard Worker              const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
1154*58b9f456SAndroid Build Coastguard Worker              intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const
1155*58b9f456SAndroid Build Coastguard Worker    {
1156*58b9f456SAndroid Build Coastguard Worker        return do_in(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
1157*58b9f456SAndroid Build Coastguard Worker    }
1158*58b9f456SAndroid Build Coastguard Worker
1159*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1160*58b9f456SAndroid Build Coastguard Worker    int encoding() const  _NOEXCEPT
1161*58b9f456SAndroid Build Coastguard Worker    {
1162*58b9f456SAndroid Build Coastguard Worker        return do_encoding();
1163*58b9f456SAndroid Build Coastguard Worker    }
1164*58b9f456SAndroid Build Coastguard Worker
1165*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1166*58b9f456SAndroid Build Coastguard Worker    bool always_noconv() const  _NOEXCEPT
1167*58b9f456SAndroid Build Coastguard Worker    {
1168*58b9f456SAndroid Build Coastguard Worker        return do_always_noconv();
1169*58b9f456SAndroid Build Coastguard Worker    }
1170*58b9f456SAndroid Build Coastguard Worker
1171*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1172*58b9f456SAndroid Build Coastguard Worker    int length(state_type& __st, const extern_type* __frm, const extern_type* __end, size_t __mx) const
1173*58b9f456SAndroid Build Coastguard Worker    {
1174*58b9f456SAndroid Build Coastguard Worker        return do_length(__st, __frm, __end, __mx);
1175*58b9f456SAndroid Build Coastguard Worker    }
1176*58b9f456SAndroid Build Coastguard Worker
1177*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1178*58b9f456SAndroid Build Coastguard Worker    int max_length() const  _NOEXCEPT
1179*58b9f456SAndroid Build Coastguard Worker    {
1180*58b9f456SAndroid Build Coastguard Worker        return do_max_length();
1181*58b9f456SAndroid Build Coastguard Worker    }
1182*58b9f456SAndroid Build Coastguard Worker
1183*58b9f456SAndroid Build Coastguard Worker    static locale::id id;
1184*58b9f456SAndroid Build Coastguard Worker
1185*58b9f456SAndroid Build Coastguard Workerprotected:
1186*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1187*58b9f456SAndroid Build Coastguard Worker    explicit codecvt(const char*, size_t __refs = 0)
1188*58b9f456SAndroid Build Coastguard Worker        : locale::facet(__refs) {}
1189*58b9f456SAndroid Build Coastguard Worker
1190*58b9f456SAndroid Build Coastguard Worker    ~codecvt();
1191*58b9f456SAndroid Build Coastguard Worker
1192*58b9f456SAndroid Build Coastguard Worker    virtual result do_out(state_type& __st,
1193*58b9f456SAndroid Build Coastguard Worker                          const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
1194*58b9f456SAndroid Build Coastguard Worker                          extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
1195*58b9f456SAndroid Build Coastguard Worker    virtual result do_in(state_type& __st,
1196*58b9f456SAndroid Build Coastguard Worker                         const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
1197*58b9f456SAndroid Build Coastguard Worker                         intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
1198*58b9f456SAndroid Build Coastguard Worker    virtual result do_unshift(state_type& __st,
1199*58b9f456SAndroid Build Coastguard Worker                              extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
1200*58b9f456SAndroid Build Coastguard Worker    virtual int do_encoding() const  _NOEXCEPT;
1201*58b9f456SAndroid Build Coastguard Worker    virtual bool do_always_noconv() const  _NOEXCEPT;
1202*58b9f456SAndroid Build Coastguard Worker    virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const;
1203*58b9f456SAndroid Build Coastguard Worker    virtual int do_max_length() const  _NOEXCEPT;
1204*58b9f456SAndroid Build Coastguard Worker};
1205*58b9f456SAndroid Build Coastguard Worker
1206*58b9f456SAndroid Build Coastguard Worker// template <class _InternT, class _ExternT, class _StateT> class codecvt_byname
1207*58b9f456SAndroid Build Coastguard Worker
1208*58b9f456SAndroid Build Coastguard Workertemplate <class _InternT, class _ExternT, class _StateT>
1209*58b9f456SAndroid Build Coastguard Workerclass _LIBCPP_TEMPLATE_VIS codecvt_byname
1210*58b9f456SAndroid Build Coastguard Worker    : public codecvt<_InternT, _ExternT, _StateT>
1211*58b9f456SAndroid Build Coastguard Worker{
1212*58b9f456SAndroid Build Coastguard Workerpublic:
1213*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1214*58b9f456SAndroid Build Coastguard Worker    explicit codecvt_byname(const char* __nm, size_t __refs = 0)
1215*58b9f456SAndroid Build Coastguard Worker        : codecvt<_InternT, _ExternT, _StateT>(__nm, __refs) {}
1216*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1217*58b9f456SAndroid Build Coastguard Worker    explicit codecvt_byname(const string& __nm, size_t __refs = 0)
1218*58b9f456SAndroid Build Coastguard Worker        : codecvt<_InternT, _ExternT, _StateT>(__nm.c_str(), __refs) {}
1219*58b9f456SAndroid Build Coastguard Workerprotected:
1220*58b9f456SAndroid Build Coastguard Worker    ~codecvt_byname();
1221*58b9f456SAndroid Build Coastguard Worker};
1222*58b9f456SAndroid Build Coastguard Worker
1223*58b9f456SAndroid Build Coastguard Workertemplate <class _InternT, class _ExternT, class _StateT>
1224*58b9f456SAndroid Build Coastguard Workercodecvt_byname<_InternT, _ExternT, _StateT>::~codecvt_byname()
1225*58b9f456SAndroid Build Coastguard Worker{
1226*58b9f456SAndroid Build Coastguard Worker}
1227*58b9f456SAndroid Build Coastguard Worker
1228*58b9f456SAndroid Build Coastguard Worker_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char, char, mbstate_t>)
1229*58b9f456SAndroid Build Coastguard Worker_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<wchar_t, char, mbstate_t>)
1230*58b9f456SAndroid Build Coastguard Worker_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char16_t, char, mbstate_t>)
1231*58b9f456SAndroid Build Coastguard Worker_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char32_t, char, mbstate_t>)
1232*58b9f456SAndroid Build Coastguard Worker
1233*58b9f456SAndroid Build Coastguard Worker_LIBCPP_NORETURN _LIBCPP_FUNC_VIS void __throw_runtime_error(const char*);
1234*58b9f456SAndroid Build Coastguard Worker
1235*58b9f456SAndroid Build Coastguard Workertemplate <size_t _Np>
1236*58b9f456SAndroid Build Coastguard Workerstruct __narrow_to_utf8
1237*58b9f456SAndroid Build Coastguard Worker{
1238*58b9f456SAndroid Build Coastguard Worker    template <class _OutputIterator, class _CharT>
1239*58b9f456SAndroid Build Coastguard Worker    _OutputIterator
1240*58b9f456SAndroid Build Coastguard Worker    operator()(_OutputIterator __s, const _CharT* __wb, const _CharT* __we) const;
1241*58b9f456SAndroid Build Coastguard Worker};
1242*58b9f456SAndroid Build Coastguard Worker
1243*58b9f456SAndroid Build Coastguard Workertemplate <>
1244*58b9f456SAndroid Build Coastguard Workerstruct __narrow_to_utf8<8>
1245*58b9f456SAndroid Build Coastguard Worker{
1246*58b9f456SAndroid Build Coastguard Worker    template <class _OutputIterator, class _CharT>
1247*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1248*58b9f456SAndroid Build Coastguard Worker    _OutputIterator
1249*58b9f456SAndroid Build Coastguard Worker    operator()(_OutputIterator __s, const _CharT* __wb, const _CharT* __we) const
1250*58b9f456SAndroid Build Coastguard Worker    {
1251*58b9f456SAndroid Build Coastguard Worker        for (; __wb < __we; ++__wb, ++__s)
1252*58b9f456SAndroid Build Coastguard Worker            *__s = *__wb;
1253*58b9f456SAndroid Build Coastguard Worker        return __s;
1254*58b9f456SAndroid Build Coastguard Worker    }
1255*58b9f456SAndroid Build Coastguard Worker};
1256*58b9f456SAndroid Build Coastguard Worker
1257*58b9f456SAndroid Build Coastguard Workertemplate <>
1258*58b9f456SAndroid Build Coastguard Workerstruct _LIBCPP_TEMPLATE_VIS __narrow_to_utf8<16>
1259*58b9f456SAndroid Build Coastguard Worker    : public codecvt<char16_t, char, mbstate_t>
1260*58b9f456SAndroid Build Coastguard Worker{
1261*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1262*58b9f456SAndroid Build Coastguard Worker    __narrow_to_utf8() : codecvt<char16_t, char, mbstate_t>(1) {}
1263*58b9f456SAndroid Build Coastguard Worker
1264*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_EXPORTED_FROM_ABI ~__narrow_to_utf8();
1265*58b9f456SAndroid Build Coastguard Worker
1266*58b9f456SAndroid Build Coastguard Worker    template <class _OutputIterator, class _CharT>
1267*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1268*58b9f456SAndroid Build Coastguard Worker    _OutputIterator
1269*58b9f456SAndroid Build Coastguard Worker    operator()(_OutputIterator __s, const _CharT* __wb, const _CharT* __we) const
1270*58b9f456SAndroid Build Coastguard Worker    {
1271*58b9f456SAndroid Build Coastguard Worker        result __r = ok;
1272*58b9f456SAndroid Build Coastguard Worker        mbstate_t __mb;
1273*58b9f456SAndroid Build Coastguard Worker        while (__wb < __we && __r != error)
1274*58b9f456SAndroid Build Coastguard Worker        {
1275*58b9f456SAndroid Build Coastguard Worker            const int __sz = 32;
1276*58b9f456SAndroid Build Coastguard Worker            char __buf[__sz];
1277*58b9f456SAndroid Build Coastguard Worker            char* __bn;
1278*58b9f456SAndroid Build Coastguard Worker            const char16_t* __wn = (const char16_t*)__wb;
1279*58b9f456SAndroid Build Coastguard Worker            __r = do_out(__mb, (const char16_t*)__wb, (const char16_t*)__we, __wn,
1280*58b9f456SAndroid Build Coastguard Worker                         __buf, __buf+__sz, __bn);
1281*58b9f456SAndroid Build Coastguard Worker            if (__r == codecvt_base::error || __wn == (const char16_t*)__wb)
1282*58b9f456SAndroid Build Coastguard Worker                __throw_runtime_error("locale not supported");
1283*58b9f456SAndroid Build Coastguard Worker            for (const char* __p = __buf; __p < __bn; ++__p, ++__s)
1284*58b9f456SAndroid Build Coastguard Worker                *__s = *__p;
1285*58b9f456SAndroid Build Coastguard Worker            __wb = (const _CharT*)__wn;
1286*58b9f456SAndroid Build Coastguard Worker        }
1287*58b9f456SAndroid Build Coastguard Worker        return __s;
1288*58b9f456SAndroid Build Coastguard Worker    }
1289*58b9f456SAndroid Build Coastguard Worker};
1290*58b9f456SAndroid Build Coastguard Worker
1291*58b9f456SAndroid Build Coastguard Workertemplate <>
1292*58b9f456SAndroid Build Coastguard Workerstruct _LIBCPP_TEMPLATE_VIS __narrow_to_utf8<32>
1293*58b9f456SAndroid Build Coastguard Worker    : public codecvt<char32_t, char, mbstate_t>
1294*58b9f456SAndroid Build Coastguard Worker{
1295*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1296*58b9f456SAndroid Build Coastguard Worker    __narrow_to_utf8() : codecvt<char32_t, char, mbstate_t>(1) {}
1297*58b9f456SAndroid Build Coastguard Worker
1298*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_EXPORTED_FROM_ABI ~__narrow_to_utf8();
1299*58b9f456SAndroid Build Coastguard Worker
1300*58b9f456SAndroid Build Coastguard Worker    template <class _OutputIterator, class _CharT>
1301*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1302*58b9f456SAndroid Build Coastguard Worker    _OutputIterator
1303*58b9f456SAndroid Build Coastguard Worker    operator()(_OutputIterator __s, const _CharT* __wb, const _CharT* __we) const
1304*58b9f456SAndroid Build Coastguard Worker    {
1305*58b9f456SAndroid Build Coastguard Worker        result __r = ok;
1306*58b9f456SAndroid Build Coastguard Worker        mbstate_t __mb;
1307*58b9f456SAndroid Build Coastguard Worker        while (__wb < __we && __r != error)
1308*58b9f456SAndroid Build Coastguard Worker        {
1309*58b9f456SAndroid Build Coastguard Worker            const int __sz = 32;
1310*58b9f456SAndroid Build Coastguard Worker            char __buf[__sz];
1311*58b9f456SAndroid Build Coastguard Worker            char* __bn;
1312*58b9f456SAndroid Build Coastguard Worker            const char32_t* __wn = (const char32_t*)__wb;
1313*58b9f456SAndroid Build Coastguard Worker            __r = do_out(__mb, (const char32_t*)__wb, (const char32_t*)__we, __wn,
1314*58b9f456SAndroid Build Coastguard Worker                         __buf, __buf+__sz, __bn);
1315*58b9f456SAndroid Build Coastguard Worker            if (__r == codecvt_base::error || __wn == (const char32_t*)__wb)
1316*58b9f456SAndroid Build Coastguard Worker                __throw_runtime_error("locale not supported");
1317*58b9f456SAndroid Build Coastguard Worker            for (const char* __p = __buf; __p < __bn; ++__p, ++__s)
1318*58b9f456SAndroid Build Coastguard Worker                *__s = *__p;
1319*58b9f456SAndroid Build Coastguard Worker            __wb = (const _CharT*)__wn;
1320*58b9f456SAndroid Build Coastguard Worker        }
1321*58b9f456SAndroid Build Coastguard Worker        return __s;
1322*58b9f456SAndroid Build Coastguard Worker    }
1323*58b9f456SAndroid Build Coastguard Worker};
1324*58b9f456SAndroid Build Coastguard Worker
1325*58b9f456SAndroid Build Coastguard Workertemplate <size_t _Np>
1326*58b9f456SAndroid Build Coastguard Workerstruct __widen_from_utf8
1327*58b9f456SAndroid Build Coastguard Worker{
1328*58b9f456SAndroid Build Coastguard Worker    template <class _OutputIterator>
1329*58b9f456SAndroid Build Coastguard Worker    _OutputIterator
1330*58b9f456SAndroid Build Coastguard Worker    operator()(_OutputIterator __s, const char* __nb, const char* __ne) const;
1331*58b9f456SAndroid Build Coastguard Worker};
1332*58b9f456SAndroid Build Coastguard Worker
1333*58b9f456SAndroid Build Coastguard Workertemplate <>
1334*58b9f456SAndroid Build Coastguard Workerstruct __widen_from_utf8<8>
1335*58b9f456SAndroid Build Coastguard Worker{
1336*58b9f456SAndroid Build Coastguard Worker    template <class _OutputIterator>
1337*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1338*58b9f456SAndroid Build Coastguard Worker    _OutputIterator
1339*58b9f456SAndroid Build Coastguard Worker    operator()(_OutputIterator __s, const char* __nb, const char* __ne) const
1340*58b9f456SAndroid Build Coastguard Worker    {
1341*58b9f456SAndroid Build Coastguard Worker        for (; __nb < __ne; ++__nb, ++__s)
1342*58b9f456SAndroid Build Coastguard Worker            *__s = *__nb;
1343*58b9f456SAndroid Build Coastguard Worker        return __s;
1344*58b9f456SAndroid Build Coastguard Worker    }
1345*58b9f456SAndroid Build Coastguard Worker};
1346*58b9f456SAndroid Build Coastguard Worker
1347*58b9f456SAndroid Build Coastguard Workertemplate <>
1348*58b9f456SAndroid Build Coastguard Workerstruct _LIBCPP_TEMPLATE_VIS __widen_from_utf8<16>
1349*58b9f456SAndroid Build Coastguard Worker    : public codecvt<char16_t, char, mbstate_t>
1350*58b9f456SAndroid Build Coastguard Worker{
1351*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1352*58b9f456SAndroid Build Coastguard Worker    __widen_from_utf8() : codecvt<char16_t, char, mbstate_t>(1) {}
1353*58b9f456SAndroid Build Coastguard Worker
1354*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_EXPORTED_FROM_ABI ~__widen_from_utf8();
1355*58b9f456SAndroid Build Coastguard Worker
1356*58b9f456SAndroid Build Coastguard Worker    template <class _OutputIterator>
1357*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1358*58b9f456SAndroid Build Coastguard Worker    _OutputIterator
1359*58b9f456SAndroid Build Coastguard Worker    operator()(_OutputIterator __s, const char* __nb, const char* __ne) const
1360*58b9f456SAndroid Build Coastguard Worker    {
1361*58b9f456SAndroid Build Coastguard Worker        result __r = ok;
1362*58b9f456SAndroid Build Coastguard Worker        mbstate_t __mb;
1363*58b9f456SAndroid Build Coastguard Worker        while (__nb < __ne && __r != error)
1364*58b9f456SAndroid Build Coastguard Worker        {
1365*58b9f456SAndroid Build Coastguard Worker            const int __sz = 32;
1366*58b9f456SAndroid Build Coastguard Worker            char16_t __buf[__sz];
1367*58b9f456SAndroid Build Coastguard Worker            char16_t* __bn;
1368*58b9f456SAndroid Build Coastguard Worker            const char* __nn = __nb;
1369*58b9f456SAndroid Build Coastguard Worker            __r = do_in(__mb, __nb, __ne - __nb > __sz ? __nb+__sz : __ne, __nn,
1370*58b9f456SAndroid Build Coastguard Worker                        __buf, __buf+__sz, __bn);
1371*58b9f456SAndroid Build Coastguard Worker            if (__r == codecvt_base::error || __nn == __nb)
1372*58b9f456SAndroid Build Coastguard Worker                __throw_runtime_error("locale not supported");
1373*58b9f456SAndroid Build Coastguard Worker            for (const char16_t* __p = __buf; __p < __bn; ++__p, ++__s)
1374*58b9f456SAndroid Build Coastguard Worker                *__s = (wchar_t)*__p;
1375*58b9f456SAndroid Build Coastguard Worker            __nb = __nn;
1376*58b9f456SAndroid Build Coastguard Worker        }
1377*58b9f456SAndroid Build Coastguard Worker        return __s;
1378*58b9f456SAndroid Build Coastguard Worker    }
1379*58b9f456SAndroid Build Coastguard Worker};
1380*58b9f456SAndroid Build Coastguard Worker
1381*58b9f456SAndroid Build Coastguard Workertemplate <>
1382*58b9f456SAndroid Build Coastguard Workerstruct _LIBCPP_TEMPLATE_VIS __widen_from_utf8<32>
1383*58b9f456SAndroid Build Coastguard Worker    : public codecvt<char32_t, char, mbstate_t>
1384*58b9f456SAndroid Build Coastguard Worker{
1385*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1386*58b9f456SAndroid Build Coastguard Worker    __widen_from_utf8() : codecvt<char32_t, char, mbstate_t>(1) {}
1387*58b9f456SAndroid Build Coastguard Worker
1388*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_EXPORTED_FROM_ABI ~__widen_from_utf8();
1389*58b9f456SAndroid Build Coastguard Worker
1390*58b9f456SAndroid Build Coastguard Worker    template <class _OutputIterator>
1391*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
1392*58b9f456SAndroid Build Coastguard Worker    _OutputIterator
1393*58b9f456SAndroid Build Coastguard Worker    operator()(_OutputIterator __s, const char* __nb, const char* __ne) const
1394*58b9f456SAndroid Build Coastguard Worker    {
1395*58b9f456SAndroid Build Coastguard Worker        result __r = ok;
1396*58b9f456SAndroid Build Coastguard Worker        mbstate_t __mb;
1397*58b9f456SAndroid Build Coastguard Worker        while (__nb < __ne && __r != error)
1398*58b9f456SAndroid Build Coastguard Worker        {
1399*58b9f456SAndroid Build Coastguard Worker            const int __sz = 32;
1400*58b9f456SAndroid Build Coastguard Worker            char32_t __buf[__sz];
1401*58b9f456SAndroid Build Coastguard Worker            char32_t* __bn;
1402*58b9f456SAndroid Build Coastguard Worker            const char* __nn = __nb;
1403*58b9f456SAndroid Build Coastguard Worker            __r = do_in(__mb, __nb, __ne - __nb > __sz ? __nb+__sz : __ne, __nn,
1404*58b9f456SAndroid Build Coastguard Worker                        __buf, __buf+__sz, __bn);
1405*58b9f456SAndroid Build Coastguard Worker            if (__r == codecvt_base::error || __nn == __nb)
1406*58b9f456SAndroid Build Coastguard Worker                __throw_runtime_error("locale not supported");
1407*58b9f456SAndroid Build Coastguard Worker            for (const char32_t* __p = __buf; __p < __bn; ++__p, ++__s)
1408*58b9f456SAndroid Build Coastguard Worker                *__s = (wchar_t)*__p;
1409*58b9f456SAndroid Build Coastguard Worker            __nb = __nn;
1410*58b9f456SAndroid Build Coastguard Worker        }
1411*58b9f456SAndroid Build Coastguard Worker        return __s;
1412*58b9f456SAndroid Build Coastguard Worker    }
1413*58b9f456SAndroid Build Coastguard Worker};
1414*58b9f456SAndroid Build Coastguard Worker
1415*58b9f456SAndroid Build Coastguard Worker// template <class charT> class numpunct
1416*58b9f456SAndroid Build Coastguard Worker
1417*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT> class _LIBCPP_TEMPLATE_VIS numpunct;
1418*58b9f456SAndroid Build Coastguard Worker
1419*58b9f456SAndroid Build Coastguard Workertemplate <>
1420*58b9f456SAndroid Build Coastguard Workerclass _LIBCPP_TYPE_VIS numpunct<char>
1421*58b9f456SAndroid Build Coastguard Worker    : public locale::facet
1422*58b9f456SAndroid Build Coastguard Worker{
1423*58b9f456SAndroid Build Coastguard Workerpublic:
1424*58b9f456SAndroid Build Coastguard Worker    typedef char char_type;
1425*58b9f456SAndroid Build Coastguard Worker    typedef basic_string<char_type> string_type;
1426*58b9f456SAndroid Build Coastguard Worker
1427*58b9f456SAndroid Build Coastguard Worker    explicit numpunct(size_t __refs = 0);
1428*58b9f456SAndroid Build Coastguard Worker
1429*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY char_type decimal_point() const {return do_decimal_point();}
1430*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY char_type thousands_sep() const {return do_thousands_sep();}
1431*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY string grouping() const         {return do_grouping();}
1432*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY string_type truename() const    {return do_truename();}
1433*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY string_type falsename() const   {return do_falsename();}
1434*58b9f456SAndroid Build Coastguard Worker
1435*58b9f456SAndroid Build Coastguard Worker    static locale::id id;
1436*58b9f456SAndroid Build Coastguard Worker
1437*58b9f456SAndroid Build Coastguard Workerprotected:
1438*58b9f456SAndroid Build Coastguard Worker    ~numpunct();
1439*58b9f456SAndroid Build Coastguard Worker    virtual char_type do_decimal_point() const;
1440*58b9f456SAndroid Build Coastguard Worker    virtual char_type do_thousands_sep() const;
1441*58b9f456SAndroid Build Coastguard Worker    virtual string do_grouping() const;
1442*58b9f456SAndroid Build Coastguard Worker    virtual string_type do_truename() const;
1443*58b9f456SAndroid Build Coastguard Worker    virtual string_type do_falsename() const;
1444*58b9f456SAndroid Build Coastguard Worker
1445*58b9f456SAndroid Build Coastguard Worker    char_type __decimal_point_;
1446*58b9f456SAndroid Build Coastguard Worker    char_type __thousands_sep_;
1447*58b9f456SAndroid Build Coastguard Worker    string __grouping_;
1448*58b9f456SAndroid Build Coastguard Worker};
1449*58b9f456SAndroid Build Coastguard Worker
1450*58b9f456SAndroid Build Coastguard Workertemplate <>
1451*58b9f456SAndroid Build Coastguard Workerclass _LIBCPP_TYPE_VIS numpunct<wchar_t>
1452*58b9f456SAndroid Build Coastguard Worker    : public locale::facet
1453*58b9f456SAndroid Build Coastguard Worker{
1454*58b9f456SAndroid Build Coastguard Workerpublic:
1455*58b9f456SAndroid Build Coastguard Worker    typedef wchar_t char_type;
1456*58b9f456SAndroid Build Coastguard Worker    typedef basic_string<char_type> string_type;
1457*58b9f456SAndroid Build Coastguard Worker
1458*58b9f456SAndroid Build Coastguard Worker    explicit numpunct(size_t __refs = 0);
1459*58b9f456SAndroid Build Coastguard Worker
1460*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY char_type decimal_point() const {return do_decimal_point();}
1461*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY char_type thousands_sep() const {return do_thousands_sep();}
1462*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY string grouping() const         {return do_grouping();}
1463*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY string_type truename() const    {return do_truename();}
1464*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY string_type falsename() const   {return do_falsename();}
1465*58b9f456SAndroid Build Coastguard Worker
1466*58b9f456SAndroid Build Coastguard Worker    static locale::id id;
1467*58b9f456SAndroid Build Coastguard Worker
1468*58b9f456SAndroid Build Coastguard Workerprotected:
1469*58b9f456SAndroid Build Coastguard Worker    ~numpunct();
1470*58b9f456SAndroid Build Coastguard Worker    virtual char_type do_decimal_point() const;
1471*58b9f456SAndroid Build Coastguard Worker    virtual char_type do_thousands_sep() const;
1472*58b9f456SAndroid Build Coastguard Worker    virtual string do_grouping() const;
1473*58b9f456SAndroid Build Coastguard Worker    virtual string_type do_truename() const;
1474*58b9f456SAndroid Build Coastguard Worker    virtual string_type do_falsename() const;
1475*58b9f456SAndroid Build Coastguard Worker
1476*58b9f456SAndroid Build Coastguard Worker    char_type __decimal_point_;
1477*58b9f456SAndroid Build Coastguard Worker    char_type __thousands_sep_;
1478*58b9f456SAndroid Build Coastguard Worker    string __grouping_;
1479*58b9f456SAndroid Build Coastguard Worker};
1480*58b9f456SAndroid Build Coastguard Worker
1481*58b9f456SAndroid Build Coastguard Worker// template <class charT> class numpunct_byname
1482*58b9f456SAndroid Build Coastguard Worker
1483*58b9f456SAndroid Build Coastguard Workertemplate <class _CharT> class _LIBCPP_TEMPLATE_VIS numpunct_byname;
1484*58b9f456SAndroid Build Coastguard Worker
1485*58b9f456SAndroid Build Coastguard Workertemplate <>
1486*58b9f456SAndroid Build Coastguard Workerclass _LIBCPP_TYPE_VIS numpunct_byname<char>
1487*58b9f456SAndroid Build Coastguard Worker: public numpunct<char>
1488*58b9f456SAndroid Build Coastguard Worker{
1489*58b9f456SAndroid Build Coastguard Workerpublic:
1490*58b9f456SAndroid Build Coastguard Worker    typedef char char_type;
1491*58b9f456SAndroid Build Coastguard Worker    typedef basic_string<char_type> string_type;
1492*58b9f456SAndroid Build Coastguard Worker
1493*58b9f456SAndroid Build Coastguard Worker    explicit numpunct_byname(const char* __nm, size_t __refs = 0);
1494*58b9f456SAndroid Build Coastguard Worker    explicit numpunct_byname(const string& __nm, size_t __refs = 0);
1495*58b9f456SAndroid Build Coastguard Worker
1496*58b9f456SAndroid Build Coastguard Workerprotected:
1497*58b9f456SAndroid Build Coastguard Worker    ~numpunct_byname();
1498*58b9f456SAndroid Build Coastguard Worker
1499*58b9f456SAndroid Build Coastguard Workerprivate:
1500*58b9f456SAndroid Build Coastguard Worker    void __init(const char*);
1501*58b9f456SAndroid Build Coastguard Worker};
1502*58b9f456SAndroid Build Coastguard Worker
1503*58b9f456SAndroid Build Coastguard Workertemplate <>
1504*58b9f456SAndroid Build Coastguard Workerclass _LIBCPP_TYPE_VIS numpunct_byname<wchar_t>
1505*58b9f456SAndroid Build Coastguard Worker: public numpunct<wchar_t>
1506*58b9f456SAndroid Build Coastguard Worker{
1507*58b9f456SAndroid Build Coastguard Workerpublic:
1508*58b9f456SAndroid Build Coastguard Worker    typedef wchar_t char_type;
1509*58b9f456SAndroid Build Coastguard Worker    typedef basic_string<char_type> string_type;
1510*58b9f456SAndroid Build Coastguard Worker
1511*58b9f456SAndroid Build Coastguard Worker    explicit numpunct_byname(const char* __nm, size_t __refs = 0);
1512*58b9f456SAndroid Build Coastguard Worker    explicit numpunct_byname(const string& __nm, size_t __refs = 0);
1513*58b9f456SAndroid Build Coastguard Worker
1514*58b9f456SAndroid Build Coastguard Workerprotected:
1515*58b9f456SAndroid Build Coastguard Worker    ~numpunct_byname();
1516*58b9f456SAndroid Build Coastguard Worker
1517*58b9f456SAndroid Build Coastguard Workerprivate:
1518*58b9f456SAndroid Build Coastguard Worker    void __init(const char*);
1519*58b9f456SAndroid Build Coastguard Worker};
1520*58b9f456SAndroid Build Coastguard Worker
1521*58b9f456SAndroid Build Coastguard Worker_LIBCPP_END_NAMESPACE_STD
1522*58b9f456SAndroid Build Coastguard Worker
1523*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP___LOCALE
1524