mirror of
https://github.com/marzer/tomlplusplus.git
synced 2024-09-15 15:13:21 +00:00
added support for \xHH escape sequences (unreleased)
also: - fixed EOF bug in string parsing when exceptions are disabled - fixed exception mode detection sometimes being incorrect on MSVC - added short-form license preamble to all source files - simplified license files
This commit is contained in:
parent
45bfff536b
commit
438970b412
3
LICENSE
3
LICENSE
@ -1,6 +1,7 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2019-2020 Mark Gillard
|
||||
Copyright (c) 2019-2020 Mark Gillard <mark.gillard@outlook.com.au>
|
||||
Copyright (c) 2008-2010 Bjoern Hoehrmann <bjoern@hoehrmann.de> (utf8_decoder)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
|
||||
documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
|
||||
|
@ -1,14 +0,0 @@
|
||||
Copyright (c) 2008-2010 Bjoern Hoehrmann <bjoern@hoehrmann.de>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
|
||||
documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
|
||||
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
|
||||
Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
||||
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@ -120,6 +120,7 @@ defines `TOML_LANG_MAJOR`, `TOML_LANG_MINOR` and `TOML_LANG_PATCH`.
|
||||
- [#665]: Make arrays heterogeneous
|
||||
- [#671]: Local time of day format should support `09:30` as opposed to `09:30:00`
|
||||
- [#687]: Relax bare key restrictions to allow additional unicode characters
|
||||
- [#709]: Include an \xHH escape code sequence
|
||||
|
||||
_These can be disabled (and thus strict [TOML v0.5.0] compliance enforced) by specifying
|
||||
`TOML_UNRELEASED_FEATURES = 0` (see [Configuration](#Configuration))._
|
||||
@ -139,8 +140,7 @@ If you wish to submit a pull request, please see [CONTRIBUTING] for all the deta
|
||||
|
||||
`toml++` is licensed under the terms of the MIT license - see [LICENSE].
|
||||
|
||||
UTF-8 decoding is performed using a state machine based on Bjoern Hoehrmann's '[Flexible and Economical UTF-8 Decoder]',
|
||||
which is also subject to the terms of the MIT license - see [LICENSE-utf8-decoder].
|
||||
UTF-8 decoding is performed using a state machine based on Bjoern Hoehrmann's '[Flexible and Economical UTF-8 Decoder]'.
|
||||
|
||||
[API documentation]: https://marzer.github.io/tomlplusplus/
|
||||
[unreleased TOML language features]: #unreleased-toml-features
|
||||
@ -165,5 +165,6 @@ which is also subject to the terms of the MIT license - see [LICENSE-utf8-decode
|
||||
[#665]: https://github.com/toml-lang/toml/issues/665
|
||||
[#671]: https://github.com/toml-lang/toml/issues/671
|
||||
[#687]: https://github.com/toml-lang/toml/issues/687
|
||||
[#709]: https://github.com/toml-lang/toml/pull/709
|
||||
[LICENSE-utf8-decoder]: ./LICENSE-utf8-decoder
|
||||
[something better than std::optional]: https://github.com/TartanLlama/optional
|
||||
|
@ -1,3 +1,7 @@
|
||||
//# 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.
|
||||
|
||||
#pragma once
|
||||
|
||||
//# Note: most of these would be included transitively but
|
||||
@ -51,7 +55,6 @@
|
||||
#undef TOML_CONSTEVAL
|
||||
#undef TOML_LIKELY
|
||||
#undef TOML_UNLIKELY
|
||||
#undef TOML_NO_UNIQUE_ADDRESS
|
||||
#undef TOML_NODISCARD_CTOR
|
||||
#undef TOML_MAKE_VERSION
|
||||
#undef TOML_LANG_EFFECTIVE_VERSION
|
||||
@ -78,6 +81,7 @@
|
||||
#undef TOML_ALL_INLINE
|
||||
#undef TOML_IMPLEMENTATION
|
||||
#undef TOML_INLINE_FUNC_IMPL
|
||||
#undef TOML_COMPILER_EXCEPTIONS
|
||||
#endif
|
||||
|
||||
/// \mainpage toml++
|
||||
@ -222,7 +226,6 @@
|
||||
/// static constexpr auto source = R"(
|
||||
/// [library]
|
||||
/// name = "toml++"
|
||||
/// version = "0.1.0"
|
||||
/// authors = ["Mark Gillard <mark@notarealwebsite.com>"]
|
||||
///
|
||||
/// [dependencies]
|
||||
@ -253,7 +256,6 @@
|
||||
/// [library]
|
||||
/// authors = ["Mark Gillard <mark@notarealwebsite.com>"]
|
||||
/// name = "toml++"
|
||||
/// version = "0.1.0"
|
||||
///
|
||||
/// ... exactly as above, but twice
|
||||
/// \eout
|
||||
@ -422,12 +424,8 @@
|
||||
/// toml++ is licensed under the terms of the MIT license - see
|
||||
/// [LICENSE](https://github.com/marzer/tomlplusplus/blob/master/LICENSE).
|
||||
///
|
||||
/// UTF-8 decoding is performed using a state machine based on Bjoern Hoehrmann's
|
||||
/// 'Flexible and Economical UTF - 8 Decoder', which is also subject to the terms of the MIT license - see
|
||||
/// [LICENSE-utf8-decoder](https://github.com/marzer/tomlplusplus/blob/master/LICENSE-utf8-decoder).
|
||||
///
|
||||
/// \m_class{m-note m-default}
|
||||
///
|
||||
/// If you're using the single-header version of the library you don't need to distribute these files;
|
||||
/// their contents is included in the preamble at the top of the file.
|
||||
/// If you're using the single-header version of the library you don't need to explicitly distribute the license file;
|
||||
/// it is embedded in the preamble at the top of the header.
|
||||
///
|
||||
|
@ -1,3 +1,7 @@
|
||||
//# 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.
|
||||
|
||||
#pragma once
|
||||
#include "toml_value.h"
|
||||
|
||||
|
@ -1,3 +1,7 @@
|
||||
//# 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.
|
||||
|
||||
#pragma once
|
||||
#include "toml_array.h"
|
||||
|
||||
|
@ -1,3 +1,7 @@
|
||||
//# 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.
|
||||
|
||||
#pragma once
|
||||
|
||||
////////// CONFIGURATION
|
||||
@ -70,14 +74,15 @@
|
||||
#define TOML_ALWAYS_INLINE TOML_GCC_ATTR(__always_inline__) inline
|
||||
#define TOML_ASSUME(cond) __builtin_assume(cond)
|
||||
#define TOML_UNREACHABLE __builtin_unreachable()
|
||||
|
||||
#if __has_declspec_attribute(novtable)
|
||||
#define TOML_INTERFACE __declspec(novtable)
|
||||
#endif
|
||||
|
||||
#if __has_declspec_attribute(empty_bases)
|
||||
#define TOML_EMPTY_BASES __declspec(empty_bases)
|
||||
#endif
|
||||
#ifdef __EXCEPTIONS
|
||||
#define TOML_COMPILER_EXCEPTIONS 1
|
||||
#endif
|
||||
|
||||
//floating-point from_chars and to_chars are not implemented in any version of clang as of 1/1/2020
|
||||
#ifndef TOML_USE_STREAMS_FOR_FLOATS
|
||||
@ -97,10 +102,12 @@
|
||||
#define TOML_UNREACHABLE __assume(0)
|
||||
#define TOML_INTERFACE __declspec(novtable)
|
||||
#define TOML_EMPTY_BASES __declspec(empty_bases)
|
||||
|
||||
#if !defined(TOML_RELOPS_REORDERING) && defined(__cpp_impl_three_way_comparison)
|
||||
#define TOML_RELOPS_REORDERING 1
|
||||
#endif
|
||||
#ifdef _CPPUNWIND
|
||||
#define TOML_COMPILER_EXCEPTIONS 1
|
||||
#endif
|
||||
|
||||
#elif defined(__GNUC__)
|
||||
|
||||
@ -116,6 +123,12 @@
|
||||
#define TOML_POP_WARNINGS _Pragma("GCC diagnostic pop")
|
||||
#define TOML_ALWAYS_INLINE TOML_GCC_ATTR(__always_inline__) inline
|
||||
#define TOML_UNREACHABLE __builtin_unreachable()
|
||||
#if !defined(TOML_RELOPS_REORDERING) && defined(__cpp_impl_three_way_comparison)
|
||||
#define TOML_RELOPS_REORDERING 1
|
||||
#endif
|
||||
#ifdef __cpp_exceptions
|
||||
#define TOML_COMPILER_EXCEPTIONS 1
|
||||
#endif
|
||||
|
||||
// these pass the __has_attribute() test but cause warnings on if/else branches =/
|
||||
#define TOML_LIKELY
|
||||
@ -126,10 +139,6 @@
|
||||
#define TOML_USE_STREAMS_FOR_FLOATS 1
|
||||
#endif
|
||||
|
||||
#if !defined(TOML_RELOPS_REORDERING) && defined(__cpp_impl_three_way_comparison)
|
||||
#define TOML_RELOPS_REORDERING 1
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef TOML_CPP_VERSION
|
||||
@ -148,16 +157,19 @@
|
||||
#elif TOML_CPP_VERSION >= 201703L
|
||||
#define TOML_CPP 17
|
||||
#endif
|
||||
#if !defined(__EXCEPTIONS) && !defined(__cpp_exceptions) && !defined(_CPPUNWIND)
|
||||
#ifndef TOML_COMPILER_EXCEPTIONS
|
||||
#define TOML_COMPILER_EXCEPTIONS 0
|
||||
#endif
|
||||
#if TOML_COMPILER_EXCEPTIONS
|
||||
#ifndef TOML_EXCEPTIONS
|
||||
#define TOML_EXCEPTIONS 1
|
||||
#endif
|
||||
#else
|
||||
#if defined(TOML_EXCEPTIONS) && TOML_EXCEPTIONS
|
||||
#error TOML_EXCEPTIONS was explicitly enabled but exceptions are disabled/unsupported by the compiler.
|
||||
#endif
|
||||
#undef TOML_EXCEPTIONS
|
||||
#define TOML_EXCEPTIONS 0
|
||||
#else
|
||||
#ifndef TOML_EXCEPTIONS
|
||||
#define TOML_EXCEPTIONS 1
|
||||
#endif
|
||||
#endif
|
||||
#if TOML_EXCEPTIONS
|
||||
#define TOML_MAY_THROW
|
||||
@ -214,9 +226,6 @@
|
||||
#if !defined(TOML_UNLIKELY) && __has_cpp_attribute(unlikely)
|
||||
#define TOML_UNLIKELY [[unlikely]]
|
||||
#endif
|
||||
#if !defined(TOML_NO_UNIQUE_ADDRESS) && __has_cpp_attribute(no_unique_address)
|
||||
#define TOML_NO_UNIQUE_ADDRESS [[no_unique_address]]
|
||||
#endif
|
||||
#if __has_cpp_attribute(nodiscard) >= 201907L
|
||||
#define TOML_NODISCARD_CTOR [[nodiscard]]
|
||||
#endif
|
||||
@ -227,9 +236,6 @@
|
||||
#ifndef TOML_UNLIKELY
|
||||
#define TOML_UNLIKELY
|
||||
#endif
|
||||
#ifndef TOML_NO_UNIQUE_ADDRESS
|
||||
#define TOML_NO_UNIQUE_ADDRESS
|
||||
#endif
|
||||
#ifndef TOML_NODISCARD_CTOR
|
||||
#define TOML_NODISCARD_CTOR
|
||||
#endif
|
||||
|
@ -1,3 +1,7 @@
|
||||
//# 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.
|
||||
|
||||
#pragma once
|
||||
#include "toml_common.h"
|
||||
|
||||
|
@ -1,3 +1,7 @@
|
||||
//# 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.
|
||||
|
||||
#pragma once
|
||||
#include "toml_formatter.h"
|
||||
#include "toml_table.h"
|
||||
|
@ -1,3 +1,7 @@
|
||||
//# 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.
|
||||
|
||||
#pragma once
|
||||
#include "toml_print_to_stream.h"
|
||||
|
||||
|
@ -1,3 +1,7 @@
|
||||
//# 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.
|
||||
|
||||
#pragma once
|
||||
#include "toml_value.h"
|
||||
#include "toml_node_view.h"
|
||||
|
@ -1,3 +1,7 @@
|
||||
//# 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.
|
||||
|
||||
#pragma once
|
||||
#include "toml_formatter.h"
|
||||
|
||||
|
@ -1,3 +1,7 @@
|
||||
//# 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.
|
||||
|
||||
#pragma once
|
||||
#include "toml_common.h"
|
||||
|
||||
|
@ -1,3 +1,7 @@
|
||||
//# 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.
|
||||
|
||||
#pragma once
|
||||
#include "toml_node.h"
|
||||
|
||||
|
@ -1,3 +1,7 @@
|
||||
//# 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.
|
||||
|
||||
#pragma once
|
||||
#include "toml_table.h"
|
||||
#include "toml_array.h"
|
||||
|
@ -1,3 +1,7 @@
|
||||
//# 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.
|
||||
|
||||
#pragma once
|
||||
#include "toml_table.h"
|
||||
#include "toml_utf8.h"
|
||||
|
@ -1,3 +1,7 @@
|
||||
//# 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.
|
||||
|
||||
#pragma once
|
||||
#include "toml_parser.h"
|
||||
|
||||
@ -444,14 +448,24 @@ TOML_IMPL_START
|
||||
case U'\\': str += TOML_STRING_PREFIX('\\'); break;
|
||||
|
||||
// unicode scalar sequences
|
||||
case U'x':
|
||||
#if TOML_LANG_HIGHER_THAN(0, 5, 0)
|
||||
[[fallthrough]];
|
||||
#else
|
||||
abort_with_error("Escape sequence '\\x' is not supported "
|
||||
"in TOML 0.5.0 and earlier."sv
|
||||
);
|
||||
break;
|
||||
#endif
|
||||
case U'u': [[fallthrough]];
|
||||
case U'U':
|
||||
{
|
||||
uint32_t place_value = escaped_codepoint == U'U' ? 0x10000000u : 0x1000u;
|
||||
uint32_t place_value = escaped_codepoint == U'U' ? 0x10000000u : (escaped_codepoint == U'u' ? 0x1000u : 0x10u);
|
||||
uint32_t sequence_value{};
|
||||
while (place_value)
|
||||
{
|
||||
eof_check();
|
||||
TOML_ERROR_CHECK({});
|
||||
|
||||
if (!is_hexadecimal_digit(*cp))
|
||||
abort_with_error(
|
||||
@ -497,7 +511,6 @@ TOML_IMPL_START
|
||||
str += static_cast<string_char>(0x80u | ((sequence_value >> 6) & 0x3Fu));
|
||||
str += static_cast<string_char>(0x80u | (sequence_value & 0x3Fu));
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,7 @@
|
||||
//# 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.
|
||||
|
||||
#pragma once
|
||||
#include "toml_date_time.h"
|
||||
|
||||
|
@ -1,3 +1,7 @@
|
||||
//# 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.
|
||||
|
||||
#pragma once
|
||||
#include "toml_array.h"
|
||||
|
||||
|
@ -1,3 +1,7 @@
|
||||
//# 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.
|
||||
|
||||
#pragma once
|
||||
#include "toml_table.h"
|
||||
#include "toml_node_view.h"
|
||||
|
@ -1,3 +1,8 @@
|
||||
//# 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>
|
||||
//# Copyright (c) 2008-2010 Bjoern Hoehrmann <bjoern@hoehrmann.de> (utf8_decoder)
|
||||
//# See https://github.com/marzer/tomlplusplus/blob/master/LICENSE for the full license text.
|
||||
|
||||
#pragma once
|
||||
#include "toml_common.h"
|
||||
#include "toml_utf8_generated.h"
|
||||
|
@ -1,4 +1,9 @@
|
||||
//# this file was generated by generate_unicode_functions.py
|
||||
//# 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.
|
||||
//#-----
|
||||
//# this file was generated by generate_unicode_functions.py - do not modify it directly
|
||||
|
||||
#pragma once
|
||||
#include "toml_common.h"
|
||||
|
||||
|
@ -1,3 +1,7 @@
|
||||
//# 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.
|
||||
|
||||
#pragma once
|
||||
#include "toml_node.h"
|
||||
#include "toml_print_to_stream.h"
|
||||
|
@ -1,8 +1,12 @@
|
||||
//# 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.
|
||||
|
||||
#pragma once
|
||||
|
||||
#define TOML_LIB_MAJOR 0
|
||||
#define TOML_LIB_MINOR 4
|
||||
#define TOML_LIB_PATCH 3
|
||||
#define TOML_LIB_PATCH 4
|
||||
|
||||
#define TOML_LANG_MAJOR 0
|
||||
#define TOML_LANG_MINOR 5
|
||||
|
@ -1,7 +1,7 @@
|
||||
project(
|
||||
'tomlplusplus',
|
||||
'cpp',
|
||||
version : '0.4.3',
|
||||
version : '0.4.4',
|
||||
license : 'MIT',
|
||||
default_options : [
|
||||
'cpp_std=c++17',
|
||||
|
@ -1,4 +1,7 @@
|
||||
#!/usr/bin/env python3
|
||||
# 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.
|
||||
|
||||
import sys
|
||||
import os
|
||||
|
@ -1,4 +1,7 @@
|
||||
#!/usr/bin/env python3
|
||||
# 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.
|
||||
|
||||
import sys
|
||||
import re
|
||||
|
@ -1,4 +1,7 @@
|
||||
#!/usr/bin/env python3
|
||||
# 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.
|
||||
|
||||
import sys
|
||||
import re
|
||||
@ -77,7 +80,7 @@ def main():
|
||||
# preprocess header(s)
|
||||
source_text = Preprocessor()('toml.h')
|
||||
source_text = re.sub('\r\n', '\n', source_text, 0, re.I | re.M) # convert windows newlines
|
||||
source_text = re.sub('(?:\n[ \t]*//[/#!<]+[^\n]*)+\n', '\n', source_text, 0, re.I | re.M) # remove 'magic' comment blocks
|
||||
source_text = re.sub('(?:(?:\n|^)[ \t]*//[/#!<]+[^\n]*)+\n', '\n', source_text, 0, re.I | re.M) # remove 'magic' comment blocks
|
||||
source_text = re.sub('(?:///[<].*?)\n', '\n', source_text, 0, re.I | re.M) # remove inline doxy briefs
|
||||
source_text = re.sub('\n(?:[ \t]*\n[ \t]*)+\n', '\n\n', source_text, 0, re.I | re.M) # remove double newlines
|
||||
source_text = re.sub('([^ \t])[ \t]+\n', '\\1\n', source_text, 0, re.I | re.M) # remove trailing whitespace
|
||||
@ -104,8 +107,6 @@ def main():
|
||||
source_text = re.sub(blank_lines_between_returns_pattern, '\\1\n\\2', source_text, 0, re.I | re.M)
|
||||
source_text = source_text.strip()
|
||||
|
||||
|
||||
|
||||
# extract library version
|
||||
library_version = [0,0,0]
|
||||
match = re.search(r'^\s*#\s*define\s+TOML_LIB_MAJOR\s+([0-9]+)\s*$', source_text, re.I | re.M)
|
||||
@ -136,15 +137,6 @@ TOML language specification:
|
||||
Latest: https://github.com/toml-lang/toml/blob/master/README.md
|
||||
v0.5.0: https://github.com/toml-lang/toml/blob/master/versions/en/toml-v0.5.0.md''')
|
||||
preamble.append(read_all_text_from_file(path.join(get_script_folder(), '..', 'LICENSE')))
|
||||
preamble.append('''
|
||||
UTF-8 decoding is performed using a derivative of Bjoern Hoehrmann's 'Flexible and Economical UTF-8 Decoder'
|
||||
See http://bjoern.hoehrmann.de/utf-8/decoder/dfa/ for details.
|
||||
|
||||
{}
|
||||
'''.format(
|
||||
read_all_text_from_file(path.join(get_script_folder(), '..', 'LICENSE-utf8-decoder'))
|
||||
))
|
||||
|
||||
|
||||
# write the output file
|
||||
output_file_path = path.join(get_script_folder(), '..', 'toml.hpp')
|
||||
|
@ -1,4 +1,7 @@
|
||||
#!/usr/bin/env python3
|
||||
# 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.
|
||||
|
||||
import sys
|
||||
import re
|
||||
@ -576,17 +579,35 @@ def main():
|
||||
output_file_path = path.join(get_script_folder(), '..', 'include', 'toml++', 'toml_utf8_generated.h')
|
||||
print("Writing to {}".format(output_file_path))
|
||||
with open(output_file_path, 'w', encoding='utf-8', newline='\n') as output_file:
|
||||
print('//# this file was generated by generate_unicode_functions.py', file=output_file)
|
||||
print('#pragma once', file=output_file)
|
||||
print('#include "toml_common.h"', file=output_file)
|
||||
print('\n#if TOML_LANG_HIGHER_THAN(0, 5, 0) // toml/issues/687', file=output_file)
|
||||
print('\n#define TOML_ASSUME_CODEPOINT_BETWEEN(first, last)\t\\\n\tTOML_ASSUME(codepoint >= first);\t\t\t\t\\\n\tTOML_ASSUME(codepoint <= last)', file=output_file)
|
||||
print('\nTOML_IMPL_START\n{', file=output_file, end='')
|
||||
print(
|
||||
'''//# 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.
|
||||
//#-----
|
||||
//# this file was generated by generate_unicode_functions.py - do not modify it directly
|
||||
|
||||
#pragma once
|
||||
#include "toml_common.h"
|
||||
|
||||
#if TOML_LANG_HIGHER_THAN(0, 5, 0) // toml/issues/687
|
||||
|
||||
#define TOML_ASSUME_CODEPOINT_BETWEEN(first, last) \\
|
||||
TOML_ASSUME(codepoint >= first); \\
|
||||
TOML_ASSUME(codepoint <= last)
|
||||
|
||||
TOML_IMPL_START
|
||||
{''', file=output_file, end='')
|
||||
emit_function('is_unicode_letter', ('Ll', 'Lm', 'Lo', 'Lt', 'Lu'), output_file, codepoints)
|
||||
emit_function('is_unicode_number', ('Nd', 'Nl'), output_file, codepoints)
|
||||
emit_function('is_unicode_combining_mark', ('Mn', 'Mc'), output_file, codepoints)
|
||||
print('}\nTOML_IMPL_END\n\n#undef TOML_ASSUME_CODEPOINT_BETWEEN', file=output_file)
|
||||
print('\n#endif // TOML_LANG_HIGHER_THAN(0, 5, 0)', file=output_file)
|
||||
print(
|
||||
'''}
|
||||
TOML_IMPL_END
|
||||
|
||||
#undef TOML_ASSUME_CODEPOINT_BETWEEN
|
||||
|
||||
#endif // TOML_LANG_HIGHER_THAN(0, 5, 0)
|
||||
''', file=output_file, end='')
|
||||
|
||||
if __name__ == '__main__':
|
||||
try:
|
||||
|
@ -138,4 +138,30 @@ str = ''''That's still pointless', she said.'''
|
||||
#else
|
||||
parsing_should_fail(R"(str = "The\squick\sbrown\sfox\sjumps\sover\sthe\slazy\sdog")"sv);
|
||||
#endif
|
||||
|
||||
// toml/pull/709 - \xHH short-form unicode scalars
|
||||
#if TOML_LANG_HIGHER_THAN(0, 5, 0)
|
||||
parse_expected_value(
|
||||
R"("\x00\x10\x20\x30\x40\x50\x60\x70\x80\x90\x11\xFF\xEE")"sv,
|
||||
S("\u0000\u0010\u0020\u0030\u0040\u0050\u0060\u0070\u0080\u0090\u0011\u00FF\u00EE"sv));
|
||||
#else
|
||||
parsing_should_fail(R"(str = "\x00\x10\x20\x30\x40\x50\x60\x70\x80\x90\x11\xFF\xEE")"sv);
|
||||
#endif
|
||||
|
||||
//check 8-digit \U scalars with insufficient digits
|
||||
parsing_should_fail(R"(str = "\U1234567")"sv);
|
||||
parsing_should_fail(R"(str = "\U123456")"sv);
|
||||
parsing_should_fail(R"(str = "\U12345")"sv);
|
||||
parsing_should_fail(R"(str = "\U1234")"sv);
|
||||
parsing_should_fail(R"(str = "\U123")"sv);
|
||||
parsing_should_fail(R"(str = "\U12")"sv);
|
||||
parsing_should_fail(R"(str = "\U1")"sv);
|
||||
|
||||
//check 4-digit \u scalars with insufficient digits
|
||||
parsing_should_fail(R"(str = "\u123")"sv);
|
||||
parsing_should_fail(R"(str = "\u12")"sv);
|
||||
parsing_should_fail(R"(str = "\u1")"sv);
|
||||
|
||||
//check 2-digit \x scalars with insufficient digits
|
||||
parsing_should_fail(R"(str = "\x1")"sv);
|
||||
}
|
||||
|
@ -14,7 +14,7 @@
|
||||
#define TOML_ALL_INLINE 0
|
||||
#include "../include/toml++/toml.h"
|
||||
|
||||
#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND)
|
||||
#if TOML_COMPILER_EXCEPTIONS
|
||||
#if !TOML_EXCEPTIONS
|
||||
#error Exceptions were enabled but TOML_EXCEPTIONS was auto-set to disabled
|
||||
#endif
|
||||
@ -115,6 +115,8 @@ inline void parsing_should_succeed(std::basic_string_view<CHAR> toml_str, FUNC&&
|
||||
template <typename CHAR>
|
||||
inline void parsing_should_fail(std::basic_string_view<CHAR> toml_str) noexcept
|
||||
{
|
||||
INFO("String being parsed: '"sv << std::string_view(reinterpret_cast<const char*>(toml_str.data()), toml_str.length()) << "'"sv)
|
||||
|
||||
#if TOML_EXCEPTIONS
|
||||
|
||||
static constexpr auto run_tests = [](auto&& fn) noexcept
|
||||
|
80
toml.hpp
80
toml.hpp
@ -1,6 +1,6 @@
|
||||
//----------------------------------------------------------------------------------------------------------------------
|
||||
//
|
||||
// toml++ v0.4.3
|
||||
// toml++ v0.4.4
|
||||
// https://github.com/marzer/tomlplusplus
|
||||
// SPDX-License-Identifier: MIT
|
||||
//
|
||||
@ -23,27 +23,8 @@
|
||||
//
|
||||
// MIT License
|
||||
//
|
||||
// Copyright (c) 2019-2020 Mark Gillard
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
|
||||
// documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
|
||||
// Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
||||
// WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
//----------------------------------------------------------------------------------------------------------------------
|
||||
//
|
||||
// UTF-8 decoding is performed using a derivative of Bjoern Hoehrmann's 'Flexible and Economical UTF-8 Decoder'
|
||||
// See http://bjoern.hoehrmann.de/utf-8/decoder/dfa/ for details.
|
||||
//
|
||||
// Copyright (c) 2008-2010 Bjoern Hoehrmann <bjoern@hoehrmann.de>
|
||||
// Copyright (c) 2019-2020 Mark Gillard <mark.gillard@outlook.com.au>
|
||||
// Copyright (c) 2008-2010 Bjoern Hoehrmann <bjoern@hoehrmann.de> (utf8_decoder)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
|
||||
// documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
|
||||
@ -134,14 +115,15 @@
|
||||
#define TOML_ALWAYS_INLINE TOML_GCC_ATTR(__always_inline__) inline
|
||||
#define TOML_ASSUME(cond) __builtin_assume(cond)
|
||||
#define TOML_UNREACHABLE __builtin_unreachable()
|
||||
|
||||
#if __has_declspec_attribute(novtable)
|
||||
#define TOML_INTERFACE __declspec(novtable)
|
||||
#endif
|
||||
|
||||
#if __has_declspec_attribute(empty_bases)
|
||||
#define TOML_EMPTY_BASES __declspec(empty_bases)
|
||||
#endif
|
||||
#ifdef __EXCEPTIONS
|
||||
#define TOML_COMPILER_EXCEPTIONS 1
|
||||
#endif
|
||||
|
||||
//floating-point from_chars and to_chars are not implemented in any version of clang as of 1/1/2020
|
||||
#ifndef TOML_USE_STREAMS_FOR_FLOATS
|
||||
@ -161,10 +143,12 @@
|
||||
#define TOML_UNREACHABLE __assume(0)
|
||||
#define TOML_INTERFACE __declspec(novtable)
|
||||
#define TOML_EMPTY_BASES __declspec(empty_bases)
|
||||
|
||||
#if !defined(TOML_RELOPS_REORDERING) && defined(__cpp_impl_three_way_comparison)
|
||||
#define TOML_RELOPS_REORDERING 1
|
||||
#endif
|
||||
#ifdef _CPPUNWIND
|
||||
#define TOML_COMPILER_EXCEPTIONS 1
|
||||
#endif
|
||||
|
||||
#elif defined(__GNUC__)
|
||||
|
||||
@ -180,6 +164,12 @@
|
||||
#define TOML_POP_WARNINGS _Pragma("GCC diagnostic pop")
|
||||
#define TOML_ALWAYS_INLINE TOML_GCC_ATTR(__always_inline__) inline
|
||||
#define TOML_UNREACHABLE __builtin_unreachable()
|
||||
#if !defined(TOML_RELOPS_REORDERING) && defined(__cpp_impl_three_way_comparison)
|
||||
#define TOML_RELOPS_REORDERING 1
|
||||
#endif
|
||||
#ifdef __cpp_exceptions
|
||||
#define TOML_COMPILER_EXCEPTIONS 1
|
||||
#endif
|
||||
|
||||
// these pass the __has_attribute() test but cause warnings on if/else branches =/
|
||||
#define TOML_LIKELY
|
||||
@ -190,10 +180,6 @@
|
||||
#define TOML_USE_STREAMS_FOR_FLOATS 1
|
||||
#endif
|
||||
|
||||
#if !defined(TOML_RELOPS_REORDERING) && defined(__cpp_impl_three_way_comparison)
|
||||
#define TOML_RELOPS_REORDERING 1
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef TOML_CPP_VERSION
|
||||
@ -212,16 +198,19 @@
|
||||
#elif TOML_CPP_VERSION >= 201703L
|
||||
#define TOML_CPP 17
|
||||
#endif
|
||||
#if !defined(__EXCEPTIONS) && !defined(__cpp_exceptions) && !defined(_CPPUNWIND)
|
||||
#ifndef TOML_COMPILER_EXCEPTIONS
|
||||
#define TOML_COMPILER_EXCEPTIONS 0
|
||||
#endif
|
||||
#if TOML_COMPILER_EXCEPTIONS
|
||||
#ifndef TOML_EXCEPTIONS
|
||||
#define TOML_EXCEPTIONS 1
|
||||
#endif
|
||||
#else
|
||||
#if defined(TOML_EXCEPTIONS) && TOML_EXCEPTIONS
|
||||
#error TOML_EXCEPTIONS was explicitly enabled but exceptions are disabled/unsupported by the compiler.
|
||||
#endif
|
||||
#undef TOML_EXCEPTIONS
|
||||
#define TOML_EXCEPTIONS 0
|
||||
#else
|
||||
#ifndef TOML_EXCEPTIONS
|
||||
#define TOML_EXCEPTIONS 1
|
||||
#endif
|
||||
#endif
|
||||
#if TOML_EXCEPTIONS
|
||||
#define TOML_MAY_THROW
|
||||
@ -278,9 +267,6 @@
|
||||
#if !defined(TOML_UNLIKELY) && __has_cpp_attribute(unlikely)
|
||||
#define TOML_UNLIKELY [[unlikely]]
|
||||
#endif
|
||||
#if !defined(TOML_NO_UNIQUE_ADDRESS) && __has_cpp_attribute(no_unique_address)
|
||||
#define TOML_NO_UNIQUE_ADDRESS [[no_unique_address]]
|
||||
#endif
|
||||
#if __has_cpp_attribute(nodiscard) >= 201907L
|
||||
#define TOML_NODISCARD_CTOR [[nodiscard]]
|
||||
#endif
|
||||
@ -291,9 +277,6 @@
|
||||
#ifndef TOML_UNLIKELY
|
||||
#define TOML_UNLIKELY
|
||||
#endif
|
||||
#ifndef TOML_NO_UNIQUE_ADDRESS
|
||||
#define TOML_NO_UNIQUE_ADDRESS
|
||||
#endif
|
||||
#ifndef TOML_NODISCARD_CTOR
|
||||
#define TOML_NODISCARD_CTOR
|
||||
#endif
|
||||
@ -316,7 +299,7 @@
|
||||
|
||||
#define TOML_LIB_MAJOR 0
|
||||
#define TOML_LIB_MINOR 4
|
||||
#define TOML_LIB_PATCH 3
|
||||
#define TOML_LIB_PATCH 4
|
||||
|
||||
#define TOML_LANG_MAJOR 0
|
||||
#define TOML_LANG_MINOR 5
|
||||
@ -6670,14 +6653,24 @@ TOML_IMPL_START
|
||||
case U'\\': str += TOML_STRING_PREFIX('\\'); break;
|
||||
|
||||
// unicode scalar sequences
|
||||
case U'x':
|
||||
#if TOML_LANG_HIGHER_THAN(0, 5, 0)
|
||||
[[fallthrough]];
|
||||
#else
|
||||
abort_with_error("Escape sequence '\\x' is not supported "
|
||||
"in TOML 0.5.0 and earlier."sv
|
||||
);
|
||||
break;
|
||||
#endif
|
||||
case U'u': [[fallthrough]];
|
||||
case U'U':
|
||||
{
|
||||
uint32_t place_value = escaped_codepoint == U'U' ? 0x10000000u : 0x1000u;
|
||||
uint32_t place_value = escaped_codepoint == U'U' ? 0x10000000u : (escaped_codepoint == U'u' ? 0x1000u : 0x10u);
|
||||
uint32_t sequence_value{};
|
||||
while (place_value)
|
||||
{
|
||||
eof_check();
|
||||
TOML_ERROR_CHECK({});
|
||||
|
||||
if (!is_hexadecimal_digit(*cp))
|
||||
abort_with_error(
|
||||
@ -6723,7 +6716,6 @@ TOML_IMPL_START
|
||||
str += static_cast<string_char>(0x80u | ((sequence_value >> 6) & 0x3Fu));
|
||||
str += static_cast<string_char>(0x80u | (sequence_value & 0x3Fu));
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@ -9221,7 +9213,6 @@ TOML_END
|
||||
#undef TOML_CONSTEVAL
|
||||
#undef TOML_LIKELY
|
||||
#undef TOML_UNLIKELY
|
||||
#undef TOML_NO_UNIQUE_ADDRESS
|
||||
#undef TOML_NODISCARD_CTOR
|
||||
#undef TOML_MAKE_VERSION
|
||||
#undef TOML_LANG_EFFECTIVE_VERSION
|
||||
@ -9248,6 +9239,7 @@ TOML_END
|
||||
#undef TOML_ALL_INLINE
|
||||
#undef TOML_IMPLEMENTATION
|
||||
#undef TOML_INLINE_FUNC_IMPL
|
||||
#undef TOML_COMPILER_EXCEPTIONS
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
|
Loading…
Reference in New Issue
Block a user