added trivial abi attribute to date, time, time_offset
also: - included <cassert> directly in 'debug' builds when TOML_ASSERT isn't defined - minor preprocessor cleanup - minor documentation fixes
This commit is contained in:
parent
60853e27db
commit
b2f36e38f1
@ -83,6 +83,7 @@
|
||||
#undef TOML_INLINE_FUNC_IMPL
|
||||
#undef TOML_COMPILER_EXCEPTIONS
|
||||
#undef TOML_LAUNDER
|
||||
#undef TOML_TRIVIAL_ABI
|
||||
#endif
|
||||
|
||||
/// \mainpage toml++
|
||||
|
@ -40,18 +40,12 @@
|
||||
#define TOML_LARGE_FILES 0
|
||||
#endif
|
||||
|
||||
#ifndef TOML_ASSERT
|
||||
#ifdef assert
|
||||
#define TOML_ASSERT(expr) assert(expr)
|
||||
#else
|
||||
#define TOML_ASSERT(expr) (void)0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef TOML_UNDEF_MACROS
|
||||
#define TOML_UNDEF_MACROS 1
|
||||
#endif
|
||||
|
||||
//TOML_ASSERT
|
||||
|
||||
////////// COMPILER & ENVIRONMENT STUFF
|
||||
|
||||
#ifndef __cplusplus
|
||||
@ -66,8 +60,9 @@
|
||||
#define TOML_POP_WARNINGS _Pragma("clang diagnostic pop")
|
||||
#define TOML_ASSUME(cond) __builtin_assume(cond)
|
||||
#define TOML_UNREACHABLE __builtin_unreachable()
|
||||
#define TOML_GNU_ATTR(attr) __attribute__((attr))
|
||||
#if defined(_MSC_VER) // msvc compat mode
|
||||
#if defined(__has_declspec_attribute)
|
||||
#ifdef __has_declspec_attribute
|
||||
#if __has_declspec_attribute(novtable)
|
||||
#define TOML_INTERFACE __declspec(novtable)
|
||||
#endif
|
||||
@ -76,12 +71,13 @@
|
||||
#endif
|
||||
#define TOML_ALWAYS_INLINE __forceinline
|
||||
#endif
|
||||
#else // regular ol' clang
|
||||
#define TOML_GNU_ATTR(attr) __attribute__((attr))
|
||||
#ifdef __has_attribute
|
||||
#if __has_attribute(always_inline)
|
||||
#define TOML_ALWAYS_INLINE __attribute__((__always_inline__)) inline
|
||||
#endif
|
||||
#endif
|
||||
#ifdef __has_attribute
|
||||
#if !defined(TOML_ALWAYS_INLINE) && __has_attribute(always_inline)
|
||||
#define TOML_ALWAYS_INLINE __attribute__((__always_inline__)) inline
|
||||
#endif
|
||||
#if !defined(TOML_TRIVIAL_ABI) && __has_attribute(trivial_abi)
|
||||
#define TOML_TRIVIAL_ABI __attribute__((__trivial_abi__))
|
||||
#endif
|
||||
#endif
|
||||
#ifdef __EXCEPTIONS
|
||||
@ -244,6 +240,9 @@
|
||||
#ifndef TOML_UNLIKELY
|
||||
#define TOML_UNLIKELY
|
||||
#endif
|
||||
#ifndef TOML_TRIVIAL_ABI
|
||||
#define TOML_TRIVIAL_ABI
|
||||
#endif
|
||||
#ifndef TOML_NODISCARD_CTOR
|
||||
#define TOML_NODISCARD_CTOR
|
||||
#endif
|
||||
@ -338,6 +337,14 @@ TOML_DISABLE_ALL_WARNINGS
|
||||
#include <map>
|
||||
#include <iosfwd>
|
||||
#include <charconv>
|
||||
#ifndef TOML_ASSERT
|
||||
#if !defined(NDEBUG) || defined(_DEBUG) || defined(DEBUG)
|
||||
#include <cassert>
|
||||
#define TOML_ASSERT(expr) assert(expr)
|
||||
#else
|
||||
#define TOML_ASSERT(expr) (void)0
|
||||
#endif
|
||||
#endif
|
||||
#ifndef TOML_OPTIONAL_TYPE
|
||||
#include <optional>
|
||||
#endif
|
||||
|
@ -8,7 +8,7 @@
|
||||
TOML_START
|
||||
{
|
||||
/// \brief A local date.
|
||||
struct date final
|
||||
struct TOML_TRIVIAL_ABI date final
|
||||
{
|
||||
/// \brief The year component.
|
||||
uint16_t year;
|
||||
@ -92,7 +92,7 @@ TOML_START
|
||||
}
|
||||
|
||||
/// \brief A local time-of-day.
|
||||
struct time final
|
||||
struct TOML_TRIVIAL_ABI time final
|
||||
{
|
||||
/// \brief The hour component, from 0 - 23.
|
||||
uint8_t hour;
|
||||
@ -180,7 +180,7 @@ TOML_START
|
||||
}
|
||||
|
||||
/// \brief A timezone offset.
|
||||
struct time_offset final
|
||||
struct TOML_TRIVIAL_ABI time_offset final
|
||||
{
|
||||
/// \brief Offset from UTC+0, in minutes.
|
||||
int16_t minutes;
|
||||
|
@ -484,10 +484,9 @@ TOML_START
|
||||
|
||||
/// \brief Gets a raw reference to a value node's underlying data.
|
||||
///
|
||||
/// \warning This function is dangerous if used carelessly and **WILL** break your code if the chosen value type
|
||||
/// doesn't match the node's actual type. If you provide a definition for `TOML_ASSERT`
|
||||
/// (explicitly or indirectly by including `<cassert>`) an assertion will fire when
|
||||
/// invalid accesses are attempted: \cpp
|
||||
/// \warning This function is dangerous if used carelessly and **WILL** break your code if the
|
||||
/// chosen value type doesn't match the node's actual type. In debug builds an assertion
|
||||
/// will fire when invalid accesses are attempted: \cpp
|
||||
///
|
||||
/// auto tbl = toml::parse(R"(
|
||||
///
|
||||
|
@ -217,8 +217,7 @@ TOML_START
|
||||
///
|
||||
/// \warning This function is dangerous if used carelessly and **WILL** break your code if the
|
||||
/// node_view didn't reference a node, or the chosen value type doesn't match the node's
|
||||
/// actual type. If you provide a definition for TOML_ASSERT (explicitly or indirectly
|
||||
/// by including `<cassert>`) an assertion will fire when invalid accesses are attempted: \cpp
|
||||
/// actual type. In debug builds an assertion will fire when invalid accesses are attempted: \cpp
|
||||
///
|
||||
/// auto tbl = toml::parse(R"(
|
||||
///
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
#define TOML_LIB_MAJOR 0
|
||||
#define TOML_LIB_MINOR 5
|
||||
#define TOML_LIB_PATCH 1
|
||||
#define TOML_LIB_PATCH 2
|
||||
|
||||
#define TOML_LANG_MAJOR 0
|
||||
#define TOML_LANG_MINOR 5
|
||||
|
@ -1,7 +1,7 @@
|
||||
project(
|
||||
'tomlplusplus',
|
||||
'cpp',
|
||||
version : '0.5.1',
|
||||
version : '0.5.2',
|
||||
license : 'MIT',
|
||||
default_options : [
|
||||
'cpp_std=c++17',
|
||||
|
@ -25,21 +25,7 @@ inline_namespaces = [
|
||||
inline_namespace_explainer = 'All members of this namespace are automatically members of the parent namespace. ' \
|
||||
+ 'It does not require an explicit \'using\' statement.'
|
||||
type_names = [
|
||||
'table',
|
||||
'array',
|
||||
'value',
|
||||
'date',
|
||||
'time',
|
||||
'date_time',
|
||||
'time_offset',
|
||||
'string',
|
||||
'string_view',
|
||||
'string_char',
|
||||
'parse_result',
|
||||
'parse_error',
|
||||
'json_formatter',
|
||||
'default_formatter',
|
||||
'format_flags',
|
||||
#------ standard types
|
||||
'size_t',
|
||||
'uint8_t',
|
||||
'uint16_t',
|
||||
@ -71,7 +57,24 @@ type_names = [
|
||||
'ofstream',
|
||||
'stringstream',
|
||||
'istringstream',
|
||||
'ostringstream'
|
||||
'ostringstream',
|
||||
'string_view',
|
||||
'string',
|
||||
'byte',
|
||||
#------ toml++ types
|
||||
'table',
|
||||
'array',
|
||||
'value',
|
||||
'date',
|
||||
'time',
|
||||
'date_time',
|
||||
'time_offset',
|
||||
'string_char',
|
||||
'parse_result',
|
||||
'parse_error',
|
||||
'json_formatter',
|
||||
'default_formatter',
|
||||
'format_flags'
|
||||
]
|
||||
all_namespaces = [
|
||||
'std',
|
||||
@ -657,16 +660,13 @@ class ExtDocLinksFix(object):
|
||||
(r'std::(?:basic_|w)?ostringstreams?', 'https://en.cppreference.com/w/cpp/io/basic_ostringstream'),
|
||||
(r'std::(?:basic_|w)?stringstreams?', 'https://en.cppreference.com/w/cpp/io/basic_stringstream'),
|
||||
(r'std::(?:basic_|w|u8)?string_views?', 'https://en.cppreference.com/w/cpp/string/basic_string_view'),
|
||||
(r'std::(?:basic_|w|u8)?strings?', 'https://en.cppreference.com/w/cpp/string/basic_string'),
|
||||
|
||||
(r'std::(?:basic_|w|u8)?strings?', 'https://en.cppreference.com/w/cpp/string/basic_string'),
|
||||
(r'\s(?:<|<)fstream(?:>|>)', 'https://en.cppreference.com/w/cpp/header/fstream'),
|
||||
(r'\s(?:<|<)sstream(?:>|>)', 'https://en.cppreference.com/w/cpp/header/sstream'),
|
||||
(r'\s(?:<|<)iostream(?:>|>)', 'https://en.cppreference.com/w/cpp/header/iostream'),
|
||||
(r'\s(?:<|<)iosfwd(?:>|>)', 'https://en.cppreference.com/w/cpp/header/iosfwd'),
|
||||
(r'\s(?:<|<)string(?:>|>)', 'https://en.cppreference.com/w/cpp/header/string'),
|
||||
(r'\s(?:<|<)string_view(?:>|>)', 'https://en.cppreference.com/w/cpp/header/string_view'),
|
||||
|
||||
|
||||
(r'char(?:8|16|32)_ts?', 'https://en.cppreference.com/w/cpp/language/types'),
|
||||
(r'std::is_(?:nothrow_)?convertible(?:_v)?', 'https://en.cppreference.com/w/cpp/types/is_convertible'),
|
||||
(r'std::is_same(?:_v)?', 'https://en.cppreference.com/w/cpp/types/is_same'),
|
||||
@ -683,8 +683,15 @@ class ExtDocLinksFix(object):
|
||||
(r'std::add_[lr]value_reference(?:_t)?', 'https://en.cppreference.com/w/cpp/types/add_reference'),
|
||||
(r'std::remove_reference(?:_t)?', 'https://en.cppreference.com/w/cpp/types/remove_reference'),
|
||||
(r'std::remove_cv(?:_t)?', 'https://en.cppreference.com/w/cpp/types/remove_cv'),
|
||||
(r'std::underlying_type(?:_t)?', 'https://en.cppreference.com/w/cpp/types/underlying_type'),
|
||||
(r'std::exceptions?', 'https://en.cppreference.com/w/cpp/error/exception'),
|
||||
(r'std::runtime_errors?', 'https://en.cppreference.com/w/cpp/error/runtime_error'),
|
||||
(r'std::is_constant_evaluated', 'https://en.cppreference.com/w/cpp/types/is_constant_evaluated'),
|
||||
(r'std::launder', 'https://en.cppreference.com/w/cpp/utility/launder'),
|
||||
(r'std::bit_width', 'https://en.cppreference.com/w/cpp/numeric/bit_width'),
|
||||
(r'std::bit_ceil', 'https://en.cppreference.com/w/cpp/numeric/bit_ceil'),
|
||||
(r'std::bit_floor', 'https://en.cppreference.com/w/cpp/numeric/bit_floor'),
|
||||
(r'std::bit_cast', 'https://en.cppreference.com/w/cpp/numeric/bit_cast'),
|
||||
(r'std::initializer_lists?', 'https://en.cppreference.com/w/cpp/utility/initializer_list'),
|
||||
(
|
||||
r'(?:L?P)?(?:'
|
||||
@ -704,7 +711,15 @@ class ExtDocLinksFix(object):
|
||||
(r'(?:Legacy)?BidirectionalIterators?', 'https://en.cppreference.com/w/cpp/named_req/BidirectionalIterator'),
|
||||
(r'(?:Legacy)?RandomAccessIterators?', 'https://en.cppreference.com/w/cpp/named_req/RandomAccessIterator'),
|
||||
(r'(?:Legacy)?ContiguousIterators?', 'https://en.cppreference.com/w/cpp/named_req/ContiguousIterator'),
|
||||
#(r'(?:Legacy)?Iterators?', 'https://en.cppreference.com/w/cpp/named_req/Iterator'),
|
||||
(
|
||||
r'(?:'
|
||||
+ r'__cplusplus|__STDC_HOSTED__'
|
||||
+ r'|__FILE__|__LINE__'
|
||||
+ r'|__DATE__|__TIME__'
|
||||
+ r'|__STDCPP_DEFAULT_NEW_ALIGNMENT__'
|
||||
+ r')',
|
||||
'https://en.cppreference.com/w/cpp/preprocessor/replace'
|
||||
),
|
||||
# toml-specific
|
||||
(r'toml::values?', 'classtoml_1_1value.html'),
|
||||
(r'(toml::)?date_times?', 'structtoml_1_1date__time.html'),
|
||||
|
@ -6,10 +6,10 @@
|
||||
#endif
|
||||
#define TOML_OPTIONAL_TYPE tl::optional
|
||||
#endif
|
||||
|
||||
#include <cassert> //so TOML_ASSERT() maps to assert()
|
||||
#define TOML_ALL_INLINE 0
|
||||
#define TOML_IMPLEMENTATION
|
||||
#if !defined(_MSC_VER) || !defined(_M_IX86)
|
||||
#define TOML_ALL_INLINE 0
|
||||
#define TOML_IMPLEMENTATION
|
||||
#endif
|
||||
#include "../include/toml++/toml.h"
|
||||
|
||||
#define CATCH_CONFIG_RUNNER
|
||||
|
@ -9,9 +9,10 @@
|
||||
#endif
|
||||
#include "catch2.h"
|
||||
#include <sstream>
|
||||
#include <cassert> //so TOML_ASSERT() maps to assert()
|
||||
#define TOML_UNDEF_MACROS 0
|
||||
#define TOML_ALL_INLINE 0
|
||||
#if !defined(_MSC_VER) || !defined(_M_IX86)
|
||||
#define TOML_ALL_INLINE 0
|
||||
#endif
|
||||
#include "../include/toml++/toml.h"
|
||||
|
||||
#if TOML_COMPILER_EXCEPTIONS
|
||||
|
48
toml.hpp
48
toml.hpp
@ -1,6 +1,6 @@
|
||||
//----------------------------------------------------------------------------------------------------------------------
|
||||
//
|
||||
// toml++ v0.5.1
|
||||
// toml++ v0.5.2
|
||||
// https://github.com/marzer/tomlplusplus
|
||||
// SPDX-License-Identifier: MIT
|
||||
//
|
||||
@ -83,18 +83,12 @@
|
||||
#define TOML_LARGE_FILES 0
|
||||
#endif
|
||||
|
||||
#ifndef TOML_ASSERT
|
||||
#ifdef assert
|
||||
#define TOML_ASSERT(expr) assert(expr)
|
||||
#else
|
||||
#define TOML_ASSERT(expr) (void)0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef TOML_UNDEF_MACROS
|
||||
#define TOML_UNDEF_MACROS 1
|
||||
#endif
|
||||
|
||||
//TOML_ASSERT
|
||||
|
||||
#ifndef __cplusplus
|
||||
#error toml++ is a C++ library.
|
||||
#endif
|
||||
@ -107,8 +101,9 @@
|
||||
#define TOML_POP_WARNINGS _Pragma("clang diagnostic pop")
|
||||
#define TOML_ASSUME(cond) __builtin_assume(cond)
|
||||
#define TOML_UNREACHABLE __builtin_unreachable()
|
||||
#define TOML_GNU_ATTR(attr) __attribute__((attr))
|
||||
#if defined(_MSC_VER) // msvc compat mode
|
||||
#if defined(__has_declspec_attribute)
|
||||
#ifdef __has_declspec_attribute
|
||||
#if __has_declspec_attribute(novtable)
|
||||
#define TOML_INTERFACE __declspec(novtable)
|
||||
#endif
|
||||
@ -117,12 +112,13 @@
|
||||
#endif
|
||||
#define TOML_ALWAYS_INLINE __forceinline
|
||||
#endif
|
||||
#else // regular ol' clang
|
||||
#define TOML_GNU_ATTR(attr) __attribute__((attr))
|
||||
#ifdef __has_attribute
|
||||
#if __has_attribute(always_inline)
|
||||
#define TOML_ALWAYS_INLINE __attribute__((__always_inline__)) inline
|
||||
#endif
|
||||
#endif
|
||||
#ifdef __has_attribute
|
||||
#if !defined(TOML_ALWAYS_INLINE) && __has_attribute(always_inline)
|
||||
#define TOML_ALWAYS_INLINE __attribute__((__always_inline__)) inline
|
||||
#endif
|
||||
#if !defined(TOML_TRIVIAL_ABI) && __has_attribute(trivial_abi)
|
||||
#define TOML_TRIVIAL_ABI __attribute__((__trivial_abi__))
|
||||
#endif
|
||||
#endif
|
||||
#ifdef __EXCEPTIONS
|
||||
@ -285,6 +281,9 @@
|
||||
#ifndef TOML_UNLIKELY
|
||||
#define TOML_UNLIKELY
|
||||
#endif
|
||||
#ifndef TOML_TRIVIAL_ABI
|
||||
#define TOML_TRIVIAL_ABI
|
||||
#endif
|
||||
#ifndef TOML_NODISCARD_CTOR
|
||||
#define TOML_NODISCARD_CTOR
|
||||
#endif
|
||||
@ -307,7 +306,7 @@
|
||||
|
||||
#define TOML_LIB_MAJOR 0
|
||||
#define TOML_LIB_MINOR 5
|
||||
#define TOML_LIB_PATCH 1
|
||||
#define TOML_LIB_PATCH 2
|
||||
|
||||
#define TOML_LANG_MAJOR 0
|
||||
#define TOML_LANG_MINOR 5
|
||||
@ -383,6 +382,14 @@ TOML_DISABLE_ALL_WARNINGS
|
||||
#include <map>
|
||||
#include <iosfwd>
|
||||
#include <charconv>
|
||||
#ifndef TOML_ASSERT
|
||||
#if !defined(NDEBUG) || defined(_DEBUG) || defined(DEBUG)
|
||||
#include <cassert>
|
||||
#define TOML_ASSERT(expr) assert(expr)
|
||||
#else
|
||||
#define TOML_ASSERT(expr) (void)0
|
||||
#endif
|
||||
#endif
|
||||
#ifndef TOML_OPTIONAL_TYPE
|
||||
#include <optional>
|
||||
#endif
|
||||
@ -909,7 +916,7 @@ TOML_END
|
||||
|
||||
TOML_START
|
||||
{
|
||||
struct date final
|
||||
struct TOML_TRIVIAL_ABI date final
|
||||
{
|
||||
uint16_t year;
|
||||
uint8_t month;
|
||||
@ -975,7 +982,7 @@ TOML_START
|
||||
return lhs;
|
||||
}
|
||||
|
||||
struct time final
|
||||
struct TOML_TRIVIAL_ABI time final
|
||||
{
|
||||
uint8_t hour;
|
||||
uint8_t minute;
|
||||
@ -1042,7 +1049,7 @@ TOML_START
|
||||
return lhs;
|
||||
}
|
||||
|
||||
struct time_offset final
|
||||
struct TOML_TRIVIAL_ABI time_offset final
|
||||
{
|
||||
int16_t minutes;
|
||||
|
||||
@ -9212,6 +9219,7 @@ TOML_END
|
||||
#undef TOML_INLINE_FUNC_IMPL
|
||||
#undef TOML_COMPILER_EXCEPTIONS
|
||||
#undef TOML_LAUNDER
|
||||
#undef TOML_TRIVIAL_ABI
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
|
@ -17,7 +17,6 @@
|
||||
<ClCompile>
|
||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||
<ControlFlowGuard>false</ControlFlowGuard>
|
||||
<RuntimeTypeInfo>false</RuntimeTypeInfo> <!-- /GR- -->
|
||||
<FloatingPointExceptions>false</FloatingPointExceptions> <!-- /fp:except- -->
|
||||
<ExceptionHandling>Sync</ExceptionHandling> <!-- /EHsc -->
|
||||
<ConformanceMode>true</ConformanceMode> <!-- /permissive- -->
|
||||
@ -33,7 +32,6 @@
|
||||
<AdditionalOptions>%(AdditionalOptions) /utf-8 /volatile:iso /Zc:__cplusplus /bigobj /Zc:inline /Zc:throwingNew</AdditionalOptions>
|
||||
<PreprocessorDefinitions>%(PreprocessorDefinitions);_CONSOLE</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>%(PreprocessorDefinitions);_ITERATOR_DEBUG_LEVEL=0</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>%(PreprocessorDefinitions);_ITERATOR_DEBUG_LEVEL=0</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>%(PreprocessorDefinitions);_WINSOCK_DEPRECATED_NO_WARNINGS</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>%(PreprocessorDefinitions);_SCL_SECURE_NO_WARNINGS</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS</PreprocessorDefinitions>
|
||||
|
@ -93,6 +93,7 @@
|
||||
<None Include="..\python\generate_unicode_functions.py" />
|
||||
<None Include="..\README.md" />
|
||||
<None Include="..\tests\meson.build" />
|
||||
<None Include="toml++.props" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
</Project>
|
@ -100,6 +100,7 @@
|
||||
<None Include="..\tests\meson.build">
|
||||
<Filter>tests</Filter>
|
||||
</None>
|
||||
<None Include="toml++.props" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Filter Include="include">
|
||||
|
Loading…
Reference in New Issue
Block a user