ztd::text::validate_transcodable_as is a function that takes an input sequence of code_units and attempts to validate that they can be turned into the code_points of the provided encoding. Unlike the ztd::text::count_as_decoded 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_transcodable_as(input, from_encoding, to_encoding, decode_state, encode_state) extension point, if possible.

  • An internal, implementation-defined customization point.

  • The basic_validate_transcodable_as base function.

The base function call, basic_validate_transcodable_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_transcodable_as(input, encoding, decode_state) can be called, it will be called without attempt to create an encode_state value with ztd::text::make_encode_state(…).

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

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


πŸ‘‰ 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.


πŸ‘‰ 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_transcodable_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.



doxygengroup: Cannot find file: /home/docs/checkouts/