19 template <
bool IsConst>
20 struct table_proxy_pair
22 using value_type = std::conditional_t<IsConst, const node, node>;
24 const toml::key& first;
28 template <
bool IsConst>
33 friend class table_iterator;
35 using proxy_type = table_proxy_pair<IsConst>;
36 using mutable_map_iterator = std::map<toml::key, node_ptr, std::less<>>::iterator;
37 using const_map_iterator = std::map<toml::key, node_ptr, std::less<>>::const_iterator;
38 using map_iterator = std::conditional_t<IsConst, const_map_iterator, mutable_map_iterator>;
40 mutable map_iterator iter_;
41 alignas(proxy_type)
mutable unsigned char proxy_[
sizeof(proxy_type)];
42 mutable bool proxy_instantiated_ =
false;
45 proxy_type* get_proxy() const noexcept
47 if (!proxy_instantiated_)
49 auto p = ::new (
static_cast<void*
>(proxy_)) proxy_type{ iter_->first, *iter_->second.get() };
50 proxy_instantiated_ =
true;
54 return TOML_LAUNDER(
reinterpret_cast<proxy_type*
>(proxy_));
59 table_iterator() noexcept = default;
62 explicit table_iterator(mutable_map_iterator iter) noexcept
68 explicit table_iterator(const_map_iterator iter)
noexcept
74 table_iterator(
const table_iterator<false>& other)
noexcept
75 : iter_{ other.iter_ }
79 table_iterator(
const table_iterator& other)
noexcept
80 : iter_{ other.iter_ }
83 table_iterator& operator=(
const table_iterator& rhs)
noexcept
86 proxy_instantiated_ =
false;
90 using value_type = table_proxy_pair<IsConst>;
91 using reference = value_type&;
92 using pointer = value_type*;
93 using difference_type =
typename std::iterator_traits<map_iterator>::difference_type;
94 using iterator_category =
typename std::iterator_traits<map_iterator>::iterator_category;
96 table_iterator& operator++() noexcept
99 proxy_instantiated_ =
false;
103 table_iterator operator++(
int)
noexcept
105 table_iterator out{ iter_ };
107 proxy_instantiated_ =
false;
111 table_iterator& operator--() noexcept
114 proxy_instantiated_ =
false;
118 table_iterator operator--(
int)
noexcept
120 table_iterator out{ iter_ };
122 proxy_instantiated_ =
false;
127 reference operator*() const noexcept
133 pointer operator->() const noexcept
139 explicit operator const map_iterator&()
const noexcept
146 explicit operator const const_map_iterator() const noexcept
152 friend bool operator==(
const table_iterator& lhs,
const table_iterator& rhs)
noexcept
154 return lhs.iter_ == rhs.iter_;
158 friend bool operator!=(
const table_iterator& lhs,
const table_iterator& rhs)
noexcept
160 return lhs.iter_ != rhs.iter_;
164 struct table_init_pair
166 mutable toml::key
key;
167 mutable node_ptr
value;
169 template <
typename K,
typename V>
172 :
key{ static_cast<K&&>(k) },
173 value{ make_node(static_cast<V&&>(v), flags) }
224 using map_type = std::map<toml::key, impl::node_ptr, std::less<>>;
225 using map_pair = std::pair<const toml::key, impl::node_ptr>;
226 using map_iterator =
typename map_type::iterator;
227 using const_map_iterator =
typename map_type::const_iterator;
230 bool inline_ =
false;
234 table(
const impl::table_init_pair*,
const impl::table_init_pair*);
275 explicit
table(
std::initializer_list<impl::table_init_pair> kvps)
276 :
table(kvps.begin(), kvps.end())
292 node_type
type() const noexcept final
294 return node_type::table;
307 bool is_homogeneous(node_type ntype,
const node*& first_nonmatch)
const noexcept final;
310 template <
typename ElemType =
void>
312 bool is_homogeneous() const noexcept
314 using type = impl::remove_cvref<impl::unwrap_node<ElemType>>;
315 static_assert(std::is_void_v<type> || toml::is_value<type> || toml::is_container<type>,
316 "The template type argument of table::is_homogeneous() must be void or one "
317 "of:" TOML_SA_UNWRAPPED_NODE_TYPE_LIST);
319 return is_homogeneous(impl::node_type_of<type>);
491 const toml::value<std::string>*
as_string() const noexcept final
498 const toml::value<int64_t>*
as_integer() const noexcept final
519 const toml::value<date>*
as_date() const noexcept final
526 const toml::value<time>*
as_time() const noexcept final
627 node*
get(std::string_view key)
noexcept;
635 const node*
get(std::string_view key)
const noexcept
637 return const_cast<table&
>(*this).
get(key);
640#if TOML_ENABLE_WINDOWS_COMPAT
650 node*
get(std::wstring_view key)
655 return get(impl::narrow(key));
666 const node*
get(std::wstring_view key)
const
668 return const_cast<table&
>(*this).
get(key);
692 template <
typename T>
694 impl::wrap_node<T>*
get_as(std::string_view key)
noexcept
696 const auto n = this->get(key);
697 return n ? n->template as<T>() :
nullptr;
706 template <
typename T>
708 const impl::wrap_node<T>*
get_as(std::string_view key)
const noexcept
710 return const_cast<table&
>(*this).template get_as<T>(key);
713#if TOML_ENABLE_WINDOWS_COMPAT
723 template <
typename T>
725 impl::wrap_node<T>*
get_as(std::wstring_view key)
730 return get_as<T>(impl::narrow(key));
741 template <
typename T>
743 const impl::wrap_node<T>*
get_as(std::wstring_view key)
const
745 return const_cast<table&
>(*this).template get_as<T>(key);
753 node&
at(std::string_view key);
757 const node&
at(std::string_view key)
const
759 return const_cast<table&
>(*this).
at(key);
762#if TOML_ENABLE_WINDOWS_COMPAT
768 node&
at(std::wstring_view key)
770 return at(impl::narrow(key));
777 const node&
at(std::wstring_view key)
const
779 return const_cast<table&
>(*this).
at(key);
840 template <
typename T,
typename Table>
841 using for_each_value_ref = impl::copy_cvref<impl::wrap_node<impl::remove_cvref<impl::unwrap_node<T>>>, Table>;
843 template <
typename Func,
typename Table,
typename T>
844 using can_for_each = std::disjunction<std::is_invocable<Func, const key&, for_each_value_ref<T, Table>>,
845 std::is_invocable<Func, for_each_value_ref<T, Table>>>;
847 template <
typename Func,
typename Table,
typename T>
848 using can_for_each_nothrow = std::conditional_t<
850 std::is_invocable_v<Func, const key&, for_each_value_ref<T, Table>>,
851 std::is_nothrow_invocable<Func, const key&, for_each_value_ref<T, Table>>,
854 std::is_invocable_v<Func, for_each_value_ref<T, Table>>,
855 std::is_nothrow_invocable<Func, for_each_value_ref<T, Table>>,
858 template <
typename Func,
typename Table>
859 using can_for_each_any = std::disjunction<can_for_each<Func, Table, table>,
860 can_for_each<Func, Table, array>,
861 can_for_each<Func, Table, std::string>,
862 can_for_each<Func, Table, int64_t>,
863 can_for_each<Func, Table, double>,
864 can_for_each<Func, Table, bool>,
865 can_for_each<Func, Table, date>,
866 can_for_each<Func, Table, time>,
867 can_for_each<Func, Table, date_time>>;
869 template <
typename Func,
typename Table,
typename T>
870 using for_each_is_nothrow_one = std::disjunction<std::negation<can_for_each<Func, Table, T>>,
871 can_for_each_nothrow<Func, Table, T>>;
873 template <
typename Func,
typename Table>
874 using for_each_is_nothrow = std::conjunction<for_each_is_nothrow_one<Func, Table, table>,
875 for_each_is_nothrow_one<Func, Table, array>,
876 for_each_is_nothrow_one<Func, Table, std::string>,
877 for_each_is_nothrow_one<Func, Table, int64_t>,
878 for_each_is_nothrow_one<Func, Table, double>,
879 for_each_is_nothrow_one<Func, Table, bool>,
880 for_each_is_nothrow_one<Func, Table, date>,
881 for_each_is_nothrow_one<Func, Table, time>,
882 for_each_is_nothrow_one<Func, Table, date_time>>;
884 template <
typename Func,
typename Table>
885 static void do_for_each(Func&& visitor, Table&& tbl)
886 noexcept(for_each_is_nothrow<Func&&, Table&&>::value)
888 static_assert(can_for_each_any<Func&&, Table&&>::value,
889 "TOML table for_each visitors must be invocable for at least one of the toml::node "
890 "specializations:" TOML_SA_NODE_TYPE_LIST);
892 using kvp_type = impl::copy_cv<map_pair, std::remove_reference_t<Table>>;
894 for (kvp_type& kvp : tbl.map_)
896 using node_ref = impl::copy_cvref<toml::node, Table&&>;
897 static_assert(std::is_reference_v<node_ref>);
899#if TOML_RETURN_BOOL_FROM_FOR_EACH_BROKEN
901#ifndef TOML_RETURN_BOOL_FROM_FOR_EACH_BROKEN_ACKNOWLEDGED
902 static_assert(impl::always_false<Func, Table, kvp_type, node_ref>,
903 TOML_RETURN_BOOL_FROM_FOR_EACH_BROKEN_MESSAGE);
906 static_cast<node_ref
>(*kvp.second)
908 [&]([[maybe_unused]]
auto&& v)
909 noexcept(for_each_is_nothrow_one<Func&&, Table&&,
decltype(v)>::value)
911 using value_ref = for_each_value_ref<
decltype(v), Table&&>;
912 static_assert(std::is_reference_v<value_ref>);
915 if constexpr (std::is_invocable_v<Func&&, const key&, value_ref>)
917 static_cast<Func&&
>(visitor)(
static_cast<const key&
>(kvp.first),
918 static_cast<value_ref
>(v));
922 else if constexpr (std::is_invocable_v<Func&&, value_ref>)
924 static_cast<Func&&
>(visitor)(
static_cast<value_ref
>(v));
929 const auto keep_going =
930 static_cast<node_ref
>(*kvp.second)
932 [&]([[maybe_unused]]
auto&& v)
933 noexcept(for_each_is_nothrow_one<Func&&, Table&&,
decltype(v)>::value)
935 using value_ref = for_each_value_ref<
decltype(v), Table&&>;
936 static_assert(std::is_reference_v<value_ref>);
939 if constexpr (std::is_invocable_v<Func&&, const key&, value_ref>)
941 using return_type =
decltype(
static_cast<Func&&
>(
942 visitor)(
static_cast<const key&
>(kvp.first),
static_cast<value_ref
>(v)));
944 if constexpr (impl::is_constructible_or_convertible<bool, return_type>)
946 return static_cast<bool>(
static_cast<Func&&
>(
947 visitor)(
static_cast<const key&
>(kvp.first),
static_cast<value_ref
>(v)));
951 static_cast<Func&&
>(visitor)(
static_cast<const key&
>(kvp.first),
952 static_cast<value_ref
>(v));
958 else if constexpr (std::is_invocable_v<Func&&, value_ref>)
961 decltype(
static_cast<Func&&
>(visitor)(
static_cast<value_ref
>(v)));
963 if constexpr (impl::is_constructible_or_convertible<bool, return_type>)
965 return static_cast<bool>(
966 static_cast<Func&&
>(visitor)(
static_cast<value_ref
>(v)));
970 static_cast<Func&&
>(visitor)(
static_cast<value_ref
>(v));
1070 template <
typename Func>
1072 noexcept(for_each_is_nothrow<Func&&, table&>::value)
1074 do_for_each(
static_cast<Func&&
>(visitor), *
this);
1079 template <
typename Func>
1081 noexcept(for_each_is_nothrow<Func&&, table&&>::value)
1083 do_for_each(
static_cast<Func&&
>(visitor),
static_cast<table&&
>(*
this));
1084 return static_cast<table&&
>(*this);
1088 template <
typename Func>
1090 noexcept(for_each_is_nothrow<Func&&, const table&>::value)
1092 do_for_each(
static_cast<Func&&
>(visitor), *
this);
1097 template <
typename Func>
1099 noexcept(for_each_is_nothrow<Func&&, const table&&>::value)
1101 do_for_each(
static_cast<Func&&
>(visitor),
static_cast<const table&&
>(*
this));
1102 return static_cast<const table&&
>(*this);
1114 return map_.empty();
1134 map_iterator get_lower_bound(std::string_view)
noexcept;
1145 return iterator{ get_lower_bound(key) };
1157#if TOML_ENABLE_WINDOWS_COMPAT
1170 return lower_bound(impl::narrow(key));
1184 return lower_bound(impl::narrow(key));
1211 return get(key) !=
nullptr;
1214#if TOML_ENABLE_WINDOWS_COMPAT
1229 return find(impl::narrow(key));
1242 return find(impl::narrow(key));
1251 return contains(impl::narrow(key));
1265 map_iterator erase(const_map_iterator)
noexcept;
1268 map_iterator erase(const_map_iterator, const_map_iterator)
noexcept;
1297 return iterator{ erase(const_map_iterator{ pos }) };
1324 return iterator{ erase(const_map_iterator{ pos }) };
1353 return iterator{ erase(const_map_iterator{ begin }, const_map_iterator{ end }) };
1382 size_t erase(std::string_view key)
noexcept;
1384#if TOML_ENABLE_WINDOWS_COMPAT
1398 return erase(impl::narrow(key));
1432 return static_cast<toml::table&&
>(this->prune(recursive));
1448 map_iterator insert_with_hint(
const_iterator, key&&, impl::node_ptr&&);
1466 typename ValueType =
void,
1468 typename... ValueArgs)
1472 "Emplacement using wide-character keys is only supported on Windows with "
1473 "TOML_ENABLE_WINDOWS_COMPAT enabled.");
1477 conditional_t<std::is_void_v<raw_value_type>, impl::emplaced_type_of<ValueArgs&&...>,
raw_value_type>;
1479 if constexpr (impl::is_wide_string<KeyType>)
1481#if TOML_ENABLE_WINDOWS_COMPAT
1482 return emplace_hint<value_type>(hint,
1483 impl::narrow(
static_cast<KeyType&&
>(key)),
1484 static_cast<ValueArgs&&
>(args)...);
1486 static_assert(impl::always_false<KeyType>,
"Evaluated unreachable branch!");
1491 static constexpr auto moving_node_ptr = std::is_same_v<value_type, impl::node_ptr>
1492 &&
sizeof...(ValueArgs) == 1u
1493 && impl::first_is_same<impl::node_ptr&&, ValueArgs&&...>;
1496 static_assert(moving_node_ptr
1497 || impl::is_native<unwrapped_type>
1498 || impl::is_one_of<unwrapped_type, table, array>,
1499 "ValueType argument of table::emplace_hint() must be one "
1500 "of:" TOML_SA_UNWRAPPED_NODE_TYPE_LIST);
1502 map_iterator ipos = insert_with_hint(hint, toml::key{
static_cast<KeyType&&
>(key) },
nullptr);
1508 if constexpr (moving_node_ptr)
1509 ipos->second = std::move(
static_cast<ValueArgs&&
>(args)...);
1512#if TOML_COMPILER_HAS_EXCEPTIONS
1517 new impl::wrap_node<unwrapped_type>{
static_cast<ValueArgs&&
>(args)... });
1518#if TOML_COMPILER_HAS_EXCEPTIONS
1522 erase(const_map_iterator{ ipos });
1586 std::pair<iterator, bool> insert(KeyType&& key,
1591 "Insertion using wide-character keys is only supported on Windows with "
1592 "TOML_ENABLE_WINDOWS_COMPAT enabled.");
1594 if constexpr (is_node_view<ValueType>)
1597 return { end(),
false };
1600 if constexpr (impl::is_wide_string<KeyType>)
1602#if TOML_ENABLE_WINDOWS_COMPAT
1603 return insert(impl::narrow(
static_cast<KeyType&&
>(key)),
static_cast<ValueType&&
>(val), flags);
1605 static_assert(impl::always_false<KeyType>,
"Evaluated unreachable branch!");
1610 const auto key_view = std::string_view{ key };
1611 map_iterator ipos = get_lower_bound(key_view);
1612 if (ipos == map_.end() || ipos->first != key_view)
1615 toml::key{
static_cast<KeyType&&
>(key) },
1616 impl::make_node(
static_cast<ValueType&&
>(val), flags));
1619 return {
iterator{ ipos },
false };
1667 for (
auto it = begin; it != end; it++)
1669 if constexpr (std::is_rvalue_reference_v<
decltype(*it)>)
1670 insert(std::move((*it).first), std::move((*it).second), flags);
1672 insert((*it).first, (*it).second, flags);
1731 std::pair<iterator, bool> insert_or_assign(KeyType&& key,
1736 "Insertion using wide-character keys is only supported on Windows with "
1737 "TOML_ENABLE_WINDOWS_COMPAT enabled.");
1739 if constexpr (is_node_view<ValueType>)
1742 return { end(),
false };
1745 if constexpr (impl::is_wide_string<KeyType>)
1747#if TOML_ENABLE_WINDOWS_COMPAT
1748 return insert_or_assign(impl::narrow(
static_cast<KeyType&&
>(key)),
1749 static_cast<ValueType&&
>(val),
1752 static_assert(impl::always_false<KeyType>,
"Evaluated unreachable branch!");
1757 const auto key_view = std::string_view{ key };
1758 map_iterator ipos = get_lower_bound(key_view);
1759 if (ipos == map_.end() || ipos->first != key_view)
1762 toml::key{
static_cast<KeyType&&
>(key) },
1763 impl::make_node(
static_cast<ValueType&&
>(val), flags));
1768 (*ipos).second = impl::make_node(
static_cast<ValueType&&
>(val), flags);
1769 return {
iterator{ ipos },
false };
1812 typename ValueType =
void,
1814 typename... ValueArgs)
1815 std::pair<iterator, bool> emplace(KeyType&& key, ValueArgs&&... args)
1818 "Emplacement using wide-character keys is only supported on Windows with "
1819 "TOML_ENABLE_WINDOWS_COMPAT enabled.");
1823 conditional_t<std::is_void_v<raw_value_type>, impl::emplaced_type_of<ValueArgs&&...>,
raw_value_type>;
1825 if constexpr (impl::is_wide_string<KeyType>)
1827#if TOML_ENABLE_WINDOWS_COMPAT
1828 return emplace<value_type>(impl::narrow(
static_cast<KeyType&&
>(key)),
1829 static_cast<ValueArgs&&
>(args)...);
1831 static_assert(impl::always_false<KeyType>,
"Evaluated unreachable branch!");
1836 using unwrapped_type = impl::remove_cvref<impl::unwrap_node<value_type>>;
1837 static_assert((impl::is_native<unwrapped_type> || impl::is_one_of<unwrapped_type, table, array>),
1838 "ValueType argument of table::emplace() must be one "
1839 "of:" TOML_SA_UNWRAPPED_NODE_TYPE_LIST);
1841 const auto key_view = std::string_view{ key };
1842 auto ipos = get_lower_bound(key_view);
1843 if (ipos == map_.end() || ipos->first != key_view)
1845 ipos = insert_with_hint(
1847 toml::key{
static_cast<KeyType&&
>(key) },
1848 impl::node_ptr{
new impl::wrap_node<unwrapped_type>{
static_cast<ValueArgs&&
>(args)... } });
1851 return {
iterator{ ipos },
false };
1861 using node::operator[];
1878 return node_view<node>{ get(key) };
1893 node_view<const node>
operator[](std::string_view key)
const noexcept
1895 return node_view<const node>{ get(key) };
1898#if TOML_ENABLE_WINDOWS_COMPAT
1916 return node_view<node>{ get(key) };
1935 return node_view<const node>{ get(key) };
1963 return equal(lhs, rhs);
1975 return !equal(lhs, rhs);
1980#if TOML_ENABLE_FORMATTERS
1987 impl::print_to_stream(lhs, rhs);
A TOML array.
Definition array.hpp:285
A TOML table.
Definition table.hpp:220
TOML_PURE_INLINE_GETTER const_iterator begin() const noexcept
Returns an iterator to the first key-value pair.
Definition table.hpp:804
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).
Definition table.hpp:743
TOML_CONST_INLINE_GETTER bool is_date_time() const noexcept final
Returns false.
Definition table.hpp:402
TOML_NODISCARD node * get(std::wstring_view key)
Gets the node at a specific key.
Definition table.hpp:650
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.
Definition table.hpp:757
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.
Definition table.hpp:353
TOML_PURE_INLINE_GETTER const node * get(std::string_view key) const noexcept
Gets the node at a specific key (const overload).
Definition table.hpp:635
TOML_CONST_INLINE_GETTER const toml::value< std::string > * as_string() const noexcept final
Returns nullptr.
Definition table.hpp:491
TOML_NODISCARD bool contains(std::wstring_view key) const
Returns true if the table contains a node at the given key.
Definition table.hpp:1249
TOML_CONST_INLINE_GETTER bool is_number() const noexcept final
Returns false.
Definition table.hpp:374
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.
Definition table.hpp:725
iterator erase(const_iterator pos) noexcept
Removes the specified key-value pair from the table (const iterator overload).
Definition table.hpp:1322
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).
Definition table.hpp:1080
TOML_CONST_INLINE_GETTER const toml::value< double > * as_floating_point() const noexcept final
Returns nullptr.
Definition table.hpp:505
TOML_CONST_INLINE_GETTER toml::value< bool > * as_boolean() noexcept final
Returns nullptr.
Definition table.hpp:449
size_t erase(std::wstring_view key)
Removes the value with the given key from the table.
Definition table.hpp:1393
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.
Definition table.hpp:498
table & for_each(Func &&visitor) &noexcept(for_each_is_nothrow< Func &&, table & >::value)
Invokes a visitor on each key-value pair in the table.
Definition table.hpp:1071
TOML_PURE_INLINE_GETTER bool empty() const noexcept
Returns true if the table is empty.
Definition table.hpp:1112
TOML_CONST_INLINE_GETTER const toml::value< time > * as_time() const noexcept final
Returns nullptr.
Definition table.hpp:526
TOML_NODISCARD node_view< node > operator[](std::wstring_view key)
Gets a node_view for the selected value.
Definition table.hpp:1914
TOML_PURE_GETTER bool contains(std::string_view key) const noexcept
Returns true if the table contains a node at the given key.
Definition table.hpp:1209
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).
Definition table.hpp:1098
TOML_CONST_INLINE_GETTER bool is_array() const noexcept final
Returns false.
Definition table.hpp:332
TOML_CONST_INLINE_GETTER node_type type() const noexcept final
Returns #toml::node_type::table.
Definition table.hpp:292
TOML_CONST_INLINE_GETTER array * as_array() noexcept final
Returns nullptr.
Definition table.hpp:421
iterator erase(const_iterator begin, const_iterator end) noexcept
Removes the key-value pairs in the range [first, last) from the table.
Definition table.hpp:1351
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.
Definition table.hpp:777
toml::const_table_iterator const_iterator
A BidirectionalIterator for iterating over const key-value pairs in a toml::table.
Definition table.hpp:793
TOML_NODISCARD node_view< const node > operator[](std::wstring_view key) const
Gets a node_view for the selected value (const overload).
Definition table.hpp:1933
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.
Definition table.hpp:694
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.
Definition table.hpp:790
TOML_NODISCARD node_view< node > operator[](std::string_view key) noexcept
Gets a node_view for the selected value.
Definition table.hpp:1876
impl::remove_cvref< ValueType > raw_value_type
Definition table.hpp:1475
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.
Definition table.hpp:1811
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.
Definition table.hpp:1152
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.
Definition table.hpp:414
TOML_EXPORTED_MEMBER_FUNCTION table & operator=(const table &)
Copy-assignment operator.
TOML_CONST_INLINE_GETTER toml::value< time > * as_time() noexcept final
Returns nullptr.
Definition table.hpp:463
TOML_PURE_INLINE_GETTER const_iterator end() const noexcept
Returns an iterator to one-past-the-last key-value pair.
Definition table.hpp:825
TOML_CONST_INLINE_GETTER const toml::value< date_time > * as_date_time() const noexcept final
Returns nullptr.
Definition table.hpp:533
TOML_PURE_INLINE_GETTER iterator begin() noexcept
Returns an iterator to the first key-value pair.
Definition table.hpp:797
TOML_NODISCARD node_view< const node > operator[](std::string_view key) const noexcept
Gets a node_view for the selected value (const overload).
Definition table.hpp:1893
TOML_CONST_INLINE_GETTER bool is_table() const noexcept final
Returns true.
Definition table.hpp:325
TOML_CONST_INLINE_GETTER bool is_value() const noexcept final
Returns false.
Definition table.hpp:346
TOML_NODISCARD friend bool operator==(const table &lhs, const table &rhs) noexcept
Equality operator.
Definition table.hpp:1961
TOML_CONST_INLINE_GETTER const table * as_table() const noexcept final
Returns a const-qualified pointer to the table.
Definition table.hpp:477
friend std::ostream & operator<<(std::ostream &lhs, const table &rhs)
Prints the table out to a stream as formatted TOML.
Definition table.hpp:1985
TOML_CONST_INLINE_GETTER bool is_boolean() const noexcept final
Returns false.
Definition table.hpp:381
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.
Definition table.hpp:1583
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.
Definition table.hpp:1224
TOML_CONST_INLINE_GETTER toml::value< int64_t > * as_integer() noexcept final
Returns nullptr.
Definition table.hpp:435
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.
Definition table.hpp:1179
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).
Definition table.hpp:1089
table && prune(bool recursive=true) &&noexcept
Removes empty child arrays and tables (rvalue overload).
Definition table.hpp:1430
TOML_CONST_INLINE_GETTER bool is_floating_point() const noexcept final
Returns false.
Definition table.hpp:367
TOML_PURE_INLINE_GETTER const_iterator cbegin() const noexcept
Returns an iterator to the first key-value pair.
Definition table.hpp:811
TOML_CONST_INLINE_GETTER bool is_date() const noexcept final
Returns false.
Definition table.hpp:388
TOML_PURE_INLINE_GETTER iterator end() noexcept
Returns an iterator to one-past-the-last key-value pair.
Definition table.hpp:818
impl::remove_cvref< impl::unwrap_node< value_type > > unwrapped_type
Definition table.hpp:1494
TOML_CONST_INLINE_GETTER toml::value< date > * as_date() noexcept final
Returns nullptr.
Definition table.hpp:456
TOML_PURE_INLINE_GETTER bool is_inline() const noexcept
Returns true if this table is an inline table.
Definition table.hpp:548
TOML_CONST_INLINE_GETTER const array * as_array() const noexcept final
Returns nullptr.
Definition table.hpp:484
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).
Definition table.hpp:708
TOML_NODISCARD friend bool operator!=(const table &lhs, const table &rhs) noexcept
Inequality operator.
Definition table.hpp:1973
TOML_CONST_INLINE_GETTER const toml::value< date > * as_date() const noexcept final
Returns nullptr.
Definition table.hpp:519
TOML_NODISCARD const_iterator find(std::wstring_view key) const
Gets an iterator to the node at a specific key (const overload).
Definition table.hpp:1240
TOML_CONST_INLINE_GETTER toml::value< double > * as_floating_point() noexcept final
Returns nullptr.
Definition table.hpp:442
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.
Definition table.hpp:1143
TOML_CONST_INLINE_GETTER toml::value< date_time > * as_date_time() noexcept final
Returns nullptr.
Definition table.hpp:470
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.
Definition table.hpp:1165
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.
Definition table.hpp:339
TOML_CONST_INLINE_GETTER bool is_integer() const noexcept final
Returns false.
Definition table.hpp:360
TOML_CONST_INLINE_GETTER const toml::value< bool > * as_boolean() const noexcept final
Returns nullptr.
Definition table.hpp:512
void is_inline(bool val) noexcept
Sets whether this table is a TOML inline table.
Definition table.hpp:591
TOML_PURE_INLINE_GETTER const_iterator cend() const noexcept
Returns an iterator to one-past-the-last key-value pair.
Definition table.hpp:832
TOML_NODISCARD const node * get(std::wstring_view key) const
Gets the node at a specific key (const overload).
Definition table.hpp:666
TOML_CONST_INLINE_GETTER bool is_time() const noexcept final
Returns false.
Definition table.hpp:395
TOML_CONST_INLINE_GETTER toml::value< std::string > * as_string() noexcept final
Returns nullptr.
Definition table.hpp:428
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.
Definition table.hpp:768
std::conditional_t< std::is_void_v< raw_value_type >, impl::emplaced_type_of< ValueArgs &&... >, raw_value_type > value_type
Definition table.hpp:1477
iterator erase(iterator pos) noexcept
Removes the specified key-value pair from the table.
Definition table.hpp:1295
TOML_PURE_INLINE_GETTER size_t size() const noexcept
Returns the number of key-value pairs in the table.
Definition table.hpp:1119
enum TOML_OPEN_FLAGS_ENUM value_flags
Metadata associated with TOML values.
Definition forward_declarations.hpp:272
constexpr value_flags preserve_source_value_flags
Special #toml::value_flags constant used for array + table insert functions to specify that any value...
Definition forward_declarations.hpp:290
#define TOML_CALLCONV
Calling convention to apply to exported free/static functions. \detail Not defined by default (let th...
Definition preprocessor.hpp:1134
#define TOML_EXPORTED_CLASS
An 'export' annotation to add to classes. \detail Not defined by default.
Definition preprocessor.hpp:979
#define TOML_EXPORTED_STATIC_FUNCTION
An 'export' annotation to add to static class member functions. \detail Not defined by default.
Definition preprocessor.hpp:985
#define TOML_ENABLE_WINDOWS_COMPAT
Enables the use of wide strings (wchar_t, std::wstring) in various places throughout the library when...
Definition preprocessor.hpp:1074
#define TOML_EXPORTED_MEMBER_FUNCTION
An 'export' annotation to add to non-static class member functions. \detail Not defined by default.
Definition preprocessor.hpp:982
bool operator==(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
Definition json.h:14737
bool operator!=(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
Definition json.h:14762
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...
Definition key.hpp:330
@ value
the parser finished reading a JSON value
@ key
the parser read a key of a value in an object
#define TOML_NODISCARD_CTOR
Definition preprocessor.hpp:446
#define POXY_IMPLEMENTATION_DETAIL(...)
Definition preprocessor.hpp:633
#define TOML_CONSTRAINED_TEMPLATE(condition,...)
Definition preprocessor.hpp:1260
#define TOML_NODISCARD
Definition preprocessor.hpp:439
#define TOML_PURE_GETTER
Definition preprocessor.hpp:474
#define TOML_PURE_INLINE_GETTER
Definition preprocessor.hpp:479
#define TOML_IMPL_NAMESPACE_END
Definition preprocessor.hpp:1334
#define TOML_IMPL_NAMESPACE_START
Definition preprocessor.hpp:1333
#define TOML_CONST_INLINE_GETTER
Definition preprocessor.hpp:490
#define TOML_LAUNDER(x)
Definition std_new.hpp:17
TOML_NAMESPACE_START
Definition table.hpp:181
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
TOML_NAMESPACE_END
Definition table.hpp:1994