documentation improvements and minor cleanup

- split conformance tests into multiple TU's
- added "Try this code on Compiler Explorer" links to the main page
- minor preprocessor cleanup
This commit is contained in:
Mark Gillard 2020-07-05 18:08:28 +03:00
parent 51f64fd08d
commit 8d958fcc54
47 changed files with 3653 additions and 3387 deletions

View File

@ -47,8 +47,9 @@ ALIASES = \
"bash=@code{.sh}" \ "bash=@code{.sh}" \
"ebash=@endcode" \ "ebash=@endcode" \
"detail=@details" \ "detail=@details" \
"gh{1}=<a href=\"https://github.com/\1\">\1</a>"\ "gh{1}=<a href=\"https://github.com/\1\" target=\"_blank\">\1</a>" \
"gh2{2}=<a href=\"https://github.com/\1\">\2</a>"\ "gh2{2}=<a href=\"https://github.com/\1\" target=\"_blank\">\2</a>" \
"godbolt{1}=<a href=\"https://godbolt.org/z/\1\" target=\"_blank\">Try this code on Compiler Explorer</a>" \
"m_div{1}=@xmlonly<mcss:div xmlns:mcss=\"http://mcss.mosra.cz/doxygen/\" mcss:class=\"\1\">@endxmlonly" \ "m_div{1}=@xmlonly<mcss:div xmlns:mcss=\"http://mcss.mosra.cz/doxygen/\" mcss:class=\"\1\">@endxmlonly" \
"m_enddiv=@xmlonly</mcss:div>@endxmlonly" \ "m_enddiv=@xmlonly</mcss:div>@endxmlonly" \
"m_span{1}=@xmlonly<mcss:span xmlns:mcss=\"http://mcss.mosra.cz/doxygen/\" mcss:class=\"\1\">@endxmlonly" \ "m_span{1}=@xmlonly<mcss:span xmlns:mcss=\"http://mcss.mosra.cz/doxygen/\" mcss:class=\"\1\">@endxmlonly" \
@ -316,7 +317,7 @@ PREDEFINED = TOML_DOXYGEN=1 \
TOML_API= \ TOML_API= \
TOML_ABI_NAMESPACE_START(x)= \ TOML_ABI_NAMESPACE_START(x)= \
TOML_ABI_NAMESPACE_END= \ TOML_ABI_NAMESPACE_END= \
TOML_GNU_ATTR(...)= \ TOML_ATTR(...)= \
TOML_PUSH_WARNINGS= \ TOML_PUSH_WARNINGS= \
TOML_DISABLE_SWITCH_WARNINGS= \ TOML_DISABLE_SWITCH_WARNINGS= \
TOML_DISABLE_INIT_WARNINGS= \ TOML_DISABLE_INIT_WARNINGS= \
@ -324,6 +325,7 @@ PREDEFINED = TOML_DOXYGEN=1 \
TOML_DISABLE_PADDING_WARNINGS= \ TOML_DISABLE_PADDING_WARNINGS= \
TOML_DISABLE_FLOAT_WARNINGS= \ TOML_DISABLE_FLOAT_WARNINGS= \
TOML_DISABLE_SHADOW_WARNINGS= \ TOML_DISABLE_SHADOW_WARNINGS= \
TOML_DISABLE_SUGGEST_WARNINGS= \
TOML_DISABLE_ALL_WARNINGS= \ TOML_DISABLE_ALL_WARNINGS= \
TOML_POP_WARNINGS= \ TOML_POP_WARNINGS= \
TOML_ASYMMETRICAL_EQUALITY_OPS(...)= \ TOML_ASYMMETRICAL_EQUALITY_OPS(...)= \

View File

@ -37,21 +37,20 @@
/// #include <fstream> //required for parse_file() /// #include <fstream> //required for parse_file()
/// #include <toml++/toml.h> /// #include <toml++/toml.h>
/// ///
/// int main() /// int main(int argc, char** argv)
/// { /// {
/// toml::table tbl; /// toml::table tbl;
/// try /// try
/// { /// {
/// tbl = toml::parse_file("configuration.toml"); /// tbl = toml::parse_file(argv[1]);
/// std::cout << tbl << std::endl;
/// } /// }
/// catch (const toml::parse_error& err) /// catch (const toml::parse_error& err)
/// { /// {
/// std::cerr << "Parsing failed:\n" << err << "\n"; /// std::cerr << "Parsing failed:\n" << err << std::endl;
/// return 1; /// return 1;
/// } /// }
/// ///
/// do_stuff_with_your_config(tbl);
///
/// return 0; /// return 0;
/// } /// }
/// ///
@ -77,6 +76,8 @@
/// ///
/// Call toml::parse() and work with the toml::table you get back, or handle any toml::parse_error that gets thrown: /// Call toml::parse() and work with the toml::table you get back, or handle any toml::parse_error that gets thrown:
/// ///
/// \godbolt{NsR-xf}
///
/// \cpp /// \cpp
/// #include <iostream> /// #include <iostream>
/// #include <sstream> /// #include <sstream>
@ -199,6 +200,9 @@
/// A TOML document is a tree of values, arrays and tables, represented as the toml::value, toml::array /// A TOML document is a tree of values, arrays and tables, represented as the toml::value, toml::array
/// and toml::table, respectively. All three inherit from toml::node, and can be easily accessed via /// and toml::table, respectively. All three inherit from toml::node, and can be easily accessed via
/// the toml::node_view: /// the toml::node_view:
///
/// \godbolt{ieG52U}
///
/// \cpp /// \cpp
/// #include <iostream> /// #include <iostream>
/// #include <toml++/toml.h> /// #include <toml++/toml.h>
@ -300,6 +304,9 @@
/// All toml++ data types have overloaded `operator<<` for ostreams, so 'serializing' a set of TOML data to actual /// All toml++ data types have overloaded `operator<<` for ostreams, so 'serializing' a set of TOML data to actual
/// TOML is done just by printing it to an ostream. Converting it to JSON is done in the same way, /// TOML is done just by printing it to an ostream. Converting it to JSON is done in the same way,
/// but via a toml::json_formatter. /// but via a toml::json_formatter.
///
/// \godbolt{MMNoW4}
///
/// \cpp /// \cpp
/// #include <iostream> /// #include <iostream>
/// #include <toml++/toml.h> /// #include <toml++/toml.h>

View File

@ -8,6 +8,11 @@ body
margin-top: 3rem; margin-top: 3rem;
} }
a
{
text-decoration: none !important;
}
header header
{ {
position: fixed; position: fixed;
@ -136,8 +141,9 @@ pre.m-code + pre.m-console span
} }
/* int and float literals */ /* int and float literals */
.m-code .mi, pre.m-code .mi,
.m-code .mf pre.m-code .mf,
pre.m-code .mh
{ {
color: rgb(181,206,168); color: rgb(181,206,168);
} }
@ -248,3 +254,29 @@ main > article > .m-container.m-container-inflatable > .m-row > div.m-col-l-10.m
margin-top: -1.75rem; margin-top: -1.75rem;
max-width: calc(100% + 2rem); max-width: calc(100% + 2rem);
} }
/* "Try this code on Compiler Explorer" */
.godbolt
{
font-family: 'Source Sans Pro', sans-serif;
}
p.godbolt
{
text-align: center;
padding: 0.0rem;
text-indent: 0.0rem;
opacity: 0.5;
}
p.godbolt:hover
{
opacity: 1.0;
}
a.godbolt
{
padding: 0.5rem;
display: inline-block;
}
pre > p.godbolt
{
float: right;
}

View File

@ -52,13 +52,15 @@
#if TOML_UNDEF_MACROS #if TOML_UNDEF_MACROS
#undef TOML_INT_CHARCONV #undef TOML_INT_CHARCONV
#undef TOML_FLOAT_CHARCONV #undef TOML_FLOAT_CHARCONV
#undef TOML_GNU_ATTR #undef TOML_ATTR
#undef TOML_PUSH_WARNINGS #undef TOML_PUSH_WARNINGS
#undef TOML_DISABLE_SWITCH_WARNINGS #undef TOML_DISABLE_SWITCH_WARNINGS
#undef TOML_DISABLE_INIT_WARNINGS #undef TOML_DISABLE_INIT_WARNINGS
#undef TOML_DISABLE_VTABLE_WARNINGS #undef TOML_DISABLE_VTABLE_WARNINGS
#undef TOML_DISABLE_PADDING_WARNINGS #undef TOML_DISABLE_PADDING_WARNINGS
#undef TOML_DISABLE_FLOAT_WARNINGS #undef TOML_DISABLE_FLOAT_WARNINGS
#undef TOML_DISABLE_SHADOW_WARNINGS
#undef TOML_DISABLE_SUGGEST_WARNINGS
#undef TOML_DISABLE_ALL_WARNINGS #undef TOML_DISABLE_ALL_WARNINGS
#undef TOML_POP_WARNINGS #undef TOML_POP_WARNINGS
#undef TOML_ALWAYS_INLINE #undef TOML_ALWAYS_INLINE

View File

@ -12,7 +12,7 @@ TOML_DISABLE_VTABLE_WARNINGS
namespace toml::impl namespace toml::impl
{ {
template <bool IsConst> template <bool IsConst>
class array_iterator final class TOML_TRIVIAL_ABI array_iterator final
{ {
private: private:
friend class ::toml::array; friend class ::toml::array;
@ -170,8 +170,9 @@ namespace toml::impl
template <typename T> template <typename T>
[[nodiscard]] [[nodiscard]]
TOML_ATTR(returns_nonnull)
TOML_ALWAYS_INLINE TOML_ALWAYS_INLINE
auto make_node(T&& val) noexcept auto* make_node(T&& val) noexcept
{ {
using type = unwrapped<remove_cvref_t<T>>; using type = unwrapped<remove_cvref_t<T>>;
if constexpr (is_one_of<type, array, table>) if constexpr (is_one_of<type, array, table>)
@ -194,8 +195,9 @@ namespace toml::impl
template <typename T> template <typename T>
[[nodiscard]] [[nodiscard]]
TOML_ATTR(returns_nonnull)
TOML_ALWAYS_INLINE TOML_ALWAYS_INLINE
auto make_node(inserter<T>&& val) noexcept auto* make_node(inserter<T>&& val) noexcept
{ {
return make_node(std::move(val.value)); return make_node(std::move(val.value));
} }

View File

@ -13,6 +13,9 @@
#include "toml_array.h" #include "toml_array.h"
TOML_PUSH_WARNINGS
TOML_DISABLE_SUGGEST_WARNINGS
namespace toml namespace toml
{ {
TOML_EXTERNAL_LINKAGE TOML_EXTERNAL_LINKAGE
@ -45,38 +48,41 @@ namespace toml
return *this; return *this;
} }
TOML_EXTERNAL_LINKAGE node_type array::type() const noexcept { return node_type::array; } #define TOML_MEMBER_ATTR(attr) TOML_EXTERNAL_LINKAGE TOML_ATTR(attr)
TOML_EXTERNAL_LINKAGE bool array::is_table() const noexcept { return false; }
TOML_EXTERNAL_LINKAGE bool array::is_array() const noexcept { return true; }
TOML_EXTERNAL_LINKAGE bool array::is_value() const noexcept { return false; }
TOML_EXTERNAL_LINKAGE array* array::as_array() noexcept { return this; }
TOML_EXTERNAL_LINKAGE const array* array::as_array() const noexcept { return this; }
TOML_EXTERNAL_LINKAGE node& array::operator[] (size_t index) noexcept { return *values[index]; } TOML_MEMBER_ATTR(const) node_type array::type() const noexcept { return node_type::array; }
TOML_EXTERNAL_LINKAGE const node& array::operator[] (size_t index) const noexcept { return *values[index]; } TOML_MEMBER_ATTR(const) bool array::is_table() const noexcept { return false; }
TOML_MEMBER_ATTR(const) bool array::is_array() const noexcept { return true; }
TOML_MEMBER_ATTR(const) bool array::is_value() const noexcept { return false; }
TOML_MEMBER_ATTR(const) const array* array::as_array() const noexcept { return this; }
TOML_MEMBER_ATTR(const) array* array::as_array() noexcept { return this; }
TOML_EXTERNAL_LINKAGE node& array::front() noexcept { return *values.front(); } TOML_MEMBER_ATTR(pure) const node& array::operator[] (size_t index) const noexcept { return *values[index]; }
TOML_EXTERNAL_LINKAGE const node& array::front() const noexcept { return *values.front(); } TOML_MEMBER_ATTR(pure) node& array::operator[] (size_t index) noexcept { return *values[index]; }
TOML_EXTERNAL_LINKAGE node& array::back() noexcept { return *values.back(); }
TOML_EXTERNAL_LINKAGE const node& array::back() const noexcept { return *values.back(); }
TOML_EXTERNAL_LINKAGE array::iterator array::begin() noexcept { return { values.begin() }; } TOML_MEMBER_ATTR(pure) const node& array::front() const noexcept { return *values.front(); }
TOML_EXTERNAL_LINKAGE array::const_iterator array::begin() const noexcept { return { values.begin() }; } TOML_MEMBER_ATTR(pure) const node& array::back() const noexcept { return *values.back(); }
TOML_EXTERNAL_LINKAGE array::const_iterator array::cbegin() const noexcept { return { values.cbegin() }; } TOML_MEMBER_ATTR(pure) node& array::front() noexcept { return *values.front(); }
TOML_MEMBER_ATTR(pure) node& array::back() noexcept { return *values.back(); }
TOML_EXTERNAL_LINKAGE array::iterator array::end() noexcept { return { values.end() }; } TOML_MEMBER_ATTR(pure) array::const_iterator array::begin() const noexcept { return { values.begin() }; }
TOML_EXTERNAL_LINKAGE array::const_iterator array::end() const noexcept { return { values.end() }; } TOML_MEMBER_ATTR(pure) array::const_iterator array::end() const noexcept { return { values.end() }; }
TOML_EXTERNAL_LINKAGE array::const_iterator array::cend() const noexcept { return { values.cend() }; } TOML_MEMBER_ATTR(pure) array::const_iterator array::cbegin() const noexcept { return { values.cbegin() }; }
TOML_MEMBER_ATTR(pure) array::const_iterator array::cend() const noexcept { return { values.cend() }; }
TOML_MEMBER_ATTR(pure) array::iterator array::begin() noexcept { return { values.begin() }; }
TOML_MEMBER_ATTR(pure) array::iterator array::end() noexcept { return { values.end() }; }
TOML_MEMBER_ATTR(pure) size_t array::size() const noexcept { return values.size(); }
TOML_MEMBER_ATTR(pure) size_t array::capacity() const noexcept { return values.capacity(); }
TOML_MEMBER_ATTR(pure) bool array::empty() const noexcept { return values.empty(); }
TOML_MEMBER_ATTR(const) size_t array::max_size() const noexcept { return values.max_size(); }
TOML_EXTERNAL_LINKAGE bool array::empty() const noexcept { return values.empty(); }
TOML_EXTERNAL_LINKAGE size_t array::size() const noexcept { return values.size(); }
TOML_EXTERNAL_LINKAGE void array::reserve(size_t new_capacity) { values.reserve(new_capacity); } TOML_EXTERNAL_LINKAGE void array::reserve(size_t new_capacity) { values.reserve(new_capacity); }
TOML_EXTERNAL_LINKAGE void array::clear() noexcept { values.clear(); } TOML_EXTERNAL_LINKAGE void array::clear() noexcept { values.clear(); }
TOML_EXTERNAL_LINKAGE size_t array::max_size() const noexcept { return values.max_size(); }
TOML_EXTERNAL_LINKAGE size_t array::capacity() const noexcept { return values.capacity(); }
TOML_EXTERNAL_LINKAGE void array::shrink_to_fit() { values.shrink_to_fit(); } TOML_EXTERNAL_LINKAGE void array::shrink_to_fit() { values.shrink_to_fit(); }
#undef TOML_MEMBER_ATTR
TOML_EXTERNAL_LINKAGE TOML_EXTERNAL_LINKAGE
void array::truncate(size_t new_size) void array::truncate(size_t new_size)
{ {
@ -103,12 +109,14 @@ namespace toml
} }
TOML_EXTERNAL_LINKAGE TOML_EXTERNAL_LINKAGE
TOML_ATTR(pure)
node* array::get(size_t index) noexcept node* array::get(size_t index) noexcept
{ {
return index < values.size() ? values[index].get() : nullptr; return index < values.size() ? values[index].get() : nullptr;
} }
TOML_EXTERNAL_LINKAGE TOML_EXTERNAL_LINKAGE
TOML_ATTR(pure)
const node* array::get(size_t index) const noexcept const node* array::get(size_t index) const noexcept
{ {
return index < values.size() ? values[index].get() : nullptr; return index < values.size() ? values[index].get() : nullptr;
@ -225,3 +233,5 @@ namespace toml
return *this; return *this;
} }
} }
TOML_POP_WARNINGS // TOML_DISABLE_SUGGEST_WARNINGS

View File

@ -49,7 +49,7 @@ namespace toml
using ptrdiff_t = std::ptrdiff_t; using ptrdiff_t = std::ptrdiff_t;
[[nodiscard]] [[nodiscard]]
TOML_GNU_ATTR(const) TOML_ATTR(const)
TOML_ALWAYS_INLINE TOML_ALWAYS_INLINE
TOML_CONSTEVAL size_t operator"" _sz(unsigned long long n) noexcept TOML_CONSTEVAL size_t operator"" _sz(unsigned long long n) noexcept
{ {
@ -299,7 +299,7 @@ namespace toml::impl
template <typename T> template <typename T>
[[nodiscard]] [[nodiscard]]
TOML_GNU_ATTR(const) TOML_ATTR(const)
TOML_ALWAYS_INLINE TOML_ALWAYS_INLINE
constexpr std::underlying_type_t<T> unbox_enum(T val) noexcept constexpr std::underlying_type_t<T> unbox_enum(T val) noexcept
{ {

View File

@ -20,7 +20,7 @@ namespace toml
}; };
[[nodiscard]] [[nodiscard]]
TOML_GNU_ATTR(const) TOML_ATTR(const)
TOML_ALWAYS_INLINE TOML_ALWAYS_INLINE
constexpr format_flags operator & (format_flags lhs, format_flags rhs) noexcept constexpr format_flags operator & (format_flags lhs, format_flags rhs) noexcept
{ {
@ -28,7 +28,7 @@ namespace toml
} }
[[nodiscard]] [[nodiscard]]
TOML_GNU_ATTR(const) TOML_ATTR(const)
TOML_ALWAYS_INLINE TOML_ALWAYS_INLINE
constexpr format_flags operator | (format_flags lhs, format_flags rhs) noexcept constexpr format_flags operator | (format_flags lhs, format_flags rhs) noexcept
{ {

View File

@ -13,6 +13,9 @@
#include "toml_node.h" #include "toml_node.h"
TOML_PUSH_WARNINGS
TOML_DISABLE_SUGGEST_WARNINGS
namespace toml namespace toml
{ {
TOML_EXTERNAL_LINKAGE TOML_EXTERNAL_LINKAGE
@ -32,35 +35,41 @@ namespace toml
return *this; return *this;
} }
TOML_EXTERNAL_LINKAGE bool node::is_string() const noexcept { return false; } #define TOML_MEMBER_ATTR(attr) TOML_EXTERNAL_LINKAGE TOML_ATTR(attr)
TOML_EXTERNAL_LINKAGE bool node::is_integer() const noexcept { return false; }
TOML_EXTERNAL_LINKAGE bool node::is_floating_point() const noexcept { return false; }
TOML_EXTERNAL_LINKAGE bool node::is_number() const noexcept { return false; }
TOML_EXTERNAL_LINKAGE bool node::is_boolean() const noexcept { return false; }
TOML_EXTERNAL_LINKAGE bool node::is_date() const noexcept { return false; }
TOML_EXTERNAL_LINKAGE bool node::is_time() const noexcept { return false; }
TOML_EXTERNAL_LINKAGE bool node::is_date_time() const noexcept { return false; }
TOML_EXTERNAL_LINKAGE bool node::is_array_of_tables() const noexcept { return false; }
TOML_EXTERNAL_LINKAGE table* node::as_table() noexcept { return nullptr; } TOML_MEMBER_ATTR(const) bool node::is_string() const noexcept { return false; }
TOML_EXTERNAL_LINKAGE array* node::as_array() noexcept { return nullptr; } TOML_MEMBER_ATTR(const) bool node::is_integer() const noexcept { return false; }
TOML_EXTERNAL_LINKAGE value<string>* node::as_string() noexcept { return nullptr; } TOML_MEMBER_ATTR(const) bool node::is_floating_point() const noexcept { return false; }
TOML_EXTERNAL_LINKAGE value<int64_t>* node::as_integer() noexcept { return nullptr; } TOML_MEMBER_ATTR(const) bool node::is_number() const noexcept { return false; }
TOML_EXTERNAL_LINKAGE value<double>* node::as_floating_point() noexcept { return nullptr; } TOML_MEMBER_ATTR(const) bool node::is_boolean() const noexcept { return false; }
TOML_EXTERNAL_LINKAGE value<bool>* node::as_boolean() noexcept { return nullptr; } TOML_MEMBER_ATTR(const) bool node::is_date() const noexcept { return false; }
TOML_EXTERNAL_LINKAGE value<date>* node::as_date() noexcept { return nullptr; } TOML_MEMBER_ATTR(const) bool node::is_time() const noexcept { return false; }
TOML_EXTERNAL_LINKAGE value<time>* node::as_time() noexcept { return nullptr; } TOML_MEMBER_ATTR(const) bool node::is_date_time() const noexcept { return false; }
TOML_EXTERNAL_LINKAGE value<date_time>* node::as_date_time() noexcept { return nullptr; } TOML_MEMBER_ATTR(const) bool node::is_array_of_tables() const noexcept { return false; }
TOML_EXTERNAL_LINKAGE const table* node::as_table() const noexcept { return nullptr; } TOML_MEMBER_ATTR(const) table* node::as_table() noexcept { return nullptr; }
TOML_EXTERNAL_LINKAGE const array* node::as_array() const noexcept { return nullptr; } TOML_MEMBER_ATTR(const) array* node::as_array() noexcept { return nullptr; }
TOML_EXTERNAL_LINKAGE const value<string>* node::as_string() const noexcept { return nullptr; } TOML_MEMBER_ATTR(const) value<string>* node::as_string() noexcept { return nullptr; }
TOML_EXTERNAL_LINKAGE const value<int64_t>* node::as_integer() const noexcept { return nullptr; } TOML_MEMBER_ATTR(const) value<int64_t>* node::as_integer() noexcept { return nullptr; }
TOML_EXTERNAL_LINKAGE const value<double>* node::as_floating_point() const noexcept { return nullptr; } TOML_MEMBER_ATTR(const) value<double>* node::as_floating_point() noexcept { return nullptr; }
TOML_EXTERNAL_LINKAGE const value<bool>* node::as_boolean() const noexcept { return nullptr; } TOML_MEMBER_ATTR(const) value<bool>* node::as_boolean() noexcept { return nullptr; }
TOML_EXTERNAL_LINKAGE const value<date>* node::as_date() const noexcept { return nullptr; } TOML_MEMBER_ATTR(const) value<date>* node::as_date() noexcept { return nullptr; }
TOML_EXTERNAL_LINKAGE const value<time>* node::as_time() const noexcept { return nullptr; } TOML_MEMBER_ATTR(const) value<time>* node::as_time() noexcept { return nullptr; }
TOML_EXTERNAL_LINKAGE const value<date_time>* node::as_date_time() const noexcept { return nullptr; } TOML_MEMBER_ATTR(const) value<date_time>* node::as_date_time() noexcept { return nullptr; }
TOML_EXTERNAL_LINKAGE const source_region& node::source() const noexcept { return source_; } TOML_MEMBER_ATTR(const) const table* node::as_table() const noexcept { return nullptr; }
TOML_MEMBER_ATTR(const) const array* node::as_array() const noexcept { return nullptr; }
TOML_MEMBER_ATTR(const) const value<string>* node::as_string() const noexcept { return nullptr; }
TOML_MEMBER_ATTR(const) const value<int64_t>* node::as_integer() const noexcept { return nullptr; }
TOML_MEMBER_ATTR(const) const value<double>* node::as_floating_point() const noexcept { return nullptr; }
TOML_MEMBER_ATTR(const) const value<bool>* node::as_boolean() const noexcept { return nullptr; }
TOML_MEMBER_ATTR(const) const value<date>* node::as_date() const noexcept { return nullptr; }
TOML_MEMBER_ATTR(const) const value<time>* node::as_time() const noexcept { return nullptr; }
TOML_MEMBER_ATTR(const) const value<date_time>* node::as_date_time() const noexcept { return nullptr; }
TOML_MEMBER_ATTR(const) const source_region& node::source() const noexcept { return source_; }
#undef TOML_MEMBER_ATTR
} }
TOML_POP_WARNINGS // TOML_DISABLE_SUGGEST_WARNINGS

View File

@ -91,20 +91,20 @@ namespace toml
public: public:
TOML_NODISCARD_CTOR TOML_NODISCARD_CTOR
TOML_GNU_ATTR(nonnull) TOML_ATTR(nonnull)
parse_error(const char* desc, source_region&& src) noexcept parse_error(const char* desc, source_region&& src) noexcept
: std::runtime_error{ desc }, : std::runtime_error{ desc },
source_{ std::move(src) } source_{ std::move(src) }
{} {}
TOML_NODISCARD_CTOR TOML_NODISCARD_CTOR
TOML_GNU_ATTR(nonnull) TOML_ATTR(nonnull)
parse_error(const char* desc, const source_region& src) noexcept parse_error(const char* desc, const source_region& src) noexcept
: parse_error{ desc, source_region{ src } } : parse_error{ desc, source_region{ src } }
{} {}
TOML_NODISCARD_CTOR TOML_NODISCARD_CTOR
TOML_GNU_ATTR(nonnull) TOML_ATTR(nonnull)
parse_error(const char* desc, const source_position& position, const source_path_ptr& path = {}) noexcept parse_error(const char* desc, const source_position& position, const source_path_ptr& path = {}) noexcept
: parse_error{ desc, source_region{ position, position, path } } : parse_error{ desc, source_region{ position, position, path } }
{} {}

View File

@ -522,10 +522,9 @@ namespace toml
TOML_PARSE_FILE_ERROR("Could not determine file size", source_position{}); TOML_PARSE_FILE_ERROR("Could not determine file size", source_position{});
file.seekg(0, std::ios::beg); file.seekg(0, std::ios::beg);
// if the file size is the sweet spot, read the whole thing into memory and parse from there // read the whole file into memory first if the file isn't too large
constexpr auto small_file_threshold = 1024 * 32; //32 kilobytes constexpr auto large_file_threshold = 1024 * 1024 * static_cast<int>(sizeof(void*)) * 4; // 32 megabytes on 64-bit
constexpr auto large_file_threshold = 1024 * 1024 * static_cast<int>(sizeof(void*)) * 8; // 64 megabytes on 64-bit if (file_size <= large_file_threshold)
if (file_size >= small_file_threshold && file_size <= large_file_threshold)
{ {
std::vector<StreamChar> file_data; std::vector<StreamChar> file_data;
file_data.resize(static_cast<size_t>(file_size)); file_data.resize(static_cast<size_t>(file_size));

View File

@ -95,7 +95,7 @@ namespace TOML_INTERNAL_NAMESPACE
} }
[[nodiscard]] [[nodiscard]]
TOML_GNU_ATTR(const) TOML_ATTR(const)
TOML_INTERNAL_LINKAGE TOML_INTERNAL_LINKAGE
std::string_view to_sv(bool val) noexcept std::string_view to_sv(bool val) noexcept
{ {
@ -120,7 +120,7 @@ namespace TOML_INTERNAL_NAMESPACE
} }
template <typename T> template <typename T>
TOML_GNU_ATTR(nonnull) TOML_ATTR(nonnull)
TOML_INTERNAL_LINKAGE TOML_INTERNAL_LINKAGE
TOML_NEVER_INLINE TOML_NEVER_INLINE
void concatenate(char*& write_pos, char *const buf_end, const T& arg) noexcept void concatenate(char*& write_pos, char *const buf_end, const T& arg) noexcept

View File

@ -72,7 +72,7 @@
#define TOML_ASSUME(cond) __builtin_assume(cond) #define TOML_ASSUME(cond) __builtin_assume(cond)
#define TOML_UNREACHABLE __builtin_unreachable() #define TOML_UNREACHABLE __builtin_unreachable()
#define TOML_GNU_ATTR(...) __attribute__((__VA_ARGS__)) #define TOML_ATTR(...) __attribute__((__VA_ARGS__))
#if defined(_MSC_VER) // msvc compat mode #if defined(_MSC_VER) // msvc compat mode
#ifdef __has_declspec_attribute #ifdef __has_declspec_attribute
#if __has_declspec_attribute(novtable) #if __has_declspec_attribute(novtable)
@ -151,10 +151,13 @@
#define TOML_DISABLE_PADDING_WARNINGS _Pragma("GCC diagnostic ignored \"-Wpadded\"") #define TOML_DISABLE_PADDING_WARNINGS _Pragma("GCC diagnostic ignored \"-Wpadded\"")
#define TOML_DISABLE_FLOAT_WARNINGS _Pragma("GCC diagnostic ignored \"-Wfloat-equal\"") #define TOML_DISABLE_FLOAT_WARNINGS _Pragma("GCC diagnostic ignored \"-Wfloat-equal\"")
#define TOML_DISABLE_SHADOW_WARNINGS _Pragma("GCC diagnostic ignored \"-Wshadow\"") #define TOML_DISABLE_SHADOW_WARNINGS _Pragma("GCC diagnostic ignored \"-Wshadow\"")
#define TOML_DISABLE_SUGGEST_WARNINGS _Pragma("GCC diagnostic ignored \"-Wsuggest-attribute=const\"") \
_Pragma("GCC diagnostic ignored \"-Wsuggest-attribute=pure\"")
#define TOML_DISABLE_ALL_WARNINGS _Pragma("GCC diagnostic ignored \"-Wall\"") \ #define TOML_DISABLE_ALL_WARNINGS _Pragma("GCC diagnostic ignored \"-Wall\"") \
_Pragma("GCC diagnostic ignored \"-Wextra\"") \ _Pragma("GCC diagnostic ignored \"-Wextra\"") \
_Pragma("GCC diagnostic ignored \"-Wchar-subscripts\"") \ _Pragma("GCC diagnostic ignored \"-Wchar-subscripts\"") \
_Pragma("GCC diagnostic ignored \"-Wtype-limits\"") \ _Pragma("GCC diagnostic ignored \"-Wtype-limits\"") \
TOML_DISABLE_SUGGEST_WARNINGS \
TOML_DISABLE_SWITCH_WARNINGS \ TOML_DISABLE_SWITCH_WARNINGS \
TOML_DISABLE_INIT_WARNINGS \ TOML_DISABLE_INIT_WARNINGS \
TOML_DISABLE_PADDING_WARNINGS \ TOML_DISABLE_PADDING_WARNINGS \
@ -162,7 +165,7 @@
TOML_DISABLE_SHADOW_WARNINGS TOML_DISABLE_SHADOW_WARNINGS
#define TOML_POP_WARNINGS _Pragma("GCC diagnostic pop") #define TOML_POP_WARNINGS _Pragma("GCC diagnostic pop")
#define TOML_GNU_ATTR(...) __attribute__((__VA_ARGS__)) #define TOML_ATTR(...) __attribute__((__VA_ARGS__))
#ifndef TOML_ALWAYS_INLINE #ifndef TOML_ALWAYS_INLINE
#define TOML_ALWAYS_INLINE __attribute__((__always_inline__)) inline #define TOML_ALWAYS_INLINE __attribute__((__always_inline__)) inline
#endif #endif
@ -259,6 +262,9 @@
#ifndef TOML_DISABLE_SHADOW_WARNINGS #ifndef TOML_DISABLE_SHADOW_WARNINGS
#define TOML_DISABLE_SHADOW_WARNINGS #define TOML_DISABLE_SHADOW_WARNINGS
#endif #endif
#ifndef TOML_DISABLE_SUGGEST_WARNINGS
#define TOML_DISABLE_SUGGEST_WARNINGS
#endif
#ifndef TOML_DISABLE_ALL_WARNINGS #ifndef TOML_DISABLE_ALL_WARNINGS
#define TOML_DISABLE_ALL_WARNINGS #define TOML_DISABLE_ALL_WARNINGS
#endif #endif
@ -266,8 +272,8 @@
#define TOML_POP_WARNINGS #define TOML_POP_WARNINGS
#endif #endif
#ifndef TOML_GNU_ATTR #ifndef TOML_ATTR
#define TOML_GNU_ATTR(...) #define TOML_ATTR(...)
#endif #endif
#ifndef TOML_INTERFACE #ifndef TOML_INTERFACE

View File

@ -60,7 +60,7 @@ namespace toml::impl
} }
template <typename Char> template <typename Char>
TOML_GNU_ATTR(nonnull) TOML_ATTR(nonnull)
TOML_ALWAYS_INLINE TOML_ALWAYS_INLINE
void print_to_stream(const char* str, size_t len, std::basic_ostream<Char>& stream) void print_to_stream(const char* str, size_t len, std::basic_ostream<Char>& stream)
{ {
@ -79,7 +79,7 @@ namespace toml::impl
} }
template <typename Char> template <typename Char>
TOML_GNU_ATTR(nonnull) TOML_ATTR(nonnull)
TOML_ALWAYS_INLINE TOML_ALWAYS_INLINE
void print_to_stream(const char8_t* str, size_t len, std::basic_ostream<Char>& stream) void print_to_stream(const char8_t* str, size_t len, std::basic_ostream<Char>& stream)
{ {

View File

@ -14,6 +14,9 @@
#include "toml_table.h" #include "toml_table.h"
#include "toml_node_view.h" #include "toml_node_view.h"
TOML_PUSH_WARNINGS
TOML_DISABLE_SUGGEST_WARNINGS
namespace toml namespace toml
{ {
TOML_EXTERNAL_LINKAGE TOML_EXTERNAL_LINKAGE
@ -47,15 +50,31 @@ namespace toml
return *this; return *this;
} }
TOML_EXTERNAL_LINKAGE node_type table::type() const noexcept { return node_type::table; } #define TOML_MEMBER_ATTR(attr) TOML_EXTERNAL_LINKAGE TOML_ATTR(attr)
TOML_EXTERNAL_LINKAGE bool table::is_table() const noexcept { return true; }
TOML_EXTERNAL_LINKAGE bool table::is_array() const noexcept { return false; } TOML_MEMBER_ATTR(const) node_type table::type() const noexcept { return node_type::table; }
TOML_EXTERNAL_LINKAGE bool table::is_value() const noexcept { return false; } TOML_MEMBER_ATTR(const) bool table::is_table() const noexcept { return true; }
TOML_EXTERNAL_LINKAGE table* table::as_table() noexcept { return this; } TOML_MEMBER_ATTR(const) bool table::is_array() const noexcept { return false; }
TOML_EXTERNAL_LINKAGE const table* table::as_table() const noexcept { return this; } TOML_MEMBER_ATTR(const) bool table::is_value() const noexcept { return false; }
TOML_EXTERNAL_LINKAGE bool table::is_inline() const noexcept { return inline_; } TOML_MEMBER_ATTR(const) const table* table::as_table() const noexcept { return this; }
TOML_MEMBER_ATTR(const) table* table::as_table() noexcept { return this; }
TOML_MEMBER_ATTR(pure) bool table::is_inline() const noexcept { return inline_; }
TOML_EXTERNAL_LINKAGE void table::is_inline(bool val) noexcept { inline_ = val; } TOML_EXTERNAL_LINKAGE void table::is_inline(bool val) noexcept { inline_ = val; }
TOML_EXTERNAL_LINKAGE table::const_iterator table::begin() const noexcept { return { values.begin() }; }
TOML_EXTERNAL_LINKAGE table::const_iterator table::end() const noexcept { return { values.end() }; }
TOML_EXTERNAL_LINKAGE table::const_iterator table::cbegin() const noexcept { return { values.cbegin() }; }
TOML_EXTERNAL_LINKAGE table::const_iterator table::cend() const noexcept { return { values.cend() }; }
TOML_EXTERNAL_LINKAGE table::iterator table::begin() noexcept { return { values.begin() }; }
TOML_EXTERNAL_LINKAGE table::iterator table::end() noexcept { return { values.end() }; }
TOML_MEMBER_ATTR(pure) bool table::empty() const noexcept { return values.empty(); }
TOML_MEMBER_ATTR(pure) size_t table::size() const noexcept { return values.size(); }
TOML_EXTERNAL_LINKAGE void table::clear() noexcept { values.clear(); }
#undef TOML_MEMBER_ATTR
TOML_EXTERNAL_LINKAGE TOML_EXTERNAL_LINKAGE
node_view<node> table::operator[] (string_view key) noexcept node_view<node> table::operator[] (string_view key) noexcept
{ {
@ -67,18 +86,6 @@ namespace toml
return { this->get(key) }; return { this->get(key) };
} }
TOML_EXTERNAL_LINKAGE table::iterator table::begin() noexcept { return { values.begin() }; }
TOML_EXTERNAL_LINKAGE table::const_iterator table::begin() const noexcept { return { values.begin() }; }
TOML_EXTERNAL_LINKAGE table::const_iterator table::cbegin() const noexcept { return { values.cbegin() }; }
TOML_EXTERNAL_LINKAGE table::iterator table::end() noexcept { return { values.end() }; }
TOML_EXTERNAL_LINKAGE table::const_iterator table::end() const noexcept { return { values.end() }; }
TOML_EXTERNAL_LINKAGE table::const_iterator table::cend() const noexcept { return { values.cend() }; }
TOML_EXTERNAL_LINKAGE bool table::empty() const noexcept { return values.empty(); }
TOML_EXTERNAL_LINKAGE size_t table::size() const noexcept { return values.size(); }
TOML_EXTERNAL_LINKAGE void table::clear() noexcept { values.clear(); }
TOML_EXTERNAL_LINKAGE TOML_EXTERNAL_LINKAGE
table::iterator table::erase(iterator pos) noexcept table::iterator table::erase(iterator pos) noexcept
{ {
@ -175,3 +182,5 @@ namespace toml
return !(lhs == rhs); return !(lhs == rhs);
} }
} }
TOML_POP_WARNINGS // TOML_DISABLE_SUGGEST_WARNINGS

View File

@ -11,7 +11,7 @@ namespace toml::impl
{ {
template <typename... T> template <typename... T>
[[nodiscard]] [[nodiscard]]
TOML_GNU_ATTR(const) TOML_ATTR(const)
constexpr bool is_match(char32_t codepoint, T... vals) noexcept constexpr bool is_match(char32_t codepoint, T... vals) noexcept
{ {
static_assert((std::is_same_v<char32_t, T> && ...)); static_assert((std::is_same_v<char32_t, T> && ...));
@ -19,7 +19,7 @@ namespace toml::impl
} }
[[nodiscard]] [[nodiscard]]
TOML_GNU_ATTR(const) TOML_ATTR(const)
TOML_ALWAYS_INLINE TOML_ALWAYS_INLINE
constexpr bool is_ascii_whitespace(char32_t codepoint) noexcept constexpr bool is_ascii_whitespace(char32_t codepoint) noexcept
{ {
@ -27,7 +27,7 @@ namespace toml::impl
} }
[[nodiscard]] [[nodiscard]]
TOML_GNU_ATTR(const) TOML_ATTR(const)
constexpr bool is_unicode_whitespace(char32_t codepoint) noexcept constexpr bool is_unicode_whitespace(char32_t codepoint) noexcept
{ {
// see: https://en.wikipedia.org/wiki/Whitespace_character#Unicode // see: https://en.wikipedia.org/wiki/Whitespace_character#Unicode
@ -43,7 +43,7 @@ namespace toml::impl
} }
[[nodiscard]] [[nodiscard]]
TOML_GNU_ATTR(const) TOML_ATTR(const)
constexpr bool is_whitespace(char32_t codepoint) noexcept constexpr bool is_whitespace(char32_t codepoint) noexcept
{ {
return is_ascii_whitespace(codepoint) || is_unicode_whitespace(codepoint); return is_ascii_whitespace(codepoint) || is_unicode_whitespace(codepoint);
@ -51,7 +51,7 @@ namespace toml::impl
template <bool IncludeCarriageReturn = true> template <bool IncludeCarriageReturn = true>
[[nodiscard]] [[nodiscard]]
TOML_GNU_ATTR(const) TOML_ATTR(const)
TOML_ALWAYS_INLINE TOML_ALWAYS_INLINE
constexpr bool is_ascii_line_break(char32_t codepoint) noexcept constexpr bool is_ascii_line_break(char32_t codepoint) noexcept
{ {
@ -60,7 +60,7 @@ namespace toml::impl
} }
[[nodiscard]] [[nodiscard]]
TOML_GNU_ATTR(const) TOML_ATTR(const)
constexpr bool is_unicode_line_break(char32_t codepoint) noexcept constexpr bool is_unicode_line_break(char32_t codepoint) noexcept
{ {
// see https://en.wikipedia.org/wiki/Whitespace_character#Unicode // see https://en.wikipedia.org/wiki/Whitespace_character#Unicode
@ -74,14 +74,14 @@ namespace toml::impl
template <bool IncludeCarriageReturn = true> template <bool IncludeCarriageReturn = true>
[[nodiscard]] [[nodiscard]]
TOML_GNU_ATTR(const) TOML_ATTR(const)
constexpr bool is_line_break(char32_t codepoint) noexcept constexpr bool is_line_break(char32_t codepoint) noexcept
{ {
return is_ascii_line_break<IncludeCarriageReturn>(codepoint) || is_unicode_line_break(codepoint); return is_ascii_line_break<IncludeCarriageReturn>(codepoint) || is_unicode_line_break(codepoint);
} }
[[nodiscard]] [[nodiscard]]
TOML_GNU_ATTR(const) TOML_ATTR(const)
TOML_ALWAYS_INLINE TOML_ALWAYS_INLINE
constexpr bool is_string_delimiter(char32_t codepoint) noexcept constexpr bool is_string_delimiter(char32_t codepoint) noexcept
{ {
@ -89,7 +89,7 @@ namespace toml::impl
} }
[[nodiscard]] [[nodiscard]]
TOML_GNU_ATTR(const) TOML_ATTR(const)
TOML_ALWAYS_INLINE TOML_ALWAYS_INLINE
constexpr bool is_ascii_letter(char32_t codepoint) noexcept constexpr bool is_ascii_letter(char32_t codepoint) noexcept
{ {
@ -98,7 +98,7 @@ namespace toml::impl
} }
[[nodiscard]] [[nodiscard]]
TOML_GNU_ATTR(const) TOML_ATTR(const)
TOML_ALWAYS_INLINE TOML_ALWAYS_INLINE
constexpr bool is_binary_digit(char32_t codepoint) noexcept constexpr bool is_binary_digit(char32_t codepoint) noexcept
{ {
@ -106,7 +106,7 @@ namespace toml::impl
} }
[[nodiscard]] [[nodiscard]]
TOML_GNU_ATTR(const) TOML_ATTR(const)
TOML_ALWAYS_INLINE TOML_ALWAYS_INLINE
constexpr bool is_octal_digit(char32_t codepoint) noexcept constexpr bool is_octal_digit(char32_t codepoint) noexcept
{ {
@ -114,7 +114,7 @@ namespace toml::impl
} }
[[nodiscard]] [[nodiscard]]
TOML_GNU_ATTR(const) TOML_ATTR(const)
TOML_ALWAYS_INLINE TOML_ALWAYS_INLINE
constexpr bool is_decimal_digit(char32_t codepoint) noexcept constexpr bool is_decimal_digit(char32_t codepoint) noexcept
{ {
@ -123,7 +123,7 @@ namespace toml::impl
template <typename T> template <typename T>
[[nodiscard]] [[nodiscard]]
TOML_GNU_ATTR(const) TOML_ATTR(const)
TOML_ALWAYS_INLINE TOML_ALWAYS_INLINE
constexpr std::uint_least32_t hex_to_dec(const T codepoint) noexcept constexpr std::uint_least32_t hex_to_dec(const T codepoint) noexcept
{ {
@ -137,7 +137,7 @@ namespace toml::impl
} }
[[nodiscard]] [[nodiscard]]
TOML_GNU_ATTR(const) TOML_ATTR(const)
constexpr bool is_bare_key_character(char32_t codepoint) noexcept constexpr bool is_bare_key_character(char32_t codepoint) noexcept
{ {
return is_ascii_letter(codepoint) return is_ascii_letter(codepoint)
@ -154,7 +154,7 @@ namespace toml::impl
} }
[[nodiscard]] [[nodiscard]]
TOML_GNU_ATTR(const) TOML_ATTR(const)
constexpr bool is_value_terminator(char32_t codepoint) noexcept constexpr bool is_value_terminator(char32_t codepoint) noexcept
{ {
return is_ascii_line_break(codepoint) return is_ascii_line_break(codepoint)
@ -169,7 +169,7 @@ namespace toml::impl
} }
[[nodiscard]] [[nodiscard]]
TOML_GNU_ATTR(const) TOML_ATTR(const)
TOML_ALWAYS_INLINE TOML_ALWAYS_INLINE
constexpr bool is_control_character(char32_t codepoint) noexcept constexpr bool is_control_character(char32_t codepoint) noexcept
{ {
@ -177,7 +177,7 @@ namespace toml::impl
} }
[[nodiscard]] [[nodiscard]]
TOML_GNU_ATTR(const) TOML_ATTR(const)
TOML_ALWAYS_INLINE TOML_ALWAYS_INLINE
constexpr bool is_nontab_control_character(char32_t codepoint) noexcept constexpr bool is_nontab_control_character(char32_t codepoint) noexcept
{ {
@ -187,7 +187,7 @@ namespace toml::impl
} }
[[nodiscard]] [[nodiscard]]
TOML_GNU_ATTR(const) TOML_ATTR(const)
TOML_ALWAYS_INLINE TOML_ALWAYS_INLINE
constexpr bool is_unicode_surrogate(char32_t codepoint) noexcept constexpr bool is_unicode_surrogate(char32_t codepoint) noexcept
{ {

View File

@ -13,7 +13,7 @@ namespace toml::impl
//# Returns true if a codepoint matches any of: //# Returns true if a codepoint matches any of:
//# 0 - 9, A - F, a - f //# 0 - 9, A - F, a - f
[[nodiscard]] [[nodiscard]]
TOML_GNU_ATTR(const) TOML_ATTR(const)
constexpr bool is_hexadecimal_digit(char32_t cp) noexcept constexpr bool is_hexadecimal_digit(char32_t cp) noexcept
{ {
using ui64 = std::uint_least64_t; using ui64 = std::uint_least64_t;
@ -26,7 +26,7 @@ namespace toml::impl
//# Returns true if a codepoint belongs to any of these categories: //# Returns true if a codepoint belongs to any of these categories:
//# Ll, Lm, Lo, Lt, Lu //# Ll, Lm, Lo, Lt, Lu
[[nodiscard]] [[nodiscard]]
TOML_GNU_ATTR(const) TOML_ATTR(const)
constexpr bool is_unicode_letter(char32_t cp) noexcept constexpr bool is_unicode_letter(char32_t cp) noexcept
{ {
using ui64 = std::uint_least64_t; using ui64 = std::uint_least64_t;
@ -383,7 +383,7 @@ namespace toml::impl
//# Returns true if a codepoint belongs to any of these categories: //# Returns true if a codepoint belongs to any of these categories:
//# Nd, Nl //# Nd, Nl
[[nodiscard]] [[nodiscard]]
TOML_GNU_ATTR(const) TOML_ATTR(const)
constexpr bool is_unicode_number(char32_t cp) noexcept constexpr bool is_unicode_number(char32_t cp) noexcept
{ {
using ui64 = std::uint_least64_t; using ui64 = std::uint_least64_t;
@ -541,7 +541,7 @@ namespace toml::impl
//# Returns true if a codepoint belongs to any of these categories: //# Returns true if a codepoint belongs to any of these categories:
//# Mn, Mc //# Mn, Mc
[[nodiscard]] [[nodiscard]]
TOML_GNU_ATTR(const) TOML_ATTR(const)
constexpr bool is_unicode_combining_mark(char32_t cp) noexcept constexpr bool is_unicode_combining_mark(char32_t cp) noexcept
{ {
using ui64 = std::uint_least64_t; using ui64 = std::uint_least64_t;

View File

@ -163,7 +163,7 @@ namespace toml::impl
} }
[[nodiscard]] [[nodiscard]]
TOML_GNU_ATTR(pure) TOML_ATTR(pure)
TOML_ALWAYS_INLINE TOML_ALWAYS_INLINE
constexpr operator char32_t& () noexcept constexpr operator char32_t& () noexcept
{ {
@ -171,7 +171,7 @@ namespace toml::impl
} }
[[nodiscard]] [[nodiscard]]
TOML_GNU_ATTR(pure) TOML_ATTR(pure)
TOML_ALWAYS_INLINE TOML_ALWAYS_INLINE
constexpr operator const char32_t& () const noexcept constexpr operator const char32_t& () const noexcept
{ {
@ -179,7 +179,7 @@ namespace toml::impl
} }
[[nodiscard]] [[nodiscard]]
TOML_GNU_ATTR(pure) TOML_ATTR(pure)
TOML_ALWAYS_INLINE TOML_ALWAYS_INLINE
constexpr const char32_t& operator* () const noexcept constexpr const char32_t& operator* () const noexcept
{ {

View File

@ -84,6 +84,9 @@ if build_tests or build_examples
'-Wunused-parameter', '-Wunused-parameter',
'-Wvariadic-macros', '-Wvariadic-macros',
'-Wwrite-strings', '-Wwrite-strings',
'-Wmissing-noreturn',
'-Wsuggest-attribute=const',
'-Wsuggest-attribute=pure'
], ],
language : 'cpp' language : 'cpp'
) )

View File

@ -15,8 +15,13 @@ import math
import dateutil.parser # pip install python-dateutil import dateutil.parser # pip install python-dateutil
from datetime import datetime, date, time from datetime import datetime, date, time
def sanitize(s): def sanitize(s):
return re.sub(r'[ _:;\/-]+', '_', s, 0, re.I | re.M) s = re.sub(r'[ _:;\/-]+', '_', s, 0, re.I | re.M)
if s in ('bool', 'float', 'int', 'double', 'auto'):
s = s + '_'
return s
@ -207,10 +212,9 @@ def python_to_tomlpp(node):
class TomlTest: class TomlTest:
def __init__(self, file_path, group, name, is_valid_case): def __init__(self, file_path, name, is_valid_case):
self.__name = name self.__name = name
self.__group = group self.__identifier = sanitize(name)
self.__identifier = sanitize(group + '_' + name)
self.__data = utils.read_all_text_from_file(file_path).strip() self.__data = utils.read_all_text_from_file(file_path).strip()
self.condition = '' self.condition = ''
if is_valid_case: if is_valid_case:
@ -235,9 +239,6 @@ class TomlTest:
def name(self): def name(self):
return self.__name return self.__name
def group(self):
return self.__group
def identifier(self): def identifier(self):
return self.__identifier return self.__identifier
@ -255,78 +256,32 @@ class TomlTest:
def load_tests(source_folder, group, is_valid_set, ignore_list): def load_tests(source_folder, is_valid_set, ignore_list):
tests = [] tests = []
files = [(fp, path.splitext(path.split(fp)[1])[0]) for fp in utils.get_all_files(source_folder, all="*.toml")] files = [(fp, path.splitext(path.split(fp)[1])[0]) for fp in utils.get_all_files(source_folder, all="*.toml")]
for file_path,name in files: for file_path,name in files:
if ignore_list and name in ignore_list: if ignore_list and name in ignore_list:
continue continue
tests.append(TomlTest(file_path, group, name, is_valid_set)) tests.append(TomlTest(file_path, name, is_valid_set))
return tests return tests
def set_condition(tests, condition, group, names): def set_condition(tests, condition, names):
for test in tests: for test in tests:
if test.group() == group and test.name() in names: if test.name() in names:
test.condition = condition test.condition = condition
def main(): def load_valid_inputs(tests, extern_root):
extern_root = path.join(utils.get_script_folder(), '..', 'extern') tests['valid']['burntsushi'] = load_tests(path.join(extern_root, 'toml-test', 'tests', 'valid'), True, (
tests = { 'valid': list(), 'invalid': list() }
tests['invalid'] += load_tests(path.join(extern_root, 'toml-test', 'tests', 'invalid'), 'burntsushi', False, (
# false negatives after TOML 0.4.0
'array-mixed-types-arrays-and-ints',
'array-mixed-types-ints-and-floats',
'array-mixed-types-strings-and-ints'
))
set_condition(tests['invalid'], '!TOML_LANG_UNRELEASED', 'burntsushi', (
'datetime-malformed-no-secs',
'inline-table-linebreak',
'multi-line-inline-table',
'string-byte-escapes'
))
tests['invalid'] += load_tests(path.join(extern_root, 'toml-spec-tests', 'errors'), 'iarna', False, (
# I test these explicitly in the other test files (they get broken by I/O)
'comment-control-1',
'comment-control-2',
'comment-control-3',
'comment-control-4',
'string-basic-control-1',
'string-basic-control-2',
'string-basic-control-3',
'string-basic-control-4',
'string-basic-multiline-control-1',
'string-basic-multiline-control-2',
'string-basic-multiline-control-3',
'string-basic-multiline-control-4',
'string-literal-control-1',
'string-literal-control-2',
'string-literal-control-3',
'string-literal-control-4',
'string-literal-multiline-control-1',
'string-literal-multiline-control-2',
'string-literal-multiline-control-3',
'string-literal-multiline-control-4'
))
set_condition(tests['invalid'], '!TOML_LANG_UNRELEASED', 'iarna', (
'inline-table-trailing-comma',
))
tests['valid'] += load_tests(path.join(extern_root, 'toml-test', 'tests', 'valid'), 'burntsushi', True, (
# newline/escape handling tests. these get broken by I/O (I test them separately) # newline/escape handling tests. these get broken by I/O (I test them separately)
'string-escapes', 'string-escapes',
# bugged: https://github.com/BurntSushi/toml-test/issues/58 # bugged: https://github.com/BurntSushi/toml-test/issues/58
'datetime' 'datetime'
)) ))
tests['valid']['iarna'] = load_tests(path.join(extern_root, 'toml-spec-tests', 'values'), True, (
tests['valid'] += load_tests(path.join(extern_root, 'toml-spec-tests', 'values'), 'iarna', True, (
# these are stress-tests for 'large' datasets. I test these separately. Having them inline in C++ code is insane. # these are stress-tests for 'large' datasets. I test these separately. Having them inline in C++ code is insane.
'qa-array-inline-1000', 'qa-array-inline-1000',
'qa-array-inline-nested-1000', 'qa-array-inline-nested-1000',
@ -359,12 +314,57 @@ def main():
'spec-string-basic-multiline-4', 'spec-string-basic-multiline-4',
)) ))
def load_invalid_inputs(tests, extern_root):
tests['invalid']['burntsushi'] = load_tests(path.join(extern_root, 'toml-test', 'tests', 'invalid'), False, (
# false negatives after TOML 0.4.0
'array-mixed-types-arrays-and-ints',
'array-mixed-types-ints-and-floats',
'array-mixed-types-strings-and-ints'
))
set_condition(tests['invalid']['burntsushi'], '!TOML_LANG_UNRELEASED', (
'datetime-malformed-no-secs',
'inline-table-linebreak',
'multi-line-inline-table',
'string-byte-escapes'
))
tests['invalid']['iarna'] = load_tests(path.join(extern_root, 'toml-spec-tests', 'errors'), False, (
# I test these explicitly in the other test files (they get broken by I/O)
'comment-control-1',
'comment-control-2',
'comment-control-3',
'comment-control-4',
'string-basic-control-1',
'string-basic-control-2',
'string-basic-control-3',
'string-basic-control-4',
'string-basic-multiline-control-1',
'string-basic-multiline-control-2',
'string-basic-multiline-control-3',
'string-basic-multiline-control-4',
'string-literal-control-1',
'string-literal-control-2',
'string-literal-control-3',
'string-literal-control-4',
'string-literal-multiline-control-1',
'string-literal-multiline-control-2',
'string-literal-multiline-control-3',
'string-literal-multiline-control-4'
))
set_condition(tests['invalid']['iarna'], '!TOML_LANG_UNRELEASED', (
'inline-table-trailing-comma',
))
def write_test_file(name, test_cases):
conditions = set() conditions = set()
for test_type, test_cases in tests.items():
for test in test_cases: for test in test_cases:
conditions.add(test.condition) conditions.add(test.condition)
test_file_path = path.join(utils.get_script_folder(), '..', 'tests', 'conformance.cpp') test_file_path = path.join(utils.get_script_folder(), '..', 'tests', 'conformance_{}.cpp'.format(sanitize(name.strip())))
print("Writing to {}".format(test_file_path)) print("Writing to {}".format(test_file_path))
with open(test_file_path, 'w', encoding='utf-8', newline='\n') as test_file: with open(test_file_path, 'w', encoding='utf-8', newline='\n') as test_file:
write = lambda txt: print(txt, file=test_file) write = lambda txt: print(txt, file=test_file)
@ -385,56 +385,54 @@ def main():
write('TOML_PUSH_WARNINGS') write('TOML_PUSH_WARNINGS')
write('TOML_DISABLE_ALL_WARNINGS // unused variable spam') write('TOML_DISABLE_ALL_WARNINGS // unused variable spam')
write('') write('')
write('namespace {') write('namespace')
write('')
for test_type, test_cases in tests.items():
write('namespace {}'.format(test_type))
write('{') write('{')
for test in test_cases: for test in test_cases:
write('\t{}'.format(test)) write('\t{}'.format(test))
write('}') write('}')
write('') write('')
write('}')
write('')
write('TOML_POP_WARNINGS') write('TOML_POP_WARNINGS')
write('') write('')
# tests # tests
write('TEST_CASE("conformance")') write('TEST_CASE("conformance - {}")'.format(name))
write('{') write('{')
for test_type, test_cases in tests.items():
write('\t'+utils.make_divider(test_type + ' inputs', 20, line_length=116))
write('\t#if 1')
write('\t{')
for condition in conditions: for condition in conditions:
if condition != '': if condition != '':
write('') write('')
write('\t\t#if {}'.format(condition)); write('\t#if {}'.format(condition));
for test in test_cases: for test in test_cases:
if test.condition != condition: if test.condition != condition:
continue continue
expected = test.expected() expected = test.expected()
if isinstance(expected, bool): if isinstance(expected, bool):
if expected: if expected:
write('\t\tparsing_should_succeed(FILE_LINE_ARGS, {}::{});'.format(test_type, test.identifier())) write('\tparsing_should_succeed(FILE_LINE_ARGS, {});'.format(test.identifier()))
else: else:
write('\t\tparsing_should_fail(FILE_LINE_ARGS, {}::{});'.format(test_type, test.identifier())) write('\tparsing_should_fail(FILE_LINE_ARGS, {});'.format(test.identifier()))
else: else:
write('\tparsing_should_succeed(FILE_LINE_ARGS, {}, [](toml::table&& tbl)'.format(test.identifier()))
write('\t{')
write('\t\tauto expected = {};'.format(expected.render('\t\t')))
write('\t\tREQUIRE(tbl == expected);')
write('\t});')
write('') write('')
write('\t\tparsing_should_succeed(FILE_LINE_ARGS, {}::{}, [](toml::table&& tbl)'.format(test_type, test.identifier()))
write('\t\t{')
write('\t\t\tauto expected = {};'.format(expected.render('\t\t\t')))
write('\t\t\tREQUIRE(tbl == expected);')
write('\t\t});')
if condition != '': if condition != '':
write('\t\t#endif // {}'.format(condition)); write('\t#endif // {}'.format(condition));
write('\t}')
write('\t#endif')
write('')
write('}') write('}')
write('') write('')
def main():
extern_root = path.join(utils.get_script_folder(), '..', 'extern')
tests = { 'valid': dict(), 'invalid': dict() }
load_valid_inputs(tests, extern_root)
load_invalid_inputs(tests, extern_root)
for test_type, test_groups in tests.items():
for test_group, test_cases in test_groups.items():
write_test_file('{}/{}'.format(test_group, test_type), test_cases )
if __name__ == '__main__': if __name__ == '__main__':
utils.run(main) utils.run(main)

View File

@ -41,6 +41,8 @@ type_names = [
'iterator', 'iterator',
'const_iterator', 'const_iterator',
'void', 'void',
'char',
'wchar_t',
'int', 'int',
'long', 'long',
'short', 'short',
@ -63,6 +65,7 @@ type_names = [
'byte', 'byte',
'optional', 'optional',
#------ toml++ types #------ toml++ types
'node',
'table', 'table',
'array', 'array',
'value', 'value',
@ -228,6 +231,20 @@ def html_string_descendants(starting_tag, filter = None):
def html_append_class(tag, classes):
appended = False
if 'class' not in tag.attrs:
tag['class'] = []
if not utils.is_collection(classes):
classes = (classes,)
for class_ in classes:
if class_ not in tag['class']:
tag['class'].append(class_)
appended = True
return appended
class RegexReplacer(object): class RegexReplacer(object):
def __substitute(self, m): def __substitute(self, m):
@ -922,6 +939,40 @@ class EnableIfFix(object):
# makes sure links to certain external sources are correctly marked as such.
class ExternalLinksFix(object):
__href = re.compile(r'^\s*(?:https?|s?ftp|mailto)[:]', re.I)
__godbolt = re.compile(r'^\s*https[:]//godbolt.org/z/.+?$', re.I)
def __call__(self, file, doc):
changed = False
for anchor in doc.body('a', recursive=True):
if self.__href.search(anchor['href']):
if 'target' not in anchor.attrs or anchor['target'] != '_blank':
anchor['target'] = '_blank'
changed = True
changed = html_append_class(anchor, 'tpp-external') or changed
# do magic with godbolt.org links
if self.__godbolt.fullmatch(anchor['href']):
changed = html_append_class(anchor, 'godbolt') or changed
if anchor.parent.name == 'p' and len(anchor.parent.contents) == 1:
changed = html_append_class(anchor.parent, ('m-note', 'm-success', 'godbolt')) or changed
if anchor.parent.next_sibling is not None and anchor.parent.next_sibling.name == 'pre':
code_block = anchor.parent.next_sibling
code_block.insert(0, anchor.parent.extract())
return changed
#=======================================================================================================================
_threadError = False _threadError = False
@ -1008,6 +1059,7 @@ def main():
, InlineNamespaceFix3() , InlineNamespaceFix3()
, ExtDocLinksFix() , ExtDocLinksFix()
, EnableIfFix() , EnableIfFix()
, ExternalLinksFix()
] ]
files = [path.split(f) for f in utils.get_all_files(html_dir, any=('*.html', '*.htm'))] files = [path.split(f) for f in utils.get_all_files(html_dir, any=('*.html', '*.htm'))]
if files: if files:

View File

@ -961,7 +961,7 @@ def emit_function(name, header_file, test_file, codepoints, test_func, descripti
header = lambda txt: print(txt, file=header_file) header = lambda txt: print(txt, file=header_file)
header(" //# " + ("\n\t//# ".join(description.split('\n')))) header(" //# " + ("\n\t//# ".join(description.split('\n'))))
header(' [[nodiscard]]') header(' [[nodiscard]]')
header(' TOML_GNU_ATTR(const)') header(' TOML_ATTR(const)')
header(' constexpr bool {}(char32_t cp) noexcept'.format(name)) header(' constexpr bool {}(char32_t cp) noexcept'.format(name))
header(' {') header(' {')
header(indent_with_tabs(str(root_chunk), 2)) header(indent_with_tabs(str(root_chunk), 2))

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,192 @@
// This file is a part of toml++ and is subject to the the terms of the MIT license.
// Copyright (c) 2019-2020 Mark Gillard <mark.gillard@outlook.com.au>
// See https://github.com/marzer/tomlplusplus/blob/master/LICENSE for the full license text.
// SPDX-License-Identifier: MIT
//-----
// this file was generated by generate_conformance_tests.py - do not modify it directly
#include "tests.h"
using namespace toml::impl;
TOML_PUSH_WARNINGS
TOML_DISABLE_ALL_WARNINGS // unused variable spam
namespace
{
static constexpr auto datetime_malformed_no_leads = R"(no-leads = 1987-7-05T17:45:00Z)"sv;
static constexpr auto datetime_malformed_no_secs = R"(no-secs = 1987-07-05T17:45Z)"sv;
static constexpr auto datetime_malformed_no_t = R"(no-t = 1987-07-0517:45:00Z)"sv;
static constexpr auto datetime_malformed_with_milli = R"(with-milli = 1987-07-5T17:45:00.12Z)"sv;
static constexpr auto duplicate_key_table = R"([fruit]
type = "apple"
[fruit.type]
apple = "yes")"sv;
static constexpr auto duplicate_keys = R"(dupe = false
dupe = true)"sv;
static constexpr auto duplicate_tables = R"([a]
[a])"sv;
static constexpr auto empty_implicit_table = R"([naughty..naughty])"sv;
static constexpr auto empty_table = R"([])"sv;
static constexpr auto float_leading_zero_neg = R"(leading-zero = -03.14)"sv;
static constexpr auto float_leading_zero_pos = R"(leading-zero = +03.14)"sv;
static constexpr auto float_leading_zero = R"(leading-zero = 03.14)"sv;
static constexpr auto float_no_leading_zero = R"(answer = .12345
neganswer = -.12345)"sv;
static constexpr auto float_no_trailing_digits = R"(answer = 1.
neganswer = -1.)"sv;
static constexpr auto float_underscore_after_point = R"(bad = 1._2)"sv;
static constexpr auto float_underscore_after = R"(bad = 1.2_)"sv;
static constexpr auto float_underscore_before_point = R"(bad = 1_.2)"sv;
static constexpr auto float_underscore_before = R"(bad = _1.2)"sv;
static constexpr auto inline_table_linebreak = R"(simple = { a = 1
})"sv;
static constexpr auto integer_leading_zero_neg = R"(leading-zero = -012)"sv;
static constexpr auto integer_leading_zero_pos = R"(leading-zero = +012)"sv;
static constexpr auto integer_leading_zero = R"(leading-zero = 012)"sv;
static constexpr auto integer_underscore_after = R"(bad = 123_)"sv;
static constexpr auto integer_underscore_before = R"(bad = _123)"sv;
static constexpr auto integer_underscore_double = R"(bad = 1__23)"sv;
static constexpr auto key_after_array = R"([[agencies]] owner = "S Cjelli")"sv;
static constexpr auto key_after_table = R"([error] this = "should not be here")"sv;
static constexpr auto key_empty = R"(= 1)"sv;
static constexpr auto key_hash = R"(a# = 1)"sv;
static constexpr auto key_newline = R"(a
= 1)"sv;
static constexpr auto key_no_eol = R"(a = 1 b = 2)"sv;
static constexpr auto key_open_bracket = R"([abc = 1)"sv;
static constexpr auto key_single_open_bracket = R"([)"sv;
static constexpr auto key_space = R"(a b = 1)"sv;
static constexpr auto key_start_bracket = R"([a]
[xyz = 5
[b])"sv;
static constexpr auto key_two_equals = R"(key= = 1)"sv;
static constexpr auto llbrace = R"([ [table]])"sv;
static constexpr auto multi_line_inline_table = R"(json_like = {
first = "Tom",
last = "Preston-Werner"
})"sv;
static constexpr auto multi_line_string_no_close = R"(invalid = """
this will fail)"sv;
static constexpr auto rrbrace = R"([[table] ])"sv;
static constexpr auto string_bad_byte_escape = R"(naughty = "\xAg")"sv;
static constexpr auto string_bad_codepoint = R"(invalid-codepoint = "This string contains a non scalar unicode codepoint \uD801")"sv;
static constexpr auto string_bad_escape = R"(invalid-escape = "This string has a bad \a escape character.")"sv;
static constexpr auto string_bad_slash_escape = R"(invalid-escape = "This string has a bad \/ escape character.")"sv;
static constexpr auto string_bad_uni_esc = R"(str = "val\ue")"sv;
static constexpr auto string_byte_escapes = R"(answer = "\x33")"sv;
static constexpr auto string_no_close = R"(no-ending-quote = "One time, at band camp)"sv;
static constexpr auto table_array_implicit = R"(# This test is a bit tricky. It should fail because the first use of
# `[[albums.songs]]` without first declaring `albums` implies that `albums`
# must be a table. The alternative would be quite weird. Namely, it wouldn't
# comply with the TOML spec: "Each double-bracketed sub-table will belong to
# the most *recently* defined table element *above* it."
#
# This is in contrast to the *valid* test, table-array-implicit where
# `[[albums.songs]]` works by itself, so long as `[[albums]]` isn't declared
# later. (Although, `[albums]` could be.)
[[albums.songs]]
name = "Glory Days"
[[albums]]
name = "Born in the USA")"sv;
static constexpr auto table_array_malformed_bracket = R"([[albums]
name = "Born to Run")"sv;
static constexpr auto table_array_malformed_empty = R"([[]]
name = "Born to Run")"sv;
static constexpr auto table_empty = R"([])"sv;
static constexpr auto table_nested_brackets_close = R"([a]b]
zyx = 42)"sv;
static constexpr auto table_nested_brackets_open = R"([a[b]
zyx = 42)"sv;
static constexpr auto table_whitespace = R"([invalid key])"sv;
static constexpr auto table_with_pound = R"([key#group]
answer = 42)"sv;
static constexpr auto text_after_array_entries = R"(array = [
"Is there life after an array separator?", No
"Entry"
])"sv;
static constexpr auto text_after_integer = R"(answer = 42 the ultimate answer?)"sv;
static constexpr auto text_after_string = R"(string = "Is there life after strings?" No.)"sv;
static constexpr auto text_after_table = R"([error] this shouldn't be here)"sv;
static constexpr auto text_before_array_separator = R"(array = [
"Is there life before an array separator?" No,
"Entry"
])"sv;
static constexpr auto text_in_array = R"(array = [
"Entry 1",
I don't belong,
"Entry 2",
])"sv;
}
TOML_POP_WARNINGS
TEST_CASE("conformance - burntsushi/invalid")
{
parsing_should_fail(FILE_LINE_ARGS, datetime_malformed_no_leads);
parsing_should_fail(FILE_LINE_ARGS, datetime_malformed_no_t);
parsing_should_fail(FILE_LINE_ARGS, datetime_malformed_with_milli);
parsing_should_fail(FILE_LINE_ARGS, duplicate_key_table);
parsing_should_fail(FILE_LINE_ARGS, duplicate_keys);
parsing_should_fail(FILE_LINE_ARGS, duplicate_tables);
parsing_should_fail(FILE_LINE_ARGS, empty_implicit_table);
parsing_should_fail(FILE_LINE_ARGS, empty_table);
parsing_should_fail(FILE_LINE_ARGS, float_leading_zero_neg);
parsing_should_fail(FILE_LINE_ARGS, float_leading_zero_pos);
parsing_should_fail(FILE_LINE_ARGS, float_leading_zero);
parsing_should_fail(FILE_LINE_ARGS, float_no_leading_zero);
parsing_should_fail(FILE_LINE_ARGS, float_no_trailing_digits);
parsing_should_fail(FILE_LINE_ARGS, float_underscore_after_point);
parsing_should_fail(FILE_LINE_ARGS, float_underscore_after);
parsing_should_fail(FILE_LINE_ARGS, float_underscore_before_point);
parsing_should_fail(FILE_LINE_ARGS, float_underscore_before);
parsing_should_fail(FILE_LINE_ARGS, integer_leading_zero_neg);
parsing_should_fail(FILE_LINE_ARGS, integer_leading_zero_pos);
parsing_should_fail(FILE_LINE_ARGS, integer_leading_zero);
parsing_should_fail(FILE_LINE_ARGS, integer_underscore_after);
parsing_should_fail(FILE_LINE_ARGS, integer_underscore_before);
parsing_should_fail(FILE_LINE_ARGS, integer_underscore_double);
parsing_should_fail(FILE_LINE_ARGS, key_after_array);
parsing_should_fail(FILE_LINE_ARGS, key_after_table);
parsing_should_fail(FILE_LINE_ARGS, key_empty);
parsing_should_fail(FILE_LINE_ARGS, key_hash);
parsing_should_fail(FILE_LINE_ARGS, key_newline);
parsing_should_fail(FILE_LINE_ARGS, key_no_eol);
parsing_should_fail(FILE_LINE_ARGS, key_open_bracket);
parsing_should_fail(FILE_LINE_ARGS, key_single_open_bracket);
parsing_should_fail(FILE_LINE_ARGS, key_space);
parsing_should_fail(FILE_LINE_ARGS, key_start_bracket);
parsing_should_fail(FILE_LINE_ARGS, key_two_equals);
parsing_should_fail(FILE_LINE_ARGS, llbrace);
parsing_should_fail(FILE_LINE_ARGS, multi_line_string_no_close);
parsing_should_fail(FILE_LINE_ARGS, rrbrace);
parsing_should_fail(FILE_LINE_ARGS, string_bad_byte_escape);
parsing_should_fail(FILE_LINE_ARGS, string_bad_codepoint);
parsing_should_fail(FILE_LINE_ARGS, string_bad_escape);
parsing_should_fail(FILE_LINE_ARGS, string_bad_slash_escape);
parsing_should_fail(FILE_LINE_ARGS, string_bad_uni_esc);
parsing_should_fail(FILE_LINE_ARGS, string_no_close);
parsing_should_fail(FILE_LINE_ARGS, table_array_implicit);
parsing_should_fail(FILE_LINE_ARGS, table_array_malformed_bracket);
parsing_should_fail(FILE_LINE_ARGS, table_array_malformed_empty);
parsing_should_fail(FILE_LINE_ARGS, table_empty);
parsing_should_fail(FILE_LINE_ARGS, table_nested_brackets_close);
parsing_should_fail(FILE_LINE_ARGS, table_nested_brackets_open);
parsing_should_fail(FILE_LINE_ARGS, table_whitespace);
parsing_should_fail(FILE_LINE_ARGS, table_with_pound);
parsing_should_fail(FILE_LINE_ARGS, text_after_array_entries);
parsing_should_fail(FILE_LINE_ARGS, text_after_integer);
parsing_should_fail(FILE_LINE_ARGS, text_after_string);
parsing_should_fail(FILE_LINE_ARGS, text_after_table);
parsing_should_fail(FILE_LINE_ARGS, text_before_array_separator);
parsing_should_fail(FILE_LINE_ARGS, text_in_array);
#if !TOML_LANG_UNRELEASED
parsing_should_fail(FILE_LINE_ARGS, datetime_malformed_no_secs);
parsing_should_fail(FILE_LINE_ARGS, inline_table_linebreak);
parsing_should_fail(FILE_LINE_ARGS, multi_line_inline_table);
parsing_should_fail(FILE_LINE_ARGS, string_byte_escapes);
#endif // !TOML_LANG_UNRELEASED
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,177 @@
// This file is a part of toml++ and is subject to the the terms of the MIT license.
// Copyright (c) 2019-2020 Mark Gillard <mark.gillard@outlook.com.au>
// See https://github.com/marzer/tomlplusplus/blob/master/LICENSE for the full license text.
// SPDX-License-Identifier: MIT
//-----
// this file was generated by generate_conformance_tests.py - do not modify it directly
#include "tests.h"
using namespace toml::impl;
TOML_PUSH_WARNINGS
TOML_DISABLE_ALL_WARNINGS // unused variable spam
namespace
{
static constexpr auto array_of_tables_1 = R"(# INVALID TOML DOC
fruit = []
[[fruit]] # Not allowed)"sv;
static constexpr auto array_of_tables_2 = R"(# INVALID TOML DOC
[[fruit]]
name = "apple"
[[fruit.variety]]
name = "red delicious"
# This table conflicts with the previous table
[fruit.variety]
name = "granny smith")"sv;
static constexpr auto bare_key_1 = R"(bare!key = 123)"sv;
static constexpr auto bare_key_2 = R"(barekey
= 123)"sv;
static constexpr auto bare_key_3 = R"(barekey =)"sv;
static constexpr auto inline_table_imutable_1 = R"([product]
type = { name = "Nail" }
type.edible = false # INVALID)"sv;
static constexpr auto inline_table_imutable_2 = R"([product]
type.name = "Nail"
type = { edible = false } # INVALID)"sv;
static constexpr auto inline_table_trailing_comma = R"(abc = { abc = 123, })"sv;
static constexpr auto int_0_padded = R"(int = 0123)"sv;
static constexpr auto int_signed_bin = R"(bin = +0b10)"sv;
static constexpr auto int_signed_hex = R"(hex = +0xab)"sv;
static constexpr auto int_signed_oct = R"(oct = +0o23)"sv;
static constexpr auto key_value_pair_1 = R"(key = # INVALID)"sv;
static constexpr auto key_value_pair_2 = R"(first = "Tom" last = "Preston-Werner" # INVALID)"sv;
static constexpr auto multiple_dot_key = R"(# THE FOLLOWING IS INVALID
# This defines the value of fruit.apple to be an integer.
fruit.apple = 1
# But then this treats fruit.apple like it's a table.
# You can't turn an integer into a table.
fruit.apple.smooth = true)"sv;
static constexpr auto multiple_key = R"(# DO NOT DO THIS
name = "Tom"
name = "Pradyun")"sv;
static constexpr auto no_key_name = R"(= "no key name" # INVALID)"sv;
static constexpr auto string_basic_multiline_invalid_backslash = R"(a = """
foo \ \n
bar""")"sv;
static constexpr auto string_basic_multiline_out_of_range_unicode_escape_1 = R"(a = """\UFFFFFFFF""")"sv;
static constexpr auto string_basic_multiline_out_of_range_unicode_escape_2 = R"(a = """\U00D80000""")"sv;
static constexpr auto string_basic_multiline_quotes = R"(str5 = """Here are three quotation marks: """.""")"sv;
static constexpr auto string_basic_multiline_unknown_escape = R"(a = """\@""")"sv;
static constexpr auto string_basic_out_of_range_unicode_escape_1 = R"(a = "\UFFFFFFFF")"sv;
static constexpr auto string_basic_out_of_range_unicode_escape_2 = R"(a = "\U00D80000")"sv;
static constexpr auto string_basic_unknown_escape = R"(a = "\@")"sv;
static constexpr auto string_literal_multiline_quotes = R"(apos15 = '''Here are fifteen apostrophes: '''''''''''''''''' # INVALID)"sv;
static constexpr auto table_1 = R"(# DO NOT DO THIS
[fruit]
apple = "red"
[fruit]
orange = "orange")"sv;
static constexpr auto table_2 = R"(# DO NOT DO THIS EITHER
[fruit]
apple = "red"
[fruit.apple]
texture = "smooth")"sv;
static constexpr auto table_3 = R"([fruit]
apple.color = "red"
apple.taste.sweet = true
[fruit.apple] # INVALID)"sv;
static constexpr auto table_4 = R"([fruit]
apple.color = "red"
apple.taste.sweet = true
[fruit.apple.taste] # INVALID)"sv;
static constexpr auto table_invalid_1 = R"([fruit.physical] # subtable, but to which parent element should it belong?
color = "red"
shape = "round"
[[fruit]] # parser must throw an error upon discovering that "fruit" is
# an array rather than a table
name = "apple")"sv;
static constexpr auto table_invalid_2 = R"(# INVALID TOML DOC
fruit = []
[[fruit]] # Not allowed)"sv;
static constexpr auto table_invalid_3 = R"(# INVALID TOML DOC
[[fruit]]
name = "apple"
[[fruit.variety]]
name = "red delicious"
# INVALID: This table conflicts with the previous array of tables
[fruit.variety]
name = "granny smith"
[fruit.physical]
color = "red"
shape = "round")"sv;
static constexpr auto table_invalid_4 = R"(# INVALID TOML DOC
[[fruit]]
name = "apple"
[[fruit.variety]]
name = "red delicious"
[fruit.physical]
color = "red"
shape = "round"
# INVALID: This array of tables conflicts with the previous table
[[fruit.physical]]
color = "green")"sv;
}
TOML_POP_WARNINGS
TEST_CASE("conformance - iarna/invalid")
{
parsing_should_fail(FILE_LINE_ARGS, array_of_tables_1);
parsing_should_fail(FILE_LINE_ARGS, array_of_tables_2);
parsing_should_fail(FILE_LINE_ARGS, bare_key_1);
parsing_should_fail(FILE_LINE_ARGS, bare_key_2);
parsing_should_fail(FILE_LINE_ARGS, bare_key_3);
parsing_should_fail(FILE_LINE_ARGS, inline_table_imutable_1);
parsing_should_fail(FILE_LINE_ARGS, inline_table_imutable_2);
parsing_should_fail(FILE_LINE_ARGS, int_0_padded);
parsing_should_fail(FILE_LINE_ARGS, int_signed_bin);
parsing_should_fail(FILE_LINE_ARGS, int_signed_hex);
parsing_should_fail(FILE_LINE_ARGS, int_signed_oct);
parsing_should_fail(FILE_LINE_ARGS, key_value_pair_1);
parsing_should_fail(FILE_LINE_ARGS, key_value_pair_2);
parsing_should_fail(FILE_LINE_ARGS, multiple_dot_key);
parsing_should_fail(FILE_LINE_ARGS, multiple_key);
parsing_should_fail(FILE_LINE_ARGS, no_key_name);
parsing_should_fail(FILE_LINE_ARGS, string_basic_multiline_invalid_backslash);
parsing_should_fail(FILE_LINE_ARGS, string_basic_multiline_out_of_range_unicode_escape_1);
parsing_should_fail(FILE_LINE_ARGS, string_basic_multiline_out_of_range_unicode_escape_2);
parsing_should_fail(FILE_LINE_ARGS, string_basic_multiline_quotes);
parsing_should_fail(FILE_LINE_ARGS, string_basic_multiline_unknown_escape);
parsing_should_fail(FILE_LINE_ARGS, string_basic_out_of_range_unicode_escape_1);
parsing_should_fail(FILE_LINE_ARGS, string_basic_out_of_range_unicode_escape_2);
parsing_should_fail(FILE_LINE_ARGS, string_basic_unknown_escape);
parsing_should_fail(FILE_LINE_ARGS, string_literal_multiline_quotes);
parsing_should_fail(FILE_LINE_ARGS, table_1);
parsing_should_fail(FILE_LINE_ARGS, table_2);
parsing_should_fail(FILE_LINE_ARGS, table_3);
parsing_should_fail(FILE_LINE_ARGS, table_4);
parsing_should_fail(FILE_LINE_ARGS, table_invalid_1);
parsing_should_fail(FILE_LINE_ARGS, table_invalid_2);
parsing_should_fail(FILE_LINE_ARGS, table_invalid_3);
parsing_should_fail(FILE_LINE_ARGS, table_invalid_4);
#if !TOML_LANG_UNRELEASED
parsing_should_fail(FILE_LINE_ARGS, inline_table_trailing_comma);
#endif // !TOML_LANG_UNRELEASED
}

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,8 @@
test_sources = [ test_sources = [
'conformance.cpp', 'conformance_burntsushi_invalid.cpp',
'conformance_burntsushi_valid.cpp',
'conformance_iarna_invalid.cpp',
'conformance_iarna_valid.cpp',
'impl_toml.cpp', 'impl_toml.cpp',
'impl_catch2.cpp', 'impl_catch2.cpp',
'tests.cpp', 'tests.cpp',

273
toml.hpp
View File

@ -112,7 +112,7 @@
#define TOML_ASSUME(cond) __builtin_assume(cond) #define TOML_ASSUME(cond) __builtin_assume(cond)
#define TOML_UNREACHABLE __builtin_unreachable() #define TOML_UNREACHABLE __builtin_unreachable()
#define TOML_GNU_ATTR(...) __attribute__((__VA_ARGS__)) #define TOML_ATTR(...) __attribute__((__VA_ARGS__))
#if defined(_MSC_VER) // msvc compat mode #if defined(_MSC_VER) // msvc compat mode
#ifdef __has_declspec_attribute #ifdef __has_declspec_attribute
#if __has_declspec_attribute(novtable) #if __has_declspec_attribute(novtable)
@ -191,10 +191,13 @@
#define TOML_DISABLE_PADDING_WARNINGS _Pragma("GCC diagnostic ignored \"-Wpadded\"") #define TOML_DISABLE_PADDING_WARNINGS _Pragma("GCC diagnostic ignored \"-Wpadded\"")
#define TOML_DISABLE_FLOAT_WARNINGS _Pragma("GCC diagnostic ignored \"-Wfloat-equal\"") #define TOML_DISABLE_FLOAT_WARNINGS _Pragma("GCC diagnostic ignored \"-Wfloat-equal\"")
#define TOML_DISABLE_SHADOW_WARNINGS _Pragma("GCC diagnostic ignored \"-Wshadow\"") #define TOML_DISABLE_SHADOW_WARNINGS _Pragma("GCC diagnostic ignored \"-Wshadow\"")
#define TOML_DISABLE_SUGGEST_WARNINGS _Pragma("GCC diagnostic ignored \"-Wsuggest-attribute=const\"") \
_Pragma("GCC diagnostic ignored \"-Wsuggest-attribute=pure\"")
#define TOML_DISABLE_ALL_WARNINGS _Pragma("GCC diagnostic ignored \"-Wall\"") \ #define TOML_DISABLE_ALL_WARNINGS _Pragma("GCC diagnostic ignored \"-Wall\"") \
_Pragma("GCC diagnostic ignored \"-Wextra\"") \ _Pragma("GCC diagnostic ignored \"-Wextra\"") \
_Pragma("GCC diagnostic ignored \"-Wchar-subscripts\"") \ _Pragma("GCC diagnostic ignored \"-Wchar-subscripts\"") \
_Pragma("GCC diagnostic ignored \"-Wtype-limits\"") \ _Pragma("GCC diagnostic ignored \"-Wtype-limits\"") \
TOML_DISABLE_SUGGEST_WARNINGS \
TOML_DISABLE_SWITCH_WARNINGS \ TOML_DISABLE_SWITCH_WARNINGS \
TOML_DISABLE_INIT_WARNINGS \ TOML_DISABLE_INIT_WARNINGS \
TOML_DISABLE_PADDING_WARNINGS \ TOML_DISABLE_PADDING_WARNINGS \
@ -202,7 +205,7 @@
TOML_DISABLE_SHADOW_WARNINGS TOML_DISABLE_SHADOW_WARNINGS
#define TOML_POP_WARNINGS _Pragma("GCC diagnostic pop") #define TOML_POP_WARNINGS _Pragma("GCC diagnostic pop")
#define TOML_GNU_ATTR(...) __attribute__((__VA_ARGS__)) #define TOML_ATTR(...) __attribute__((__VA_ARGS__))
#ifndef TOML_ALWAYS_INLINE #ifndef TOML_ALWAYS_INLINE
#define TOML_ALWAYS_INLINE __attribute__((__always_inline__)) inline #define TOML_ALWAYS_INLINE __attribute__((__always_inline__)) inline
#endif #endif
@ -299,6 +302,9 @@
#ifndef TOML_DISABLE_SHADOW_WARNINGS #ifndef TOML_DISABLE_SHADOW_WARNINGS
#define TOML_DISABLE_SHADOW_WARNINGS #define TOML_DISABLE_SHADOW_WARNINGS
#endif #endif
#ifndef TOML_DISABLE_SUGGEST_WARNINGS
#define TOML_DISABLE_SUGGEST_WARNINGS
#endif
#ifndef TOML_DISABLE_ALL_WARNINGS #ifndef TOML_DISABLE_ALL_WARNINGS
#define TOML_DISABLE_ALL_WARNINGS #define TOML_DISABLE_ALL_WARNINGS
#endif #endif
@ -306,8 +312,8 @@
#define TOML_POP_WARNINGS #define TOML_POP_WARNINGS
#endif #endif
#ifndef TOML_GNU_ATTR #ifndef TOML_ATTR
#define TOML_GNU_ATTR(...) #define TOML_ATTR(...)
#endif #endif
#ifndef TOML_INTERFACE #ifndef TOML_INTERFACE
@ -491,7 +497,7 @@ namespace toml
using ptrdiff_t = std::ptrdiff_t; using ptrdiff_t = std::ptrdiff_t;
[[nodiscard]] [[nodiscard]]
TOML_GNU_ATTR(const) TOML_ATTR(const)
TOML_ALWAYS_INLINE TOML_ALWAYS_INLINE
TOML_CONSTEVAL size_t operator"" _sz(unsigned long long n) noexcept TOML_CONSTEVAL size_t operator"" _sz(unsigned long long n) noexcept
{ {
@ -657,7 +663,7 @@ namespace toml::impl
template <typename T> template <typename T>
[[nodiscard]] [[nodiscard]]
TOML_GNU_ATTR(const) TOML_ATTR(const)
TOML_ALWAYS_INLINE TOML_ALWAYS_INLINE
constexpr std::underlying_type_t<T> unbox_enum(T val) noexcept constexpr std::underlying_type_t<T> unbox_enum(T val) noexcept
{ {
@ -1289,7 +1295,7 @@ namespace toml::impl
} }
template <typename Char> template <typename Char>
TOML_GNU_ATTR(nonnull) TOML_ATTR(nonnull)
TOML_ALWAYS_INLINE TOML_ALWAYS_INLINE
void print_to_stream(const char* str, size_t len, std::basic_ostream<Char>& stream) void print_to_stream(const char* str, size_t len, std::basic_ostream<Char>& stream)
{ {
@ -1308,7 +1314,7 @@ namespace toml::impl
} }
template <typename Char> template <typename Char>
TOML_GNU_ATTR(nonnull) TOML_ATTR(nonnull)
TOML_ALWAYS_INLINE TOML_ALWAYS_INLINE
void print_to_stream(const char8_t* str, size_t len, std::basic_ostream<Char>& stream) void print_to_stream(const char8_t* str, size_t len, std::basic_ostream<Char>& stream)
{ {
@ -2390,7 +2396,7 @@ TOML_DISABLE_VTABLE_WARNINGS
namespace toml::impl namespace toml::impl
{ {
template <bool IsConst> template <bool IsConst>
class array_iterator final class TOML_TRIVIAL_ABI array_iterator final
{ {
private: private:
friend class ::toml::array; friend class ::toml::array;
@ -2548,8 +2554,9 @@ namespace toml::impl
template <typename T> template <typename T>
[[nodiscard]] [[nodiscard]]
TOML_ATTR(returns_nonnull)
TOML_ALWAYS_INLINE TOML_ALWAYS_INLINE
auto make_node(T&& val) noexcept auto* make_node(T&& val) noexcept
{ {
using type = unwrapped<remove_cvref_t<T>>; using type = unwrapped<remove_cvref_t<T>>;
if constexpr (is_one_of<type, array, table>) if constexpr (is_one_of<type, array, table>)
@ -2572,8 +2579,9 @@ namespace toml::impl
template <typename T> template <typename T>
[[nodiscard]] [[nodiscard]]
TOML_ATTR(returns_nonnull)
TOML_ALWAYS_INLINE TOML_ALWAYS_INLINE
auto make_node(inserter<T>&& val) noexcept auto* make_node(inserter<T>&& val) noexcept
{ {
return make_node(std::move(val.value)); return make_node(std::move(val.value));
} }
@ -3490,7 +3498,7 @@ namespace toml
namespace toml::impl namespace toml::impl
{ {
[[nodiscard]] [[nodiscard]]
TOML_GNU_ATTR(const) TOML_ATTR(const)
constexpr bool is_hexadecimal_digit(char32_t cp) noexcept constexpr bool is_hexadecimal_digit(char32_t cp) noexcept
{ {
using ui64 = std::uint_least64_t; using ui64 = std::uint_least64_t;
@ -3501,7 +3509,7 @@ namespace toml::impl
#if TOML_LANG_UNRELEASED // toml/issues/687 (unicode bare keys) #if TOML_LANG_UNRELEASED // toml/issues/687 (unicode bare keys)
[[nodiscard]] [[nodiscard]]
TOML_GNU_ATTR(const) TOML_ATTR(const)
constexpr bool is_unicode_letter(char32_t cp) noexcept constexpr bool is_unicode_letter(char32_t cp) noexcept
{ {
using ui64 = std::uint_least64_t; using ui64 = std::uint_least64_t;
@ -3840,7 +3848,7 @@ namespace toml::impl
} }
[[nodiscard]] [[nodiscard]]
TOML_GNU_ATTR(const) TOML_ATTR(const)
constexpr bool is_unicode_number(char32_t cp) noexcept constexpr bool is_unicode_number(char32_t cp) noexcept
{ {
using ui64 = std::uint_least64_t; using ui64 = std::uint_least64_t;
@ -3988,7 +3996,7 @@ namespace toml::impl
} }
[[nodiscard]] [[nodiscard]]
TOML_GNU_ATTR(const) TOML_ATTR(const)
constexpr bool is_unicode_combining_mark(char32_t cp) noexcept constexpr bool is_unicode_combining_mark(char32_t cp) noexcept
{ {
using ui64 = std::uint_least64_t; using ui64 = std::uint_least64_t;
@ -4205,7 +4213,7 @@ namespace toml::impl
{ {
template <typename... T> template <typename... T>
[[nodiscard]] [[nodiscard]]
TOML_GNU_ATTR(const) TOML_ATTR(const)
constexpr bool is_match(char32_t codepoint, T... vals) noexcept constexpr bool is_match(char32_t codepoint, T... vals) noexcept
{ {
static_assert((std::is_same_v<char32_t, T> && ...)); static_assert((std::is_same_v<char32_t, T> && ...));
@ -4213,7 +4221,7 @@ namespace toml::impl
} }
[[nodiscard]] [[nodiscard]]
TOML_GNU_ATTR(const) TOML_ATTR(const)
TOML_ALWAYS_INLINE TOML_ALWAYS_INLINE
constexpr bool is_ascii_whitespace(char32_t codepoint) noexcept constexpr bool is_ascii_whitespace(char32_t codepoint) noexcept
{ {
@ -4221,7 +4229,7 @@ namespace toml::impl
} }
[[nodiscard]] [[nodiscard]]
TOML_GNU_ATTR(const) TOML_ATTR(const)
constexpr bool is_unicode_whitespace(char32_t codepoint) noexcept constexpr bool is_unicode_whitespace(char32_t codepoint) noexcept
{ {
// see: https://en.wikipedia.org/wiki/Whitespace_character#Unicode // see: https://en.wikipedia.org/wiki/Whitespace_character#Unicode
@ -4237,7 +4245,7 @@ namespace toml::impl
} }
[[nodiscard]] [[nodiscard]]
TOML_GNU_ATTR(const) TOML_ATTR(const)
constexpr bool is_whitespace(char32_t codepoint) noexcept constexpr bool is_whitespace(char32_t codepoint) noexcept
{ {
return is_ascii_whitespace(codepoint) || is_unicode_whitespace(codepoint); return is_ascii_whitespace(codepoint) || is_unicode_whitespace(codepoint);
@ -4245,7 +4253,7 @@ namespace toml::impl
template <bool IncludeCarriageReturn = true> template <bool IncludeCarriageReturn = true>
[[nodiscard]] [[nodiscard]]
TOML_GNU_ATTR(const) TOML_ATTR(const)
TOML_ALWAYS_INLINE TOML_ALWAYS_INLINE
constexpr bool is_ascii_line_break(char32_t codepoint) noexcept constexpr bool is_ascii_line_break(char32_t codepoint) noexcept
{ {
@ -4254,7 +4262,7 @@ namespace toml::impl
} }
[[nodiscard]] [[nodiscard]]
TOML_GNU_ATTR(const) TOML_ATTR(const)
constexpr bool is_unicode_line_break(char32_t codepoint) noexcept constexpr bool is_unicode_line_break(char32_t codepoint) noexcept
{ {
// see https://en.wikipedia.org/wiki/Whitespace_character#Unicode // see https://en.wikipedia.org/wiki/Whitespace_character#Unicode
@ -4268,14 +4276,14 @@ namespace toml::impl
template <bool IncludeCarriageReturn = true> template <bool IncludeCarriageReturn = true>
[[nodiscard]] [[nodiscard]]
TOML_GNU_ATTR(const) TOML_ATTR(const)
constexpr bool is_line_break(char32_t codepoint) noexcept constexpr bool is_line_break(char32_t codepoint) noexcept
{ {
return is_ascii_line_break<IncludeCarriageReturn>(codepoint) || is_unicode_line_break(codepoint); return is_ascii_line_break<IncludeCarriageReturn>(codepoint) || is_unicode_line_break(codepoint);
} }
[[nodiscard]] [[nodiscard]]
TOML_GNU_ATTR(const) TOML_ATTR(const)
TOML_ALWAYS_INLINE TOML_ALWAYS_INLINE
constexpr bool is_string_delimiter(char32_t codepoint) noexcept constexpr bool is_string_delimiter(char32_t codepoint) noexcept
{ {
@ -4283,7 +4291,7 @@ namespace toml::impl
} }
[[nodiscard]] [[nodiscard]]
TOML_GNU_ATTR(const) TOML_ATTR(const)
TOML_ALWAYS_INLINE TOML_ALWAYS_INLINE
constexpr bool is_ascii_letter(char32_t codepoint) noexcept constexpr bool is_ascii_letter(char32_t codepoint) noexcept
{ {
@ -4292,7 +4300,7 @@ namespace toml::impl
} }
[[nodiscard]] [[nodiscard]]
TOML_GNU_ATTR(const) TOML_ATTR(const)
TOML_ALWAYS_INLINE TOML_ALWAYS_INLINE
constexpr bool is_binary_digit(char32_t codepoint) noexcept constexpr bool is_binary_digit(char32_t codepoint) noexcept
{ {
@ -4300,7 +4308,7 @@ namespace toml::impl
} }
[[nodiscard]] [[nodiscard]]
TOML_GNU_ATTR(const) TOML_ATTR(const)
TOML_ALWAYS_INLINE TOML_ALWAYS_INLINE
constexpr bool is_octal_digit(char32_t codepoint) noexcept constexpr bool is_octal_digit(char32_t codepoint) noexcept
{ {
@ -4308,7 +4316,7 @@ namespace toml::impl
} }
[[nodiscard]] [[nodiscard]]
TOML_GNU_ATTR(const) TOML_ATTR(const)
TOML_ALWAYS_INLINE TOML_ALWAYS_INLINE
constexpr bool is_decimal_digit(char32_t codepoint) noexcept constexpr bool is_decimal_digit(char32_t codepoint) noexcept
{ {
@ -4317,7 +4325,7 @@ namespace toml::impl
template <typename T> template <typename T>
[[nodiscard]] [[nodiscard]]
TOML_GNU_ATTR(const) TOML_ATTR(const)
TOML_ALWAYS_INLINE TOML_ALWAYS_INLINE
constexpr std::uint_least32_t hex_to_dec(const T codepoint) noexcept constexpr std::uint_least32_t hex_to_dec(const T codepoint) noexcept
{ {
@ -4331,7 +4339,7 @@ namespace toml::impl
} }
[[nodiscard]] [[nodiscard]]
TOML_GNU_ATTR(const) TOML_ATTR(const)
constexpr bool is_bare_key_character(char32_t codepoint) noexcept constexpr bool is_bare_key_character(char32_t codepoint) noexcept
{ {
return is_ascii_letter(codepoint) return is_ascii_letter(codepoint)
@ -4348,7 +4356,7 @@ namespace toml::impl
} }
[[nodiscard]] [[nodiscard]]
TOML_GNU_ATTR(const) TOML_ATTR(const)
constexpr bool is_value_terminator(char32_t codepoint) noexcept constexpr bool is_value_terminator(char32_t codepoint) noexcept
{ {
return is_ascii_line_break(codepoint) return is_ascii_line_break(codepoint)
@ -4363,7 +4371,7 @@ namespace toml::impl
} }
[[nodiscard]] [[nodiscard]]
TOML_GNU_ATTR(const) TOML_ATTR(const)
TOML_ALWAYS_INLINE TOML_ALWAYS_INLINE
constexpr bool is_control_character(char32_t codepoint) noexcept constexpr bool is_control_character(char32_t codepoint) noexcept
{ {
@ -4371,7 +4379,7 @@ namespace toml::impl
} }
[[nodiscard]] [[nodiscard]]
TOML_GNU_ATTR(const) TOML_ATTR(const)
TOML_ALWAYS_INLINE TOML_ALWAYS_INLINE
constexpr bool is_nontab_control_character(char32_t codepoint) noexcept constexpr bool is_nontab_control_character(char32_t codepoint) noexcept
{ {
@ -4381,7 +4389,7 @@ namespace toml::impl
} }
[[nodiscard]] [[nodiscard]]
TOML_GNU_ATTR(const) TOML_ATTR(const)
TOML_ALWAYS_INLINE TOML_ALWAYS_INLINE
constexpr bool is_unicode_surrogate(char32_t codepoint) noexcept constexpr bool is_unicode_surrogate(char32_t codepoint) noexcept
{ {
@ -4465,7 +4473,7 @@ namespace toml
}; };
[[nodiscard]] [[nodiscard]]
TOML_GNU_ATTR(const) TOML_ATTR(const)
TOML_ALWAYS_INLINE TOML_ALWAYS_INLINE
constexpr format_flags operator & (format_flags lhs, format_flags rhs) noexcept constexpr format_flags operator & (format_flags lhs, format_flags rhs) noexcept
{ {
@ -4473,7 +4481,7 @@ namespace toml
} }
[[nodiscard]] [[nodiscard]]
TOML_GNU_ATTR(const) TOML_ATTR(const)
TOML_ALWAYS_INLINE TOML_ALWAYS_INLINE
constexpr format_flags operator | (format_flags lhs, format_flags rhs) noexcept constexpr format_flags operator | (format_flags lhs, format_flags rhs) noexcept
{ {
@ -5156,20 +5164,20 @@ namespace toml
public: public:
TOML_NODISCARD_CTOR TOML_NODISCARD_CTOR
TOML_GNU_ATTR(nonnull) TOML_ATTR(nonnull)
parse_error(const char* desc, source_region&& src) noexcept parse_error(const char* desc, source_region&& src) noexcept
: std::runtime_error{ desc }, : std::runtime_error{ desc },
source_{ std::move(src) } source_{ std::move(src) }
{} {}
TOML_NODISCARD_CTOR TOML_NODISCARD_CTOR
TOML_GNU_ATTR(nonnull) TOML_ATTR(nonnull)
parse_error(const char* desc, const source_region& src) noexcept parse_error(const char* desc, const source_region& src) noexcept
: parse_error{ desc, source_region{ src } } : parse_error{ desc, source_region{ src } }
{} {}
TOML_NODISCARD_CTOR TOML_NODISCARD_CTOR
TOML_GNU_ATTR(nonnull) TOML_ATTR(nonnull)
parse_error(const char* desc, const source_position& position, const source_path_ptr& path = {}) noexcept parse_error(const char* desc, const source_position& position, const source_path_ptr& path = {}) noexcept
: parse_error{ desc, source_region{ position, position, path } } : parse_error{ desc, source_region{ position, position, path } }
{} {}
@ -5366,7 +5374,7 @@ namespace toml::impl
} }
[[nodiscard]] [[nodiscard]]
TOML_GNU_ATTR(pure) TOML_ATTR(pure)
TOML_ALWAYS_INLINE TOML_ALWAYS_INLINE
constexpr operator char32_t& () noexcept constexpr operator char32_t& () noexcept
{ {
@ -5374,7 +5382,7 @@ namespace toml::impl
} }
[[nodiscard]] [[nodiscard]]
TOML_GNU_ATTR(pure) TOML_ATTR(pure)
TOML_ALWAYS_INLINE TOML_ALWAYS_INLINE
constexpr operator const char32_t& () const noexcept constexpr operator const char32_t& () const noexcept
{ {
@ -5382,7 +5390,7 @@ namespace toml::impl
} }
[[nodiscard]] [[nodiscard]]
TOML_GNU_ATTR(pure) TOML_ATTR(pure)
TOML_ALWAYS_INLINE TOML_ALWAYS_INLINE
constexpr const char32_t& operator* () const noexcept constexpr const char32_t& operator* () const noexcept
{ {
@ -5986,10 +5994,9 @@ namespace toml
TOML_PARSE_FILE_ERROR("Could not determine file size", source_position{}); TOML_PARSE_FILE_ERROR("Could not determine file size", source_position{});
file.seekg(0, std::ios::beg); file.seekg(0, std::ios::beg);
// if the file size is the sweet spot, read the whole thing into memory and parse from there // read the whole file into memory first if the file isn't too large
constexpr auto small_file_threshold = 1024 * 32; //32 kilobytes constexpr auto large_file_threshold = 1024 * 1024 * static_cast<int>(sizeof(void*)) * 4; // 32 megabytes on 64-bit
constexpr auto large_file_threshold = 1024 * 1024 * static_cast<int>(sizeof(void*)) * 8; // 64 megabytes on 64-bit if (file_size <= large_file_threshold)
if (file_size >= small_file_threshold && file_size <= large_file_threshold)
{ {
std::vector<StreamChar> file_data; std::vector<StreamChar> file_data;
file_data.resize(static_cast<size_t>(file_size)); file_data.resize(static_cast<size_t>(file_size));
@ -6065,6 +6072,9 @@ TOML_POP_WARNINGS // TOML_DISABLE_PADDING_WARNINGS
//------------------------------------------ ↓ toml_node.hpp --------------------------------------------------------- //------------------------------------------ ↓ toml_node.hpp ---------------------------------------------------------
#if 1 #if 1
TOML_PUSH_WARNINGS
TOML_DISABLE_SUGGEST_WARNINGS
namespace toml namespace toml
{ {
TOML_EXTERNAL_LINKAGE TOML_EXTERNAL_LINKAGE
@ -6084,45 +6094,54 @@ namespace toml
return *this; return *this;
} }
TOML_EXTERNAL_LINKAGE bool node::is_string() const noexcept { return false; } #define TOML_MEMBER_ATTR(attr) TOML_EXTERNAL_LINKAGE TOML_ATTR(attr)
TOML_EXTERNAL_LINKAGE bool node::is_integer() const noexcept { return false; }
TOML_EXTERNAL_LINKAGE bool node::is_floating_point() const noexcept { return false; }
TOML_EXTERNAL_LINKAGE bool node::is_number() const noexcept { return false; }
TOML_EXTERNAL_LINKAGE bool node::is_boolean() const noexcept { return false; }
TOML_EXTERNAL_LINKAGE bool node::is_date() const noexcept { return false; }
TOML_EXTERNAL_LINKAGE bool node::is_time() const noexcept { return false; }
TOML_EXTERNAL_LINKAGE bool node::is_date_time() const noexcept { return false; }
TOML_EXTERNAL_LINKAGE bool node::is_array_of_tables() const noexcept { return false; }
TOML_EXTERNAL_LINKAGE table* node::as_table() noexcept { return nullptr; } TOML_MEMBER_ATTR(const) bool node::is_string() const noexcept { return false; }
TOML_EXTERNAL_LINKAGE array* node::as_array() noexcept { return nullptr; } TOML_MEMBER_ATTR(const) bool node::is_integer() const noexcept { return false; }
TOML_EXTERNAL_LINKAGE value<string>* node::as_string() noexcept { return nullptr; } TOML_MEMBER_ATTR(const) bool node::is_floating_point() const noexcept { return false; }
TOML_EXTERNAL_LINKAGE value<int64_t>* node::as_integer() noexcept { return nullptr; } TOML_MEMBER_ATTR(const) bool node::is_number() const noexcept { return false; }
TOML_EXTERNAL_LINKAGE value<double>* node::as_floating_point() noexcept { return nullptr; } TOML_MEMBER_ATTR(const) bool node::is_boolean() const noexcept { return false; }
TOML_EXTERNAL_LINKAGE value<bool>* node::as_boolean() noexcept { return nullptr; } TOML_MEMBER_ATTR(const) bool node::is_date() const noexcept { return false; }
TOML_EXTERNAL_LINKAGE value<date>* node::as_date() noexcept { return nullptr; } TOML_MEMBER_ATTR(const) bool node::is_time() const noexcept { return false; }
TOML_EXTERNAL_LINKAGE value<time>* node::as_time() noexcept { return nullptr; } TOML_MEMBER_ATTR(const) bool node::is_date_time() const noexcept { return false; }
TOML_EXTERNAL_LINKAGE value<date_time>* node::as_date_time() noexcept { return nullptr; } TOML_MEMBER_ATTR(const) bool node::is_array_of_tables() const noexcept { return false; }
TOML_EXTERNAL_LINKAGE const table* node::as_table() const noexcept { return nullptr; } TOML_MEMBER_ATTR(const) table* node::as_table() noexcept { return nullptr; }
TOML_EXTERNAL_LINKAGE const array* node::as_array() const noexcept { return nullptr; } TOML_MEMBER_ATTR(const) array* node::as_array() noexcept { return nullptr; }
TOML_EXTERNAL_LINKAGE const value<string>* node::as_string() const noexcept { return nullptr; } TOML_MEMBER_ATTR(const) value<string>* node::as_string() noexcept { return nullptr; }
TOML_EXTERNAL_LINKAGE const value<int64_t>* node::as_integer() const noexcept { return nullptr; } TOML_MEMBER_ATTR(const) value<int64_t>* node::as_integer() noexcept { return nullptr; }
TOML_EXTERNAL_LINKAGE const value<double>* node::as_floating_point() const noexcept { return nullptr; } TOML_MEMBER_ATTR(const) value<double>* node::as_floating_point() noexcept { return nullptr; }
TOML_EXTERNAL_LINKAGE const value<bool>* node::as_boolean() const noexcept { return nullptr; } TOML_MEMBER_ATTR(const) value<bool>* node::as_boolean() noexcept { return nullptr; }
TOML_EXTERNAL_LINKAGE const value<date>* node::as_date() const noexcept { return nullptr; } TOML_MEMBER_ATTR(const) value<date>* node::as_date() noexcept { return nullptr; }
TOML_EXTERNAL_LINKAGE const value<time>* node::as_time() const noexcept { return nullptr; } TOML_MEMBER_ATTR(const) value<time>* node::as_time() noexcept { return nullptr; }
TOML_EXTERNAL_LINKAGE const value<date_time>* node::as_date_time() const noexcept { return nullptr; } TOML_MEMBER_ATTR(const) value<date_time>* node::as_date_time() noexcept { return nullptr; }
TOML_EXTERNAL_LINKAGE const source_region& node::source() const noexcept { return source_; } TOML_MEMBER_ATTR(const) const table* node::as_table() const noexcept { return nullptr; }
TOML_MEMBER_ATTR(const) const array* node::as_array() const noexcept { return nullptr; }
TOML_MEMBER_ATTR(const) const value<string>* node::as_string() const noexcept { return nullptr; }
TOML_MEMBER_ATTR(const) const value<int64_t>* node::as_integer() const noexcept { return nullptr; }
TOML_MEMBER_ATTR(const) const value<double>* node::as_floating_point() const noexcept { return nullptr; }
TOML_MEMBER_ATTR(const) const value<bool>* node::as_boolean() const noexcept { return nullptr; }
TOML_MEMBER_ATTR(const) const value<date>* node::as_date() const noexcept { return nullptr; }
TOML_MEMBER_ATTR(const) const value<time>* node::as_time() const noexcept { return nullptr; }
TOML_MEMBER_ATTR(const) const value<date_time>* node::as_date_time() const noexcept { return nullptr; }
TOML_MEMBER_ATTR(const) const source_region& node::source() const noexcept { return source_; }
#undef TOML_MEMBER_ATTR
} }
TOML_POP_WARNINGS // TOML_DISABLE_SUGGEST_WARNINGS
#endif #endif
//------------------------------------------ ↑ toml_node.hpp --------------------------------------------------------- //------------------------------------------ ↑ toml_node.hpp ---------------------------------------------------------
//------------------------------------------------------------------ ↓ toml_array.hpp -------------------------------- //------------------------------------------------------------------ ↓ toml_array.hpp --------------------------------
#if 1 #if 1
TOML_PUSH_WARNINGS
TOML_DISABLE_SUGGEST_WARNINGS
namespace toml namespace toml
{ {
TOML_EXTERNAL_LINKAGE TOML_EXTERNAL_LINKAGE
@ -6155,38 +6174,41 @@ namespace toml
return *this; return *this;
} }
TOML_EXTERNAL_LINKAGE node_type array::type() const noexcept { return node_type::array; } #define TOML_MEMBER_ATTR(attr) TOML_EXTERNAL_LINKAGE TOML_ATTR(attr)
TOML_EXTERNAL_LINKAGE bool array::is_table() const noexcept { return false; }
TOML_EXTERNAL_LINKAGE bool array::is_array() const noexcept { return true; }
TOML_EXTERNAL_LINKAGE bool array::is_value() const noexcept { return false; }
TOML_EXTERNAL_LINKAGE array* array::as_array() noexcept { return this; }
TOML_EXTERNAL_LINKAGE const array* array::as_array() const noexcept { return this; }
TOML_EXTERNAL_LINKAGE node& array::operator[] (size_t index) noexcept { return *values[index]; } TOML_MEMBER_ATTR(const) node_type array::type() const noexcept { return node_type::array; }
TOML_EXTERNAL_LINKAGE const node& array::operator[] (size_t index) const noexcept { return *values[index]; } TOML_MEMBER_ATTR(const) bool array::is_table() const noexcept { return false; }
TOML_MEMBER_ATTR(const) bool array::is_array() const noexcept { return true; }
TOML_MEMBER_ATTR(const) bool array::is_value() const noexcept { return false; }
TOML_MEMBER_ATTR(const) const array* array::as_array() const noexcept { return this; }
TOML_MEMBER_ATTR(const) array* array::as_array() noexcept { return this; }
TOML_EXTERNAL_LINKAGE node& array::front() noexcept { return *values.front(); } TOML_MEMBER_ATTR(pure) const node& array::operator[] (size_t index) const noexcept { return *values[index]; }
TOML_EXTERNAL_LINKAGE const node& array::front() const noexcept { return *values.front(); } TOML_MEMBER_ATTR(pure) node& array::operator[] (size_t index) noexcept { return *values[index]; }
TOML_EXTERNAL_LINKAGE node& array::back() noexcept { return *values.back(); }
TOML_EXTERNAL_LINKAGE const node& array::back() const noexcept { return *values.back(); }
TOML_EXTERNAL_LINKAGE array::iterator array::begin() noexcept { return { values.begin() }; } TOML_MEMBER_ATTR(pure) const node& array::front() const noexcept { return *values.front(); }
TOML_EXTERNAL_LINKAGE array::const_iterator array::begin() const noexcept { return { values.begin() }; } TOML_MEMBER_ATTR(pure) const node& array::back() const noexcept { return *values.back(); }
TOML_EXTERNAL_LINKAGE array::const_iterator array::cbegin() const noexcept { return { values.cbegin() }; } TOML_MEMBER_ATTR(pure) node& array::front() noexcept { return *values.front(); }
TOML_MEMBER_ATTR(pure) node& array::back() noexcept { return *values.back(); }
TOML_EXTERNAL_LINKAGE array::iterator array::end() noexcept { return { values.end() }; } TOML_MEMBER_ATTR(pure) array::const_iterator array::begin() const noexcept { return { values.begin() }; }
TOML_EXTERNAL_LINKAGE array::const_iterator array::end() const noexcept { return { values.end() }; } TOML_MEMBER_ATTR(pure) array::const_iterator array::end() const noexcept { return { values.end() }; }
TOML_EXTERNAL_LINKAGE array::const_iterator array::cend() const noexcept { return { values.cend() }; } TOML_MEMBER_ATTR(pure) array::const_iterator array::cbegin() const noexcept { return { values.cbegin() }; }
TOML_MEMBER_ATTR(pure) array::const_iterator array::cend() const noexcept { return { values.cend() }; }
TOML_MEMBER_ATTR(pure) array::iterator array::begin() noexcept { return { values.begin() }; }
TOML_MEMBER_ATTR(pure) array::iterator array::end() noexcept { return { values.end() }; }
TOML_MEMBER_ATTR(pure) size_t array::size() const noexcept { return values.size(); }
TOML_MEMBER_ATTR(pure) size_t array::capacity() const noexcept { return values.capacity(); }
TOML_MEMBER_ATTR(pure) bool array::empty() const noexcept { return values.empty(); }
TOML_MEMBER_ATTR(const) size_t array::max_size() const noexcept { return values.max_size(); }
TOML_EXTERNAL_LINKAGE bool array::empty() const noexcept { return values.empty(); }
TOML_EXTERNAL_LINKAGE size_t array::size() const noexcept { return values.size(); }
TOML_EXTERNAL_LINKAGE void array::reserve(size_t new_capacity) { values.reserve(new_capacity); } TOML_EXTERNAL_LINKAGE void array::reserve(size_t new_capacity) { values.reserve(new_capacity); }
TOML_EXTERNAL_LINKAGE void array::clear() noexcept { values.clear(); } TOML_EXTERNAL_LINKAGE void array::clear() noexcept { values.clear(); }
TOML_EXTERNAL_LINKAGE size_t array::max_size() const noexcept { return values.max_size(); }
TOML_EXTERNAL_LINKAGE size_t array::capacity() const noexcept { return values.capacity(); }
TOML_EXTERNAL_LINKAGE void array::shrink_to_fit() { values.shrink_to_fit(); } TOML_EXTERNAL_LINKAGE void array::shrink_to_fit() { values.shrink_to_fit(); }
#undef TOML_MEMBER_ATTR
TOML_EXTERNAL_LINKAGE TOML_EXTERNAL_LINKAGE
void array::truncate(size_t new_size) void array::truncate(size_t new_size)
{ {
@ -6213,12 +6235,14 @@ namespace toml
} }
TOML_EXTERNAL_LINKAGE TOML_EXTERNAL_LINKAGE
TOML_ATTR(pure)
node* array::get(size_t index) noexcept node* array::get(size_t index) noexcept
{ {
return index < values.size() ? values[index].get() : nullptr; return index < values.size() ? values[index].get() : nullptr;
} }
TOML_EXTERNAL_LINKAGE TOML_EXTERNAL_LINKAGE
TOML_ATTR(pure)
const node* array::get(size_t index) const noexcept const node* array::get(size_t index) const noexcept
{ {
return index < values.size() ? values[index].get() : nullptr; return index < values.size() ? values[index].get() : nullptr;
@ -6336,12 +6360,17 @@ namespace toml
} }
} }
TOML_POP_WARNINGS // TOML_DISABLE_SUGGEST_WARNINGS
#endif #endif
//------------------------------------------------------------------ ↑ toml_array.hpp -------------------------------- //------------------------------------------------------------------ ↑ toml_array.hpp --------------------------------
//------------------------------------------------------------------------------------------- ↓ toml_table.hpp ------- //------------------------------------------------------------------------------------------- ↓ toml_table.hpp -------
#if 1 #if 1
TOML_PUSH_WARNINGS
TOML_DISABLE_SUGGEST_WARNINGS
namespace toml namespace toml
{ {
TOML_EXTERNAL_LINKAGE TOML_EXTERNAL_LINKAGE
@ -6375,15 +6404,31 @@ namespace toml
return *this; return *this;
} }
TOML_EXTERNAL_LINKAGE node_type table::type() const noexcept { return node_type::table; } #define TOML_MEMBER_ATTR(attr) TOML_EXTERNAL_LINKAGE TOML_ATTR(attr)
TOML_EXTERNAL_LINKAGE bool table::is_table() const noexcept { return true; }
TOML_EXTERNAL_LINKAGE bool table::is_array() const noexcept { return false; } TOML_MEMBER_ATTR(const) node_type table::type() const noexcept { return node_type::table; }
TOML_EXTERNAL_LINKAGE bool table::is_value() const noexcept { return false; } TOML_MEMBER_ATTR(const) bool table::is_table() const noexcept { return true; }
TOML_EXTERNAL_LINKAGE table* table::as_table() noexcept { return this; } TOML_MEMBER_ATTR(const) bool table::is_array() const noexcept { return false; }
TOML_EXTERNAL_LINKAGE const table* table::as_table() const noexcept { return this; } TOML_MEMBER_ATTR(const) bool table::is_value() const noexcept { return false; }
TOML_EXTERNAL_LINKAGE bool table::is_inline() const noexcept { return inline_; } TOML_MEMBER_ATTR(const) const table* table::as_table() const noexcept { return this; }
TOML_MEMBER_ATTR(const) table* table::as_table() noexcept { return this; }
TOML_MEMBER_ATTR(pure) bool table::is_inline() const noexcept { return inline_; }
TOML_EXTERNAL_LINKAGE void table::is_inline(bool val) noexcept { inline_ = val; } TOML_EXTERNAL_LINKAGE void table::is_inline(bool val) noexcept { inline_ = val; }
TOML_EXTERNAL_LINKAGE table::const_iterator table::begin() const noexcept { return { values.begin() }; }
TOML_EXTERNAL_LINKAGE table::const_iterator table::end() const noexcept { return { values.end() }; }
TOML_EXTERNAL_LINKAGE table::const_iterator table::cbegin() const noexcept { return { values.cbegin() }; }
TOML_EXTERNAL_LINKAGE table::const_iterator table::cend() const noexcept { return { values.cend() }; }
TOML_EXTERNAL_LINKAGE table::iterator table::begin() noexcept { return { values.begin() }; }
TOML_EXTERNAL_LINKAGE table::iterator table::end() noexcept { return { values.end() }; }
TOML_MEMBER_ATTR(pure) bool table::empty() const noexcept { return values.empty(); }
TOML_MEMBER_ATTR(pure) size_t table::size() const noexcept { return values.size(); }
TOML_EXTERNAL_LINKAGE void table::clear() noexcept { values.clear(); }
#undef TOML_MEMBER_ATTR
TOML_EXTERNAL_LINKAGE TOML_EXTERNAL_LINKAGE
node_view<node> table::operator[] (string_view key) noexcept node_view<node> table::operator[] (string_view key) noexcept
{ {
@ -6395,18 +6440,6 @@ namespace toml
return { this->get(key) }; return { this->get(key) };
} }
TOML_EXTERNAL_LINKAGE table::iterator table::begin() noexcept { return { values.begin() }; }
TOML_EXTERNAL_LINKAGE table::const_iterator table::begin() const noexcept { return { values.begin() }; }
TOML_EXTERNAL_LINKAGE table::const_iterator table::cbegin() const noexcept { return { values.cbegin() }; }
TOML_EXTERNAL_LINKAGE table::iterator table::end() noexcept { return { values.end() }; }
TOML_EXTERNAL_LINKAGE table::const_iterator table::end() const noexcept { return { values.end() }; }
TOML_EXTERNAL_LINKAGE table::const_iterator table::cend() const noexcept { return { values.cend() }; }
TOML_EXTERNAL_LINKAGE bool table::empty() const noexcept { return values.empty(); }
TOML_EXTERNAL_LINKAGE size_t table::size() const noexcept { return values.size(); }
TOML_EXTERNAL_LINKAGE void table::clear() noexcept { values.clear(); }
TOML_EXTERNAL_LINKAGE TOML_EXTERNAL_LINKAGE
table::iterator table::erase(iterator pos) noexcept table::iterator table::erase(iterator pos) noexcept
{ {
@ -6504,6 +6537,8 @@ namespace toml
} }
} }
TOML_POP_WARNINGS // TOML_DISABLE_SUGGEST_WARNINGS
#endif #endif
//------------------------------------------------------------------------------------------- ↑ toml_table.hpp ------- //------------------------------------------------------------------------------------------- ↑ toml_table.hpp -------
@ -6846,7 +6881,7 @@ namespace TOML_INTERNAL_NAMESPACE
} }
[[nodiscard]] [[nodiscard]]
TOML_GNU_ATTR(const) TOML_ATTR(const)
TOML_INTERNAL_LINKAGE TOML_INTERNAL_LINKAGE
std::string_view to_sv(bool val) noexcept std::string_view to_sv(bool val) noexcept
{ {
@ -6871,7 +6906,7 @@ namespace TOML_INTERNAL_NAMESPACE
} }
template <typename T> template <typename T>
TOML_GNU_ATTR(nonnull) TOML_ATTR(nonnull)
TOML_INTERNAL_LINKAGE TOML_INTERNAL_LINKAGE
TOML_NEVER_INLINE TOML_NEVER_INLINE
void concatenate(char*& write_pos, char *const buf_end, const T& arg) noexcept void concatenate(char*& write_pos, char *const buf_end, const T& arg) noexcept
@ -9855,13 +9890,15 @@ namespace toml
#if TOML_UNDEF_MACROS #if TOML_UNDEF_MACROS
#undef TOML_INT_CHARCONV #undef TOML_INT_CHARCONV
#undef TOML_FLOAT_CHARCONV #undef TOML_FLOAT_CHARCONV
#undef TOML_GNU_ATTR #undef TOML_ATTR
#undef TOML_PUSH_WARNINGS #undef TOML_PUSH_WARNINGS
#undef TOML_DISABLE_SWITCH_WARNINGS #undef TOML_DISABLE_SWITCH_WARNINGS
#undef TOML_DISABLE_INIT_WARNINGS #undef TOML_DISABLE_INIT_WARNINGS
#undef TOML_DISABLE_VTABLE_WARNINGS #undef TOML_DISABLE_VTABLE_WARNINGS
#undef TOML_DISABLE_PADDING_WARNINGS #undef TOML_DISABLE_PADDING_WARNINGS
#undef TOML_DISABLE_FLOAT_WARNINGS #undef TOML_DISABLE_FLOAT_WARNINGS
#undef TOML_DISABLE_SHADOW_WARNINGS
#undef TOML_DISABLE_SUGGEST_WARNINGS
#undef TOML_DISABLE_ALL_WARNINGS #undef TOML_DISABLE_ALL_WARNINGS
#undef TOML_POP_WARNINGS #undef TOML_POP_WARNINGS
#undef TOML_ALWAYS_INLINE #undef TOML_ALWAYS_INLINE

View File

@ -61,7 +61,10 @@
<LocalDebuggerWorkingDirectory>..\tests\</LocalDebuggerWorkingDirectory> <LocalDebuggerWorkingDirectory>..\tests\</LocalDebuggerWorkingDirectory>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\tests\conformance.cpp" /> <ClCompile Include="..\tests\conformance_burntsushi_invalid.cpp" />
<ClCompile Include="..\tests\conformance_burntsushi_valid.cpp" />
<ClCompile Include="..\tests\conformance_iarna_invalid.cpp" />
<ClCompile Include="..\tests\conformance_iarna_valid.cpp" />
<ClCompile Include="..\tests\impl_catch2.cpp"> <ClCompile Include="..\tests\impl_catch2.cpp">
<PrecompiledHeader>NotUsing</PrecompiledHeader> <PrecompiledHeader>NotUsing</PrecompiledHeader>
</ClCompile> </ClCompile>

View File

@ -61,7 +61,10 @@
<LocalDebuggerWorkingDirectory>..\tests\</LocalDebuggerWorkingDirectory> <LocalDebuggerWorkingDirectory>..\tests\</LocalDebuggerWorkingDirectory>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\tests\conformance.cpp" /> <ClCompile Include="..\tests\conformance_burntsushi_invalid.cpp" />
<ClCompile Include="..\tests\conformance_burntsushi_valid.cpp" />
<ClCompile Include="..\tests\conformance_iarna_invalid.cpp" />
<ClCompile Include="..\tests\conformance_iarna_valid.cpp" />
<ClCompile Include="..\tests\impl_catch2.cpp"> <ClCompile Include="..\tests\impl_catch2.cpp">
<PrecompiledHeader>NotUsing</PrecompiledHeader> <PrecompiledHeader>NotUsing</PrecompiledHeader>
</ClCompile> </ClCompile>

View File

@ -63,7 +63,10 @@
<LocalDebuggerWorkingDirectory>..\tests\</LocalDebuggerWorkingDirectory> <LocalDebuggerWorkingDirectory>..\tests\</LocalDebuggerWorkingDirectory>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\tests\conformance.cpp" /> <ClCompile Include="..\tests\conformance_burntsushi_invalid.cpp" />
<ClCompile Include="..\tests\conformance_burntsushi_valid.cpp" />
<ClCompile Include="..\tests\conformance_iarna_invalid.cpp" />
<ClCompile Include="..\tests\conformance_iarna_valid.cpp" />
<ClCompile Include="..\tests\impl_catch2.cpp"> <ClCompile Include="..\tests\impl_catch2.cpp">
<PrecompiledHeader>NotUsing</PrecompiledHeader> <PrecompiledHeader>NotUsing</PrecompiledHeader>
</ClCompile> </ClCompile>

View File

@ -61,7 +61,10 @@
<LocalDebuggerWorkingDirectory>..\tests\</LocalDebuggerWorkingDirectory> <LocalDebuggerWorkingDirectory>..\tests\</LocalDebuggerWorkingDirectory>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\tests\conformance.cpp" /> <ClCompile Include="..\tests\conformance_burntsushi_invalid.cpp" />
<ClCompile Include="..\tests\conformance_burntsushi_valid.cpp" />
<ClCompile Include="..\tests\conformance_iarna_invalid.cpp" />
<ClCompile Include="..\tests\conformance_iarna_valid.cpp" />
<ClCompile Include="..\tests\impl_catch2.cpp"> <ClCompile Include="..\tests\impl_catch2.cpp">
<PrecompiledHeader>NotUsing</PrecompiledHeader> <PrecompiledHeader>NotUsing</PrecompiledHeader>
</ClCompile> </ClCompile>

View File

@ -63,7 +63,10 @@
<LocalDebuggerWorkingDirectory>..\tests\</LocalDebuggerWorkingDirectory> <LocalDebuggerWorkingDirectory>..\tests\</LocalDebuggerWorkingDirectory>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\tests\conformance.cpp" /> <ClCompile Include="..\tests\conformance_burntsushi_invalid.cpp" />
<ClCompile Include="..\tests\conformance_burntsushi_valid.cpp" />
<ClCompile Include="..\tests\conformance_iarna_invalid.cpp" />
<ClCompile Include="..\tests\conformance_iarna_valid.cpp" />
<ClCompile Include="..\tests\impl_catch2.cpp"> <ClCompile Include="..\tests\impl_catch2.cpp">
<PrecompiledHeader>NotUsing</PrecompiledHeader> <PrecompiledHeader>NotUsing</PrecompiledHeader>
</ClCompile> </ClCompile>

View File

@ -63,7 +63,10 @@
<LocalDebuggerWorkingDirectory>..\tests\</LocalDebuggerWorkingDirectory> <LocalDebuggerWorkingDirectory>..\tests\</LocalDebuggerWorkingDirectory>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\tests\conformance.cpp" /> <ClCompile Include="..\tests\conformance_burntsushi_invalid.cpp" />
<ClCompile Include="..\tests\conformance_burntsushi_valid.cpp" />
<ClCompile Include="..\tests\conformance_iarna_invalid.cpp" />
<ClCompile Include="..\tests\conformance_iarna_valid.cpp" />
<ClCompile Include="..\tests\impl_catch2.cpp"> <ClCompile Include="..\tests\impl_catch2.cpp">
<PrecompiledHeader>NotUsing</PrecompiledHeader> <PrecompiledHeader>NotUsing</PrecompiledHeader>
</ClCompile> </ClCompile>

View File

@ -61,7 +61,10 @@
<LocalDebuggerWorkingDirectory>..\tests\</LocalDebuggerWorkingDirectory> <LocalDebuggerWorkingDirectory>..\tests\</LocalDebuggerWorkingDirectory>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\tests\conformance.cpp" /> <ClCompile Include="..\tests\conformance_burntsushi_invalid.cpp" />
<ClCompile Include="..\tests\conformance_burntsushi_valid.cpp" />
<ClCompile Include="..\tests\conformance_iarna_invalid.cpp" />
<ClCompile Include="..\tests\conformance_iarna_valid.cpp" />
<ClCompile Include="..\tests\impl_catch2.cpp"> <ClCompile Include="..\tests\impl_catch2.cpp">
<PrecompiledHeader>NotUsing</PrecompiledHeader> <PrecompiledHeader>NotUsing</PrecompiledHeader>
</ClCompile> </ClCompile>

View File

@ -63,7 +63,10 @@
<LocalDebuggerWorkingDirectory>..\tests\</LocalDebuggerWorkingDirectory> <LocalDebuggerWorkingDirectory>..\tests\</LocalDebuggerWorkingDirectory>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\tests\conformance.cpp" /> <ClCompile Include="..\tests\conformance_burntsushi_invalid.cpp" />
<ClCompile Include="..\tests\conformance_burntsushi_valid.cpp" />
<ClCompile Include="..\tests\conformance_iarna_invalid.cpp" />
<ClCompile Include="..\tests\conformance_iarna_valid.cpp" />
<ClCompile Include="..\tests\impl_catch2.cpp"> <ClCompile Include="..\tests\impl_catch2.cpp">
<PrecompiledHeader>NotUsing</PrecompiledHeader> <PrecompiledHeader>NotUsing</PrecompiledHeader>
</ClCompile> </ClCompile>

View File

@ -61,7 +61,10 @@
<LocalDebuggerWorkingDirectory>..\tests\</LocalDebuggerWorkingDirectory> <LocalDebuggerWorkingDirectory>..\tests\</LocalDebuggerWorkingDirectory>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\tests\conformance.cpp" /> <ClCompile Include="..\tests\conformance_burntsushi_invalid.cpp" />
<ClCompile Include="..\tests\conformance_burntsushi_valid.cpp" />
<ClCompile Include="..\tests\conformance_iarna_invalid.cpp" />
<ClCompile Include="..\tests\conformance_iarna_valid.cpp" />
<ClCompile Include="..\tests\impl_catch2.cpp"> <ClCompile Include="..\tests\impl_catch2.cpp">
<PrecompiledHeader>NotUsing</PrecompiledHeader> <PrecompiledHeader>NotUsing</PrecompiledHeader>
</ClCompile> </ClCompile>

View File

@ -61,7 +61,10 @@
<LocalDebuggerWorkingDirectory>..\tests\</LocalDebuggerWorkingDirectory> <LocalDebuggerWorkingDirectory>..\tests\</LocalDebuggerWorkingDirectory>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\tests\conformance.cpp" /> <ClCompile Include="..\tests\conformance_burntsushi_invalid.cpp" />
<ClCompile Include="..\tests\conformance_burntsushi_valid.cpp" />
<ClCompile Include="..\tests\conformance_iarna_invalid.cpp" />
<ClCompile Include="..\tests\conformance_iarna_valid.cpp" />
<ClCompile Include="..\tests\impl_catch2.cpp"> <ClCompile Include="..\tests\impl_catch2.cpp">
<PrecompiledHeader>NotUsing</PrecompiledHeader> <PrecompiledHeader>NotUsing</PrecompiledHeader>
</ClCompile> </ClCompile>

View File

@ -63,7 +63,10 @@
<LocalDebuggerWorkingDirectory>..\tests\</LocalDebuggerWorkingDirectory> <LocalDebuggerWorkingDirectory>..\tests\</LocalDebuggerWorkingDirectory>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\tests\conformance.cpp" /> <ClCompile Include="..\tests\conformance_burntsushi_invalid.cpp" />
<ClCompile Include="..\tests\conformance_burntsushi_valid.cpp" />
<ClCompile Include="..\tests\conformance_iarna_invalid.cpp" />
<ClCompile Include="..\tests\conformance_iarna_valid.cpp" />
<ClCompile Include="..\tests\impl_catch2.cpp"> <ClCompile Include="..\tests\impl_catch2.cpp">
<PrecompiledHeader>NotUsing</PrecompiledHeader> <PrecompiledHeader>NotUsing</PrecompiledHeader>
</ClCompile> </ClCompile>

View File

@ -61,7 +61,10 @@
<LocalDebuggerWorkingDirectory>..\tests\</LocalDebuggerWorkingDirectory> <LocalDebuggerWorkingDirectory>..\tests\</LocalDebuggerWorkingDirectory>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\tests\conformance.cpp" /> <ClCompile Include="..\tests\conformance_burntsushi_invalid.cpp" />
<ClCompile Include="..\tests\conformance_burntsushi_valid.cpp" />
<ClCompile Include="..\tests\conformance_iarna_invalid.cpp" />
<ClCompile Include="..\tests\conformance_iarna_valid.cpp" />
<ClCompile Include="..\tests\impl_catch2.cpp"> <ClCompile Include="..\tests\impl_catch2.cpp">
<PrecompiledHeader>NotUsing</PrecompiledHeader> <PrecompiledHeader>NotUsing</PrecompiledHeader>
</ClCompile> </ClCompile>

View File

@ -63,7 +63,10 @@
<LocalDebuggerWorkingDirectory>..\tests\</LocalDebuggerWorkingDirectory> <LocalDebuggerWorkingDirectory>..\tests\</LocalDebuggerWorkingDirectory>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\tests\conformance.cpp" /> <ClCompile Include="..\tests\conformance_burntsushi_invalid.cpp" />
<ClCompile Include="..\tests\conformance_burntsushi_valid.cpp" />
<ClCompile Include="..\tests\conformance_iarna_invalid.cpp" />
<ClCompile Include="..\tests\conformance_iarna_valid.cpp" />
<ClCompile Include="..\tests\impl_catch2.cpp"> <ClCompile Include="..\tests\impl_catch2.cpp">
<PrecompiledHeader>NotUsing</PrecompiledHeader> <PrecompiledHeader>NotUsing</PrecompiledHeader>
</ClCompile> </ClCompile>

View File

@ -63,7 +63,10 @@
<LocalDebuggerWorkingDirectory>..\tests\</LocalDebuggerWorkingDirectory> <LocalDebuggerWorkingDirectory>..\tests\</LocalDebuggerWorkingDirectory>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\tests\conformance.cpp" /> <ClCompile Include="..\tests\conformance_burntsushi_invalid.cpp" />
<ClCompile Include="..\tests\conformance_burntsushi_valid.cpp" />
<ClCompile Include="..\tests\conformance_iarna_invalid.cpp" />
<ClCompile Include="..\tests\conformance_iarna_valid.cpp" />
<ClCompile Include="..\tests\impl_catch2.cpp"> <ClCompile Include="..\tests\impl_catch2.cpp">
<PrecompiledHeader>NotUsing</PrecompiledHeader> <PrecompiledHeader>NotUsing</PrecompiledHeader>
</ClCompile> </ClCompile>

View File

@ -61,7 +61,10 @@
<LocalDebuggerWorkingDirectory>..\tests\</LocalDebuggerWorkingDirectory> <LocalDebuggerWorkingDirectory>..\tests\</LocalDebuggerWorkingDirectory>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\tests\conformance.cpp" /> <ClCompile Include="..\tests\conformance_burntsushi_invalid.cpp" />
<ClCompile Include="..\tests\conformance_burntsushi_valid.cpp" />
<ClCompile Include="..\tests\conformance_iarna_invalid.cpp" />
<ClCompile Include="..\tests\conformance_iarna_valid.cpp" />
<ClCompile Include="..\tests\impl_catch2.cpp"> <ClCompile Include="..\tests\impl_catch2.cpp">
<PrecompiledHeader>NotUsing</PrecompiledHeader> <PrecompiledHeader>NotUsing</PrecompiledHeader>
</ClCompile> </ClCompile>

View File

@ -63,7 +63,10 @@
<LocalDebuggerWorkingDirectory>..\tests\</LocalDebuggerWorkingDirectory> <LocalDebuggerWorkingDirectory>..\tests\</LocalDebuggerWorkingDirectory>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\tests\conformance.cpp" /> <ClCompile Include="..\tests\conformance_burntsushi_invalid.cpp" />
<ClCompile Include="..\tests\conformance_burntsushi_valid.cpp" />
<ClCompile Include="..\tests\conformance_iarna_invalid.cpp" />
<ClCompile Include="..\tests\conformance_iarna_valid.cpp" />
<ClCompile Include="..\tests\impl_catch2.cpp"> <ClCompile Include="..\tests\impl_catch2.cpp">
<PrecompiledHeader>NotUsing</PrecompiledHeader> <PrecompiledHeader>NotUsing</PrecompiledHeader>
</ClCompile> </ClCompile>

View File

@ -83,7 +83,6 @@
<ClInclude Include="..\include\toml++\toml_instantiations.hpp" /> <ClInclude Include="..\include\toml++\toml_instantiations.hpp" />
<ClInclude Include="..\include\toml++\toml_version.h" /> <ClInclude Include="..\include\toml++\toml_version.h" />
<ClInclude Include="..\tests\settings.h" /> <ClInclude Include="..\tests\settings.h" />
<ClInclude Include="..\toml.hpp" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="..\.editorconfig" /> <None Include="..\.editorconfig" />

View File

@ -79,7 +79,6 @@
<ClInclude Include="..\include\toml++\toml_json_formatter.hpp"> <ClInclude Include="..\include\toml++\toml_json_formatter.hpp">
<Filter>include</Filter> <Filter>include</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\toml.hpp" />
<ClInclude Include="..\tests\settings.h"> <ClInclude Include="..\tests\settings.h">
<Filter>include</Filter> <Filter>include</Filter>
</ClInclude> </ClInclude>