added node::operator[] for toml::path

also:
- added missing relational operators for `source_position`
- TOML_CHARCONV cleanup (was too keen)
- minor refactors
This commit is contained in:
Mark Gillard 2022-06-06 23:46:04 +03:00
parent 5baa568a6b
commit 0058d68bbc
35 changed files with 868 additions and 655 deletions

View File

@ -2,8 +2,8 @@ name: ci
on:
push:
branches:
- master
branches-ignore:
- 'gh-pages'
paths:
- '**.h'
- '**.hpp'
@ -13,8 +13,8 @@ on:
- '**/meson.build'
- '**/workflows/**.yaml'
pull_request:
branches:
- master
branches-ignore:
- 'gh-pages'
paths:
- '**.h'
- '**.hpp'

View File

@ -16,40 +16,42 @@ template:
## Unreleased
#### Fixes:
- Fixed `[dotted.table]` source columns sometimes being off by one (#152) (@vaartis)
- fixed `[dotted.table]` source columns sometimes being off by one (#152) (@vaartis)
#### Additions:
- Added value type deduction to `emplace()` methods
- Added `toml::path` utility type (#153, #156) (@jonestristand)
- Added config option `TOML_CALLCONV`
- added value type deduction to `emplace()` methods
- added `toml::path` utility type (#153, #156) (@jonestristand)
- added config option `TOML_CALLCONV`
- added missing relational operators for `source_position`
#### Changes:
- Relaxed cvref requirements of `is_homogeneous()`, `emplace()`, `emplace_back()`, `emplace_hint()`
- relaxed cvref requirements of `is_homogeneous()`, `emplace()`, `emplace_back()`, `emplace_hint()`
<br><br>
## [v3.1.0](https://github.com/marzer/tomlplusplus/releases/tag/v3.1.0) - 2022-04-22
#### Fixes:
- Fixed potential segfault when calling `at_path()` with an empty string
- Fixed UB in internal unicode machinery (#144) (@kchalmer)
- Fixed a number of spurious warnings with Clang 10 (#145, #146) (@chronoxor)
- fixed potential segfault when calling `at_path()` with an empty string
- fixed UB in internal unicode machinery (#144) (@kchalmer)
- fixed a number of spurious warnings with Clang 10 (#145, #146) (@chronoxor)
#### Additions:
- Added `toml::array::for_each()`
- Added `toml::table::for_each()`
- Added config options `TOML_EXPORTED_CLASS`, `TOML_EXPORTED_MEMBER_FUNCTION`, `TOML_EXPORTED_STATIC_FUNCTION` &amp; `TOML_EXPORTED_FREE_FUNCTION`
- Added support for escape sequence `\e` when using `TOML_ENABLE_UNRELEASED_FEATURES` ([toml/790](https://github.com/toml-lang/toml/pull/790))
- Added support for more unicode in bare keys when using `TOML_ENABLE_UNRELEASED_FEATURES` ([toml/891](https://github.com/toml-lang/toml/pull/891))
- added `toml::array::for_each()`
- added `toml::table::for_each()`
- added config options `TOML_EXPORTED_CLASS`, `TOML_EXPORTED_MEMBER_FUNCTION`, `TOML_EXPORTED_STATIC_FUNCTION` &amp; `TOML_EXPORTED_FREE_FUNCTION`
- added support for escape sequence `\e` when using `TOML_ENABLE_UNRELEASED_FEATURES` ([toml/790](https://github.com/toml-lang/toml/pull/790))
- added support for more unicode in bare keys when using `TOML_ENABLE_UNRELEASED_FEATURES` ([toml/891](https://github.com/toml-lang/toml/pull/891))
#### Removals/Deprecations:
- Deprecated old `TOML_API` option in favour new `TOML_EXPORTED_X` options
- deprecated old `TOML_API` option in favour new `TOML_EXPORTED_X` options
(it will continue to work as it did before if none of the new function export options are defined)
#### Build system:
- Meson: Added `compile_library` option (@Tachi107)
- Meson: Added `ubsan_tests` and `ubsan_examples` options
- Meson: Use system dependencies where available when building tests (@Tachi107)
- meson: added `compile_library` option (@Tachi107)
- meson: added `ubsan_tests` and `ubsan_examples` options
- meson: use system dependencies where available when building tests (@Tachi107)
<br><br>

View File

@ -186,7 +186,7 @@ won't need to mess with these at all, but if you do, set them before including t
| Option | Type | Description | Default |
|-----------------------------------|:--------------:|----------------------------------------------------------------------------------------------------------|------------------------|
| `TOML_ASSERT(expr)` | function macro | Sets the assert function used by the library. | `assert()` |
| `TOML_CALLCONV` | define | Calling convention to apply to all free/static functions in the library. | undefined |
| `TOML_CALLCONV` | define | Calling convention to apply to exported free/static functions. | undefined |
| `TOML_CONFIG_HEADER` | string literal | Includes the given header file before the rest of the library. | undefined |
| `TOML_ENABLE_FORMATTERS` | boolean | Enables the formatters. Set to `0` if you don't need them to improve compile times and binary size. | `1` |
| `TOML_ENABLE_PARSER` | boolean | Enables the parser. Set to `0` if you don't need it to improve compile times and binary size. | `1` |

View File

@ -123,61 +123,61 @@ TOML_IMPL_NAMESPACE_START
}
TOML_NODISCARD
friend array_iterator TOML_CALLCONV operator+(const array_iterator& lhs, ptrdiff_t rhs) noexcept
friend array_iterator operator+(const array_iterator& lhs, ptrdiff_t rhs) noexcept
{
return array_iterator{ lhs.iter_ + rhs };
}
TOML_NODISCARD
friend array_iterator TOML_CALLCONV operator+(ptrdiff_t lhs, const array_iterator& rhs) noexcept
friend array_iterator operator+(ptrdiff_t lhs, const array_iterator& rhs) noexcept
{
return array_iterator{ rhs.iter_ + lhs };
}
TOML_NODISCARD
friend array_iterator TOML_CALLCONV operator-(const array_iterator& lhs, ptrdiff_t rhs) noexcept
friend array_iterator operator-(const array_iterator& lhs, ptrdiff_t rhs) noexcept
{
return array_iterator{ lhs.iter_ - rhs };
}
TOML_PURE_INLINE_GETTER
friend ptrdiff_t TOML_CALLCONV operator-(const array_iterator& lhs, const array_iterator& rhs) noexcept
friend ptrdiff_t operator-(const array_iterator& lhs, const array_iterator& rhs) noexcept
{
return lhs.iter_ - rhs.iter_;
}
TOML_PURE_INLINE_GETTER
friend bool TOML_CALLCONV operator==(const array_iterator& lhs, const array_iterator& rhs) noexcept
friend bool operator==(const array_iterator& lhs, const array_iterator& rhs) noexcept
{
return lhs.iter_ == rhs.iter_;
}
TOML_PURE_INLINE_GETTER
friend bool TOML_CALLCONV operator!=(const array_iterator& lhs, const array_iterator& rhs) noexcept
friend bool operator!=(const array_iterator& lhs, const array_iterator& rhs) noexcept
{
return lhs.iter_ != rhs.iter_;
}
TOML_PURE_INLINE_GETTER
friend bool TOML_CALLCONV operator<(const array_iterator& lhs, const array_iterator& rhs) noexcept
friend bool operator<(const array_iterator& lhs, const array_iterator& rhs) noexcept
{
return lhs.iter_ < rhs.iter_;
}
TOML_PURE_INLINE_GETTER
friend bool TOML_CALLCONV operator<=(const array_iterator& lhs, const array_iterator& rhs) noexcept
friend bool operator<=(const array_iterator& lhs, const array_iterator& rhs) noexcept
{
return lhs.iter_ <= rhs.iter_;
}
TOML_PURE_INLINE_GETTER
friend bool TOML_CALLCONV operator>(const array_iterator& lhs, const array_iterator& rhs) noexcept
friend bool operator>(const array_iterator& lhs, const array_iterator& rhs) noexcept
{
return lhs.iter_ > rhs.iter_;
}
TOML_PURE_INLINE_GETTER
friend bool TOML_CALLCONV operator>=(const array_iterator& lhs, const array_iterator& rhs) noexcept
friend bool operator>=(const array_iterator& lhs, const array_iterator& rhs) noexcept
{
return lhs.iter_ >= rhs.iter_;
}
@ -716,6 +716,10 @@ TOML_NAMESPACE_START
return const_cast<array&>(*this).template get_as<ElemType>(index);
}
/// \cond
using node::operator[]; // inherit operator[toml::path]
/// \endcond
/// \brief Gets a reference to the element at a specific index.
TOML_NODISCARD
node& operator[](size_t index) noexcept
@ -872,8 +876,7 @@ TOML_NAMESPACE_START
// clang-format on
template <typename Func, typename Array>
static void TOML_CALLCONV do_for_each(Func&& visitor,
Array&& arr) noexcept(for_each_is_nothrow<Func&&, Array&&>)
static void do_for_each(Func&& visitor, Array&& arr) noexcept(for_each_is_nothrow<Func&&, Array&&>)
{
static_assert(can_for_each_any<Func&&, Array&&>,
"TOML array for_each visitors must be invocable for at least one of the toml::node "
@ -1633,7 +1636,7 @@ TOML_NAMESPACE_START
template <typename T>
TOML_NODISCARD
static bool TOML_CALLCONV equal_to_container(const array& lhs, const T& rhs) noexcept
static bool equal_to_container(const array& lhs, const T& rhs) noexcept
{
using element_type = std::remove_const_t<typename T::value_type>;
static_assert(impl::is_losslessly_convertible_to_native<element_type>,
@ -1668,7 +1671,7 @@ TOML_NAMESPACE_START
///
/// \returns True if the arrays contained the same elements.
TOML_NODISCARD
friend bool TOML_CALLCONV operator==(const array& lhs, const array& rhs) noexcept
friend bool operator==(const array& lhs, const array& rhs) noexcept
{
return equal(lhs, rhs);
}
@ -1680,7 +1683,7 @@ TOML_NAMESPACE_START
///
/// \returns True if the arrays did not contain the same elements.
TOML_NODISCARD
friend bool TOML_CALLCONV operator!=(const array& lhs, const array& rhs) noexcept
friend bool operator!=(const array& lhs, const array& rhs) noexcept
{
return !equal(lhs, rhs);
}
@ -1688,7 +1691,7 @@ TOML_NAMESPACE_START
/// \brief Initializer list equality operator.
template <typename T>
TOML_NODISCARD
friend bool TOML_CALLCONV operator==(const array& lhs, const std::initializer_list<T>& rhs) noexcept
friend bool operator==(const array& lhs, const std::initializer_list<T>& rhs) noexcept
{
return equal_to_container(lhs, rhs);
}
@ -1697,7 +1700,7 @@ TOML_NAMESPACE_START
/// \brief Vector equality operator.
template <typename T>
TOML_NODISCARD
friend bool TOML_CALLCONV operator==(const array& lhs, const std::vector<T>& rhs) noexcept
friend bool operator==(const array& lhs, const std::vector<T>& rhs) noexcept
{
return equal_to_container(lhs, rhs);
}
@ -1710,7 +1713,7 @@ TOML_NAMESPACE_START
/// \brief Prints the array out to a stream as formatted TOML.
///
/// \availability This operator is only available when #TOML_ENABLE_FORMATTERS is enabled.
friend std::ostream& TOML_CALLCONV operator<<(std::ostream& lhs, const array& rhs)
friend std::ostream& operator<<(std::ostream& lhs, const array& rhs)
{
impl::print_to_stream(lhs, rhs);
return lhs;

View File

@ -13,7 +13,6 @@ TOML_IMPL_NAMESPACE_START
using parse_path_callback = bool(TOML_CALLCONV*)(void*, T);
TOML_NODISCARD
TOML_EXPORTED_FREE_FUNCTION
bool TOML_CALLCONV parse_path(std::string_view,
void*,
parse_path_callback<std::string_view>,

View File

@ -37,23 +37,25 @@ TOML_NAMESPACE_START
/// \brief Equality operator.
TOML_PURE_GETTER
friend constexpr bool TOML_CALLCONV operator==(const date& lhs, const date& rhs) noexcept
friend constexpr bool operator==(const date& lhs, const date& rhs) noexcept
{
return lhs.year == rhs.year && lhs.month == rhs.month && lhs.day == rhs.day;
return lhs.year == rhs.year //
&& lhs.month == rhs.month //
&& lhs.day == rhs.day;
}
/// \brief Inequality operator.
TOML_PURE_GETTER
friend constexpr bool TOML_CALLCONV operator!=(const date& lhs, const date& rhs) noexcept
TOML_PURE_INLINE_GETTER
friend constexpr bool operator!=(const date& lhs, const date& rhs) noexcept
{
return lhs.year != rhs.year || lhs.month != rhs.month || lhs.day != rhs.day;
return !(lhs == rhs);
}
private:
/// \cond
TOML_PURE_GETTER
static constexpr uint32_t TOML_CALLCONV pack(const date& d) noexcept
static constexpr uint32_t pack(const date& d) noexcept
{
return (static_cast<uint32_t>(d.year) << 16) | (static_cast<uint32_t>(d.month) << 8)
| static_cast<uint32_t>(d.day);
@ -64,28 +66,28 @@ TOML_NAMESPACE_START
public:
/// \brief Less-than operator.
TOML_PURE_GETTER
friend constexpr bool TOML_CALLCONV operator<(const date& lhs, const date& rhs) noexcept
friend constexpr bool operator<(const date& lhs, const date& rhs) noexcept
{
return pack(lhs) < pack(rhs);
}
/// \brief Less-than-or-equal-to operator.
TOML_PURE_GETTER
friend constexpr bool TOML_CALLCONV operator<=(const date& lhs, const date& rhs) noexcept
friend constexpr bool operator<=(const date& lhs, const date& rhs) noexcept
{
return pack(lhs) <= pack(rhs);
}
/// \brief Greater-than operator.
TOML_PURE_GETTER
friend constexpr bool TOML_CALLCONV operator>(const date& lhs, const date& rhs) noexcept
friend constexpr bool operator>(const date& lhs, const date& rhs) noexcept
{
return pack(lhs) > pack(rhs);
}
/// \brief Greater-than-or-equal-to operator.
TOML_PURE_GETTER
friend constexpr bool TOML_CALLCONV operator>=(const date& lhs, const date& rhs) noexcept
friend constexpr bool operator>=(const date& lhs, const date& rhs) noexcept
{
return pack(lhs) >= pack(rhs);
}
@ -99,7 +101,7 @@ TOML_NAMESPACE_START
/// \out
/// 1987-03-16
/// \eout
friend std::ostream& TOML_CALLCONV operator<<(std::ostream& lhs, const date& rhs)
friend std::ostream& operator<<(std::ostream& lhs, const date& rhs)
{
impl::print_to_stream(lhs, rhs);
return lhs;
@ -141,15 +143,17 @@ TOML_NAMESPACE_START
/// \brief Equality operator.
TOML_PURE_GETTER
friend constexpr bool TOML_CALLCONV operator==(const time& lhs, const time& rhs) noexcept
friend constexpr bool operator==(const time& lhs, const time& rhs) noexcept
{
return lhs.hour == rhs.hour && lhs.minute == rhs.minute && lhs.second == rhs.second
return lhs.hour == rhs.hour //
&& lhs.minute == rhs.minute //
&& lhs.second == rhs.second //
&& lhs.nanosecond == rhs.nanosecond;
}
/// \brief Inequality operator.
TOML_PURE_GETTER
friend constexpr bool TOML_CALLCONV operator!=(const time& lhs, const time& rhs) noexcept
TOML_PURE_INLINE_GETTER
friend constexpr bool operator!=(const time& lhs, const time& rhs) noexcept
{
return !(lhs == rhs);
}
@ -158,7 +162,7 @@ TOML_NAMESPACE_START
/// \cond
TOML_PURE_GETTER
static constexpr uint64_t TOML_CALLCONV pack(const time& t) noexcept
static constexpr uint64_t pack(const time& t) noexcept
{
return static_cast<uint64_t>(t.hour) << 48 | static_cast<uint64_t>(t.minute) << 40
| static_cast<uint64_t>(t.second) << 32 | static_cast<uint64_t>(t.nanosecond);
@ -169,28 +173,28 @@ TOML_NAMESPACE_START
public:
/// \brief Less-than operator.
TOML_PURE_GETTER
friend constexpr bool TOML_CALLCONV operator<(const time& lhs, const time& rhs) noexcept
friend constexpr bool operator<(const time& lhs, const time& rhs) noexcept
{
return pack(lhs) < pack(rhs);
}
/// \brief Less-than-or-equal-to operator.
TOML_PURE_GETTER
friend constexpr bool TOML_CALLCONV operator<=(const time& lhs, const time& rhs) noexcept
friend constexpr bool operator<=(const time& lhs, const time& rhs) noexcept
{
return pack(lhs) <= pack(rhs);
}
/// \brief Greater-than operator.
TOML_PURE_GETTER
friend constexpr bool TOML_CALLCONV operator>(const time& lhs, const time& rhs) noexcept
friend constexpr bool operator>(const time& lhs, const time& rhs) noexcept
{
return pack(lhs) > pack(rhs);
}
/// \brief Greater-than-or-equal-to operator.
TOML_PURE_GETTER
friend constexpr bool TOML_CALLCONV operator>=(const time& lhs, const time& rhs) noexcept
friend constexpr bool operator>=(const time& lhs, const time& rhs) noexcept
{
return pack(lhs) >= pack(rhs);
}
@ -205,7 +209,7 @@ TOML_NAMESPACE_START
/// 10:20:34
/// 10:20:34.5
/// \eout
friend std::ostream& TOML_CALLCONV operator<<(std::ostream& lhs, const time& rhs)
friend std::ostream& operator<<(std::ostream& lhs, const time& rhs)
{
impl::print_to_stream(lhs, rhs);
return lhs;
@ -252,43 +256,43 @@ TOML_NAMESPACE_START
{}
/// \brief Equality operator.
TOML_PURE_GETTER
friend constexpr bool TOML_CALLCONV operator==(time_offset lhs, time_offset rhs) noexcept
TOML_PURE_INLINE_GETTER
friend constexpr bool operator==(time_offset lhs, time_offset rhs) noexcept
{
return lhs.minutes == rhs.minutes;
}
/// \brief Inequality operator.
TOML_PURE_GETTER
friend constexpr bool TOML_CALLCONV operator!=(time_offset lhs, time_offset rhs) noexcept
TOML_PURE_INLINE_GETTER
friend constexpr bool operator!=(time_offset lhs, time_offset rhs) noexcept
{
return lhs.minutes != rhs.minutes;
}
/// \brief Less-than operator.
TOML_PURE_GETTER
friend constexpr bool TOML_CALLCONV operator<(time_offset lhs, time_offset rhs) noexcept
TOML_PURE_INLINE_GETTER
friend constexpr bool operator<(time_offset lhs, time_offset rhs) noexcept
{
return lhs.minutes < rhs.minutes;
}
/// \brief Less-than-or-equal-to operator.
TOML_PURE_GETTER
friend constexpr bool TOML_CALLCONV operator<=(time_offset lhs, time_offset rhs) noexcept
TOML_PURE_INLINE_GETTER
friend constexpr bool operator<=(time_offset lhs, time_offset rhs) noexcept
{
return lhs.minutes <= rhs.minutes;
}
/// \brief Greater-than operator.
TOML_PURE_GETTER
friend constexpr bool TOML_CALLCONV operator>(time_offset lhs, time_offset rhs) noexcept
TOML_PURE_INLINE_GETTER
friend constexpr bool operator>(time_offset lhs, time_offset rhs) noexcept
{
return lhs.minutes > rhs.minutes;
}
/// \brief Greater-than-or-equal-to operator.
TOML_PURE_GETTER
friend constexpr bool TOML_CALLCONV operator>=(time_offset lhs, time_offset rhs) noexcept
TOML_PURE_INLINE_GETTER
friend constexpr bool operator>=(time_offset lhs, time_offset rhs) noexcept
{
return lhs.minutes >= rhs.minutes;
}
@ -309,7 +313,7 @@ TOML_NAMESPACE_START
/// -01:30
/// -02:30
/// \eout
friend std::ostream& TOML_CALLCONV operator<<(std::ostream& lhs, const time_offset& rhs)
friend std::ostream& operator<<(std::ostream& lhs, const time_offset& rhs)
{
impl::print_to_stream(lhs, rhs);
return lhs;
@ -380,7 +384,7 @@ TOML_NAMESPACE_START
{}
/// \brief Returns true if this date_time does not contain timezone offset information.
TOML_PURE_GETTER
TOML_PURE_INLINE_GETTER
constexpr bool is_local() const noexcept
{
return !offset.has_value();
@ -388,21 +392,23 @@ TOML_NAMESPACE_START
/// \brief Equality operator.
TOML_PURE_GETTER
friend constexpr bool TOML_CALLCONV operator==(const date_time& lhs, const date_time& rhs) noexcept
friend constexpr bool operator==(const date_time& lhs, const date_time& rhs) noexcept
{
return lhs.date == rhs.date && lhs.time == rhs.time && lhs.offset == rhs.offset;
return lhs.date == rhs.date //
&& lhs.time == rhs.time //
&& lhs.offset == rhs.offset;
}
/// \brief Inequality operator.
TOML_PURE_GETTER
friend constexpr bool TOML_CALLCONV operator!=(const date_time& lhs, const date_time& rhs) noexcept
TOML_PURE_INLINE_GETTER
friend constexpr bool operator!=(const date_time& lhs, const date_time& rhs) noexcept
{
return !(lhs == rhs);
}
/// \brief Less-than operator.
TOML_PURE_GETTER
friend constexpr bool TOML_CALLCONV operator<(const date_time& lhs, const date_time& rhs) noexcept
friend constexpr bool operator<(const date_time& lhs, const date_time& rhs) noexcept
{
if (lhs.date != rhs.date)
return lhs.date < rhs.date;
@ -413,7 +419,7 @@ TOML_NAMESPACE_START
/// \brief Less-than-or-equal-to operator.
TOML_PURE_GETTER
friend constexpr bool TOML_CALLCONV operator<=(const date_time& lhs, const date_time& rhs) noexcept
friend constexpr bool operator<=(const date_time& lhs, const date_time& rhs) noexcept
{
if (lhs.date != rhs.date)
return lhs.date < rhs.date;
@ -423,15 +429,15 @@ TOML_NAMESPACE_START
}
/// \brief Greater-than operator.
TOML_PURE_GETTER
friend constexpr bool TOML_CALLCONV operator>(const date_time& lhs, const date_time& rhs) noexcept
TOML_PURE_INLINE_GETTER
friend constexpr bool operator>(const date_time& lhs, const date_time& rhs) noexcept
{
return !(lhs <= rhs);
}
/// \brief Greater-than-or-equal-to operator.
TOML_PURE_GETTER
friend constexpr bool TOML_CALLCONV operator>=(const date_time& lhs, const date_time& rhs) noexcept
TOML_PURE_INLINE_GETTER
friend constexpr bool operator>=(const date_time& lhs, const date_time& rhs) noexcept
{
return !(lhs < rhs);
}
@ -448,7 +454,7 @@ TOML_NAMESPACE_START
/// 1987-03-16T10:20:34-02:30
/// 1987-03-16T10:20:34Z
/// \eout
friend std::ostream& TOML_CALLCONV operator<<(std::ostream& lhs, const date_time& rhs)
friend std::ostream& operator<<(std::ostream& lhs, const date_time& rhs)
{
impl::print_to_stream(lhs, rhs);
return lhs;

View File

@ -250,7 +250,7 @@ TOML_NAMESPACE_START // abi namespace
/// Element [3] is: boolean
/// \eout
template <typename Char>
inline std::basic_ostream<Char>& TOML_CALLCONV operator<<(std::basic_ostream<Char>& lhs, node_type rhs)
inline std::basic_ostream<Char>& operator<<(std::basic_ostream<Char>& lhs, node_type rhs)
{
const auto str = impl::node_type_friendly_names[static_cast<std::underlying_type_t<node_type>>(rhs)];
using str_char_t = decltype(str)::value_type;
@ -1013,7 +1013,7 @@ TOML_IMPL_NAMESPACE_START
{
template <typename T>
TOML_CONST_INLINE_GETTER
constexpr std::underlying_type_t<T> TOML_CALLCONV unwrap_enum(T val) noexcept
constexpr std::underlying_type_t<T> unwrap_enum(T val) noexcept
{
return static_cast<std::underlying_type_t<T>>(val);
}
@ -1029,7 +1029,7 @@ TOML_IMPL_NAMESPACE_START
};
TOML_PURE_GETTER
inline fp_class TOML_CALLCONV fpclassify(const double& val) noexcept
inline fp_class fpclassify(const double& val) noexcept
{
static_assert(sizeof(uint64_t) == sizeof(double));
@ -1052,7 +1052,7 @@ TOML_IMPL_NAMESPACE_START
template <typename Iterator, typename T>
TOML_PURE_GETTER
inline auto TOML_CALLCONV find(Iterator start, Iterator end, const T& needle) noexcept //
inline auto find(Iterator start, Iterator end, const T& needle) noexcept //
->decltype(&(*start))
{
for (; start != end; start++)
@ -1062,8 +1062,8 @@ TOML_IMPL_NAMESPACE_START
}
template <typename T>
TOML_PURE_GETTER
constexpr const T& TOML_CALLCONV min(const T& a, const T& b) noexcept //
TOML_PURE_INLINE_GETTER
constexpr const T& min(const T& a, const T& b) noexcept //
{
return a < b ? a : b;
}

View File

@ -6,5 +6,6 @@
#ifdef _MSC_VER
#pragma pop_macro("min")
#pragma pop_macro("max")
#pragma inline_recursion(off)
#endif
TOML_POP_WARNINGS;

View File

@ -5,6 +5,7 @@
//# }}
TOML_PUSH_WARNINGS;
#ifdef _MSC_VER
#pragma inline_recursion(on)
#pragma push_macro("min")
#pragma push_macro("max")
#undef min

View File

@ -121,7 +121,7 @@ TOML_NAMESPACE_START
#endif
/// \brief Prints the bound TOML object out to the stream as JSON.
friend std::ostream& TOML_CALLCONV operator<<(std::ostream& lhs, json_formatter& rhs)
friend std::ostream& operator<<(std::ostream& lhs, json_formatter& rhs)
{
rhs.attach(lhs);
rhs.print();
@ -130,7 +130,7 @@ TOML_NAMESPACE_START
}
/// \brief Prints the bound TOML object out to the stream as JSON (rvalue overload).
friend std::ostream& TOML_CALLCONV operator<<(std::ostream& lhs, json_formatter&& rhs)
friend std::ostream& operator<<(std::ostream& lhs, json_formatter&& rhs)
{
return lhs << rhs; // as lvalue
}

View File

@ -161,126 +161,126 @@ TOML_NAMESPACE_START
/// \brief Returns true if `lhs.str() == rhs.str()`.
TOML_PURE_INLINE_GETTER
friend bool TOML_CALLCONV operator==(const key& lhs, const key& rhs) noexcept
friend bool operator==(const key& lhs, const key& rhs) noexcept
{
return lhs.key_ == rhs.key_;
}
/// \brief Returns true if `lhs.str() != rhs.str()`.
TOML_PURE_INLINE_GETTER
friend bool TOML_CALLCONV operator!=(const key& lhs, const key& rhs) noexcept
friend bool operator!=(const key& lhs, const key& rhs) noexcept
{
return lhs.key_ != rhs.key_;
}
/// \brief Returns true if `lhs.str() < rhs.str()`.
TOML_PURE_INLINE_GETTER
friend bool TOML_CALLCONV operator<(const key& lhs, const key& rhs) noexcept
friend bool operator<(const key& lhs, const key& rhs) noexcept
{
return lhs.key_ < rhs.key_;
}
/// \brief Returns true if `lhs.str() <= rhs.str()`.
TOML_PURE_INLINE_GETTER
friend bool TOML_CALLCONV operator<=(const key& lhs, const key& rhs) noexcept
friend bool operator<=(const key& lhs, const key& rhs) noexcept
{
return lhs.key_ <= rhs.key_;
}
/// \brief Returns true if `lhs.str() > rhs.str()`.
TOML_PURE_INLINE_GETTER
friend bool TOML_CALLCONV operator>(const key& lhs, const key& rhs) noexcept
friend bool operator>(const key& lhs, const key& rhs) noexcept
{
return lhs.key_ > rhs.key_;
}
/// \brief Returns true if `lhs.str() >= rhs.str()`.
TOML_PURE_INLINE_GETTER
friend bool TOML_CALLCONV operator>=(const key& lhs, const key& rhs) noexcept
friend bool operator>=(const key& lhs, const key& rhs) noexcept
{
return lhs.key_ >= rhs.key_;
}
/// \brief Returns true if `lhs.str() == rhs`.
TOML_PURE_INLINE_GETTER
friend bool TOML_CALLCONV operator==(const key& lhs, std::string_view rhs) noexcept
friend bool operator==(const key& lhs, std::string_view rhs) noexcept
{
return lhs.key_ == rhs;
}
/// \brief Returns true if `lhs.str() != rhs`.
TOML_PURE_INLINE_GETTER
friend bool TOML_CALLCONV operator!=(const key& lhs, std::string_view rhs) noexcept
friend bool operator!=(const key& lhs, std::string_view rhs) noexcept
{
return lhs.key_ != rhs;
}
/// \brief Returns true if `lhs.str() < rhs`.
TOML_PURE_INLINE_GETTER
friend bool TOML_CALLCONV operator<(const key& lhs, std::string_view rhs) noexcept
friend bool operator<(const key& lhs, std::string_view rhs) noexcept
{
return lhs.key_ < rhs;
}
/// \brief Returns true if `lhs.str() <= rhs`.
TOML_PURE_INLINE_GETTER
friend bool TOML_CALLCONV operator<=(const key& lhs, std::string_view rhs) noexcept
friend bool operator<=(const key& lhs, std::string_view rhs) noexcept
{
return lhs.key_ <= rhs;
}
/// \brief Returns true if `lhs.str() > rhs`.
TOML_PURE_INLINE_GETTER
friend bool TOML_CALLCONV operator>(const key& lhs, std::string_view rhs) noexcept
friend bool operator>(const key& lhs, std::string_view rhs) noexcept
{
return lhs.key_ > rhs;
}
/// \brief Returns true if `lhs.str() >= rhs`.
TOML_PURE_INLINE_GETTER
friend bool TOML_CALLCONV operator>=(const key& lhs, std::string_view rhs) noexcept
friend bool operator>=(const key& lhs, std::string_view rhs) noexcept
{
return lhs.key_ >= rhs;
}
/// \brief Returns true if `lhs == rhs.str()`.
TOML_PURE_INLINE_GETTER
friend bool TOML_CALLCONV operator==(std::string_view lhs, const key& rhs) noexcept
friend bool operator==(std::string_view lhs, const key& rhs) noexcept
{
return lhs == rhs.key_;
}
/// \brief Returns true if `lhs != rhs.str()`.
TOML_PURE_INLINE_GETTER
friend bool TOML_CALLCONV operator!=(std::string_view lhs, const key& rhs) noexcept
friend bool operator!=(std::string_view lhs, const key& rhs) noexcept
{
return lhs != rhs.key_;
}
/// \brief Returns true if `lhs < rhs.str()`.
TOML_PURE_INLINE_GETTER
friend bool TOML_CALLCONV operator<(std::string_view lhs, const key& rhs) noexcept
friend bool operator<(std::string_view lhs, const key& rhs) noexcept
{
return lhs < rhs.key_;
}
/// \brief Returns true if `lhs <= rhs.str()`.
TOML_PURE_INLINE_GETTER
friend bool TOML_CALLCONV operator<=(std::string_view lhs, const key& rhs) noexcept
friend bool operator<=(std::string_view lhs, const key& rhs) noexcept
{
return lhs <= rhs.key_;
}
/// \brief Returns true if `lhs > rhs.str()`.
TOML_PURE_INLINE_GETTER
friend bool TOML_CALLCONV operator>(std::string_view lhs, const key& rhs) noexcept
friend bool operator>(std::string_view lhs, const key& rhs) noexcept
{
return lhs > rhs.key_;
}
/// \brief Returns true if `lhs >= rhs.str()`.
TOML_PURE_INLINE_GETTER
friend bool TOML_CALLCONV operator>=(std::string_view lhs, const key& rhs) noexcept
friend bool operator>=(std::string_view lhs, const key& rhs) noexcept
{
return lhs >= rhs.key_;
}
@ -313,7 +313,7 @@ TOML_NAMESPACE_START
/// @}
/// \brief Prints the key's underlying string out to the stream.
friend std::ostream& TOML_CALLCONV operator<<(std::ostream& lhs, const key& rhs)
friend std::ostream& operator<<(std::ostream& lhs, const key& rhs)
{
impl::print_to_stream(lhs, rhs.key_);
return lhs;

View File

@ -13,7 +13,7 @@ TOML_IMPL_NAMESPACE_START
template <typename T>
TOML_NODISCARD
TOML_ATTR(returns_nonnull)
auto* TOML_CALLCONV make_node_impl_specialized(T && val, [[maybe_unused]] value_flags flags)
auto* make_node_impl_specialized(T && val, [[maybe_unused]] value_flags flags)
{
using unwrapped_type = unwrap_node<remove_cvref<T>>;
static_assert(!std::is_same_v<unwrapped_type, node>);
@ -81,7 +81,7 @@ TOML_IMPL_NAMESPACE_START
template <typename T>
TOML_NODISCARD
auto* TOML_CALLCONV make_node_impl(T && val, value_flags flags = preserve_source_value_flags)
auto* make_node_impl(T && val, value_flags flags = preserve_source_value_flags)
{
using unwrapped_type = unwrap_node<remove_cvref<T>>;
if constexpr (std::is_same_v<unwrapped_type, node> || is_node_view<unwrapped_type>)
@ -104,7 +104,7 @@ TOML_IMPL_NAMESPACE_START
template <typename T>
TOML_NODISCARD
auto* TOML_CALLCONV make_node_impl(inserter<T> && val, value_flags flags = preserve_source_value_flags)
auto* make_node_impl(inserter<T> && val, value_flags flags = preserve_source_value_flags)
{
return make_node_impl(static_cast<T&&>(val.value), flags);
}
@ -129,7 +129,7 @@ TOML_IMPL_NAMESPACE_START
template <typename T>
TOML_NODISCARD
node_ptr TOML_CALLCONV make_node(T && val, value_flags flags = preserve_source_value_flags)
node_ptr make_node(T && val, value_flags flags = preserve_source_value_flags)
{
return node_ptr{ make_node_impl(static_cast<T&&>(val), flags) };
}

View File

@ -43,7 +43,7 @@ TOML_NAMESPACE_START
template <typename T, typename N>
TOML_PURE_GETTER
static ref_type<T, N&&> TOML_CALLCONV do_ref(N&& n) noexcept
static ref_type<T, N&&> do_ref(N&& n) noexcept
{
using unwrapped_type = impl::unwrap_node<T>;
static_assert(toml::is_value<unwrapped_type> || toml::is_container<unwrapped_type>,
@ -795,8 +795,7 @@ TOML_NAMESPACE_START
using nonvoid = std::conditional_t<std::is_void_v<A>, B, A>;
template <typename Func, typename Node>
static decltype(auto) TOML_CALLCONV do_visit(Func&& visitor,
Node&& n) noexcept(visit_is_nothrow<Func&&, Node&&>)
static decltype(auto) do_visit(Func&& visitor, Node&& n) noexcept(visit_is_nothrow<Func&&, Node&&>)
{
static_assert(can_visit_any<Func&&, Node&&>,
"TOML node visitors must be invocable for at least one of the toml::node "
@ -1048,7 +1047,7 @@ TOML_NAMESPACE_START
/// \brief Returns a const view of the subnode matching a fully-qualified "TOML path".
///
/// \see #at_path(const toml::path& path)
/// \see #at_path(const toml::path&)
TOML_NODISCARD
TOML_EXPORTED_MEMBER_FUNCTION
node_view<const node> at_path(const toml::path& path) const noexcept;
@ -1075,6 +1074,28 @@ TOML_NAMESPACE_START
#endif // TOML_ENABLE_WINDOWS_COMPAT
/// \brief Returns a const view of the subnode matching a fully-qualified "TOML path".
///
/// \param path The "TOML path" to the desired child.
///
/// \returns A view of the child node at the given path if one existed, or an empty node view.
///
/// \see toml::node_view
TOML_NODISCARD
TOML_EXPORTED_MEMBER_FUNCTION
node_view<node> operator[](const toml::path& path) noexcept;
/// \brief Returns a const view of the subnode matching a fully-qualified "TOML path".
///
/// \param path The "TOML path" to the desired child.
///
/// \returns A view of the child node at the given path if one existed, or an empty node view.
///
/// \see toml::node_view
TOML_NODISCARD
TOML_EXPORTED_MEMBER_FUNCTION
node_view<const node> operator[](const toml::path& path) const noexcept;
/// @}
};
}
@ -1085,7 +1106,7 @@ TOML_IMPL_NAMESPACE_START
{
TOML_PURE_GETTER
TOML_EXPORTED_FREE_FUNCTION
bool node_deep_equality(const node*, const node*) noexcept;
bool TOML_CALLCONV node_deep_equality(const node*, const node*) noexcept;
}
TOML_IMPL_NAMESPACE_END;
/// \endcond

View File

@ -72,15 +72,15 @@ TOML_NAMESPACE_START
}
TOML_EXTERNAL_LINKAGE
node_view<node> node::at_path(const toml::path& path) noexcept
node_view<node> node::at_path(const path& p) noexcept
{
return toml::at_path(*this, path);
return toml::at_path(*this, p);
}
TOML_EXTERNAL_LINKAGE
node_view<const node> node::at_path(const toml::path& path) const noexcept
node_view<const node> node::at_path(const path& p) const noexcept
{
return toml::at_path(*this, path);
return toml::at_path(*this, p);
}
#if TOML_ENABLE_WINDOWS_COMPAT
@ -98,6 +98,18 @@ TOML_NAMESPACE_START
}
#endif // TOML_ENABLE_WINDOWS_COMPAT
TOML_EXTERNAL_LINKAGE
node_view<node> node::operator[](const path& p) noexcept
{
return toml::at_path(*this, p);
}
TOML_EXTERNAL_LINKAGE
node_view<const node> node::operator[](const path& p) const noexcept
{
return toml::at_path(*this, p);
}
}
TOML_NAMESPACE_END;

View File

@ -595,7 +595,7 @@ TOML_NAMESPACE_START
/// \brief Returns true if the two views refer to nodes of the same type and value.
template <typename T>
TOML_PURE_GETTER
friend bool TOML_CALLCONV operator==(const node_view& lhs, const node_view<T>& rhs) noexcept
friend bool operator==(const node_view& lhs, const node_view<T>& rhs) noexcept
{
return impl::node_deep_equality(lhs.node_, rhs.node_);
}
@ -603,14 +603,14 @@ TOML_NAMESPACE_START
/// \brief Returns true if the two views do not refer to nodes of the same type and value.
template <typename T>
TOML_PURE_GETTER
friend bool TOML_CALLCONV operator!=(const node_view& lhs, const node_view<T>& rhs) noexcept
friend bool operator!=(const node_view& lhs, const node_view<T>& rhs) noexcept
{
return !impl::node_deep_equality(lhs.node_, rhs.node_);
}
/// \brief Returns true if the viewed node is a table with the same contents as RHS.
TOML_NODISCARD
friend bool TOML_CALLCONV operator==(const node_view& lhs, const table& rhs) noexcept
friend bool operator==(const node_view& lhs, const table& rhs) noexcept
{
if (lhs.node_ == &rhs)
return true;
@ -621,7 +621,7 @@ TOML_NAMESPACE_START
/// \brief Returns true if the viewed node is an array with the same contents as RHS.
TOML_NODISCARD
friend bool TOML_CALLCONV operator==(const node_view& lhs, const array& rhs) noexcept
friend bool operator==(const node_view& lhs, const array& rhs) noexcept
{
if (lhs.node_ == &rhs)
return true;
@ -633,7 +633,7 @@ TOML_NAMESPACE_START
/// \brief Returns true if the viewed node is a value with the same value as RHS.
template <typename T>
TOML_NODISCARD
friend bool TOML_CALLCONV operator==(const node_view& lhs, const toml::value<T>& rhs) noexcept
friend bool operator==(const node_view& lhs, const toml::value<T>& rhs) noexcept
{
if (lhs.node_ == &rhs)
return true;
@ -645,7 +645,7 @@ TOML_NAMESPACE_START
/// \brief Returns true if the viewed node is a value with the same value as RHS.
TOML_CONSTRAINED_TEMPLATE(impl::is_losslessly_convertible_to_native<T>, typename T)
TOML_NODISCARD
friend bool TOML_CALLCONV operator==(const node_view& lhs, const T& rhs) noexcept(!impl::is_wide_string<T>)
friend bool operator==(const node_view& lhs, const T& rhs) noexcept(!impl::is_wide_string<T>)
{
static_assert(!impl::is_wide_string<T> || TOML_ENABLE_WINDOWS_COMPAT,
"Comparison with wide-character strings is only "
@ -673,8 +673,8 @@ TOML_NAMESPACE_START
/// \brief Returns true if the viewed node is an array with the same contents as the RHS initializer list.
template <typename T>
TOML_NODISCARD
friend bool TOML_CALLCONV operator==(const node_view& lhs,
const std::initializer_list<T>& rhs) noexcept(!impl::is_wide_string<T>)
friend bool operator==(const node_view& lhs,
const std::initializer_list<T>& rhs) noexcept(!impl::is_wide_string<T>)
{
const auto arr = lhs.as<array>();
return arr && *arr == rhs;
@ -684,8 +684,7 @@ TOML_NAMESPACE_START
/// \brief Returns true if the viewed node is an array with the same contents as the RHS vector.
template <typename T>
TOML_NODISCARD
friend bool TOML_CALLCONV operator==(const node_view& lhs,
const std::vector<T>& rhs) noexcept(!impl::is_wide_string<T>)
friend bool operator==(const node_view& lhs, const std::vector<T>& rhs) noexcept(!impl::is_wide_string<T>)
{
const auto arr = lhs.as<array>();
return arr && *arr == rhs;
@ -793,7 +792,7 @@ TOML_NAMESPACE_START
/// \brief Prints the viewed node out to a stream.
///
/// \availability This operator is only available when #TOML_ENABLE_FORMATTERS is enabled.
friend std::ostream& TOML_CALLCONV operator<<(std::ostream& os, const node_view& nv)
friend std::ostream& operator<<(std::ostream& os, const node_view& nv)
{
if (nv.node_)
nv.node_->visit([&os](const auto& n) { os << n; });

View File

@ -119,7 +119,7 @@ TOML_NAMESPACE_START
/// \param rhs The parse_error.
///
/// \returns The input stream.
friend std::ostream& TOML_CALLCONV operator<<(std::ostream& lhs, const parse_error& rhs)
friend std::ostream& operator<<(std::ostream& lhs, const parse_error& rhs)
{
impl::print_to_stream(lhs, rhs.description());
impl::print_to_stream(lhs, "\n\t(error occurred at "sv);

View File

@ -68,7 +68,7 @@ TOML_NAMESPACE_START
template <typename Type>
TOML_NODISCARD
TOML_ALWAYS_INLINE
static Type* TOML_CALLCONV get_as(storage_t& s) noexcept
static Type* get_as(storage_t& s) noexcept
{
return TOML_LAUNDER(reinterpret_cast<Type*>(s.bytes));
}
@ -328,6 +328,86 @@ TOML_NAMESPACE_START
/// \name Node views
/// @{
/// \brief Returns a view of the subnode matching a fully-qualified "TOML path".
///
/// \see #toml::node::at_path(std::string_view)
TOML_NODISCARD
node_view<node> at_path(std::string_view path) noexcept
{
return err_ ? node_view<node>{} : table().at_path(path);
}
/// \brief Returns a const view of the subnode matching a fully-qualified "TOML path".
///
/// \see #toml::node::at_path(std::string_view)
TOML_NODISCARD
node_view<const node> at_path(std::string_view path) const noexcept
{
return err_ ? node_view<const node>{} : table().at_path(path);
}
/// \brief Returns a view of the subnode matching a fully-qualified "TOML path".
///
/// \see #toml::node::at_path(const toml::path&)
TOML_NODISCARD
node_view<node> at_path(const toml::path& path) noexcept
{
return err_ ? node_view<node>{} : table().at_path(path);
}
/// \brief Returns a const view of the subnode matching a fully-qualified "TOML path".
///
/// \see #toml::node::at_path(const toml::path&)
TOML_NODISCARD
node_view<const node> at_path(const toml::path& path) const noexcept
{
return err_ ? node_view<const node>{} : table().at_path(path);
}
#if TOML_ENABLE_WINDOWS_COMPAT
/// \brief Returns a view of the subnode matching a fully-qualified "TOML path".
///
/// \availability This overload is only available when #TOML_ENABLE_WINDOWS_COMPAT is enabled.
///
/// \see #toml::node::at_path(std::string_view)
TOML_NODISCARD
node_view<node> at_path(std::wstring_view path)
{
return err_ ? node_view<node>{} : table().at_path(path);
}
/// \brief Returns a const view of the subnode matching a fully-qualified "TOML path".
///
/// \availability This overload is only available when #TOML_ENABLE_WINDOWS_COMPAT is enabled.
///
/// \see #toml::node::at_path(std::string_view)
TOML_NODISCARD
node_view<const node> at_path(std::wstring_view path) const
{
return err_ ? node_view<const node>{} : table().at_path(path);
}
#endif
/// \brief Returns a view of the subnode matching a fully-qualified "TOML path".
///
/// \see #toml::node::operator[](const toml::path&)
TOML_NODISCARD
node_view<node> operator[](const toml::path& path) noexcept
{
return err_ ? node_view<node>{} : table()[path];
}
/// \brief Returns a const view of the subnode matching a fully-qualified "TOML path".
///
/// \see #toml::node::operator[](const toml::path&)
TOML_NODISCARD
node_view<const node> operator[](const toml::path& path) const noexcept
{
return err_ ? node_view<const node>{} : table()[path];
}
/// \brief Gets a node_view for the selected key-value pair in the wrapped table.
///
/// \param key The key used for the lookup.
@ -356,24 +436,6 @@ TOML_NAMESPACE_START
return err_ ? node_view<const node>{} : table()[key];
}
/// \brief Returns a view of the subnode matching a fully-qualified "TOML path".
///
/// \see #toml::node::at_path(std::string_view)
TOML_NODISCARD
node_view<node> at_path(std::string_view path) noexcept
{
return err_ ? node_view<node>{} : table().at_path(path);
}
/// \brief Returns a const view of the subnode matching a fully-qualified "TOML path".
///
/// \see #toml::node::at_path(std::string_view)
TOML_NODISCARD
node_view<const node> at_path(std::string_view path) const noexcept
{
return err_ ? node_view<const node>{} : table().at_path(path);
}
#if TOML_ENABLE_WINDOWS_COMPAT
/// \brief Gets a node_view for the selected key-value pair in the wrapped table.
@ -387,7 +449,7 @@ TOML_NAMESPACE_START
///
/// \see toml::node_view
TOML_NODISCARD
node_view<node> operator[](std::wstring_view key) noexcept
node_view<node> operator[](std::wstring_view key)
{
return err_ ? node_view<node>{} : table()[key];
}
@ -403,33 +465,11 @@ TOML_NAMESPACE_START
///
/// \see toml::node_view
TOML_NODISCARD
node_view<const node> operator[](std::wstring_view key) const noexcept
node_view<const node> operator[](std::wstring_view key) const
{
return err_ ? node_view<const node>{} : table()[key];
}
/// \brief Returns a view of the subnode matching a fully-qualified "TOML path".
///
/// \availability This overload is only available when #TOML_ENABLE_WINDOWS_COMPAT is enabled.
///
/// \see #toml::node::at_path(std::string_view)
TOML_NODISCARD
node_view<node> at_path(std::wstring_view path) noexcept
{
return err_ ? node_view<node>{} : table().at_path(path);
}
/// \brief Returns a const view of the subnode matching a fully-qualified "TOML path".
///
/// \availability This overload is only available when #TOML_ENABLE_WINDOWS_COMPAT is enabled.
///
/// \see #toml::node::at_path(std::string_view)
TOML_NODISCARD
node_view<const node> at_path(std::wstring_view path) const noexcept
{
return err_ ? node_view<const node>{} : table().at_path(path);
}
#endif // TOML_ENABLE_WINDOWS_COMPAT
/// @}
@ -439,7 +479,7 @@ TOML_NAMESPACE_START
/// \brief Prints the held error or table object out to a text stream.
///
/// \availability This operator is only available when #TOML_ENABLE_FORMATTERS is enabled.
friend std::ostream& TOML_CALLCONV operator<<(std::ostream& os, const parse_result& result)
friend std::ostream& operator<<(std::ostream& os, const parse_result& result)
{
return result.err_ ? (os << result.error()) : (os << result.table());
}

View File

@ -345,7 +345,7 @@ TOML_NAMESPACE_START
/// A toml::parse_result.
TOML_NODISCARD
TOML_ALWAYS_INLINE
parse_result TOML_CALLCONV operator"" _toml(const char* str, size_t len)
parse_result operator"" _toml(const char* str, size_t len)
{
return parse(std::string_view{ str, len });
}
@ -374,7 +374,7 @@ TOML_NAMESPACE_START
/// A toml::parse_result.
TOML_NODISCARD
TOML_ALWAYS_INLINE
parse_result TOML_CALLCONV operator"" _toml(const char8_t* str, size_t len)
parse_result operator"" _toml(const char8_t* str, size_t len)
{
return parse(std::u8string_view{ str, len });
}

View File

@ -608,7 +608,7 @@ TOML_ANON_NAMESPACE_START
template <typename... T>
TOML_CONST_GETTER
TOML_INTERNAL_LINKAGE
constexpr bool TOML_CALLCONV is_match(char32_t codepoint, T... vals) noexcept
constexpr bool is_match(char32_t codepoint, T... vals) noexcept
{
static_assert((std::is_same_v<char32_t, T> && ...));
return ((codepoint == vals) || ...);
@ -3464,7 +3464,7 @@ TOML_IMPL_NAMESPACE_START
current_table->source_.end = eof_pos;
}
static void TOML_CALLCONV update_region_ends(node& nde) noexcept
static void update_region_ends(node& nde) noexcept
{
const auto type = nde.type();
if (type > node_type::array)
@ -3729,14 +3729,14 @@ TOML_ANON_NAMESPACE_START
{
TOML_NODISCARD
TOML_INTERNAL_LINKAGE
parse_result TOML_CALLCONV do_parse(utf8_reader_interface && reader)
parse_result do_parse(utf8_reader_interface && reader)
{
return impl::parser{ std::move(reader) };
}
TOML_NODISCARD
TOML_INTERNAL_LINKAGE
parse_result TOML_CALLCONV do_parse_file(std::string_view file_path)
parse_result do_parse_file(std::string_view file_path)
{
#if TOML_EXCEPTIONS
#define TOML_PARSE_FILE_ERROR(msg, path) \

View File

@ -39,14 +39,14 @@ TOML_NAMESPACE_START
public:
/// \brief Returns true if two path components represent the same key or array index.
TOML_PURE_INLINE_GETTER
friend bool TOML_CALLCONV operator==(const path_component& lhs, const path_component& rhs) noexcept
friend bool operator==(const path_component& lhs, const path_component& rhs) noexcept
{
return equal(lhs, rhs);
}
/// \brief Returns true if two path components do not represent the same key or array index.
TOML_PURE_INLINE_GETTER
friend bool TOML_CALLCONV operator!=(const path_component& lhs, const path_component& rhs) noexcept
friend bool operator!=(const path_component& lhs, const path_component& rhs) noexcept
{
return !equal(lhs, rhs);
}
@ -78,8 +78,6 @@ TOML_NAMESPACE_START
std::vector<path_component> components_;
static bool TOML_CALLCONV parse_into(std::string_view, std::vector<path_component>&);
TOML_EXPORTED_MEMBER_FUNCTION
void print_to(std::ostream&) const;
@ -308,7 +306,7 @@ TOML_NAMESPACE_START
/// \brief Concatenates two paths.
TOML_NODISCARD
friend path TOML_CALLCONV operator+(const path& lhs, const path& rhs)
friend path operator+(const path& lhs, const path& rhs)
{
path result = lhs;
result += rhs;
@ -317,7 +315,7 @@ TOML_NAMESPACE_START
/// \brief Concatenates two paths.
TOML_NODISCARD
friend path TOML_CALLCONV operator+(const path& lhs, std::string_view rhs)
friend path operator+(const path& lhs, std::string_view rhs)
{
path result = lhs;
result += rhs;
@ -326,7 +324,7 @@ TOML_NAMESPACE_START
/// \brief Concatenates two paths.
TOML_NODISCARD
friend path TOML_CALLCONV operator+(std::string_view lhs, const path& rhs)
friend path operator+(std::string_view lhs, const path& rhs)
{
path result = rhs;
result.prepend(lhs);
@ -339,7 +337,7 @@ TOML_NAMESPACE_START
///
/// \availability This overload is only available when #TOML_ENABLE_WINDOWS_COMPAT is enabled.
TOML_NODISCARD
friend path TOML_CALLCONV operator+(const path& lhs, std::wstring_view rhs)
friend path operator+(const path& lhs, std::wstring_view rhs)
{
path result = lhs;
result += rhs;
@ -350,7 +348,7 @@ TOML_NAMESPACE_START
///
/// \availability This overload is only available when #TOML_ENABLE_WINDOWS_COMPAT is enabled.
TOML_NODISCARD
friend path TOML_CALLCONV operator+(std::wstring_view lhs, const path& rhs)
friend path operator+(std::wstring_view lhs, const path& rhs)
{
path result = rhs;
result.prepend(lhs);
@ -366,7 +364,7 @@ TOML_NAMESPACE_START
/// \brief Prints the string representation of a #toml::path out to a stream.
TOML_ALWAYS_INLINE
friend std::ostream& TOML_CALLCONV operator<<(std::ostream& os, const path& rhs)
friend std::ostream& operator<<(std::ostream& os, const path& rhs)
{
rhs.print_to(os);
return os;
@ -414,7 +412,7 @@ TOML_NAMESPACE_START
/// \brief Returns whether two paths are the same.
TOML_NODISCARD
TOML_ALWAYS_INLINE
friend bool TOML_CALLCONV operator==(const path& lhs, const path& rhs) noexcept
friend bool operator==(const path& lhs, const path& rhs) noexcept
{
return equal(lhs, rhs);
}
@ -422,7 +420,7 @@ TOML_NAMESPACE_START
/// \brief Returns whether two paths are not the same.
TOML_NODISCARD
TOML_ALWAYS_INLINE
friend bool TOML_CALLCONV operator!=(const path& lhs, const path& rhs) noexcept
friend bool operator!=(const path& lhs, const path& rhs) noexcept
{
return !equal(lhs, rhs);
}
@ -430,7 +428,7 @@ TOML_NAMESPACE_START
/// \brief Returns whether two paths are the same.
TOML_NODISCARD
TOML_ALWAYS_INLINE
friend bool TOML_CALLCONV operator==(const path& lhs, std::string_view rhs)
friend bool operator==(const path& lhs, std::string_view rhs)
{
return lhs == path{ rhs };
}
@ -438,7 +436,7 @@ TOML_NAMESPACE_START
/// \brief Returns whether two paths are the same.
TOML_NODISCARD
TOML_ALWAYS_INLINE
friend bool TOML_CALLCONV operator==(std::string_view lhs, const path& rhs)
friend bool operator==(std::string_view lhs, const path& rhs)
{
return rhs == lhs;
}
@ -446,7 +444,7 @@ TOML_NAMESPACE_START
/// \brief Returns whether two paths are not the same.
TOML_NODISCARD
TOML_ALWAYS_INLINE
friend bool TOML_CALLCONV operator!=(const path& lhs, std::string_view rhs)
friend bool operator!=(const path& lhs, std::string_view rhs)
{
return lhs != path{ rhs };
}
@ -454,7 +452,7 @@ TOML_NAMESPACE_START
/// \brief Returns whether two paths are not the same.
TOML_NODISCARD
TOML_ALWAYS_INLINE
friend bool TOML_CALLCONV operator!=(std::string_view lhs, const path& rhs)
friend bool operator!=(std::string_view lhs, const path& rhs)
{
return rhs != lhs;
}
@ -466,7 +464,7 @@ TOML_NAMESPACE_START
/// \availability This overload is only available when #TOML_ENABLE_WINDOWS_COMPAT is enabled.
TOML_NODISCARD
TOML_ALWAYS_INLINE
friend bool TOML_CALLCONV operator==(const path& lhs, std::wstring_view rhs)
friend bool operator==(const path& lhs, std::wstring_view rhs)
{
return lhs == path{ rhs };
}
@ -476,7 +474,7 @@ TOML_NAMESPACE_START
/// \availability This overload is only available when #TOML_ENABLE_WINDOWS_COMPAT is enabled.
TOML_NODISCARD
TOML_ALWAYS_INLINE
friend bool TOML_CALLCONV operator==(std::wstring_view lhs, const path& rhs)
friend bool operator==(std::wstring_view lhs, const path& rhs)
{
return rhs == lhs;
}
@ -486,7 +484,7 @@ TOML_NAMESPACE_START
/// \availability This overload is only available when #TOML_ENABLE_WINDOWS_COMPAT is enabled.
TOML_NODISCARD
TOML_ALWAYS_INLINE
friend bool TOML_CALLCONV operator!=(const path& lhs, std::wstring_view rhs)
friend bool operator!=(const path& lhs, std::wstring_view rhs)
{
return lhs != path{ rhs };
}
@ -496,7 +494,7 @@ TOML_NAMESPACE_START
/// \availability This overload is only available when #TOML_ENABLE_WINDOWS_COMPAT is enabled.
TOML_NODISCARD
TOML_ALWAYS_INLINE
friend bool TOML_CALLCONV operator!=(std::wstring_view lhs, const path& rhs)
friend bool operator!=(std::wstring_view lhs, const path& rhs)
{
return rhs != lhs;
}
@ -509,14 +507,14 @@ TOML_NAMESPACE_START
TOML_EXPORTED_MEMBER_FUNCTION
void clear() noexcept;
/// \brief Iterator at the start of the vector of path components (see #path_component)
/// \brief Iterator at the start of the vector of path components (see #toml::path_component)
TOML_NODISCARD
auto begin() const noexcept
{
return components_.begin();
}
/// \brief Iterator at the end of the vector of path components (see #path_component)
/// \brief Iterator at the end of the vector of path components (see #toml::path_component)
TOML_NODISCARD
auto end() const noexcept
{
@ -577,7 +575,7 @@ TOML_NAMESPACE_START
/// \returns A #toml::path generated from the string literal.
TOML_NODISCARD
TOML_ALWAYS_INLINE
path TOML_CALLCONV operator"" _tpath(const char* str, size_t len)
path operator"" _tpath(const char* str, size_t len)
{
return path(std::string_view{ str, len });
}

View File

@ -40,10 +40,10 @@ TOML_NAMESPACE_END;
//# toml::path
//#=====================================================================================================================
TOML_NAMESPACE_START
TOML_ANON_NAMESPACE_START
{
TOML_EXTERNAL_LINKAGE
bool TOML_CALLCONV path::parse_into(std::string_view path_str, std::vector<path_component> & components)
TOML_INTERNAL_LINKAGE
bool parse_path_into(std::string_view path_str, std::vector<path_component> & components)
{
using components_type = std::remove_reference_t<decltype(components)>;
@ -71,7 +71,11 @@ TOML_NAMESPACE_START
return true;
}
}
TOML_ANON_NAMESPACE_END;
TOML_NAMESPACE_START
{
TOML_EXTERNAL_LINKAGE
void path::print_to(std::ostream & os) const
{
@ -105,7 +109,7 @@ TOML_NAMESPACE_START
TOML_EXTERNAL_LINKAGE
path::path(std::string_view str) //
{
parse_into(str, components_);
TOML_ANON_NAMESPACE::parse_path_into(str, components_);
}
#if TOML_ENABLE_WINDOWS_COMPAT
@ -123,7 +127,7 @@ TOML_NAMESPACE_START
path& path::operator=(std::string_view rhs)
{
components_.clear();
parse_into(rhs, components_);
TOML_ANON_NAMESPACE::parse_path_into(rhs, components_);
return *this;
}
@ -158,7 +162,7 @@ TOML_NAMESPACE_START
TOML_EXTERNAL_LINKAGE
path& path::operator+=(std::string_view str)
{
parse_into(str, components_);
TOML_ANON_NAMESPACE::parse_path_into(str, components_);
return *this;
}

View File

@ -429,6 +429,9 @@
#define TOML_EXPORTED_CLASS __declspec(dllimport)
#define TOML_EXPORTED_FREE_FUNCTION __declspec(dllimport)
#endif
#ifndef TOML_CALLCONV
#define TOML_CALLCONV __cdecl
#endif
#elif defined(__GNUC__) && __GNUC__ >= 4
#define TOML_EXPORTED_CLASS __attribute__((visibility("default")))
#define TOML_EXPORTED_MEMBER_FUNCTION __attribute__((visibility("default")))
@ -718,9 +721,9 @@
#endif
#define TOML_ASYMMETRICAL_EQUALITY_OPS(LHS, RHS, ...) \
__VA_ARGS__ TOML_NODISCARD friend bool TOML_CALLCONV operator == (RHS rhs, LHS lhs) noexcept { return lhs == rhs; } \
__VA_ARGS__ TOML_NODISCARD friend bool TOML_CALLCONV operator != (LHS lhs, RHS rhs) noexcept { return !(lhs == rhs); } \
__VA_ARGS__ TOML_NODISCARD friend bool TOML_CALLCONV operator != (RHS rhs, LHS lhs) noexcept { return !(lhs == rhs); } \
__VA_ARGS__ TOML_NODISCARD friend bool operator == (RHS rhs, LHS lhs) noexcept { return lhs == rhs; } \
__VA_ARGS__ TOML_NODISCARD friend bool operator != (LHS lhs, RHS rhs) noexcept { return !(lhs == rhs); } \
__VA_ARGS__ TOML_NODISCARD friend bool operator != (RHS rhs, LHS lhs) noexcept { return !(lhs == rhs); } \
static_assert(true)
#ifndef TOML_SIMPLE_STATIC_ASSERT_MESSAGES
@ -1035,7 +1038,7 @@
/// \def TOML_CALLCONV
/// \brief Calling convention to apply to all free/static functions in the library.
/// \brief Calling convention to apply to exported free/static functions.
/// \detail Not defined by default (let the compiler decide).

View File

@ -112,7 +112,7 @@ TOML_IMPL_NAMESPACE_START
#endif
template <typename T, typename U>
inline void TOML_CALLCONV print_to_stream_bookended(std::ostream & stream, const T& val, const U& bookend)
inline void print_to_stream_bookended(std::ostream & stream, const T& val, const U& bookend)
{
print_to_stream(stream, bookend);
print_to_stream(stream, val);

View File

@ -69,10 +69,7 @@ TOML_ANON_NAMESPACE_START
template <typename T>
TOML_INTERNAL_LINKAGE
void TOML_CALLCONV print_integer_to_stream(std::ostream & stream,
T val,
value_flags format = {},
size_t min_digits = 0)
void print_integer_to_stream(std::ostream & stream, T val, value_flags format = {}, size_t min_digits = 0)
{
if (!val)
{
@ -159,10 +156,10 @@ TOML_ANON_NAMESPACE_START
template <typename T>
TOML_INTERNAL_LINKAGE
void TOML_CALLCONV print_floating_point_to_stream(std::ostream & stream,
T val,
value_flags format,
[[maybe_unused]] bool relaxed_precision)
void print_floating_point_to_stream(std::ostream & stream,
T val,
value_flags format,
[[maybe_unused]] bool relaxed_precision)
{
switch (impl::fpclassify(val))
{

View File

@ -50,38 +50,66 @@ TOML_NAMESPACE_START
source_index column;
/// \brief Returns true if both line and column numbers are non-zero.
TOML_NODISCARD
TOML_PURE_GETTER
explicit constexpr operator bool() const noexcept
{
return line > source_index{} && column > source_index{};
return line > source_index{} //
&& column > source_index{};
}
/// \brief Returns true if two source_positions represent the same line and column.
TOML_NODISCARD
friend constexpr bool TOML_CALLCONV operator==(const source_position& lhs, const source_position& rhs) noexcept
/// \brief Equality operator.
TOML_PURE_GETTER
friend constexpr bool operator==(const source_position& lhs, const source_position& rhs) noexcept
{
return lhs.line == rhs.line && lhs.column == rhs.column;
return lhs.line == rhs.line //
&& lhs.column == rhs.column;
}
/// \brief Returns true if two source_positions do not represent the same line and column.
TOML_NODISCARD
friend constexpr bool TOML_CALLCONV operator!=(const source_position& lhs, const source_position& rhs) noexcept
/// \brief Inequality operator.
TOML_PURE_INLINE_GETTER
friend constexpr bool operator!=(const source_position& lhs, const source_position& rhs) noexcept
{
return lhs.line != rhs.line || lhs.column != rhs.column;
return !(lhs == rhs);
}
/// \brief Returns true if the LHS position is before the RHS position.
TOML_NODISCARD
friend constexpr bool TOML_CALLCONV operator<(const source_position& lhs, const source_position& rhs) noexcept
private:
/// \cond
TOML_PURE_GETTER
static constexpr uint64_t pack(const source_position& pos) noexcept
{
return lhs.line < rhs.line || (lhs.line == rhs.line && lhs.column < rhs.column);
return static_cast<uint64_t>(pos.line) << 32 | static_cast<uint64_t>(pos.column);
}
/// \brief Returns true if the LHS position is before the RHS position or equal to it.
TOML_NODISCARD
friend constexpr bool TOML_CALLCONV operator<=(const source_position& lhs, const source_position& rhs) noexcept
/// \endcond
public:
/// \brief Less-than operator.
TOML_PURE_GETTER
friend constexpr bool operator<(const source_position& lhs, const source_position& rhs) noexcept
{
return lhs.line < rhs.line || (lhs.line == rhs.line && lhs.column <= rhs.column);
return pack(lhs) < pack(rhs);
}
/// \brief Less-than-or-equal-to operator.
TOML_PURE_GETTER
friend constexpr bool operator<=(const source_position& lhs, const source_position& rhs) noexcept
{
return pack(lhs) <= pack(rhs);
}
/// \brief Greater-than operator.
TOML_PURE_GETTER
friend constexpr bool operator>(const source_position& lhs, const source_position& rhs) noexcept
{
return pack(lhs) > pack(rhs);
}
/// \brief Greater-than-or-equal-to operator.
TOML_PURE_GETTER
friend constexpr bool operator>=(const source_position& lhs, const source_position& rhs) noexcept
{
return pack(lhs) >= pack(rhs);
}
/// \brief Prints a source_position to a stream.
@ -102,7 +130,7 @@ TOML_NAMESPACE_START
/// \param rhs The source_position.
///
/// \returns The input stream.
friend std::ostream& TOML_CALLCONV operator<<(std::ostream& lhs, const source_position& rhs)
friend std::ostream& operator<<(std::ostream& lhs, const source_position& rhs)
{
impl::print_to_stream(lhs, rhs);
return lhs;
@ -183,7 +211,7 @@ TOML_NAMESPACE_START
/// \param rhs The source_position.
///
/// \returns The input stream.
friend std::ostream& TOML_CALLCONV operator<<(std::ostream& lhs, const source_region& rhs)
friend std::ostream& operator<<(std::ostream& lhs, const source_region& rhs)
{
impl::print_to_stream(lhs, rhs);
return lhs;

View File

@ -149,13 +149,13 @@ TOML_IMPL_NAMESPACE_START
}
TOML_PURE_INLINE_GETTER
friend bool TOML_CALLCONV operator==(const table_iterator& lhs, const table_iterator& rhs) noexcept
friend bool operator==(const table_iterator& lhs, const table_iterator& rhs) noexcept
{
return lhs.iter_ == rhs.iter_;
}
TOML_PURE_INLINE_GETTER
friend bool TOML_CALLCONV operator!=(const table_iterator& lhs, const table_iterator& rhs) noexcept
friend bool operator!=(const table_iterator& lhs, const table_iterator& rhs) noexcept
{
return lhs.iter_ != rhs.iter_;
}
@ -881,8 +881,7 @@ TOML_NAMESPACE_START
// clang-format on
template <typename Func, typename Table>
static void TOML_CALLCONV do_for_each(Func&& visitor,
Table&& tbl) noexcept(for_each_is_nothrow<Func&&, Table&&>)
static void do_for_each(Func&& visitor, Table&& tbl) noexcept(for_each_is_nothrow<Func&&, Table&&>)
{
static_assert(can_for_each_any<Func&&, Table&&>,
"TOML table for_each visitors must be invocable for at least one of the toml::node "
@ -1823,6 +1822,10 @@ TOML_NAMESPACE_START
/// \name Node views
/// @{
/// \cond
using node::operator[]; // inherit operator[toml::path]
/// \endcond
/// \brief Gets a node_view for the selected value.
///
/// \param key The key used for the lookup.
@ -1857,40 +1860,6 @@ TOML_NAMESPACE_START
return node_view<const node>{ get(key) };
}
/// \brief Gets a node_view for the provided path.
///
/// \param path The "TOML path" to the desired key.
///
/// \returns A view of the value at the given path if one existed, or an empty node view.
///
/// \remarks std::map::operator[]'s behaviour of default-constructing a value at a key if it
/// didn't exist is a crazy bug factory so I've deliberately chosen not to emulate it.
/// <strong>This is not an error.</strong>
///
/// \see toml::node_view
TOML_NODISCARD
node_view<node> operator[](const toml::path& path) noexcept
{
return node_view<node>{ at_path(path) };
}
/// \brief Gets a node_view for the provided path (const overload).
///
/// \param path The "TOML path" to the desired key.
///
/// \returns A view of the value at the given path if one existed, or an empty node view.
///
/// \remarks std::map::operator[]'s behaviour of default-constructing a value at a key if it
/// didn't exist is a crazy bug factory so I've deliberately chosen not to emulate it.
/// <strong>This is not an error.</strong>
///
/// \see toml::node_view
TOML_NODISCARD
node_view<const node> operator[](const toml::path& path) const noexcept
{
return node_view<const node>{ at_path(path) };
}
#if TOML_ENABLE_WINDOWS_COMPAT
/// \brief Gets a node_view for the selected value.
@ -1907,7 +1876,7 @@ TOML_NAMESPACE_START
///
/// \see toml::node_view
TOML_NODISCARD
node_view<node> operator[](std::wstring_view key) noexcept
node_view<node> operator[](std::wstring_view key)
{
return node_view<node>{ get(key) };
}
@ -1926,7 +1895,7 @@ TOML_NAMESPACE_START
///
/// \see toml::node_view
TOML_NODISCARD
node_view<const node> operator[](std::wstring_view key) const noexcept
node_view<const node> operator[](std::wstring_view key) const
{
return node_view<const node>{ get(key) };
}
@ -1954,7 +1923,7 @@ TOML_NAMESPACE_START
///
/// \returns True if the tables contained the same keys and map.
TOML_NODISCARD
friend bool TOML_CALLCONV operator==(const table& lhs, const table& rhs) noexcept
friend bool operator==(const table& lhs, const table& rhs) noexcept
{
return equal(lhs, rhs);
}
@ -1966,7 +1935,7 @@ TOML_NAMESPACE_START
///
/// \returns True if the tables did not contain the same keys and map.
TOML_NODISCARD
friend bool TOML_CALLCONV operator!=(const table& lhs, const table& rhs) noexcept
friend bool operator!=(const table& lhs, const table& rhs) noexcept
{
return !equal(lhs, rhs);
}
@ -1978,7 +1947,7 @@ TOML_NAMESPACE_START
/// \brief Prints the table out to a stream as formatted TOML.
///
/// \availability This operator is only available when #TOML_ENABLE_FORMATTERS is enabled.
friend std::ostream& TOML_CALLCONV operator<<(std::ostream& lhs, const table& rhs)
friend std::ostream& operator<<(std::ostream& lhs, const table& rhs)
{
impl::print_to_stream(lhs, rhs);
return lhs;

View File

@ -131,7 +131,7 @@ TOML_NAMESPACE_START
#endif
/// \brief Prints the bound TOML object out to the stream as formatted TOML.
friend std::ostream& TOML_CALLCONV operator<<(std::ostream& lhs, toml_formatter& rhs)
friend std::ostream& operator<<(std::ostream& lhs, toml_formatter& rhs)
{
rhs.attach(lhs);
rhs.key_path_.clear();
@ -141,7 +141,7 @@ TOML_NAMESPACE_START
}
/// \brief Prints the bound TOML object out to the stream as formatted TOML (rvalue overload).
friend std::ostream& TOML_CALLCONV operator<<(std::ostream& lhs, toml_formatter&& rhs)
friend std::ostream& operator<<(std::ostream& lhs, toml_formatter&& rhs)
{
return lhs << rhs; // as lvalue
}

View File

@ -24,7 +24,7 @@ TOML_DISABLE_ARITHMETIC_WARNINGS;
TOML_ANON_NAMESPACE_START
{
TOML_INTERNAL_LINKAGE
size_t TOML_CALLCONV toml_formatter_count_inline_columns(const node& node, size_t line_wrap_cols) noexcept
size_t toml_formatter_count_inline_columns(const node& node, size_t line_wrap_cols) noexcept
{
switch (node.type())
{
@ -107,9 +107,7 @@ TOML_ANON_NAMESPACE_START
}
TOML_INTERNAL_LINKAGE
bool TOML_CALLCONV toml_formatter_forces_multiline(const node& node,
size_t line_wrap_cols,
size_t starting_column_bias) noexcept
bool toml_formatter_forces_multiline(const node& node, size_t line_wrap_cols, size_t starting_column_bias) noexcept
{
return (toml_formatter_count_inline_columns(node, line_wrap_cols) + starting_column_bias) >= line_wrap_cols;
}

View File

@ -11,44 +11,44 @@
TOML_IMPL_NAMESPACE_START
{
TOML_CONST_GETTER
constexpr bool TOML_CALLCONV is_string_delimiter(char32_t c) noexcept
constexpr bool is_string_delimiter(char32_t c) noexcept
{
return c == U'"' || c == U'\'';
}
TOML_CONST_GETTER
constexpr bool TOML_CALLCONV is_ascii_letter(char32_t c) noexcept
constexpr bool is_ascii_letter(char32_t c) noexcept
{
return (c >= U'a' && c <= U'z') || (c >= U'A' && c <= U'Z');
}
TOML_CONST_GETTER
constexpr bool TOML_CALLCONV is_binary_digit(char32_t c) noexcept
constexpr bool is_binary_digit(char32_t c) noexcept
{
return c == U'0' || c == U'1';
}
TOML_CONST_GETTER
constexpr bool TOML_CALLCONV is_octal_digit(char32_t c) noexcept
constexpr bool is_octal_digit(char32_t c) noexcept
{
return (c >= U'0' && c <= U'7');
}
TOML_CONST_GETTER
constexpr bool TOML_CALLCONV is_decimal_digit(char32_t c) noexcept
constexpr bool is_decimal_digit(char32_t c) noexcept
{
return (c >= U'0' && c <= U'9');
}
TOML_CONST_GETTER
constexpr bool TOML_CALLCONV is_hexadecimal_digit(char32_t c) noexcept
constexpr bool is_hexadecimal_digit(char32_t c) noexcept
{
return U'0' <= c && c <= U'f' && (1ull << (static_cast<uint_least64_t>(c) - 0x30u)) & 0x7E0000007E03FFull;
}
template <typename T>
TOML_CONST_GETTER
constexpr uint_least32_t TOML_CALLCONV hex_to_dec(const T c) noexcept
constexpr uint_least32_t hex_to_dec(const T c) noexcept
{
if constexpr (std::is_same_v<remove_cvref<T>, uint_least32_t>)
return c >= 0x41u // >= 'A'
@ -60,25 +60,25 @@ TOML_IMPL_NAMESPACE_START
}
TOML_CONST_GETTER
constexpr bool TOML_CALLCONV is_horizontal_whitespace(char32_t c) noexcept
constexpr bool is_horizontal_whitespace(char32_t c) noexcept
{
return is_ascii_horizontal_whitespace(c) || is_non_ascii_horizontal_whitespace(c);
}
TOML_CONST_GETTER
constexpr bool TOML_CALLCONV is_vertical_whitespace(char32_t c) noexcept
constexpr bool is_vertical_whitespace(char32_t c) noexcept
{
return is_ascii_vertical_whitespace(c) || is_non_ascii_vertical_whitespace(c);
}
TOML_CONST_GETTER
constexpr bool TOML_CALLCONV is_whitespace(char32_t c) noexcept
constexpr bool is_whitespace(char32_t c) noexcept
{
return is_horizontal_whitespace(c) || is_vertical_whitespace(c);
}
TOML_CONST_GETTER
constexpr bool TOML_CALLCONV is_bare_key_character(char32_t c) noexcept
constexpr bool is_bare_key_character(char32_t c) noexcept
{
return is_ascii_bare_key_character(c)
#if TOML_LANG_UNRELEASED // toml/pull/891 (unicode bare keys)
@ -88,31 +88,31 @@ TOML_IMPL_NAMESPACE_START
}
TOML_CONST_GETTER
constexpr bool TOML_CALLCONV is_value_terminator(char32_t c) noexcept
constexpr bool is_value_terminator(char32_t c) noexcept
{
return is_whitespace(c) || c == U']' || c == U'}' || c == U',' || c == U'#';
}
TOML_CONST_GETTER
constexpr bool TOML_CALLCONV is_control_character(char c) noexcept
constexpr bool is_control_character(char c) noexcept
{
return c <= '\u001F' || c == '\u007F';
}
TOML_CONST_GETTER
constexpr bool TOML_CALLCONV is_control_character(char32_t c) noexcept
constexpr bool is_control_character(char32_t c) noexcept
{
return c <= U'\u001F' || c == U'\u007F';
}
TOML_CONST_GETTER
constexpr bool TOML_CALLCONV is_nontab_control_character(char32_t c) noexcept
constexpr bool is_nontab_control_character(char32_t c) noexcept
{
return c <= U'\u0008' || (c >= U'\u000A' && c <= U'\u001F') || c == U'\u007F';
}
TOML_CONST_GETTER
constexpr bool TOML_CALLCONV is_unicode_surrogate(char32_t c) noexcept
constexpr bool is_unicode_surrogate(char32_t c) noexcept
{
return c >= 0xD800u && c <= 0xDFFF;
}
@ -189,7 +189,7 @@ TOML_IMPL_NAMESPACE_START
TOML_PURE_GETTER
TOML_ATTR(nonnull)
bool TOML_CALLCONV is_ascii(const char* str, size_t len) noexcept;
bool is_ascii(const char* str, size_t len) noexcept;
}
TOML_IMPL_NAMESPACE_END;

View File

@ -18,7 +18,7 @@
TOML_IMPL_NAMESPACE_START
{
TOML_EXTERNAL_LINKAGE
bool TOML_CALLCONV is_ascii(const char* str, size_t len) noexcept
bool is_ascii(const char* str, size_t len) noexcept
{
const char* const end = str + len;

View File

@ -18,13 +18,13 @@
TOML_IMPL_NAMESPACE_START
{
TOML_CONST_GETTER
constexpr bool TOML_CALLCONV is_ascii_horizontal_whitespace(char32_t c) noexcept
constexpr bool is_ascii_horizontal_whitespace(char32_t c) noexcept
{
return c == U'\t' || c == U' ';
}
TOML_CONST_GETTER
constexpr bool TOML_CALLCONV is_non_ascii_horizontal_whitespace(char32_t c) noexcept
constexpr bool is_non_ascii_horizontal_whitespace(char32_t c) noexcept
{
// 20 code units from 8 ranges (spanning a search area of 65120)
@ -48,19 +48,19 @@ TOML_IMPL_NAMESPACE_START
}
TOML_CONST_GETTER
constexpr bool TOML_CALLCONV is_ascii_vertical_whitespace(char32_t c) noexcept
constexpr bool is_ascii_vertical_whitespace(char32_t c) noexcept
{
return c >= U'\n' && c <= U'\r';
}
TOML_CONST_GETTER
constexpr bool TOML_CALLCONV is_non_ascii_vertical_whitespace(char32_t c) noexcept
constexpr bool is_non_ascii_vertical_whitespace(char32_t c) noexcept
{
return (U'\u2028' <= c && c <= U'\u2029') || c == U'\x85';
}
TOML_CONST_GETTER
constexpr bool TOML_CALLCONV is_ascii_bare_key_character(char32_t c) noexcept
constexpr bool is_ascii_bare_key_character(char32_t c) noexcept
{
#if TOML_LANG_UNRELEASED // toml/issues/644 ('+' in bare keys)
if TOML_UNLIKELY(c == U'+')
@ -78,7 +78,7 @@ TOML_IMPL_NAMESPACE_START
#if TOML_LANG_UNRELEASED // toml/pull/891 (unicode bare keys)
TOML_CONST_GETTER
constexpr bool TOML_CALLCONV is_non_ascii_bare_key_character(char32_t c) noexcept
constexpr bool is_non_ascii_bare_key_character(char32_t c) noexcept
{
// 971732 code units from 16 ranges (spanning a search area of 982862)

View File

@ -80,7 +80,7 @@ TOML_IMPL_NAMESPACE_START
{
template <typename... Args>
TOML_NODISCARD
static T TOML_CALLCONV make(Args&&... args) noexcept(std::is_nothrow_constructible_v<T, Args&&...>)
static T make(Args&&... args) noexcept(std::is_nothrow_constructible_v<T, Args&&...>)
{
if constexpr (std::is_aggregate_v<T>)
return T{ static_cast<Args&&>(args)... };
@ -95,7 +95,7 @@ TOML_IMPL_NAMESPACE_START
template <typename U>
TOML_NODISCARD
TOML_ALWAYS_INLINE
static U&& TOML_CALLCONV make(U&& val) noexcept
static U&& make(U&& val) noexcept
{
return static_cast<U&&>(val);
}
@ -107,7 +107,7 @@ TOML_IMPL_NAMESPACE_START
{
template <typename T>
TOML_NODISCARD
static std::string TOML_CALLCONV make(T&& arg) noexcept
static std::string make(T&& arg) noexcept
{
using arg_type = std::decay_t<T>;
#if TOML_HAS_CHAR8
@ -221,7 +221,7 @@ TOML_NAMESPACE_START
template <typename T, typename U>
TOML_CONST_INLINE_GETTER
static auto TOML_CALLCONV as_value([[maybe_unused]] U* ptr) noexcept
static auto as_value([[maybe_unused]] U* ptr) noexcept
{
if constexpr (std::is_same_v<value_type, T>)
return ptr;
@ -771,8 +771,8 @@ TOML_NAMESPACE_START
/// @{
/// \brief Value equality operator.
TOML_NODISCARD
friend bool TOML_CALLCONV operator==(const value& lhs, value_arg rhs) noexcept
TOML_PURE_GETTER
friend bool operator==(const value& lhs, value_arg rhs) noexcept
{
if constexpr (std::is_same_v<value_type, double>)
{
@ -788,57 +788,57 @@ TOML_NAMESPACE_START
TOML_ASYMMETRICAL_EQUALITY_OPS(const value&, value_arg, );
/// \brief Value less-than operator.
TOML_NODISCARD
friend bool TOML_CALLCONV operator<(const value& lhs, value_arg rhs) noexcept
TOML_PURE_GETTER
friend bool operator<(const value& lhs, value_arg rhs) noexcept
{
return lhs.val_ < rhs;
}
/// \brief Value less-than operator.
TOML_NODISCARD
friend bool TOML_CALLCONV operator<(value_arg lhs, const value& rhs) noexcept
TOML_PURE_GETTER
friend bool operator<(value_arg lhs, const value& rhs) noexcept
{
return lhs < rhs.val_;
}
/// \brief Value less-than-or-equal-to operator.
TOML_NODISCARD
friend bool TOML_CALLCONV operator<=(const value& lhs, value_arg rhs) noexcept
TOML_PURE_GETTER
friend bool operator<=(const value& lhs, value_arg rhs) noexcept
{
return lhs.val_ <= rhs;
}
/// \brief Value less-than-or-equal-to operator.
TOML_NODISCARD
friend bool TOML_CALLCONV operator<=(value_arg lhs, const value& rhs) noexcept
TOML_PURE_GETTER
friend bool operator<=(value_arg lhs, const value& rhs) noexcept
{
return lhs <= rhs.val_;
}
/// \brief Value greater-than operator.
TOML_NODISCARD
friend bool TOML_CALLCONV operator>(const value& lhs, value_arg rhs) noexcept
TOML_PURE_GETTER
friend bool operator>(const value& lhs, value_arg rhs) noexcept
{
return lhs.val_ > rhs;
}
/// \brief Value greater-than operator.
TOML_NODISCARD
friend bool TOML_CALLCONV operator>(value_arg lhs, const value& rhs) noexcept
TOML_PURE_GETTER
friend bool operator>(value_arg lhs, const value& rhs) noexcept
{
return lhs > rhs.val_;
}
/// \brief Value greater-than-or-equal-to operator.
TOML_NODISCARD
friend bool TOML_CALLCONV operator>=(const value& lhs, value_arg rhs) noexcept
TOML_PURE_GETTER
friend bool operator>=(const value& lhs, value_arg rhs) noexcept
{
return lhs.val_ >= rhs;
}
/// \brief Value greater-than-or-equal-to operator.
TOML_NODISCARD
friend bool TOML_CALLCONV operator>=(value_arg lhs, const value& rhs) noexcept
TOML_PURE_GETTER
friend bool operator>=(value_arg lhs, const value& rhs) noexcept
{
return lhs >= rhs.val_;
}
@ -850,8 +850,8 @@ TOML_NAMESPACE_START
///
/// \returns True if the values were of the same type and contained the same value.
template <typename T>
TOML_NODISCARD
friend bool TOML_CALLCONV operator==(const value& lhs, const value<T>& rhs) noexcept
TOML_PURE_GETTER
friend bool operator==(const value& lhs, const value<T>& rhs) noexcept
{
if constexpr (std::is_same_v<value_type, T>)
return lhs == rhs.val_; // calls asymmetrical value-equality operator defined above
@ -866,8 +866,8 @@ TOML_NAMESPACE_START
///
/// \returns True if the values were not of the same type, or did not contain the same value.
template <typename T>
TOML_NODISCARD
friend bool TOML_CALLCONV operator!=(const value& lhs, const value<T>& rhs) noexcept
TOML_PURE_INLINE_GETTER
friend bool operator!=(const value& lhs, const value<T>& rhs) noexcept
{
return !(lhs == rhs);
}
@ -882,8 +882,8 @@ TOML_NAMESPACE_START
/// \conditional_return{Different value types}
/// `lhs.type() < rhs.type()`
template <typename T>
TOML_NODISCARD
friend bool TOML_CALLCONV operator<(const value& lhs, const value<T>& rhs) noexcept
TOML_PURE_GETTER
friend bool operator<(const value& lhs, const value<T>& rhs) noexcept
{
if constexpr (std::is_same_v<value_type, T>)
return lhs.val_ < rhs.val_;
@ -901,8 +901,8 @@ TOML_NAMESPACE_START
/// \conditional_return{Different value types}
/// `lhs.type() <= rhs.type()`
template <typename T>
TOML_NODISCARD
friend bool TOML_CALLCONV operator<=(const value& lhs, const value<T>& rhs) noexcept
TOML_PURE_GETTER
friend bool operator<=(const value& lhs, const value<T>& rhs) noexcept
{
if constexpr (std::is_same_v<value_type, T>)
return lhs.val_ <= rhs.val_;
@ -920,8 +920,8 @@ TOML_NAMESPACE_START
/// \conditional_return{Different value types}
/// `lhs.type() > rhs.type()`
template <typename T>
TOML_NODISCARD
friend bool TOML_CALLCONV operator>(const value& lhs, const value<T>& rhs) noexcept
TOML_PURE_GETTER
friend bool operator>(const value& lhs, const value<T>& rhs) noexcept
{
if constexpr (std::is_same_v<value_type, T>)
return lhs.val_ > rhs.val_;
@ -939,8 +939,8 @@ TOML_NAMESPACE_START
/// \conditional_return{Different value types}
/// `lhs.type() >= rhs.type()`
template <typename T>
TOML_NODISCARD
friend bool TOML_CALLCONV operator>=(const value& lhs, const value<T>& rhs) noexcept
TOML_PURE_GETTER
friend bool operator>=(const value& lhs, const value<T>& rhs) noexcept
{
if constexpr (std::is_same_v<value_type, T>)
return lhs.val_ >= rhs.val_;
@ -955,7 +955,7 @@ TOML_NAMESPACE_START
/// \brief Prints the value out to a stream as formatted TOML.
///
/// \availability This operator is only available when #TOML_ENABLE_FORMATTERS is enabled.
friend std::ostream& TOML_CALLCONV operator<<(std::ostream& lhs, const value& rhs)
friend std::ostream& operator<<(std::ostream& lhs, const value& rhs)
{
impl::print_to_stream(lhs, rhs);
return lhs;

View File

@ -42,7 +42,6 @@
<ClInclude Include="include\toml++\impl\key.h" />
<ClInclude Include="include\toml++\impl\path.h" />
<ClInclude Include="include\toml++\impl\simd.h" />
<ClInclude Include="include\toml++\impl\std_algorithm.h" />
<ClInclude Include="include\toml++\impl\std_utility.h" />
<ClInclude Include="include\toml++\impl\std_variant.h" />
<ClInclude Include="include\toml++\impl\toml_formatter.h" />

View File

@ -136,8 +136,9 @@
<ClInclude Include="include\toml++\impl\path.h">
<Filter>include\impl</Filter>
</ClInclude>
<ClInclude Include="include\toml++\impl\std_variant.h" />
<ClInclude Include="include\toml++\impl\std_algorithm.h" />
<ClInclude Include="include\toml++\impl\std_variant.h">
<Filter>include\impl</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="toml++.props" />

718
toml.hpp

File diff suppressed because it is too large Load Diff