aboutsummaryrefslogtreecommitdiff
path: root/include/jsoncons/config
diff options
context:
space:
mode:
authorRichard <q@1bpm.net>2022-09-04 00:32:56 +0100
committerRichard <q@1bpm.net>2022-09-04 00:32:56 +0100
commit1d055261b4144dbf86b2658437015b15d4dd9bff (patch)
tree6049b19d1bf953a650383de1a5e438b8b82679f6 /include/jsoncons/config
downloadcsound-json-1d055261b4144dbf86b2658437015b15d4dd9bff.tar.gz
csound-json-1d055261b4144dbf86b2658437015b15d4dd9bff.tar.bz2
csound-json-1d055261b4144dbf86b2658437015b15d4dd9bff.zip
initial
Diffstat (limited to 'include/jsoncons/config')
-rw-r--r--include/jsoncons/config/binary_config.hpp226
-rw-r--r--include/jsoncons/config/compiler_support.hpp389
-rw-r--r--include/jsoncons/config/jsoncons_config.hpp308
-rw-r--r--include/jsoncons/config/version.hpp40
4 files changed, 963 insertions, 0 deletions
diff --git a/include/jsoncons/config/binary_config.hpp b/include/jsoncons/config/binary_config.hpp
new file mode 100644
index 0000000..51b52a8
--- /dev/null
+++ b/include/jsoncons/config/binary_config.hpp
@@ -0,0 +1,226 @@
+// Copyright 2017 Daniel Parker
+// Distributed under the Boost license, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// See https://github.com/danielaparker/jsoncons for latest version
+
+#ifndef JSONCONS_CONFIG_BINARY_CONFIG_HPP
+#define JSONCONS_CONFIG_BINARY_CONFIG_HPP
+
+#include <cfloat>
+#include <cstddef>
+#include <cstdint>
+#include <cstring> // std::memcpy
+#include <memory>
+#include <type_traits> // std::enable_if
+
+// The definitions below follow the definitions in compiler_support_p.h, https://github.com/01org/tinycbor
+// MIT license
+
+#ifdef __F16C__
+# include <immintrin.h>
+#endif
+
+#ifndef __has_builtin
+# define __has_builtin(x) 0
+#endif
+
+#if defined(__GNUC__)
+#if (__GNUC__ * 100 + __GNUC_MINOR__ >= 403) || (__has_builtin(__builtin_bswap64) && __has_builtin(__builtin_bswap32))
+# define JSONCONS_BYTE_SWAP_64 __builtin_bswap64
+# define JSONCONS_BYTE_SWAP_32 __builtin_bswap32
+# ifdef __INTEL_COMPILER
+# define JSONCONS_BYTE_SWAP_16 _bswap16
+# elif (__GNUC__ * 100 + __GNUC_MINOR__ >= 608) || __has_builtin(__builtin_bswap16)
+# define JSONCONS_BYTE_SWAP_16 __builtin_bswap16
+# endif
+#endif
+#elif defined(__sun)
+# include <sys/byteorder.h>
+#elif defined(_MSC_VER)
+// MSVC, which implies sizeof(long) == 4
+# define JSONCONS_BYTE_SWAP_64 _byteswap_uint64
+# define JSONCONS_BYTE_SWAP_32 _byteswap_ulong
+# define JSONCONS_BYTE_SWAP_16 _byteswap_ushort
+#endif
+
+namespace jsoncons {
+namespace binary {
+
+ struct uint128_holder
+ {
+ uint64_t lo;
+ uint64_t hi;
+ };
+
+ static inline bool add_check_overflow(std::size_t v1, std::size_t v2, std::size_t *r)
+ {
+ #if ((defined(__GNUC__) && (__GNUC__ >= 5)) && !defined(__INTEL_COMPILER)) || __has_builtin(__builtin_add_overflow)
+ return __builtin_add_overflow(v1, v2, r);
+ #else
+ // unsigned additions are well-defined
+ *r = v1 + v2;
+ return v1 > v1 + v2;
+ #endif
+ }
+
+ #if defined(__apple_build_version__) && ((__clang_major__ < 8) || ((__clang_major__ == 8) && (__clang_minor__ < 1)))
+ #define APPLE_MISSING_INTRINSICS 1
+ #endif
+
+ inline
+ uint16_t encode_half(double val)
+ {
+ #if defined(__F16C__) && !defined(APPLE_MISSING_INTRINSICS)
+ return _cvtss_sh((float)val, 3);
+ #else
+ uint64_t v;
+ std::memcpy(&v, &val, sizeof(v));
+ int64_t sign = static_cast<int64_t>(v >> 63 << 15);
+ int64_t exp = (v >> 52) & 0x7ff;
+ int64_t mant = v << 12 >> 12 >> (53-11); /* keep only the 11 most significant bits of the mantissa */
+ exp -= 1023;
+ if (exp == 1024) {
+ /* infinity or NaN */
+ exp = 16;
+ mant >>= 1;
+ } else if (exp >= 16) {
+ /* overflow, as largest number */
+ exp = 15;
+ mant = 1023;
+ } else if (exp >= -14) {
+ /* regular normal */
+ } else if (exp >= -24) {
+ /* subnormal */
+ mant |= 1024;
+ mant >>= -(exp + 14);
+ exp = -15;
+ } else {
+ /* underflow, make zero */
+ return 0;
+ }
+
+ /* safe cast here as bit operations above guarantee not to overflow */
+ return static_cast<uint16_t>(sign | ((exp + 15) << 10) | mant);
+ #endif
+ }
+
+ /* this function was copied & adapted from RFC 7049 Appendix D */
+ inline
+ double decode_half(uint16_t half)
+ {
+ #if defined(__F16C__) && !defined(APPLE_MISSING_INTRINSICS)
+ return _cvtsh_ss(half);
+ #else
+ int64_t exp = (half >> 10) & 0x1f;
+ int64_t mant = half & 0x3ff;
+ double val;
+ if (exp == 0)
+ {
+ val = ldexp(static_cast<double>(mant), -24);
+ }
+ else if (exp != 31)
+ {
+ val = ldexp(static_cast<double>(mant) + 1024.0, static_cast<int>(exp - 25));
+ }
+ else
+ {
+ val = mant == 0 ? std::numeric_limits<double>::infinity() : std::nan("");
+ }
+ return half & 0x8000 ? -val : val;
+ #endif
+ }
+
+ // byte_swap
+
+ template<class T>
+ typename std::enable_if<std::is_integral<T>::value && sizeof(T) == sizeof(uint8_t),T>::type
+ byte_swap(T val)
+ {
+ return val;
+ }
+
+ template<class T>
+ typename std::enable_if<std::is_integral<T>::value && sizeof(T) == sizeof(uint16_t),T>::type
+ byte_swap(T val)
+ {
+ #if defined(JSONCONS_BYTE_SWAP_16)
+ return JSONCONS_BYTE_SWAP_16(val);
+ #else
+ return (static_cast<uint16_t>(val) >> 8) | (static_cast<uint16_t>(val) << 8);
+ #endif
+ }
+
+ template<class T>
+ typename std::enable_if<std::is_integral<T>::value && sizeof(T) == sizeof(uint32_t),T>::type
+ byte_swap(T val)
+ {
+ #if defined(JSONCONS_BYTE_SWAP_32)
+ return JSONCONS_BYTE_SWAP_32(val);
+ #else
+ uint32_t tmp = ((static_cast<uint32_t>(val) << 8) & 0xff00ff00) | ((static_cast<uint32_t>(val) >> 8) & 0xff00ff);
+ return (tmp << 16) | (tmp >> 16);
+ #endif
+ }
+
+ template<class T>
+ typename std::enable_if<std::is_integral<T>::value && sizeof(T) == sizeof(uint64_t),T>::type
+ byte_swap(T val)
+ {
+ #if defined(JSONCONS_BYTE_SWAP_64)
+ return JSONCONS_BYTE_SWAP_64(val);
+ #else
+ uint64_t tmp = ((static_cast<uint64_t>(val) & 0x00000000ffffffffull) << 32) | ((static_cast<uint64_t>(val) & 0xffffffff00000000ull) >> 32);
+ tmp = ((tmp & 0x0000ffff0000ffffull) << 16) | ((tmp & 0xffff0000ffff0000ull) >> 16);
+ return ((tmp & 0x00ff00ff00ff00ffull) << 8) | ((tmp & 0xff00ff00ff00ff00ull) >> 8);
+ #endif
+ }
+
+ template<class T>
+ typename std::enable_if<std::is_floating_point<T>::value && sizeof(T) == sizeof(uint32_t),T>::type
+ byte_swap(T val)
+ {
+ uint32_t x;
+ std::memcpy(&x,&val,sizeof(uint32_t));
+ uint32_t y = byte_swap(x);
+ T val2;
+ std::memcpy(&val2,&y,sizeof(uint32_t));
+ return val2;
+ }
+
+ template<class T>
+ typename std::enable_if<std::is_floating_point<T>::value && sizeof(T) == sizeof(uint64_t),T>::type
+ byte_swap(T val)
+ {
+ uint64_t x;
+ std::memcpy(&x,&val,sizeof(uint64_t));
+ uint64_t y = byte_swap(x);
+ T val2;
+ std::memcpy(&val2,&y,sizeof(uint64_t));
+ return val2;
+ }
+
+ template<class T>
+ typename std::enable_if<std::is_floating_point<T>::value && sizeof(T) == 2*sizeof(uint64_t),T>::type
+ byte_swap(T val)
+ {
+ uint128_holder x;
+ uint8_t buf[2*sizeof(uint64_t)];
+ std::memcpy(buf,&val,2*sizeof(uint64_t));
+ std::memcpy(&x.lo,buf,sizeof(uint64_t));
+ std::memcpy(&x.hi,buf+sizeof(uint64_t),sizeof(uint64_t));
+
+ uint128_holder y;
+ y.lo = byte_swap(x.hi);
+ y.hi = byte_swap(x.lo);
+
+ T val2;
+ std::memcpy(&val2,&y,2*sizeof(uint64_t));
+
+ return val2;
+ }
+
+} // binary
+} // jsoncons
+
+#endif
diff --git a/include/jsoncons/config/compiler_support.hpp b/include/jsoncons/config/compiler_support.hpp
new file mode 100644
index 0000000..15d30cf
--- /dev/null
+++ b/include/jsoncons/config/compiler_support.hpp
@@ -0,0 +1,389 @@
+// Copyright 2013 Daniel Parker
+// Distributed under the Boost license, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// See https://github.com/danielaparker/jsoncons for latest version
+
+#ifndef JSONCONS_COMPILER_SUPPORT_HPP
+#define JSONCONS_COMPILER_SUPPORT_HPP
+
+#include <stdexcept>
+#include <string>
+#include <cmath>
+#include <exception>
+#include <ostream>
+
+#if defined (__clang__)
+#define JSONCONS_CLANG_VERSION (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__)
+#endif
+
+// Uncomment the following line to suppress deprecated names (recommended for new code)
+//#define JSONCONS_NO_DEPRECATED
+
+// The definitions below follow the definitions in compiler_support_p.h, https://github.com/01org/tinycbor
+// MIT license
+
+// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54577
+#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 9
+#define JSONCONS_NO_VECTOR_ERASE_TAKES_CONST_ITERATOR 1
+#define JSONCONS_NO_MAP_CONS_TAKES_ALLOCATOR 1
+#endif
+
+#if defined(__clang__)
+# define JSONCONS_FALLTHROUGH [[clang::fallthrough]]
+#elif defined(__GNUC__) && ((__GNUC__ >= 7))
+# define JSONCONS_FALLTHROUGH __attribute__((fallthrough))
+#elif defined (__GNUC__)
+# define JSONCONS_FALLTHROUGH // FALLTHRU
+#else
+# define JSONCONS_FALLTHROUGH
+#endif
+
+#if defined(__GNUC__) || defined(__clang__)
+#define JSONCONS_LIKELY(x) __builtin_expect(!!(x), 1)
+#define JSONCONS_UNLIKELY(x) __builtin_expect(!!(x), 0)
+#define JSONCONS_UNREACHABLE() __builtin_unreachable()
+#elif defined(_MSC_VER)
+#define JSONCONS_LIKELY(x) x
+#define JSONCONS_UNLIKELY(x) x
+#define JSONCONS_UNREACHABLE() __assume(0)
+#else
+#define JSONCONS_LIKELY(x) x
+#define JSONCONS_UNLIKELY(x) x
+#define JSONCONS_UNREACHABLE() do {} while (0)
+#endif
+
+// Deprecated symbols markup
+#if (defined(__cplusplus) && __cplusplus >= 201402L)
+#define JSONCONS_DEPRECATED_MSG(msg) [[deprecated(msg)]]
+#endif
+
+#if !defined(JSONCONS_DEPRECATED_MSG) && defined(__GNUC__) && defined(__has_extension)
+#if __has_extension(attribute_deprecated_with_message)
+#define JSONCONS_DEPRECATED_MSG(msg) __attribute__((deprecated(msg)))
+#endif
+#endif
+
+#if !defined(JSONCONS_DEPRECATED_MSG) && defined(_MSC_VER)
+#if (_MSC_VER) >= 1920
+#define JSONCONS_DEPRECATED_MSG(msg) [[deprecated(msg)]]
+#else
+#define JSONCONS_DEPRECATED_MSG(msg) __declspec(deprecated(msg))
+#endif
+#endif
+
+// Following boost/atomic/detail/config.hpp
+#if !defined(JSONCONS_DEPRECATED_MSG) && (\
+ (defined(__GNUC__) && ((__GNUC__ + 0) * 100 + (__GNUC_MINOR__ + 0)) >= 405) ||\
+ (defined(__SUNPRO_CC) && (__SUNPRO_CC + 0) >= 0x5130))
+ #define JSONCONS_DEPRECATED_MSG(msg) __attribute__((deprecated(msg)))
+#endif
+
+#if !defined(JSONCONS_DEPRECATED_MSG) && defined(__clang__) && defined(__has_extension)
+ #if __has_extension(attribute_deprecated_with_message)
+ #define JSONCONS_DEPRECATED_MSG(msg) __attribute__((deprecated(msg)))
+ #else
+ #define JSONCONS_DEPRECATED_MSG(msg) __attribute__((deprecated))
+ #endif
+#endif
+
+#if !defined(JSONCONS_DEPRECATED_MSG)
+#define JSONCONS_DEPRECATED_MSG(msg)
+#endif
+
+#if defined(ANDROID) || defined(__ANDROID__)
+#if __ANDROID_API__ >= 21
+#define JSONCONS_HAS_STRTOLD_L
+#else
+#define JSONCONS_NO_LOCALECONV
+#endif
+#endif
+
+#if defined(_MSC_VER)
+#define JSONCONS_HAS_MSC_STRTOD_L
+#define JSONCONS_HAS_FOPEN_S
+#endif
+
+#ifndef JSONCONS_HAS_CP14
+ #if defined(_MSVC_LANG)
+ #if _MSVC_LANG >= 201402L
+ #define JSONCONS_HAS_CP14
+ #endif
+ #elif __cplusplus >= 201402L
+ #define JSONCONS_HAS_CP14
+ #endif
+#endif
+
+#if !defined(JSONCONS_HAS_STD_FROM_CHARS)
+# if defined(__GNUC__)
+# if (__GNUC__ >= 11)
+# if (__cplusplus >= 201703)
+# define JSONCONS_HAS_STD_FROM_CHARS 1
+# endif // (__cplusplus >= 201703)
+# endif // (__GNUC__ >= 11)
+# endif // defined(__GNUC__)
+# if defined(_MSC_VER)
+# if (_MSC_VER >= 1924 && _MSVC_LANG >= 201703)
+# define JSONCONS_HAS_STD_FROM_CHARS 1
+# endif // (_MSC_VER >= 1924 && MSVC_LANG >= 201703)
+# endif // defined(_MSC_VER)
+#endif
+#if defined(JSONCONS_HAS_STD_FROM_CHARS)
+#include <charconv>
+#endif
+
+#if !defined(JSONCONS_HAS_2017)
+# if defined(__clang__)
+# if (__cplusplus >= 201703)
+# define JSONCONS_HAS_2017 1
+# endif // (__cplusplus >= 201703)
+# endif // defined(__clang__)
+# if defined(__GNUC__)
+# if (__GNUC__ >= 7)
+# if (__cplusplus >= 201703)
+# define JSONCONS_HAS_2017 1
+# endif // (__cplusplus >= 201703)
+# endif // (__GNUC__ >= 7)
+# endif // defined(__GNUC__)
+# if defined(_MSC_VER)
+# if (_MSC_VER >= 1910 && _MSVC_LANG >= 201703)
+# define JSONCONS_HAS_2017 1
+# endif // (_MSC_VER >= 1910 && MSVC_LANG >= 201703)
+# endif // defined(_MSC_VER)
+#endif
+
+#if defined(JSONCONS_HAS_2017)
+ #define JSONCONS_NODISCARD [[nodiscard]]
+ #define JSONCONS_IF_CONSTEXPR if constexpr
+#else
+ #define JSONCONS_NODISCARD
+ #define JSONCONS_IF_CONSTEXPR if
+#endif
+
+#if !defined(JSONCONS_HAS_STD_STRING_VIEW)
+# if (defined JSONCONS_HAS_2017)
+# if defined(__clang__)
+# if __has_include(<string_view>)
+# define JSONCONS_HAS_STD_STRING_VIEW 1
+# endif // __has_include(<string_view>)
+# else
+# define JSONCONS_HAS_STD_STRING_VIEW 1
+# endif
+# endif // defined(JSONCONS_HAS_2017)
+#endif // !defined(JSONCONS_HAS_STD_STRING_VIEW)
+
+#if !defined(JSONCONS_HAS_STD_BYTE)
+# if (defined JSONCONS_HAS_2017)
+# define JSONCONS_HAS_STD_BYTE 1
+# endif // defined(JSONCONS_HAS_2017)
+#endif // !defined(JSONCONS_HAS_STD_BYTE)
+
+#if !defined(JSONCONS_HAS_STD_OPTIONAL)
+# if (defined JSONCONS_HAS_2017)
+# if defined(__clang__)
+# if __has_include(<optional>)
+# define JSONCONS_HAS_STD_OPTIONAL 1
+# endif // __has_include(<string_view>)
+# else
+# define JSONCONS_HAS_STD_OPTIONAL 1
+# endif
+# endif // defined(JSONCONS_HAS_2017)
+#endif // !defined(JSONCONS_HAS_STD_OPTIONAL)
+
+#if !defined(JSONCONS_HAS_STD_VARIANT)
+# if (defined JSONCONS_HAS_2017)
+# if defined(__clang__)
+# if defined(__APPLE__)
+# if JSONCONS_CLANG_VERSION >= 100001
+# define JSONCONS_HAS_STD_VARIANT 1
+# endif
+# elif __has_include(<variant>)
+# define JSONCONS_HAS_STD_VARIANT 1
+# endif // __has_include(<variant>)
+# else
+# define JSONCONS_HAS_STD_VARIANT 1
+# endif
+# endif // defined(JSONCONS_HAS_2017)
+#endif // !defined(JSONCONS_HAS_STD_VARIANT)
+
+#if !defined(JSONCONS_HAS_FILESYSTEM)
+# if (defined JSONCONS_HAS_2017)
+# if defined(__clang__)
+# if __has_include(<filesystem>)
+# define JSONCONS_HAS_FILESYSTEM 1
+# endif // __has_include(<filesystem>)
+# else
+# define JSONCONS_HAS_FILESYSTEM 1
+# endif
+# endif // defined(JSONCONS_HAS_2017)
+#endif // !defined(JSONCONS_HAS_FILESYSTEM)
+
+#if (!defined(JSONCONS_NO_EXCEPTIONS))
+// Check if exceptions are disabled.
+# if defined( __cpp_exceptions) && __cpp_exceptions == 0
+# define JSONCONS_NO_EXCEPTIONS 1
+# endif
+#endif
+
+#if !defined(JSONCONS_NO_EXCEPTIONS)
+
+#if defined(__GNUC__) && !__EXCEPTIONS
+# define JSONCONS_NO_EXCEPTIONS 1
+#elif _MSC_VER
+#if defined(_HAS_EXCEPTIONS) && _HAS_EXCEPTIONS == 0
+# define JSONCONS_NO_EXCEPTIONS 1
+#elif !defined(_CPPUNWIND)
+# define JSONCONS_NO_EXCEPTIONS 1
+#endif
+#endif
+#endif
+
+// allow to disable exceptions
+#if !defined(JSONCONS_NO_EXCEPTIONS)
+ #define JSONCONS_THROW(exception) throw exception
+ #define JSONCONS_RETHROW throw
+ #define JSONCONS_TRY try
+ #define JSONCONS_CATCH(exception) catch(exception)
+#else
+ #define JSONCONS_THROW(exception) std::terminate()
+ #define JSONCONS_RETHROW std::terminate()
+ #define JSONCONS_TRY if (true)
+ #define JSONCONS_CATCH(exception) if (false)
+#endif
+
+#if !defined(JSONCONS_HAS_STD_MAKE_UNIQUE)
+ #if defined(__clang__) && defined(__cplusplus)
+ #if defined(__APPLE__)
+ #if __clang_major__ >= 6 && __cplusplus >= 201402L // Xcode 6
+ #define JSONCONS_HAS_STD_MAKE_UNIQUE
+ #endif
+ #elif ((__clang_major__*100 +__clang_minor__) >= 340) && __cplusplus >= 201402L
+ #define JSONCONS_HAS_STD_MAKE_UNIQUE
+ #endif
+ #elif defined(__GNUC__)
+ #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 409 && __cplusplus > 201103L
+ #define JSONCONS_HAS_STD_MAKE_UNIQUE
+ #endif
+ #elif defined(_MSC_VER)
+ #if _MSC_VER >= 1800
+ #define JSONCONS_HAS_STD_MAKE_UNIQUE
+ #endif
+ #endif
+#endif // !defined(JSONCONS_HAS_STD_MAKE_UNIQUE)
+
+#ifndef JSONCONS_HAS_CP14_CONSTEXPR
+ #if defined(_MSC_VER)
+ #if _MSC_VER >= 1910
+ #define JSONCONS_HAS_CP14_CONSTEXPR
+ #endif
+ #elif defined(__GNUC__)
+ #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 600 && __cplusplus >= 201402L
+ #define JSONCONS_HAS_CP14_CONSTEXPR
+ #endif
+ #endif
+#endif
+
+#if defined(JSONCONS_HAS_CP14_CONSTEXPR)
+# define JSONCONS_CPP14_CONSTEXPR constexpr
+#else
+# define JSONCONS_CPP14_CONSTEXPR
+#endif
+
+// Follows boost
+
+// gcc and clang
+#if (defined(__clang__) || defined(__GNUC__)) && defined(__cplusplus)
+#if defined(__SIZEOF_INT128__) && !defined(_MSC_VER)
+# define JSONCONS_HAS_INT128
+#endif
+
+#if (defined(linux) || defined(__linux) || defined(__linux__) || defined(__GNU__) || defined(__GLIBC__)) && !defined(_CRAYC)
+#if (__clang_major__ >= 4) && defined(__has_include)
+#if __has_include(<quadmath.h>)
+# define JSONCONS_HAS_FLOAT128
+#endif
+#endif
+#endif
+#endif
+
+#if defined(__GNUC__)
+#if defined(_GLIBCXX_USE_FLOAT128)
+# define JSONCONS_HAS_FLOAT128
+#endif
+#endif
+
+#if defined(__clang__)
+#if (defined(linux) || defined(__linux) || defined(__linux__) || defined(__GNU__) || defined(__GLIBC__)) && !defined(_CRAYC)
+#if (__clang_major__ >= 4) && defined(__has_include)
+#if __has_include(<quadmath.h>)
+# define JSONCONS_HAS_FLOAT128
+#endif
+#endif
+#endif
+#endif
+
+// Follows boost config/detail/suffix.hpp
+#if defined(JSONCONS_HAS_INT128) && defined(__cplusplus)
+namespace jsoncons{
+# ifdef __GNUC__
+ __extension__ typedef __int128 int128_type;
+ __extension__ typedef unsigned __int128 uint128_type;
+# else
+ typedef __int128 int128_type;
+ typedef unsigned __int128 uint128_type;
+# endif
+}
+#endif
+#if defined(JSONCONS_HAS_FLOAT128) && defined(__cplusplus)
+namespace jsoncons {
+# ifdef __GNUC__
+ __extension__ typedef __float128 float128_type;
+# else
+ typedef __float128 float128_type;
+# endif
+}
+#endif
+
+#if defined(_MSC_VER) && _MSC_VER <= 1900
+ #define JSONCONS_COPY(first,last,d_first) std::copy(first, last, stdext::make_checked_array_iterator(d_first, static_cast<std::size_t>(std::distance(first, last))))
+#else
+ #define JSONCONS_COPY(first,last,d_first) std::copy(first, last, d_first)
+#endif
+
+#if defined(_MSC_VER) && _MSC_VER <= 1900
+#define JSONCONS_CONSTEXPR
+#else
+#define JSONCONS_CONSTEXPR constexpr
+#endif
+
+namespace jsoncons {
+
+ class assertion_error : public std::runtime_error
+ {
+ public:
+ assertion_error(const std::string& s) noexcept
+ : std::runtime_error(s)
+ {
+ }
+ const char* what() const noexcept override
+ {
+ return std::runtime_error::what();
+ }
+ };
+
+} // namespace jsoncons
+
+#define JSONCONS_STR2(x) #x
+#define JSONCONS_STR(x) JSONCONS_STR2(x)
+
+#ifdef _DEBUG
+#define JSONCONS_ASSERT(x) if (!(x)) { \
+ JSONCONS_THROW(jsoncons::assertion_error("assertion '" #x "' failed at " __FILE__ ":" \
+ JSONCONS_STR(__LINE__))); }
+#else
+#define JSONCONS_ASSERT(x) if (!(x)) { \
+ JSONCONS_THROW(jsoncons::assertion_error("assertion '" #x "' failed at <> :" \
+ JSONCONS_STR( 0 ))); }
+#endif // _DEBUG
+
+#endif // JSONCONS_COMPILER_SUPPORT_HPP
diff --git a/include/jsoncons/config/jsoncons_config.hpp b/include/jsoncons/config/jsoncons_config.hpp
new file mode 100644
index 0000000..63c437b
--- /dev/null
+++ b/include/jsoncons/config/jsoncons_config.hpp
@@ -0,0 +1,308 @@
+// Copyright 2019 Daniel Parker
+// Distributed under the Boost license, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// See https://github.com/danielaparker/jsoncons for latest version
+
+#ifndef JSONCONS_CONFIG_JSONCONS_CONFIG_HPP
+#define JSONCONS_CONFIG_JSONCONS_CONFIG_HPP
+
+#include <type_traits>
+#include <limits>
+#include <jsoncons/config/compiler_support.hpp>
+#include <jsoncons/config/binary_config.hpp>
+
+#if !defined(JSONCONS_HAS_STD_STRING_VIEW)
+#include <jsoncons/detail/string_view.hpp>
+namespace jsoncons {
+using jsoncons::detail::basic_string_view;
+using string_view = basic_string_view<char, std::char_traits<char>>;
+using wstring_view = basic_string_view<wchar_t, std::char_traits<wchar_t>>;
+}
+#else
+#include <string_view>
+namespace jsoncons {
+using std::basic_string_view;
+using std::string_view;
+using std::wstring_view;
+}
+#endif
+
+#if !defined(JSONCONS_HAS_STD_SPAN)
+#include <jsoncons/detail/span.hpp>
+namespace jsoncons {
+using jsoncons::detail::span;
+}
+#else
+#include <span>
+namespace jsoncons {
+using std::span;
+}
+#endif
+
+#if defined(JSONCONS_HAS_STD_OPTIONAL)
+ #include <optional>
+ namespace jsoncons {
+ using std::optional;
+ }
+#elif defined(JSONCONS_HAS_BOOST_OPTIONAL)
+ #include <boost/optional.hpp>
+ namespace jsoncons {
+ using boost::optional;
+ }
+#else
+ #include <jsoncons/detail/optional.hpp>
+ namespace jsoncons {
+ using jsoncons::detail::optional;
+}
+#endif // !defined(JSONCONS_HAS_STD_OPTIONAL)
+
+#if !defined(JSONCONS_HAS_STD_ENDIAN)
+#include <jsoncons/detail/endian.hpp>
+namespace jsoncons {
+using jsoncons::detail::endian;
+}
+#else
+#include <bit>
+namespace jsoncons
+{
+ using std::endian;
+}
+#endif
+
+#if !defined(JSONCONS_HAS_STD_MAKE_UNIQUE)
+
+#include <cstddef>
+#include <memory>
+#include <type_traits>
+#include <utility>
+
+namespace jsoncons {
+
+ template<class T>
+ struct unique_if
+ {
+ using value_is_not_array = std::unique_ptr<T>;
+ };
+
+ template<class T>
+ struct unique_if<T[]>
+ {
+ typedef std::unique_ptr<T[]> value_is_array_of_unknown_bound;
+ };
+
+ template<class T, std::size_t N>
+ struct unique_if<T[N]> {
+ using value_is_array_of_known_bound = void;
+ };
+
+ template<class T, class... Args>
+ typename unique_if<T>::value_is_not_array
+ make_unique(Args&&... args)
+ {
+ return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
+ }
+
+ template<class T>
+ typename unique_if<T>::value_is_array_of_unknown_bound
+ make_unique(std::size_t n)
+ {
+ using U = typename std::remove_extent<T>::type;
+ return std::unique_ptr<T>(new U[n]());
+ }
+
+ template<class T, class... Args>
+ typename unique_if<T>::value_is_array_of_known_bound
+ make_unique(Args&&...) = delete;
+} // jsoncons
+
+#else
+
+#include <memory>
+namespace jsoncons
+{
+ using std::make_unique;
+}
+
+#endif // !defined(JSONCONS_HAS_STD_MAKE_UNIQUE)
+
+namespace jsoncons {
+namespace binary {
+
+ // native_to_big
+
+ template<typename T, class OutputIt, class Endian=endian>
+ typename std::enable_if<Endian::native == Endian::big,void>::type
+ native_to_big(T val, OutputIt d_first)
+ {
+ uint8_t buf[sizeof(T)];
+ std::memcpy(buf, &val, sizeof(T));
+ for (auto item : buf)
+ {
+ *d_first++ = item;
+ }
+ }
+
+ template<typename T, class OutputIt, class Endian=endian>
+ typename std::enable_if<Endian::native == Endian::little,void>::type
+ native_to_big(T val, OutputIt d_first)
+ {
+ T val2 = byte_swap(val);
+ uint8_t buf[sizeof(T)];
+ std::memcpy(buf, &val2, sizeof(T));
+ for (auto item : buf)
+ {
+ *d_first++ = item;
+ }
+ }
+
+ // native_to_little
+
+ template<typename T, class OutputIt, class Endian = endian>
+ typename std::enable_if<Endian::native == Endian::little,void>::type
+ native_to_little(T val, OutputIt d_first)
+ {
+ uint8_t buf[sizeof(T)];
+ std::memcpy(buf, &val, sizeof(T));
+ for (auto item : buf)
+ {
+ *d_first++ = item;
+ }
+ }
+
+ template<typename T, class OutputIt, class Endian=endian>
+ typename std::enable_if<Endian::native == Endian::big, void>::type
+ native_to_little(T val, OutputIt d_first)
+ {
+ T val2 = byte_swap(val);
+ uint8_t buf[sizeof(T)];
+ std::memcpy(buf, &val2, sizeof(T));
+ for (auto item : buf)
+ {
+ *d_first++ = item;
+ }
+ }
+
+ // big_to_native
+
+ template<class T,class Endian=endian>
+ typename std::enable_if<Endian::native == Endian::big,T>::type
+ big_to_native(const uint8_t* first, std::size_t count)
+ {
+ if (sizeof(T) > count)
+ {
+ return T{};
+ }
+ T val;
+ std::memcpy(&val,first,sizeof(T));
+ return val;
+ }
+
+ template<class T,class Endian=endian>
+ typename std::enable_if<Endian::native == Endian::little,T>::type
+ big_to_native(const uint8_t* first, std::size_t count)
+ {
+ if (sizeof(T) > count)
+ {
+ return T{};
+ }
+ T val;
+ std::memcpy(&val,first,sizeof(T));
+ return byte_swap(val);
+ }
+
+ // little_to_native
+
+ template<class T,class Endian=endian>
+ typename std::enable_if<Endian::native == Endian::little,T>::type
+ little_to_native(const uint8_t* first, std::size_t count)
+ {
+ if (sizeof(T) > count)
+ {
+ return T{};
+ }
+ T val;
+ std::memcpy(&val,first,sizeof(T));
+ return val;
+ }
+
+ template<class T,class Endian=endian>
+ typename std::enable_if<Endian::native == Endian::big,T>::type
+ little_to_native(const uint8_t* first, std::size_t count)
+ {
+ if (sizeof(T) > count)
+ {
+ return T{};
+ }
+ T val;
+ std::memcpy(&val,first,sizeof(T));
+ return byte_swap(val);
+ }
+
+} // binary
+} // jsoncons
+
+namespace jsoncons {
+
+ template<typename CharT>
+ constexpr const CharT* cstring_constant_of_type(const char* c, const wchar_t* w);
+
+ template<> inline
+ constexpr const char* cstring_constant_of_type<char>(const char* c, const wchar_t*)
+ {
+ return c;
+ }
+ template<> inline
+ constexpr const wchar_t* cstring_constant_of_type<wchar_t>(const char*, const wchar_t* w)
+ {
+ return w;
+ }
+
+ template<typename CharT>
+ std::basic_string<CharT> string_constant_of_type(const char* c, const wchar_t* w);
+
+ template<> inline
+ std::string string_constant_of_type<char>(const char* c, const wchar_t*)
+ {
+ return std::string(c);
+ }
+ template<> inline
+ std::wstring string_constant_of_type<wchar_t>(const char*, const wchar_t* w)
+ {
+ return std::wstring(w);
+ }
+
+ template<typename CharT>
+ jsoncons::basic_string_view<CharT> string_view_constant_of_type(const char* c, const wchar_t* w);
+
+ template<> inline
+ jsoncons::string_view string_view_constant_of_type<char>(const char* c, const wchar_t*)
+ {
+ return jsoncons::string_view(c);
+ }
+ template<> inline
+ jsoncons::wstring_view string_view_constant_of_type<wchar_t>(const char*, const wchar_t* w)
+ {
+ return jsoncons::wstring_view(w);
+ }
+
+} // jsoncons
+
+#define JSONCONS_EXPAND(X) X
+#define JSONCONS_QUOTE(Prefix, A) JSONCONS_EXPAND(Prefix ## #A)
+
+#define JSONCONS_CSTRING_CONSTANT(CharT, Str) cstring_constant_of_type<CharT>(Str, JSONCONS_QUOTE(L, Str))
+#define JSONCONS_STRING_CONSTANT(CharT, Str) string_constant_of_type<CharT>(Str, JSONCONS_QUOTE(L, Str))
+#define JSONCONS_STRING_VIEW_CONSTANT(CharT, Str) string_view_constant_of_type<CharT>(Str, JSONCONS_QUOTE(L, Str))
+
+#if defined(__clang__)
+#define JSONCONS_HAS_STD_REGEX 1
+#elif (defined(__GNUC__) && (__GNUC__ == 4)) && (defined(__GNUC__) && __GNUC_MINOR__ < 9)
+// GCC 4.8 has broken regex support: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53631
+#else
+#define JSONCONS_HAS_STD_REGEX 1
+#endif
+
+#endif // JSONCONS_CONFIG_JSONCONS_CONFIG_HPP
+
+
diff --git a/include/jsoncons/config/version.hpp b/include/jsoncons/config/version.hpp
new file mode 100644
index 0000000..7f11eef
--- /dev/null
+++ b/include/jsoncons/config/version.hpp
@@ -0,0 +1,40 @@
+// Copyright 2017 Daniel Parker
+// Distributed under the Boost license, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// See https://github.com/danielaparker/jsoncons for latest version
+
+#ifndef JSONCONS_VERSION_HPP
+#define JSONCONS_VERSION_HPP
+
+#include <iostream>
+
+#define JSONCONS_VERSION_MAJOR 0
+#define JSONCONS_VERSION_MINOR 168
+#define JSONCONS_VERSION_PATCH 7
+
+namespace jsoncons {
+
+struct versioning_info
+{
+ unsigned int const major;
+ unsigned int const minor;
+ unsigned int const patch;
+
+ friend std::ostream& operator<<(std::ostream& os, const versioning_info& ver)
+ {
+ os << ver.major << '.'
+ << ver.minor << '.'
+ << ver.patch;
+ return os;
+ }
+};
+
+constexpr versioning_info version()
+{
+ return versioning_info{JSONCONS_VERSION_MAJOR, JSONCONS_VERSION_MINOR, JSONCONS_VERSION_PATCH};
+}
+
+}
+
+#endif