8#if TOML_DOXYGEN || (TOML_ENABLE_PARSER && !TOML_EXCEPTIONS)
57 static constexpr size_t size =
58 (
sizeof(toml::table) <
sizeof(parse_error) ?
sizeof(parse_error) : sizeof(
toml::
table));
60 (
alignof(toml::table) <
alignof(parse_error) ?
alignof(parse_error) : alignof(
toml::
table));
68 template <
typename Type>
79 get_as<parse_error>(
storage_)->~parse_error();
81 get_as<toml::table>(
storage_)->~table();
104 ::new (
static_cast<void*
>(
storage_.
bytes)) parse_error{ std::move(err) };
113 ::new (
static_cast<void*
>(
storage_.
bytes)) parse_error{ std::move(res).error() };
121 if (
err_ != rhs.err_)
126 ::new (
static_cast<void*
>(
storage_.
bytes)) parse_error{ std::move(rhs).error() };
128 ::new (
static_cast<void*
>(
storage_.
bytes)) toml::table{ std::move(rhs).table() };
133 error() = std::move(rhs).error();
165 explicit operator bool() const noexcept
182 return *get_as<toml::table>(
storage_);
190 return static_cast<toml::table&&
>(*get_as<toml::table>(
storage_));
195 const toml::table&
table() const& noexcept
198 return *get_as<const toml::table>(
storage_);
203 operator toml::table&()
noexcept
210 operator toml::table&&()
noexcept
212 return std::move(
table());
217 operator const toml::table&()
const noexcept
234 return *get_as<parse_error>(
storage_);
242 return static_cast<parse_error&&
>(*get_as<parse_error>(
storage_));
247 const parse_error&
error() const& noexcept
250 return *get_as<const parse_error>(
storage_);
255 explicit operator parse_error&()
noexcept
262 explicit operator parse_error&&()
noexcept
264 return std::move(
error());
269 explicit operator const parse_error&()
const noexcept
311 table_iterator
end() noexcept
348 node_view<const node>
at_path(std::string_view
path)
const noexcept
350 return err_ ? node_view<const node>{} :
table().at_path(
path);
366 node_view<const node>
at_path(
const toml::path&
path)
const noexcept
368 return err_ ? node_view<const node>{} :
table().at_path(
path);
371#if TOML_ENABLE_WINDOWS_COMPAT
392 return err_ ? node_view<const node>{} :
table().at_path(
path);
426 return err_ ? node_view<node>{} :
table()[key];
438 node_view<const node>
operator[](std::string_view key)
const noexcept
440 return err_ ? node_view<const node>{} :
table()[key];
443#if TOML_ENABLE_WINDOWS_COMPAT
458 return err_ ? node_view<node>{} :
table()[key];
472 node_view<const node>
operator[](std::wstring_view key)
const
474 return err_ ? node_view<const node>{} :
table()[key];
481#if TOML_ENABLE_FORMATTERS
488 return result.
err_ ? (os << result.
error()) : (os << result.
table());
The result of a parsing operation.
Definition parse_result.hpp:53
TOML_NODISCARD toml::table && table() &&noexcept
Returns the internal toml::table (rvalue overload).
Definition parse_result.hpp:187
TOML_NODISCARD toml::table & table() &noexcept
Returns the internal toml::table.
Definition parse_result.hpp:179
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".
Definition parse_result.hpp:410
TOML_NODISCARD node_view< node > at_path(std::string_view path) noexcept
Returns a view of the subnode matching a fully-qualified "TOML path".
Definition parse_result.hpp:339
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).
Definition parse_result.hpp:472
TOML_NODISCARD node_view< node > at_path(const toml::path &path) noexcept
Returns a view of the subnode matching a fully-qualified "TOML path".
Definition parse_result.hpp:357
TOML_NODISCARD const toml::table & table() const &noexcept
Returns the internal toml::table (const lvalue overload).
Definition parse_result.hpp:195
TOML_NODISCARD const_table_iterator begin() const noexcept
Returns an iterator to the first key-value pair in the wrapped table.
Definition parse_result.hpp:296
TOML_NODISCARD bool failed() const noexcept
Returns true if parsing failed.
Definition parse_result.hpp:158
friend std::ostream & operator<<(std::ostream &os, const parse_result &result)
Prints the held error or table object out to a text stream.
Definition parse_result.hpp:486
TOML_NODISCARD_CTOR parse_result(parse_result &&res) noexcept
Move constructor.
Definition parse_result.hpp:109
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".
Definition parse_result.hpp:366
TOML_NODISCARD table_iterator end() noexcept
Returns an iterator to one-past-the-last key-value pair in the wrapped table.
Definition parse_result.hpp:311
~parse_result() noexcept
Destructor.
Definition parse_result.hpp:141
TOML_NODISCARD_CTOR parse_result(toml::table &&tbl) noexcept
Definition parse_result.hpp:94
table_iterator iterator
A BidirectionalIterator for iterating over key-value pairs in a wrapped toml::table.
Definition parse_result.hpp:280
TOML_NODISCARD table_iterator begin() noexcept
Returns an iterator to the first key-value pair in the wrapped table.
Definition parse_result.hpp:288
const_table_iterator const_iterator
A BidirectionalIterator for iterating over const key-value pairs in a wrapped toml::table.
Definition parse_result.hpp:283
parse_result & operator=(parse_result &&rhs) noexcept
Move-assignment operator.
Definition parse_result.hpp:119
TOML_NODISCARD_CTOR parse_result() noexcept
Default constructs an 'error' result.
Definition parse_result.hpp:87
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.
Definition parse_result.hpp:424
TOML_NODISCARD const_table_iterator end() const noexcept
Returns an iterator to one-past-the-last key-value pair in the wrapped table.
Definition parse_result.hpp:318
TOML_NODISCARD node_view< node > at_path(std::wstring_view path)
Returns a view of the subnode matching a fully-qualified "TOML path".
Definition parse_result.hpp:379
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).
Definition parse_result.hpp:438
TOML_NODISCARD node_view< node > operator[](std::wstring_view key)
Gets a node_view for the selected key-value pair in the wrapped table.
Definition parse_result.hpp:456
TOML_NODISCARD static TOML_ALWAYS_INLINE Type * get_as(storage_t &s) noexcept
Definition parse_result.hpp:71
TOML_NODISCARD_CTOR parse_result(parse_error &&err) noexcept
Definition parse_result.hpp:101
void destroy() noexcept
Definition parse_result.hpp:76
TOML_NODISCARD const_table_iterator cend() const noexcept
Returns an iterator to one-past-the-last key-value pair in the wrapped table.
Definition parse_result.hpp:325
TOML_NODISCARD node_view< node > operator[](const toml::path &path) noexcept
Returns a view of the subnode matching a fully-qualified "TOML path".
Definition parse_result.hpp:401
TOML_NODISCARD parse_error && error() &&noexcept
Returns the internal toml::parse_error (rvalue overload).
Definition parse_result.hpp:239
TOML_NODISCARD const parse_error & error() const &noexcept
Returns the internal toml::parse_error (const lvalue overload).
Definition parse_result.hpp:247
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".
Definition parse_result.hpp:348
bool err_
Definition parse_result.hpp:66
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".
Definition parse_result.hpp:390
TOML_NODISCARD bool succeeded() const noexcept
Returns true if parsing succeeeded.
Definition parse_result.hpp:151
TOML_NODISCARD parse_error & error() &noexcept
Returns the internal toml::parse_error.
Definition parse_result.hpp:231
storage_t storage_
Definition parse_result.hpp:65
TOML_NODISCARD const_table_iterator cbegin() const noexcept
Returns an iterator to the first key-value pair in the wrapped table.
Definition parse_result.hpp:304
A TOML path.
Definition path.hpp:239
A TOML table.
Definition table.hpp:220
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.
Definition table.hpp:797
TOML_PURE_INLINE_GETTER const_iterator cbegin() const noexcept
Returns an iterator to the first key-value pair.
Definition table.hpp:811
TOML_PURE_INLINE_GETTER iterator end() noexcept
Returns an iterator to one-past-the-last key-value pair.
Definition table.hpp:818
TOML_PURE_INLINE_GETTER const_iterator cend() const noexcept
Returns an iterator to one-past-the-last key-value pair.
Definition table.hpp:832
#define TOML_ASSERT_ASSUME(expr)
Definition preprocessor.hpp:1190
The root namespace for all toml++ functions and types.
Definition forward_declarations.hpp:199
TOML_NAMESPACE_START
Definition parse_result.hpp:15
TOML_ABI_NAMESPACE_END
Definition parse_result.hpp:494
TOML_NAMESPACE_END
Definition parse_result.hpp:496
#define TOML_NODISCARD_CTOR
Definition preprocessor.hpp:446
#define TOML_NODISCARD
Definition preprocessor.hpp:439
#define TOML_ABI_NAMESPACE_START(name)
Definition preprocessor.hpp:1322
#define TOML_ALWAYS_INLINE
Definition preprocessor.hpp:405
#define TOML_LAUNDER(x)
Definition std_new.hpp:17
Definition parse_result.hpp:56
unsigned char bytes[size]
Definition parse_result.hpp:62
static constexpr size_t align
Definition parse_result.hpp:59
static constexpr size_t size
Definition parse_result.hpp:57
A source document region.
Definition source_region.hpp:167
POXY_IMPLEMENTATION_DETAIL(impl::table_iterator< true >) const_table_iterator
A BidirectionalIterator for iterating over const key-value pairs in a toml::table.
Definition table.hpp:186