|
Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
|
The result of a parsing operation. More...
#include <parse_result.hpp>
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). | |
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.
Definition at line 51 of file parse_result.hpp.
A BidirectionalIterator for iterating over const key-value pairs in a wrapped toml::table.
Definition at line 236 of file parse_result.hpp.
| using parse_result::iterator = table_iterator |
A BidirectionalIterator for iterating over key-value pairs in a wrapped toml::table.
Definition at line 232 of file parse_result.hpp.
|
inlinenoexcept |
Default constructs an 'error' result.
Definition at line 81 of file parse_result.hpp.
|
inlineexplicitnoexcept |
Definition at line 87 of file parse_result.hpp.
|
inlineexplicitnoexcept |
Definition at line 93 of file parse_result.hpp.
|
inlinenoexcept |
Move constructor.
Definition at line 100 of file parse_result.hpp.
|
inlinenoexcept |
Destructor.
Definition at line 127 of file parse_result.hpp.
|
inlinenoexcept |
Returns a const view of the subnode matching a fully-qualified "TOML path".
Definition at line 306 of file parse_result.hpp.
|
inlinenoexcept |
Returns a view of the subnode matching a fully-qualified "TOML path".
Definition at line 298 of file parse_result.hpp.
|
inlinenoexcept |
Returns a const view of the subnode matching a fully-qualified "TOML path".
Definition at line 290 of file parse_result.hpp.
|
inlinenoexcept |
Returns a view of the subnode matching a fully-qualified "TOML path".
Definition at line 282 of file parse_result.hpp.
|
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.
Definition at line 318 of file parse_result.hpp.
|
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.
Definition at line 328 of file parse_result.hpp.
|
inlinenoexcept |
Returns an iterator to the first key-value pair in the wrapped table.
Definition at line 246 of file parse_result.hpp.
|
inlinenoexcept |
Returns an iterator to the first key-value pair in the wrapped table.
Definition at line 241 of file parse_result.hpp.
|
inlinenoexcept |
Returns an iterator to the first key-value pair in the wrapped table.
Definition at line 253 of file parse_result.hpp.
|
inlinenoexcept |
Returns an iterator to one-past-the-last key-value pair in the wrapped table.
Definition at line 269 of file parse_result.hpp.
|
inlinenoexcept |
Returns an iterator to one-past-the-last key-value pair in the wrapped table.
Definition at line 263 of file parse_result.hpp.
|
inlinenoexcept |
Returns an iterator to one-past-the-last key-value pair in the wrapped table.
Definition at line 259 of file parse_result.hpp.
|
inlinenoexcept |
Returns the internal toml::parse_error (rvalue overload).
Definition at line 202 of file parse_result.hpp.
|
inlinenoexcept |
Returns the internal toml::parse_error.
Definition at line 195 of file parse_result.hpp.
|
inlinenoexcept |
Returns the internal toml::parse_error (const lvalue overload).
Definition at line 209 of file parse_result.hpp.
|
inlinenoexcept |
Returns true if parsing failed.
Definition at line 138 of file parse_result.hpp.
|
inlineexplicitnoexcept |
Returns true if parsing succeeded.
Definition at line 142 of file parse_result.hpp.
|
inlineexplicitnoexcept |
Returns the internal toml::parse_error (const lvalue overload).
Definition at line 224 of file parse_result.hpp.
|
inlinenoexcept |
Returns the internal toml::table (const lvalue overload).
Definition at line 183 of file parse_result.hpp.
|
inlineexplicitnoexcept |
Returns the internal toml::parse_error.
Definition at line 216 of file parse_result.hpp.
|
inlineexplicitnoexcept |
Returns the internal toml::parse_error (rvalue overload).
Definition at line 220 of file parse_result.hpp.
|
inlinenoexcept |
Returns the internal toml::table.
Definition at line 175 of file parse_result.hpp.
|
inlinenoexcept |
Returns the internal toml::table (rvalue overload).
Definition at line 179 of file parse_result.hpp.
|
inlinenoexcept |
Move-assignment operator.
Definition at line 109 of file parse_result.hpp.
|
inlinenoexcept |
Returns a const view of the subnode matching a fully-qualified "TOML path".
Definition at line 346 of file parse_result.hpp.
|
inlinenoexcept |
Returns a view of the subnode matching a fully-qualified "TOML path".
Definition at line 338 of file parse_result.hpp.
|
inlinenoexcept |
Gets a node_view for the selected key-value pair in the wrapped table (const overload).
| key | The key used for the lookup. |
Definition at line 373 of file parse_result.hpp.
|
inlinenoexcept |
Gets a node_view for the selected key-value pair in the wrapped table.
| key | The key used for the lookup. |
Definition at line 359 of file parse_result.hpp.
|
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. |
Definition at line 390 of file parse_result.hpp.
|
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. |
Definition at line 406 of file parse_result.hpp.
|
inlinenoexcept |
Returns true if parsing succeeeded.
Definition at line 134 of file parse_result.hpp.
|
inlinenoexcept |
Returns the internal toml::table (rvalue overload).
Definition at line 161 of file parse_result.hpp.
|
inlinenoexcept |
Returns the internal toml::table.
Definition at line 154 of file parse_result.hpp.
|
inlinenoexcept |
Returns the internal toml::table (const lvalue overload).
Definition at line 168 of file parse_result.hpp.
|
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.
Definition at line 419 of file parse_result.hpp.