decode_viewο
The decode_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_point
value corresponding to the desired encodingβs transformation of the internal code units.
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 decode eagerly and in bulk, see the decode functions.
-
template<typename _Encoding, typename _Range = __txt_detail::__default_char_view_t<code_unit_t<_Encoding>>, typename _ErrorHandler = default_handler_t, typename _State = decode_state_t<_Encoding>>
class decode_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 point one at a time, regardless of how many code points are output by one decode operation. This means if, for example, four (4) UTF-8 code units becomes two (2) UTF-16 code points, it will present one code point at a time. If you are looking to explicitly know what a single decode 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 decode operations to intermediate code points.
Public Types
-
using iterator = decode_iterator<_Encoding, _StoredRange, _ErrorHandler, _State>ο
The iterator type for this view.
-
using sentinel = decode_sentinel_tο
The sentinel type for this view.
-
using error_handler_type = _ErrorHandlerο
The error handler when a decode operation fails.
-
using state_type = decode_state_t<encoding_type>ο
The state type used for decode operations.
Public Functions
-
template<typename _ArgRange, ::std::enable_if_t<!::std::is_same_v<remove_cvref_t<_ArgRange>, decode_view> && !::std::is_same_v<remove_cvref_t<_ArgRange>, iterator>>* = nullptr>
inline constexpr decode_view(_ArgRange &&__range) noexcept(::std::is_nothrow_constructible_v<iterator, _ArgRange>)ο Constructs a decode_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 decode_view(range_type __range, encoding_type __encoding) noexcept(::std::is_nothrow_constructible_v<iterator, range_type, encoding_type>)ο
Constructs a decode_view from the underlying range.
- Parameters:
__range β [in] The input range to wrap and iterate over.
__encoding β [in] The encoding object to call
.decode
or equivalent functionality on.
-
inline constexpr decode_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 a decode_view from the underlying range.
- Parameters:
__range β [in] The input range to wrap and iterate over.
__encoding β [in] The encoding object to call
.decode
or equivalent functionality on.__error_handler β [in] The error handler to store in this view.
-
inline constexpr decode_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 a decode_view from the underlying range.
- Parameters:
__range β [in] The input range to wrap and iterate over.
__encoding β [in] The encoding object to call
.decode
or equivalent functionality on.__error_handler β [in] The error handler to store in this view.
__state β [in] The state to user for the decode operation.
-
inline constexpr decode_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 decode_view iterator.
-
constexpr decode_view() = defaultο
Default constructor. Defaulted.
-
constexpr decode_view(const decode_view&) = defaultο
Copy constructor. Defaulted.
-
constexpr decode_view(decode_view&&) = defaultο
Move constructor. Defaulted.
-
constexpr decode_view &operator=(const decode_view&) = defaultο
Copy assignment operator. Defaulted.
-
constexpr decode_view &operator=(decode_view&&) = defaultο
Move assignment operator. Defaulted.
-
template<typename _Encoding, typename _Range, typename _ErrorHandler = default_handler_t, typename _State = decode_state_t<_Encoding>>
class decode_iterator : public __txt_detail::__encoding_iterator<__txt_detail::__transaction::__decode, decode_iterator<_Encoding, _Range, default_handler_t, decode_state_t<_Encoding>>, __txt_detail::__iterator_storage<_Encoding, _Range, default_handler_t, decode_state_t<_Encoding>>>ο An iterator over a range of code points, presented as a range of code units, using 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 point one at a time, regardless of how many code points are output by one decode operation. This means if, for example, four (4) UTF-8 code units becomes two (2) UTF-16 code points, it will present one code point at a time. If you are looking to explicitly know what a single decode 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 decode_iterator() = defaultο
Default constructor. Defaulted.
-
constexpr decode_iterator(const decode_iterator&) = defaultο
Copy constructor. Defaulted.
-
constexpr decode_iterator(decode_iterator&&) = defaultο
Move constructor. Defaulted.
-
template<typename _ArgRange, ::std::enable_if_t<!::std::is_same_v<remove_cvref_t<_ArgRange>, decode_iterator>>* = nullptr>
inline constexpr decode_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 decode_iterator(range_type __range, encoding_type __encoding) noexcept(::std::is_nothrow_constructible_v<__iterator_base_it, range_type, encoding_type>)ο
Constructs a ztd::text::decode_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 decode_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::decode_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 decode_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::decode_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 decode_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::decode_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 decode_iterator &operator=(const decode_iterator&) = defaultο
Copy assignment operator. Defaulted.
-
constexpr decode_iterator &operator=(decode_iterator&&) = defaultο
Move assignment operator. Defaulted.