any_encoding omni-encoding typeο
any_encoding is a class type whose sole purpose is to provide a type-generic, byte-based, runtime-deferred way of handling encodings.
Aliasesο
-
using ztd::text::any_encoding = any_byte_encoding<::std::byte>ο
The canonical erased encoding type which uses a
std::byteas its code unit type and anunicode_code_pointas its code point type, with spans for input and output operations.Remark
If the input encoding does not match
std::byte, it will be first wrapped in a ztd::text::encoding_scheme first.
-
template<typename _EncodeCodeUnit, typename _EncodeCodePoint = const unicode_code_point, typename _DecodeCodeUnit = ::std::add_const_t<_EncodeCodeUnit>, typename _DecodeCodePoint = ::std::remove_const_t<_EncodeCodePoint>, ::std::size_t _MaxCodeUnits = __txt_detail::__default_max_code_units_any_encoding, ::std::size_t _MaxCodePoints = __txt_detail::__default_max_code_points_any_encoding>
using ztd::text::any_encoding_of = any_encoding_with<::ztd::span<_EncodeCodeUnit>, ::ztd::span<_EncodeCodePoint>, ::ztd::span<_DecodeCodeUnit>, ::ztd::span<_DecodeCodePoint>, _MaxCodeUnits, _MaxCodePoints>ο A type-erased encoding that uses the specified code unit, code point, and input/output ranges for the various operations.
-
using ztd::text::compat_any_encoding = any_byte_encoding<char>ο
The canonical erased encoding type which uses a
charas its code unit type and anunicode_code_pointas its code point type, with spans for input and output operations.Remark
If the input encoding does not match
char, it will be first wrapped in a ztd::text::encoding_scheme first. Use this type when dealing with what are effectively byte stream inputs but oriented in a legacy manner, such as oldstd::stringor<iostream>-based work.
-
using ztd::text::ucompat_any_encoding = any_byte_encoding<unsigned char>ο
The canonical erased encoding type which uses a
unsigned charas its code unit type and anunicode_code_pointas its code point type, with spans for input and output operations.Remark
If the input encoding does not match
unsigned char, it will be first wrapped in a ztd::text::encoding_scheme first. Use this type when dealing with what are effectively byte stream inputs but oriented around a slightly more modern approach to proper unsigned data handling withunsigned char.
Baseο
This is based off of ztd::text::any_encoding_with; the only thing special about it is the constructor logic on top of ztd::text::any_encoding_with.
-
template<typename _Byte, typename _CodePoint = unicode_code_point>
class any_byte_encoding : public ztd::text::any_encoding_with<_Byte, const unicode_code_point, const _Byte, unicode_code_point>ο An encoding type that wraps up other encodings to specifically traffic in the given
_Bytetype provided, which is typically set tostd::byte.Remark
This type traffics solely in
std::spans, which for most people is fine. Others may want to interface with different iterator types (e.g., from a custom Rope implementation or other). For those, one must first create ranges that can operate with those iterators, then use them themselves. (Itβs not an ideal process at the moment, and we are looking to make this experience better.) It is recommended to use the provided ztd::text::any_encoding type definition instead of accessing this directly, unless you have a reason for using a different byte type (e.g., interfacing with legacy APIs).- Template Parameters:
_Byte β The byte type to use. Typically, this is either
unsigned charorstd::byte.
Public Functions
-
any_byte_encoding() = deleteο
Cannot default-construct a ztd::text::any_byte_encoding object.
-
template<typename _EncodingArg, typename ..._Args, ::std::enable_if_t<!::std::is_same_v<remove_cvref_t<_EncodingArg>, any_byte_encoding> && !::std::is_same_v<__txt_detail::__code_unit_or_void_t<remove_cvref_t<_EncodingArg>>, _Byte> && !is_specialization_of_v<remove_cvref_t<_EncodingArg>, ::ztd::text::any_byte_encoding> && !::std::is_same_v<remove_cvref_t<_EncodingArg>, __base_t> && !is_specialization_of_v<remove_cvref_t<_EncodingArg>, ::std::in_place_type_t>>* = nullptr>
inline any_byte_encoding(_EncodingArg &&__encoding, _Args&&... __args)ο Constructs a ztd::text::any_byte_encoding with the encoding object and any additional arguments.
Remark
If the provided encoding does not have a byte code_unit type, it is wrapped in an ztd::text::encoding_scheme first.
- Parameters:
__encoding β [in] The encoding object that informs the ztd::text::any_byte_encoding what encoding object to store.
__args β [in] Any additional arguments used to construct the encoding in the erased storage.
-
template<typename _EncodingArg, typename ..._Args, ::std::enable_if_t<!::std::is_same_v<_Byte, code_unit_t<remove_cvref_t<_EncodingArg>>>>* = nullptr>
inline any_byte_encoding(::std::in_place_type_t<_EncodingArg>, _Args&&... __args)ο Constructs a ztd::text::any_byte_encoding with the encoding object and any additional arguments.
Remark
If the provided encoding does not have a byte code_unit type, it is wrapped in an ztd::text::encoding_scheme first.
- Template Parameters:
_EncodingArg β The Encoding specified by the
std::in_place_type<...>argument.- Parameters:
__args β [in] Any additional arguments used to construct the encoding in the erased storage.
-
template<typename _EncodingArg, typename ..._Args, ::std::enable_if_t<::std::is_same_v<_Byte, code_unit_t<remove_cvref_t<_EncodingArg>>>>* = nullptr>
inline any_byte_encoding(::std::in_place_type_t<_EncodingArg> __tag, _Args&&... __args)ο Constructs a ztd::text::any_byte_encoding with the encoding object and any additional arguments.
Remark
If the provided encoding does not have a byte code_unit type, it is wrapped in an ztd::text::encoding_scheme first.
- Template Parameters:
_EncodingArg β The Encoding specified by the
std::in_place_type<...>argument.- Parameters:
__tag β [in] A tag containing the encoding type.
__args β [in] Any additional arguments used to construct the encoding in the erased storage.
-
any_byte_encoding(const any_byte_encoding&) = deleteο
Cannot copy-construct a ztd::text::any_byte_encoding object.
-
any_byte_encoding &operator=(const any_byte_encoding&) = deleteο
Cannot copy-assign a ztd::text::any_byte_encoding object.
-
any_byte_encoding(any_byte_encoding&&) = defaultο
Move-constructs a ztd::text::any_byte_encoding from the provided r-value reference.
Remark
This leaves the passed-in r-value reference without an encoding object. Calling any function on a moved-fron ztd::text::any_byte_encoding, except for destruction, is a violation and invokes Undefined Behavior (generally, a crash).
-
any_byte_encoding &operator=(any_byte_encoding&&) = defaultο
Move-assigns a ztd::text::any_byte_encoding from the provided r-value reference.
Remark
This leaves the passed-in r-value reference without an encoding object. Calling any function on a moved-fron ztd::text::any_byte_encoding, except for destruction, is a violation and invokes Undefined Behavior (generally, a crash).