encode_viewο
The encode_view
class provides a one-by-one view of the stored rangeβs code points as the desired encodingβs code units. Dereferencing the iterators returns a single code_unit
value corresponding to the desired encodingβs transformation of the internal code points.
The range-based classes are excellent ways to walk over units of information in a low-memory environment, as they only store the minimum amount of data necessary to perform their operations on the fly. This reduces the speed but is fine for one-at-a-time encoding operations. To encode eagerly and in bulk, see the encode functions.
-
template<typename _Encoding, typename _Range = __txt_detail::__default_char_view_t<code_point_t<_Encoding>>, typename _ErrorHandler = default_handler_t, typename _State = encode_state_t<_Encoding>>
class encode_view : public view_baseο A view over a range of code points, presenting the code points as code units. Uses the
_Encoding
specified to do so.Remark
The view presents code units one at a time, regardless of how many code units are output by one decode operation. This means if, for example, one (1) UTF-32 code point becomes four (4) UTF-8 code units, it will present each code unit one at a time. If you are looking to explicitly know what a single encode operation maps into as far as number of code points to code units (and vice-versa), you will have to use lower-level interfaces.
- Template Parameters
_Encoding β The encoding to read the underlying range of code points as.
_Range β The range of input that will be fed into the _FromEncodingβs decode operation.
_ErrorHandler β The error handler for any encode-step failures.
_State β The state type to use for the encode operations to intermediate code points.
Public Types
-
using iterator = encode_iterator<_Encoding, _StoredRange, _ErrorHandler, _State>ο
The iterator type for this view.
-
using sentinel = encode_sentinel_tο
The sentinel type for this view.
-
using error_handler_type = _ErrorHandlerο
The error handler when an encode operation fails.
-
using state_type = encode_state_t<encoding_type>ο
The state type used for encode operations.
Public Functions
-
constexpr encode_view() = defaultο
Default constructor. Defaulted.
-
constexpr encode_view(const encode_view&) = defaultο
Copy constructor. Defaulted.
-
constexpr encode_view(encode_view&&) = defaultο
Move constructor. Defaulted.
-
template<typename _ArgRange, ::std::enable_if_t<!::std::is_same_v<remove_cvref_t<_ArgRange>, encode_view> && !::std::is_same_v<remove_cvref_t<_ArgRange>, iterator>>* = nullptr>
inline constexpr encode_view(_ArgRange &&__range) noexcept(::std::is_nothrow_constructible_v<iterator, _ArgRange>)ο Constructs an encode_view from the underlying range.
Remark
the stored encoding, error handler, and state type are default-constructed.
- Parameters
__range β [in] The input range to wrap and iterate over.
-
inline constexpr encode_view(range_type __range, encoding_type __encoding) noexcept(::std::is_nothrow_constructible_v<iterator, range_type, encoding_type>)ο
Constructs an encode_view from the underlying range.
- Parameters
__range β [in] The input range to wrap and iterate over.
__encoding β [in] The encoding object to call
.encode
or equivalent functionality on.
-
inline constexpr encode_view(range_type __range, encoding_type __encoding, error_handler_type __error_handler) noexcept(::std::is_nothrow_constructible_v<iterator, range_type, encoding_type, error_handler_type>)ο
Constructs an encode_view from the underlying range.
- Parameters
__range β [in] The input range to wrap and iterate over.
__encoding β [in] The encoding object to call
.encode
or equivalent functionality on.__error_handler β [in] A previously-made encode_view iterator.
-
inline constexpr encode_view(range_type __range, encoding_type __encoding, error_handler_type __error_handler, state_type __state) noexcept(::std::is_nothrow_constructible_v<iterator, range_type, encoding_type, error_handler_type, state_type>)ο
Constructs an encode_view from the underlying range.
- Parameters
__range β [in] The input range to wrap and iterate over.
__encoding β [in] The encoding object to call
.encode
or equivalent functionality on.__error_handler β [in] A previously-made encode_view iterator.
__state β [in] The state to user for the encode operation.
-
inline constexpr encode_view(iterator __it) noexcept(::std::is_nothrow_move_constructible_v<iterator>)ο
Constructs an encoding_view from one of its iterators, reconstituting the range.
- Parameters
__it β [in] A previously-made encode_view iterator.
-
constexpr encode_view &operator=(const encode_view&) = defaultο
Copy assignment operator. Defaulted.
-
constexpr encode_view &operator=(encode_view&&) = defaultο
Move assignment operator. Defaulted.
-
template<typename _Encoding, typename _Range, typename _ErrorHandler = default_handler_t, typename _State = encode_state_t<_Encoding>>
class encode_iterator : public __txt_detail::__encoding_iterator<__txt_detail::__transaction::__encode, encode_iterator<_Encoding, _Range, _ErrorHandler, _State>, __txt_detail::__iterator_storage<_Encoding, _Range, _ErrorHandler, _State>>ο An iterator over an iterator of code points, presenting the code points as code units. Uses the
_Encoding
specified to do so.Remark
This type produces proxies as their reference type, and are only readable, not writable iterators. The iterator presents code units one at a time, regardless of how many code units are output by one decode operation. This means if, for example, one (1) UTF-32 code point becomes four (4) UTF-8 code units, it will present each code unit one at a time. If you are looking to explicitly know what a single encode operation maps into as far as number of code points to code units (and vice-versa), you will have to use lower-level interfaces.
- Template Parameters
_Encoding β The encoding to read the underlying range of code points as.
_Range β The range of input that will be fed into the _FromEncodingβs decode operation.
_ErrorHandler β The error handler for any encode-step failures.
_State β The state type to use for the encode operations to intermediate code points.
Public Types
-
using range_type = typename __iterator_base_it::range_typeο
The underlying range type.
-
using iterator = typename __iterator_base_it::iteratorο
The base iterator type.
-
using encoding_type = typename __iterator_base_it::encoding_typeο
The encoding type used for transformations.
-
using error_handler_type = typename __iterator_base_it::error_handler_typeο
The error handler when an encode operation fails.
-
using state_type = typename __iterator_base_it::state_typeο
The state type used for encode operations.
-
using iterator_category = typename __iterator_base_it::iterator_categoryο
The strength of the iterator category, as defined in relation to the base.
-
using iterator_concept = typename __iterator_base_it::iterator_conceptο
The strength of the iterator concept, as defined in relation to the base.
-
using value_type = typename __iterator_base_it::value_typeο
The object type that gets output on every dereference.
-
using pointer = typename __iterator_base_it::pointerο
A pointer type to the value_type.
-
using reference = typename __iterator_base_it::value_typeο
The value returned from derefencing the iterator.
Remark
This is a proxy iterator, so the
reference
is a non-referencevalue_type.
-
using difference_type = typename __iterator_base_it::difference_typeο
The type returned when two of these pointers are subtracted from one another.
Remark
Itβs not a very useful typeβ¦
Public Functions
-
constexpr encode_iterator() = defaultο
Default constructor. Defaulted.
-
constexpr encode_iterator(const encode_iterator&) = defaultο
Copy constructor. Defaulted.
-
constexpr encode_iterator(encode_iterator&&) = defaultο
Move constructor. Defaulted.
-
template<typename _ArgRange, ::std::enable_if_t<!::std::is_same_v<remove_cvref_t<_ArgRange>, encode_iterator>>* = nullptr>
inline constexpr encode_iterator(_ArgRange &&__range) noexcept(::std::is_nothrow_constructible_v<__iterator_base_it, range_type>)ο Constructs a ztd::text::decode_iterator from the explicitly given
__range
.Remark
Each argument is moved/forwarded in.
- Parameters
__range β [in] The range value that will be read from.
-
inline constexpr encode_iterator(range_type __range, encoding_type __encoding) noexcept(::std::is_nothrow_constructible_v<__iterator_base_it, range_type, encoding_type>)ο
Constructs a ztd::text::encode_iterator from the explicitly given
__range
, and__encoding
.Remark
Each argument is moved in.
- Parameters
__range β [in] The range value that will be read from.
__encoding β [in] The encoding object to use.
-
inline constexpr encode_iterator(range_type __range, error_handler_type __error_handler) noexcept(::std::is_nothrow_constructible_v<__iterator_base_it, range_type, error_handler_type>)ο
Constructs a ztd::text::encode_iterator from the explicitly given
__range
, and__error_handler
.Remark
Each argument is moved in.
- Parameters
__range β [in] The range value that will be read from.
__error_handler β [in] The error handler to use for reporting errors.
-
inline constexpr encode_iterator(range_type __range, encoding_type __encoding, error_handler_type __error_handler) noexcept(::std::is_nothrow_constructible_v<__iterator_base_it, range_type, encoding_type, error_handler_type>)ο
Constructs a ztd::text::encode_iterator from the explicitly given
__range
,__encoding
, and__error_handler
.Remark
Each argument is moved in.
- Parameters
__range β [in] The range value that will be read from.
__encoding β [in] The encoding object to use.
__error_handler β [in] The error handler to use for reporting errors.
-
inline constexpr encode_iterator(range_type __range, encoding_type __encoding, error_handler_type __error_handler, state_type __state) noexcept(::std::is_nothrow_constructible_v<__iterator_base_it, range_type, encoding_type, error_handler_type, state_type>)ο
Constructs a ztd::text::encode_iterator from the explicitly given
__range
,__encoding
,__error_handler
and__state
.Remark
Each argument is moved in.
- Parameters
__range β [in] The range value that will be read from.
__encoding β [in] The encoding object to use.
__error_handler β [in] The error handler to use for reporting errors.
__state β [in] The current state.
-
constexpr encode_iterator &operator=(const encode_iterator&) = defaultο
Copy assignment operator. Defaulted.
-
constexpr encode_iterator &operator=(encode_iterator&&) = defaultο
Move assignment operator. Defaulted.