chromium/third_party/libc++/src/include/__locale

// -*- C++ -*-
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#ifndef _LIBCPP___LOCALE
#define _LIBCPP___LOCALE

#include <__config>
#include <__locale_dir/locale_base_api.h>
#include <__memory/shared_ptr.h> // __shared_count
#include <__mutex/once_flag.h>
#include <__type_traits/make_unsigned.h>
#include <__utility/no_destroy.h>
#include <__utility/private_constructor_tag.h>
#include <cctype>
#include <clocale>
#include <cstdint>
#include <cstdlib>
#include <string>

// Some platforms require more includes than others. Keep the includes on all plaforms for now.
#include <cstddef>
#include <cstring>

#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
#  include <cwchar>
#else
#  include <__std_mbstate_t.h>
#endif

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#  pragma GCC system_header
#endif

_LIBCPP_BEGIN_NAMESPACE_STD

class _LIBCPP_EXPORTED_FROM_ABI locale;

template <class _Facet>
_LIBCPP_HIDE_FROM_ABI bool has_facet(const locale&) _NOEXCEPT;

template <class _Facet>
_LIBCPP_HIDE_FROM_ABI const _Facet& use_facet(const locale&);

class _LIBCPP_EXPORTED_FROM_ABI locale {};

class _LIBCPP_EXPORTED_FROM_ABI locale::facet : public __shared_count {};

class _LIBCPP_EXPORTED_FROM_ABI locale::id {};

template <class _Facet>
inline _LIBCPP_HIDE_FROM_ABI locale::locale(const locale& __other, _Facet* __f) {}

template <class _Facet>
locale locale::combine(const locale& __other) const {}

template <class _Facet>
inline _LIBCPP_HIDE_FROM_ABI bool has_facet(const locale& __l) _NOEXCEPT {}

template <class _Facet>
inline _LIBCPP_HIDE_FROM_ABI const _Facet& use_facet(const locale& __l) {}

// template <class _CharT> class collate;

template <class _CharT>
class _LIBCPP_TEMPLATE_VIS collate : public locale::facet {};

template <class _CharT>
locale::id collate<_CharT>::id;

template <class _CharT>
collate<_CharT>::~collate() {}

template <class _CharT>
int collate<_CharT>::do_compare(
    const char_type* __lo1, const char_type* __hi1, const char_type* __lo2, const char_type* __hi2) const {}

template <class _CharT>
long collate<_CharT>::do_hash(const char_type* __lo, const char_type* __hi) const {}

extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS collate<char>;
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS collate<wchar_t>;
#endif

// template <class CharT> class collate_byname;

template <class _CharT>
class _LIBCPP_TEMPLATE_VIS collate_byname;

template <>
class _LIBCPP_EXPORTED_FROM_ABI collate_byname<char> : public collate<char> {};

#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
template <>
class _LIBCPP_EXPORTED_FROM_ABI collate_byname<wchar_t> : public collate<wchar_t> {};
#endif

template <class _CharT, class _Traits, class _Allocator>
bool locale::operator()(const basic_string<_CharT, _Traits, _Allocator>& __x,
                        const basic_string<_CharT, _Traits, _Allocator>& __y) const {}

// template <class charT> class ctype

class _LIBCPP_EXPORTED_FROM_ABI ctype_base {};

template <class _CharT>
class _LIBCPP_TEMPLATE_VIS ctype;

#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
template <>
class _LIBCPP_EXPORTED_FROM_ABI ctype<wchar_t> : public locale::facet, public ctype_base {};
#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS

template <>
class _LIBCPP_EXPORTED_FROM_ABI ctype<char> : public locale::facet, public ctype_base {};

// template <class CharT> class ctype_byname;

template <class _CharT>
class _LIBCPP_TEMPLATE_VIS ctype_byname;

template <>
class _LIBCPP_EXPORTED_FROM_ABI ctype_byname<char> : public ctype<char> {};

#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
template <>
class _LIBCPP_EXPORTED_FROM_ABI ctype_byname<wchar_t> : public ctype<wchar_t> {};
#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS

template <class _CharT>
inline _LIBCPP_HIDE_FROM_ABI bool isspace(_CharT __c, const locale& __loc) {}

template <class _CharT>
inline _LIBCPP_HIDE_FROM_ABI bool isprint(_CharT __c, const locale& __loc) {}

template <class _CharT>
inline _LIBCPP_HIDE_FROM_ABI bool iscntrl(_CharT __c, const locale& __loc) {}

template <class _CharT>
inline _LIBCPP_HIDE_FROM_ABI bool isupper(_CharT __c, const locale& __loc) {}

template <class _CharT>
inline _LIBCPP_HIDE_FROM_ABI bool islower(_CharT __c, const locale& __loc) {}

template <class _CharT>
inline _LIBCPP_HIDE_FROM_ABI bool isalpha(_CharT __c, const locale& __loc) {}

template <class _CharT>
inline _LIBCPP_HIDE_FROM_ABI bool isdigit(_CharT __c, const locale& __loc) {}

template <class _CharT>
inline _LIBCPP_HIDE_FROM_ABI bool ispunct(_CharT __c, const locale& __loc) {}

template <class _CharT>
inline _LIBCPP_HIDE_FROM_ABI bool isxdigit(_CharT __c, const locale& __loc) {}

template <class _CharT>
inline _LIBCPP_HIDE_FROM_ABI bool isalnum(_CharT __c, const locale& __loc) {}

template <class _CharT>
inline _LIBCPP_HIDE_FROM_ABI bool isgraph(_CharT __c, const locale& __loc) {}

template <class _CharT>
_LIBCPP_HIDE_FROM_ABI bool isblank(_CharT __c, const locale& __loc) {}

template <class _CharT>
inline _LIBCPP_HIDE_FROM_ABI _CharT toupper(_CharT __c, const locale& __loc) {}

template <class _CharT>
inline _LIBCPP_HIDE_FROM_ABI _CharT tolower(_CharT __c, const locale& __loc) {}

// codecvt_base

class _LIBCPP_EXPORTED_FROM_ABI codecvt_base {};

// template <class internT, class externT, class stateT> class codecvt;

template <class _InternT, class _ExternT, class _StateT>
class _LIBCPP_TEMPLATE_VIS codecvt;

// template <> class codecvt<char, char, mbstate_t>

template <>
class _LIBCPP_EXPORTED_FROM_ABI codecvt<char, char, mbstate_t> : public locale::facet, public codecvt_base {};

// template <> class codecvt<wchar_t, char, mbstate_t>

#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
template <>
class _LIBCPP_EXPORTED_FROM_ABI codecvt<wchar_t, char, mbstate_t> : public locale::facet, public codecvt_base {};
#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS

// template <> class codecvt<char16_t, char, mbstate_t> // deprecated in C++20

template <>
class _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_EXPORTED_FROM_ABI codecvt<char16_t, char, mbstate_t>
    : public locale::facet, public codecvt_base {};

#ifndef _LIBCPP_HAS_NO_CHAR8_T

// template <> class codecvt<char16_t, char8_t, mbstate_t> // C++20

template <>
class _LIBCPP_EXPORTED_FROM_ABI codecvt<char16_t, char8_t, mbstate_t> : public locale::facet, public codecvt_base {};

#endif

// template <> class codecvt<char32_t, char, mbstate_t> // deprecated in C++20

template <>
class _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_EXPORTED_FROM_ABI codecvt<char32_t, char, mbstate_t>
    : public locale::facet, public codecvt_base {};

#ifndef _LIBCPP_HAS_NO_CHAR8_T

// template <> class codecvt<char32_t, char8_t, mbstate_t> // C++20

template <>
class _LIBCPP_EXPORTED_FROM_ABI codecvt<char32_t, char8_t, mbstate_t> : public locale::facet, public codecvt_base {};

#endif

// template <class _InternT, class _ExternT, class _StateT> class codecvt_byname

template <class _InternT, class _ExternT, class _StateT>
class _LIBCPP_TEMPLATE_VIS codecvt_byname : public codecvt<_InternT, _ExternT, _StateT> {};

_LIBCPP_SUPPRESS_DEPRECATED_PUSH
template <class _InternT, class _ExternT, class _StateT>
codecvt_byname<_InternT, _ExternT, _StateT>::~codecvt_byname() {}
_LIBCPP_SUPPRESS_DEPRECATED_POP

extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char, char, mbstate_t>;
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<wchar_t, char, mbstate_t>;
#endif
extern template class _LIBCPP_DEPRECATED_IN_CXX20
_LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char16_t, char, mbstate_t>; // deprecated in C++20
extern template class _LIBCPP_DEPRECATED_IN_CXX20
_LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char32_t, char, mbstate_t>; // deprecated in C++20
#ifndef _LIBCPP_HAS_NO_CHAR8_T
extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char16_t, char8_t, mbstate_t>; // C++20
extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char32_t, char8_t, mbstate_t>; // C++20
#endif

template <size_t _Np>
struct __narrow_to_utf8 {};

template <>
struct __narrow_to_utf8<8> {};

_LIBCPP_SUPPRESS_DEPRECATED_PUSH
template <>
struct _LIBCPP_EXPORTED_FROM_ABI __narrow_to_utf8<16> : public codecvt<char16_t, char, mbstate_t> {};

_LIBCPP_SUPPRESS_DEPRECATED_PUSH
template <>
struct _LIBCPP_EXPORTED_FROM_ABI __narrow_to_utf8<32> : public codecvt<char32_t, char, mbstate_t> {};

template <size_t _Np>
struct __widen_from_utf8 {};

template <>
struct __widen_from_utf8<8> {};

_LIBCPP_SUPPRESS_DEPRECATED_PUSH
template <>
struct _LIBCPP_EXPORTED_FROM_ABI __widen_from_utf8<16> : public codecvt<char16_t, char, mbstate_t> {};

_LIBCPP_SUPPRESS_DEPRECATED_PUSH
template <>
struct _LIBCPP_EXPORTED_FROM_ABI __widen_from_utf8<32> : public codecvt<char32_t, char, mbstate_t> {};

// template <class charT> class numpunct

template <class _CharT>
class _LIBCPP_TEMPLATE_VIS numpunct;

template <>
class _LIBCPP_EXPORTED_FROM_ABI numpunct<char> : public locale::facet {};

#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
template <>
class _LIBCPP_EXPORTED_FROM_ABI numpunct<wchar_t> : public locale::facet {};
#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS

// template <class charT> class numpunct_byname

template <class _CharT>
class _LIBCPP_TEMPLATE_VIS numpunct_byname;

template <>
class _LIBCPP_EXPORTED_FROM_ABI numpunct_byname<char> : public numpunct<char> {};

#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
template <>
class _LIBCPP_EXPORTED_FROM_ABI numpunct_byname<wchar_t> : public numpunct<wchar_t> {};
#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS

_LIBCPP_END_NAMESPACE_STD

#endif // _LIBCPP___LOCALE