8#if TOML_DOXYGEN || (TOML_ENABLE_PARSER && !TOML_EXCEPTIONS)
54 static constexpr size_t size =
55 (
sizeof(toml::table) <
sizeof(parse_error) ?
sizeof(parse_error) :
sizeof(toml::table));
56 static constexpr size_t align =
57 (
alignof(toml::table) <
alignof(parse_error) ?
alignof(parse_error)
58 :
alignof(toml::table));
63 alignas(storage_t::align)
mutable storage_t storage_;
66 template <
typename Type>
71 void destroy()
noexcept {
73 get_as<parse_error>(storage_)->~parse_error();
75 get_as<toml::table>(storage_)->~table();
83 ::new (
static_cast<void*
>(storage_.bytes)) parse_error{std::string{},
source_region{}};
89 ::new (
static_cast<void*
>(storage_.bytes))
toml::
table{std::move(tbl)};
95 ::new (
static_cast<void*
>(storage_.bytes)) parse_error{std::move(err)};
103 ::new (
static_cast<void*
>(storage_.bytes)) parse_error{std::move(
res).error()};
110 if (err_ !=
rhs.err_) {
114 ::new (
static_cast<void*
>(storage_.bytes)) parse_error{std::move(
rhs).error()};
116 ::new (
static_cast<void*
>(storage_.bytes)) toml::table{std::move(
rhs).table()};
138 bool failed() const noexcept {
return err_; }
142 explicit operator bool() const noexcept {
return !err_; }
156 return *get_as<toml::table>(storage_);
163 return static_cast<toml::table&&
>(*get_as<toml::table>(storage_));
168 const toml::table&
table() const& noexcept {
170 return *get_as<const toml::table>(storage_);
175 operator toml::table&()
noexcept {
return table(); }
179 operator toml::table&&()
noexcept {
return std::move(
table()); }
183 operator const toml::table&()
const noexcept {
return table(); }
197 return *get_as<parse_error>(storage_);
204 return static_cast<parse_error&&
>(*get_as<parse_error>(storage_));
209 const parse_error&
error() const& noexcept {
211 return *get_as<const parse_error>(storage_);
216 explicit operator parse_error&()
noexcept {
return error(); }
220 explicit operator parse_error&&()
noexcept {
return std::move(
error()); }
224 explicit operator const parse_error&()
const noexcept {
return error(); }
259 table_iterator
end() noexcept {
return err_ ? table_iterator{} :
table().
end(); }
283 return err_ ? node_view<node>{} :
table().at_path(
path);
290 node_view<const node>
at_path(std::string_view
path)
const noexcept {
291 return err_ ? node_view<const node>{} :
table().at_path(
path);
299 return err_ ? node_view<node>{} :
table().at_path(
path);
306 node_view<const node>
at_path(
const toml::path&
path)
const noexcept {
307 return err_ ? node_view<const node>{} :
table().at_path(
path);
310#if TOML_ENABLE_WINDOWS_COMPAT
319 return err_ ? node_view<node>{} :
table().at_path(
path);
329 return err_ ? node_view<const node>{} :
table().at_path(
path);
339 return err_ ? node_view<node>{} :
table()[
path];
347 return err_ ? node_view<const node>{} :
table()[
path];
360 return err_ ? node_view<node>{} :
table()[key];
373 node_view<const node>
operator[](std::string_view key)
const noexcept {
374 return err_ ? node_view<const node>{} :
table()[key];
377#if TOML_ENABLE_WINDOWS_COMPAT
391 return err_ ? node_view<node>{} :
table()[key];
406 node_view<const node>
operator[](std::wstring_view key)
const {
407 return err_ ? node_view<const node>{} :
table()[key];
414#if TOML_ENABLE_FORMATTERS
The result of a parsing operation.
TOML_NODISCARD toml::table && table() &&noexcept
Returns the internal toml::table (rvalue overload).
TOML_NODISCARD toml::table & table() &noexcept
Returns the internal toml::table.
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 > 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 > operator[](std::wstring_view key) const
Gets a node_view for the selected key-value pair in the wrapped table (const overload).
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 const toml::table & table() const &noexcept
Returns the internal toml::table (const lvalue overload).
TOML_NODISCARD const_table_iterator begin() const noexcept
Returns an iterator to the first key-value pair in the wrapped table.
TOML_NODISCARD bool failed() const noexcept
Returns true if parsing failed.
friend std::ostream & operator<<(std::ostream &os, const parse_result &result)
Prints the held error or table object out to a text stream.
TOML_NODISCARD_CTOR parse_result(parse_result &&res) noexcept
Move constructor.
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 table_iterator end() noexcept
Returns an iterator to one-past-the-last key-value pair in the wrapped table.
~parse_result() noexcept
Destructor.
TOML_NODISCARD_CTOR parse_result(toml::table &&tbl) noexcept
table_iterator iterator
A BidirectionalIterator for iterating over 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.
const_table_iterator const_iterator
A BidirectionalIterator for iterating over const key-value pairs in a wrapped toml::table.
parse_result & operator=(parse_result &&rhs) noexcept
Move-assignment operator.
TOML_NODISCARD_CTOR parse_result() noexcept
Default constructs an 'error' result.
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 const_table_iterator end() const noexcept
Returns an iterator to one-past-the-last key-value pair in the wrapped table.
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 > 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_CTOR parse_result(parse_error &&err) noexcept
TOML_NODISCARD const_table_iterator cend() const noexcept
Returns an iterator to one-past-the-last key-value pair in the wrapped table.
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 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 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< const node > at_path(std::wstring_view path) const
Returns a const view of the subnode matching a fully-qualified "TOML path".
TOML_NODISCARD bool succeeded() const noexcept
Returns true if parsing succeeeded.
TOML_NODISCARD parse_error & error() &noexcept
Returns the internal toml::parse_error.
TOML_NODISCARD const_table_iterator cbegin() const noexcept
Returns an iterator to the first key-value pair in the wrapped table.
TOML_NODISCARD_CTOR TOML_EXPORTED_MEMBER_FUNCTION table() noexcept
Default constructor.
TOML_PURE_INLINE_GETTER iterator begin() noexcept
Returns an iterator to the first key-value pair.
TOML_PURE_INLINE_GETTER const_iterator cbegin() const noexcept
Returns an iterator to the first key-value pair.
TOML_PURE_INLINE_GETTER const_iterator cend() const noexcept
Returns an iterator to one-past-the-last key-value pair.
#define TOML_ASSERT_ASSUME(expr)
The root namespace for all toml++ functions and types.
#define TOML_NODISCARD_CTOR
#define TOML_ABI_NAMESPACE_START(name)
#define TOML_ALWAYS_INLINE
A source document region.
POXY_IMPLEMENTATION_DETAIL(impl::table_iterator< true >) const_table_iterator
A BidirectionalIterator for iterating over const key-value pairs in a toml::table.