Compare commits

...

4 Commits

Author SHA1 Message Date
ToruNiina
b32a2fff0d feat [skip ci]: update single_include 2025-12-03 15:00:56 +00:00
Toru Niina
b96acf96ba Merge pull request #295 from franzpoeschel/undef-source-location
Add a way to optionally suppress usage of std::source_location
2025-12-04 00:00:36 +09:00
ToruNiina
504692db77 feat [skip ci]: update single_include 2025-12-02 14:39:12 +00:00
Franz Pöschel
8588eb2197 Add a define to optionally suppress usage of std::source_location 2025-06-16 12:00:28 +02:00
2 changed files with 18 additions and 16 deletions

View File

@@ -448,13 +448,13 @@ using void_t = void;
// ----------------------------------------------------------------------------
// (subset of) source_location
#if TOML11_CPLUSPLUS_STANDARD_VERSION >= 202002L
#if ! defined(TOML11_DISABLE_SOURCE_LOCATION) && TOML11_CPLUSPLUS_STANDARD_VERSION >= 202002L
# if __has_include(<source_location>)
# define TOML11_HAS_STD_SOURCE_LOCATION
# endif // has_include
#endif // c++20
#if ! defined(TOML11_HAS_STD_SOURCE_LOCATION)
#if ! defined(TOML11_DISABLE_SOURCE_LOCATION) && ! defined(TOML11_HAS_STD_SOURCE_LOCATION)
# if defined(__GNUC__) && ! defined(__clang__)
# if TOML11_CPLUSPLUS_STANDARD_VERSION >= TOML11_CXX14_VALUE
# if __has_include(<experimental/source_location>)
@@ -464,7 +464,7 @@ using void_t = void;
# endif // GNU g++
#endif // not TOML11_HAS_STD_SOURCE_LOCATION
#if ! defined(TOML11_HAS_STD_SOURCE_LOCATION) && ! defined(TOML11_HAS_EXPERIMENTAL_SOURCE_LOCATION)
#if ! defined(TOML11_DISABLE_SOURCE_LOCATION) && ! defined(TOML11_HAS_STD_SOURCE_LOCATION) && ! defined(TOML11_HAS_EXPERIMENTAL_SOURCE_LOCATION)
# if defined(__GNUC__) && ! defined(__clang__)
# if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 9))
# define TOML11_HAS_BUILTIN_FILE_LINE 1

View File

@@ -237,13 +237,13 @@ struct spec
constexpr explicit spec(const semantic_version& semver) noexcept
: version{semver},
v1_1_0_allow_control_characters_in_comments {semantic_version{1, 1, 0} <= semver},
v1_1_0_allow_newlines_in_inline_tables {semantic_version{1, 1, 0} <= semver},
v1_1_0_allow_trailing_comma_in_inline_tables{semantic_version{1, 1, 0} <= semver},
v1_1_0_allow_non_english_in_bare_keys {semantic_version{1, 1, 0} <= semver},
v1_1_0_add_escape_sequence_e {semantic_version{1, 1, 0} <= semver},
v1_1_0_add_escape_sequence_x {semantic_version{1, 1, 0} <= semver},
v1_1_0_make_seconds_optional {semantic_version{1, 1, 0} <= semver},
ext_allow_control_characters_in_comments{false},
ext_allow_non_english_in_bare_keys{false},
ext_hex_float {false},
ext_num_suffix{false},
ext_null_value{false}
@@ -252,14 +252,16 @@ struct spec
semantic_version version; // toml version
// diff from v1.0.0 -> v1.1.0
bool v1_1_0_allow_control_characters_in_comments;
bool v1_1_0_allow_newlines_in_inline_tables;
bool v1_1_0_allow_trailing_comma_in_inline_tables;
bool v1_1_0_allow_non_english_in_bare_keys;
bool v1_1_0_add_escape_sequence_e;
bool v1_1_0_add_escape_sequence_x;
bool v1_1_0_make_seconds_optional;
// discussed in toml-lang, but currently not in it
bool ext_allow_control_characters_in_comments;
bool ext_allow_non_english_in_bare_keys;
// library extensions
bool ext_hex_float; // allow hex float (in C++ style)
bool ext_num_suffix; // allow number suffix (in C++ style)
@@ -272,13 +274,13 @@ inline std::pair<const semantic_version&, std::array<bool, 10>>
to_tuple(const spec& s) noexcept
{
return std::make_pair(std::cref(s.version), std::array<bool, 10>{{
s.v1_1_0_allow_control_characters_in_comments,
s.v1_1_0_allow_newlines_in_inline_tables,
s.v1_1_0_allow_trailing_comma_in_inline_tables,
s.v1_1_0_allow_non_english_in_bare_keys,
s.v1_1_0_add_escape_sequence_e,
s.v1_1_0_add_escape_sequence_x,
s.v1_1_0_make_seconds_optional,
s.ext_allow_control_characters_in_comments,
s.ext_allow_non_english_in_bare_keys,
s.ext_hex_float,
s.ext_num_suffix,
s.ext_null_value
@@ -2471,13 +2473,13 @@ using void_t = void;
// ----------------------------------------------------------------------------
// (subset of) source_location
#if TOML11_CPLUSPLUS_STANDARD_VERSION >= 202002L
#if ! defined(TOML11_DISABLE_SOURCE_LOCATION) && TOML11_CPLUSPLUS_STANDARD_VERSION >= 202002L
# if __has_include(<source_location>)
# define TOML11_HAS_STD_SOURCE_LOCATION
# endif // has_include
#endif // c++20
#if ! defined(TOML11_HAS_STD_SOURCE_LOCATION)
#if ! defined(TOML11_DISABLE_SOURCE_LOCATION) && ! defined(TOML11_HAS_STD_SOURCE_LOCATION)
# if defined(__GNUC__) && ! defined(__clang__)
# if TOML11_CPLUSPLUS_STANDARD_VERSION >= TOML11_CXX14_VALUE
# if __has_include(<experimental/source_location>)
@@ -2487,7 +2489,7 @@ using void_t = void;
# endif // GNU g++
#endif // not TOML11_HAS_STD_SOURCE_LOCATION
#if ! defined(TOML11_HAS_STD_SOURCE_LOCATION) && ! defined(TOML11_HAS_EXPERIMENTAL_SOURCE_LOCATION)
#if ! defined(TOML11_DISABLE_SOURCE_LOCATION) && ! defined(TOML11_HAS_STD_SOURCE_LOCATION) && ! defined(TOML11_HAS_EXPERIMENTAL_SOURCE_LOCATION)
# if defined(__GNUC__) && ! defined(__clang__)
# if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 9))
# define TOML11_HAS_BUILTIN_FILE_LINE 1
@@ -6146,7 +6148,7 @@ TOML11_INLINE either const& newline(const spec&)
TOML11_INLINE either const& allowed_comment_char(const spec& sp)
{
static thread_local auto cache = make_cache([](const spec& s){
if(s.v1_1_0_allow_control_characters_in_comments)
if(s.ext_allow_control_characters_in_comments)
{
return either(
character_in_range(0x01, 0x09),
@@ -6713,7 +6715,7 @@ TOML11_INLINE either const& string(const spec& sp)
// to keep `expected_chars` simple
TOML11_INLINE non_ascii_key_char::non_ascii_key_char(const spec& s) noexcept
{
assert(s.v1_1_0_allow_non_english_in_bare_keys);
assert(s.ext_allow_non_english_in_bare_keys);
(void)s; // for NDEBUG
}
@@ -6825,7 +6827,7 @@ TOML11_INLINE repeat_at_least const& unquoted_key(const spec& sp)
{
static thread_local auto cache = make_cache([](const spec& s) {
const auto keychar = [&s] {
if(s.v1_1_0_allow_non_english_in_bare_keys)
if(s.ext_allow_non_english_in_bare_keys)
{
return either(alpha(s), digit(s), character{0x2D}, character{0x5F},
non_ascii_key_char(s));
@@ -16051,7 +16053,7 @@ parse_simple_key(location& loc, const context<TC>& ctx)
else
{
std::string postfix;
if(spec.v1_1_0_allow_non_english_in_bare_keys)
if(spec.ext_allow_non_english_in_bare_keys)
{
postfix = "Hint: Not all Unicode characters are allowed as bare key.\n";
}