class
parse_resultThe result of a parsing operation.
A parse_
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";
example output: Parse failed: Encountered unexpected character while parsing boolean; expected 'true', saw 'trU' (error occurred at line 1, column 13 of 'config.toml')
Getting node_views (operator[]
) 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_begin()
and end()
return the same iterator and will not lead to any dereferences and iterations.
Public types
-
using const_iterator = const_
table_ iterator - A BidirectionalIterator for iterating over const key-value pairs in a wrapped toml::
table. -
using iterator = table_
iterator - A BidirectionalIterator for iterating over key-value pairs in a wrapped toml::
table.
Constructors, destructors, conversion operators
- operator bool() const explicit noexcept
- Returns true if parsing succeeded.
- operator const parse_error&() const explicit noexcept
- Returns the internal toml::
parse_error (const lvalue overload). - operator const toml::table&() const noexcept
- Returns the internal toml::
table (const lvalue overload). - operator parse_error&() explicit noexcept
- Returns the internal toml::
parse_error. - operator parse_error&&() explicit noexcept
- Returns the internal toml::
parse_error (rvalue overload). - operator toml::table&() noexcept
- Returns the internal toml::
table. - operator toml::table&&() noexcept
- Returns the internal toml::
table (rvalue overload). -
parse_result(parse_
result&& res) noexcept - Move constructor.
- ~parse_result() noexcept
- Destructor.
Public functions
-
auto begin() → table_
iterator noexcept - Returns an iterator to the first key-value pair in the wrapped table.
-
auto begin() const → const_
table_ iterator noexcept - Returns an iterator to the first key-value pair in the wrapped table.
-
auto cbegin() const → const_
table_ iterator noexcept - Returns an iterator to the first key-value pair in the wrapped table.
-
auto cend() const → const_
table_ iterator noexcept - Returns an iterator to one-past-the-last key-value pair in the wrapped table.
-
auto end() → table_
iterator noexcept - Returns an iterator to one-past-the-last key-value pair in the wrapped table.
-
auto end() const → const_
table_ iterator noexcept - Returns an iterator to one-past-the-last key-value pair in the wrapped table.
-
auto error() & → parse_
error& noexcept - Returns the internal toml::
parse_error. -
auto error() && → parse_
error&& noexcept - Returns the internal toml::
parse_error (rvalue overload). -
auto error() const & → const parse_
error& noexcept - Returns the internal toml::
parse_error (const lvalue overload). - auto failed() const → bool noexcept
- Returns true if parsing failed.
-
auto operator=(parse_
result&& rhs) → parse_ result& noexcept - Move-assignment operator.
-
auto operator[](string_view key) → node_
view<node> noexcept - Gets a node_
view for the selected key-value pair in the wrapped table. -
auto operator[](string_view key) const → node_
view<const node> noexcept - Gets a node_
view for the selected key-value pair in the wrapped table (const overload). -
auto operator[](std::
wstring_view key) → node_ view<node> noexcept - Gets a node_
view for the selected key-value pair in the wrapped table. -
auto operator[](std::
wstring_view key) const → node_ view<const node> noexcept - Gets a node_
view for the selected key-value pair in the wrapped table (const overload). - auto succeeded() const → bool noexcept
- Returns true if parsing succeeeded.
-
auto table() & → toml::
table& noexcept - Returns the internal toml::
table. -
auto table() && → toml::
table&& noexcept - Returns the internal toml::
table (rvalue overload). -
auto table() const & → const toml::
table& noexcept - Returns the internal toml::
table (const lvalue overload).
Friends
-
template <typename Char>auto operator<<(std::
basic_ostream<Char>& os, const parse_ result& result) → std:: basic_ostream<Char>& - Prints the held error or table object out to a text stream.
Function documentation
table_ iterator toml:: parse_result:: begin() noexcept
Returns an iterator to the first key-value pair in the wrapped table.
const_ table_ iterator toml:: parse_result:: begin() const noexcept
Returns an iterator to the first key-value pair in the wrapped table.
const_ table_ iterator toml:: parse_result:: cbegin() const noexcept
Returns an iterator to the first key-value pair in the wrapped table.
const_ table_ iterator toml:: parse_result:: cend() const noexcept
Returns an iterator to one-past-the-last key-value pair in the wrapped table.
table_ iterator toml:: parse_result:: end() noexcept
Returns an iterator to one-past-the-last key-value pair in the wrapped table.
const_ table_ iterator toml:: parse_result:: end() const noexcept
Returns an iterator to one-past-the-last key-value pair in the wrapped table.
node_ view<node> toml:: parse_result:: operator[](string_view key) noexcept
Gets a node_
Parameters | |
---|---|
key | The key used for the lookup. |
Returns | A view of the value at the given key if parsing was successful and a matching key existed, or an empty node view. |
node_ view<const node> toml:: parse_result:: operator[](string_view key) const noexcept
Gets a node_
Parameters | |
---|---|
key | The key used for the lookup. |
Returns | A view of the value at the given key if parsing was successful and a matching key existed, or an empty node view. |
node_ view<node> toml:: parse_result:: operator[](std:: wstring_view key) noexcept
Gets a node_
Parameters | |
---|---|
key | The key used for the lookup. |
Returns | A view of the value at the given key if parsing was successful and a matching key existed, or an empty node view. |
node_ view<const node> toml:: parse_result:: operator[](std:: wstring_view key) const noexcept
Gets a node_
Parameters | |
---|---|
key | The key used for the lookup. |
Returns | A view of the value at the given key if parsing was successful and a matching key existed, or an empty node view. |