removed final from value, array and table

also:
- renamed `TOML_WINDOWS_COMPAT` to `TOML_ENABLE_WINDOWS_COMPAT`
- renamed `TOML_UNRELEASED_FEATURES` to `TOML_ENABLE_UNRELEASED_FEATURES`
- added additional tests
- fixed minor documentation issues
This commit is contained in:
Mark Gillard 2021-10-30 17:26:05 +03:00
parent 87d6c7eef1
commit 0ffd23d73f
67 changed files with 1863 additions and 983 deletions

View File

@ -53,7 +53,7 @@ assignees: marzer
**Library configuration overrides:**
<!--
If you've explicitly set any of the library configuration macros,
list them here (e.g. TOML_EXCEPTIONS=0, TOML_UNRELEASED_FEATURES=1, etc.)
list them here (e.g. TOML_EXCEPTIONS=0, TOML_ENABLE_UNRELEASED_FEATURES=1, etc.)
-->

View File

@ -136,22 +136,22 @@ assured that I fully support it being added, and welcome [pull requests](./CONTR
A number of configurable options are exposed in the form of preprocessor `#defines` Most likely you
won't need to mess with these at all, but if you do, set them before including toml++.
| Option | Type | Default | Description |
|--------------------------------|:--------------:|--------------------------|----------------------------------------------------------------------------------------------------------------------|
| `TOML_API` | define | undefined | API annotation to add to public symbols (e.g. `__declspec(dllexport)` on Windows). |
| `TOML_ASSERT(expr)` | function macro | `assert()` | Sets the assert function used by the library. |
| `TOML_CONFIG_HEADER` | string literal | undefined | Includes the given header file before the rest of the library. |
| `TOML_ENABLE_PARSER` | boolean | `1` | Inclusion of the parser. Set to `0` if you don't need it to improve compile times and binary size. |
| `TOML_ENABLE_TOML_FORMATTER` | boolean | `1` | Inclusion of the TOML formatter. Set to `0` if you don't need it to improve compile times and binary size. |
| `TOML_ENABLE_JSON_FORMATTER` | boolean | `1` | Inclusion of the JSON formatter. Set to `0` if you don't need it to improve compile times and binary size. |
| `TOML_EXCEPTIONS` | boolean | your compiler's settings | Sets whether the library uses exceptions. |
| `TOML_HEADER_ONLY` | boolean | `1` | Disable this to explicitly control where toml++'s implementation is compiled (e.g. as part of a library). |
| `TOML_IMPLEMENTATION` | define | undefined | Define this to enable compilation of the library's implementation. Meaningless if `TOML_HEADER_ONLY` is `1`. |
| `TOML_OPTIONAL_TYPE` | type name | undefined | Overrides the `optional<T>` type used by the library if you need [something better than std::optional]. |
| `TOML_SMALL_FLOAT_TYPE` | type name | undefined | If your codebase has an additional 'small' float type (e.g. half-precision), this tells toml++ about it. |
| `TOML_SMALL_INT_TYPE` | type name | undefined | If your codebase has an additional 'small' integer type (e.g. 24-bits), this tells toml++ about it. |
| `TOML_UNRELEASED_FEATURES` | boolean | `0` | Enables support for [unreleased TOML language features] not yet part of a [numbered version]. |
| `TOML_WINDOWS_COMPAT` | boolean | `1` on Windows | Enables support for transparent conversion between wide and narrow strings. |
| Option | Type | Default | Description |
|-----------------------------------|:--------------:|--------------------------|----------------------------------------------------------------------------------------------------------------------|
| `TOML_API` | define | undefined | API annotation to add to public symbols (e.g. `__declspec(dllexport)` on Windows). |
| `TOML_ASSERT(expr)` | function macro | `assert()` | Sets the assert function used by the library. |
| `TOML_CONFIG_HEADER` | string literal | undefined | Includes the given header file before the rest of the library. |
| `TOML_ENABLE_JSON_FORMATTER` | boolean | `1` | Enables the JSON formatter. Set to `0` if you don't need it to improve compile times and binary size. |
| `TOML_ENABLE_TOML_FORMATTER` | boolean | `1` | Enables the TOML formatter. Set to `0` if you don't need it to improve compile times and binary size. |
| `TOML_ENABLE_PARSER` | boolean | `1` | Enables the parser. Set to `0` if you don't need it to improve compile times and binary size. |
| `TOML_ENABLE_UNRELEASED_FEATURES` | boolean | `0` | Enables support for [unreleased TOML language features. |
| `TOML_ENABLE_WINDOWS_COMPAT` | boolean | `1` on Windows | Enables support for transparent conversion between wide and narrow strings. |
| `TOML_EXCEPTIONS` | boolean | your compiler's settings | Sets whether the library uses exceptions. |
| `TOML_HEADER_ONLY` | boolean | `1` | Disable this to explicitly control where toml++'s implementation is compiled (e.g. as part of a library). |
| `TOML_IMPLEMENTATION` | define | undefined | Define this to enable compilation of the library's implementation when `TOML_HEADER_ONLY` == `0`. |
| `TOML_OPTIONAL_TYPE` | type name | undefined | Overrides the `optional<T>` type used by the library if you need [something better than std::optional]. |
| `TOML_SMALL_FLOAT_TYPE` | type name | undefined | If your codebase has an additional 'small' float type (e.g. half-precision), this tells toml++ about it. |
| `TOML_SMALL_INT_TYPE` | type name | undefined | If your codebase has an additional 'small' integer type (e.g. 24-bits), this tells toml++ about it. |
> &#xFE0F; _A number of these have ABI implications; the library uses inline namespaces to prevent you from accidentally
linking incompatible combinations together._
@ -174,7 +174,7 @@ defines `TOML_LANG_MAJOR`, `TOML_LANG_MINOR` and `TOML_LANG_PATCH`.
- [#687]: Relax bare key restrictions to allow additional unicode characters
- [#709]: Include an \xHH escape code sequence
> &#xFE0F; _`#define TOML_UNRELEASED_FEATURES 1` to enable these features (see [Configuration](#Configuration))._
> &#xFE0F; _`#define TOML_ENABLE_UNRELEASED_FEATURES 1` to enable these features (see [Configuration](#Configuration))._
### 🔹&#xFE0F; **TOML v1.0.0:**
All features supported, including:
@ -215,13 +215,13 @@ UTF-8 decoding is performed using a state machine based on Bjoern Hoehrmann's '[
- **[@Reedbeta](https://github.com/Reedbeta)** - Fixed a bug and added additional Visual Studio debugger native visualizers
- **[@Ryan-rsm-McKenzie](https://github.com/Ryan-rsm-McKenzie)** - Add natvis file to cmake install script
- **[@shdnx](https://github.com/shdnx)** - Fixed a bug on GCC 8.2.0 and some meson config issues
- **[@sobczyk](https://github.com/sobczyk)** - Reported some bugs
- **[@sneves](https://github.com/sneves)** - Helped fix a number of parser bugs
- **[@sobczyk](https://github.com/sobczyk)** - Reported some bugs
- **[@std-any-emplace](https://github.com/std-any-emplace)** - Reported some bugs
- **[@traversaro](https://github.com/traversaro)** - Added vcpkg support and reported a bunch of bugs
- **[@ximion](https://github.com/ximion)** - Added support for installation with meson
- **[@whiterabbit963](https://github.com/whiterabbit963)** - Fixed a bug with value_or conversions
- **[@Tachi107](https://github.com/Tachi107)** - Made some tweaks to meson.build
- **[@traversaro](https://github.com/traversaro)** - Added vcpkg support and reported a bunch of bugs
- **[@whiterabbit963](https://github.com/whiterabbit963)** - Fixed a bug with value_or conversions
- **[@ximion](https://github.com/ximion)** - Added support for installation with meson
<br>

View File

@ -8,8 +8,8 @@
#include "examples.h"
#define TOML_EXCEPTIONS 0
#define TOML_UNRELEASED_FEATURES 0
#define TOML_EXCEPTIONS 0
#define TOML_ENABLE_UNRELEASED_FEATURES 0
#include <toml++/toml.h>
using namespace std::string_view_literals;
@ -24,10 +24,10 @@ namespace
"########## inline tables"sv,
"val = {,}"sv,
"val = {a='b',}"sv, // allowed when TOML_UNRELEASED_FEATURES == 1
"val = {a='b',}"sv, // allowed when TOML_ENABLE_UNRELEASED_FEATURES == 1
"val = {a='b',,}"sv,
"val = {a='b',"sv,
"val = {a='b',\n c='d'}"sv, // allowed when TOML_UNRELEASED_FEATURES == 1
"val = {a='b',\n c='d'}"sv, // allowed when TOML_ENABLE_UNRELEASED_FEATURES == 1
"val = {?='b'}"sv,
"########## tables"sv,
@ -68,7 +68,7 @@ namespace
"val = \" \r \""sv,
R"(val = ")"sv,
R"(val = "\g")"sv,
R"(val = "\x20")"sv, // allowed when TOML_UNRELEASED_FEATURES == 1
R"(val = "\x20")"sv, // allowed when TOML_ENABLE_UNRELEASED_FEATURES == 1
R"(val = "\uFFF")"sv,
R"(val = "\uFFFG")"sv,
R"(val = "\UFFFFFFF")"sv,

View File

@ -7,7 +7,7 @@
#include "examples.h"
#define TOML_UNRELEASED_FEATURES 1
#define TOML_ENABLE_UNRELEASED_FEATURES 1
#include <toml++/toml.h>
using namespace std::string_view_literals;

View File

@ -7,7 +7,7 @@
#include "examples.h"
#define TOML_UNRELEASED_FEATURES 1
#define TOML_ENABLE_UNRELEASED_FEATURES 1
#include <toml++/toml.h>
using namespace std::string_view_literals;

2
external/toml-test vendored

@ -1 +1 @@
Subproject commit f2f2280c83f74212860fe0f12ee84581836c066c
Subproject commit 643fd7585441148f5d7ff6d1eb1de62292fa900f

View File

@ -243,7 +243,7 @@ TOML_NAMESPACE_START
/// [ 3, 4, 5, 'six', 7, 8.0, 'nine' ]
/// [ 3, 4, 5, 'six', 7, 8.0, 'nine', 'ten', [ 11, 12.0 ] ]
/// \eout
class array final : public node
class array : public node
{
private:
/// \cond
@ -378,44 +378,28 @@ TOML_NAMESPACE_START
/// \name Type checks
/// @{
TOML_NODISCARD
/// \brief Returns #toml::node_type::array.
TOML_CONST_INLINE_GETTER
node_type type() const noexcept final
{
return node_type::array;
}
TOML_NODISCARD
bool is_array() const noexcept final
{
return true;
}
TOML_NODISCARD
array* as_array() noexcept final
{
return this;
}
TOML_NODISCARD
const array* as_array() const noexcept final
{
return this;
}
TOML_NODISCARD
TOML_PURE_GETTER
TOML_API
bool is_homogeneous(node_type ntype) const noexcept final;
TOML_NODISCARD
TOML_PURE_GETTER
TOML_API
bool is_homogeneous(node_type ntype, node*& first_nonmatch) noexcept final;
TOML_NODISCARD
TOML_PURE_GETTER
TOML_API
bool is_homogeneous(node_type ntype, const node*& first_nonmatch) const noexcept final;
/// \cond
template <typename ElemType = void>
TOML_NODISCARD
TOML_PURE_GETTER
bool is_homogeneous() const noexcept
{
using type = impl::unwrap_node<ElemType>;
@ -426,13 +410,223 @@ TOML_NAMESPACE_START
"of:" TOML_SA_UNWRAPPED_NODE_TYPE_LIST);
return is_homogeneous(impl::node_type_of<type>);
}
/// \endcond
TOML_NODISCARD
/// \brief Returns `false`.
TOML_CONST_INLINE_GETTER
bool is_table() const noexcept final
{
return false;
}
/// \brief Returns `true`.
TOML_CONST_INLINE_GETTER
bool is_array() const noexcept final
{
return true;
}
/// \brief Returns `true` if the array contains only tables.
TOML_PURE_GETTER
bool is_array_of_tables() const noexcept final
{
return is_homogeneous(node_type::table);
}
/// \brief Returns `false`.
TOML_CONST_INLINE_GETTER
bool is_value() const noexcept final
{
return false;
}
/// \brief Returns `false`.
TOML_CONST_INLINE_GETTER
bool is_string() const noexcept final
{
return false;
}
/// \brief Returns `false`.
TOML_CONST_INLINE_GETTER
bool is_integer() const noexcept final
{
return false;
}
/// \brief Returns `false`.
TOML_CONST_INLINE_GETTER
bool is_floating_point() const noexcept final
{
return false;
}
/// \brief Returns `false`.
TOML_CONST_INLINE_GETTER
bool is_number() const noexcept final
{
return false;
}
/// \brief Returns `false`.
TOML_CONST_INLINE_GETTER
bool is_boolean() const noexcept final
{
return false;
}
/// \brief Returns `false`.
TOML_CONST_INLINE_GETTER
bool is_date() const noexcept final
{
return false;
}
/// \brief Returns `false`.
TOML_CONST_INLINE_GETTER
bool is_time() const noexcept final
{
return false;
}
/// \brief Returns `false`.
TOML_CONST_INLINE_GETTER
bool is_date_time() const noexcept final
{
return false;
}
/// @}
/// \name Type casts
/// @{
/// \brief Returns `nullptr`.
TOML_CONST_INLINE_GETTER
table* as_table() noexcept final
{
return nullptr;
}
/// \brief Returns a pointer to the array.
TOML_CONST_INLINE_GETTER
array* as_array() noexcept final
{
return this;
}
/// \brief Returns `nullptr`.
TOML_CONST_INLINE_GETTER
toml::value<std::string>* as_string() noexcept final
{
return nullptr;
}
/// \brief Returns `nullptr`.
TOML_CONST_INLINE_GETTER
toml::value<int64_t>* as_integer() noexcept final
{
return nullptr;
}
/// \brief Returns `nullptr`.
TOML_CONST_INLINE_GETTER
toml::value<double>* as_floating_point() noexcept final
{
return nullptr;
}
/// \brief Returns `nullptr`.
TOML_CONST_INLINE_GETTER
toml::value<bool>* as_boolean() noexcept final
{
return nullptr;
}
/// \brief Returns `nullptr`.
TOML_CONST_INLINE_GETTER
toml::value<date>* as_date() noexcept final
{
return nullptr;
}
/// \brief Returns `nullptr`.
TOML_CONST_INLINE_GETTER
toml::value<time>* as_time() noexcept final
{
return nullptr;
}
/// \brief Returns `nullptr`.
TOML_CONST_INLINE_GETTER
toml::value<date_time>* as_date_time() noexcept final
{
return nullptr;
}
/// \brief Returns `nullptr`.
TOML_CONST_INLINE_GETTER
const table* as_table() const noexcept final
{
return nullptr;
}
/// \brief Returns a const-qualified pointer to the array.
TOML_CONST_INLINE_GETTER
const array* as_array() const noexcept final
{
return this;
}
/// \brief Returns `nullptr`.
TOML_CONST_INLINE_GETTER
const toml::value<std::string>* as_string() const noexcept final
{
return nullptr;
}
/// \brief Returns `nullptr`.
TOML_CONST_INLINE_GETTER
const toml::value<int64_t>* as_integer() const noexcept final
{
return nullptr;
}
/// \brief Returns `nullptr`.
TOML_CONST_INLINE_GETTER
const toml::value<double>* as_floating_point() const noexcept final
{
return nullptr;
}
/// \brief Returns `nullptr`.
TOML_CONST_INLINE_GETTER
const toml::value<bool>* as_boolean() const noexcept final
{
return nullptr;
}
/// \brief Returns `nullptr`.
TOML_CONST_INLINE_GETTER
const toml::value<date>* as_date() const noexcept final
{
return nullptr;
}
/// \brief Returns `nullptr`.
TOML_CONST_INLINE_GETTER
const toml::value<time>* as_time() const noexcept final
{
return nullptr;
}
/// \brief Returns `nullptr`.
TOML_CONST_INLINE_GETTER
const toml::value<date_time>* as_date_time() const noexcept final
{
return nullptr;
}
/// @}
/// \name Array operations
@ -857,7 +1051,7 @@ TOML_NAMESPACE_START
///
/// \param new_size The number of elements the array will have after resizing.
/// \param default_init_val The node or value used to initialize new elements if the array needs to grow.
/// \param flags Value flags to apply to new values created if new elements are created by growing.
/// \param default_init_flags Value flags to apply to new values created if new elements are created by growing.
template <typename ElemType>
void resize(size_t new_size,
ElemType&& default_init_val,

View File

@ -241,7 +241,6 @@ TOML_NAMESPACE_START // abi namespace
/// auto arr = toml::array{ 1, 2.0, "3", false };
/// for (size_t i = 0; i < arr.size() i++)
/// std::cout << "Element ["sv << i << "] is: "sv << arr[i].type() << "\n";
///
/// \ecpp
///
/// \out
@ -661,7 +660,7 @@ TOML_IMPL_NAMESPACE_START
#endif
// string value_traits specializations - wchar_t-based strings on Windows
#if TOML_WINDOWS_COMPAT
#if TOML_ENABLE_WINDOWS_COMPAT
template <typename T>
struct wstring_value_traits
{

View File

@ -42,15 +42,15 @@ TOML_IMPL_NAMESPACE_START
// creating from raw value
else
{
static_assert(!is_wide_string<T> || TOML_WINDOWS_COMPAT,
static_assert(!is_wide_string<T> || TOML_ENABLE_WINDOWS_COMPAT,
"Instantiating values from wide-character strings is only "
"supported on Windows with TOML_WINDOWS_COMPAT enabled.");
"supported on Windows with TOML_ENABLE_WINDOWS_COMPAT enabled.");
static_assert(is_native<unwrapped_type> || is_losslessly_convertible_to_native<unwrapped_type>,
"Value initializers must be (or be promotable to) one of the TOML value types");
if constexpr (is_wide_string<T>)
{
#if TOML_WINDOWS_COMPAT
#if TOML_ENABLE_WINDOWS_COMPAT
out = new value_type{ narrow(static_cast<T&&>(val)) };
#else
static_assert(dependent_false<T>, "Evaluated unreachable branch!");

View File

@ -90,127 +90,6 @@ TOML_NAMESPACE_START
/// \name Type checks
/// @{
/// \brief Returns the node's type identifier.
TOML_NODISCARD
virtual node_type type() const noexcept = 0;
/// \brief Returns true if this node is a table.
TOML_PURE_INLINE_GETTER
virtual bool is_table() const noexcept
{
return false;
}
/// \brief Returns true if this node is an array.
TOML_PURE_INLINE_GETTER
virtual bool is_array() const noexcept
{
return false;
}
/// \brief Returns true if this node is a value.
TOML_PURE_INLINE_GETTER
virtual bool is_value() const noexcept
{
return false;
}
/// \brief Returns true if this node is a string value.
TOML_PURE_INLINE_GETTER
virtual bool is_string() const noexcept
{
return false;
}
/// \brief Returns true if this node is an integer value.
TOML_PURE_INLINE_GETTER
virtual bool is_integer() const noexcept
{
return false;
}
/// \brief Returns true if this node is an floating-point value.
TOML_PURE_INLINE_GETTER
virtual bool is_floating_point() const noexcept
{
return false;
}
/// \brief Returns true if this node is an integer or floating-point value.
TOML_PURE_INLINE_GETTER
virtual bool is_number() const noexcept
{
return false;
}
/// \brief Returns true if this node is a boolean value.
TOML_PURE_INLINE_GETTER
virtual bool is_boolean() const noexcept
{
return false;
}
/// \brief Returns true if this node is a local date value.
TOML_PURE_INLINE_GETTER
virtual bool is_date() const noexcept
{
return false;
}
/// \brief Returns true if this node is a local time value.
TOML_PURE_INLINE_GETTER
virtual bool is_time() const noexcept
{
return false;
}
/// \brief Returns true if this node is a date-time value.
TOML_PURE_INLINE_GETTER
virtual bool is_date_time() const noexcept
{
return false;
}
/// \brief Returns true if this node is an array containing only tables.
TOML_PURE_INLINE_GETTER
virtual bool is_array_of_tables() const noexcept
{
return false;
}
/// \brief Checks if a node is a specific type.
///
/// \tparam T A TOML node or value type.
///
/// \returns Returns true if this node is an instance of the specified type.
template <typename T>
TOML_PURE_INLINE_GETTER
bool is() const noexcept
{
using type = impl::unwrap_node<T>;
static_assert((impl::is_native<type> || impl::is_one_of<type, table, array>)&&!impl::is_cvref<type>,
"The template type argument of node::is() must be one of:" TOML_SA_UNWRAPPED_NODE_TYPE_LIST);
if constexpr (std::is_same_v<type, table>)
return is_table();
else if constexpr (std::is_same_v<type, array>)
return is_array();
else if constexpr (std::is_same_v<type, std::string>)
return is_string();
else if constexpr (std::is_same_v<type, int64_t>)
return is_integer();
else if constexpr (std::is_same_v<type, double>)
return is_floating_point();
else if constexpr (std::is_same_v<type, bool>)
return is_boolean();
else if constexpr (std::is_same_v<type, date>)
return is_date();
else if constexpr (std::is_same_v<type, time>)
return is_time();
else if constexpr (std::is_same_v<type, date_time>)
return is_date_time();
}
/// \brief Checks if a node contains values/elements of only one type.
///
/// \detail \cpp
@ -242,11 +121,11 @@ TOML_NAMESPACE_START
/// \returns True if the node was homogeneous.
///
/// \remarks Always returns `false` for empty tables and arrays.
TOML_NODISCARD
TOML_PURE_GETTER
virtual bool is_homogeneous(node_type ntype, node*& first_nonmatch) noexcept = 0;
/// \brief Checks if a node contains values/elements of only one type (const overload).
TOML_NODISCARD
TOML_PURE_GETTER
virtual bool is_homogeneous(node_type ntype, const node*& first_nonmatch) const noexcept = 0;
/// \brief Checks if the node contains values/elements of only one type.
@ -276,7 +155,7 @@ TOML_NAMESPACE_START
/// \returns True if the node was homogeneous.
///
/// \remarks Always returns `false` for empty tables and arrays.
TOML_NODISCARD
TOML_PURE_GETTER
virtual bool is_homogeneous(node_type ntype) const noexcept = 0;
/// \brief Checks if the node contains values/elements of only one type.
@ -319,127 +198,167 @@ TOML_NAMESPACE_START
return is_homogeneous(impl::node_type_of<type>);
}
/// \brief Returns the node's type identifier.
TOML_PURE_GETTER
virtual node_type type() const noexcept = 0;
/// \brief Returns true if this node is a table.
TOML_PURE_GETTER
virtual bool is_table() const noexcept = 0;
/// \brief Returns true if this node is an array.
TOML_PURE_GETTER
virtual bool is_array() const noexcept = 0;
/// \brief Returns true if this node is an array containing only tables.
TOML_PURE_GETTER
virtual bool is_array_of_tables() const noexcept = 0;
/// \brief Returns true if this node is a value.
TOML_PURE_GETTER
virtual bool is_value() const noexcept = 0;
/// \brief Returns true if this node is a string value.
TOML_PURE_GETTER
virtual bool is_string() const noexcept = 0;
/// \brief Returns true if this node is an integer value.
TOML_PURE_GETTER
virtual bool is_integer() const noexcept = 0;
/// \brief Returns true if this node is an floating-point value.
TOML_PURE_GETTER
virtual bool is_floating_point() const noexcept = 0;
/// \brief Returns true if this node is an integer or floating-point value.
TOML_PURE_GETTER
virtual bool is_number() const noexcept = 0;
/// \brief Returns true if this node is a boolean value.
TOML_PURE_GETTER
virtual bool is_boolean() const noexcept = 0;
/// \brief Returns true if this node is a local date value.
TOML_PURE_GETTER
virtual bool is_date() const noexcept = 0;
/// \brief Returns true if this node is a local time value.
TOML_PURE_GETTER
virtual bool is_time() const noexcept = 0;
/// \brief Returns true if this node is a date-time value.
TOML_PURE_GETTER
virtual bool is_date_time() const noexcept = 0;
/// \brief Checks if a node is a specific type.
///
/// \tparam T A TOML node or value type.
///
/// \returns Returns true if this node is an instance of the specified type.
template <typename T>
TOML_PURE_INLINE_GETTER
bool is() const noexcept
{
using type = impl::unwrap_node<T>;
static_assert((impl::is_native<type> || impl::is_one_of<type, table, array>)&&!impl::is_cvref<type>,
"The template type argument of node::is() must be one of:" TOML_SA_UNWRAPPED_NODE_TYPE_LIST);
if constexpr (std::is_same_v<type, table>)
return is_table();
else if constexpr (std::is_same_v<type, array>)
return is_array();
else if constexpr (std::is_same_v<type, std::string>)
return is_string();
else if constexpr (std::is_same_v<type, int64_t>)
return is_integer();
else if constexpr (std::is_same_v<type, double>)
return is_floating_point();
else if constexpr (std::is_same_v<type, bool>)
return is_boolean();
else if constexpr (std::is_same_v<type, date>)
return is_date();
else if constexpr (std::is_same_v<type, time>)
return is_time();
else if constexpr (std::is_same_v<type, date_time>)
return is_date_time();
}
/// @}
/// \name Type casts
/// @{
/// \brief Returns a pointer to the node as a toml::table, if it is one.
TOML_PURE_INLINE_GETTER
virtual table* as_table() noexcept
{
return nullptr;
}
TOML_PURE_GETTER
virtual table* as_table() noexcept = 0;
/// \brief Returns a pointer to the node as a toml::array, if it is one.
TOML_PURE_INLINE_GETTER
virtual array* as_array() noexcept
{
return nullptr;
}
TOML_PURE_GETTER
virtual array* as_array() noexcept = 0;
/// \brief Returns a pointer to the node as a toml::value<string>, if it is one.
TOML_PURE_INLINE_GETTER
virtual toml::value<std::string>* as_string() noexcept
{
return nullptr;
}
/// \brief Returns a pointer to the node as a toml::value<std::string>, if it is one.
TOML_PURE_GETTER
virtual toml::value<std::string>* as_string() noexcept = 0;
/// \brief Returns a pointer to the node as a toml::value<int64_t>, if it is one.
TOML_PURE_INLINE_GETTER
virtual toml::value<int64_t>* as_integer() noexcept
{
return nullptr;
}
TOML_PURE_GETTER
virtual toml::value<int64_t>* as_integer() noexcept = 0;
/// \brief Returns a pointer to the node as a toml::value<double>, if it is one.
TOML_PURE_INLINE_GETTER
virtual toml::value<double>* as_floating_point() noexcept
{
return nullptr;
}
TOML_PURE_GETTER
virtual toml::value<double>* as_floating_point() noexcept = 0;
/// \brief Returns a pointer to the node as a toml::value<bool>, if it is one.
TOML_PURE_INLINE_GETTER
virtual toml::value<bool>* as_boolean() noexcept
{
return nullptr;
}
TOML_PURE_GETTER
virtual toml::value<bool>* as_boolean() noexcept = 0;
/// \brief Returns a pointer to the node as a toml::value<date>, if it is one.
TOML_PURE_INLINE_GETTER
virtual toml::value<date>* as_date() noexcept
{
return nullptr;
}
/// \brief Returns a pointer to the node as a toml::value<toml::date>, if it is one.
TOML_PURE_GETTER
virtual toml::value<date>* as_date() noexcept = 0;
/// \brief Returns a pointer to the node as a toml::value<time>, if it is one.
TOML_PURE_INLINE_GETTER
virtual toml::value<time>* as_time() noexcept
{
return nullptr;
}
/// \brief Returns a pointer to the node as a toml::value<toml::time>, if it is one.
TOML_PURE_GETTER
virtual toml::value<time>* as_time() noexcept = 0;
/// \brief Returns a pointer to the node as a toml::value<date_time>, if it is one.
TOML_PURE_INLINE_GETTER
virtual toml::value<date_time>* as_date_time() noexcept
{
return nullptr;
}
/// \brief Returns a pointer to the node as a toml::value<toml::date_time>, if it is one.
TOML_PURE_GETTER
virtual toml::value<date_time>* as_date_time() noexcept = 0;
TOML_PURE_INLINE_GETTER
virtual const table* as_table() const noexcept
{
return nullptr;
}
/// \brief Returns a const-qualified pointer to the node as a toml::table, if it is one.
TOML_PURE_GETTER
virtual const table* as_table() const noexcept = 0;
TOML_PURE_INLINE_GETTER
virtual const array* as_array() const noexcept
{
return nullptr;
}
/// \brief Returns a const-qualified pointer to the node as a toml::array, if it is one.
TOML_PURE_GETTER
virtual const array* as_array() const noexcept = 0;
TOML_PURE_INLINE_GETTER
virtual const toml::value<std::string>* as_string() const noexcept
{
return nullptr;
}
/// \brief Returns a const-qualified pointer to the node as a toml::value<std::string>, if it is one.
TOML_PURE_GETTER
virtual const toml::value<std::string>* as_string() const noexcept = 0;
TOML_PURE_INLINE_GETTER
virtual const toml::value<int64_t>* as_integer() const noexcept
{
return nullptr;
}
/// \brief Returns a const-qualified pointer to the node as a toml::value<int64_t>, if it is one.
TOML_PURE_GETTER
virtual const toml::value<int64_t>* as_integer() const noexcept = 0;
TOML_PURE_INLINE_GETTER
virtual const toml::value<double>* as_floating_point() const noexcept
{
return nullptr;
}
/// \brief Returns a const-qualified pointer to the node as a toml::value<double>, if it is one.
TOML_PURE_GETTER
virtual const toml::value<double>* as_floating_point() const noexcept = 0;
TOML_PURE_INLINE_GETTER
virtual const toml::value<bool>* as_boolean() const noexcept
{
return nullptr;
}
/// \brief Returns a const-qualified pointer to the node as a toml::value<bool>, if it is one.
TOML_PURE_GETTER
virtual const toml::value<bool>* as_boolean() const noexcept = 0;
TOML_PURE_INLINE_GETTER
virtual const toml::value<date>* as_date() const noexcept
{
return nullptr;
}
/// \brief Returns a const-qualified pointer to the node as a toml::value<toml::date>, if it is one.
TOML_PURE_GETTER
virtual const toml::value<date>* as_date() const noexcept = 0;
TOML_PURE_INLINE_GETTER
virtual const toml::value<time>* as_time() const noexcept
{
return nullptr;
}
/// \brief Returns a const-qualified pointer to the node as a toml::value<toml::time>, if it is one.
TOML_PURE_GETTER
virtual const toml::value<time>* as_time() const noexcept = 0;
TOML_PURE_INLINE_GETTER
virtual const toml::value<date_time>* as_date_time() const noexcept
{
return nullptr;
}
/// \brief Returns a const-qualified pointer to the node as a toml::value<toml::date_time>, if it is one.
TOML_PURE_GETTER
virtual const toml::value<date_time>* as_date_time() const noexcept = 0;
/// \brief Gets a pointer to the node as a more specific node type.
///

View File

@ -492,13 +492,13 @@ TOML_NAMESPACE_START
{
using namespace ::toml::impl;
static_assert(!is_wide_string<T> || TOML_WINDOWS_COMPAT,
static_assert(!is_wide_string<T> || TOML_ENABLE_WINDOWS_COMPAT,
"Retrieving values as wide-character strings is only "
"supported on Windows with TOML_WINDOWS_COMPAT enabled.");
"supported on Windows with TOML_ENABLE_WINDOWS_COMPAT enabled.");
if constexpr (is_wide_string<T>)
{
#if TOML_WINDOWS_COMPAT
#if TOML_ENABLE_WINDOWS_COMPAT
if (node_)
return node_->value_or(static_cast<T&&>(default_value));
@ -618,13 +618,13 @@ TOML_NAMESPACE_START
TOML_NODISCARD
friend bool operator==(const node_view& lhs, const T& rhs) noexcept(!impl::is_wide_string<T>)
{
static_assert(!impl::is_wide_string<T> || TOML_WINDOWS_COMPAT,
static_assert(!impl::is_wide_string<T> || TOML_ENABLE_WINDOWS_COMPAT,
"Comparison with wide-character strings is only "
"supported on Windows with TOML_WINDOWS_COMPAT enabled.");
"supported on Windows with TOML_ENABLE_WINDOWS_COMPAT enabled.");
if constexpr (impl::is_wide_string<T>)
{
#if TOML_WINDOWS_COMPAT
#if TOML_ENABLE_WINDOWS_COMPAT
return lhs == impl::narrow(rhs);
#else
static_assert(impl::dependent_false<T>, "Evaluated unreachable branch!");
@ -682,11 +682,11 @@ TOML_NAMESPACE_START
return node_view{ nullptr };
}
#if TOML_WINDOWS_COMPAT
#if TOML_ENABLE_WINDOWS_COMPAT
/// \brief Returns a view of the selected subnode.
///
/// \availability This overload is only available when #TOML_WINDOWS_COMPAT is enabled.
/// \availability This overload is only available when #TOML_ENABLE_WINDOWS_COMPAT is enabled.
///
/// \param key The key of the node to retrieve
///
@ -700,7 +700,7 @@ TOML_NAMESPACE_START
return node_view{ nullptr };
}
#endif // TOML_WINDOWS_COMPAT
#endif // TOML_ENABLE_WINDOWS_COMPAT
/// \brief Returns a view of the selected subnode.
///

View File

@ -59,7 +59,7 @@ TOML_NAMESPACE_START
TOML_EXTERN_FUNC(value, const char8_t*);
#endif
#if TOML_WINDOWS_COMPAT
#if TOML_ENABLE_WINDOWS_COMPAT
TOML_EXTERN_FUNC(value_exact, std::wstring);
TOML_EXTERN_FUNC(value, std::wstring);
#endif

View File

@ -288,11 +288,11 @@ TOML_NAMESPACE_START
return err_ ? node_view<const node>{} : table()[key];
}
#if TOML_WINDOWS_COMPAT
#if TOML_ENABLE_WINDOWS_COMPAT
/// \brief Gets a node_view for the selected key-value pair in the wrapped table.
///
/// \availability This overload is only available when #TOML_WINDOWS_COMPAT is enabled.
/// \availability This overload is only available when #TOML_ENABLE_WINDOWS_COMPAT is enabled.
///
/// \param key The key used for the lookup.
///
@ -308,7 +308,7 @@ TOML_NAMESPACE_START
/// \brief Gets a node_view for the selected key-value pair in the wrapped table (const overload).
///
/// \availability This overload is only available when #TOML_WINDOWS_COMPAT is enabled.
/// \availability This overload is only available when #TOML_ENABLE_WINDOWS_COMPAT is enabled.
///
/// \param key The key used for the lookup.
///
@ -322,7 +322,7 @@ TOML_NAMESPACE_START
return err_ ? node_view<const node>{} : table()[key];
}
#endif // TOML_WINDOWS_COMPAT
#endif // TOML_ENABLE_WINDOWS_COMPAT
/// \brief Returns an iterator to the first key-value pair in the wrapped table.
/// \remarks Returns a default-constructed 'nothing' iterator if the parsing failed.

View File

@ -157,11 +157,11 @@ TOML_NAMESPACE_START
#endif // TOML_HAS_CHAR8
#if TOML_WINDOWS_COMPAT
#if TOML_ENABLE_WINDOWS_COMPAT
/// \brief Parses a TOML document from a string view.
///
/// \availability This overload is only available when #TOML_WINDOWS_COMPAT is enabled.
/// \availability This overload is only available when #TOML_ENABLE_WINDOWS_COMPAT is enabled.
///
/// \detail \cpp
/// auto tbl = toml::parse("a = 3"sv, L"foo.toml");
@ -188,7 +188,7 @@ TOML_NAMESPACE_START
/// \brief Parses a TOML document from a stream.
///
/// \availability This overload is only available when #TOML_WINDOWS_COMPAT is enabled.
/// \availability This overload is only available when #TOML_ENABLE_WINDOWS_COMPAT is enabled.
///
/// \detail \cpp
/// std::stringstream ss;
@ -218,7 +218,7 @@ TOML_NAMESPACE_START
/// \brief Parses a TOML document from a file.
///
/// \availability This overload is only available when #TOML_WINDOWS_COMPAT is enabled.
/// \availability This overload is only available when #TOML_ENABLE_WINDOWS_COMPAT is enabled.
///
/// \detail \cpp
/// toml::parse_result get_foo_toml()
@ -237,13 +237,13 @@ TOML_NAMESPACE_START
TOML_API
parse_result parse_file(std::wstring_view file_path);
#endif // TOML_WINDOWS_COMPAT
#endif // TOML_ENABLE_WINDOWS_COMPAT
#if TOML_HAS_CHAR8 && TOML_WINDOWS_COMPAT
#if TOML_HAS_CHAR8 && TOML_ENABLE_WINDOWS_COMPAT
/// \brief Parses a TOML document from a char8_t string view.
///
/// \availability This overload is only available when #TOML_WINDOWS_COMPAT is enabled.
/// \availability This overload is only available when #TOML_ENABLE_WINDOWS_COMPAT is enabled.
///
/// \detail \cpp
/// auto tbl = toml::parse(u8"a = 3"sv, L"foo.toml");
@ -267,7 +267,7 @@ TOML_NAMESPACE_START
TOML_API
parse_result parse(std::u8string_view doc, std::wstring_view source_path);
#endif // TOML_HAS_CHAR8 && TOML_WINDOWS_COMPAT
#endif // TOML_HAS_CHAR8 && TOML_ENABLE_WINDOWS_COMPAT
/// \brief Parses a TOML document from a stream.
///

View File

@ -3602,7 +3602,7 @@ TOML_NAMESPACE_START
#endif // TOML_HAS_CHAR8
#if TOML_WINDOWS_COMPAT
#if TOML_ENABLE_WINDOWS_COMPAT
TOML_EXTERNAL_LINKAGE
parse_result parse(std::string_view doc, std::wstring_view source_path)
@ -3622,9 +3622,9 @@ TOML_NAMESPACE_START
return TOML_ANON_NAMESPACE::do_parse_file(impl::narrow(file_path));
}
#endif // TOML_WINDOWS_COMPAT
#endif // TOML_ENABLE_WINDOWS_COMPAT
#if TOML_HAS_CHAR8 && TOML_WINDOWS_COMPAT
#if TOML_HAS_CHAR8 && TOML_ENABLE_WINDOWS_COMPAT
TOML_EXTERNAL_LINKAGE
parse_result parse(std::u8string_view doc, std::wstring_view source_path)
@ -3632,7 +3632,7 @@ TOML_NAMESPACE_START
return TOML_ANON_NAMESPACE::do_parse(TOML_ANON_NAMESPACE::utf8_reader{ doc, impl::narrow(source_path) });
}
#endif // TOML_HAS_CHAR8 && TOML_WINDOWS_COMPAT
#endif // TOML_HAS_CHAR8 && TOML_ENABLE_WINDOWS_COMPAT
TOML_ABI_NAMESPACE_END; // TOML_EXCEPTIONS
}

View File

@ -335,7 +335,7 @@
#endif
// header-only mode
#if !defined(TOML_HEADER_ONLY) && defined(TOML_ALL_INLINE) // TOML_HEADER_ONLY was TOML_ALL_INLINE pre-2.0
#if !defined(TOML_HEADER_ONLY) && defined(TOML_ALL_INLINE) // was TOML_ALL_INLINE pre-2.0
#define TOML_HEADER_ONLY TOML_ALL_INLINE
#endif
#if !defined(TOML_HEADER_ONLY) || (defined(TOML_HEADER_ONLY) && TOML_HEADER_ONLY) || TOML_INTELLISENSE
@ -370,16 +370,19 @@
#endif
// experimental language features
#if (defined(TOML_UNRELEASED_FEATURES) && TOML_UNRELEASED_FEATURES) || TOML_INTELLISENSE
#undef TOML_UNRELEASED_FEATURES
#define TOML_UNRELEASED_FEATURES 1
#if !defined(TOML_ENABLE_UNRELEASED_FEATURES) && defined(TOML_UNRELEASED_FEATURES) // was TOML_UNRELEASED_FEATURES pre-3.0
#define TOML_ENABLE_UNRELEASED_FEATURES TOML_UNRELEASED_FEATURES
#endif
#ifndef TOML_UNRELEASED_FEATURES
#define TOML_UNRELEASED_FEATURES 0
#if (defined(TOML_ENABLE_UNRELEASED_FEATURES) && TOML_ENABLE_UNRELEASED_FEATURES) || TOML_INTELLISENSE
#undef TOML_ENABLE_UNRELEASED_FEATURES
#define TOML_ENABLE_UNRELEASED_FEATURES 1
#endif
#ifndef TOML_ENABLE_UNRELEASED_FEATURES
#define TOML_ENABLE_UNRELEASED_FEATURES 0
#endif
// parser
#if !defined(TOML_ENABLE_PARSER) && defined(TOML_PARSER) // TOML_ENABLE_PARSER was TOML_PARSER pre-3.0
#if !defined(TOML_ENABLE_PARSER) && defined(TOML_PARSER) // was TOML_PARSER pre-3.0
#define TOML_ENABLE_PARSER TOML_PARSER
#endif
#if !defined(TOML_ENABLE_PARSER) || (defined(TOML_ENABLE_PARSER) && TOML_ENABLE_PARSER) || TOML_INTELLISENSE
@ -388,7 +391,7 @@
#endif
// toml formatter
#if !defined(TOML_ENABLE_TOML_FORMATTER) \
#if !defined(TOML_ENABLE_TOML_FORMATTER) \
|| (defined(TOML_ENABLE_TOML_FORMATTER) && TOML_ENABLE_TOML_FORMATTER) \
|| TOML_INTELLISENSE
#undef TOML_ENABLE_TOML_FORMATTER
@ -404,16 +407,19 @@
#endif
// windows compat
#if !defined(TOML_WINDOWS_COMPAT) \
|| (defined(TOML_WINDOWS_COMPAT) && TOML_WINDOWS_COMPAT) \
#if !defined(TOML_ENABLE_WINDOWS_COMPAT) && defined(TOML_WINDOWS_COMPAT) // was TOML_WINDOWS_COMPAT pre-3.0
#define TOML_ENABLE_WINDOWS_COMPAT TOML_WINDOWS_COMPAT
#endif
#if !defined(TOML_ENABLE_WINDOWS_COMPAT) \
|| (defined(TOML_ENABLE_WINDOWS_COMPAT) && TOML_ENABLE_WINDOWS_COMPAT) \
|| TOML_INTELLISENSE
#undef TOML_WINDOWS_COMPAT
#define TOML_WINDOWS_COMPAT 1
#undef TOML_ENABLE_WINDOWS_COMPAT
#define TOML_ENABLE_WINDOWS_COMPAT 1
#endif
/// \cond
#ifndef _WIN32
#undef TOML_WINDOWS_COMPAT
#define TOML_WINDOWS_COMPAT 0
#undef TOML_ENABLE_WINDOWS_COMPAT
#define TOML_ENABLE_WINDOWS_COMPAT 0
#endif
/// \endcond
#ifndef TOML_INCLUDE_WINDOWS_H
@ -764,7 +770,7 @@
#define TOML_MAKE_VERSION(maj, min, rev) \
((maj) * 1000 + (min) * 25 + (rev))
#if TOML_UNRELEASED_FEATURES
#if TOML_ENABLE_UNRELEASED_FEATURES
#define TOML_LANG_EFFECTIVE_VERSION \
TOML_MAKE_VERSION(TOML_LANG_MAJOR, TOML_LANG_MINOR, TOML_LANG_PATCH+1)
#else
@ -996,14 +1002,14 @@ TOML_ENABLE_WARNINGS;
/// \detail Not defined by default.
/// \def TOML_UNRELEASED_FEATURES
/// \def TOML_ENABLE_UNRELEASED_FEATURES
/// \brief Enables support for unreleased TOML language features not yet part of a
/// [numbered version](https://github.com/toml-lang/toml/releases).
/// \detail Defaults to `0`.
/// \see [TOML Language Support](https://github.com/marzer/tomlplusplus/blob/master/README.md#toml-language-support)
/// \def TOML_WINDOWS_COMPAT
/// \def TOML_ENABLE_WINDOWS_COMPAT
/// \brief Enables the use of wide strings (wchar_t, std::wstring) in various places throughout the library
/// when building for Windows.
/// \detail Defaults to `1` when building for Windows, `0` otherwise. Has no effect when building for anything other

View File

@ -151,11 +151,11 @@ TOML_NAMESPACE_START
/// \remarks This will be `nullptr` if no path was provided to toml::parse().
source_path_ptr path;
#if TOML_WINDOWS_COMPAT
#if TOML_ENABLE_WINDOWS_COMPAT
/// \brief The path to the corresponding source document as a wide-string.
///
/// \availability This function is only available when #TOML_WINDOWS_COMPAT is enabled.
/// \availability This function is only available when #TOML_ENABLE_WINDOWS_COMPAT is enabled.
///
/// \remarks This will return an empty optional if no path was provided to toml::parse().
TOML_NODISCARD

View File

@ -31,7 +31,7 @@ namespace toml // non-abi namespace; this is not an error
using string_view = std::string_view;
}
#if TOML_WINDOWS_COMPAT
#if TOML_ENABLE_WINDOWS_COMPAT
TOML_IMPL_NAMESPACE_START
{
@ -53,6 +53,6 @@ TOML_IMPL_NAMESPACE_START
}
TOML_IMPL_NAMESPACE_END;
#endif // TOML_WINDOWS_COMPAT
#endif // TOML_ENABLE_WINDOWS_COMPAT
/// \endcond

View File

@ -11,7 +11,7 @@
#endif
//# }}
#if TOML_WINDOWS_COMPAT
#if TOML_ENABLE_WINDOWS_COMPAT
#include "std_string.h"
#include "header_start.h"
@ -97,4 +97,4 @@ TOML_IMPL_NAMESPACE_START
TOML_IMPL_NAMESPACE_END;
#include "header_end.h"
#endif // TOML_WINDOWS_COMPAT
#endif // TOML_ENABLE_WINDOWS_COMPAT

View File

@ -178,7 +178,7 @@ TOML_IMPL_NAMESPACE_START
value{ make_node(static_cast<V&&>(v), flags) }
{}
#if TOML_WINDOWS_COMPAT
#if TOML_ENABLE_WINDOWS_COMPAT
template <typename V>
TOML_NODISCARD_CTOR
@ -221,7 +221,7 @@ TOML_NAMESPACE_START
/// additional considerations made for the heterogeneous nature of a
/// TOML table, and for the removal of some cruft (the public interface of
/// std::map is, simply, _a hot mess_).
class table final : public node
class table : public node
{
private:
/// \cond
@ -240,13 +240,13 @@ TOML_NAMESPACE_START
static auto do_get(Map& vals, const Key& key) noexcept(!impl::is_wide_string<Key>)
-> std::conditional_t<std::is_const_v<Map>, const node*, node*>
{
static_assert(
!impl::is_wide_string<Key> || TOML_WINDOWS_COMPAT,
"Retrieval using wide-character keys is only supported on Windows with TOML_WINDOWS_COMPAT enabled.");
static_assert(!impl::is_wide_string<Key> || TOML_ENABLE_WINDOWS_COMPAT,
"Retrieval using wide-character keys is only supported on Windows with "
"TOML_ENABLE_WINDOWS_COMPAT enabled.");
if constexpr (impl::is_wide_string<Key>)
{
#if TOML_WINDOWS_COMPAT
#if TOML_ENABLE_WINDOWS_COMPAT
return do_get(vals, impl::narrow(key));
#else
static_assert(impl::dependent_false<Key>, "Evaluated unreachable branch!");
@ -348,32 +348,28 @@ TOML_NAMESPACE_START
/// \name Type checks
/// @{
TOML_NODISCARD
/// \brief Returns #toml::node_type::table.
TOML_CONST_INLINE_GETTER
node_type type() const noexcept final
{
return node_type::table;
}
TOML_NODISCARD
bool is_table() const noexcept final
{
return true;
}
TOML_NODISCARD
TOML_PURE_GETTER
TOML_API
bool is_homogeneous(node_type ntype) const noexcept final;
TOML_NODISCARD
TOML_PURE_GETTER
TOML_API
bool is_homogeneous(node_type ntype, node*& first_nonmatch) noexcept final;
TOML_NODISCARD
TOML_PURE_GETTER
TOML_API
bool is_homogeneous(node_type ntype, const node*& first_nonmatch) const noexcept final;
/// \cond
template <typename ElemType = void>
TOML_NODISCARD
TOML_PURE_GETTER
bool is_homogeneous() const noexcept
{
using type = impl::unwrap_node<ElemType>;
@ -386,24 +382,223 @@ TOML_NAMESPACE_START
return is_homogeneous(impl::node_type_of<type>);
}
/// \endcond
/// \brief Returns `true`.
TOML_CONST_INLINE_GETTER
bool is_table() const noexcept final
{
return true;
}
/// \brief Returns `false`.
TOML_CONST_INLINE_GETTER
bool is_array() const noexcept final
{
return false;
}
/// \brief Returns `false`.
TOML_PURE_GETTER
bool is_array_of_tables() const noexcept final
{
return false;
}
/// \brief Returns `false`.
TOML_CONST_INLINE_GETTER
bool is_value() const noexcept final
{
return false;
}
/// \brief Returns `false`.
TOML_CONST_INLINE_GETTER
bool is_string() const noexcept final
{
return false;
}
/// \brief Returns `false`.
TOML_CONST_INLINE_GETTER
bool is_integer() const noexcept final
{
return false;
}
/// \brief Returns `false`.
TOML_CONST_INLINE_GETTER
bool is_floating_point() const noexcept final
{
return false;
}
/// \brief Returns `false`.
TOML_CONST_INLINE_GETTER
bool is_number() const noexcept final
{
return false;
}
/// \brief Returns `false`.
TOML_CONST_INLINE_GETTER
bool is_boolean() const noexcept final
{
return false;
}
/// \brief Returns `false`.
TOML_CONST_INLINE_GETTER
bool is_date() const noexcept final
{
return false;
}
/// \brief Returns `false`.
TOML_CONST_INLINE_GETTER
bool is_time() const noexcept final
{
return false;
}
/// \brief Returns `false`.
TOML_CONST_INLINE_GETTER
bool is_date_time() const noexcept final
{
return false;
}
/// @}
/// \name Type casts
/// @{
TOML_NODISCARD
/// \brief Returns a pointer to the table.
TOML_CONST_INLINE_GETTER
table* as_table() noexcept final
{
return this;
}
TOML_NODISCARD
/// \brief Returns `nullptr`.
TOML_CONST_INLINE_GETTER
array* as_array() noexcept final
{
return nullptr;
}
/// \brief Returns `nullptr`.
TOML_CONST_INLINE_GETTER
toml::value<std::string>* as_string() noexcept final
{
return nullptr;
}
/// \brief Returns `nullptr`.
TOML_CONST_INLINE_GETTER
toml::value<int64_t>* as_integer() noexcept final
{
return nullptr;
}
/// \brief Returns `nullptr`.
TOML_CONST_INLINE_GETTER
toml::value<double>* as_floating_point() noexcept final
{
return nullptr;
}
/// \brief Returns `nullptr`.
TOML_CONST_INLINE_GETTER
toml::value<bool>* as_boolean() noexcept final
{
return nullptr;
}
/// \brief Returns `nullptr`.
TOML_CONST_INLINE_GETTER
toml::value<date>* as_date() noexcept final
{
return nullptr;
}
/// \brief Returns `nullptr`.
TOML_CONST_INLINE_GETTER
toml::value<time>* as_time() noexcept final
{
return nullptr;
}
/// \brief Returns `nullptr`.
TOML_CONST_INLINE_GETTER
toml::value<date_time>* as_date_time() noexcept final
{
return nullptr;
}
/// \brief Returns a const-qualified pointer to the table.
TOML_CONST_INLINE_GETTER
const table* as_table() const noexcept final
{
return this;
}
/// \brief Returns `nullptr`.
TOML_CONST_INLINE_GETTER
const array* as_array() const noexcept final
{
return nullptr;
}
/// \brief Returns `nullptr`.
TOML_CONST_INLINE_GETTER
const toml::value<std::string>* as_string() const noexcept final
{
return nullptr;
}
/// \brief Returns `nullptr`.
TOML_CONST_INLINE_GETTER
const toml::value<int64_t>* as_integer() const noexcept final
{
return nullptr;
}
/// \brief Returns `nullptr`.
TOML_CONST_INLINE_GETTER
const toml::value<double>* as_floating_point() const noexcept final
{
return nullptr;
}
/// \brief Returns `nullptr`.
TOML_CONST_INLINE_GETTER
const toml::value<bool>* as_boolean() const noexcept final
{
return nullptr;
}
/// \brief Returns `nullptr`.
TOML_CONST_INLINE_GETTER
const toml::value<date>* as_date() const noexcept final
{
return nullptr;
}
/// \brief Returns `nullptr`.
TOML_CONST_INLINE_GETTER
const toml::value<time>* as_time() const noexcept final
{
return nullptr;
}
/// \brief Returns `nullptr`.
TOML_CONST_INLINE_GETTER
const toml::value<date_time>* as_date_time() const noexcept final
{
return nullptr;
}
/// @}
/// \name Metadata
@ -502,11 +697,11 @@ TOML_NAMESPACE_START
return node_view<const node>{ this->get(key) };
}
#if TOML_WINDOWS_COMPAT
#if TOML_ENABLE_WINDOWS_COMPAT
/// \brief Gets a node_view for the selected key-value pair.
///
/// \availability This overload is only available when #TOML_WINDOWS_COMPAT is enabled.
/// \availability This overload is only available when #TOML_ENABLE_WINDOWS_COMPAT is enabled.
///
/// \param key The key used for the lookup.
///
@ -525,7 +720,7 @@ TOML_NAMESPACE_START
/// \brief Gets a node_view for the selected key-value pair (const overload).
///
/// \availability This overload is only available when #TOML_WINDOWS_COMPAT is enabled.
/// \availability This overload is only available when #TOML_ENABLE_WINDOWS_COMPAT is enabled.
///
/// \param key The key used for the lookup.
///
@ -542,7 +737,7 @@ TOML_NAMESPACE_START
return node_view<const node>{ this->get(key) };
}
#endif // TOML_WINDOWS_COMPAT
#endif // TOML_ENABLE_WINDOWS_COMPAT
/// @}
@ -670,9 +865,9 @@ TOML_NAMESPACE_START
ValueType&& val,
value_flags flags = preserve_source_value_flags)
{
static_assert(
!impl::is_wide_string<KeyType> || TOML_WINDOWS_COMPAT,
"Insertion using wide-character keys is only supported on Windows with TOML_WINDOWS_COMPAT enabled.");
static_assert(!impl::is_wide_string<KeyType> || TOML_ENABLE_WINDOWS_COMPAT,
"Insertion using wide-character keys is only supported on Windows with "
"TOML_ENABLE_WINDOWS_COMPAT enabled.");
if constexpr (is_node_view<ValueType>)
{
@ -682,7 +877,7 @@ TOML_NAMESPACE_START
if constexpr (impl::is_wide_string<KeyType>)
{
#if TOML_WINDOWS_COMPAT
#if TOML_ENABLE_WINDOWS_COMPAT
return insert(impl::narrow(std::forward<KeyType>(key)), std::forward<ValueType>(val), flags);
#else
static_assert(impl::dependent_false<KeyType>, "Evaluated unreachable branch!");
@ -815,9 +1010,9 @@ TOML_NAMESPACE_START
ValueType&& val,
value_flags flags = preserve_source_value_flags)
{
static_assert(
!impl::is_wide_string<KeyType> || TOML_WINDOWS_COMPAT,
"Insertion using wide-character keys is only supported on Windows with TOML_WINDOWS_COMPAT enabled.");
static_assert(!impl::is_wide_string<KeyType> || TOML_ENABLE_WINDOWS_COMPAT,
"Insertion using wide-character keys is only supported on Windows with "
"TOML_ENABLE_WINDOWS_COMPAT enabled.");
if constexpr (is_node_view<ValueType>)
{
@ -827,7 +1022,7 @@ TOML_NAMESPACE_START
if constexpr (impl::is_wide_string<KeyType>)
{
#if TOML_WINDOWS_COMPAT
#if TOML_ENABLE_WINDOWS_COMPAT
return insert_or_assign(impl::narrow(std::forward<KeyType>(key)), std::forward<ValueType>(val), flags);
#else
static_assert(impl::dependent_false<KeyType>, "Evaluated unreachable branch!");
@ -892,13 +1087,13 @@ TOML_NAMESPACE_START
template <typename ValueType, typename KeyType, typename... ValueArgs>
std::pair<iterator, bool> emplace(KeyType&& key, ValueArgs&&... args)
{
static_assert(
!impl::is_wide_string<KeyType> || TOML_WINDOWS_COMPAT,
"Emplacement using wide-character keys is only supported on Windows with TOML_WINDOWS_COMPAT enabled.");
static_assert(!impl::is_wide_string<KeyType> || TOML_ENABLE_WINDOWS_COMPAT,
"Emplacement using wide-character keys is only supported on Windows with "
"TOML_ENABLE_WINDOWS_COMPAT enabled.");
if constexpr (impl::is_wide_string<KeyType>)
{
#if TOML_WINDOWS_COMPAT
#if TOML_ENABLE_WINDOWS_COMPAT
return emplace<ValueType>(impl::narrow(std::forward<KeyType>(key)), std::forward<ValueArgs>(args)...);
#else
static_assert(impl::dependent_false<KeyType>, "Evaluated unreachable branch!");
@ -1045,11 +1240,11 @@ TOML_NAMESPACE_START
return false;
}
#if TOML_WINDOWS_COMPAT
#if TOML_ENABLE_WINDOWS_COMPAT
/// \brief Removes the value with the given key from the table.
///
/// \availability This overload is only available when #TOML_WINDOWS_COMPAT is enabled.
/// \availability This overload is only available when #TOML_ENABLE_WINDOWS_COMPAT is enabled.
///
/// \param key Key to erase.
///
@ -1059,7 +1254,7 @@ TOML_NAMESPACE_START
return erase(impl::narrow(key));
}
#endif // TOML_WINDOWS_COMPAT
#endif // TOML_ENABLE_WINDOWS_COMPAT
/// \brief Gets an iterator to the node at a specific key.
///
@ -1090,11 +1285,11 @@ TOML_NAMESPACE_START
return do_contains(map_, key);
}
#if TOML_WINDOWS_COMPAT
#if TOML_ENABLE_WINDOWS_COMPAT
/// \brief Gets an iterator to the node at a specific key.
///
/// \availability This overload is only available when #TOML_WINDOWS_COMPAT is enabled.
/// \availability This overload is only available when #TOML_ENABLE_WINDOWS_COMPAT is enabled.
///
/// \param key The node's key.
///
@ -1107,7 +1302,7 @@ TOML_NAMESPACE_START
/// \brief Gets an iterator to the node at a specific key (const overload).
///
/// \availability This overload is only available when #TOML_WINDOWS_COMPAT is enabled.
/// \availability This overload is only available when #TOML_ENABLE_WINDOWS_COMPAT is enabled.
///
/// \param key The node's key.
///
@ -1120,14 +1315,14 @@ TOML_NAMESPACE_START
/// \brief Returns true if the table contains a node at the given key.
///
/// \availability This overload is only available when #TOML_WINDOWS_COMPAT is enabled.
/// \availability This overload is only available when #TOML_ENABLE_WINDOWS_COMPAT is enabled.
TOML_NODISCARD
bool contains(std::wstring_view key) const
{
return contains(impl::narrow(key));
}
#endif // TOML_WINDOWS_COMPAT
#endif // TOML_ENABLE_WINDOWS_COMPAT
/// @}
@ -1176,11 +1371,11 @@ TOML_NAMESPACE_START
return do_get(map_, key);
}
#if TOML_WINDOWS_COMPAT
#if TOML_ENABLE_WINDOWS_COMPAT
/// \brief Gets the node at a specific key.
///
/// \availability This overload is only available when #TOML_WINDOWS_COMPAT is enabled.
/// \availability This overload is only available when #TOML_ENABLE_WINDOWS_COMPAT is enabled.
///
/// \param key The node's key.
///
@ -1193,7 +1388,7 @@ TOML_NAMESPACE_START
/// \brief Gets the node at a specific key (const overload).
///
/// \availability This overload is only available when #TOML_WINDOWS_COMPAT is enabled.
/// \availability This overload is only available when #TOML_ENABLE_WINDOWS_COMPAT is enabled.
///
/// \param key The node's key.
///
@ -1204,7 +1399,7 @@ TOML_NAMESPACE_START
return get(impl::narrow(key));
}
#endif // TOML_WINDOWS_COMPAT
#endif // TOML_ENABLE_WINDOWS_COMPAT
/// \brief Gets the node at a specific key if it is a particular type.
///
@ -1246,11 +1441,11 @@ TOML_NAMESPACE_START
return do_get_as<ValueType>(map_, key);
}
#if TOML_WINDOWS_COMPAT
#if TOML_ENABLE_WINDOWS_COMPAT
/// \brief Gets the node at a specific key if it is a particular type.
///
/// \availability This overload is only available when #TOML_WINDOWS_COMPAT is enabled.
/// \availability This overload is only available when #TOML_ENABLE_WINDOWS_COMPAT is enabled.
///
/// \tparam ValueType One of the TOML node or value types.
/// \param key The node's key.
@ -1265,7 +1460,7 @@ TOML_NAMESPACE_START
/// \brief Gets the node at a specific key if it is a particular type (const overload).
///
/// \availability This overload is only available when #TOML_WINDOWS_COMPAT is enabled.
/// \availability This overload is only available when #TOML_ENABLE_WINDOWS_COMPAT is enabled.
///
/// \tparam ValueType One of the TOML node or value types.
/// \param key The node's key.
@ -1278,7 +1473,7 @@ TOML_NAMESPACE_START
return get_as<ValueType>(impl::narrow(key));
}
#endif // TOML_WINDOWS_COMPAT
#endif // TOML_ENABLE_WINDOWS_COMPAT
/// @}
@ -1341,9 +1536,9 @@ TOML_NAMESPACE_START
//# using namespace impl;
//#
//# static_assert(
//# !is_wide_string<T> || TOML_WINDOWS_COMPAT,
//# !is_wide_string<T> || TOML_ENABLE_WINDOWS_COMPAT,
//# "Retrieving values as wide-character strings with node::select_exact() is only "
//# "supported on Windows with TOML_WINDOWS_COMPAT enabled."
//# "supported on Windows with TOML_ENABLE_WINDOWS_COMPAT enabled."
//# );
//#
//# static_assert(
@ -1358,9 +1553,9 @@ TOML_NAMESPACE_START
//# using namespace impl;
//#
//# static_assert(
//# !is_wide_string<T> || TOML_WINDOWS_COMPAT,
//# !is_wide_string<T> || TOML_ENABLE_WINDOWS_COMPAT,
//# "Retrieving values as wide-character strings with node::select() is only "
//# "supported on Windows with TOML_WINDOWS_COMPAT enabled."
//# "supported on Windows with TOML_ENABLE_WINDOWS_COMPAT enabled."
//# );
//# static_assert(
//# (is_native<T> || can_represent_native<T> || can_partially_represent_native<T>) && !is_cvref<T>,

View File

@ -13,7 +13,7 @@ TOML_DISABLE_ARITHMETIC_WARNINGS;
/// \cond
// clang-format off
#if TOML_WINDOWS_COMPAT
#if TOML_ENABLE_WINDOWS_COMPAT
#define TOML_SA_VALUE_MESSAGE_WSTRING TOML_SA_LIST_SEP "std::wstring"
#else
#define TOML_SA_VALUE_MESSAGE_WSTRING
@ -98,7 +98,7 @@ TOML_IMPL_NAMESPACE_START
}
};
#if TOML_HAS_CHAR8 || TOML_WINDOWS_COMPAT
#if TOML_HAS_CHAR8 || TOML_ENABLE_WINDOWS_COMPAT
struct string_maker
{
@ -114,10 +114,10 @@ TOML_IMPL_NAMESPACE_START
arg.length());
#endif // TOML_HAS_CHAR8
#if TOML_WINDOWS_COMPAT
#if TOML_ENABLE_WINDOWS_COMPAT
if constexpr (is_wide_string<T>)
return narrow(static_cast<T&&>(arg));
#endif // TOML_WINDOWS_COMPAT
#endif // TOML_ENABLE_WINDOWS_COMPAT
}
};
@ -136,7 +136,7 @@ TOML_IMPL_NAMESPACE_START
{};
#endif // TOML_HAS_CHAR8
#if TOML_WINDOWS_COMPAT
#if TOML_ENABLE_WINDOWS_COMPAT
template <>
struct native_value_maker<std::string, wchar_t*> : string_maker
{};
@ -149,9 +149,9 @@ TOML_IMPL_NAMESPACE_START
template <>
struct native_value_maker<std::string, std::wstring_view> : string_maker
{};
#endif // TOML_WINDOWS_COMPAT
#endif // TOML_ENABLE_WINDOWS_COMPAT
#endif // TOML_HAS_CHAR8 || TOML_WINDOWS_COMPAT
#endif // TOML_HAS_CHAR8 || TOML_ENABLE_WINDOWS_COMPAT
template <typename T>
TOML_NODISCARD
@ -200,7 +200,7 @@ TOML_NAMESPACE_START
/// - double
/// - bool
template <typename ValueType>
class value final : public node
class value : public node
{
static_assert(impl::is_native<ValueType> && !impl::is_cvref<ValueType>,
"A toml::value<> must model one of the native TOML value types:" TOML_SA_NATIVE_VALUE_TYPE_LIST);
@ -211,9 +211,7 @@ TOML_NAMESPACE_START
friend class TOML_PARSER_TYPENAME;
template <typename T, typename U>
TOML_NODISCARD
TOML_ALWAYS_INLINE
TOML_ATTR(const)
TOML_CONST_INLINE_GETTER
static auto as_value([[maybe_unused]] U* ptr) noexcept
{
if constexpr (std::is_same_v<value_type, T>)
@ -322,73 +320,19 @@ TOML_NAMESPACE_START
/// - node_type::date
/// - node_type::time
/// - node_type::date_time
TOML_NODISCARD
TOML_CONST_INLINE_GETTER
node_type type() const noexcept final
{
return impl::node_type_of<value_type>;
}
TOML_NODISCARD
bool is_value() const noexcept final
{
return true;
}
TOML_NODISCARD
bool is_string() const noexcept final
{
return std::is_same_v<value_type, std::string>;
}
TOML_NODISCARD
bool is_integer() const noexcept final
{
return std::is_same_v<value_type, int64_t>;
}
TOML_NODISCARD
bool is_floating_point() const noexcept final
{
return std::is_same_v<value_type, double>;
}
TOML_NODISCARD
bool is_number() const noexcept final
{
return impl::is_one_of<value_type, int64_t, double>;
}
TOML_NODISCARD
bool is_boolean() const noexcept final
{
return std::is_same_v<value_type, bool>;
}
TOML_NODISCARD
bool is_date() const noexcept final
{
return std::is_same_v<value_type, date>;
}
TOML_NODISCARD
bool is_time() const noexcept final
{
return std::is_same_v<value_type, time>;
}
TOML_NODISCARD
bool is_date_time() const noexcept final
{
return std::is_same_v<value_type, date_time>;
}
TOML_NODISCARD
TOML_PURE_GETTER
bool is_homogeneous(node_type ntype) const noexcept final
{
return ntype == node_type::none || ntype == impl::node_type_of<value_type>;
}
TOML_NODISCARD
TOML_PURE_GETTER
bool is_homogeneous(node_type ntype, node*& first_nonmatch) noexcept final
{
if (ntype != node_type::none && ntype != impl::node_type_of<value_type>)
@ -399,7 +343,7 @@ TOML_NAMESPACE_START
return true;
}
TOML_NODISCARD
TOML_PURE_GETTER
bool is_homogeneous(node_type ntype, const node*& first_nonmatch) const noexcept final
{
if (ntype != node_type::none && ntype != impl::node_type_of<value_type>)
@ -410,8 +354,9 @@ TOML_NAMESPACE_START
return true;
}
/// \cond
template <typename ElemType = void>
TOML_NODISCARD
TOML_PURE_GETTER
bool is_homogeneous() const noexcept
{
using type = impl::unwrap_node<ElemType>;
@ -427,91 +372,218 @@ TOML_NAMESPACE_START
else
return impl::node_type_of<type> == impl::node_type_of<value_type>;
}
/// \endcond
/// \brief Returns `false`.
TOML_CONST_INLINE_GETTER
bool is_table() const noexcept final
{
return false;
}
/// \brief Returns `false`.
TOML_CONST_INLINE_GETTER
bool is_array() const noexcept final
{
return false;
}
/// \brief Returns `false`.
TOML_CONST_INLINE_GETTER
bool is_array_of_tables() const noexcept final
{
return false;
}
/// \brief Returns `true`.
TOML_CONST_INLINE_GETTER
bool is_value() const noexcept final
{
return true;
}
/// \brief Returns `true` if the #value_type is std::string.
TOML_CONST_INLINE_GETTER
bool is_string() const noexcept final
{
return std::is_same_v<value_type, std::string>;
}
/// \brief Returns `true` if the #value_type is int64_t.
TOML_CONST_INLINE_GETTER
bool is_integer() const noexcept final
{
return std::is_same_v<value_type, int64_t>;
}
/// \brief Returns `true` if the #value_type is `double`.
TOML_CONST_INLINE_GETTER
bool is_floating_point() const noexcept final
{
return std::is_same_v<value_type, double>;
}
/// \brief Returns `true` if the #value_type is int64_t or `double`.
TOML_CONST_INLINE_GETTER
bool is_number() const noexcept final
{
return impl::is_one_of<value_type, int64_t, double>;
}
/// \brief Returns `true` if the #value_type is `bool`.
TOML_CONST_INLINE_GETTER
bool is_boolean() const noexcept final
{
return std::is_same_v<value_type, bool>;
}
/// \brief Returns `true` if the #value_type is toml::date.
TOML_CONST_INLINE_GETTER
bool is_date() const noexcept final
{
return std::is_same_v<value_type, date>;
}
/// \brief Returns `true` if the #value_type is toml::time.
TOML_CONST_INLINE_GETTER
bool is_time() const noexcept final
{
return std::is_same_v<value_type, time>;
}
/// \brief Returns `true` if the #value_type is toml_date_time.
TOML_CONST_INLINE_GETTER
bool is_date_time() const noexcept final
{
return std::is_same_v<value_type, date_time>;
}
/// @}
/// \name Type casts
/// @{
TOML_NODISCARD
/// \brief Returns `nullptr`.
TOML_CONST_INLINE_GETTER
table* as_table() noexcept final
{
return nullptr;
}
/// \brief Returns `nullptr`.
TOML_CONST_INLINE_GETTER
array* as_array() noexcept final
{
return nullptr;
}
/// \brief Returns a pointer to the value if it is a value<std::string>, otherwise `nullptr`.
TOML_CONST_INLINE_GETTER
value<std::string>* as_string() noexcept final
{
return as_value<std::string>(this);
}
TOML_NODISCARD
/// \brief Returns a pointer to the value if it is a value<int64_t>, otherwise `nullptr`.
TOML_CONST_INLINE_GETTER
value<int64_t>* as_integer() noexcept final
{
return as_value<int64_t>(this);
}
TOML_NODISCARD
/// \brief Returns a pointer to the value if it is a value<double>, otherwise `nullptr`.
TOML_CONST_INLINE_GETTER
value<double>* as_floating_point() noexcept final
{
return as_value<double>(this);
}
TOML_NODISCARD
/// \brief Returns a pointer to the value if it is a value<bool>, otherwise `nullptr`.
TOML_CONST_INLINE_GETTER
value<bool>* as_boolean() noexcept final
{
return as_value<bool>(this);
}
TOML_NODISCARD
/// \brief Returns a pointer to the value if it is a value<date>, otherwise `nullptr`.
TOML_CONST_INLINE_GETTER
value<date>* as_date() noexcept final
{
return as_value<date>(this);
}
TOML_NODISCARD
/// \brief Returns a pointer to the value if it is a value<time>, otherwise `nullptr`.
TOML_CONST_INLINE_GETTER
value<time>* as_time() noexcept final
{
return as_value<time>(this);
}
TOML_NODISCARD
/// \brief Returns a pointer to the value if it is a value<date_time>, otherwise `nullptr`.
TOML_CONST_INLINE_GETTER
value<date_time>* as_date_time() noexcept final
{
return as_value<date_time>(this);
}
TOML_NODISCARD
/// \brief Returns `nullptr`.
TOML_CONST_INLINE_GETTER
const table* as_table() const noexcept final
{
return nullptr;
}
/// \brief Returns `nullptr`.
TOML_CONST_INLINE_GETTER
const array* as_array() const noexcept final
{
return nullptr;
}
/// \brief Returns a const-qualified pointer to the value if it is a value<std::string>, otherwise `nullptr`.
TOML_CONST_INLINE_GETTER
const value<std::string>* as_string() const noexcept final
{
return as_value<std::string>(this);
}
TOML_NODISCARD
/// \brief Returns a const-qualified pointer to the value if it is a value<int64_t>, otherwise `nullptr`.
TOML_CONST_INLINE_GETTER
const value<int64_t>* as_integer() const noexcept final
{
return as_value<int64_t>(this);
}
TOML_NODISCARD
/// \brief Returns a const-qualified pointer to the value if it is a value<double>, otherwise `nullptr`.
TOML_CONST_INLINE_GETTER
const value<double>* as_floating_point() const noexcept final
{
return as_value<double>(this);
}
TOML_NODISCARD
/// \brief Returns a const-qualified pointer to the value if it is a value<bool>, otherwise `nullptr`.
TOML_CONST_INLINE_GETTER
const value<bool>* as_boolean() const noexcept final
{
return as_value<bool>(this);
}
TOML_NODISCARD
/// \brief Returns a const-qualified pointer to the value if it is a value<date>, otherwise `nullptr`.
TOML_CONST_INLINE_GETTER
const value<date>* as_date() const noexcept final
{
return as_value<date>(this);
}
TOML_NODISCARD
/// \brief Returns a const-qualified pointer to the value if it is a value<time>, otherwise `nullptr`.
TOML_CONST_INLINE_GETTER
const value<time>* as_time() const noexcept final
{
return as_value<time>(this);
}
TOML_NODISCARD
/// \brief Returns a const-qualified pointer to the value if it is a value<date_time>, otherwise `nullptr`.
TOML_CONST_INLINE_GETTER
const value<date_time>* as_date_time() const noexcept final
{
return as_value<date_time>(this);
@ -851,7 +923,7 @@ TOML_NAMESPACE_START
else if constexpr (std::is_same_v<T, std::wstring>)
{
#if TOML_WINDOWS_COMPAT
#if TOML_ENABLE_WINDOWS_COMPAT
return widen(str);
#else
static_assert(dependent_false<T>, "Evaluated unreachable branch!");
@ -880,9 +952,9 @@ TOML_NAMESPACE_START
{
using namespace impl;
static_assert(!is_wide_string<T> || TOML_WINDOWS_COMPAT,
static_assert(!is_wide_string<T> || TOML_ENABLE_WINDOWS_COMPAT,
"Retrieving values as wide-character strings with node::value_exact() is only "
"supported on Windows with TOML_WINDOWS_COMPAT enabled.");
"supported on Windows with TOML_ENABLE_WINDOWS_COMPAT enabled.");
static_assert((is_native<T> || can_represent_native<T>)&&!is_cvref<T>,
TOML_SA_VALUE_EXACT_FUNC_MESSAGE("return type of node::value_exact()"));
@ -903,9 +975,9 @@ TOML_NAMESPACE_START
{
using namespace impl;
static_assert(!is_wide_string<T> || TOML_WINDOWS_COMPAT,
static_assert(!is_wide_string<T> || TOML_ENABLE_WINDOWS_COMPAT,
"Retrieving values as wide-character strings with node::value() is only "
"supported on Windows with TOML_WINDOWS_COMPAT enabled.");
"supported on Windows with TOML_ENABLE_WINDOWS_COMPAT enabled.");
static_assert((is_native<T> || can_represent_native<T> || can_partially_represent_native<T>)&&!is_cvref<T>,
TOML_SA_VALUE_FUNC_MESSAGE("return type of node::value()"));
@ -1020,13 +1092,13 @@ TOML_NAMESPACE_START
{
using namespace impl;
static_assert(!is_wide_string<T> || TOML_WINDOWS_COMPAT,
static_assert(!is_wide_string<T> || TOML_ENABLE_WINDOWS_COMPAT,
"Retrieving values as wide-character strings with node::value_or() is only "
"supported on Windows with TOML_WINDOWS_COMPAT enabled.");
"supported on Windows with TOML_ENABLE_WINDOWS_COMPAT enabled.");
if constexpr (is_wide_string<T>)
{
#if TOML_WINDOWS_COMPAT
#if TOML_ENABLE_WINDOWS_COMPAT
if (type() == node_type::string)
return widen(*ref_cast<std::string>());
@ -1056,7 +1128,7 @@ TOML_NAMESPACE_START
TOML_SA_LIST_NXT "A non-view type capable of losslessly representing a native TOML value type"
TOML_SA_LIST_BEG "std::string"
#if TOML_WINDOWS_COMPAT
#if TOML_ENABLE_WINDOWS_COMPAT
TOML_SA_LIST_SEP "std::wstring"
#endif
TOML_SA_LIST_SEP "any signed integer type >= 64 bits"
@ -1073,14 +1145,14 @@ TOML_NAMESPACE_START
#if TOML_HAS_CHAR8
TOML_SA_LIST_SEP "std::u8string_view"
#endif
#if TOML_WINDOWS_COMPAT
#if TOML_ENABLE_WINDOWS_COMPAT
TOML_SA_LIST_SEP "std::wstring_view"
#endif
TOML_SA_LIST_SEP "const char*"
#if TOML_HAS_CHAR8
TOML_SA_LIST_SEP "const char8_t*"
#endif
#if TOML_WINDOWS_COMPAT
#if TOML_ENABLE_WINDOWS_COMPAT
TOML_SA_LIST_SEP "const wchar_t*"
#endif
TOML_SA_LIST_END

View File

@ -64,7 +64,7 @@ TOML_NAMESPACE_START
TOML_EXTERN_FUNC(value, std::u8string);
TOML_EXTERN_FUNC(value, const char8_t*);
#endif
#if TOML_WINDOWS_COMPAT
#if TOML_ENABLE_WINDOWS_COMPAT
TOML_EXTERN_FUNC(value_exact, std::wstring);
TOML_EXTERN_FUNC(value, std::wstring);
#endif

View File

@ -265,6 +265,16 @@ compiler_supports_cpp20 = compiler_supports_cpp20_args.length() > 0 and compiler
#include <version>
#include <string>
#include <iostream>
#include <cstdint>
#include <cstddef>
#include <cstring>
#include <cfloat>
#include <climits>
#include <cmath>
#include <limits>
#include <memory>
#include <iosfwd>
#include <type_traits>
int main()
{

View File

@ -89,6 +89,10 @@ fruit = []
static constexpr auto float_trailing_point_min = R"(trailing-point-min = -1.)"sv;
static constexpr auto float_trailing_point_plus = R"(trailing-point-plus = +1.)"sv;
static constexpr auto float_trailing_point = R"(trailing-point = 1.)"sv;
static constexpr auto float_trailing_us_exp = R"(# trailing underscore in integer part is not allowed
trailing-us-exp = 1_e2
# trailing underscore in float part is not allowed
trailing-us-exp2 = 1.2_e2)"sv;
static constexpr auto float_trailing_us = R"(trailing-us = 1.2_)"sv;
static constexpr auto float_us_after_point = R"(us-after-point = 1._2)"sv;
static constexpr auto float_us_before_point = R"(us-before-point = 1_.2)"sv;
@ -392,6 +396,8 @@ TEST_CASE("conformance - burntsushi/invalid")
parsing_should_fail(FILE_LINE_ARGS, float_trailing_point); // float-trailing-point
parsing_should_fail(FILE_LINE_ARGS, float_trailing_us_exp); // float-trailing-us-exp
parsing_should_fail(FILE_LINE_ARGS, float_trailing_us); // float-trailing-us
parsing_should_fail(FILE_LINE_ARGS, float_us_after_point); // float-us-after-point

View File

@ -170,13 +170,13 @@ neglongpi = -3.141592653589793)"sv;
static constexpr auto float_underscore = R"(before = 3_141.5927
after = 3141.592_7
exponent = 3e1_4)"sv;
static constexpr auto float_zero = R"(f1 = 0.0
f2 = +0.0
f3 = -0.0
f4 = 0e0
f5 = 0e00
f6 = +0e0
f7 = -0e0)"sv;
static constexpr auto float_zero = R"(zero = 0.0
signed-pos = +0.0
signed-neg = -0.0
exponent = 0e0
exponent-two-0 = 0e00
exponent-signed-pos = +0e0
exponent-signed-neg = -0e0)"sv;
static constexpr auto implicit_and_explicit_after = R"([a.b.c]
answer = 42
@ -1167,13 +1167,13 @@ TEST_CASE("conformance - burntsushi/valid")
parsing_should_succeed(FILE_LINE_ARGS, float_zero, [](toml::table&& tbl) // float-zero
{
const auto expected = toml::table{
{ R"(f1)"sv, 0.0 },
{ R"(f2)"sv, 0.0 },
{ R"(f3)"sv, 0.0 },
{ R"(f4)"sv, 0.0 },
{ R"(f5)"sv, 0.0 },
{ R"(f6)"sv, 0.0 },
{ R"(f7)"sv, 0.0 },
{ R"(zero)"sv, 0.0 },
{ R"(signed-pos)"sv, 0.0 },
{ R"(signed-neg)"sv, 0.0 },
{ R"(exponent)"sv, 0.0 },
{ R"(exponent-two-0)"sv, 0.0 },
{ R"(exponent-signed-pos)"sv, 0.0 },
{ R"(exponent-signed-neg)"sv, 0.0 },
};
REQUIRE(tbl == expected);
});

View File

@ -114,7 +114,7 @@ namespace toml
CHECK_CAN_REPRESENT_NATIVE(const wchar_t(&&)[2], false);
CHECK_CAN_REPRESENT_NATIVE(const wchar_t*, false);
CHECK_CAN_REPRESENT_NATIVE(const wchar_t* const, false);
CHECK_CAN_REPRESENT_NATIVE(std::wstring, !!TOML_WINDOWS_COMPAT);
CHECK_CAN_REPRESENT_NATIVE(std::wstring, !!TOML_ENABLE_WINDOWS_COMPAT);
CHECK_CAN_REPRESENT_NATIVE(std::wstring_view, false);
#define CHECK_VALUE_EXACT(T, expected) \
@ -244,7 +244,7 @@ namespace toml
CHECK_VALUE_OR(const std::u8string&, std::u8string);
CHECK_VALUE_OR(const std::u8string&&, std::u8string);
#endif
#if TOML_WINDOWS_COMPAT
#if TOML_ENABLE_WINDOWS_COMPAT
CHECK_VALUE_OR(wchar_t*, std::wstring);
CHECK_VALUE_OR(wchar_t*&, std::wstring);
CHECK_VALUE_OR(wchar_t*&&, std::wstring);

View File

@ -25,6 +25,44 @@ TEST_CASE("arrays - moving")
REQUIRE(arr1->get_as<std::string>(0u));
CHECK(*arr1->get_as<std::string>(0u) == "foo"sv);
// sanity check the virtual type checks
CHECK(arr1->type() == node_type::array);
CHECK(!arr1->is_table());
CHECK(arr1->is_array());
CHECK(!arr1->is_array_of_tables());
CHECK(!arr1->is_value());
CHECK(!arr1->is_string());
CHECK(!arr1->is_integer());
CHECK(!arr1->is_floating_point());
CHECK(!arr1->is_number());
CHECK(!arr1->is_boolean());
CHECK(!arr1->is_date());
CHECK(!arr1->is_time());
CHECK(!arr1->is_date_time());
// sanity check the virtual type casts (non-const)
CHECK(!arr1->as_table());
CHECK(arr1->as_array() == arr1);
CHECK(!arr1->as_string());
CHECK(!arr1->as_integer());
CHECK(!arr1->as_floating_point());
CHECK(!arr1->as_boolean());
CHECK(!arr1->as_date());
CHECK(!arr1->as_time());
CHECK(!arr1->as_date_time());
// sanity check the virtual type casts (const)
const auto carr1 = &std::as_const(*arr1);
CHECK(!carr1->as_table());
CHECK(carr1->as_array() == carr1);
CHECK(!carr1->as_string());
CHECK(!carr1->as_integer());
CHECK(!carr1->as_floating_point());
CHECK(!carr1->as_boolean());
CHECK(!carr1->as_date());
CHECK(!carr1->as_time());
CHECK(!carr1->as_date_time());
// sanity-check initial state of default-constructed array
array arr2;
CHECK(arr2.source().begin == source_position{});
@ -161,7 +199,7 @@ TEST_CASE("arrays - construction")
CHECK(!arr.is_homogeneous());
}
#if TOML_WINDOWS_COMPAT
#if TOML_ENABLE_WINDOWS_COMPAT
{
array arr{ "mixed", "string"sv, L"test", L"kek"sv };
CHECK(arr.size() == 4u);
@ -172,7 +210,7 @@ TEST_CASE("arrays - construction")
CHECK(*arr.get_as<std::string>(2) == "test"sv);
CHECK(*arr.get_as<std::string>(3) == "kek"sv);
}
#endif // TOML_WINDOWS_COMPAT
#endif // TOML_ENABLE_WINDOWS_COMPAT
}
TEST_CASE("arrays - equality")
@ -371,7 +409,7 @@ TEST_CASE("arrays - insertion and erasure")
CHECK(*arr.get_as<double>(5u) == 3.0);
}
#if TOML_WINDOWS_COMPAT
#if TOML_ENABLE_WINDOWS_COMPAT
arr.clear();
it = arr.insert(arr.cbegin(), L"test");
@ -386,7 +424,7 @@ TEST_CASE("arrays - insertion and erasure")
arr.emplace_back<std::string>(L"test4");
REQUIRE(*arr.back().as_string() == "test4"sv);
#endif // TOML_WINDOWS_COMPAT
#endif // TOML_ENABLE_WINDOWS_COMPAT
}
TEST_CASE("arrays - flattening")

View File

@ -21,6 +21,44 @@ TEST_CASE("tables - moving")
CHECK(tbl["test"].as<table>()->source().end == source_position{ 1, 24 });
CHECK(tbl["test"]["val1"] == "foo");
// sanity check the virtual type checks
CHECK(tbl.type() == node_type::table);
CHECK(tbl.is_table());
CHECK(!tbl.is_array());
CHECK(!tbl.is_array_of_tables());
CHECK(!tbl.is_value());
CHECK(!tbl.is_string());
CHECK(!tbl.is_integer());
CHECK(!tbl.is_floating_point());
CHECK(!tbl.is_number());
CHECK(!tbl.is_boolean());
CHECK(!tbl.is_date());
CHECK(!tbl.is_time());
CHECK(!tbl.is_date_time());
// sanity check the virtual type casts (non-const)
CHECK(tbl.as_table() == &tbl);
CHECK(!tbl.as_array());
CHECK(!tbl.as_string());
CHECK(!tbl.as_integer());
CHECK(!tbl.as_floating_point());
CHECK(!tbl.as_boolean());
CHECK(!tbl.as_date());
CHECK(!tbl.as_time());
CHECK(!tbl.as_date_time());
// sanity check the virtual type casts (const)
const auto& ctbl = std::as_const(tbl);
CHECK(ctbl.as_table() == &ctbl);
CHECK(!ctbl.as_array());
CHECK(!ctbl.as_string());
CHECK(!ctbl.as_integer());
CHECK(!ctbl.as_floating_point());
CHECK(!ctbl.as_boolean());
CHECK(!ctbl.as_date());
CHECK(!ctbl.as_time());
CHECK(!ctbl.as_date_time());
// sanity-check initial state of default-constructed table
table tbl2;
CHECK(tbl2.source().begin == source_position{});
@ -153,7 +191,7 @@ TEST_CASE("tables - construction")
CHECK(*tbl.get_as<array>("qux"sv) == array{ 1 });
}
#if TOML_WINDOWS_COMPAT
#if TOML_ENABLE_WINDOWS_COMPAT
{
table tbl{ { L"foo", L"test1" },
{ L"bar"sv, L"test2"sv },
@ -170,7 +208,7 @@ TEST_CASE("tables - construction")
REQUIRE(tbl.get_as<std::string>("qux"sv));
CHECK(*tbl.get_as<std::string>("qux"sv) == "test4"sv);
}
#endif // TOML_WINDOWS_COMPAT
#endif // TOML_ENABLE_WINDOWS_COMPAT
}
TEST_CASE("tables - equality")
@ -341,7 +379,7 @@ TEST_CASE("tables - insertion and erasure")
tbl.clear();
}
#if TOML_WINDOWS_COMPAT
#if TOML_ENABLE_WINDOWS_COMPAT
tbl.insert(L"a", L"test1");
REQUIRE(*tbl.get_as<std::string>(L"a"sv) == "test1"sv);
@ -355,7 +393,7 @@ TEST_CASE("tables - insertion and erasure")
tbl.erase(L"a"s);
CHECK(tbl.size() == 0u);
#endif // TOML_WINDOWS_COMPAT
#endif // TOML_ENABLE_WINDOWS_COMPAT
}
TEST_CASE("tables - toml_formatter")

View File

@ -7,83 +7,209 @@
#ifdef _WIN32
TOML_DISABLE_WARNINGS;
#include <windows.h>
#include <Windows.h>
TOML_ENABLE_WARNINGS;
#endif
TOML_DISABLE_SPAM_WARNINGS;
template <typename T>
static constexpr T one = static_cast<T>(1);
TEST_CASE("values - construction")
{
#define CHECK_VALUE_INIT2(initializer, target_type, equiv) \
do \
{ \
auto v = value{ initializer }; \
static_assert(std::is_same_v<decltype(v), value<target_type>>); \
CHECK(v == equiv); \
CHECK(equiv == v); \
CHECK(*v == equiv); \
CHECK(v.get() == equiv); \
CHECK(v.is_homogeneous()); \
CHECK(v.is_homogeneous<target_type>()); \
CHECK(v.is_homogeneous(impl::node_type_of<target_type>)); \
} \
while (false)
static constexpr auto check_value = [](const auto& init_value, auto expected_native_type_tag)
{
using init_type = impl::remove_cvref<decltype(init_value)>;
using native_type = impl::native_type_of<init_type>;
using expected_native_type = typename decltype(expected_native_type_tag)::type;
static_assert(std::is_same_v<native_type, expected_native_type>);
#define CHECK_VALUE_INIT(initializer, target_type) CHECK_VALUE_INIT2(initializer, target_type, initializer)
auto v = value{ init_value };
using value_type = decltype(v);
static_assert(std::is_same_v<value_type, value<native_type>>);
CHECK_VALUE_INIT(one<signed char>, int64_t);
CHECK_VALUE_INIT(one<signed short>, int64_t);
CHECK_VALUE_INIT(one<signed int>, int64_t);
CHECK_VALUE_INIT(one<signed long>, int64_t);
CHECK_VALUE_INIT(one<signed long long>, int64_t);
CHECK_VALUE_INIT2(one<unsigned char>, int64_t, 1u);
CHECK_VALUE_INIT2(one<unsigned short>, int64_t, 1u);
CHECK_VALUE_INIT2(one<unsigned int>, int64_t, 1u);
CHECK_VALUE_INIT2(one<unsigned long>, int64_t, 1u);
CHECK_VALUE_INIT2(one<unsigned long long>, int64_t, 1u);
CHECK_VALUE_INIT(true, bool);
CHECK_VALUE_INIT(false, bool);
CHECK_VALUE_INIT("kek", std::string);
CHECK_VALUE_INIT("kek"s, std::string);
CHECK_VALUE_INIT("kek"sv, std::string);
CHECK_VALUE_INIT2("kek"sv.data(), std::string, "kek"sv);
if constexpr (std::is_same_v<std::string, native_type>)
{
#if TOML_HAS_CHAR8
CHECK_VALUE_INIT2(u8"kek", std::string, "kek"sv);
CHECK_VALUE_INIT2(u8"kek"s, std::string, "kek"sv);
CHECK_VALUE_INIT2(u8"kek"sv, std::string, "kek"sv);
CHECK_VALUE_INIT2(u8"kek"sv.data(), std::string, "kek"sv);
using char8_type = char8_t;
#else
using char8_type = char;
#endif
using init_char_type = impl::remove_cvref<decltype(init_value[0])>;
using init_view_type = std::basic_string_view<init_char_type>;
static_assert(impl::is_one_of<init_char_type, char, wchar_t, char8_type>);
const auto init_view = init_view_type{ init_value };
if constexpr (impl::is_one_of<init_char_type, char, char8_type>)
{
const auto coerced_view =
std::string_view{ reinterpret_cast<const char*>(init_view.data()), init_view.length() };
CHECK(v == coerced_view);
CHECK(coerced_view == v);
}
#if TOML_ENABLE_WINDOWS_COMPAT
else if constexpr (impl::is_one_of<init_char_type, wchar_t>)
{
const auto narrowed_string = impl::narrow(init_view);
CHECK(v == narrowed_string);
CHECK(narrowed_string == v);
}
#endif
else
{
static_assert(impl::dependent_false<init_char_type>, "evaluated unreachable branch");
}
}
else if constexpr (impl::is_one_of<native_type, int64_t, double, bool>)
{
CHECK(v == static_cast<native_type>(init_value));
CHECK(static_cast<native_type>(init_value) == v);
}
else // dates + times
{
CHECK(v == init_value);
CHECK(init_value == v);
}
static constexpr auto expected_node_type = impl::node_type_of<native_type>;
CHECK(v.is_homogeneous());
CHECK(v.template is_homogeneous<native_type>());
CHECK(v.is_homogeneous(expected_node_type));
// sanity check the virtual type checks
CHECK(v.type() == expected_node_type);
CHECK(!v.is_table());
CHECK(!v.is_array());
CHECK(!v.is_array_of_tables());
CHECK(v.is_value());
CHECK(v.is_string() == (expected_node_type == node_type::string));
CHECK(v.is_integer() == (expected_node_type == node_type::integer));
CHECK(v.is_floating_point() == (expected_node_type == node_type::floating_point));
CHECK(v.is_number()
== (expected_node_type == node_type::integer || expected_node_type == node_type::floating_point));
CHECK(v.is_boolean() == (expected_node_type == node_type::boolean));
CHECK(v.is_date() == (expected_node_type == node_type::date));
CHECK(v.is_time() == (expected_node_type == node_type::time));
CHECK(v.is_date_time() == (expected_node_type == node_type::date_time));
// sanity check the virtual type casts (non-const)
CHECK(!v.as_table());
CHECK(!v.as_array());
if constexpr (expected_node_type == node_type::string)
CHECK(v.as_string() == &v);
else
CHECK(!v.as_string());
if constexpr (expected_node_type == node_type::integer)
CHECK(v.as_integer() == &v);
else
CHECK(!v.as_integer());
if constexpr (expected_node_type == node_type::floating_point)
CHECK(v.as_floating_point() == &v);
else
CHECK(!v.as_floating_point());
if constexpr (expected_node_type == node_type::boolean)
CHECK(v.as_boolean() == &v);
else
CHECK(!v.as_boolean());
if constexpr (expected_node_type == node_type::date)
CHECK(v.as_date() == &v);
else
CHECK(!v.as_date());
if constexpr (expected_node_type == node_type::time)
CHECK(v.as_time() == &v);
else
CHECK(!v.as_time());
if constexpr (expected_node_type == node_type::date_time)
CHECK(v.as_date_time() == &v);
else
CHECK(!v.as_date_time());
// sanity check the virtual type casts (const)
const auto& cv = std::as_const(v);
CHECK(!cv.as_table());
CHECK(!cv.as_array());
if constexpr (expected_node_type == node_type::string)
CHECK(cv.as_string() == &v);
else
CHECK(!cv.as_string());
if constexpr (expected_node_type == node_type::integer)
CHECK(cv.as_integer() == &v);
else
CHECK(!cv.as_integer());
if constexpr (expected_node_type == node_type::floating_point)
CHECK(cv.as_floating_point() == &v);
else
CHECK(!cv.as_floating_point());
if constexpr (expected_node_type == node_type::boolean)
CHECK(cv.as_boolean() == &v);
else
CHECK(!cv.as_boolean());
if constexpr (expected_node_type == node_type::date)
CHECK(cv.as_date() == &v);
else
CHECK(!cv.as_date());
if constexpr (expected_node_type == node_type::time)
CHECK(cv.as_time() == &v);
else
CHECK(!cv.as_time());
if constexpr (expected_node_type == node_type::date_time)
CHECK(cv.as_date_time() == &v);
else
CHECK(!cv.as_date_time());
};
check_value(one<signed char>, type_tag<int64_t>{});
check_value(one<signed short>, type_tag<int64_t>{});
check_value(one<signed int>, type_tag<int64_t>{});
check_value(one<signed long>, type_tag<int64_t>{});
check_value(one<signed long long>, type_tag<int64_t>{});
check_value(one<unsigned char>, type_tag<int64_t>{});
check_value(one<unsigned short>, type_tag<int64_t>{});
check_value(one<unsigned int>, type_tag<int64_t>{});
check_value(one<unsigned long>, type_tag<int64_t>{});
check_value(one<unsigned long long>, type_tag<int64_t>{});
check_value(true, type_tag<bool>{});
check_value(false, type_tag<bool>{});
check_value("kek", type_tag<std::string>{});
check_value("kek"s, type_tag<std::string>{});
check_value("kek"sv, type_tag<std::string>{});
check_value("kek"sv.data(), type_tag<std::string>{});
#if TOML_HAS_CHAR8
check_value(u8"kek", type_tag<std::string>{});
check_value(u8"kek"s, type_tag<std::string>{});
check_value(u8"kek"sv, type_tag<std::string>{});
check_value(u8"kek"sv.data(), type_tag<std::string>{});
#endif
#ifdef _WIN32
CHECK_VALUE_INIT(one<BOOL>, int64_t);
CHECK_VALUE_INIT(one<SHORT>, int64_t);
CHECK_VALUE_INIT(one<INT>, int64_t);
CHECK_VALUE_INIT(one<LONG>, int64_t);
CHECK_VALUE_INIT(one<INT_PTR>, int64_t);
CHECK_VALUE_INIT(one<LONG_PTR>, int64_t);
CHECK_VALUE_INIT2(one<USHORT>, int64_t, 1u);
CHECK_VALUE_INIT2(one<UINT>, int64_t, 1u);
CHECK_VALUE_INIT2(one<ULONG>, int64_t, 1u);
CHECK_VALUE_INIT2(one<UINT_PTR>, int64_t, 1u);
CHECK_VALUE_INIT2(one<ULONG_PTR>, int64_t, 1u);
CHECK_VALUE_INIT2(one<WORD>, int64_t, 1u);
CHECK_VALUE_INIT2(one<DWORD>, int64_t, 1u);
CHECK_VALUE_INIT2(one<DWORD32>, int64_t, 1u);
CHECK_VALUE_INIT2(one<DWORD64>, int64_t, 1u);
CHECK_VALUE_INIT2(one<DWORDLONG>, int64_t, 1u);
check_value(one<BOOL>, type_tag<int64_t>{});
check_value(one<SHORT>, type_tag<int64_t>{});
check_value(one<INT>, type_tag<int64_t>{});
check_value(one<LONG>, type_tag<int64_t>{});
check_value(one<INT_PTR>, type_tag<int64_t>{});
check_value(one<LONG_PTR>, type_tag<int64_t>{});
check_value(one<USHORT>, type_tag<int64_t>{});
check_value(one<UINT>, type_tag<int64_t>{});
check_value(one<ULONG>, type_tag<int64_t>{});
check_value(one<UINT_PTR>, type_tag<int64_t>{});
check_value(one<ULONG_PTR>, type_tag<int64_t>{});
check_value(one<WORD>, type_tag<int64_t>{});
check_value(one<DWORD>, type_tag<int64_t>{});
check_value(one<DWORD32>, type_tag<int64_t>{});
check_value(one<DWORD64>, type_tag<int64_t>{});
check_value(one<DWORDLONG>, type_tag<int64_t>{});
#if TOML_WINDOWS_COMPAT
#if TOML_ENABLE_WINDOWS_COMPAT
CHECK_VALUE_INIT2(L"kek", std::string, "kek"sv);
CHECK_VALUE_INIT2(L"kek"s, std::string, "kek"sv);
CHECK_VALUE_INIT2(L"kek"sv, std::string, "kek"sv);
CHECK_VALUE_INIT2(L"kek"sv.data(), std::string, "kek"sv);
check_value(L"kek", type_tag<std::string>{});
check_value(L"kek"s, type_tag<std::string>{});
check_value(L"kek"sv, type_tag<std::string>{});
check_value(L"kek"sv.data(), type_tag<std::string>{});
#endif // TOML_WINDOWS_COMPAT
#endif // TOML_ENABLE_WINDOWS_COMPAT
#endif
}

View File

@ -126,9 +126,9 @@ foreach cpp20 : cpp20_modes
if unrel
test_name = test_name + '_unrel'
test_args += '-DTOML_UNRELEASED_FEATURES=1'
test_args += '-DTOML_ENABLE_UNRELEASED_FEATURES=1'
else
test_args += '-DTOML_UNRELEASED_FEATURES=0'
test_args += '-DTOML_ENABLE_UNRELEASED_FEATURES=0'
endif
if counter % 6 == 3

View File

@ -36,8 +36,8 @@
#if TOML_COMPILER_EXCEPTIONS ^ TOML_EXCEPTIONS
#error TOML_EXCEPTIONS does not match TOML_COMPILER_EXCEPTIONS (default behaviour should be to match)
#endif
#if defined(_WIN32) ^ TOML_WINDOWS_COMPAT
#error TOML_WINDOWS_COMPAT does not match _WIN32 (default behaviour should be to match)
#if defined(_WIN32) ^ TOML_ENABLE_WINDOWS_COMPAT
#error TOML_ENABLE_WINDOWS_COMPAT does not match _WIN32 (default behaviour should be to match)
#endif
#if !(TOML_HEADER_ONLY ^ TOML_EXTERN_TEMPLATES) && !TOML_INTELLISENSE
#error TOML_EXTERN_TEMPLATES should hold the opposite value to TOML_HEADER_ONLY by default
@ -98,6 +98,12 @@ constexpr size_t operator"" _sz(unsigned long long n) noexcept
CHECK_SYMMETRIC_RELOP(lhs, ==, rhs, false); \
CHECK_SYMMETRIC_RELOP(lhs, !=, rhs, true)
template <typename T>
struct type_tag
{
using type = T;
};
// function_view - adapted from here: https://vittorioromeo.info/index/blog/passing_functions_to_functions.html
template <typename Func>
class function_view;

View File

@ -38,7 +38,7 @@
<ExceptionHandling>Sync</ExceptionHandling>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>tests.h</PrecompiledHeaderFile>
<PreprocessorDefinitions>TOML_UNRELEASED_FEATURES=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>TOML_ENABLE_UNRELEASED_FEATURES=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>LEAK_TESTS=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'%(ExceptionHandling)'=='false'">_HAS_EXCEPTIONS=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'%(ExceptionHandling)'=='false'">SHOULD_HAVE_EXCEPTIONS=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>

View File

@ -38,7 +38,7 @@
<ExceptionHandling>Sync</ExceptionHandling>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>tests.h</PrecompiledHeaderFile>
<PreprocessorDefinitions>TOML_UNRELEASED_FEATURES=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>TOML_ENABLE_UNRELEASED_FEATURES=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>LEAK_TESTS=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'%(ExceptionHandling)'=='false'">_HAS_EXCEPTIONS=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'%(ExceptionHandling)'=='false'">SHOULD_HAVE_EXCEPTIONS=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>

View File

@ -38,7 +38,7 @@
<ExceptionHandling>false</ExceptionHandling>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>tests.h</PrecompiledHeaderFile>
<PreprocessorDefinitions>TOML_UNRELEASED_FEATURES=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>TOML_ENABLE_UNRELEASED_FEATURES=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>LEAK_TESTS=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'%(ExceptionHandling)'=='false'">_HAS_EXCEPTIONS=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'%(ExceptionHandling)'=='false'">SHOULD_HAVE_EXCEPTIONS=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>

View File

@ -38,7 +38,7 @@
<ExceptionHandling>false</ExceptionHandling>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>tests.h</PrecompiledHeaderFile>
<PreprocessorDefinitions>TOML_UNRELEASED_FEATURES=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>TOML_ENABLE_UNRELEASED_FEATURES=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>LEAK_TESTS=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'%(ExceptionHandling)'=='false'">_HAS_EXCEPTIONS=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'%(ExceptionHandling)'=='false'">SHOULD_HAVE_EXCEPTIONS=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>

View File

@ -38,7 +38,7 @@
<ExceptionHandling>Sync</ExceptionHandling>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>tests.h</PrecompiledHeaderFile>
<PreprocessorDefinitions>TOML_UNRELEASED_FEATURES=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>TOML_ENABLE_UNRELEASED_FEATURES=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>LEAK_TESTS=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'%(ExceptionHandling)'=='false'">_HAS_EXCEPTIONS=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'%(ExceptionHandling)'=='false'">SHOULD_HAVE_EXCEPTIONS=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>

View File

@ -38,7 +38,7 @@
<ExceptionHandling>false</ExceptionHandling>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>tests.h</PrecompiledHeaderFile>
<PreprocessorDefinitions>TOML_UNRELEASED_FEATURES=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>TOML_ENABLE_UNRELEASED_FEATURES=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>LEAK_TESTS=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'%(ExceptionHandling)'=='false'">_HAS_EXCEPTIONS=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'%(ExceptionHandling)'=='false'">SHOULD_HAVE_EXCEPTIONS=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>

View File

@ -38,7 +38,7 @@
<ExceptionHandling>false</ExceptionHandling>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>tests.h</PrecompiledHeaderFile>
<PreprocessorDefinitions>TOML_UNRELEASED_FEATURES=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>TOML_ENABLE_UNRELEASED_FEATURES=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>LEAK_TESTS=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'%(ExceptionHandling)'=='false'">_HAS_EXCEPTIONS=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'%(ExceptionHandling)'=='false'">SHOULD_HAVE_EXCEPTIONS=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>

View File

@ -38,7 +38,7 @@
<ExceptionHandling>Sync</ExceptionHandling>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>tests.h</PrecompiledHeaderFile>
<PreprocessorDefinitions>TOML_UNRELEASED_FEATURES=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>TOML_ENABLE_UNRELEASED_FEATURES=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>LEAK_TESTS=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'%(ExceptionHandling)'=='false'">_HAS_EXCEPTIONS=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'%(ExceptionHandling)'=='false'">SHOULD_HAVE_EXCEPTIONS=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>

View File

@ -38,7 +38,7 @@
<ExceptionHandling>Sync</ExceptionHandling>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>tests.h</PrecompiledHeaderFile>
<PreprocessorDefinitions>TOML_UNRELEASED_FEATURES=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>TOML_ENABLE_UNRELEASED_FEATURES=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>LEAK_TESTS=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'%(ExceptionHandling)'=='false'">_HAS_EXCEPTIONS=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'%(ExceptionHandling)'=='false'">SHOULD_HAVE_EXCEPTIONS=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>

View File

@ -38,7 +38,7 @@
<ExceptionHandling>Sync</ExceptionHandling>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>tests.h</PrecompiledHeaderFile>
<PreprocessorDefinitions>TOML_UNRELEASED_FEATURES=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>TOML_ENABLE_UNRELEASED_FEATURES=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>LEAK_TESTS=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'%(ExceptionHandling)'=='false'">_HAS_EXCEPTIONS=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'%(ExceptionHandling)'=='false'">SHOULD_HAVE_EXCEPTIONS=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>

View File

@ -38,7 +38,7 @@
<ExceptionHandling>false</ExceptionHandling>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>tests.h</PrecompiledHeaderFile>
<PreprocessorDefinitions>TOML_UNRELEASED_FEATURES=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>TOML_ENABLE_UNRELEASED_FEATURES=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>LEAK_TESTS=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'%(ExceptionHandling)'=='false'">_HAS_EXCEPTIONS=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'%(ExceptionHandling)'=='false'">SHOULD_HAVE_EXCEPTIONS=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>

View File

@ -38,7 +38,7 @@
<ExceptionHandling>false</ExceptionHandling>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>tests.h</PrecompiledHeaderFile>
<PreprocessorDefinitions>TOML_UNRELEASED_FEATURES=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>TOML_ENABLE_UNRELEASED_FEATURES=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>LEAK_TESTS=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'%(ExceptionHandling)'=='false'">_HAS_EXCEPTIONS=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'%(ExceptionHandling)'=='false'">SHOULD_HAVE_EXCEPTIONS=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>

View File

@ -38,7 +38,7 @@
<ExceptionHandling>Sync</ExceptionHandling>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>tests.h</PrecompiledHeaderFile>
<PreprocessorDefinitions>TOML_UNRELEASED_FEATURES=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>TOML_ENABLE_UNRELEASED_FEATURES=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>LEAK_TESTS=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'%(ExceptionHandling)'=='false'">_HAS_EXCEPTIONS=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'%(ExceptionHandling)'=='false'">SHOULD_HAVE_EXCEPTIONS=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>

View File

@ -38,7 +38,7 @@
<ExceptionHandling>false</ExceptionHandling>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>tests.h</PrecompiledHeaderFile>
<PreprocessorDefinitions>TOML_UNRELEASED_FEATURES=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>TOML_ENABLE_UNRELEASED_FEATURES=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>LEAK_TESTS=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'%(ExceptionHandling)'=='false'">_HAS_EXCEPTIONS=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'%(ExceptionHandling)'=='false'">SHOULD_HAVE_EXCEPTIONS=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>

View File

@ -38,7 +38,7 @@
<ExceptionHandling>false</ExceptionHandling>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>tests.h</PrecompiledHeaderFile>
<PreprocessorDefinitions>TOML_UNRELEASED_FEATURES=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>TOML_ENABLE_UNRELEASED_FEATURES=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>LEAK_TESTS=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'%(ExceptionHandling)'=='false'">_HAS_EXCEPTIONS=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'%(ExceptionHandling)'=='false'">SHOULD_HAVE_EXCEPTIONS=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>

View File

@ -38,7 +38,7 @@
<ExceptionHandling>Sync</ExceptionHandling>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>tests.h</PrecompiledHeaderFile>
<PreprocessorDefinitions>TOML_UNRELEASED_FEATURES=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>TOML_ENABLE_UNRELEASED_FEATURES=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>LEAK_TESTS=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'%(ExceptionHandling)'=='false'">_HAS_EXCEPTIONS=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'%(ExceptionHandling)'=='false'">SHOULD_HAVE_EXCEPTIONS=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>

View File

@ -38,7 +38,7 @@
<ExceptionHandling>Sync</ExceptionHandling>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>tests.h</PrecompiledHeaderFile>
<PreprocessorDefinitions>TOML_UNRELEASED_FEATURES=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>TOML_ENABLE_UNRELEASED_FEATURES=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>LEAK_TESTS=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'%(ExceptionHandling)'=='false'">_HAS_EXCEPTIONS=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'%(ExceptionHandling)'=='false'">SHOULD_HAVE_EXCEPTIONS=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>

View File

@ -38,7 +38,7 @@
<ExceptionHandling>Sync</ExceptionHandling>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>tests.h</PrecompiledHeaderFile>
<PreprocessorDefinitions>TOML_UNRELEASED_FEATURES=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>TOML_ENABLE_UNRELEASED_FEATURES=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>LEAK_TESTS=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'%(ExceptionHandling)'=='false'">_HAS_EXCEPTIONS=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'%(ExceptionHandling)'=='false'">SHOULD_HAVE_EXCEPTIONS=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>

View File

@ -38,7 +38,7 @@
<ExceptionHandling>false</ExceptionHandling>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>tests.h</PrecompiledHeaderFile>
<PreprocessorDefinitions>TOML_UNRELEASED_FEATURES=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>TOML_ENABLE_UNRELEASED_FEATURES=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>LEAK_TESTS=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'%(ExceptionHandling)'=='false'">_HAS_EXCEPTIONS=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'%(ExceptionHandling)'=='false'">SHOULD_HAVE_EXCEPTIONS=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>

View File

@ -38,7 +38,7 @@
<ExceptionHandling>false</ExceptionHandling>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>tests.h</PrecompiledHeaderFile>
<PreprocessorDefinitions>TOML_UNRELEASED_FEATURES=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>TOML_ENABLE_UNRELEASED_FEATURES=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>LEAK_TESTS=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'%(ExceptionHandling)'=='false'">_HAS_EXCEPTIONS=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'%(ExceptionHandling)'=='false'">SHOULD_HAVE_EXCEPTIONS=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>

View File

@ -38,7 +38,7 @@
<ExceptionHandling>Sync</ExceptionHandling>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>tests.h</PrecompiledHeaderFile>
<PreprocessorDefinitions>TOML_UNRELEASED_FEATURES=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>TOML_ENABLE_UNRELEASED_FEATURES=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>LEAK_TESTS=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'%(ExceptionHandling)'=='false'">_HAS_EXCEPTIONS=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'%(ExceptionHandling)'=='false'">SHOULD_HAVE_EXCEPTIONS=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>

View File

@ -38,7 +38,7 @@
<ExceptionHandling>false</ExceptionHandling>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>tests.h</PrecompiledHeaderFile>
<PreprocessorDefinitions>TOML_UNRELEASED_FEATURES=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>TOML_ENABLE_UNRELEASED_FEATURES=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>LEAK_TESTS=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'%(ExceptionHandling)'=='false'">_HAS_EXCEPTIONS=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'%(ExceptionHandling)'=='false'">SHOULD_HAVE_EXCEPTIONS=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>

View File

@ -38,7 +38,7 @@
<ExceptionHandling>false</ExceptionHandling>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>tests.h</PrecompiledHeaderFile>
<PreprocessorDefinitions>TOML_UNRELEASED_FEATURES=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>TOML_ENABLE_UNRELEASED_FEATURES=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>LEAK_TESTS=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'%(ExceptionHandling)'=='false'">_HAS_EXCEPTIONS=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'%(ExceptionHandling)'=='false'">SHOULD_HAVE_EXCEPTIONS=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>

View File

@ -38,7 +38,7 @@
<ExceptionHandling>Sync</ExceptionHandling>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>tests.h</PrecompiledHeaderFile>
<PreprocessorDefinitions>TOML_UNRELEASED_FEATURES=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>TOML_ENABLE_UNRELEASED_FEATURES=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>LEAK_TESTS=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'%(ExceptionHandling)'=='false'">_HAS_EXCEPTIONS=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'%(ExceptionHandling)'=='false'">SHOULD_HAVE_EXCEPTIONS=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>

View File

@ -38,7 +38,7 @@
<ExceptionHandling>Sync</ExceptionHandling>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>tests.h</PrecompiledHeaderFile>
<PreprocessorDefinitions>TOML_UNRELEASED_FEATURES=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>TOML_ENABLE_UNRELEASED_FEATURES=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>LEAK_TESTS=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'%(ExceptionHandling)'=='false'">_HAS_EXCEPTIONS=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'%(ExceptionHandling)'=='false'">SHOULD_HAVE_EXCEPTIONS=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>

View File

@ -38,7 +38,7 @@
<ExceptionHandling>Sync</ExceptionHandling>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>tests.h</PrecompiledHeaderFile>
<PreprocessorDefinitions>TOML_UNRELEASED_FEATURES=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>TOML_ENABLE_UNRELEASED_FEATURES=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>LEAK_TESTS=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'%(ExceptionHandling)'=='false'">_HAS_EXCEPTIONS=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'%(ExceptionHandling)'=='false'">SHOULD_HAVE_EXCEPTIONS=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>

View File

@ -38,7 +38,7 @@
<ExceptionHandling>false</ExceptionHandling>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>tests.h</PrecompiledHeaderFile>
<PreprocessorDefinitions>TOML_UNRELEASED_FEATURES=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>TOML_ENABLE_UNRELEASED_FEATURES=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>LEAK_TESTS=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'%(ExceptionHandling)'=='false'">_HAS_EXCEPTIONS=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'%(ExceptionHandling)'=='false'">SHOULD_HAVE_EXCEPTIONS=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>

View File

@ -38,7 +38,7 @@
<ExceptionHandling>false</ExceptionHandling>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>tests.h</PrecompiledHeaderFile>
<PreprocessorDefinitions>TOML_UNRELEASED_FEATURES=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>TOML_ENABLE_UNRELEASED_FEATURES=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>LEAK_TESTS=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'%(ExceptionHandling)'=='false'">_HAS_EXCEPTIONS=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'%(ExceptionHandling)'=='false'">SHOULD_HAVE_EXCEPTIONS=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>

View File

@ -38,7 +38,7 @@
<ExceptionHandling>Sync</ExceptionHandling>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>tests.h</PrecompiledHeaderFile>
<PreprocessorDefinitions>TOML_UNRELEASED_FEATURES=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>TOML_ENABLE_UNRELEASED_FEATURES=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>LEAK_TESTS=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'%(ExceptionHandling)'=='false'">_HAS_EXCEPTIONS=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'%(ExceptionHandling)'=='false'">SHOULD_HAVE_EXCEPTIONS=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>

View File

@ -38,7 +38,7 @@
<ExceptionHandling>false</ExceptionHandling>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>tests.h</PrecompiledHeaderFile>
<PreprocessorDefinitions>TOML_UNRELEASED_FEATURES=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>TOML_ENABLE_UNRELEASED_FEATURES=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>LEAK_TESTS=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'%(ExceptionHandling)'=='false'">_HAS_EXCEPTIONS=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'%(ExceptionHandling)'=='false'">SHOULD_HAVE_EXCEPTIONS=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>

View File

@ -38,7 +38,7 @@
<ExceptionHandling>false</ExceptionHandling>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>tests.h</PrecompiledHeaderFile>
<PreprocessorDefinitions>TOML_UNRELEASED_FEATURES=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>TOML_ENABLE_UNRELEASED_FEATURES=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>LEAK_TESTS=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'%(ExceptionHandling)'=='false'">_HAS_EXCEPTIONS=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'%(ExceptionHandling)'=='false'">SHOULD_HAVE_EXCEPTIONS=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>

View File

@ -38,7 +38,7 @@
<ExceptionHandling>Sync</ExceptionHandling>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>tests.h</PrecompiledHeaderFile>
<PreprocessorDefinitions>TOML_UNRELEASED_FEATURES=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>TOML_ENABLE_UNRELEASED_FEATURES=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>LEAK_TESTS=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'%(ExceptionHandling)'=='false'">_HAS_EXCEPTIONS=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'%(ExceptionHandling)'=='false'">SHOULD_HAVE_EXCEPTIONS=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>

View File

@ -5,7 +5,7 @@
#include "tests.h"
#if TOML_WINDOWS_COMPAT
#if TOML_ENABLE_WINDOWS_COMPAT
TOML_DISABLE_WARNINGS;
#include <windows.h>
@ -94,4 +94,4 @@ TEST_CASE("windows compat")
CHECK(tbl[L"dependencies"][L"cpp"].value<DWORDLONG>() == 17u);
}
#endif // TOML_WINDOWS_COMPAT
#endif // TOML_ENABLE_WINDOWS_COMPAT

1029
toml.hpp

File diff suppressed because it is too large Load Diff

View File

@ -208,8 +208,8 @@ def main():
r'TOML_SMALL_FLOAT_TYPE',
r'TOML_SMALL_INT_TYPE',
r'TOML_UNDEF_MACROS',
r'TOML_UNRELEASED_FEATURES',
r'TOML_WINDOWS_COMPAT',
r'TOML_ENABLE_UNRELEASED_FEATURES',
r'TOML_ENABLE_WINDOWS_COMPAT',
r'POXY_IMPLEMENTATION_DETAIL',
)
set_defines = []

View File

@ -81,7 +81,7 @@ def main():
<ExceptionHandling>{exceptions}</ExceptionHandling>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>tests.h</PrecompiledHeaderFile>
<PreprocessorDefinitions>TOML_UNRELEASED_FEATURES={unreleased_features};%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>TOML_ENABLE_UNRELEASED_FEATURES={unreleased_features};%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>LEAK_TESTS=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'%(ExceptionHandling)'=='false'">_HAS_EXCEPTIONS=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'%(ExceptionHandling)'=='false'">SHOULD_HAVE_EXCEPTIONS=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>