NeBuild dev
|
The result of a parsing operation. More...
#include <parse_result.hpp>
Classes | |
struct | storage_t |
Public Member Functions | |
TOML_NODISCARD_CTOR | parse_result () noexcept |
Default constructs an 'error' result. | |
TOML_NODISCARD_CTOR | parse_result (toml::table &&tbl) noexcept |
TOML_NODISCARD_CTOR | parse_result (parse_error &&err) noexcept |
TOML_NODISCARD_CTOR | parse_result (parse_result &&res) noexcept |
Move constructor. | |
parse_result & | operator= (parse_result &&rhs) noexcept |
Move-assignment operator. | |
~parse_result () noexcept | |
Destructor. | |
Result state | |
TOML_NODISCARD bool | succeeded () const noexcept |
Returns true if parsing succeeeded. | |
TOML_NODISCARD bool | failed () const noexcept |
Returns true if parsing failed. | |
TOML_NODISCARD | operator bool () const noexcept |
Returns true if parsing succeeded. | |
Successful parses | |
| |
TOML_NODISCARD toml::table & | table () &noexcept |
Returns the internal toml::table. | |
TOML_NODISCARD toml::table && | table () &&noexcept |
Returns the internal toml::table (rvalue overload). | |
TOML_NODISCARD const toml::table & | table () const &noexcept |
Returns the internal toml::table (const lvalue overload). | |
TOML_NODISCARD | operator toml::table & () noexcept |
Returns the internal toml::table. | |
TOML_NODISCARD | operator toml::table && () noexcept |
Returns the internal toml::table (rvalue overload). | |
TOML_NODISCARD | operator const toml::table & () const noexcept |
Returns the internal toml::table (const lvalue overload). | |
Failed parses | |
| |
TOML_NODISCARD parse_error & | error () &noexcept |
Returns the internal toml::parse_error. | |
TOML_NODISCARD parse_error && | error () &&noexcept |
Returns the internal toml::parse_error (rvalue overload). | |
TOML_NODISCARD const parse_error & | error () const &noexcept |
Returns the internal toml::parse_error (const lvalue overload). | |
TOML_NODISCARD | operator parse_error & () noexcept |
Returns the internal toml::parse_error. | |
TOML_NODISCARD | operator parse_error && () noexcept |
Returns the internal toml::parse_error (rvalue overload). | |
TOML_NODISCARD | operator const parse_error & () const noexcept |
Returns the internal toml::parse_error (const lvalue overload). | |
Node views | |
TOML_NODISCARD node_view< node > | at_path (std::string_view path) noexcept |
Returns a view of the subnode matching a fully-qualified "TOML path". | |
TOML_NODISCARD node_view< const node > | at_path (std::string_view path) const noexcept |
Returns a const view of the subnode matching a fully-qualified "TOML path". | |
TOML_NODISCARD node_view< node > | at_path (const toml::path &path) noexcept |
Returns a view of the subnode matching a fully-qualified "TOML path". | |
TOML_NODISCARD node_view< const node > | at_path (const toml::path &path) const noexcept |
Returns a const view of the subnode matching a fully-qualified "TOML path". | |
TOML_NODISCARD node_view< node > | at_path (std::wstring_view path) |
Returns a view of the subnode matching a fully-qualified "TOML path". | |
TOML_NODISCARD node_view< const node > | at_path (std::wstring_view path) const |
Returns a const view of the subnode matching a fully-qualified "TOML path". | |
TOML_NODISCARD node_view< node > | operator[] (const toml::path &path) noexcept |
Returns a view of the subnode matching a fully-qualified "TOML path". | |
TOML_NODISCARD node_view< const node > | operator[] (const toml::path &path) const noexcept |
Returns a const view of the subnode matching a fully-qualified "TOML path". | |
TOML_NODISCARD node_view< node > | operator[] (std::string_view key) noexcept |
Gets a node_view for the selected key-value pair in the wrapped table. | |
TOML_NODISCARD node_view< const node > | operator[] (std::string_view key) const noexcept |
Gets a node_view for the selected key-value pair in the wrapped table (const overload). | |
TOML_NODISCARD node_view< node > | operator[] (std::wstring_view key) |
Gets a node_view for the selected key-value pair in the wrapped table. | |
TOML_NODISCARD node_view< const node > | operator[] (std::wstring_view key) const |
Gets a node_view for the selected key-value pair in the wrapped table (const overload). | |
Private Member Functions | |
void | destroy () noexcept |
Static Private Member Functions | |
template<typename Type > | |
TOML_NODISCARD static TOML_ALWAYS_INLINE Type * | get_as (storage_t &s) noexcept |
Private Attributes | |
storage_t | storage_ |
bool | err_ |
Friends | |
std::ostream & | operator<< (std::ostream &os, const parse_result &result) |
Prints the held error or table object out to a text stream. | |
Iteration | |
using | iterator = table_iterator |
A BidirectionalIterator for iterating over key-value pairs in a wrapped toml::table. | |
using | const_iterator = const_table_iterator |
A BidirectionalIterator for iterating over const key-value pairs in a wrapped toml::table. | |
TOML_NODISCARD table_iterator | begin () noexcept |
Returns an iterator to the first key-value pair in the wrapped table. | |
TOML_NODISCARD const_table_iterator | begin () const noexcept |
Returns an iterator to the first key-value pair in the wrapped table. | |
TOML_NODISCARD const_table_iterator | cbegin () const noexcept |
Returns an iterator to the first key-value pair in the wrapped table. | |
TOML_NODISCARD table_iterator | end () noexcept |
Returns an iterator to one-past-the-last key-value pair in the wrapped table. | |
TOML_NODISCARD const_table_iterator | end () const noexcept |
Returns an iterator to one-past-the-last key-value pair in the wrapped table. | |
TOML_NODISCARD const_table_iterator | cend () const noexcept |
Returns an iterator to one-past-the-last key-value pair in the wrapped table. | |
The result of a parsing operation.
\availability This type only exists when exceptions are disabled. Otherwise parse_result is just an alias for toml::table: \cpp #if TOML_EXCEPTIONS using parse_result = table; #else class parse_result { // ... #endif \ecpp
\detail A parse_result is effectively a discriminated union containing either a toml::table or a toml::parse_error. Most member functions assume a particular one of these two states, and calling them when in the wrong state will cause errors (e.g. attempting to access the error object when parsing was successful). \cpp toml::parse_result result = toml::parse_file("config.toml"); if (result) do_stuff_with_a_table(result); //implicitly converts to table& else std::cerr << "Parse failed:\n"sv << result.error() << "\n"; \ecpp
\out example output:
Parse failed: Encountered unexpected character while parsing boolean; expected 'true', saw 'trU' (error occurred at line 1, column 13 of 'config.toml') \eout
Getting node_views (operator[]
, at_path()
) and using the iterator accessor functions (begin()
, end()
etc.) are unconditionally safe; when parsing fails these just return 'empty' values. A ranged-for loop on a failed parse_result is also safe since begin()
and end()
return the same iterator and will not lead to any dereferences and iterations.
A BidirectionalIterator for iterating over const key-value pairs in a wrapped toml::table.
using parse_result::iterator = table_iterator |
A BidirectionalIterator for iterating over key-value pairs in a wrapped toml::table.
|
inlinenoexcept |
Default constructs an 'error' result.
|
inlineexplicitnoexcept |
|
inlineexplicitnoexcept |
|
inlinenoexcept |
Move constructor.
|
inlinenoexcept |
Destructor.
|
inlinenoexcept |
Returns a const view of the subnode matching a fully-qualified "TOML path".
|
inlinenoexcept |
Returns a view of the subnode matching a fully-qualified "TOML path".
|
inlinenoexcept |
Returns a const view of the subnode matching a fully-qualified "TOML path".
|
inlinenoexcept |
Returns a view of the subnode matching a fully-qualified "TOML path".
|
inline |
Returns a view of the subnode matching a fully-qualified "TOML path".
\availability This overload is only available when TOML_ENABLE_WINDOWS_COMPAT is enabled.
|
inline |
Returns a const view of the subnode matching a fully-qualified "TOML path".
\availability This overload is only available when TOML_ENABLE_WINDOWS_COMPAT is enabled.
|
inlinenoexcept |
Returns an iterator to the first key-value pair in the wrapped table.
|
inlinenoexcept |
Returns an iterator to the first key-value pair in the wrapped table.
|
inlinenoexcept |
Returns an iterator to the first key-value pair in the wrapped table.
|
inlinenoexcept |
Returns an iterator to one-past-the-last key-value pair in the wrapped table.
|
inlineprivatenoexcept |
|
inlinenoexcept |
Returns an iterator to one-past-the-last key-value pair in the wrapped table.
|
inlinenoexcept |
Returns an iterator to one-past-the-last key-value pair in the wrapped table.
|
inlinenoexcept |
Returns the internal toml::parse_error (rvalue overload).
|
inlinenoexcept |
Returns the internal toml::parse_error.
|
inlinenoexcept |
Returns the internal toml::parse_error (const lvalue overload).
|
inlinenoexcept |
Returns true if parsing failed.
|
inlinestaticprivatenoexcept |
|
inlineexplicitnoexcept |
Returns true if parsing succeeded.
|
inlineexplicitnoexcept |
Returns the internal toml::parse_error (const lvalue overload).
|
inlinenoexcept |
Returns the internal toml::table (const lvalue overload).
|
inlineexplicitnoexcept |
Returns the internal toml::parse_error.
|
inlineexplicitnoexcept |
Returns the internal toml::parse_error (rvalue overload).
|
inlinenoexcept |
Returns the internal toml::table.
|
inlinenoexcept |
Returns the internal toml::table (rvalue overload).
|
inlinenoexcept |
Move-assignment operator.
|
inlinenoexcept |
Returns a const view of the subnode matching a fully-qualified "TOML path".
|
inlinenoexcept |
Returns a view of the subnode matching a fully-qualified "TOML path".
|
inlinenoexcept |
Gets a node_view for the selected key-value pair in the wrapped table (const overload).
key | The key used for the lookup. |
|
inlinenoexcept |
Gets a node_view for the selected key-value pair in the wrapped table.
key | The key used for the lookup. |
|
inline |
Gets a node_view for the selected key-value pair in the wrapped table.
\availability This overload is only available when TOML_ENABLE_WINDOWS_COMPAT is enabled.
key | The key used for the lookup. |
|
inline |
Gets a node_view for the selected key-value pair in the wrapped table (const overload).
\availability This overload is only available when TOML_ENABLE_WINDOWS_COMPAT is enabled.
key | The key used for the lookup. |
|
inlinenoexcept |
Returns true if parsing succeeeded.
|
inlinenoexcept |
Returns the internal toml::table (rvalue overload).
|
inlinenoexcept |
Returns the internal toml::table.
|
inlinenoexcept |
Returns the internal toml::table (const lvalue overload).
|
friend |
Prints the held error or table object out to a text stream.
\availability This operator is only available when TOML_ENABLE_FORMATTERS is enabled.
|
private |
|
mutableprivate |