incomplete_handler

This error handler takes the ztd::text::encoding_error::incomplete_sequence error and uses it to read from the provided “progress” contiguous range provided as the third parameter to any error handler. This can be helpful in situations here incomplete input is not to be interpreted as an error, such as in situations with networking stacks, I/O reads (particularly, non-recoverable streams like std::istream_iterators or std::ostream_iterators), and other such storage cases.

The data read but not used from an incomplete error during encode and decode operations is stored in the incomplete_handler object and can be accessed VIA the code_points and code_units functions.

template<typename _Encoding, typename _ErrorHandler = default_handler_t>
class ztd::text::incomplete_handler : private ebco<_ErrorHandler>

This handler detects if the error code is an incomplete seqence, and sets the error code to being okay before returning.

Remark

This type is often useful in conjunction with an accumulation state or buffer, which can be very handy for I/O (e.g., Networking) operations.

tparam _Encoding

The encoding type which dictates the code_unit and code_point buffers to store in the handler to catch unused input from the last parameter of error handler invocations by the encoding.

tparam _ErrorHandler

An error handler to invoke if the encoding error code is NOT an incomplete sequence.

Public Types

using error_handler = _ErrorHandler

The underlying error handler type.

Public Functions

inline constexpr incomplete_handler() noexcept(::std::is_nothrow_default_constructible_v<__error_handler_base_t>)

Constructs a ztd::text::incomplete_handler with a default-constructed internal error handler.

inline constexpr incomplete_handler(const _ErrorHandler &__error_handler) noexcept(::std::is_nothrow_constructible_v<__error_handler_base_t, const _ErrorHandler&>)

Constructs a ztd::text::incomplete_handler with the provided internal error handler object.

Parameters

__error_handler – The provided error handler object to copy in and use when the error is not an incomplete error.

inline constexpr incomplete_handler(_ErrorHandler &&__error_handler) noexcept(::std::is_nothrow_constructible_v<__error_handler_base_t, _ErrorHandler&&>)

Constructs a ztd::text::incomplete_handler with the provided internal error handler object.

Parameters

__error_handler – The provided error handler object to move in and use when the error is not an incomplete error.

inline constexpr _ErrorHandler &base() & noexcept

Returns the base error handler that is called when a non-incomplete error occurs.

inline constexpr const _ErrorHandler &base() const & noexcept

Returns the base error handler that is called when a non-incomplete error occurs.

inline constexpr _ErrorHandler &&base() && noexcept

Returns the base error handler that is called when a non-incomplete error occurs.

template<typename _Result, typename _InputProgress, typename _OutputProgress>
inline constexpr auto operator()(const _Encoding &__encoding, _Result __result, const _InputProgress &__input_progress, const _OutputProgress &__output_progress) const & noexcept(::std::is_nothrow_invocable_v<_ErrorHandler, const _Encoding&, _Result&&, const _InputProgress&, const _OutputProgress&>)

Checks if the __result.error_code is ztd::text::encoding_error::incomplete_sequence, it saves the values from __progress and returns. Otherwise, invokes the provided error handler this object was constructed with.

Parameters
  • __encoding[in] The Encoding that experienced the error.

  • __result[in] The current state of the encode operation.

  • __input_progress[in] Any code units or code points that were read but not yet used before the failure occurred. These will be stored in this handler.

  • __output_progress[in] Any code points or code units that have not yet been written before the failure occurred. These will be stored in this handler.

template<typename _Result, typename _InputProgress, typename _OutputProgress>
inline constexpr auto operator()(const _Encoding &__encoding, _Result __result, const _InputProgress &__input_progress, const _OutputProgress &__output_progress) & noexcept(::std::is_nothrow_invocable_v<_ErrorHandler, const _Encoding&, _Result&&, const _InputProgress&, const _OutputProgress&>)

Checks if the __result.error_code is ztd::text::encoding_error::incomplete_sequence, it saves the values from __progress and returns. Otherwise, invokes the provided error handler this object was constructed with.

Parameters
  • __encoding[in] The Encoding that experienced the error.

  • __result[in] The current state of the encode operation.

  • __input_progress[in] Any code units or code points that were read but not yet used before the failure occurred. These will be stored in this handler.

  • __output_progress[in] Any code points or code units that have not yet been written before the failure occurred. These will be stored in this handler.

template<typename _Result, typename _InputProgress, typename _OutputProgress>
inline constexpr auto operator()(const _Encoding &__encoding, _Result __result, const _InputProgress &__input_progress, const _OutputProgress &__output_progress) && noexcept(::std::is_nothrow_invocable_v<_ErrorHandler, const _Encoding&, _Result&&, const _InputProgress&, const _OutputProgress&>)

Checks if the __result.error_code is ztd::text::encoding_error::incomplete_sequence, it saves the values from __progress and returns. Otherwise, invokes the provided error handler this object was constructed with.

Parameters
  • __encoding[in] The Encoding that experienced the error.

  • __result[in] The current state of the encode operation.

  • __input_progress[in] Any code units or code points that were read but not yet used before the failure occurred. These will be stored in this handler.

  • __output_progress[in] Any code points or code units that have not yet been written before the failure occurred. These will be stored in this handler.

inline ::ztd::span<_CodeUnit> code_units() const noexcept

Returns the code units from the last incomplete decode operations.

inline ::ztd::span<_CodePoint> code_points() const noexcept

Returns the code points from the last incomplete encode operations.