2010-05-11 19:42:16 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
2019-01-19 10:56:40 +00:00
|
|
|
// 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
|
2010-05-11 19:42:16 +00:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef _LIBCPP___LOCALE
|
|
|
|
#define _LIBCPP___LOCALE
|
|
|
|
|
2020-11-04 20:01:25 +00:00
|
|
|
#include <__availability>
|
2021-05-19 15:57:04 +00:00
|
|
|
#include <__config>
|
2023-05-07 00:26:49 +00:00
|
|
|
#include <__type_traits/make_unsigned.h>
|
2010-05-11 19:42:16 +00:00
|
|
|
#include <cctype>
|
2023-03-04 01:37:37 +00:00
|
|
|
#include <clocale>
|
2022-01-07 14:45:05 +00:00
|
|
|
#include <cstdint>
|
2023-01-08 15:47:53 +00:00
|
|
|
#include <cstdlib>
|
2022-01-07 14:45:05 +00:00
|
|
|
#include <mutex>
|
|
|
|
#include <string>
|
2022-03-05 18:17:07 +00:00
|
|
|
|
2022-09-22 19:53:13 +00:00
|
|
|
// Some platforms require more includes than others. Keep the includes on all plaforms for now.
|
|
|
|
#include <cstddef>
|
|
|
|
#include <cstring>
|
|
|
|
|
2023-03-04 01:37:37 +00:00
|
|
|
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
|
|
|
|
# include <cwchar>
|
2023-04-17 16:38:38 +00:00
|
|
|
#else
|
|
|
|
# include <__std_mbstate_t.h>
|
2023-03-04 01:37:37 +00:00
|
|
|
#endif
|
|
|
|
|
2017-05-31 22:14:05 +00:00
|
|
|
#if defined(_LIBCPP_MSVCRT_LIKE)
|
2021-02-02 21:58:38 +00:00
|
|
|
# include <__support/win32/locale_win32.h>
|
2020-11-10 14:54:03 +00:00
|
|
|
#elif defined(_AIX) || defined(__MVS__)
|
2021-02-02 21:58:38 +00:00
|
|
|
# include <__support/ibm/xlocale.h>
|
2014-07-10 15:20:28 +00:00
|
|
|
#elif defined(__ANDROID__)
|
2021-02-02 21:58:38 +00:00
|
|
|
# include <__support/android/locale_bionic.h>
|
2014-12-12 08:36:16 +00:00
|
|
|
#elif defined(_NEWLIB_VERSION)
|
2021-02-02 21:58:38 +00:00
|
|
|
# include <__support/newlib/xlocale.h>
|
2021-01-12 19:16:15 +00:00
|
|
|
#elif defined(__OpenBSD__)
|
2021-02-02 21:58:38 +00:00
|
|
|
# include <__support/openbsd/xlocale.h>
|
2022-07-11 15:05:42 +00:00
|
|
|
#elif (defined(__APPLE__) || defined(__FreeBSD__))
|
2011-09-22 19:10:18 +00:00
|
|
|
# include <xlocale.h>
|
2017-04-13 21:29:21 +00:00
|
|
|
#elif defined(__Fuchsia__)
|
2021-02-02 21:58:38 +00:00
|
|
|
# include <__support/fuchsia/xlocale.h>
|
2019-05-01 16:47:30 +00:00
|
|
|
#elif defined(__wasi__)
|
|
|
|
// WASI libc uses musl's locales support.
|
2021-02-02 21:58:38 +00:00
|
|
|
# include <__support/musl/xlocale.h>
|
2015-11-09 10:21:04 +00:00
|
|
|
#elif defined(_LIBCPP_HAS_MUSL_LIBC)
|
2021-02-02 21:58:38 +00:00
|
|
|
# include <__support/musl/xlocale.h>
|
2017-04-13 21:29:21 +00:00
|
|
|
#endif
|
2010-05-11 19:42:16 +00:00
|
|
|
|
2011-10-17 20:05:10 +00:00
|
|
|
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
2022-02-02 01:16:40 +00:00
|
|
|
# pragma GCC system_header
|
2011-10-17 20:05:10 +00:00
|
|
|
#endif
|
2010-05-11 19:42:16 +00:00
|
|
|
|
|
|
|
_LIBCPP_BEGIN_NAMESPACE_STD
|
|
|
|
|
2023-06-14 17:17:50 +00:00
|
|
|
class _LIBCPP_EXPORTED_FROM_ABI locale;
|
2010-05-11 19:42:16 +00:00
|
|
|
|
2012-09-14 00:39:16 +00:00
|
|
|
template <class _Facet>
|
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
|
|
|
bool
|
|
|
|
has_facet(const locale&) _NOEXCEPT;
|
|
|
|
|
|
|
|
template <class _Facet>
|
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
|
|
|
const _Facet&
|
|
|
|
use_facet(const locale&);
|
2010-05-11 19:42:16 +00:00
|
|
|
|
2023-06-14 17:17:50 +00:00
|
|
|
class _LIBCPP_EXPORTED_FROM_ABI locale
|
2010-05-11 19:42:16 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
// types:
|
2023-06-14 17:17:50 +00:00
|
|
|
class _LIBCPP_EXPORTED_FROM_ABI facet;
|
|
|
|
class _LIBCPP_EXPORTED_FROM_ABI id;
|
2010-05-11 19:42:16 +00:00
|
|
|
|
|
|
|
typedef int category;
|
2017-05-04 17:08:54 +00:00
|
|
|
_LIBCPP_AVAILABILITY_LOCALE_CATEGORY
|
2010-05-11 19:42:16 +00:00
|
|
|
static const category // values assigned here are for exposition only
|
|
|
|
none = 0,
|
|
|
|
collate = LC_COLLATE_MASK,
|
|
|
|
ctype = LC_CTYPE_MASK,
|
|
|
|
monetary = LC_MONETARY_MASK,
|
|
|
|
numeric = LC_NUMERIC_MASK,
|
|
|
|
time = LC_TIME_MASK,
|
|
|
|
messages = LC_MESSAGES_MASK,
|
|
|
|
all = collate | ctype | monetary | numeric | time | messages;
|
|
|
|
|
|
|
|
// construct/copy/destroy:
|
2011-05-31 15:34:58 +00:00
|
|
|
locale() _NOEXCEPT;
|
|
|
|
locale(const locale&) _NOEXCEPT;
|
2010-05-11 19:42:16 +00:00
|
|
|
explicit locale(const char*);
|
|
|
|
explicit locale(const string&);
|
|
|
|
locale(const locale&, const char*, category);
|
|
|
|
locale(const locale&, const string&, category);
|
2010-12-17 14:46:43 +00:00
|
|
|
template <class _Facet>
|
|
|
|
_LIBCPP_INLINE_VISIBILITY locale(const locale&, _Facet*);
|
2010-05-11 19:42:16 +00:00
|
|
|
locale(const locale&, const locale&, category);
|
|
|
|
|
2011-05-31 15:34:58 +00:00
|
|
|
~locale();
|
2010-05-11 19:42:16 +00:00
|
|
|
|
2011-05-31 15:34:58 +00:00
|
|
|
const locale& operator=(const locale&) _NOEXCEPT;
|
2010-05-11 19:42:16 +00:00
|
|
|
|
2017-03-02 03:22:18 +00:00
|
|
|
template <class _Facet>
|
|
|
|
_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
|
|
|
|
locale combine(const locale&) const;
|
2010-05-11 19:42:16 +00:00
|
|
|
|
|
|
|
// locale operations:
|
|
|
|
string name() const;
|
|
|
|
bool operator==(const locale&) const;
|
2023-06-11 19:17:19 +00:00
|
|
|
#if _LIBCPP_STD_VER <= 17
|
2023-01-23 09:27:14 +00:00
|
|
|
_LIBCPP_HIDE_FROM_ABI bool operator!=(const locale& __y) const {return !(*this == __y);}
|
2023-06-11 19:17:19 +00:00
|
|
|
#endif
|
2010-05-11 19:42:16 +00:00
|
|
|
template <class _CharT, class _Traits, class _Allocator>
|
2017-03-02 03:22:18 +00:00
|
|
|
_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
|
2010-05-11 19:42:16 +00:00
|
|
|
bool operator()(const basic_string<_CharT, _Traits, _Allocator>&,
|
|
|
|
const basic_string<_CharT, _Traits, _Allocator>&) const;
|
|
|
|
|
|
|
|
// global locale objects:
|
|
|
|
static locale global(const locale&);
|
|
|
|
static const locale& classic();
|
|
|
|
|
|
|
|
private:
|
|
|
|
class __imp;
|
|
|
|
__imp* __locale_;
|
|
|
|
|
|
|
|
void __install_ctor(const locale&, facet*, long);
|
|
|
|
static locale& __global();
|
|
|
|
bool has_facet(id&) const;
|
|
|
|
const facet* use_facet(id&) const;
|
|
|
|
|
2011-05-31 15:34:58 +00:00
|
|
|
template <class _Facet> friend bool has_facet(const locale&) _NOEXCEPT;
|
2010-05-11 19:42:16 +00:00
|
|
|
template <class _Facet> friend const _Facet& use_facet(const locale&);
|
|
|
|
};
|
|
|
|
|
2023-06-14 17:17:50 +00:00
|
|
|
class _LIBCPP_EXPORTED_FROM_ABI locale::facet
|
2010-05-11 19:42:16 +00:00
|
|
|
: public __shared_count
|
|
|
|
{
|
|
|
|
protected:
|
2010-09-21 18:58:51 +00:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2010-05-11 19:42:16 +00:00
|
|
|
explicit facet(size_t __refs = 0)
|
|
|
|
: __shared_count(static_cast<long>(__refs)-1) {}
|
|
|
|
|
2022-08-24 00:14:29 +00:00
|
|
|
~facet() override;
|
2010-05-11 19:42:16 +00:00
|
|
|
|
|
|
|
// facet(const facet&) = delete; // effectively done in __shared_count
|
|
|
|
// void operator=(const facet&) = delete;
|
|
|
|
private:
|
2022-08-24 00:14:29 +00:00
|
|
|
void __on_zero_shared() _NOEXCEPT override;
|
2010-05-11 19:42:16 +00:00
|
|
|
};
|
|
|
|
|
2023-06-14 17:17:50 +00:00
|
|
|
class _LIBCPP_EXPORTED_FROM_ABI locale::id
|
2010-05-11 19:42:16 +00:00
|
|
|
{
|
|
|
|
once_flag __flag_;
|
|
|
|
int32_t __id_;
|
2010-08-22 00:02:43 +00:00
|
|
|
|
2010-05-11 19:42:16 +00:00
|
|
|
static int32_t __next_id;
|
|
|
|
public:
|
2012-07-26 16:14:37 +00:00
|
|
|
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR id() :__id_(0) {}
|
2021-12-08 09:57:12 +00:00
|
|
|
void operator=(const id&) = delete;
|
|
|
|
id(const id&) = delete;
|
|
|
|
|
2010-05-11 19:42:16 +00:00
|
|
|
private:
|
|
|
|
void __init();
|
|
|
|
public: // only needed for tests
|
|
|
|
long __get();
|
|
|
|
|
|
|
|
friend class locale;
|
|
|
|
friend class locale::__imp;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <class _Facet>
|
|
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
|
|
|
locale::locale(const locale& __other, _Facet* __f)
|
|
|
|
{
|
|
|
|
__install_ctor(__other, __f, __f ? __f->id.__get() : 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class _Facet>
|
|
|
|
locale
|
|
|
|
locale::combine(const locale& __other) const
|
|
|
|
{
|
2011-06-30 21:18:19 +00:00
|
|
|
if (!_VSTD::has_facet<_Facet>(__other))
|
2016-08-25 15:09:01 +00:00
|
|
|
__throw_runtime_error("locale::combine: locale missing facet");
|
|
|
|
|
2011-06-30 21:18:19 +00:00
|
|
|
return locale(*this, &const_cast<_Facet&>(_VSTD::use_facet<_Facet>(__other)));
|
2010-05-11 19:42:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class _Facet>
|
|
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
|
|
|
bool
|
2011-05-31 15:34:58 +00:00
|
|
|
has_facet(const locale& __l) _NOEXCEPT
|
2010-05-11 19:42:16 +00:00
|
|
|
{
|
|
|
|
return __l.has_facet(_Facet::id);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class _Facet>
|
|
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
|
|
|
const _Facet&
|
|
|
|
use_facet(const locale& __l)
|
|
|
|
{
|
|
|
|
return static_cast<const _Facet&>(*__l.use_facet(_Facet::id));
|
|
|
|
}
|
|
|
|
|
|
|
|
// template <class _CharT> class collate;
|
|
|
|
|
|
|
|
template <class _CharT>
|
2017-01-04 23:56:00 +00:00
|
|
|
class _LIBCPP_TEMPLATE_VIS collate
|
2010-05-11 19:42:16 +00:00
|
|
|
: public locale::facet
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef _CharT char_type;
|
|
|
|
typedef basic_string<char_type> string_type;
|
|
|
|
|
2023-05-24 15:46:13 +00:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2010-05-11 19:42:16 +00:00
|
|
|
explicit collate(size_t __refs = 0)
|
|
|
|
: locale::facet(__refs) {}
|
|
|
|
|
2023-05-24 15:46:13 +00:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2010-05-11 19:42:16 +00:00
|
|
|
int compare(const char_type* __lo1, const char_type* __hi1,
|
|
|
|
const char_type* __lo2, const char_type* __hi2) const
|
|
|
|
{
|
|
|
|
return do_compare(__lo1, __hi1, __lo2, __hi2);
|
|
|
|
}
|
|
|
|
|
2019-03-08 23:59:29 +00:00
|
|
|
// FIXME(EricWF): The _LIBCPP_ALWAYS_INLINE is needed on Windows to work
|
|
|
|
// around a dllimport bug that expects an external instantiation.
|
2023-05-24 15:46:13 +00:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2019-03-08 23:59:29 +00:00
|
|
|
_LIBCPP_ALWAYS_INLINE
|
2010-05-11 19:42:16 +00:00
|
|
|
string_type transform(const char_type* __lo, const char_type* __hi) const
|
|
|
|
{
|
|
|
|
return do_transform(__lo, __hi);
|
|
|
|
}
|
|
|
|
|
2023-05-24 15:46:13 +00:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2010-05-11 19:42:16 +00:00
|
|
|
long hash(const char_type* __lo, const char_type* __hi) const
|
|
|
|
{
|
|
|
|
return do_hash(__lo, __hi);
|
|
|
|
}
|
|
|
|
|
|
|
|
static locale::id id;
|
|
|
|
|
|
|
|
protected:
|
2022-08-24 00:14:29 +00:00
|
|
|
~collate() override;
|
2010-05-11 19:42:16 +00:00
|
|
|
virtual int do_compare(const char_type* __lo1, const char_type* __hi1,
|
|
|
|
const char_type* __lo2, const char_type* __hi2) const;
|
|
|
|
virtual string_type do_transform(const char_type* __lo, const char_type* __hi) const
|
|
|
|
{return string_type(__lo, __hi);}
|
|
|
|
virtual long do_hash(const char_type* __lo, const char_type* __hi) const;
|
|
|
|
};
|
|
|
|
|
|
|
|
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
|
|
|
|
{
|
|
|
|
for (; __lo2 != __hi2; ++__lo1, ++__lo2)
|
|
|
|
{
|
|
|
|
if (__lo1 == __hi1 || *__lo1 < *__lo2)
|
|
|
|
return -1;
|
|
|
|
if (*__lo2 < *__lo1)
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return __lo1 != __hi1;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class _CharT>
|
|
|
|
long
|
2011-10-11 16:00:46 +00:00
|
|
|
collate<_CharT>::do_hash(const char_type* __lo, const char_type* __hi) const
|
2010-05-11 19:42:16 +00:00
|
|
|
{
|
2011-10-11 16:00:46 +00:00
|
|
|
size_t __h = 0;
|
|
|
|
const size_t __sr = __CHAR_BIT__ * sizeof(size_t) - 8;
|
|
|
|
const size_t __mask = size_t(0xF) << (__sr + 4);
|
|
|
|
for(const char_type* __p = __lo; __p != __hi; ++__p)
|
2010-05-11 19:42:16 +00:00
|
|
|
{
|
2011-12-01 20:21:04 +00:00
|
|
|
__h = (__h << 4) + static_cast<size_t>(*__p);
|
2011-10-11 16:00:46 +00:00
|
|
|
size_t __g = __h & __mask;
|
|
|
|
__h ^= __g | (__g >> __sr);
|
2010-05-11 19:42:16 +00:00
|
|
|
}
|
2011-10-11 16:00:46 +00:00
|
|
|
return static_cast<long>(__h);
|
2010-05-11 19:42:16 +00:00
|
|
|
}
|
|
|
|
|
2021-06-08 21:25:08 +00:00
|
|
|
extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS collate<char>;
|
2021-08-23 19:32:36 +00:00
|
|
|
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
|
2021-06-08 21:25:08 +00:00
|
|
|
extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS collate<wchar_t>;
|
2021-08-23 19:32:36 +00:00
|
|
|
#endif
|
2010-05-11 19:42:16 +00:00
|
|
|
|
|
|
|
// template <class CharT> class collate_byname;
|
|
|
|
|
2017-01-04 23:56:00 +00:00
|
|
|
template <class _CharT> class _LIBCPP_TEMPLATE_VIS collate_byname;
|
2010-05-11 19:42:16 +00:00
|
|
|
|
|
|
|
template <>
|
2023-06-14 17:17:50 +00:00
|
|
|
class _LIBCPP_EXPORTED_FROM_ABI collate_byname<char>
|
2010-05-11 19:42:16 +00:00
|
|
|
: public collate<char>
|
|
|
|
{
|
2022-09-02 14:19:07 +00:00
|
|
|
locale_t __l_;
|
2010-05-11 19:42:16 +00:00
|
|
|
public:
|
|
|
|
typedef char char_type;
|
|
|
|
typedef basic_string<char_type> string_type;
|
|
|
|
|
|
|
|
explicit collate_byname(const char* __n, size_t __refs = 0);
|
|
|
|
explicit collate_byname(const string& __n, size_t __refs = 0);
|
|
|
|
|
|
|
|
protected:
|
2022-08-24 00:14:29 +00:00
|
|
|
~collate_byname() override;
|
|
|
|
int do_compare(const char_type* __lo1, const char_type* __hi1,
|
|
|
|
const char_type* __lo2, const char_type* __hi2) const override;
|
|
|
|
string_type do_transform(const char_type* __lo, const char_type* __hi) const override;
|
2010-05-11 19:42:16 +00:00
|
|
|
};
|
|
|
|
|
2021-08-23 19:32:36 +00:00
|
|
|
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
|
2010-05-11 19:42:16 +00:00
|
|
|
template <>
|
2023-06-14 17:17:50 +00:00
|
|
|
class _LIBCPP_EXPORTED_FROM_ABI collate_byname<wchar_t>
|
2010-05-11 19:42:16 +00:00
|
|
|
: public collate<wchar_t>
|
|
|
|
{
|
2022-09-02 14:19:07 +00:00
|
|
|
locale_t __l_;
|
2010-05-11 19:42:16 +00:00
|
|
|
public:
|
|
|
|
typedef wchar_t char_type;
|
|
|
|
typedef basic_string<char_type> string_type;
|
|
|
|
|
|
|
|
explicit collate_byname(const char* __n, size_t __refs = 0);
|
|
|
|
explicit collate_byname(const string& __n, size_t __refs = 0);
|
|
|
|
|
|
|
|
protected:
|
2022-08-24 00:14:29 +00:00
|
|
|
~collate_byname() override;
|
2010-05-11 19:42:16 +00:00
|
|
|
|
2022-08-24 00:14:29 +00:00
|
|
|
int do_compare(const char_type* __lo1, const char_type* __hi1,
|
|
|
|
const char_type* __lo2, const char_type* __hi2) const override;
|
|
|
|
string_type do_transform(const char_type* __lo, const char_type* __hi) const override;
|
2010-05-11 19:42:16 +00:00
|
|
|
};
|
2021-08-23 19:32:36 +00:00
|
|
|
#endif
|
2010-05-11 19:42:16 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
{
|
2011-06-30 21:18:19 +00:00
|
|
|
return _VSTD::use_facet<_VSTD::collate<_CharT> >(*this).compare(
|
2010-05-11 19:42:16 +00:00
|
|
|
__x.data(), __x.data() + __x.size(),
|
|
|
|
__y.data(), __y.data() + __y.size()) < 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// template <class charT> class ctype
|
|
|
|
|
2023-06-14 17:17:50 +00:00
|
|
|
class _LIBCPP_EXPORTED_FROM_ABI ctype_base
|
2010-09-21 18:58:51 +00:00
|
|
|
{
|
2010-05-11 19:42:16 +00:00
|
|
|
public:
|
2020-11-11 20:30:21 +00:00
|
|
|
#if defined(_LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE)
|
|
|
|
typedef unsigned long mask;
|
|
|
|
static const mask space = 1<<0;
|
|
|
|
static const mask print = 1<<1;
|
|
|
|
static const mask cntrl = 1<<2;
|
|
|
|
static const mask upper = 1<<3;
|
|
|
|
static const mask lower = 1<<4;
|
|
|
|
static const mask alpha = 1<<5;
|
|
|
|
static const mask digit = 1<<6;
|
|
|
|
static const mask punct = 1<<7;
|
|
|
|
static const mask xdigit = 1<<8;
|
|
|
|
static const mask blank = 1<<9;
|
|
|
|
#if defined(__BIONIC__)
|
|
|
|
// Historically this was a part of regex_traits rather than ctype_base. The
|
|
|
|
// historical value of the constant is preserved for ABI compatibility.
|
|
|
|
static const mask __regex_word = 0x8000;
|
|
|
|
#else
|
|
|
|
static const mask __regex_word = 1<<10;
|
|
|
|
#endif // defined(__BIONIC__)
|
|
|
|
#elif defined(__GLIBC__)
|
2011-07-09 00:56:23 +00:00
|
|
|
typedef unsigned short mask;
|
2011-09-21 08:39:44 +00:00
|
|
|
static const mask space = _ISspace;
|
|
|
|
static const mask print = _ISprint;
|
|
|
|
static const mask cntrl = _IScntrl;
|
|
|
|
static const mask upper = _ISupper;
|
|
|
|
static const mask lower = _ISlower;
|
|
|
|
static const mask alpha = _ISalpha;
|
|
|
|
static const mask digit = _ISdigit;
|
|
|
|
static const mask punct = _ISpunct;
|
|
|
|
static const mask xdigit = _ISxdigit;
|
|
|
|
static const mask blank = _ISblank;
|
[libc++] Keep __regex_word in sync with ctype_base
Summary:
The class ctype_base in the header <__locale> contains masks for
character classification functions, which are kept in sync with
platform's C library, hence it contains many special cases.
The value of the bit mask __regex_word in the header <regex> must not
clash with those bit masks.
Currently the default case (i.e. unknown platform/C library) is
handled incorrectly: the __regex_word clashes with ctype_base::punct.
To avoid replicating the whole list of platforms in <regex> this patch
defines __regex_word in <__locale>, so that it is always kept in sync
with other masks.
Reviewers: ldionne, mclow.lists, EricWF
Reviewed By: ldionne
Subscribers: krytarowski, christof, dexonsmith, pbarrio, simon_tatham, libcxx-commits
Tags: #libc
Differential Revision: https://reviews.llvm.org/D63284
llvm-svn: 363363
2019-06-14 09:04:16 +00:00
|
|
|
#if defined(__mips__)
|
2019-08-20 10:19:55 +00:00
|
|
|
static const mask __regex_word = static_cast<mask>(_ISbit(15));
|
[libc++] Keep __regex_word in sync with ctype_base
Summary:
The class ctype_base in the header <__locale> contains masks for
character classification functions, which are kept in sync with
platform's C library, hence it contains many special cases.
The value of the bit mask __regex_word in the header <regex> must not
clash with those bit masks.
Currently the default case (i.e. unknown platform/C library) is
handled incorrectly: the __regex_word clashes with ctype_base::punct.
To avoid replicating the whole list of platforms in <regex> this patch
defines __regex_word in <__locale>, so that it is always kept in sync
with other masks.
Reviewers: ldionne, mclow.lists, EricWF
Reviewed By: ldionne
Subscribers: krytarowski, christof, dexonsmith, pbarrio, simon_tatham, libcxx-commits
Tags: #libc
Differential Revision: https://reviews.llvm.org/D63284
llvm-svn: 363363
2019-06-14 09:04:16 +00:00
|
|
|
#else
|
|
|
|
static const mask __regex_word = 0x80;
|
|
|
|
#endif
|
2017-05-31 22:14:05 +00:00
|
|
|
#elif defined(_LIBCPP_MSVCRT_LIKE)
|
2011-09-29 13:33:15 +00:00
|
|
|
typedef unsigned short mask;
|
2011-09-22 19:10:18 +00:00
|
|
|
static const mask space = _SPACE;
|
|
|
|
static const mask print = _BLANK|_PUNCT|_ALPHA|_DIGIT;
|
|
|
|
static const mask cntrl = _CONTROL;
|
|
|
|
static const mask upper = _UPPER;
|
|
|
|
static const mask lower = _LOWER;
|
|
|
|
static const mask alpha = _ALPHA;
|
|
|
|
static const mask digit = _DIGIT;
|
|
|
|
static const mask punct = _PUNCT;
|
|
|
|
static const mask xdigit = _HEX;
|
|
|
|
static const mask blank = _BLANK;
|
2022-01-12 09:26:49 +00:00
|
|
|
static const mask __regex_word = 0x4000; // 0x8000 and 0x0100 and 0x00ff are used
|
2015-03-11 17:00:28 +00:00
|
|
|
# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_PRINT
|
[libcxx] Fix the ctype `is` (pointer version) function for Windows
Previously, this test snippet would report incorrect information:
F::mask m;
std::wstring in(L"\u00DA"); // LATIN CAPITAL LETTER U WITH ACUTE
f.is(in.data(), in.data() + 1, &m);
// m & F::lower would be set
The single-character version of the `is` function wasn't
affected by this issue though.
Define `_LIBCPP_CTYPE_MASK_IS_COMPOSITE_ALPHA` for Windows,
as the `alpha` / `_ALPHA` constant is a mask consisting of
multiple bits set, which avoids setting `alpha` whenver any
of the bits is set, in the `do_is` implementation.
On Windows, with the "C" locale, wchars are classified according
to their Unicode interpretation, just as in the en_US.UTF-8 locale on
all platforms.
Due to the differing classification of some characters, the
`scan_is` and `scan_not` tests are quite annoying to fix, thus just
ifdef out some of the tests for the "C" locale there - the code gets
tested with the more standard en_US.UTF-8 locale anyway.
Differential Revision: https://reviews.llvm.org/D120796
2022-01-21 23:21:31 +00:00
|
|
|
# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_ALPHA
|
2015-03-11 00:51:06 +00:00
|
|
|
#elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__)
|
2015-02-25 22:16:46 +00:00
|
|
|
# ifdef __APPLE__
|
2010-05-11 19:42:16 +00:00
|
|
|
typedef __uint32_t mask;
|
2015-02-25 22:16:46 +00:00
|
|
|
# elif defined(__FreeBSD__)
|
2011-09-21 08:39:44 +00:00
|
|
|
typedef unsigned long mask;
|
2015-11-24 10:24:54 +00:00
|
|
|
# elif defined(__EMSCRIPTEN__) || defined(__NetBSD__)
|
2013-03-29 18:27:28 +00:00
|
|
|
typedef unsigned short mask;
|
2015-02-25 22:16:46 +00:00
|
|
|
# endif
|
2010-05-11 19:42:16 +00:00
|
|
|
static const mask space = _CTYPE_S;
|
|
|
|
static const mask print = _CTYPE_R;
|
|
|
|
static const mask cntrl = _CTYPE_C;
|
|
|
|
static const mask upper = _CTYPE_U;
|
|
|
|
static const mask lower = _CTYPE_L;
|
|
|
|
static const mask alpha = _CTYPE_A;
|
|
|
|
static const mask digit = _CTYPE_D;
|
|
|
|
static const mask punct = _CTYPE_P;
|
|
|
|
static const mask xdigit = _CTYPE_X;
|
2014-07-23 19:32:03 +00:00
|
|
|
|
2013-05-17 21:17:34 +00:00
|
|
|
# if defined(__NetBSD__)
|
|
|
|
static const mask blank = _CTYPE_BL;
|
[libc++] Keep __regex_word in sync with ctype_base
Summary:
The class ctype_base in the header <__locale> contains masks for
character classification functions, which are kept in sync with
platform's C library, hence it contains many special cases.
The value of the bit mask __regex_word in the header <regex> must not
clash with those bit masks.
Currently the default case (i.e. unknown platform/C library) is
handled incorrectly: the __regex_word clashes with ctype_base::punct.
To avoid replicating the whole list of platforms in <regex> this patch
defines __regex_word in <__locale>, so that it is always kept in sync
with other masks.
Reviewers: ldionne, mclow.lists, EricWF
Reviewed By: ldionne
Subscribers: krytarowski, christof, dexonsmith, pbarrio, simon_tatham, libcxx-commits
Tags: #libc
Differential Revision: https://reviews.llvm.org/D63284
llvm-svn: 363363
2019-06-14 09:04:16 +00:00
|
|
|
// NetBSD defines classes up to 0x2000
|
|
|
|
// see sys/ctype_bits.h, _CTYPE_Q
|
|
|
|
static const mask __regex_word = 0x8000;
|
2013-05-17 21:17:34 +00:00
|
|
|
# else
|
2010-05-11 19:42:16 +00:00
|
|
|
static const mask blank = _CTYPE_B;
|
[libc++] Keep __regex_word in sync with ctype_base
Summary:
The class ctype_base in the header <__locale> contains masks for
character classification functions, which are kept in sync with
platform's C library, hence it contains many special cases.
The value of the bit mask __regex_word in the header <regex> must not
clash with those bit masks.
Currently the default case (i.e. unknown platform/C library) is
handled incorrectly: the __regex_word clashes with ctype_base::punct.
To avoid replicating the whole list of platforms in <regex> this patch
defines __regex_word in <__locale>, so that it is always kept in sync
with other masks.
Reviewers: ldionne, mclow.lists, EricWF
Reviewed By: ldionne
Subscribers: krytarowski, christof, dexonsmith, pbarrio, simon_tatham, libcxx-commits
Tags: #libc
Differential Revision: https://reviews.llvm.org/D63284
llvm-svn: 363363
2019-06-14 09:04:16 +00:00
|
|
|
static const mask __regex_word = 0x80;
|
2013-05-17 21:17:34 +00:00
|
|
|
# endif
|
2022-11-24 18:02:58 +00:00
|
|
|
#elif defined(_AIX)
|
2012-02-29 13:05:08 +00:00
|
|
|
typedef unsigned int mask;
|
|
|
|
static const mask space = _ISSPACE;
|
|
|
|
static const mask print = _ISPRINT;
|
|
|
|
static const mask cntrl = _ISCNTRL;
|
|
|
|
static const mask upper = _ISUPPER;
|
|
|
|
static const mask lower = _ISLOWER;
|
|
|
|
static const mask alpha = _ISALPHA;
|
|
|
|
static const mask digit = _ISDIGIT;
|
|
|
|
static const mask punct = _ISPUNCT;
|
|
|
|
static const mask xdigit = _ISXDIGIT;
|
|
|
|
static const mask blank = _ISBLANK;
|
2022-07-16 22:11:04 +00:00
|
|
|
static const mask __regex_word = 0x8000;
|
2015-02-25 22:16:46 +00:00
|
|
|
#elif defined(_NEWLIB_VERSION)
|
|
|
|
// Same type as Newlib's _ctype_ array in newlib/libc/include/ctype.h.
|
|
|
|
typedef char mask;
|
|
|
|
static const mask space = _S;
|
|
|
|
static const mask print = _P | _U | _L | _N | _B;
|
|
|
|
static const mask cntrl = _C;
|
|
|
|
static const mask upper = _U;
|
|
|
|
static const mask lower = _L;
|
|
|
|
static const mask alpha = _U | _L;
|
|
|
|
static const mask digit = _N;
|
|
|
|
static const mask punct = _P;
|
|
|
|
static const mask xdigit = _X | _N;
|
|
|
|
static const mask blank = _B;
|
2022-06-20 14:44:57 +00:00
|
|
|
// mask is already fully saturated, use a different type in regex_type_traits.
|
|
|
|
static const unsigned short __regex_word = 0x100;
|
2015-03-11 17:00:28 +00:00
|
|
|
# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_PRINT
|
|
|
|
# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_ALPHA
|
|
|
|
# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_XDIGIT
|
2022-01-14 16:35:53 +00:00
|
|
|
#elif defined(__MVS__)
|
2022-01-21 21:18:46 +00:00
|
|
|
# if defined(__NATIVE_ASCII_F)
|
2022-01-14 16:35:53 +00:00
|
|
|
typedef unsigned int mask;
|
|
|
|
static const mask space = _ISSPACE_A;
|
|
|
|
static const mask print = _ISPRINT_A;
|
|
|
|
static const mask cntrl = _ISCNTRL_A;
|
|
|
|
static const mask upper = _ISUPPER_A;
|
|
|
|
static const mask lower = _ISLOWER_A;
|
|
|
|
static const mask alpha = _ISALPHA_A;
|
|
|
|
static const mask digit = _ISDIGIT_A;
|
|
|
|
static const mask punct = _ISPUNCT_A;
|
|
|
|
static const mask xdigit = _ISXDIGIT_A;
|
|
|
|
static const mask blank = _ISBLANK_A;
|
|
|
|
# else
|
|
|
|
typedef unsigned short mask;
|
|
|
|
static const mask space = __ISSPACE;
|
|
|
|
static const mask print = __ISPRINT;
|
|
|
|
static const mask cntrl = __ISCNTRL;
|
|
|
|
static const mask upper = __ISUPPER;
|
|
|
|
static const mask lower = __ISLOWER;
|
|
|
|
static const mask alpha = __ISALPHA;
|
|
|
|
static const mask digit = __ISDIGIT;
|
|
|
|
static const mask punct = __ISPUNCT;
|
|
|
|
static const mask xdigit = __ISXDIGIT;
|
|
|
|
static const mask blank = __ISBLANK;
|
|
|
|
# endif
|
2022-01-21 21:18:46 +00:00
|
|
|
static const mask __regex_word = 0x8000;
|
2015-02-25 22:16:46 +00:00
|
|
|
#else
|
2020-11-11 20:30:21 +00:00
|
|
|
# error unknown rune table for this platform -- do you mean to define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE?
|
2015-02-25 22:16:46 +00:00
|
|
|
#endif
|
2010-05-11 19:42:16 +00:00
|
|
|
static const mask alnum = alpha | digit;
|
|
|
|
static const mask graph = alnum | punct;
|
|
|
|
|
2018-07-11 23:14:33 +00:00
|
|
|
_LIBCPP_INLINE_VISIBILITY ctype_base() {}
|
2022-01-12 09:26:49 +00:00
|
|
|
|
2022-06-20 14:44:57 +00:00
|
|
|
static_assert((__regex_word & ~(std::make_unsigned<mask>::type)(space | print | cntrl | upper | lower | alpha |
|
|
|
|
digit | punct | xdigit | blank)) == __regex_word,
|
2022-01-12 09:26:49 +00:00
|
|
|
"__regex_word can't overlap other bits");
|
2010-05-11 19:42:16 +00:00
|
|
|
};
|
|
|
|
|
2017-01-04 23:56:00 +00:00
|
|
|
template <class _CharT> class _LIBCPP_TEMPLATE_VIS ctype;
|
2010-05-11 19:42:16 +00:00
|
|
|
|
2021-08-23 19:32:36 +00:00
|
|
|
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
|
2010-05-11 19:42:16 +00:00
|
|
|
template <>
|
2023-06-14 17:17:50 +00:00
|
|
|
class _LIBCPP_EXPORTED_FROM_ABI ctype<wchar_t>
|
2010-05-11 19:42:16 +00:00
|
|
|
: public locale::facet,
|
|
|
|
public ctype_base
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef wchar_t char_type;
|
2010-08-22 00:02:43 +00:00
|
|
|
|
2018-07-11 23:14:33 +00:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2010-05-11 19:42:16 +00:00
|
|
|
explicit ctype(size_t __refs = 0)
|
|
|
|
: locale::facet(__refs) {}
|
|
|
|
|
2018-07-11 23:14:33 +00:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2010-05-11 19:42:16 +00:00
|
|
|
bool is(mask __m, char_type __c) const
|
|
|
|
{
|
|
|
|
return do_is(__m, __c);
|
|
|
|
}
|
|
|
|
|
2018-07-11 23:14:33 +00:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2010-05-11 19:42:16 +00:00
|
|
|
const char_type* is(const char_type* __low, const char_type* __high, mask* __vec) const
|
|
|
|
{
|
|
|
|
return do_is(__low, __high, __vec);
|
|
|
|
}
|
|
|
|
|
2018-07-11 23:14:33 +00:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2010-05-11 19:42:16 +00:00
|
|
|
const char_type* scan_is(mask __m, const char_type* __low, const char_type* __high) const
|
|
|
|
{
|
|
|
|
return do_scan_is(__m, __low, __high);
|
|
|
|
}
|
|
|
|
|
2018-07-11 23:14:33 +00:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2010-05-11 19:42:16 +00:00
|
|
|
const char_type* scan_not(mask __m, const char_type* __low, const char_type* __high) const
|
|
|
|
{
|
|
|
|
return do_scan_not(__m, __low, __high);
|
|
|
|
}
|
|
|
|
|
2018-07-11 23:14:33 +00:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2010-05-11 19:42:16 +00:00
|
|
|
char_type toupper(char_type __c) const
|
|
|
|
{
|
|
|
|
return do_toupper(__c);
|
|
|
|
}
|
|
|
|
|
2018-07-11 23:14:33 +00:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2010-05-11 19:42:16 +00:00
|
|
|
const char_type* toupper(char_type* __low, const char_type* __high) const
|
|
|
|
{
|
|
|
|
return do_toupper(__low, __high);
|
|
|
|
}
|
|
|
|
|
2018-07-11 23:14:33 +00:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2010-05-11 19:42:16 +00:00
|
|
|
char_type tolower(char_type __c) const
|
|
|
|
{
|
|
|
|
return do_tolower(__c);
|
|
|
|
}
|
|
|
|
|
2018-07-11 23:14:33 +00:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2010-05-11 19:42:16 +00:00
|
|
|
const char_type* tolower(char_type* __low, const char_type* __high) const
|
|
|
|
{
|
|
|
|
return do_tolower(__low, __high);
|
|
|
|
}
|
|
|
|
|
2018-07-11 23:14:33 +00:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2010-05-11 19:42:16 +00:00
|
|
|
char_type widen(char __c) const
|
|
|
|
{
|
|
|
|
return do_widen(__c);
|
|
|
|
}
|
|
|
|
|
2018-07-11 23:14:33 +00:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2010-05-11 19:42:16 +00:00
|
|
|
const char* widen(const char* __low, const char* __high, char_type* __to) const
|
|
|
|
{
|
|
|
|
return do_widen(__low, __high, __to);
|
|
|
|
}
|
|
|
|
|
2018-07-11 23:14:33 +00:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2010-05-11 19:42:16 +00:00
|
|
|
char narrow(char_type __c, char __dfault) const
|
|
|
|
{
|
|
|
|
return do_narrow(__c, __dfault);
|
|
|
|
}
|
|
|
|
|
2018-07-11 23:14:33 +00:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2010-05-11 19:42:16 +00:00
|
|
|
const char_type* narrow(const char_type* __low, const char_type* __high, char __dfault, char* __to) const
|
|
|
|
{
|
|
|
|
return do_narrow(__low, __high, __dfault, __to);
|
|
|
|
}
|
|
|
|
|
|
|
|
static locale::id id;
|
|
|
|
|
|
|
|
protected:
|
2022-08-24 00:14:29 +00:00
|
|
|
~ctype() override;
|
2010-05-11 19:42:16 +00:00
|
|
|
virtual bool do_is(mask __m, char_type __c) const;
|
|
|
|
virtual const char_type* do_is(const char_type* __low, const char_type* __high, mask* __vec) const;
|
|
|
|
virtual const char_type* do_scan_is(mask __m, const char_type* __low, const char_type* __high) const;
|
|
|
|
virtual const char_type* do_scan_not(mask __m, const char_type* __low, const char_type* __high) const;
|
|
|
|
virtual char_type do_toupper(char_type) const;
|
|
|
|
virtual const char_type* do_toupper(char_type* __low, const char_type* __high) const;
|
|
|
|
virtual char_type do_tolower(char_type) const;
|
|
|
|
virtual const char_type* do_tolower(char_type* __low, const char_type* __high) const;
|
|
|
|
virtual char_type do_widen(char) const;
|
|
|
|
virtual const char* do_widen(const char* __low, const char* __high, char_type* __dest) const;
|
|
|
|
virtual char do_narrow(char_type, char __dfault) const;
|
|
|
|
virtual const char_type* do_narrow(const char_type* __low, const char_type* __high, char __dfault, char* __dest) const;
|
|
|
|
};
|
2021-08-23 19:32:36 +00:00
|
|
|
#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
|
2010-05-11 19:42:16 +00:00
|
|
|
|
|
|
|
template <>
|
2023-06-14 17:17:50 +00:00
|
|
|
class _LIBCPP_EXPORTED_FROM_ABI ctype<char>
|
2010-05-11 19:42:16 +00:00
|
|
|
: public locale::facet, public ctype_base
|
|
|
|
{
|
|
|
|
const mask* __tab_;
|
|
|
|
bool __del_;
|
|
|
|
public:
|
|
|
|
typedef char char_type;
|
|
|
|
|
2020-11-24 17:53:53 +00:00
|
|
|
explicit ctype(const mask* __tab = nullptr, bool __del = false, size_t __refs = 0);
|
2010-05-11 19:42:16 +00:00
|
|
|
|
2018-07-11 23:14:33 +00:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2010-05-11 19:42:16 +00:00
|
|
|
bool is(mask __m, char_type __c) const
|
|
|
|
{
|
2013-10-21 14:41:05 +00:00
|
|
|
return isascii(__c) ? (__tab_[static_cast<int>(__c)] & __m) !=0 : false;
|
2010-05-11 19:42:16 +00:00
|
|
|
}
|
|
|
|
|
2018-07-11 23:14:33 +00:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2010-05-11 19:42:16 +00:00
|
|
|
const char_type* is(const char_type* __low, const char_type* __high, mask* __vec) const
|
|
|
|
{
|
|
|
|
for (; __low != __high; ++__low, ++__vec)
|
2011-12-01 20:21:04 +00:00
|
|
|
*__vec = isascii(*__low) ? __tab_[static_cast<int>(*__low)] : 0;
|
2010-05-11 19:42:16 +00:00
|
|
|
return __low;
|
|
|
|
}
|
|
|
|
|
2018-07-11 23:14:33 +00:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2010-05-11 19:42:16 +00:00
|
|
|
const char_type* scan_is (mask __m, const char_type* __low, const char_type* __high) const
|
|
|
|
{
|
|
|
|
for (; __low != __high; ++__low)
|
2011-12-01 20:21:04 +00:00
|
|
|
if (isascii(*__low) && (__tab_[static_cast<int>(*__low)] & __m))
|
2010-05-11 19:42:16 +00:00
|
|
|
break;
|
|
|
|
return __low;
|
|
|
|
}
|
|
|
|
|
2018-07-11 23:14:33 +00:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2010-05-11 19:42:16 +00:00
|
|
|
const char_type* scan_not(mask __m, const char_type* __low, const char_type* __high) const
|
|
|
|
{
|
|
|
|
for (; __low != __high; ++__low)
|
2022-11-10 22:57:43 +00:00
|
|
|
if (!isascii(*__low) || !(__tab_[static_cast<int>(*__low)] & __m))
|
2010-05-11 19:42:16 +00:00
|
|
|
break;
|
|
|
|
return __low;
|
|
|
|
}
|
|
|
|
|
2018-07-11 23:14:33 +00:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2010-05-11 19:42:16 +00:00
|
|
|
char_type toupper(char_type __c) const
|
|
|
|
{
|
|
|
|
return do_toupper(__c);
|
|
|
|
}
|
|
|
|
|
2018-07-11 23:14:33 +00:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2010-05-11 19:42:16 +00:00
|
|
|
const char_type* toupper(char_type* __low, const char_type* __high) const
|
|
|
|
{
|
|
|
|
return do_toupper(__low, __high);
|
|
|
|
}
|
|
|
|
|
2018-07-11 23:14:33 +00:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2010-05-11 19:42:16 +00:00
|
|
|
char_type tolower(char_type __c) const
|
|
|
|
{
|
|
|
|
return do_tolower(__c);
|
|
|
|
}
|
|
|
|
|
2018-07-11 23:14:33 +00:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2010-05-11 19:42:16 +00:00
|
|
|
const char_type* tolower(char_type* __low, const char_type* __high) const
|
|
|
|
{
|
|
|
|
return do_tolower(__low, __high);
|
|
|
|
}
|
|
|
|
|
2018-07-11 23:14:33 +00:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2010-05-11 19:42:16 +00:00
|
|
|
char_type widen(char __c) const
|
|
|
|
{
|
|
|
|
return do_widen(__c);
|
|
|
|
}
|
|
|
|
|
2018-07-11 23:14:33 +00:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2010-05-11 19:42:16 +00:00
|
|
|
const char* widen(const char* __low, const char* __high, char_type* __to) const
|
|
|
|
{
|
|
|
|
return do_widen(__low, __high, __to);
|
|
|
|
}
|
|
|
|
|
2018-07-11 23:14:33 +00:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2010-05-11 19:42:16 +00:00
|
|
|
char narrow(char_type __c, char __dfault) const
|
|
|
|
{
|
|
|
|
return do_narrow(__c, __dfault);
|
|
|
|
}
|
|
|
|
|
2018-07-11 23:14:33 +00:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2010-05-11 19:42:16 +00:00
|
|
|
const char* narrow(const char_type* __low, const char_type* __high, char __dfault, char* __to) const
|
|
|
|
{
|
|
|
|
return do_narrow(__low, __high, __dfault, __to);
|
|
|
|
}
|
|
|
|
|
|
|
|
static locale::id id;
|
|
|
|
|
2010-05-24 17:49:41 +00:00
|
|
|
#ifdef _CACHED_RUNES
|
2010-05-11 19:42:16 +00:00
|
|
|
static const size_t table_size = _CACHED_RUNES;
|
2010-05-24 17:49:41 +00:00
|
|
|
#else
|
|
|
|
static const size_t table_size = 256; // FIXME: Don't hardcode this.
|
|
|
|
#endif
|
2018-07-11 23:14:33 +00:00
|
|
|
_LIBCPP_INLINE_VISIBILITY const mask* table() const _NOEXCEPT {return __tab_;}
|
2011-05-31 15:34:58 +00:00
|
|
|
static const mask* classic_table() _NOEXCEPT;
|
2015-11-24 10:24:54 +00:00
|
|
|
#if defined(__GLIBC__) || defined(__EMSCRIPTEN__)
|
2011-07-09 00:56:23 +00:00
|
|
|
static const int* __classic_upper_table() _NOEXCEPT;
|
|
|
|
static const int* __classic_lower_table() _NOEXCEPT;
|
2011-07-09 01:09:31 +00:00
|
|
|
#endif
|
2013-05-17 21:17:34 +00:00
|
|
|
#if defined(__NetBSD__)
|
|
|
|
static const short* __classic_upper_table() _NOEXCEPT;
|
|
|
|
static const short* __classic_lower_table() _NOEXCEPT;
|
|
|
|
#endif
|
2022-01-14 16:35:53 +00:00
|
|
|
#if defined(__MVS__)
|
|
|
|
static const unsigned short* __classic_upper_table() _NOEXCEPT;
|
|
|
|
static const unsigned short* __classic_lower_table() _NOEXCEPT;
|
|
|
|
#endif
|
2010-05-11 19:42:16 +00:00
|
|
|
|
|
|
|
protected:
|
2022-08-24 00:14:29 +00:00
|
|
|
~ctype() override;
|
2010-05-11 19:42:16 +00:00
|
|
|
virtual char_type do_toupper(char_type __c) const;
|
|
|
|
virtual const char_type* do_toupper(char_type* __low, const char_type* __high) const;
|
|
|
|
virtual char_type do_tolower(char_type __c) const;
|
|
|
|
virtual const char_type* do_tolower(char_type* __low, const char_type* __high) const;
|
|
|
|
virtual char_type do_widen(char __c) const;
|
|
|
|
virtual const char* do_widen(const char* __low, const char* __high, char_type* __to) const;
|
|
|
|
virtual char do_narrow(char_type __c, char __dfault) const;
|
|
|
|
virtual const char* do_narrow(const char_type* __low, const char_type* __high, char __dfault, char* __to) const;
|
|
|
|
};
|
|
|
|
|
|
|
|
// template <class CharT> class ctype_byname;
|
|
|
|
|
2017-01-04 23:56:00 +00:00
|
|
|
template <class _CharT> class _LIBCPP_TEMPLATE_VIS ctype_byname;
|
2010-05-11 19:42:16 +00:00
|
|
|
|
|
|
|
template <>
|
2023-06-14 17:17:50 +00:00
|
|
|
class _LIBCPP_EXPORTED_FROM_ABI ctype_byname<char>
|
2010-05-11 19:42:16 +00:00
|
|
|
: public ctype<char>
|
|
|
|
{
|
2022-09-02 14:19:07 +00:00
|
|
|
locale_t __l_;
|
2010-05-11 19:42:16 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
explicit ctype_byname(const char*, size_t = 0);
|
|
|
|
explicit ctype_byname(const string&, size_t = 0);
|
|
|
|
|
|
|
|
protected:
|
2022-08-24 00:14:29 +00:00
|
|
|
~ctype_byname() override;
|
|
|
|
char_type do_toupper(char_type) const override;
|
|
|
|
const char_type* do_toupper(char_type* __low, const char_type* __high) const override;
|
|
|
|
char_type do_tolower(char_type) const override;
|
|
|
|
const char_type* do_tolower(char_type* __low, const char_type* __high) const override;
|
2010-05-11 19:42:16 +00:00
|
|
|
};
|
|
|
|
|
2021-08-23 19:32:36 +00:00
|
|
|
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
|
2010-05-11 19:42:16 +00:00
|
|
|
template <>
|
2023-06-14 17:17:50 +00:00
|
|
|
class _LIBCPP_EXPORTED_FROM_ABI ctype_byname<wchar_t>
|
2010-05-11 19:42:16 +00:00
|
|
|
: public ctype<wchar_t>
|
|
|
|
{
|
2022-09-02 14:19:07 +00:00
|
|
|
locale_t __l_;
|
2010-05-11 19:42:16 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
explicit ctype_byname(const char*, size_t = 0);
|
|
|
|
explicit ctype_byname(const string&, size_t = 0);
|
|
|
|
|
|
|
|
protected:
|
2022-08-24 00:14:29 +00:00
|
|
|
~ctype_byname() override;
|
|
|
|
bool do_is(mask __m, char_type __c) const override;
|
|
|
|
const char_type* do_is(const char_type* __low, const char_type* __high, mask* __vec) const override;
|
|
|
|
const char_type* do_scan_is(mask __m, const char_type* __low, const char_type* __high) const override;
|
|
|
|
const char_type* do_scan_not(mask __m, const char_type* __low, const char_type* __high) const override;
|
|
|
|
char_type do_toupper(char_type) const override;
|
|
|
|
const char_type* do_toupper(char_type* __low, const char_type* __high) const override;
|
|
|
|
char_type do_tolower(char_type) const override;
|
|
|
|
const char_type* do_tolower(char_type* __low, const char_type* __high) const override;
|
|
|
|
char_type do_widen(char) const override;
|
|
|
|
const char* do_widen(const char* __low, const char* __high, char_type* __dest) const override;
|
|
|
|
char do_narrow(char_type, char __dfault) const override;
|
|
|
|
const char_type* do_narrow(const char_type* __low, const char_type* __high, char __dfault, char* __dest) const override;
|
2010-05-11 19:42:16 +00:00
|
|
|
};
|
2021-08-23 19:32:36 +00:00
|
|
|
#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
|
2010-05-11 19:42:16 +00:00
|
|
|
|
|
|
|
template <class _CharT>
|
|
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
|
|
|
bool
|
|
|
|
isspace(_CharT __c, const locale& __loc)
|
|
|
|
{
|
[libc++] Add custom clang-tidy checks
Reviewed By: #libc, ldionne
Spies: jwakely, beanz, smeenai, cfe-commits, tschuett, avogelsgesang, Mordante, sstefan1, libcxx-commits, ldionne, mgorny, arichardson, miyuki
Differential Revision: https://reviews.llvm.org/D131963
2022-08-13 20:33:12 +00:00
|
|
|
return std::use_facet<ctype<_CharT> >(__loc).is(ctype_base::space, __c);
|
2010-05-11 19:42:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class _CharT>
|
|
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
|
|
|
bool
|
|
|
|
isprint(_CharT __c, const locale& __loc)
|
|
|
|
{
|
[libc++] Add custom clang-tidy checks
Reviewed By: #libc, ldionne
Spies: jwakely, beanz, smeenai, cfe-commits, tschuett, avogelsgesang, Mordante, sstefan1, libcxx-commits, ldionne, mgorny, arichardson, miyuki
Differential Revision: https://reviews.llvm.org/D131963
2022-08-13 20:33:12 +00:00
|
|
|
return std::use_facet<ctype<_CharT> >(__loc).is(ctype_base::print, __c);
|
2010-05-11 19:42:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class _CharT>
|
|
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
|
|
|
bool
|
|
|
|
iscntrl(_CharT __c, const locale& __loc)
|
|
|
|
{
|
[libc++] Add custom clang-tidy checks
Reviewed By: #libc, ldionne
Spies: jwakely, beanz, smeenai, cfe-commits, tschuett, avogelsgesang, Mordante, sstefan1, libcxx-commits, ldionne, mgorny, arichardson, miyuki
Differential Revision: https://reviews.llvm.org/D131963
2022-08-13 20:33:12 +00:00
|
|
|
return std::use_facet<ctype<_CharT> >(__loc).is(ctype_base::cntrl, __c);
|
2010-05-11 19:42:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class _CharT>
|
|
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
|
|
|
bool
|
|
|
|
isupper(_CharT __c, const locale& __loc)
|
|
|
|
{
|
[libc++] Add custom clang-tidy checks
Reviewed By: #libc, ldionne
Spies: jwakely, beanz, smeenai, cfe-commits, tschuett, avogelsgesang, Mordante, sstefan1, libcxx-commits, ldionne, mgorny, arichardson, miyuki
Differential Revision: https://reviews.llvm.org/D131963
2022-08-13 20:33:12 +00:00
|
|
|
return std::use_facet<ctype<_CharT> >(__loc).is(ctype_base::upper, __c);
|
2010-05-11 19:42:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class _CharT>
|
|
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
|
|
|
bool
|
|
|
|
islower(_CharT __c, const locale& __loc)
|
|
|
|
{
|
[libc++] Add custom clang-tidy checks
Reviewed By: #libc, ldionne
Spies: jwakely, beanz, smeenai, cfe-commits, tschuett, avogelsgesang, Mordante, sstefan1, libcxx-commits, ldionne, mgorny, arichardson, miyuki
Differential Revision: https://reviews.llvm.org/D131963
2022-08-13 20:33:12 +00:00
|
|
|
return std::use_facet<ctype<_CharT> >(__loc).is(ctype_base::lower, __c);
|
2010-05-11 19:42:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class _CharT>
|
|
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
|
|
|
bool
|
|
|
|
isalpha(_CharT __c, const locale& __loc)
|
|
|
|
{
|
[libc++] Add custom clang-tidy checks
Reviewed By: #libc, ldionne
Spies: jwakely, beanz, smeenai, cfe-commits, tschuett, avogelsgesang, Mordante, sstefan1, libcxx-commits, ldionne, mgorny, arichardson, miyuki
Differential Revision: https://reviews.llvm.org/D131963
2022-08-13 20:33:12 +00:00
|
|
|
return std::use_facet<ctype<_CharT> >(__loc).is(ctype_base::alpha, __c);
|
2010-05-11 19:42:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class _CharT>
|
|
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
|
|
|
bool
|
|
|
|
isdigit(_CharT __c, const locale& __loc)
|
|
|
|
{
|
[libc++] Add custom clang-tidy checks
Reviewed By: #libc, ldionne
Spies: jwakely, beanz, smeenai, cfe-commits, tschuett, avogelsgesang, Mordante, sstefan1, libcxx-commits, ldionne, mgorny, arichardson, miyuki
Differential Revision: https://reviews.llvm.org/D131963
2022-08-13 20:33:12 +00:00
|
|
|
return std::use_facet<ctype<_CharT> >(__loc).is(ctype_base::digit, __c);
|
2010-05-11 19:42:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class _CharT>
|
|
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
|
|
|
bool
|
|
|
|
ispunct(_CharT __c, const locale& __loc)
|
|
|
|
{
|
[libc++] Add custom clang-tidy checks
Reviewed By: #libc, ldionne
Spies: jwakely, beanz, smeenai, cfe-commits, tschuett, avogelsgesang, Mordante, sstefan1, libcxx-commits, ldionne, mgorny, arichardson, miyuki
Differential Revision: https://reviews.llvm.org/D131963
2022-08-13 20:33:12 +00:00
|
|
|
return std::use_facet<ctype<_CharT> >(__loc).is(ctype_base::punct, __c);
|
2010-05-11 19:42:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class _CharT>
|
|
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
|
|
|
bool
|
|
|
|
isxdigit(_CharT __c, const locale& __loc)
|
|
|
|
{
|
[libc++] Add custom clang-tidy checks
Reviewed By: #libc, ldionne
Spies: jwakely, beanz, smeenai, cfe-commits, tschuett, avogelsgesang, Mordante, sstefan1, libcxx-commits, ldionne, mgorny, arichardson, miyuki
Differential Revision: https://reviews.llvm.org/D131963
2022-08-13 20:33:12 +00:00
|
|
|
return std::use_facet<ctype<_CharT> >(__loc).is(ctype_base::xdigit, __c);
|
2010-05-11 19:42:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class _CharT>
|
|
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
|
|
|
bool
|
|
|
|
isalnum(_CharT __c, const locale& __loc)
|
|
|
|
{
|
[libc++] Add custom clang-tidy checks
Reviewed By: #libc, ldionne
Spies: jwakely, beanz, smeenai, cfe-commits, tschuett, avogelsgesang, Mordante, sstefan1, libcxx-commits, ldionne, mgorny, arichardson, miyuki
Differential Revision: https://reviews.llvm.org/D131963
2022-08-13 20:33:12 +00:00
|
|
|
return std::use_facet<ctype<_CharT> >(__loc).is(ctype_base::alnum, __c);
|
2010-05-11 19:42:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class _CharT>
|
|
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
|
|
|
bool
|
|
|
|
isgraph(_CharT __c, const locale& __loc)
|
|
|
|
{
|
[libc++] Add custom clang-tidy checks
Reviewed By: #libc, ldionne
Spies: jwakely, beanz, smeenai, cfe-commits, tschuett, avogelsgesang, Mordante, sstefan1, libcxx-commits, ldionne, mgorny, arichardson, miyuki
Differential Revision: https://reviews.llvm.org/D131963
2022-08-13 20:33:12 +00:00
|
|
|
return std::use_facet<ctype<_CharT> >(__loc).is(ctype_base::graph, __c);
|
2010-05-11 19:42:16 +00:00
|
|
|
}
|
|
|
|
|
2023-04-08 12:59:09 +00:00
|
|
|
template <class _CharT>
|
|
|
|
_LIBCPP_HIDE_FROM_ABI bool isblank(_CharT __c, const locale& __loc) {
|
|
|
|
return std::use_facet<ctype<_CharT> >(__loc).is(ctype_base::blank, __c);
|
|
|
|
}
|
|
|
|
|
2010-05-11 19:42:16 +00:00
|
|
|
template <class _CharT>
|
|
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
|
|
|
_CharT
|
|
|
|
toupper(_CharT __c, const locale& __loc)
|
|
|
|
{
|
[libc++] Add custom clang-tidy checks
Reviewed By: #libc, ldionne
Spies: jwakely, beanz, smeenai, cfe-commits, tschuett, avogelsgesang, Mordante, sstefan1, libcxx-commits, ldionne, mgorny, arichardson, miyuki
Differential Revision: https://reviews.llvm.org/D131963
2022-08-13 20:33:12 +00:00
|
|
|
return std::use_facet<ctype<_CharT> >(__loc).toupper(__c);
|
2010-05-11 19:42:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class _CharT>
|
|
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
|
|
|
_CharT
|
|
|
|
tolower(_CharT __c, const locale& __loc)
|
|
|
|
{
|
[libc++] Add custom clang-tidy checks
Reviewed By: #libc, ldionne
Spies: jwakely, beanz, smeenai, cfe-commits, tschuett, avogelsgesang, Mordante, sstefan1, libcxx-commits, ldionne, mgorny, arichardson, miyuki
Differential Revision: https://reviews.llvm.org/D131963
2022-08-13 20:33:12 +00:00
|
|
|
return std::use_facet<ctype<_CharT> >(__loc).tolower(__c);
|
2010-05-11 19:42:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// codecvt_base
|
|
|
|
|
2023-06-14 17:17:50 +00:00
|
|
|
class _LIBCPP_EXPORTED_FROM_ABI codecvt_base
|
2010-05-11 19:42:16 +00:00
|
|
|
{
|
|
|
|
public:
|
2018-07-11 23:14:33 +00:00
|
|
|
_LIBCPP_INLINE_VISIBILITY codecvt_base() {}
|
2010-05-11 19:42:16 +00:00
|
|
|
enum result {ok, partial, error, noconv};
|
|
|
|
};
|
|
|
|
|
|
|
|
// template <class internT, class externT, class stateT> class codecvt;
|
|
|
|
|
2017-01-04 23:56:00 +00:00
|
|
|
template <class _InternT, class _ExternT, class _StateT> class _LIBCPP_TEMPLATE_VIS codecvt;
|
2010-05-11 19:42:16 +00:00
|
|
|
|
|
|
|
// template <> class codecvt<char, char, mbstate_t>
|
|
|
|
|
|
|
|
template <>
|
2023-06-14 17:17:50 +00:00
|
|
|
class _LIBCPP_EXPORTED_FROM_ABI codecvt<char, char, mbstate_t>
|
2010-05-11 19:42:16 +00:00
|
|
|
: public locale::facet,
|
|
|
|
public codecvt_base
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef char intern_type;
|
|
|
|
typedef char extern_type;
|
|
|
|
typedef mbstate_t state_type;
|
|
|
|
|
2018-07-11 23:14:33 +00:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2010-05-11 19:42:16 +00:00
|
|
|
explicit codecvt(size_t __refs = 0)
|
|
|
|
: locale::facet(__refs) {}
|
|
|
|
|
2018-07-11 23:14:33 +00:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2010-05-11 19:42:16 +00:00
|
|
|
result out(state_type& __st,
|
|
|
|
const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
|
|
|
|
extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const
|
|
|
|
{
|
|
|
|
return do_out(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
|
|
|
|
}
|
|
|
|
|
2018-07-11 23:14:33 +00:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2010-05-11 19:42:16 +00:00
|
|
|
result unshift(state_type& __st,
|
|
|
|
extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const
|
|
|
|
{
|
|
|
|
return do_unshift(__st, __to, __to_end, __to_nxt);
|
|
|
|
}
|
|
|
|
|
2018-07-11 23:14:33 +00:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2010-05-11 19:42:16 +00:00
|
|
|
result in(state_type& __st,
|
|
|
|
const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
|
|
|
|
intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const
|
|
|
|
{
|
|
|
|
return do_in(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
|
|
|
|
}
|
|
|
|
|
2018-07-11 23:14:33 +00:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2011-05-31 15:34:58 +00:00
|
|
|
int encoding() const _NOEXCEPT
|
2010-05-11 19:42:16 +00:00
|
|
|
{
|
|
|
|
return do_encoding();
|
|
|
|
}
|
|
|
|
|
2018-07-11 23:14:33 +00:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2011-05-31 15:34:58 +00:00
|
|
|
bool always_noconv() const _NOEXCEPT
|
2010-05-11 19:42:16 +00:00
|
|
|
{
|
|
|
|
return do_always_noconv();
|
|
|
|
}
|
|
|
|
|
2018-07-11 23:14:33 +00:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2010-05-11 19:42:16 +00:00
|
|
|
int length(state_type& __st, const extern_type* __frm, const extern_type* __end, size_t __mx) const
|
|
|
|
{
|
|
|
|
return do_length(__st, __frm, __end, __mx);
|
|
|
|
}
|
|
|
|
|
2018-07-11 23:14:33 +00:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2011-05-31 15:34:58 +00:00
|
|
|
int max_length() const _NOEXCEPT
|
2010-05-11 19:42:16 +00:00
|
|
|
{
|
|
|
|
return do_max_length();
|
|
|
|
}
|
|
|
|
|
|
|
|
static locale::id id;
|
|
|
|
|
|
|
|
protected:
|
2018-07-11 23:14:33 +00:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2010-05-11 19:42:16 +00:00
|
|
|
explicit codecvt(const char*, size_t __refs = 0)
|
|
|
|
: locale::facet(__refs) {}
|
|
|
|
|
2022-08-24 00:14:29 +00:00
|
|
|
~codecvt() override;
|
2010-05-11 19:42:16 +00:00
|
|
|
|
|
|
|
virtual result do_out(state_type& __st,
|
|
|
|
const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
|
|
|
|
extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
|
|
|
|
virtual result do_in(state_type& __st,
|
|
|
|
const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
|
|
|
|
intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
|
|
|
|
virtual result do_unshift(state_type& __st,
|
|
|
|
extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
|
2011-05-31 15:34:58 +00:00
|
|
|
virtual int do_encoding() const _NOEXCEPT;
|
|
|
|
virtual bool do_always_noconv() const _NOEXCEPT;
|
2010-05-11 19:42:16 +00:00
|
|
|
virtual int do_length(state_type& __st, const extern_type* __frm, const extern_type* __end, size_t __mx) const;
|
2011-05-31 15:34:58 +00:00
|
|
|
virtual int do_max_length() const _NOEXCEPT;
|
2010-05-11 19:42:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// template <> class codecvt<wchar_t, char, mbstate_t>
|
|
|
|
|
2021-08-23 19:32:36 +00:00
|
|
|
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
|
2010-05-11 19:42:16 +00:00
|
|
|
template <>
|
2023-06-14 17:17:50 +00:00
|
|
|
class _LIBCPP_EXPORTED_FROM_ABI codecvt<wchar_t, char, mbstate_t>
|
2010-05-11 19:42:16 +00:00
|
|
|
: public locale::facet,
|
|
|
|
public codecvt_base
|
|
|
|
{
|
2022-09-02 14:19:07 +00:00
|
|
|
locale_t __l_;
|
2010-05-11 19:42:16 +00:00
|
|
|
public:
|
|
|
|
typedef wchar_t intern_type;
|
|
|
|
typedef char extern_type;
|
|
|
|
typedef mbstate_t state_type;
|
|
|
|
|
|
|
|
explicit codecvt(size_t __refs = 0);
|
|
|
|
|
2018-07-11 23:14:33 +00:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2010-05-11 19:42:16 +00:00
|
|
|
result out(state_type& __st,
|
|
|
|
const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
|
|
|
|
extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const
|
|
|
|
{
|
|
|
|
return do_out(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
|
|
|
|
}
|
|
|
|
|
2018-07-11 23:14:33 +00:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2010-05-11 19:42:16 +00:00
|
|
|
result unshift(state_type& __st,
|
|
|
|
extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const
|
|
|
|
{
|
|
|
|
return do_unshift(__st, __to, __to_end, __to_nxt);
|
|
|
|
}
|
|
|
|
|
2018-07-11 23:14:33 +00:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2010-05-11 19:42:16 +00:00
|
|
|
result in(state_type& __st,
|
|
|
|
const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
|
|
|
|
intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const
|
|
|
|
{
|
|
|
|
return do_in(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
|
|
|
|
}
|
|
|
|
|
2018-07-11 23:14:33 +00:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2011-05-31 15:34:58 +00:00
|
|
|
int encoding() const _NOEXCEPT
|
2010-05-11 19:42:16 +00:00
|
|
|
{
|
|
|
|
return do_encoding();
|
|
|
|
}
|
|
|
|
|
2018-07-11 23:14:33 +00:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2011-05-31 15:34:58 +00:00
|
|
|
bool always_noconv() const _NOEXCEPT
|
2010-05-11 19:42:16 +00:00
|
|
|
{
|
|
|
|
return do_always_noconv();
|
|
|
|
}
|
|
|
|
|
2018-07-11 23:14:33 +00:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2010-05-11 19:42:16 +00:00
|
|
|
int length(state_type& __st, const extern_type* __frm, const extern_type* __end, size_t __mx) const
|
|
|
|
{
|
|
|
|
return do_length(__st, __frm, __end, __mx);
|
|
|
|
}
|
|
|
|
|
2018-07-11 23:14:33 +00:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2011-05-31 15:34:58 +00:00
|
|
|
int max_length() const _NOEXCEPT
|
2010-05-11 19:42:16 +00:00
|
|
|
{
|
|
|
|
return do_max_length();
|
|
|
|
}
|
|
|
|
|
|
|
|
static locale::id id;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
explicit codecvt(const char*, size_t __refs = 0);
|
|
|
|
|
2022-08-24 00:14:29 +00:00
|
|
|
~codecvt() override;
|
2010-05-11 19:42:16 +00:00
|
|
|
|
|
|
|
virtual result do_out(state_type& __st,
|
|
|
|
const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
|
|
|
|
extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
|
|
|
|
virtual result do_in(state_type& __st,
|
|
|
|
const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
|
|
|
|
intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
|
|
|
|
virtual result do_unshift(state_type& __st,
|
|
|
|
extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
|
2011-05-31 15:34:58 +00:00
|
|
|
virtual int do_encoding() const _NOEXCEPT;
|
|
|
|
virtual bool do_always_noconv() const _NOEXCEPT;
|
2010-05-11 19:42:16 +00:00
|
|
|
virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const;
|
2011-05-31 15:34:58 +00:00
|
|
|
virtual int do_max_length() const _NOEXCEPT;
|
2010-05-11 19:42:16 +00:00
|
|
|
};
|
2021-08-23 19:32:36 +00:00
|
|
|
#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
|
2010-05-11 19:42:16 +00:00
|
|
|
|
2020-12-02 07:57:02 +00:00
|
|
|
// template <> class codecvt<char16_t, char, mbstate_t> // deprecated in C++20
|
2010-05-11 19:42:16 +00:00
|
|
|
|
|
|
|
template <>
|
2023-06-14 17:17:50 +00:00
|
|
|
class _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_EXPORTED_FROM_ABI codecvt<char16_t, char, mbstate_t>
|
2010-05-11 19:42:16 +00:00
|
|
|
: public locale::facet,
|
|
|
|
public codecvt_base
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef char16_t intern_type;
|
|
|
|
typedef char extern_type;
|
|
|
|
typedef mbstate_t state_type;
|
|
|
|
|
2018-07-11 23:14:33 +00:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2010-05-11 19:42:16 +00:00
|
|
|
explicit codecvt(size_t __refs = 0)
|
|
|
|
: locale::facet(__refs) {}
|
|
|
|
|
2018-07-11 23:14:33 +00:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2010-05-11 19:42:16 +00:00
|
|
|
result out(state_type& __st,
|
|
|
|
const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
|
|
|
|
extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const
|
|
|
|
{
|
|
|
|
return do_out(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
|
|
|
|
}
|
|
|
|
|
2018-07-11 23:14:33 +00:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2010-05-11 19:42:16 +00:00
|
|
|
result unshift(state_type& __st,
|
|
|
|
extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const
|
|
|
|
{
|
|
|
|
return do_unshift(__st, __to, __to_end, __to_nxt);
|
|
|
|
}
|
|
|
|
|
2018-07-11 23:14:33 +00:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2010-05-11 19:42:16 +00:00
|
|
|
result in(state_type& __st,
|
|
|
|
const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
|
|
|
|
intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const
|
|
|
|
{
|
|
|
|
return do_in(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
|
|
|
|
}
|
|
|
|
|
2018-07-11 23:14:33 +00:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2011-05-31 15:34:58 +00:00
|
|
|
int encoding() const _NOEXCEPT
|
2010-05-11 19:42:16 +00:00
|
|
|
{
|
|
|
|
return do_encoding();
|
|
|
|
}
|
|
|
|
|
2018-07-11 23:14:33 +00:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2011-05-31 15:34:58 +00:00
|
|
|
bool always_noconv() const _NOEXCEPT
|
2010-05-11 19:42:16 +00:00
|
|
|
{
|
|
|
|
return do_always_noconv();
|
|
|
|
}
|
|
|
|
|
2018-07-11 23:14:33 +00:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2010-05-11 19:42:16 +00:00
|
|
|
int length(state_type& __st, const extern_type* __frm, const extern_type* __end, size_t __mx) const
|
|
|
|
{
|
|
|
|
return do_length(__st, __frm, __end, __mx);
|
|
|
|
}
|
|
|
|
|
2018-07-11 23:14:33 +00:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2011-05-31 15:34:58 +00:00
|
|
|
int max_length() const _NOEXCEPT
|
2010-05-11 19:42:16 +00:00
|
|
|
{
|
|
|
|
return do_max_length();
|
|
|
|
}
|
|
|
|
|
|
|
|
static locale::id id;
|
|
|
|
|
|
|
|
protected:
|
2018-07-11 23:14:33 +00:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2010-05-11 19:42:16 +00:00
|
|
|
explicit codecvt(const char*, size_t __refs = 0)
|
|
|
|
: locale::facet(__refs) {}
|
|
|
|
|
2022-08-24 00:14:29 +00:00
|
|
|
~codecvt() override;
|
2010-05-11 19:42:16 +00:00
|
|
|
|
|
|
|
virtual result do_out(state_type& __st,
|
|
|
|
const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
|
|
|
|
extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
|
|
|
|
virtual result do_in(state_type& __st,
|
|
|
|
const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
|
|
|
|
intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
|
|
|
|
virtual result do_unshift(state_type& __st,
|
|
|
|
extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
|
2011-05-31 15:34:58 +00:00
|
|
|
virtual int do_encoding() const _NOEXCEPT;
|
|
|
|
virtual bool do_always_noconv() const _NOEXCEPT;
|
2010-05-11 19:42:16 +00:00
|
|
|
virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const;
|
2011-05-31 15:34:58 +00:00
|
|
|
virtual int do_max_length() const _NOEXCEPT;
|
2010-05-11 19:42:16 +00:00
|
|
|
};
|
|
|
|
|
2021-04-19 01:47:08 +00:00
|
|
|
#ifndef _LIBCPP_HAS_NO_CHAR8_T
|
2020-12-02 07:57:02 +00:00
|
|
|
|
|
|
|
// template <> class codecvt<char16_t, char8_t, mbstate_t> // C++20
|
|
|
|
|
|
|
|
template <>
|
2023-06-14 17:17:50 +00:00
|
|
|
class _LIBCPP_EXPORTED_FROM_ABI codecvt<char16_t, char8_t, mbstate_t>
|
2020-12-02 07:57:02 +00:00
|
|
|
: public locale::facet,
|
|
|
|
public codecvt_base
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef char16_t intern_type;
|
|
|
|
typedef char8_t extern_type;
|
|
|
|
typedef mbstate_t state_type;
|
|
|
|
|
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
|
|
|
explicit codecvt(size_t __refs = 0)
|
|
|
|
: locale::facet(__refs) {}
|
|
|
|
|
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
|
|
|
result out(state_type& __st,
|
|
|
|
const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
|
|
|
|
extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const
|
|
|
|
{
|
|
|
|
return do_out(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
|
|
|
|
}
|
|
|
|
|
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
|
|
|
result unshift(state_type& __st,
|
|
|
|
extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const
|
|
|
|
{
|
|
|
|
return do_unshift(__st, __to, __to_end, __to_nxt);
|
|
|
|
}
|
|
|
|
|
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
|
|
|
result in(state_type& __st,
|
|
|
|
const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
|
|
|
|
intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const
|
|
|
|
{
|
|
|
|
return do_in(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
|
|
|
|
}
|
|
|
|
|
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
|
|
|
int encoding() const _NOEXCEPT
|
|
|
|
{
|
|
|
|
return do_encoding();
|
|
|
|
}
|
|
|
|
|
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
|
|
|
bool always_noconv() const _NOEXCEPT
|
|
|
|
{
|
|
|
|
return do_always_noconv();
|
|
|
|
}
|
|
|
|
|
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
|
|
|
int length(state_type& __st, const extern_type* __frm, const extern_type* __end, size_t __mx) const
|
|
|
|
{
|
|
|
|
return do_length(__st, __frm, __end, __mx);
|
|
|
|
}
|
|
|
|
|
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
|
|
|
int max_length() const _NOEXCEPT
|
|
|
|
{
|
|
|
|
return do_max_length();
|
|
|
|
}
|
|
|
|
|
|
|
|
static locale::id id;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
|
|
|
explicit codecvt(const char*, size_t __refs = 0)
|
|
|
|
: locale::facet(__refs) {}
|
|
|
|
|
2022-08-24 00:14:29 +00:00
|
|
|
~codecvt() override;
|
2020-12-02 07:57:02 +00:00
|
|
|
|
|
|
|
virtual result do_out(state_type& __st,
|
|
|
|
const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
|
|
|
|
extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
|
|
|
|
virtual result do_in(state_type& __st,
|
|
|
|
const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
|
|
|
|
intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
|
|
|
|
virtual result do_unshift(state_type& __st,
|
|
|
|
extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
|
|
|
|
virtual int do_encoding() const _NOEXCEPT;
|
|
|
|
virtual bool do_always_noconv() const _NOEXCEPT;
|
|
|
|
virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const;
|
|
|
|
virtual int do_max_length() const _NOEXCEPT;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// template <> class codecvt<char32_t, char, mbstate_t> // deprecated in C++20
|
2010-05-11 19:42:16 +00:00
|
|
|
|
|
|
|
template <>
|
2023-06-14 17:17:50 +00:00
|
|
|
class _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_EXPORTED_FROM_ABI codecvt<char32_t, char, mbstate_t>
|
2010-05-11 19:42:16 +00:00
|
|
|
: public locale::facet,
|
|
|
|
public codecvt_base
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef char32_t intern_type;
|
|
|
|
typedef char extern_type;
|
|
|
|
typedef mbstate_t state_type;
|
|
|
|
|
2018-07-11 23:14:33 +00:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2010-05-11 19:42:16 +00:00
|
|
|
explicit codecvt(size_t __refs = 0)
|
|
|
|
: locale::facet(__refs) {}
|
|
|
|
|
2018-07-11 23:14:33 +00:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2010-05-11 19:42:16 +00:00
|
|
|
result out(state_type& __st,
|
|
|
|
const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
|
|
|
|
extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const
|
|
|
|
{
|
|
|
|
return do_out(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
|
|
|
|
}
|
|
|
|
|
2018-07-11 23:14:33 +00:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2010-05-11 19:42:16 +00:00
|
|
|
result unshift(state_type& __st,
|
|
|
|
extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const
|
|
|
|
{
|
|
|
|
return do_unshift(__st, __to, __to_end, __to_nxt);
|
|
|
|
}
|
|
|
|
|
2018-07-11 23:14:33 +00:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2010-05-11 19:42:16 +00:00
|
|
|
result in(state_type& __st,
|
|
|
|
const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
|
|
|
|
intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const
|
|
|
|
{
|
|
|
|
return do_in(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
|
|
|
|
}
|
|
|
|
|
2018-07-11 23:14:33 +00:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2011-05-31 15:34:58 +00:00
|
|
|
int encoding() const _NOEXCEPT
|
2010-05-11 19:42:16 +00:00
|
|
|
{
|
|
|
|
return do_encoding();
|
|
|
|
}
|
|
|
|
|
2018-07-11 23:14:33 +00:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2011-05-31 15:34:58 +00:00
|
|
|
bool always_noconv() const _NOEXCEPT
|
2010-05-11 19:42:16 +00:00
|
|
|
{
|
|
|
|
return do_always_noconv();
|
|
|
|
}
|
|
|
|
|
2018-07-11 23:14:33 +00:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2010-05-11 19:42:16 +00:00
|
|
|
int length(state_type& __st, const extern_type* __frm, const extern_type* __end, size_t __mx) const
|
|
|
|
{
|
|
|
|
return do_length(__st, __frm, __end, __mx);
|
|
|
|
}
|
|
|
|
|
2018-07-11 23:14:33 +00:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2011-05-31 15:34:58 +00:00
|
|
|
int max_length() const _NOEXCEPT
|
2010-05-11 19:42:16 +00:00
|
|
|
{
|
|
|
|
return do_max_length();
|
|
|
|
}
|
|
|
|
|
|
|
|
static locale::id id;
|
|
|
|
|
|
|
|
protected:
|
2018-07-11 23:14:33 +00:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2010-05-11 19:42:16 +00:00
|
|
|
explicit codecvt(const char*, size_t __refs = 0)
|
|
|
|
: locale::facet(__refs) {}
|
|
|
|
|
2022-08-24 00:14:29 +00:00
|
|
|
~codecvt() override;
|
2010-05-11 19:42:16 +00:00
|
|
|
|
|
|
|
virtual result do_out(state_type& __st,
|
|
|
|
const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
|
|
|
|
extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
|
|
|
|
virtual result do_in(state_type& __st,
|
|
|
|
const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
|
|
|
|
intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
|
|
|
|
virtual result do_unshift(state_type& __st,
|
|
|
|
extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
|
2011-05-31 15:34:58 +00:00
|
|
|
virtual int do_encoding() const _NOEXCEPT;
|
|
|
|
virtual bool do_always_noconv() const _NOEXCEPT;
|
2010-05-11 19:42:16 +00:00
|
|
|
virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const;
|
2011-05-31 15:34:58 +00:00
|
|
|
virtual int do_max_length() const _NOEXCEPT;
|
2010-05-11 19:42:16 +00:00
|
|
|
};
|
|
|
|
|
2021-04-19 01:47:08 +00:00
|
|
|
#ifndef _LIBCPP_HAS_NO_CHAR8_T
|
2020-12-02 07:57:02 +00:00
|
|
|
|
|
|
|
// template <> class codecvt<char32_t, char8_t, mbstate_t> // C++20
|
|
|
|
|
|
|
|
template <>
|
2023-06-14 17:17:50 +00:00
|
|
|
class _LIBCPP_EXPORTED_FROM_ABI codecvt<char32_t, char8_t, mbstate_t>
|
2020-12-02 07:57:02 +00:00
|
|
|
: public locale::facet,
|
|
|
|
public codecvt_base
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef char32_t intern_type;
|
|
|
|
typedef char8_t extern_type;
|
|
|
|
typedef mbstate_t state_type;
|
|
|
|
|
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
|
|
|
explicit codecvt(size_t __refs = 0)
|
|
|
|
: locale::facet(__refs) {}
|
|
|
|
|
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
|
|
|
result out(state_type& __st,
|
|
|
|
const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
|
|
|
|
extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const
|
|
|
|
{
|
|
|
|
return do_out(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
|
|
|
|
}
|
|
|
|
|
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
|
|
|
result unshift(state_type& __st,
|
|
|
|
extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const
|
|
|
|
{
|
|
|
|
return do_unshift(__st, __to, __to_end, __to_nxt);
|
|
|
|
}
|
|
|
|
|
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
|
|
|
result in(state_type& __st,
|
|
|
|
const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
|
|
|
|
intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const
|
|
|
|
{
|
|
|
|
return do_in(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
|
|
|
|
}
|
|
|
|
|
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
|
|
|
int encoding() const _NOEXCEPT
|
|
|
|
{
|
|
|
|
return do_encoding();
|
|
|
|
}
|
|
|
|
|
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
|
|
|
bool always_noconv() const _NOEXCEPT
|
|
|
|
{
|
|
|
|
return do_always_noconv();
|
|
|
|
}
|
|
|
|
|
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
|
|
|
int length(state_type& __st, const extern_type* __frm, const extern_type* __end, size_t __mx) const
|
|
|
|
{
|
|
|
|
return do_length(__st, __frm, __end, __mx);
|
|
|
|
}
|
|
|
|
|
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
|
|
|
int max_length() const _NOEXCEPT
|
|
|
|
{
|
|
|
|
return do_max_length();
|
|
|
|
}
|
|
|
|
|
|
|
|
static locale::id id;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
|
|
|
explicit codecvt(const char*, size_t __refs = 0)
|
|
|
|
: locale::facet(__refs) {}
|
|
|
|
|
2022-08-24 00:14:29 +00:00
|
|
|
~codecvt() override;
|
2020-12-02 07:57:02 +00:00
|
|
|
|
|
|
|
virtual result do_out(state_type& __st,
|
|
|
|
const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
|
|
|
|
extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
|
|
|
|
virtual result do_in(state_type& __st,
|
|
|
|
const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
|
|
|
|
intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
|
|
|
|
virtual result do_unshift(state_type& __st,
|
|
|
|
extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
|
|
|
|
virtual int do_encoding() const _NOEXCEPT;
|
|
|
|
virtual bool do_always_noconv() const _NOEXCEPT;
|
|
|
|
virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const;
|
|
|
|
virtual int do_max_length() const _NOEXCEPT;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2010-05-11 19:42:16 +00:00
|
|
|
// template <class _InternT, class _ExternT, class _StateT> class codecvt_byname
|
|
|
|
|
|
|
|
template <class _InternT, class _ExternT, class _StateT>
|
2017-01-04 23:56:00 +00:00
|
|
|
class _LIBCPP_TEMPLATE_VIS codecvt_byname
|
2010-05-11 19:42:16 +00:00
|
|
|
: public codecvt<_InternT, _ExternT, _StateT>
|
|
|
|
{
|
|
|
|
public:
|
2023-05-24 15:46:13 +00:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2010-05-11 19:42:16 +00:00
|
|
|
explicit codecvt_byname(const char* __nm, size_t __refs = 0)
|
|
|
|
: codecvt<_InternT, _ExternT, _StateT>(__nm, __refs) {}
|
2023-05-24 15:46:13 +00:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2010-05-11 19:42:16 +00:00
|
|
|
explicit codecvt_byname(const string& __nm, size_t __refs = 0)
|
|
|
|
: codecvt<_InternT, _ExternT, _StateT>(__nm.c_str(), __refs) {}
|
|
|
|
protected:
|
2022-08-24 00:14:29 +00:00
|
|
|
~codecvt_byname() override;
|
2010-05-11 19:42:16 +00:00
|
|
|
};
|
|
|
|
|
2020-12-02 07:57:02 +00:00
|
|
|
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
|
2010-05-11 19:42:16 +00:00
|
|
|
template <class _InternT, class _ExternT, class _StateT>
|
|
|
|
codecvt_byname<_InternT, _ExternT, _StateT>::~codecvt_byname()
|
|
|
|
{
|
|
|
|
}
|
2020-12-02 07:57:02 +00:00
|
|
|
_LIBCPP_SUPPRESS_DEPRECATED_POP
|
2010-05-11 19:42:16 +00:00
|
|
|
|
2021-06-08 21:25:08 +00:00
|
|
|
extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char, char, mbstate_t>;
|
2021-08-23 19:32:36 +00:00
|
|
|
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
|
2021-06-08 21:25:08 +00:00
|
|
|
extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<wchar_t, char, mbstate_t>;
|
2021-08-23 19:32:36 +00:00
|
|
|
#endif
|
2021-06-08 21:25:08 +00:00
|
|
|
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
|
2021-04-19 01:47:08 +00:00
|
|
|
#ifndef _LIBCPP_HAS_NO_CHAR8_T
|
2021-06-08 21:25:08 +00:00
|
|
|
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
|
2020-12-02 07:57:02 +00:00
|
|
|
#endif
|
2010-05-11 19:42:16 +00:00
|
|
|
|
2011-11-29 18:15:50 +00:00
|
|
|
template <size_t _Np>
|
2010-05-11 19:42:16 +00:00
|
|
|
struct __narrow_to_utf8
|
|
|
|
{
|
|
|
|
template <class _OutputIterator, class _CharT>
|
|
|
|
_OutputIterator
|
|
|
|
operator()(_OutputIterator __s, const _CharT* __wb, const _CharT* __we) const;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <>
|
|
|
|
struct __narrow_to_utf8<8>
|
|
|
|
{
|
|
|
|
template <class _OutputIterator, class _CharT>
|
2018-07-11 23:14:33 +00:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2010-05-11 19:42:16 +00:00
|
|
|
_OutputIterator
|
|
|
|
operator()(_OutputIterator __s, const _CharT* __wb, const _CharT* __we) const
|
|
|
|
{
|
|
|
|
for (; __wb < __we; ++__wb, ++__s)
|
|
|
|
*__s = *__wb;
|
|
|
|
return __s;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-12-02 07:57:02 +00:00
|
|
|
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
|
2010-05-11 19:42:16 +00:00
|
|
|
template <>
|
2023-06-14 17:17:50 +00:00
|
|
|
struct _LIBCPP_EXPORTED_FROM_ABI __narrow_to_utf8<16>
|
2010-05-11 19:42:16 +00:00
|
|
|
: public codecvt<char16_t, char, mbstate_t>
|
|
|
|
{
|
2018-07-11 23:14:33 +00:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2010-05-11 19:42:16 +00:00
|
|
|
__narrow_to_utf8() : codecvt<char16_t, char, mbstate_t>(1) {}
|
2020-12-02 07:57:02 +00:00
|
|
|
_LIBCPP_SUPPRESS_DEPRECATED_POP
|
2010-05-11 19:42:16 +00:00
|
|
|
|
2022-08-24 00:14:29 +00:00
|
|
|
~__narrow_to_utf8() override;
|
2010-05-11 19:42:16 +00:00
|
|
|
|
|
|
|
template <class _OutputIterator, class _CharT>
|
2018-07-11 23:14:33 +00:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2010-05-11 19:42:16 +00:00
|
|
|
_OutputIterator
|
|
|
|
operator()(_OutputIterator __s, const _CharT* __wb, const _CharT* __we) const
|
|
|
|
{
|
|
|
|
result __r = ok;
|
|
|
|
mbstate_t __mb;
|
|
|
|
while (__wb < __we && __r != error)
|
|
|
|
{
|
|
|
|
const int __sz = 32;
|
|
|
|
char __buf[__sz];
|
|
|
|
char* __bn;
|
|
|
|
const char16_t* __wn = (const char16_t*)__wb;
|
|
|
|
__r = do_out(__mb, (const char16_t*)__wb, (const char16_t*)__we, __wn,
|
|
|
|
__buf, __buf+__sz, __bn);
|
|
|
|
if (__r == codecvt_base::error || __wn == (const char16_t*)__wb)
|
|
|
|
__throw_runtime_error("locale not supported");
|
|
|
|
for (const char* __p = __buf; __p < __bn; ++__p, ++__s)
|
|
|
|
*__s = *__p;
|
|
|
|
__wb = (const _CharT*)__wn;
|
|
|
|
}
|
|
|
|
return __s;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-12-02 07:57:02 +00:00
|
|
|
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
|
2010-05-11 19:42:16 +00:00
|
|
|
template <>
|
2023-06-14 17:17:50 +00:00
|
|
|
struct _LIBCPP_EXPORTED_FROM_ABI __narrow_to_utf8<32>
|
2010-05-11 19:42:16 +00:00
|
|
|
: public codecvt<char32_t, char, mbstate_t>
|
|
|
|
{
|
2018-07-11 23:14:33 +00:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2010-05-11 19:42:16 +00:00
|
|
|
__narrow_to_utf8() : codecvt<char32_t, char, mbstate_t>(1) {}
|
2020-12-02 07:57:02 +00:00
|
|
|
_LIBCPP_SUPPRESS_DEPRECATED_POP
|
2010-05-11 19:42:16 +00:00
|
|
|
|
2022-08-24 00:14:29 +00:00
|
|
|
~__narrow_to_utf8() override;
|
2010-05-11 19:42:16 +00:00
|
|
|
|
|
|
|
template <class _OutputIterator, class _CharT>
|
2018-07-11 23:14:33 +00:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2010-05-11 19:42:16 +00:00
|
|
|
_OutputIterator
|
|
|
|
operator()(_OutputIterator __s, const _CharT* __wb, const _CharT* __we) const
|
|
|
|
{
|
|
|
|
result __r = ok;
|
|
|
|
mbstate_t __mb;
|
|
|
|
while (__wb < __we && __r != error)
|
|
|
|
{
|
|
|
|
const int __sz = 32;
|
|
|
|
char __buf[__sz];
|
|
|
|
char* __bn;
|
|
|
|
const char32_t* __wn = (const char32_t*)__wb;
|
|
|
|
__r = do_out(__mb, (const char32_t*)__wb, (const char32_t*)__we, __wn,
|
|
|
|
__buf, __buf+__sz, __bn);
|
|
|
|
if (__r == codecvt_base::error || __wn == (const char32_t*)__wb)
|
|
|
|
__throw_runtime_error("locale not supported");
|
|
|
|
for (const char* __p = __buf; __p < __bn; ++__p, ++__s)
|
|
|
|
*__s = *__p;
|
|
|
|
__wb = (const _CharT*)__wn;
|
|
|
|
}
|
|
|
|
return __s;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2011-11-29 18:15:50 +00:00
|
|
|
template <size_t _Np>
|
2010-05-11 19:42:16 +00:00
|
|
|
struct __widen_from_utf8
|
|
|
|
{
|
|
|
|
template <class _OutputIterator>
|
|
|
|
_OutputIterator
|
|
|
|
operator()(_OutputIterator __s, const char* __nb, const char* __ne) const;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <>
|
|
|
|
struct __widen_from_utf8<8>
|
|
|
|
{
|
|
|
|
template <class _OutputIterator>
|
2018-07-11 23:14:33 +00:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2010-05-11 19:42:16 +00:00
|
|
|
_OutputIterator
|
|
|
|
operator()(_OutputIterator __s, const char* __nb, const char* __ne) const
|
|
|
|
{
|
|
|
|
for (; __nb < __ne; ++__nb, ++__s)
|
|
|
|
*__s = *__nb;
|
|
|
|
return __s;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-12-02 07:57:02 +00:00
|
|
|
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
|
2010-05-11 19:42:16 +00:00
|
|
|
template <>
|
2023-06-14 17:17:50 +00:00
|
|
|
struct _LIBCPP_EXPORTED_FROM_ABI __widen_from_utf8<16>
|
2010-05-11 19:42:16 +00:00
|
|
|
: public codecvt<char16_t, char, mbstate_t>
|
|
|
|
{
|
2018-07-11 23:14:33 +00:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2010-05-11 19:42:16 +00:00
|
|
|
__widen_from_utf8() : codecvt<char16_t, char, mbstate_t>(1) {}
|
2020-12-02 07:57:02 +00:00
|
|
|
_LIBCPP_SUPPRESS_DEPRECATED_POP
|
2010-05-11 19:42:16 +00:00
|
|
|
|
2022-08-24 00:14:29 +00:00
|
|
|
~__widen_from_utf8() override;
|
2010-05-11 19:42:16 +00:00
|
|
|
|
|
|
|
template <class _OutputIterator>
|
2018-07-11 23:14:33 +00:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2010-05-11 19:42:16 +00:00
|
|
|
_OutputIterator
|
|
|
|
operator()(_OutputIterator __s, const char* __nb, const char* __ne) const
|
|
|
|
{
|
|
|
|
result __r = ok;
|
|
|
|
mbstate_t __mb;
|
|
|
|
while (__nb < __ne && __r != error)
|
|
|
|
{
|
|
|
|
const int __sz = 32;
|
|
|
|
char16_t __buf[__sz];
|
|
|
|
char16_t* __bn;
|
|
|
|
const char* __nn = __nb;
|
|
|
|
__r = do_in(__mb, __nb, __ne - __nb > __sz ? __nb+__sz : __ne, __nn,
|
|
|
|
__buf, __buf+__sz, __bn);
|
|
|
|
if (__r == codecvt_base::error || __nn == __nb)
|
|
|
|
__throw_runtime_error("locale not supported");
|
|
|
|
for (const char16_t* __p = __buf; __p < __bn; ++__p, ++__s)
|
2020-10-27 11:01:54 +00:00
|
|
|
*__s = *__p;
|
2010-05-11 19:42:16 +00:00
|
|
|
__nb = __nn;
|
|
|
|
}
|
|
|
|
return __s;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-12-02 07:57:02 +00:00
|
|
|
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
|
2010-05-11 19:42:16 +00:00
|
|
|
template <>
|
2023-06-14 17:17:50 +00:00
|
|
|
struct _LIBCPP_EXPORTED_FROM_ABI __widen_from_utf8<32>
|
2010-05-11 19:42:16 +00:00
|
|
|
: public codecvt<char32_t, char, mbstate_t>
|
|
|
|
{
|
2018-07-11 23:14:33 +00:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2010-05-11 19:42:16 +00:00
|
|
|
__widen_from_utf8() : codecvt<char32_t, char, mbstate_t>(1) {}
|
2020-12-02 07:57:02 +00:00
|
|
|
_LIBCPP_SUPPRESS_DEPRECATED_POP
|
2010-05-11 19:42:16 +00:00
|
|
|
|
2022-08-24 00:14:29 +00:00
|
|
|
~__widen_from_utf8() override;
|
2010-05-11 19:42:16 +00:00
|
|
|
|
|
|
|
template <class _OutputIterator>
|
2018-07-11 23:14:33 +00:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2010-05-11 19:42:16 +00:00
|
|
|
_OutputIterator
|
|
|
|
operator()(_OutputIterator __s, const char* __nb, const char* __ne) const
|
|
|
|
{
|
|
|
|
result __r = ok;
|
|
|
|
mbstate_t __mb;
|
|
|
|
while (__nb < __ne && __r != error)
|
|
|
|
{
|
|
|
|
const int __sz = 32;
|
|
|
|
char32_t __buf[__sz];
|
|
|
|
char32_t* __bn;
|
|
|
|
const char* __nn = __nb;
|
|
|
|
__r = do_in(__mb, __nb, __ne - __nb > __sz ? __nb+__sz : __ne, __nn,
|
|
|
|
__buf, __buf+__sz, __bn);
|
|
|
|
if (__r == codecvt_base::error || __nn == __nb)
|
|
|
|
__throw_runtime_error("locale not supported");
|
|
|
|
for (const char32_t* __p = __buf; __p < __bn; ++__p, ++__s)
|
2020-10-27 11:01:54 +00:00
|
|
|
*__s = *__p;
|
2010-05-11 19:42:16 +00:00
|
|
|
__nb = __nn;
|
|
|
|
}
|
|
|
|
return __s;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// template <class charT> class numpunct
|
|
|
|
|
2017-01-04 23:56:00 +00:00
|
|
|
template <class _CharT> class _LIBCPP_TEMPLATE_VIS numpunct;
|
2010-05-11 19:42:16 +00:00
|
|
|
|
|
|
|
template <>
|
2023-06-14 17:17:50 +00:00
|
|
|
class _LIBCPP_EXPORTED_FROM_ABI numpunct<char>
|
2010-05-11 19:42:16 +00:00
|
|
|
: public locale::facet
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef char char_type;
|
|
|
|
typedef basic_string<char_type> string_type;
|
|
|
|
|
|
|
|
explicit numpunct(size_t __refs = 0);
|
|
|
|
|
2018-07-11 23:14:33 +00:00
|
|
|
_LIBCPP_INLINE_VISIBILITY char_type decimal_point() const {return do_decimal_point();}
|
|
|
|
_LIBCPP_INLINE_VISIBILITY char_type thousands_sep() const {return do_thousands_sep();}
|
|
|
|
_LIBCPP_INLINE_VISIBILITY string grouping() const {return do_grouping();}
|
|
|
|
_LIBCPP_INLINE_VISIBILITY string_type truename() const {return do_truename();}
|
|
|
|
_LIBCPP_INLINE_VISIBILITY string_type falsename() const {return do_falsename();}
|
2010-05-11 19:42:16 +00:00
|
|
|
|
|
|
|
static locale::id id;
|
|
|
|
|
|
|
|
protected:
|
2022-08-24 00:14:29 +00:00
|
|
|
~numpunct() override;
|
2010-05-11 19:42:16 +00:00
|
|
|
virtual char_type do_decimal_point() const;
|
|
|
|
virtual char_type do_thousands_sep() const;
|
|
|
|
virtual string do_grouping() const;
|
|
|
|
virtual string_type do_truename() const;
|
|
|
|
virtual string_type do_falsename() const;
|
|
|
|
|
|
|
|
char_type __decimal_point_;
|
|
|
|
char_type __thousands_sep_;
|
|
|
|
string __grouping_;
|
|
|
|
};
|
|
|
|
|
2021-08-23 19:32:36 +00:00
|
|
|
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
|
2010-05-11 19:42:16 +00:00
|
|
|
template <>
|
2023-06-14 17:17:50 +00:00
|
|
|
class _LIBCPP_EXPORTED_FROM_ABI numpunct<wchar_t>
|
2010-05-11 19:42:16 +00:00
|
|
|
: public locale::facet
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef wchar_t char_type;
|
|
|
|
typedef basic_string<char_type> string_type;
|
|
|
|
|
|
|
|
explicit numpunct(size_t __refs = 0);
|
|
|
|
|
2018-07-11 23:14:33 +00:00
|
|
|
_LIBCPP_INLINE_VISIBILITY char_type decimal_point() const {return do_decimal_point();}
|
|
|
|
_LIBCPP_INLINE_VISIBILITY char_type thousands_sep() const {return do_thousands_sep();}
|
|
|
|
_LIBCPP_INLINE_VISIBILITY string grouping() const {return do_grouping();}
|
|
|
|
_LIBCPP_INLINE_VISIBILITY string_type truename() const {return do_truename();}
|
|
|
|
_LIBCPP_INLINE_VISIBILITY string_type falsename() const {return do_falsename();}
|
2010-05-11 19:42:16 +00:00
|
|
|
|
|
|
|
static locale::id id;
|
|
|
|
|
|
|
|
protected:
|
2022-08-24 00:14:29 +00:00
|
|
|
~numpunct() override;
|
2010-05-11 19:42:16 +00:00
|
|
|
virtual char_type do_decimal_point() const;
|
|
|
|
virtual char_type do_thousands_sep() const;
|
|
|
|
virtual string do_grouping() const;
|
|
|
|
virtual string_type do_truename() const;
|
|
|
|
virtual string_type do_falsename() const;
|
|
|
|
|
|
|
|
char_type __decimal_point_;
|
|
|
|
char_type __thousands_sep_;
|
|
|
|
string __grouping_;
|
|
|
|
};
|
2021-08-23 19:32:36 +00:00
|
|
|
#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
|
2010-05-11 19:42:16 +00:00
|
|
|
|
|
|
|
// template <class charT> class numpunct_byname
|
|
|
|
|
2017-01-04 23:56:00 +00:00
|
|
|
template <class _CharT> class _LIBCPP_TEMPLATE_VIS numpunct_byname;
|
2010-05-11 19:42:16 +00:00
|
|
|
|
|
|
|
template <>
|
2023-06-14 17:17:50 +00:00
|
|
|
class _LIBCPP_EXPORTED_FROM_ABI numpunct_byname<char>
|
2010-05-11 19:42:16 +00:00
|
|
|
: public numpunct<char>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef char char_type;
|
|
|
|
typedef basic_string<char_type> string_type;
|
|
|
|
|
|
|
|
explicit numpunct_byname(const char* __nm, size_t __refs = 0);
|
|
|
|
explicit numpunct_byname(const string& __nm, size_t __refs = 0);
|
|
|
|
|
|
|
|
protected:
|
2022-08-24 00:14:29 +00:00
|
|
|
~numpunct_byname() override;
|
2010-05-11 19:42:16 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
void __init(const char*);
|
|
|
|
};
|
|
|
|
|
2021-08-23 19:32:36 +00:00
|
|
|
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
|
2010-05-11 19:42:16 +00:00
|
|
|
template <>
|
2023-06-14 17:17:50 +00:00
|
|
|
class _LIBCPP_EXPORTED_FROM_ABI numpunct_byname<wchar_t>
|
2010-05-11 19:42:16 +00:00
|
|
|
: public numpunct<wchar_t>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef wchar_t char_type;
|
|
|
|
typedef basic_string<char_type> string_type;
|
|
|
|
|
|
|
|
explicit numpunct_byname(const char* __nm, size_t __refs = 0);
|
|
|
|
explicit numpunct_byname(const string& __nm, size_t __refs = 0);
|
|
|
|
|
|
|
|
protected:
|
2022-08-24 00:14:29 +00:00
|
|
|
~numpunct_byname() override;
|
2010-05-11 19:42:16 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
void __init(const char*);
|
|
|
|
};
|
2021-08-23 19:32:36 +00:00
|
|
|
#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
|
2010-05-11 19:42:16 +00:00
|
|
|
|
|
|
|
_LIBCPP_END_NAMESPACE_STD
|
|
|
|
|
2021-04-20 16:03:32 +00:00
|
|
|
#endif // _LIBCPP___LOCALE
|