basic_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_iterator
s or std::ostream_iterator
s), and other such storage cases.
The data read but not used from an incomplete error during encode and decode operations is stored in the basic_incomplete_handler
object and can be accessed VIA the code_points
and code_units
functions.
-
template<typename _Encoding, typename _ErrorHandler = pass_handler_t>
class basic_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.
- Template Parameters
_Encoding β The encoding type which dictates the
code_unit
andcode_point
buffers to store in the handler to catch unused input from the last parameter of error handler invocations by the encoding._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 basic_incomplete_handler() noexcept(::std::is_nothrow_default_constructible_v<__error_handler_base_t>)ο
Constructs a ztd::text::basic_incomplete_handler with a default-constructed internal error handler.
-
inline constexpr basic_incomplete_handler(const _ErrorHandler &__error_handler) noexcept(::std::is_nothrow_constructible_v<__error_handler_base_t, const _ErrorHandler&>)ο
Constructs a ztd::text::basic_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 basic_incomplete_handler(_ErrorHandler &&__error_handler) noexcept(::std::is_nothrow_constructible_v<__error_handler_base_t, _ErrorHandler&&>)ο
Constructs a ztd::text::basic_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.