count_result

template<typename _Input, typename _State>
class count_result : public ztd::text::stateless_count_result<_Input>

The result of counting operations (such as ztd_text_count_as_encoded and ztd_text_count_as_encoded).

Public Functions

template<typename _ArgInput, typename _ArgState>
inline constexpr count_result(_ArgInput &&__input, ::std::size_t __count, _ArgState &&__state, encoding_error __error_code = encoding_error::ok)

Constructs a ztd::text::count_result, defaulting the error code to ztd::text::encoding_error::ok if not provided.

Parameters:
  • __input[in] The input range to store.

  • __count[in] The number of code points or code units successfully counted.

  • __state[in] The state related to the encoding for the counting operation.

  • __error_code[in] The error code for the encode operation, taken as the first of either the encode or decode operation that failed.

template<typename _ArgInput, typename _ArgState>
inline constexpr count_result(_ArgInput &&__input, ::std::size_t __count, _ArgState &&__state, encoding_error __error_code, ::std::size_t __error_count)

Constructs a ztd::text::count_result with the provided parameters and information, including whether or not an error was handled.

Parameters:
  • __input[in] The input range to store.

  • __count[in] The number of code points or code units successfully counted.

  • __state[in] The state related to the encode operation that counted the code units.

  • __error_code[in] The error code for the encode operation, taken as the first of either the encode or decode operation that failed.

  • __error_count[in] Whether or not an error was handled. Some error handlers are corrective (see ztd::text::replacement_handler_t), and so the error code is not enough to determine if the handler was invoked. This allows the value to be provided directly when constructing this result type.

inline constexpr bool errors_were_handled() const noexcept

Whether or not any errors were handled.

Returns:

Simply checks whether error_count is greater than 0.

Public Members

::ztd::reference_wrapper<_State> state

A reference to the state of the associated Encoding used for counting.

_Input input

The reconstructed input_view object, with its .begin() incremented by the number of code units successfully read (can be identical to .begin() on original range on failure).

::std::size_t count

The number of code units or code points counted successfully, so far.

encoding_error error_code

The kind of error that occured, if any.

::std::size_t error_count

The number of times an error occurred in the processed input text.

Remark

This number may be greater than one despite error_code being ztd::text::encoding_error::ok, as some error handlers will encounter an error but “fix” the text (e.g. ztd::text::skip_handler_t or ztd::text::replacement_handler_t).