18 template <
bool IsConst>
19 struct table_proxy_pair {
20 using value_type = std::conditional_t<IsConst, const node, node>;
22 const toml::key& first;
26 template <
bool IsConst>
27 class table_iterator {
30 friend class table_iterator;
32 using proxy_type = table_proxy_pair<IsConst>;
33 using mutable_map_iterator = std::map<toml::key, node_ptr, std::less<>>::iterator;
34 using const_map_iterator = std::map<toml::key, node_ptr, std::less<>>::const_iterator;
35 using map_iterator = std::conditional_t<IsConst, const_map_iterator, mutable_map_iterator>;
37 mutable map_iterator iter_;
38 alignas(proxy_type)
mutable unsigned char proxy_[
sizeof(proxy_type)];
39 mutable bool proxy_instantiated_ =
false;
42 proxy_type* get_proxy() const noexcept {
43 if (!proxy_instantiated_) {
44 auto p = ::new (
static_cast<void*
>(proxy_)) proxy_type{iter_->first, *iter_->second.get()};
45 proxy_instantiated_ =
true;
48 return TOML_LAUNDER(
reinterpret_cast<proxy_type*
>(proxy_));
53 table_iterator() noexcept = default;
56 explicit table_iterator(mutable_map_iterator iter) noexcept
61 explicit table_iterator(const_map_iterator iter)
noexcept
66 table_iterator(
const table_iterator<false>& other)
noexcept
67 : iter_{other.iter_} {}
70 table_iterator(
const table_iterator& other)
noexcept
71 : iter_{other.iter_} {}
73 table_iterator& operator=(
const table_iterator&
rhs)
noexcept {
75 proxy_instantiated_ =
false;
79 using value_type = table_proxy_pair<IsConst>;
80 using reference = value_type&;
81 using pointer = value_type*;
82 using difference_type =
typename std::iterator_traits<map_iterator>::difference_type;
83 using iterator_category =
typename std::iterator_traits<map_iterator>::iterator_category;
85 table_iterator& operator++() noexcept
88 proxy_instantiated_ =
false;
92 table_iterator operator++(
int)
noexcept
94 table_iterator
out{iter_};
96 proxy_instantiated_ =
false;
100 table_iterator& operator--() noexcept
103 proxy_instantiated_ =
false;
107 table_iterator operator--(
int)
noexcept
109 table_iterator
out{iter_};
111 proxy_instantiated_ =
false;
116 reference
operator*() const noexcept {
return *get_proxy(); }
119 pointer operator->() const noexcept {
return get_proxy(); }
122 explicit operator const map_iterator&()
const noexcept {
return iter_; }
126 explicit operator const const_map_iterator() const noexcept {
return iter_; }
129 friend bool operator==(
const table_iterator&
lhs,
const table_iterator&
rhs)
noexcept {
130 return lhs.iter_ ==
rhs.iter_;
134 friend bool operator!=(
const table_iterator&
lhs,
const table_iterator&
rhs)
noexcept {
135 return lhs.iter_ !=
rhs.iter_;
139 struct table_init_pair {
140 mutable toml::key key;
141 mutable node_ptr
value;
143 template <
typename K,
typename V>
146 : key{static_cast<
K&&>(
k)},
value{make_node(static_cast<
V&&>(
v),
flags)} {}
194 using map_type = std::map<toml::key, impl::node_ptr, std::less<>>;
195 using map_pair = std::pair<const toml::key, impl::node_ptr>;
196 using map_iterator =
typename map_type::iterator;
197 using const_map_iterator =
typename map_type::const_iterator;
200 bool inline_ =
false;
204 table(
const impl::table_init_pair*,
const impl::table_init_pair*);
245 explicit
table(
std::initializer_list<impl::table_init_pair> kvps)
246 :
table(kvps.begin(), kvps.end()) {}
261 node_type
type() const noexcept final {
return node_type::table; }
273 bool is_homogeneous(node_type ntype,
const node*& first_nonmatch)
const noexcept final;
276 template <
typename ElemType =
void>
278 using type = impl::remove_cvref<impl::unwrap_node<ElemType>>;
279 static_assert(std::is_void_v<type> || toml::is_value<type> || toml::is_container<type>,
280 "The template type argument of table::is_homogeneous() must be void or one "
281 "of:" TOML_SA_UNWRAPPED_NODE_TYPE_LIST);
283 return is_homogeneous(impl::node_type_of<type>);
289 bool is_table() const noexcept final {
return true; }
293 bool is_array() const noexcept final {
return false; }
301 bool is_value() const noexcept final {
return false; }
325 bool is_date() const noexcept final {
return false; }
329 bool is_time() const noexcept final {
return false; }
350 toml::value<std::string>*
as_string() noexcept final {
return nullptr; }
354 toml::value<int64_t>*
as_integer() noexcept final {
return nullptr; }
362 toml::value<bool>*
as_boolean() noexcept final {
return nullptr; }
366 toml::value<date>*
as_date() noexcept final {
return nullptr; }
370 toml::value<time>*
as_time() noexcept final {
return nullptr; }
374 toml::value<date_time>*
as_date_time() noexcept final {
return nullptr; }
386 const toml::value<std::string>*
as_string() const noexcept final {
return nullptr; }
390 const toml::value<int64_t>*
as_integer() const noexcept final {
return nullptr; }
398 const toml::value<bool>*
as_boolean() const noexcept final {
return nullptr; }
402 const toml::value<date>*
as_date() const noexcept final {
return nullptr; }
406 const toml::value<time>*
as_time() const noexcept final {
return nullptr; }
410 const toml::value<date_time>*
as_date_time() const noexcept final {
return nullptr; }
495 node*
get(std::string_view key)
noexcept;
503 const node*
get(std::string_view key)
const noexcept {
504 return const_cast<table&
>(*this).
get(key);
507#if TOML_ENABLE_WINDOWS_COMPAT
517 node*
get(std::wstring_view key) {
518 if (empty())
return nullptr;
520 return get(impl::narrow(key));
531 const node*
get(std::wstring_view key)
const {
return const_cast<table&
>(*this).
get(key); }
555 template <
typename T>
557 const auto n = this->get(key);
558 return n ?
n->template as<T>() :
nullptr;
568 template <
typename T>
570 return const_cast<table&
>(*this).template get_as<T>(key);
573#if TOML_ENABLE_WINDOWS_COMPAT
584 template <
typename T>
586 if (empty())
return nullptr;
588 return get_as<T>(impl::narrow(key));
600 template <
typename T>
602 return const_cast<table&
>(*this).template get_as<T>(key);
611 node&
at(std::string_view key);
616 const node&
at(std::string_view key)
const {
return const_cast<table&
>(*this).
at(key); }
618#if TOML_ENABLE_WINDOWS_COMPAT
625 node&
at(std::wstring_view key) {
return at(impl::narrow(key)); }
632 const node&
at(std::wstring_view key)
const {
return const_cast<table&
>(*this).
at(key); }
674 template <
typename T,
typename Table>
675 using for_each_value_ref =
676 impl::copy_cvref<impl::wrap_node<impl::remove_cvref<impl::unwrap_node<T>>>, Table>;
678 template <
typename Func,
typename Table,
typename T>
680 std::disjunction<std::is_invocable<Func, const key&, for_each_value_ref<T, Table>>,
681 std::is_invocable<Func, for_each_value_ref<T, Table>>>;
683 template <
typename Func,
typename Table,
typename T>
684 using can_for_each_nothrow = std::conditional_t<
686 std::is_invocable_v<Func, const key&, for_each_value_ref<T, Table>>,
687 std::is_nothrow_invocable<Func, const key&, for_each_value_ref<T, Table>>,
690 std::is_invocable_v<Func, for_each_value_ref<T, Table>>,
691 std::is_nothrow_invocable<Func, for_each_value_ref<T, Table>>, std::false_type>>;
693 template <
typename Func,
typename Table>
694 using can_for_each_any =
695 std::disjunction<can_for_each<Func, Table, table>, can_for_each<Func, Table, array>,
696 can_for_each<Func, Table, std::string>, can_for_each<Func, Table, int64_t>,
697 can_for_each<Func, Table, double>, can_for_each<Func, Table, bool>,
698 can_for_each<Func, Table, date>, can_for_each<Func, Table, time>,
699 can_for_each<Func, Table, date_time>>;
701 template <
typename Func,
typename Table,
typename T>
702 using for_each_is_nothrow_one =
703 std::disjunction<std::negation<can_for_each<Func, Table, T>>,
704 can_for_each_nothrow<Func, Table, T>>;
706 template <
typename Func,
typename Table>
707 using for_each_is_nothrow = std::conjunction<
708 for_each_is_nothrow_one<Func, Table, table>, for_each_is_nothrow_one<Func, Table, array>,
709 for_each_is_nothrow_one<Func, Table, std::string>,
710 for_each_is_nothrow_one<Func, Table, int64_t>, for_each_is_nothrow_one<Func, Table, double>,
711 for_each_is_nothrow_one<Func, Table, bool>, for_each_is_nothrow_one<Func, Table, date>,
712 for_each_is_nothrow_one<Func, Table, time>,
713 for_each_is_nothrow_one<Func, Table, date_time>>;
715 template <
typename Func,
typename Table>
716 static void do_for_each(Func&& visitor, Table&& tbl)
717 noexcept(for_each_is_nothrow<Func&&, Table&&>::value) {
719 can_for_each_any<Func&&, Table&&>::value,
720 "TOML table for_each visitors must be invocable for at least one of the toml::node "
721 "specializations:" TOML_SA_NODE_TYPE_LIST);
723 using kvp_type = impl::copy_cv<map_pair, std::remove_reference_t<Table>>;
725 for (kvp_type& kvp : tbl.map_) {
726 using node_ref = impl::copy_cvref<toml::node, Table&&>;
727 static_assert(std::is_reference_v<node_ref>);
729#if TOML_RETURN_BOOL_FROM_FOR_EACH_BROKEN
731#ifndef TOML_RETURN_BOOL_FROM_FOR_EACH_BROKEN_ACKNOWLEDGED
732 static_assert(impl::always_false<Func, Table, kvp_type, node_ref>,
733 TOML_RETURN_BOOL_FROM_FOR_EACH_BROKEN_MESSAGE);
736 static_cast<node_ref
>(*kvp.second)
737 .visit([&]([[maybe_unused]]
auto&&
v)
738 noexcept(for_each_is_nothrow_one<Func&&, Table&&,
decltype(
v)>
::value) {
739 using value_ref = for_each_value_ref<
decltype(
v), Table&&>;
740 static_assert(std::is_reference_v<value_ref>);
743 if constexpr (std::is_invocable_v<Func&&, const key&, value_ref>) {
744 static_cast<Func&&
>(visitor)(
static_cast<const key&
>(kvp.first),
745 static_cast<value_ref
>(
v));
749 else if constexpr (std::is_invocable_v<Func&&, value_ref>) {
750 static_cast<Func&&
>(visitor)(
static_cast<value_ref
>(
v));
755 const auto keep_going =
756 static_cast<node_ref
>(*kvp.second)
757 .visit([&]([[maybe_unused]]
auto&&
v)
758 noexcept(for_each_is_nothrow_one<Func&&, Table&&,
decltype(
v)>
::value) {
759 using value_ref = for_each_value_ref<
decltype(
v), Table&&>;
760 static_assert(std::is_reference_v<value_ref>);
763 if constexpr (std::is_invocable_v<Func&&, const key&, value_ref>) {
764 using return_type =
decltype(
static_cast<Func&&
>(visitor)(
765 static_cast<const key&
>(kvp.first),
static_cast<value_ref
>(
v)));
767 if constexpr (impl::is_constructible_or_convertible<bool, return_type>) {
768 return static_cast<bool>(
static_cast<Func&&
>(visitor)(
769 static_cast<const key&
>(kvp.first),
static_cast<value_ref
>(
v)));
771 static_cast<Func&&
>(visitor)(
static_cast<const key&
>(kvp.first),
772 static_cast<value_ref
>(
v));
778 else if constexpr (std::is_invocable_v<Func&&, value_ref>) {
780 decltype(
static_cast<Func&&
>(visitor)(
static_cast<value_ref
>(
v)));
782 if constexpr (impl::is_constructible_or_convertible<bool, return_type>) {
783 return static_cast<bool>(
784 static_cast<Func&&
>(visitor)(
static_cast<value_ref
>(
v)));
786 static_cast<Func&&
>(visitor)(
static_cast<value_ref
>(
v));
796 if (!keep_going)
return;
886 template <
typename Func>
888 noexcept(for_each_is_nothrow<Func&&, table&>::value) {
889 do_for_each(
static_cast<Func&&
>(visitor), *
this);
894 template <
typename Func>
896 noexcept(for_each_is_nothrow<Func&&, table&&>::value) {
897 do_for_each(
static_cast<Func&&
>(visitor),
static_cast<table&&
>(*
this));
898 return static_cast<table&&
>(*this);
902 template <
typename Func>
904 noexcept(for_each_is_nothrow<Func&&, const table&>::value) {
905 do_for_each(
static_cast<Func&&
>(visitor), *
this);
910 template <
typename Func>
912 noexcept(for_each_is_nothrow<Func&&, const table&&>::value) {
913 do_for_each(
static_cast<Func&&
>(visitor),
static_cast<const table&&
>(*
this));
914 return static_cast<const table&&
>(*this);
924 bool empty() const noexcept {
return map_.empty(); }
928 size_t size() const noexcept {
return map_.size(); }
940 map_iterator get_lower_bound(std::string_view)
noexcept;
961#if TOML_ENABLE_WINDOWS_COMPAT
971 if (empty())
return end();
973 return lower_bound(impl::narrow(key));
984 if (empty())
return end();
986 return lower_bound(impl::narrow(key));
1011 bool contains(std::string_view key)
const noexcept {
return get(key) !=
nullptr; }
1013#if TOML_ENABLE_WINDOWS_COMPAT
1024 if (empty())
return end();
1026 return find(impl::narrow(key));
1056 map_iterator erase(const_map_iterator)
noexcept;
1059 map_iterator erase(const_map_iterator, const_map_iterator)
noexcept;
1140 return iterator{erase(const_map_iterator{begin}, const_map_iterator{
end})};
1169 size_t erase(std::string_view key)
noexcept;
1171#if TOML_ENABLE_WINDOWS_COMPAT
1181 if (empty())
return false;
1183 return erase(impl::narrow(key));
1216 return static_cast<toml::table&&
>(this->prune(recursive));
1232 map_iterator insert_with_hint(
const_iterator, key&&, impl::node_ptr&&);
1252 typename ValueType =
void, typename KeyType, typename... ValueArgs)
1255 "Emplacement using wide-character keys is only supported on Windows with "
1256 "TOML_ENABLE_WINDOWS_COMPAT enabled.");
1259 using value_type = std::conditional_t<std::is_void_v<raw_value_type>,
1262 if constexpr (impl::is_wide_string<KeyType>) {
1263#if TOML_ENABLE_WINDOWS_COMPAT
1264 return emplace_hint<value_type>(
hint, impl::narrow(
static_cast<KeyType&&
>(key)),
1265 static_cast<ValueArgs&&
>(args)...);
1267 static_assert(impl::always_false<KeyType>,
"Evaluated unreachable branch!");
1270 static constexpr auto moving_node_ptr =
1271 std::is_same_v<value_type, impl::node_ptr>
1272 &&
sizeof...(ValueArgs) == 1u
1273 && impl::first_is_same<impl::node_ptr&&, ValueArgs&&...>;
1276 static_assert(moving_node_ptr
1277 || impl::is_native<unwrapped_type>
1278 || impl::is_one_of<unwrapped_type, table, array>,
1279 "ValueType argument of table::emplace_hint() must be one "
1280 "of:" TOML_SA_UNWRAPPED_NODE_TYPE_LIST);
1282 map_iterator ipos = insert_with_hint(
hint, toml::key{
static_cast<KeyType&&
>(key)},
nullptr);
1286 if (!ipos->second) {
1287 if constexpr (moving_node_ptr)
1288 ipos->second = std::move(
static_cast<ValueArgs&&
>(args)...);
1290#if TOML_COMPILER_HAS_EXCEPTIONS
1294 new impl::wrap_node<unwrapped_type>{
static_cast<ValueArgs&&
>(args)...});
1295#if TOML_COMPILER_HAS_EXCEPTIONS
1297 erase(const_map_iterator{ipos});
1359 typename KeyType,
typename ValueType)
1360 std::pair<iterator, bool> insert(KeyType&& key, ValueType&&
val,
1363 "Insertion using wide-character keys is only supported on Windows with "
1364 "TOML_ENABLE_WINDOWS_COMPAT enabled.");
1366 if constexpr (is_node_view<ValueType>) {
1367 if (!
val)
return {
end(),
false};
1370 if constexpr (impl::is_wide_string<KeyType>) {
1371#if TOML_ENABLE_WINDOWS_COMPAT
1372 return insert(impl::narrow(
static_cast<KeyType&&
>(key)),
static_cast<ValueType&&
>(
val),
1375 static_assert(impl::always_false<KeyType>,
"Evaluated unreachable branch!");
1378 const auto key_view = std::string_view{key};
1379 map_iterator ipos = get_lower_bound(key_view);
1380 if (ipos == map_.end() || ipos->first != key_view) {
1381 ipos = insert_with_hint(
const_iterator{ipos}, toml::key{
static_cast<KeyType&&
>(key)},
1382 impl::make_node(
static_cast<ValueType&&
>(
val),
flags));
1431 if (begin ==
end)
return;
1432 for (
auto it = begin; it !=
end; it++) {
1433 if constexpr (std::is_rvalue_reference_v<
decltype(*it)>)
1434 insert(std::move((*it).first), std::move((*it).second),
flags);
1436 insert((*it).first, (*it).second,
flags);
1493 typename KeyType,
typename ValueType)
1497 "Insertion using wide-character keys is only supported on Windows with "
1498 "TOML_ENABLE_WINDOWS_COMPAT enabled.");
1500 if constexpr (is_node_view<ValueType>) {
1501 if (!
val)
return {
end(),
false};
1504 if constexpr (impl::is_wide_string<KeyType>) {
1505#if TOML_ENABLE_WINDOWS_COMPAT
1506 return insert_or_assign(impl::narrow(
static_cast<KeyType&&
>(key)),
1507 static_cast<ValueType&&
>(
val),
flags);
1509 static_assert(impl::always_false<KeyType>,
"Evaluated unreachable branch!");
1512 const auto key_view = std::string_view{key};
1513 map_iterator ipos = get_lower_bound(key_view);
1514 if (ipos == map_.end() || ipos->first != key_view) {
1515 ipos = insert_with_hint(
const_iterator{ipos}, toml::key{
static_cast<KeyType&&
>(key)},
1516 impl::make_node(
static_cast<ValueType&&
>(
val),
flags));
1519 (*ipos).second = impl::make_node(
static_cast<ValueType&&
>(
val),
flags);
1565 typename ValueType =
void,
typename KeyType,
typename... ValueArgs)
1566 std::pair<iterator, bool> emplace(KeyType&& key, ValueArgs&&... args) {
1568 "Emplacement using wide-character keys is only supported on Windows with "
1569 "TOML_ENABLE_WINDOWS_COMPAT enabled.");
1572 using value_type = std::conditional_t<std::is_void_v<raw_value_type>,
1575 if constexpr (impl::is_wide_string<KeyType>) {
1576#if TOML_ENABLE_WINDOWS_COMPAT
1577 return emplace<value_type>(impl::narrow(
static_cast<KeyType&&
>(key)),
1578 static_cast<ValueArgs&&
>(args)...);
1580 static_assert(impl::always_false<KeyType>,
"Evaluated unreachable branch!");
1583 using unwrapped_type = impl::remove_cvref<impl::unwrap_node<value_type>>;
1585 (impl::is_native<unwrapped_type> || impl::is_one_of<unwrapped_type, table, array>),
1586 "ValueType argument of table::emplace() must be one "
1587 "of:" TOML_SA_UNWRAPPED_NODE_TYPE_LIST);
1589 const auto key_view = std::string_view{key};
1590 auto ipos = get_lower_bound(key_view);
1591 if (ipos == map_.end() || ipos->first != key_view) {
1592 ipos = insert_with_hint(
const_iterator{ipos}, toml::key{
static_cast<KeyType&&
>(key)},
1593 impl::node_ptr{
new impl::wrap_node<unwrapped_type>{
1594 static_cast<ValueArgs&&
>(args)...}});
1607 using node::operator[];
1622 node_view<node>
operator[](std::string_view key)
noexcept {
return node_view<node>{get(key)}; }
1636 node_view<const node>
operator[](std::string_view key)
const noexcept {
1637 return node_view<const node>{get(key)};
1640#if TOML_ENABLE_WINDOWS_COMPAT
1656 node_view<node>
operator[](std::wstring_view key) {
return node_view<node>{get(key)}; }
1673 return node_view<const node>{get(key)};
1712#if TOML_ENABLE_FORMATTERS
1718 impl::print_to_stream(
lhs,
rhs);
bool equal(const T &x, const U &y)
const plus_asgn< T > & operator*(const plus_asgn< T > &lhs, const plus_asgn< T > &rhs)
std::ostream_iterator< int, char, std::char_traits< char > > Iter
TOML_PURE_INLINE_GETTER const_iterator begin() const noexcept
Returns an iterator to the first key-value pair.
TOML_EXPORTED_MEMBER_FUNCTION table & prune(bool recursive=true) &noexcept
Removes empty child arrays and tables.
TOML_PURE_GETTER TOML_EXPORTED_MEMBER_FUNCTION bool is_homogeneous(node_type ntype, node *&first_nonmatch) noexcept final
TOML_NODISCARD const impl::wrap_node< T > * get_as(std::wstring_view key) const
Gets the node at a specific key if it is a particular type (const overload).
TOML_CONST_INLINE_GETTER bool is_date_time() const noexcept final
Returns false.
TOML_NODISCARD node * get(std::wstring_view key)
Gets the node at a specific key.
TOML_NODISCARD const node & at(std::string_view key) const
Gets a reference to the element at a specific key, throwing std::out_of_range if none existed.
TOML_NODISCARD TOML_EXPORTED_MEMBER_FUNCTION node & at(std::string_view key)
Gets a reference to the element at a specific key, throwing std::out_of_range if none existed.
TOML_CONST_INLINE_GETTER bool is_string() const noexcept final
Returns false.
TOML_PURE_INLINE_GETTER const node * get(std::string_view key) const noexcept
Gets the node at a specific key (const overload).
TOML_CONST_INLINE_GETTER const toml::value< std::string > * as_string() const noexcept final
Returns nullptr.
TOML_NODISCARD bool contains(std::wstring_view key) const
Returns true if the table contains a node at the given key.
TOML_CONST_INLINE_GETTER bool is_number() const noexcept final
Returns false.
TOML_NODISCARD_CTOR TOML_EXPORTED_MEMBER_FUNCTION table() noexcept
Default constructor.
TOML_NODISCARD impl::wrap_node< T > * get_as(std::wstring_view key)
Gets the node at a specific key if it is a particular type.
iterator erase(const_iterator pos) noexcept
Removes the specified key-value pair from the table (const iterator overload).
table && for_each(Func &&visitor) &&noexcept(for_each_is_nothrow< Func &&, table && >::value)
Invokes a visitor on each key-value pair in the table (rvalue overload).
TOML_CONST_INLINE_GETTER const toml::value< double > * as_floating_point() const noexcept final
Returns nullptr.
TOML_CONST_INLINE_GETTER toml::value< bool > * as_boolean() noexcept final
Returns nullptr.
size_t erase(std::wstring_view key)
Removes the value with the given key from the table.
TOML_PURE_GETTER TOML_EXPORTED_MEMBER_FUNCTION node * get(std::string_view key) noexcept
Gets the node at a specific key.
TOML_CONST_INLINE_GETTER const toml::value< int64_t > * as_integer() const noexcept final
Returns nullptr.
table & for_each(Func &&visitor) &noexcept(for_each_is_nothrow< Func &&, table & >::value)
Invokes a visitor on each key-value pair in the table.
TOML_PURE_INLINE_GETTER bool empty() const noexcept
Returns true if the table is empty.
TOML_CONST_INLINE_GETTER const toml::value< time > * as_time() const noexcept final
Returns nullptr.
TOML_NODISCARD node_view< node > operator[](std::wstring_view key)
Gets a node_view for the selected value.
TOML_PURE_GETTER bool contains(std::string_view key) const noexcept
Returns true if the table contains a node at the given key.
const table && for_each(Func &&visitor) const &&noexcept(for_each_is_nothrow< Func &&, const table && >::value)
Invokes a visitor on each key-value pair in the table (const rvalue overload).
TOML_CONST_INLINE_GETTER bool is_array() const noexcept final
Returns false.
TOML_CONST_INLINE_GETTER node_type type() const noexcept final
Returns #toml::node_type::table.
TOML_CONSTRAINED_TEMPLATE((!is_key_or_convertible< Iter > &&!impl::is_wide_string< Iter >), typename Iter) void insert(Iter begin
Inserts a series of key-value pairs into the table.
TOML_CONST_INLINE_GETTER array * as_array() noexcept final
Returns nullptr.
iterator erase(const_iterator begin, const_iterator end) noexcept
Removes the key-value pairs in the range [first, last) from the table.
TOML_NODISCARD const node & at(std::wstring_view key) const
Gets a reference to the element at a specific key, throwing std::out_of_range if none existed.
toml::const_table_iterator const_iterator
A BidirectionalIterator for iterating over const key-value pairs in a toml::table.
TOML_NODISCARD node_view< const node > operator[](std::wstring_view key) const
Gets a node_view for the selected value (const overload).
TOML_EXPORTED_MEMBER_FUNCTION table & operator=(table &&rhs) noexcept
Move-assignment operator.
TOML_EXPORTED_MEMBER_FUNCTION size_t erase(std::string_view key) noexcept
Removes the value with the given key from the table.
TOML_PURE_GETTER impl::wrap_node< T > * get_as(std::string_view key) noexcept
Gets the node at a specific key if it is a particular type.
TOML_EXPORTED_MEMBER_FUNCTION void clear() noexcept
Removes all key-value pairs from the table.
toml::table_iterator iterator
A BidirectionalIterator for iterating over key-value pairs in a toml::table.
TOML_NODISCARD node_view< node > operator[](std::string_view key) noexcept
Gets a node_view for the selected value.
impl::remove_cvref< ValueType > raw_value_type
TOML_CONSTRAINED_TEMPLATE((is_key_or_convertible< KeyType && >||impl::is_wide_string< KeyType >), typename ValueType=void, typename KeyType, typename... ValueArgs) std
Emplaces a new value at a specific key if one did not already exist.
TOML_PURE_GETTER const_iterator lower_bound(std::string_view key) const noexcept
Returns a const iterator to the first key-value pair with key that is not less than the given key.
TOML_PURE_GETTER TOML_EXPORTED_MEMBER_FUNCTION bool is_homogeneous(node_type ntype) const noexcept final
TOML_CONST_INLINE_GETTER table * as_table() noexcept final
Returns a pointer to the table.
TOML_EXPORTED_MEMBER_FUNCTION table & operator=(const table &)
Copy-assignment operator.
TOML_CONST_INLINE_GETTER toml::value< time > * as_time() noexcept final
Returns nullptr.
TOML_PURE_INLINE_GETTER const_iterator end() const noexcept
Returns an iterator to one-past-the-last key-value pair.
TOML_CONST_INLINE_GETTER const toml::value< date_time > * as_date_time() const noexcept final
Returns nullptr.
TOML_PURE_INLINE_GETTER iterator begin() noexcept
Returns an iterator to the first key-value pair.
TOML_NODISCARD node_view< const node > operator[](std::string_view key) const noexcept
Gets a node_view for the selected value (const overload).
TOML_CONST_INLINE_GETTER bool is_table() const noexcept final
Returns true.
TOML_CONST_INLINE_GETTER bool is_value() const noexcept final
Returns false.
TOML_NODISCARD friend bool operator==(const table &lhs, const table &rhs) noexcept
Equality operator.
TOML_CONST_INLINE_GETTER const table * as_table() const noexcept final
Returns a const-qualified pointer to the table.
friend std::ostream & operator<<(std::ostream &lhs, const table &rhs)
Prints the table out to a stream as formatted TOML.
TOML_CONST_INLINE_GETTER bool is_boolean() const noexcept final
Returns false.
TOML_CONSTRAINED_TEMPLATE((is_key_or_convertible< KeyType && >||impl::is_wide_string< KeyType >), typename KeyType, typename ValueType) std
Inserts a new value at a specific key if one did not already exist.
TOML_PURE_GETTER TOML_EXPORTED_MEMBER_FUNCTION const_iterator find(std::string_view key) const noexcept
Gets an iterator to the node at a specific key (const overload)
TOML_PURE_GETTER TOML_EXPORTED_MEMBER_FUNCTION iterator find(std::string_view key) noexcept
Gets an iterator to the node at a specific key.
TOML_NODISCARD iterator find(std::wstring_view key)
Gets an iterator to the node at a specific key.
TOML_CONST_INLINE_GETTER toml::value< int64_t > * as_integer() noexcept final
Returns nullptr.
TOML_NODISCARD const_iterator lower_bound(std::wstring_view key) const
Returns a const iterator to the first key-value pair with key that is not less than the given key.
const table & for_each(Func &&visitor) const &noexcept(for_each_is_nothrow< Func &&, const table & >::value)
Invokes a visitor on each key-value pair in the table (const lvalue overload).
table && prune(bool recursive=true) &&noexcept
Removes empty child arrays and tables (rvalue overload).
TOML_CONST_INLINE_GETTER bool is_floating_point() const noexcept final
Returns false.
TOML_PURE_INLINE_GETTER const_iterator cbegin() const noexcept
Returns an iterator to the first key-value pair.
TOML_CONST_INLINE_GETTER bool is_date() const noexcept final
Returns false.
TOML_PURE_INLINE_GETTER iterator end() noexcept
Returns an iterator to one-past-the-last key-value pair.
impl::remove_cvref< impl::unwrap_node< value_type > > unwrapped_type
TOML_CONST_INLINE_GETTER toml::value< date > * as_date() noexcept final
Returns nullptr.
TOML_PURE_INLINE_GETTER bool is_inline() const noexcept
Returns true if this table is an inline table.
TOML_CONST_INLINE_GETTER const array * as_array() const noexcept final
Returns nullptr.
TOML_PURE_GETTER const impl::wrap_node< T > * get_as(std::string_view key) const noexcept
Gets the node at a specific key if it is a particular type (const overload).
TOML_NODISCARD friend bool operator!=(const table &lhs, const table &rhs) noexcept
Inequality operator.
TOML_CONST_INLINE_GETTER const toml::value< date > * as_date() const noexcept final
Returns nullptr.
TOML_NODISCARD const_iterator find(std::wstring_view key) const
Gets an iterator to the node at a specific key (const overload).
TOML_CONST_INLINE_GETTER toml::value< double > * as_floating_point() noexcept final
Returns nullptr.
TOML_PURE_GETTER iterator lower_bound(std::string_view key) noexcept
Returns an iterator to the first key-value pair with key that is not less than the given key.
TOML_CONST_INLINE_GETTER toml::value< date_time > * as_date_time() noexcept final
Returns nullptr.
TOML_NODISCARD iterator lower_bound(std::wstring_view key)
Returns an iterator to the first key-value pair with key that is not less than the given key.
TOML_PURE_GETTER TOML_EXPORTED_MEMBER_FUNCTION bool is_homogeneous(node_type ntype, const node *&first_nonmatch) const noexcept final
TOML_PURE_GETTER bool is_array_of_tables() const noexcept final
Returns false.
TOML_CONST_INLINE_GETTER bool is_integer() const noexcept final
Returns false.
TOML_CONST_INLINE_GETTER const toml::value< bool > * as_boolean() const noexcept final
Returns nullptr.
void is_inline(bool val) noexcept
Sets whether this table is a TOML inline table.
TOML_PURE_INLINE_GETTER const_iterator cend() const noexcept
Returns an iterator to one-past-the-last key-value pair.
TOML_NODISCARD const node * get(std::wstring_view key) const
Gets the node at a specific key (const overload).
TOML_CONST_INLINE_GETTER bool is_time() const noexcept final
Returns false.
TOML_CONST_INLINE_GETTER toml::value< std::string > * as_string() noexcept final
Returns nullptr.
std::conditional_t< std::is_void_v< raw_value_type >, impl::emplaced_type_of< ValueArgs &&... >, raw_value_type > value_type
TOML_NODISCARD node & at(std::wstring_view key)
Gets a reference to the element at a specific key, throwing std::out_of_range if none existed.
iterator erase(iterator pos) noexcept
Removes the specified key-value pair from the table.
TOML_PURE_INLINE_GETTER size_t size() const noexcept
Returns the number of key-value pairs in the table.
enum TOML_OPEN_FLAGS_ENUM value_flags
Metadata associated with TOML values.
constexpr value_flags preserve_source_value_flags
Special #toml::value_flags constant used for array + table insert functions to specify that any value...
#define TOML_CALLCONV
Calling convention to apply to exported free/static functions. \detail Not defined by default (let th...
#define TOML_EXPORTED_CLASS
An 'export' annotation to add to classes. \detail Not defined by default.
#define TOML_EXPORTED_STATIC_FUNCTION
An 'export' annotation to add to static class member functions. \detail Not defined by default.
#define TOML_ENABLE_WINDOWS_COMPAT
Enables the use of wide strings (wchar_t, std::wstring) in various places throughout the library when...
#define TOML_EXPORTED_MEMBER_FUNCTION
An 'export' annotation to add to non-static class member functions. \detail Not defined by default.
bool operator==(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
bool operator!=(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
constexpr bool is_key_or_convertible
Metafunction for determining if a type is, or is a reference to, a toml::key, or is implicitly or exp...
#define TOML_NODISCARD_CTOR
#define POXY_IMPLEMENTATION_DETAIL(...)
#define TOML_CONSTRAINED_TEMPLATE(condition,...)
#define TOML_PURE_INLINE_GETTER
#define TOML_IMPL_NAMESPACE_END
#define TOML_IMPL_NAMESPACE_START
#define TOML_CONST_INLINE_GETTER
POXY_IMPLEMENTATION_DETAIL(impl::table_iterator< true >) const_table_iterator
A BidirectionalIterator for iterating over const key-value pairs in a toml::table.