validate_encodable_as

ztd::text::validate_encodable_as is a function that takes an input sequence of code_points and attempts to validate that they can be turned into the code_units of the provided encoding. Unlike the ztd::text::count_as_encoded function, this does not take an error handler. Any error, even if it would be corrected over, produces a stop in the algorithm and a validate_result/stateless_validate_result object gets returned with the .valid member set to false.

The overloads of this function increase the level of control with each passed argument. At the last overload with four arguments, the function attempts to work call some extension points or falls back to the base function call in this order:

  • The text_validate_encodable_as(input, encoding, encode_state) extension point, if possible.

  • The text_validate_encodable_as(input, encoding, encode_state, decode_state) extension point, if possible.

  • An internal, implementation-defined customization point.

  • The basic_validate_encodable_as base function.

The base function call, basic_validate_encodable_as, simply performs the core validating loop using the Lucky 7 design. The reason the last overload takes 2 state arguments is due to how the base implementation works from the core validating loop. If during the 3-argument overload it is detected that text_validate_encodable_as(input, encoding, encode_state) can be called, it will be called without attempt to create an decode_state value with ztd::text::make_decode_state(…).

During the basic_validate_encodable_as loop, if it detects that there is a preferable text_validate_decodable_as_one, it will call that method as text_validate_encodable_as_one(input, encoding, encode_state) inside of the loop rather than doing the core design.

The ztd::text::validate_result type only includes the encode_state in all cases.

Note

πŸ‘‰ This means that if you implement none of the extension points whatsoever, implementing the basic decode_one and encode_one functions on your Encoding Object type will guarantee a proper, working implementation.

Note

πŸ‘‰ If you need to call the β€œbasic” form of this function that takes no secret implementation shortcuts or user-defined extension points, then call basic_validate_encodable_as directly. This can be useful to stop infinity loops when your extension points cannot handle certain inputs and thereby needs to β€œdelegate” to the basic case.


Functions

template<typename _Input, typename _Encoding, typename _EncodeState, typename _DecodeState>
constexpr auto basic_validate_encodable_as(_Input &&__input, _Encoding &&__encoding, _EncodeState &__encode_state, _DecodeState &__decode_state)

Validates the code points of the __input according to the __encoding with the given states __encode_state and __decode_state.

Remark

This function explicitly does not check any of the extension points. It defers to doing a typical loop over the code points to verify it can be encoded into code units, and then decoded into code points, with no errors.

Parameters:
  • __input – [in] The input range of code points to validate is possible for encoding into code units.

  • __encoding – [in] The encoding to verify can properly encode the input of code units.

  • __encode_state – [in] The state to use for the encoding portion of the validation check.

  • __decode_state – [in] The state to use for the decoding portion of the validation check, if needed.

template<typename _Input, typename _Encoding, typename _EncodeState, typename _DecodeState>
constexpr auto validate_encodable_as(_Input &&__input, _Encoding &&__encoding, _EncodeState &__encode_state, _DecodeState &__decode_state)

Validates the code points of the __input according to the __encoding with the given states __encode_state and __decode_state.

Remark

This functions checks to see if extension points for text_validate_encodable_as is available taking the available 4 parameters. If so, it calls this. Otherwise, it defers to doing a typical loop over the code points to verify it can be encoded into code units, and then decoded into code points, with no errors.

Parameters:
  • __input – [in] The input range of code points to validate is possible for encoding into code units.

  • __encoding – [in] The encoding to verify can properly encode the input of code units.

  • __encode_state – [in] The state to use for the encoding portion of the validation check.

  • __decode_state – [in] The state to use for the decoding portion of the validation check, if needed.

template<typename _Input, typename _Encoding, typename _EncodeState>
constexpr auto validate_encodable_as(_Input &&__input, _Encoding &&__encoding, _EncodeState &__encode_state)

Validates the code points of the __input according to the __encoding with the given states "__encode_state".

Remark

This functions checks to see if extension points for text_validate_encodable_as is available taking the available 3 parameters. If so, it calls this. Otherwise, it defers to ztd::text::validate_encodable_as.

Parameters:
  • __input – [in] The input range of code points to validate is possible for encoding into code units.

  • __encoding – [in] The encoding to verify can properly encode the input of code units.

  • __encode_state – [in] The state for encoding to use.

template<typename _Input, typename _Encoding>
constexpr auto validate_encodable_as(_Input &&__input, _Encoding &&__encoding)

Validates the code points of the __input according to the "__encoding".

Parameters:
  • __input – [in] The input range of code points to validate is possible for encoding into code units.

  • __encoding – [in] The encoding to verify can properly encode the input of code units.

template<typename _Input>
constexpr auto validate_encodable_as(_Input &&__input)

Validates the code points of the input.

Remark

This passes the default encoding as inferred from the discernible value_type of the input range input into the ztd::text::default_code_point_encoding.

Parameters:

__input – [in] The input range of code points to validate is possible for encoding into code units.