Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
__locale1558 linesDownload Raw Back to include
1// -*- C++ -*-2//===----------------------------------------------------------------------===//3//4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.5// See https://llvm.org/LICENSE.txt for license information.6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception7//8//===----------------------------------------------------------------------===//9 10#ifndef _LIBCUDACXX___LOCALE11#define _LIBCUDACXX___LOCALE12 13#include <__config>14#include <string>15#include <memory>16#include <utility>17#include <mutex>18#include <cstdint>19#include <cctype>20#include <locale.h>21#if defined(_LIBCUDACXX_MSVCRT_LIKE)22# include <cstring>23# include <support/win32/locale_win32.h>24#elif defined(_AIX)25# include <support/ibm/xlocale.h>26#elif defined(__ANDROID__)27# include <support/android/locale_bionic.h>28#elif defined(__sun__)29# include <xlocale.h>30# include <support/solaris/xlocale.h>31#elif defined(_NEWLIB_VERSION)32# include <support/newlib/xlocale.h>33#elif (defined(__APPLE__)      || defined(__FreeBSD__) \34    || defined(__EMSCRIPTEN__) || defined(__IBMCPP__))35# include <xlocale.h>36#elif defined(__Fuchsia__)37# include <support/fuchsia/xlocale.h>38#elif defined(__wasi__)39// WASI libc uses musl's locales support.40# include <support/musl/xlocale.h>41#elif defined(_LIBCUDACXX_HAS_MUSL_LIBC)42# include <support/musl/xlocale.h>43#endif44 45#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)46#  pragma GCC system_header47#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)48#  pragma clang system_header49#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)50#  pragma system_header51#endif // no system header52 53_LIBCUDACXX_BEGIN_NAMESPACE_STD54 55#if !defined(_LIBCUDACXX_LOCALE__L_EXTENSIONS)56struct __libcpp_locale_guard {57  _LIBCUDACXX_INLINE_VISIBILITY58  __libcpp_locale_guard(locale_t& __loc) : __old_loc_(uselocale(__loc)) {}59 60  _LIBCUDACXX_INLINE_VISIBILITY61  ~__libcpp_locale_guard() {62    if (__old_loc_)63      uselocale(__old_loc_);64  }65 66  locale_t __old_loc_;67private:68  __libcpp_locale_guard(__libcpp_locale_guard const&);69  __libcpp_locale_guard& operator=(__libcpp_locale_guard const&);70};71#elif defined(_LIBCUDACXX_MSVCRT_LIKE)72struct __libcpp_locale_guard {73    __libcpp_locale_guard(locale_t __l) :74        __status(_configthreadlocale(_ENABLE_PER_THREAD_LOCALE)) {75      // Setting the locale can be expensive even when the locale given is76      // already the current locale, so do an explicit check to see if the77      // current locale is already the one we want.78      const char* __lc = __setlocale(nullptr);79      // If every category is the same, the locale string will simply be the80      // locale name, otherwise it will be a semicolon-separated string listing81      // each category.  In the second case, we know at least one category won't82      // be what we want, so we only have to check the first case.83      if (strcmp(__l.__get_locale(), __lc) != 0) {84        __locale_all = _strdup(__lc);85        if (__locale_all == nullptr)86          __throw_bad_alloc();87        __setlocale(__l.__get_locale());88      }89    }90    ~__libcpp_locale_guard() {91      // The CRT documentation doesn't explicitly say, but setlocale() does the92      // right thing when given a semicolon-separated list of locale settings93      // for the different categories in the same format as returned by94      // setlocale(LC_ALL, nullptr).95      if (__locale_all != nullptr) {96        __setlocale(__locale_all);97        free(__locale_all);98      }99      _configthreadlocale(__status);100    }101    static const char* __setlocale(const char* __locale) {102      const char* __new_locale = setlocale(LC_ALL, __locale);103      if (__new_locale == nullptr)104        __throw_bad_alloc();105      return __new_locale;106    }107    int __status;108    char* __locale_all = nullptr;109};110#endif111 112 113class _LIBCUDACXX_TYPE_VIS locale;114 115template <class _Facet>116_LIBCUDACXX_INLINE_VISIBILITY117bool118has_facet(const locale&) noexcept;119 120template <class _Facet>121_LIBCUDACXX_INLINE_VISIBILITY122const _Facet&123use_facet(const locale&);124 125class _LIBCUDACXX_TYPE_VIS locale126{127public:128    // types:129    class _LIBCUDACXX_TYPE_VIS facet;130    class _LIBCUDACXX_TYPE_VIS id;131 132    typedef int category;133    _LIBCUDACXX_AVAILABILITY_LOCALE_CATEGORY134    static const category // values assigned here are for exposition only135        none     = 0,136        collate  = LC_COLLATE_MASK,137        ctype    = LC_CTYPE_MASK,138        monetary = LC_MONETARY_MASK,139        numeric  = LC_NUMERIC_MASK,140        time     = LC_TIME_MASK,141        messages = LC_MESSAGES_MASK,142        all = collate | ctype | monetary | numeric | time | messages;143 144    // construct/copy/destroy:145    locale()  noexcept;146    locale(const locale&)  noexcept;147    explicit locale(const char*);148    explicit locale(const string&);149    locale(const locale&, const char*, category);150    locale(const locale&, const string&, category);151    template <class _Facet>152        _LIBCUDACXX_INLINE_VISIBILITY locale(const locale&, _Facet*);153    locale(const locale&, const locale&, category);154 155    ~locale();156 157    const locale& operator=(const locale&)  noexcept;158 159    template <class _Facet>160      _LIBCUDACXX_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS161      locale combine(const locale&) const;162 163    // locale operations:164    string name() const;165    bool operator==(const locale&) const;166    bool operator!=(const locale& __y) const {return !(*this == __y);}167    template <class _CharT, class _Traits, class _Allocator>168      _LIBCUDACXX_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS169      bool operator()(const basic_string<_CharT, _Traits, _Allocator>&,170                      const basic_string<_CharT, _Traits, _Allocator>&) const;171 172    // global locale objects:173    static locale global(const locale&);174    static const locale& classic();175 176private:177    class __imp;178    __imp* __locale_;179 180    void __install_ctor(const locale&, facet*, long);181    static locale& __global();182    bool has_facet(id&) const;183    const facet* use_facet(id&) const;184 185    template <class _Facet> friend bool has_facet(const locale&)  noexcept;186    template <class _Facet> friend const _Facet& use_facet(const locale&);187};188 189class _LIBCUDACXX_TYPE_VIS locale::facet190    : public __shared_count191{192protected:193    _LIBCUDACXX_INLINE_VISIBILITY194    explicit facet(size_t __refs = 0)195        : __shared_count(static_cast<long>(__refs)-1) {}196 197    virtual ~facet();198 199//    facet(const facet&) = delete;     // effectively done in __shared_count200//    void operator=(const facet&) = delete;201private:202    virtual void __on_zero_shared() noexcept;203};204 205class _LIBCUDACXX_TYPE_VIS locale::id206{207    once_flag      __flag_;208    int32_t        __id_;209 210    static int32_t __next_id;211public:212    _LIBCUDACXX_INLINE_VISIBILITY constexpr id() :__id_(0) {}213private:214    void __init();215    void operator=(const id&); // = delete;216    id(const id&); // = delete;217public:  // only needed for tests218    long __get();219 220    friend class locale;221    friend class locale::__imp;222};223 224template <class _Facet>225inline _LIBCUDACXX_INLINE_VISIBILITY226locale::locale(const locale& __other, _Facet* __f)227{228    __install_ctor(__other, __f, __f ? __f->id.__get() : 0);229}230 231template <class _Facet>232locale233locale::combine(const locale& __other) const234{235    if (!_CUDA_VSTD::has_facet<_Facet>(__other))236        __throw_runtime_error("locale::combine: locale missing facet");237 238    return locale(*this, &const_cast<_Facet&>(_CUDA_VSTD::use_facet<_Facet>(__other)));239}240 241template <class _Facet>242inline _LIBCUDACXX_INLINE_VISIBILITY243bool244has_facet(const locale& __l)  noexcept245{246    return __l.has_facet(_Facet::id);247}248 249template <class _Facet>250inline _LIBCUDACXX_INLINE_VISIBILITY251const _Facet&252use_facet(const locale& __l)253{254    return static_cast<const _Facet&>(*__l.use_facet(_Facet::id));255}256 257// template <class _CharT> class collate;258 259template <class _CharT>260class _LIBCUDACXX_TEMPLATE_VIS collate261    : public locale::facet262{263public:264    typedef _CharT char_type;265    typedef basic_string<char_type> string_type;266 267    _LIBCUDACXX_INLINE_VISIBILITY268    explicit collate(size_t __refs = 0)269        : locale::facet(__refs) {}270 271    _LIBCUDACXX_INLINE_VISIBILITY272    int compare(const char_type* __lo1, const char_type* __hi1,273                const char_type* __lo2, const char_type* __hi2) const274    {275        return do_compare(__lo1, __hi1, __lo2, __hi2);276    }277 278    // FIXME(EricWF): The _LIBCUDACXX_ALWAYS_INLINE is needed on Windows to work279    // around a dllimport bug that expects an external instantiation.280    _LIBCUDACXX_INLINE_VISIBILITY281    _LIBCUDACXX_ALWAYS_INLINE282    string_type transform(const char_type* __lo, const char_type* __hi) const283    {284        return do_transform(__lo, __hi);285    }286 287    _LIBCUDACXX_INLINE_VISIBILITY288    long hash(const char_type* __lo, const char_type* __hi) const289    {290        return do_hash(__lo, __hi);291    }292 293    static locale::id id;294 295protected:296    ~collate();297    virtual int do_compare(const char_type* __lo1, const char_type* __hi1,298                           const char_type* __lo2, const char_type* __hi2) const;299    virtual string_type do_transform(const char_type* __lo, const char_type* __hi) const300        {return string_type(__lo, __hi);}301    virtual long do_hash(const char_type* __lo, const char_type* __hi) const;302};303 304template <class _CharT> locale::id collate<_CharT>::id;305 306template <class _CharT>307collate<_CharT>::~collate()308{309}310 311template <class _CharT>312int313collate<_CharT>::do_compare(const char_type* __lo1, const char_type* __hi1,314                            const char_type* __lo2, const char_type* __hi2) const315{316    for (; __lo2 != __hi2; ++__lo1, ++__lo2)317    {318        if (__lo1 == __hi1 || *__lo1 < *__lo2)319            return -1;320        if (*__lo2 < *__lo1)321            return 1;322    }323    return __lo1 != __hi1;324}325 326template <class _CharT>327long328collate<_CharT>::do_hash(const char_type* __lo, const char_type* __hi) const329{330    size_t __h = 0;331    const size_t __sr = __CHAR_BIT__ * sizeof(size_t) - 8;332    const size_t __mask = size_t(0xF) << (__sr + 4);333    for(const char_type* __p = __lo; __p != __hi; ++__p)334    {335        __h = (__h << 4) + static_cast<size_t>(*__p);336        size_t __g = __h & __mask;337        __h ^= __g | (__g >> __sr);338    }339    return static_cast<long>(__h);340}341 342_LIBCUDACXX_EXTERN_TEMPLATE2(class _LIBCUDACXX_EXTERN_TEMPLATE_TYPE_VIS collate<char>)343_LIBCUDACXX_EXTERN_TEMPLATE2(class _LIBCUDACXX_EXTERN_TEMPLATE_TYPE_VIS collate<wchar_t>)344 345// template <class CharT> class collate_byname;346 347template <class _CharT> class _LIBCUDACXX_TEMPLATE_VIS collate_byname;348 349template <>350class _LIBCUDACXX_TYPE_VIS collate_byname<char>351    : public collate<char>352{353    locale_t __l;354public:355    typedef char char_type;356    typedef basic_string<char_type> string_type;357 358    explicit collate_byname(const char* __n, size_t __refs = 0);359    explicit collate_byname(const string& __n, size_t __refs = 0);360 361protected:362    ~collate_byname();363    virtual int do_compare(const char_type* __lo1, const char_type* __hi1,364                           const char_type* __lo2, const char_type* __hi2) const;365    virtual string_type do_transform(const char_type* __lo, const char_type* __hi) const;366};367 368template <>369class _LIBCUDACXX_TYPE_VIS collate_byname<wchar_t>370    : public collate<wchar_t>371{372    locale_t __l;373public:374    typedef wchar_t char_type;375    typedef basic_string<char_type> string_type;376 377    explicit collate_byname(const char* __n, size_t __refs = 0);378    explicit collate_byname(const string& __n, size_t __refs = 0);379 380protected:381    ~collate_byname();382 383    virtual int do_compare(const char_type* __lo1, const char_type* __hi1,384                           const char_type* __lo2, const char_type* __hi2) const;385    virtual string_type do_transform(const char_type* __lo, const char_type* __hi) const;386};387 388template <class _CharT, class _Traits, class _Allocator>389bool390locale::operator()(const basic_string<_CharT, _Traits, _Allocator>& __x,391                   const basic_string<_CharT, _Traits, _Allocator>& __y) const392{393    return _CUDA_VSTD::use_facet<_CUDA_VSTD::collate<_CharT> >(*this).compare(394                                       __x.data(), __x.data() + __x.size(),395                                       __y.data(), __y.data() + __y.size()) < 0;396}397 398// template <class charT> class ctype399 400class _LIBCUDACXX_TYPE_VIS ctype_base401{402public:403#if defined(__GLIBC__)404    typedef unsigned short mask;405    static const mask space  = _ISspace;406    static const mask print  = _ISprint;407    static const mask cntrl  = _IScntrl;408    static const mask upper  = _ISupper;409    static const mask lower  = _ISlower;410    static const mask alpha  = _ISalpha;411    static const mask digit  = _ISdigit;412    static const mask punct  = _ISpunct;413    static const mask xdigit = _ISxdigit;414    static const mask blank  = _ISblank;415#if defined(__mips__)416    static const mask __regex_word = static_cast<mask>(_ISbit(15));417#else418    static const mask __regex_word = 0x80;419#endif420#elif defined(_LIBCUDACXX_MSVCRT_LIKE)421    typedef unsigned short mask;422    static const mask space  = _SPACE;423    static const mask print  = _BLANK|_PUNCT|_ALPHA|_DIGIT;424    static const mask cntrl  = _CONTROL;425    static const mask upper  = _UPPER;426    static const mask lower  = _LOWER;427    static const mask alpha  = _ALPHA;428    static const mask digit  = _DIGIT;429    static const mask punct  = _PUNCT;430    static const mask xdigit = _HEX;431    static const mask blank  = _BLANK;432    static const mask __regex_word = 0x80;433# define _LIBCUDACXX_CTYPE_MASK_IS_COMPOSITE_PRINT434#elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__)435# ifdef __APPLE__436    typedef __uint32_t mask;437# elif defined(__FreeBSD__)438    typedef unsigned long mask;439# elif defined(__EMSCRIPTEN__) || defined(__NetBSD__)440    typedef unsigned short mask;441# endif442    static const mask space  = _CTYPE_S;443    static const mask print  = _CTYPE_R;444    static const mask cntrl  = _CTYPE_C;445    static const mask upper  = _CTYPE_U;446    static const mask lower  = _CTYPE_L;447    static const mask alpha  = _CTYPE_A;448    static const mask digit  = _CTYPE_D;449    static const mask punct  = _CTYPE_P;450    static const mask xdigit = _CTYPE_X;451 452# if defined(__NetBSD__)453    static const mask blank  = _CTYPE_BL;454    // NetBSD defines classes up to 0x2000455    // see sys/ctype_bits.h, _CTYPE_Q456    static const mask __regex_word = 0x8000;457# else458    static const mask blank  = _CTYPE_B;459    static const mask __regex_word = 0x80;460# endif461#elif defined(__sun__) || defined(_AIX)462    typedef unsigned int mask;463    static const mask space  = _ISSPACE;464    static const mask print  = _ISPRINT;465    static const mask cntrl  = _ISCNTRL;466    static const mask upper  = _ISUPPER;467    static const mask lower  = _ISLOWER;468    static const mask alpha  = _ISALPHA;469    static const mask digit  = _ISDIGIT;470    static const mask punct  = _ISPUNCT;471    static const mask xdigit = _ISXDIGIT;472    static const mask blank  = _ISBLANK;473    static const mask __regex_word = 0x80;474#elif defined(_NEWLIB_VERSION)475    // Same type as Newlib's _ctype_ array in newlib/libc/include/ctype.h.476    typedef char mask;477    static const mask space  = _S;478    static const mask print  = _P | _U | _L | _N | _B;479    static const mask cntrl  = _C;480    static const mask upper  = _U;481    static const mask lower  = _L;482    static const mask alpha  = _U | _L;483    static const mask digit  = _N;484    static const mask punct  = _P;485    static const mask xdigit = _X | _N;486    static const mask blank  = _B;487    static const mask __regex_word = 0x80;488# define _LIBCUDACXX_CTYPE_MASK_IS_COMPOSITE_PRINT489# define _LIBCUDACXX_CTYPE_MASK_IS_COMPOSITE_ALPHA490# define _LIBCUDACXX_CTYPE_MASK_IS_COMPOSITE_XDIGIT491#else492    typedef unsigned long mask;493    static const mask space  = 1<<0;494    static const mask print  = 1<<1;495    static const mask cntrl  = 1<<2;496    static const mask upper  = 1<<3;497    static const mask lower  = 1<<4;498    static const mask alpha  = 1<<5;499    static const mask digit  = 1<<6;500    static const mask punct  = 1<<7;501    static const mask xdigit = 1<<8;502    static const mask blank  = 1<<9;503    static const mask __regex_word = 1<<10;504#endif505    static const mask alnum  = alpha | digit;506    static const mask graph  = alnum | punct;507 508    _LIBCUDACXX_INLINE_VISIBILITY ctype_base() {}509};510 511template <class _CharT> class _LIBCUDACXX_TEMPLATE_VIS ctype;512 513template <>514class _LIBCUDACXX_TYPE_VIS ctype<wchar_t>515    : public locale::facet,516      public ctype_base517{518public:519    typedef wchar_t char_type;520 521    _LIBCUDACXX_INLINE_VISIBILITY522    explicit ctype(size_t __refs = 0)523        : locale::facet(__refs) {}524 525    _LIBCUDACXX_INLINE_VISIBILITY526    bool is(mask __m, char_type __c) const527    {528        return do_is(__m, __c);529    }530 531    _LIBCUDACXX_INLINE_VISIBILITY532    const char_type* is(const char_type* __low, const char_type* __high, mask* __vec) const533    {534        return do_is(__low, __high, __vec);535    }536 537    _LIBCUDACXX_INLINE_VISIBILITY538    const char_type* scan_is(mask __m, const char_type* __low, const char_type* __high) const539    {540        return do_scan_is(__m, __low, __high);541    }542 543    _LIBCUDACXX_INLINE_VISIBILITY544    const char_type* scan_not(mask __m, const char_type* __low, const char_type* __high) const545    {546        return do_scan_not(__m, __low, __high);547    }548 549    _LIBCUDACXX_INLINE_VISIBILITY550    char_type toupper(char_type __c) const551    {552        return do_toupper(__c);553    }554 555    _LIBCUDACXX_INLINE_VISIBILITY556    const char_type* toupper(char_type* __low, const char_type* __high) const557    {558        return do_toupper(__low, __high);559    }560 561    _LIBCUDACXX_INLINE_VISIBILITY562    char_type tolower(char_type __c) const563    {564        return do_tolower(__c);565    }566 567    _LIBCUDACXX_INLINE_VISIBILITY568    const char_type* tolower(char_type* __low, const char_type* __high) const569    {570        return do_tolower(__low, __high);571    }572 573    _LIBCUDACXX_INLINE_VISIBILITY574    char_type widen(char __c) const575    {576        return do_widen(__c);577    }578 579    _LIBCUDACXX_INLINE_VISIBILITY580    const char* widen(const char* __low, const char* __high, char_type* __to) const581    {582        return do_widen(__low, __high, __to);583    }584 585    _LIBCUDACXX_INLINE_VISIBILITY586    char narrow(char_type __c, char __dfault) const587    {588        return do_narrow(__c, __dfault);589    }590 591    _LIBCUDACXX_INLINE_VISIBILITY592    const char_type* narrow(const char_type* __low, const char_type* __high, char __dfault, char* __to) const593    {594        return do_narrow(__low, __high, __dfault, __to);595    }596 597    static locale::id id;598 599protected:600    ~ctype();601    virtual bool do_is(mask __m, char_type __c) const;602    virtual const char_type* do_is(const char_type* __low, const char_type* __high, mask* __vec) const;603    virtual const char_type* do_scan_is(mask __m, const char_type* __low, const char_type* __high) const;604    virtual const char_type* do_scan_not(mask __m, const char_type* __low, const char_type* __high) const;605    virtual char_type do_toupper(char_type) const;606    virtual const char_type* do_toupper(char_type* __low, const char_type* __high) const;607    virtual char_type do_tolower(char_type) const;608    virtual const char_type* do_tolower(char_type* __low, const char_type* __high) const;609    virtual char_type do_widen(char) const;610    virtual const char* do_widen(const char* __low, const char* __high, char_type* __dest) const;611    virtual char do_narrow(char_type, char __dfault) const;612    virtual const char_type* do_narrow(const char_type* __low, const char_type* __high, char __dfault, char* __dest) const;613};614 615template <>616class _LIBCUDACXX_TYPE_VIS ctype<char>617    : public locale::facet, public ctype_base618{619    const mask* __tab_;620    bool        __del_;621public:622    typedef char char_type;623 624    explicit ctype(const mask* __tab = 0, bool __del = false, size_t __refs = 0);625 626    _LIBCUDACXX_INLINE_VISIBILITY627    bool is(mask __m, char_type __c) const628    {629        return isascii(__c) ? (__tab_[static_cast<int>(__c)] & __m) !=0 : false;630    }631 632    _LIBCUDACXX_INLINE_VISIBILITY633    const char_type* is(const char_type* __low, const char_type* __high, mask* __vec) const634    {635        for (; __low != __high; ++__low, ++__vec)636            *__vec = isascii(*__low) ? __tab_[static_cast<int>(*__low)] : 0;637        return __low;638    }639 640    _LIBCUDACXX_INLINE_VISIBILITY641    const char_type* scan_is (mask __m, const char_type* __low, const char_type* __high) const642    {643        for (; __low != __high; ++__low)644            if (isascii(*__low) && (__tab_[static_cast<int>(*__low)] & __m))645                break;646        return __low;647    }648 649    _LIBCUDACXX_INLINE_VISIBILITY650    const char_type* scan_not(mask __m, const char_type* __low, const char_type* __high) const651    {652        for (; __low != __high; ++__low)653            if (!(isascii(*__low) && (__tab_[static_cast<int>(*__low)] & __m)))654                break;655        return __low;656    }657 658    _LIBCUDACXX_INLINE_VISIBILITY659    char_type toupper(char_type __c) const660    {661        return do_toupper(__c);662    }663 664    _LIBCUDACXX_INLINE_VISIBILITY665    const char_type* toupper(char_type* __low, const char_type* __high) const666    {667        return do_toupper(__low, __high);668    }669 670    _LIBCUDACXX_INLINE_VISIBILITY671    char_type tolower(char_type __c) const672    {673        return do_tolower(__c);674    }675 676    _LIBCUDACXX_INLINE_VISIBILITY677    const char_type* tolower(char_type* __low, const char_type* __high) const678    {679        return do_tolower(__low, __high);680    }681 682    _LIBCUDACXX_INLINE_VISIBILITY683    char_type widen(char __c) const684    {685        return do_widen(__c);686    }687 688    _LIBCUDACXX_INLINE_VISIBILITY689    const char* widen(const char* __low, const char* __high, char_type* __to) const690    {691        return do_widen(__low, __high, __to);692    }693 694    _LIBCUDACXX_INLINE_VISIBILITY695    char narrow(char_type __c, char __dfault) const696    {697        return do_narrow(__c, __dfault);698    }699 700    _LIBCUDACXX_INLINE_VISIBILITY701    const char* narrow(const char_type* __low, const char_type* __high, char __dfault, char* __to) const702    {703        return do_narrow(__low, __high, __dfault, __to);704    }705 706    static locale::id id;707 708#ifdef _CACHED_RUNES709    static const size_t table_size = _CACHED_RUNES;710#else711    static const size_t table_size = 256;  // FIXME: Don't hardcode this.712#endif713    _LIBCUDACXX_INLINE_VISIBILITY const mask* table() const  noexcept {return __tab_;}714    static const mask* classic_table()  noexcept;715#if defined(__GLIBC__) || defined(__EMSCRIPTEN__)716    static const int* __classic_upper_table() noexcept;717    static const int* __classic_lower_table() noexcept;718#endif719#if defined(__NetBSD__)720    static const short* __classic_upper_table() noexcept;721    static const short* __classic_lower_table() noexcept;722#endif723 724protected:725    ~ctype();726    virtual char_type do_toupper(char_type __c) const;727    virtual const char_type* do_toupper(char_type* __low, const char_type* __high) const;728    virtual char_type do_tolower(char_type __c) const;729    virtual const char_type* do_tolower(char_type* __low, const char_type* __high) const;730    virtual char_type do_widen(char __c) const;731    virtual const char* do_widen(const char* __low, const char* __high, char_type* __to) const;732    virtual char do_narrow(char_type __c, char __dfault) const;733    virtual const char* do_narrow(const char_type* __low, const char_type* __high, char __dfault, char* __to) const;734};735 736// template <class CharT> class ctype_byname;737 738template <class _CharT> class _LIBCUDACXX_TEMPLATE_VIS ctype_byname;739 740template <>741class _LIBCUDACXX_TYPE_VIS ctype_byname<char>742    : public ctype<char>743{744    locale_t __l;745 746public:747    explicit ctype_byname(const char*, size_t = 0);748    explicit ctype_byname(const string&, size_t = 0);749 750protected:751    ~ctype_byname();752    virtual char_type do_toupper(char_type) const;753    virtual const char_type* do_toupper(char_type* __low, const char_type* __high) const;754    virtual char_type do_tolower(char_type) const;755    virtual const char_type* do_tolower(char_type* __low, const char_type* __high) const;756};757 758template <>759class _LIBCUDACXX_TYPE_VIS ctype_byname<wchar_t>760    : public ctype<wchar_t>761{762    locale_t __l;763 764public:765    explicit ctype_byname(const char*, size_t = 0);766    explicit ctype_byname(const string&, size_t = 0);767 768protected:769    ~ctype_byname();770    virtual bool do_is(mask __m, char_type __c) const;771    virtual const char_type* do_is(const char_type* __low, const char_type* __high, mask* __vec) const;772    virtual const char_type* do_scan_is(mask __m, const char_type* __low, const char_type* __high) const;773    virtual const char_type* do_scan_not(mask __m, const char_type* __low, const char_type* __high) const;774    virtual char_type do_toupper(char_type) const;775    virtual const char_type* do_toupper(char_type* __low, const char_type* __high) const;776    virtual char_type do_tolower(char_type) const;777    virtual const char_type* do_tolower(char_type* __low, const char_type* __high) const;778    virtual char_type do_widen(char) const;779    virtual const char* do_widen(const char* __low, const char* __high, char_type* __dest) const;780    virtual char do_narrow(char_type, char __dfault) const;781    virtual const char_type* do_narrow(const char_type* __low, const char_type* __high, char __dfault, char* __dest) const;782};783 784template <class _CharT>785inline _LIBCUDACXX_INLINE_VISIBILITY786bool787isspace(_CharT __c, const locale& __loc)788{789    return use_facet<ctype<_CharT> >(__loc).is(ctype_base::space, __c);790}791 792template <class _CharT>793inline _LIBCUDACXX_INLINE_VISIBILITY794bool795isprint(_CharT __c, const locale& __loc)796{797    return use_facet<ctype<_CharT> >(__loc).is(ctype_base::print, __c);798}799 800template <class _CharT>801inline _LIBCUDACXX_INLINE_VISIBILITY802bool803iscntrl(_CharT __c, const locale& __loc)804{805    return use_facet<ctype<_CharT> >(__loc).is(ctype_base::cntrl, __c);806}807 808template <class _CharT>809inline _LIBCUDACXX_INLINE_VISIBILITY810bool811isupper(_CharT __c, const locale& __loc)812{813    return use_facet<ctype<_CharT> >(__loc).is(ctype_base::upper, __c);814}815 816template <class _CharT>817inline _LIBCUDACXX_INLINE_VISIBILITY818bool819islower(_CharT __c, const locale& __loc)820{821    return use_facet<ctype<_CharT> >(__loc).is(ctype_base::lower, __c);822}823 824template <class _CharT>825inline _LIBCUDACXX_INLINE_VISIBILITY826bool827isalpha(_CharT __c, const locale& __loc)828{829    return use_facet<ctype<_CharT> >(__loc).is(ctype_base::alpha, __c);830}831 832template <class _CharT>833inline _LIBCUDACXX_INLINE_VISIBILITY834bool835isdigit(_CharT __c, const locale& __loc)836{837    return use_facet<ctype<_CharT> >(__loc).is(ctype_base::digit, __c);838}839 840template <class _CharT>841inline _LIBCUDACXX_INLINE_VISIBILITY842bool843ispunct(_CharT __c, const locale& __loc)844{845    return use_facet<ctype<_CharT> >(__loc).is(ctype_base::punct, __c);846}847 848template <class _CharT>849inline _LIBCUDACXX_INLINE_VISIBILITY850bool851isxdigit(_CharT __c, const locale& __loc)852{853    return use_facet<ctype<_CharT> >(__loc).is(ctype_base::xdigit, __c);854}855 856template <class _CharT>857inline _LIBCUDACXX_INLINE_VISIBILITY858bool859isalnum(_CharT __c, const locale& __loc)860{861    return use_facet<ctype<_CharT> >(__loc).is(ctype_base::alnum, __c);862}863 864template <class _CharT>865inline _LIBCUDACXX_INLINE_VISIBILITY866bool867isgraph(_CharT __c, const locale& __loc)868{869    return use_facet<ctype<_CharT> >(__loc).is(ctype_base::graph, __c);870}871 872template <class _CharT>873inline _LIBCUDACXX_INLINE_VISIBILITY874_CharT875toupper(_CharT __c, const locale& __loc)876{877    return use_facet<ctype<_CharT> >(__loc).toupper(__c);878}879 880template <class _CharT>881inline _LIBCUDACXX_INLINE_VISIBILITY882_CharT883tolower(_CharT __c, const locale& __loc)884{885    return use_facet<ctype<_CharT> >(__loc).tolower(__c);886}887 888// codecvt_base889 890class _LIBCUDACXX_TYPE_VIS codecvt_base891{892public:893    _LIBCUDACXX_INLINE_VISIBILITY codecvt_base() {}894    enum result {ok, partial, error, noconv};895};896 897// template <class internT, class externT, class stateT> class codecvt;898 899template <class _InternT, class _ExternT, class _StateT> class _LIBCUDACXX_TEMPLATE_VIS codecvt;900 901// template <> class codecvt<char, char, mbstate_t>902 903template <>904class _LIBCUDACXX_TYPE_VIS codecvt<char, char, mbstate_t>905    : public locale::facet,906      public codecvt_base907{908public:909    typedef char      intern_type;910    typedef char      extern_type;911    typedef mbstate_t state_type;912 913    _LIBCUDACXX_INLINE_VISIBILITY914    explicit codecvt(size_t __refs = 0)915        : locale::facet(__refs) {}916 917    _LIBCUDACXX_INLINE_VISIBILITY918    result out(state_type& __st,919               const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,920               extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const921    {922        return do_out(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);923    }924 925    _LIBCUDACXX_INLINE_VISIBILITY926    result unshift(state_type& __st,927                   extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const928    {929        return do_unshift(__st, __to, __to_end, __to_nxt);930    }931 932    _LIBCUDACXX_INLINE_VISIBILITY933    result in(state_type& __st,934              const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,935              intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const936    {937        return do_in(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);938    }939 940    _LIBCUDACXX_INLINE_VISIBILITY941    int encoding() const  noexcept942    {943        return do_encoding();944    }945 946    _LIBCUDACXX_INLINE_VISIBILITY947    bool always_noconv() const  noexcept948    {949        return do_always_noconv();950    }951 952    _LIBCUDACXX_INLINE_VISIBILITY953    int length(state_type& __st, const extern_type* __frm, const extern_type* __end, size_t __mx) const954    {955        return do_length(__st, __frm, __end, __mx);956    }957 958    _LIBCUDACXX_INLINE_VISIBILITY959    int max_length() const  noexcept960    {961        return do_max_length();962    }963 964    static locale::id id;965 966protected:967    _LIBCUDACXX_INLINE_VISIBILITY968    explicit codecvt(const char*, size_t __refs = 0)969        : locale::facet(__refs) {}970 971    ~codecvt();972 973    virtual result do_out(state_type& __st,974                          const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,975                          extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;976    virtual result do_in(state_type& __st,977                         const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,978                         intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;979    virtual result do_unshift(state_type& __st,980                              extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;981    virtual int do_encoding() const  noexcept;982    virtual bool do_always_noconv() const  noexcept;983    virtual int do_length(state_type& __st, const extern_type* __frm, const extern_type* __end, size_t __mx) const;984    virtual int do_max_length() const  noexcept;985};986 987// template <> class codecvt<wchar_t, char, mbstate_t>988 989template <>990class _LIBCUDACXX_TYPE_VIS codecvt<wchar_t, char, mbstate_t>991    : public locale::facet,992      public codecvt_base993{994    locale_t __l;995public:996    typedef wchar_t   intern_type;997    typedef char      extern_type;998    typedef mbstate_t state_type;999 1000    explicit codecvt(size_t __refs = 0);1001 1002    _LIBCUDACXX_INLINE_VISIBILITY1003    result out(state_type& __st,1004               const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,1005               extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const1006    {1007        return do_out(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);1008    }1009 1010    _LIBCUDACXX_INLINE_VISIBILITY1011    result unshift(state_type& __st,1012                   extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const1013    {1014        return do_unshift(__st, __to, __to_end, __to_nxt);1015    }1016 1017    _LIBCUDACXX_INLINE_VISIBILITY1018    result in(state_type& __st,1019              const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,1020              intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const1021    {1022        return do_in(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);1023    }1024 1025    _LIBCUDACXX_INLINE_VISIBILITY1026    int encoding() const  noexcept1027    {1028        return do_encoding();1029    }1030 1031    _LIBCUDACXX_INLINE_VISIBILITY1032    bool always_noconv() const  noexcept1033    {1034        return do_always_noconv();1035    }1036 1037    _LIBCUDACXX_INLINE_VISIBILITY1038    int length(state_type& __st, const extern_type* __frm, const extern_type* __end, size_t __mx) const1039    {1040        return do_length(__st, __frm, __end, __mx);1041    }1042 1043    _LIBCUDACXX_INLINE_VISIBILITY1044    int max_length() const  noexcept1045    {1046        return do_max_length();1047    }1048 1049    static locale::id id;1050 1051protected:1052    explicit codecvt(const char*, size_t __refs = 0);1053 1054    ~codecvt();1055 1056    virtual result do_out(state_type& __st,1057                          const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,1058                          extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;1059    virtual result do_in(state_type& __st,1060                         const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,1061                         intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;1062    virtual result do_unshift(state_type& __st,1063                              extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;1064    virtual int do_encoding() const  noexcept;1065    virtual bool do_always_noconv() const  noexcept;1066    virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const;1067    virtual int do_max_length() const  noexcept;1068};1069 1070// template <> class codecvt<char16_t, char, mbstate_t>1071 1072template <>1073class _LIBCUDACXX_TYPE_VIS codecvt<char16_t, char, mbstate_t>1074    : public locale::facet,1075      public codecvt_base1076{1077public:1078    typedef char16_t  intern_type;1079    typedef char      extern_type;1080    typedef mbstate_t state_type;1081 1082    _LIBCUDACXX_INLINE_VISIBILITY1083    explicit codecvt(size_t __refs = 0)1084        : locale::facet(__refs) {}1085 1086    _LIBCUDACXX_INLINE_VISIBILITY1087    result out(state_type& __st,1088               const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,1089               extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const1090    {1091        return do_out(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);1092    }1093 1094    _LIBCUDACXX_INLINE_VISIBILITY1095    result unshift(state_type& __st,1096                   extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const1097    {1098        return do_unshift(__st, __to, __to_end, __to_nxt);1099    }1100 1101    _LIBCUDACXX_INLINE_VISIBILITY1102    result in(state_type& __st,1103              const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,1104              intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const1105    {1106        return do_in(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);1107    }1108 1109    _LIBCUDACXX_INLINE_VISIBILITY1110    int encoding() const  noexcept1111    {1112        return do_encoding();1113    }1114 1115    _LIBCUDACXX_INLINE_VISIBILITY1116    bool always_noconv() const  noexcept1117    {1118        return do_always_noconv();1119    }1120 1121    _LIBCUDACXX_INLINE_VISIBILITY1122    int length(state_type& __st, const extern_type* __frm, const extern_type* __end, size_t __mx) const1123    {1124        return do_length(__st, __frm, __end, __mx);1125    }1126 1127    _LIBCUDACXX_INLINE_VISIBILITY1128    int max_length() const  noexcept1129    {1130        return do_max_length();1131    }1132 1133    static locale::id id;1134 1135protected:1136    _LIBCUDACXX_INLINE_VISIBILITY1137    explicit codecvt(const char*, size_t __refs = 0)1138        : locale::facet(__refs) {}1139 1140    ~codecvt();1141 1142    virtual result do_out(state_type& __st,1143                          const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,1144                          extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;1145    virtual result do_in(state_type& __st,1146                         const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,1147                         intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;1148    virtual result do_unshift(state_type& __st,1149                              extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;1150    virtual int do_encoding() const  noexcept;1151    virtual bool do_always_noconv() const  noexcept;1152    virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const;1153    virtual int do_max_length() const  noexcept;1154};1155 1156// template <> class codecvt<char32_t, char, mbstate_t>1157 1158template <>1159class _LIBCUDACXX_TYPE_VIS codecvt<char32_t, char, mbstate_t>1160    : public locale::facet,1161      public codecvt_base1162{1163public:1164    typedef char32_t  intern_type;1165    typedef char      extern_type;1166    typedef mbstate_t state_type;1167 1168    _LIBCUDACXX_INLINE_VISIBILITY1169    explicit codecvt(size_t __refs = 0)1170        : locale::facet(__refs) {}1171 1172    _LIBCUDACXX_INLINE_VISIBILITY1173    result out(state_type& __st,1174               const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,1175               extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const1176    {1177        return do_out(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);1178    }1179 1180    _LIBCUDACXX_INLINE_VISIBILITY1181    result unshift(state_type& __st,1182                   extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const1183    {1184        return do_unshift(__st, __to, __to_end, __to_nxt);1185    }1186 1187    _LIBCUDACXX_INLINE_VISIBILITY1188    result in(state_type& __st,1189              const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,1190              intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const1191    {1192        return do_in(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);1193    }1194 1195    _LIBCUDACXX_INLINE_VISIBILITY1196    int encoding() const  noexcept1197    {1198        return do_encoding();1199    }1200 

Showing the first 1,200 of 1558 lines. Download the file for the rest.

codekingpro/portable-devtools · Team Ai