Class holding the result from parsing a string, in the form of a status and a message.
More...
#include <parse_result.h>
|
| void | revert_parse_error_to_ok () noexcept |
| |
| void | update_parse_error_pos (std::size_t position) |
| | Update the position of a parse error to the given position. More...
|
| |
| void | set_store_error (const std::string_view &message) noexcept |
| | Store a result representing that the requested object could not be parsed because something went wrong which is not the string's fault. More...
|
| |
| void | set_fullmatch_error () noexcept |
| | Store a result representing that an object was successfully parsed from a prefix of the string, but the user invoked a function such as decode which requires that the object description extends to the end of the string. More...
|
| |
| void | set_oom () noexcept |
| | Store a result representing that the requested object could not be parsed because and out-of-memory condition occurred. More...
|
| |
| bool | is_ok () const |
| | Return true if the last operation succeeded, i.e., either a full match was requested and an object was found which extended to the end of the string; or a prefix match was requested and an object was found, possibly followed by unparsed character; or an optional match was requested and the object was found or was completely absent (but no error occurred). More...
|
| |
| bool | is_prefix_ok () const |
| | Return true if either the last operation succeeded, or failed because a full match was requested and only a prefix match was found. More...
|
| |
| std::size_t | found_count () const |
| | Return the number of repetitions found in the last call. More...
|
| |
| bool | is_found () const |
| | Return true if found_count() != 0. More...
|
| |
| bool | is_store_error () const |
| | Return true if an environment error occurred. More...
|
| |
| bool | is_parse_error () const |
| | Return true if a parse error occurred. More...
|
| |
| bool | is_fullmatch_error () const |
| | Return true if the object was parsed successfully, but there were more characters after the end. More...
|
| |
|
| void | do_set_parse_error (const std::string_view &string, Message_form message_form, std::size_t position) |
| | Common implementation of set_parse_error and set_parse_error_expected_string. More...
|
| |
| void | set_match_count (std::size_t count) noexcept |
| | Store a result representing that the requested object was successfully parsed, overriding a previous error state. More...
|
| |
|
| static constexpr char | oom_message [] = "Out of memory" |
| | Message to use on out-of-memory. More...
|
| |
Class holding the result from parsing a string, in the form of a status and a message.
◆ Message_form
The form of the message stored in this object.
| Enumerator |
|---|
| sentence | The message is expressed as a full sentence, for example "Value out of
range".
It should begin with a capital letter and not end with a period. It will be exended with a string like " after 5 characters, near [HERE] in "foo: [HERE]123".".
|
| expected_string | The message is a string that was expected but not found at the current position.
It must be a literal string, not a descriptive name of a token. For example, if a comma was missing, the string should be ",". It will be escaped and quoted, and the result inserted in a string like "Expected "," after 4 characters, near [HERE] in "foo [HERE]bar"."
|
◆ do_set_parse_error()
| void mysql::strconv::detail::Parse_result::do_set_parse_error |
( |
const std::string_view & |
string, |
|
|
Message_form |
message_form, |
|
|
std::size_t |
position |
|
) |
| |
|
inlineprotected |
Common implementation of set_parse_error and set_parse_error_expected_string.
◆ found_count()
| std::size_t mysql::strconv::detail::Parse_result::found_count |
( |
| ) |
const |
|
inline |
Return the number of repetitions found in the last call.
This may be nonzero if the status is ok or fullmatch_error; in other cases it is 0.
◆ is_found()
| bool mysql::strconv::detail::Parse_result::is_found |
( |
| ) |
const |
|
inline |
Return true if found_count() != 0.
◆ is_fullmatch_error()
| bool mysql::strconv::detail::Parse_result::is_fullmatch_error |
( |
| ) |
const |
|
inline |
Return true if the object was parsed successfully, but there were more characters after the end.
◆ is_ok()
| bool mysql::strconv::detail::Parse_result::is_ok |
( |
| ) |
const |
|
inline |
Return true if the last operation succeeded, i.e., either a full match was requested and an object was found which extended to the end of the string; or a prefix match was requested and an object was found, possibly followed by unparsed character; or an optional match was requested and the object was found or was completely absent (but no error occurred).
◆ is_parse_error()
| bool mysql::strconv::detail::Parse_result::is_parse_error |
( |
| ) |
const |
|
inline |
Return true if a parse error occurred.
◆ is_prefix_ok()
| bool mysql::strconv::detail::Parse_result::is_prefix_ok |
( |
| ) |
const |
|
inline |
Return true if either the last operation succeeded, or failed because a full match was requested and only a prefix match was found.
◆ is_store_error()
| bool mysql::strconv::detail::Parse_result::is_store_error |
( |
| ) |
const |
|
inline |
Return true if an environment error occurred.
◆ message()
| std::string_view mysql::strconv::detail::Parse_result::message |
( |
| ) |
const |
|
inlineprivate |
◆ revert_parse_error_to_ok()
| void mysql::strconv::detail::Parse_result::revert_parse_error_to_ok |
( |
| ) |
|
|
inlinenoexcept |
◆ set_fullmatch_error()
| void mysql::strconv::detail::Parse_result::set_fullmatch_error |
( |
| ) |
|
|
inlinenoexcept |
Store a result representing that an object was successfully parsed from a prefix of the string, but the user invoked a function such as decode which requires that the object description extends to the end of the string.
This should only be used by the framework, not by user-defined decode_impl functions.
◆ set_match_count()
| void mysql::strconv::detail::Parse_result::set_match_count |
( |
std::size_t |
count | ) |
|
|
inlineprotectednoexcept |
Store a result representing that the requested object was successfully parsed, overriding a previous error state.
- Parameters
-
| count | The number of successfully parsed repetitions of the parsed token. |
◆ set_oom()
| void mysql::strconv::detail::Parse_result::set_oom |
( |
| ) |
|
|
inlinenoexcept |
Store a result representing that the requested object could not be parsed because and out-of-memory condition occurred.
This is shorthand for set_store_error("Out of memory").
◆ set_store_error()
| void mysql::strconv::detail::Parse_result::set_store_error |
( |
const std::string_view & |
message | ) |
|
|
inlinenoexcept |
Store a result representing that the requested object could not be parsed because something went wrong which is not the string's fault.
- Parameters
-
| message | Error message describing what went wrong. |
◆ status()
| Parse_status mysql::strconv::detail::Parse_result::status |
( |
| ) |
const |
|
inlineprivate |
Return the current status.
◆ update_parse_error_pos()
| void mysql::strconv::detail::Parse_result::update_parse_error_pos |
( |
std::size_t |
position | ) |
|
|
inline |
Update the position of a parse error to the given position.
This requires that the current sattus is parse_error.
- Parameters
-
◆ Parse_result_internals
◆ m_found_count
| std::size_t mysql::strconv::detail::Parse_result::m_found_count {0} |
|
private |
If the status is "ok", the number of tokens found.
◆ m_message
| std::string_view mysql::strconv::detail::Parse_result::m_message {} |
|
private |
◆ m_message_form
◆ m_parse_error_position
| std::ptrdiff_t mysql::strconv::detail::Parse_result::m_parse_error_position {-1} |
|
private |
The position of the most recent "parse_error".
◆ m_status
◆ oom_message
| constexpr char mysql::strconv::detail::Parse_result::oom_message[] = "Out of memory" |
|
staticconstexprprivate |
Message to use on out-of-memory.
The documentation for this class was generated from the following file: