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 = ::std::basic_string_view<code_unit_t<_Encoding>>, typename _ErrorHandler = default_handler_t, typename _State = decode_state_t<_Encoding>>
class ztd::text::decode_view¶

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.

tparam _Encoding

The encoding to read the underlying range of code points as.

tparam _Range

The range of input that will be fed into the _FromEncoding’s decode operation.

tparam _ErrorHandler

The error handler for any encode-step failures.

tparam _State

The state type to use for the encode 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 range_type = _Range¶

The underlying range type.

using encoding_type = _Encoding¶

The encoding type used for transformations.

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.

inline constexpr iterator begin() & noexcept¶

The beginning of the range. Uses a sentinel type and not a special iterator.

inline constexpr iterator begin() const & noexcept¶

The beginning of the range. Uses a sentinel type and not a special iterator.

inline constexpr iterator begin() && noexcept¶

The beginning of the range. Uses a sentinel type and not a special iterator.

inline constexpr sentinel end() const noexcept¶

The end of the range. Uses a sentinel type and not a special iterator.