Date: Fri, 24 Aug 2018 19:12:40 +0000 (UTC) From: Dave Cottlehuber <dch@FreeBSD.org> To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r477979 - in head/net/zerotier: . files Message-ID: <201808241912.w7OJCecK044854@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: dch Date: Fri Aug 24 19:12:40 2018 New Revision: 477979 URL: https://svnweb.freebsd.org/changeset/ports/477979 Log: net/zerotier: update 1.2.10 to 1.2.12 also: - compile against libc++7 reported broken in PR230629 - correct combined LICENSEs to match source code PR: 230629 Reported by: jbeich Approved by: jrm Differential Revision: https://reviews.freebsd.org/D16880 Added: head/net/zerotier/files/patch-ext_json_json.hpp (contents, props changed) Deleted: head/net/zerotier/files/patch-node_Packet.cpp Modified: head/net/zerotier/Makefile head/net/zerotier/distinfo Modified: head/net/zerotier/Makefile ============================================================================== --- head/net/zerotier/Makefile Fri Aug 24 18:42:44 2018 (r477978) +++ head/net/zerotier/Makefile Fri Aug 24 19:12:40 2018 (r477979) @@ -2,19 +2,20 @@ # $FreeBSD$ PORTNAME= zerotier -DISTVERSION= 1.2.10 -PORTREVISION= 1 +DISTVERSION= 1.2.12 CATEGORIES= net MAINTAINER= dch@FreeBSD.org COMMENT= Network virtualization everywhere -LICENSE= GPLv3 +LICENSE= GPLv3 MIT PD BSD3CLAUSE APACHE20 +LICENSE_COMB= multi LICENSE_FILE= ${WRKSRC}/LICENSE.GPL-3 BROKEN_armv6= fails to link: Source object ext/arm32-neon-salsa2012-asm/salsa2012.o has EABI version 0, but target zerotier-one has EABI version 5 BROKEN_armv7= fails to link: Source object ext/arm32-neon-salsa2012-asm/salsa2012.o has EABI version 0, but target zerotier-one has EABI version 5 BROKEN_powerpc64= fails to compile: clang: not found +BROKEN_FreeBSD_10_i386= fails to compile: clang++: error: unable to execute command: Segmentation fault (core dumped) USES= gmake compiler:c11 USE_RC_SUBR= zerotier Modified: head/net/zerotier/distinfo ============================================================================== --- head/net/zerotier/distinfo Fri Aug 24 18:42:44 2018 (r477978) +++ head/net/zerotier/distinfo Fri Aug 24 19:12:40 2018 (r477979) @@ -1,3 +1,3 @@ -TIMESTAMP = 1529964792 -SHA256 (zerotier-ZeroTierOne-1.2.10_GH0.tar.gz) = 1c79ec57e67764079a77704b336e642ae3cf221dc8088b0cf9e9c81e0a9c0c57 -SIZE (zerotier-ZeroTierOne-1.2.10_GH0.tar.gz) = 6056935 +TIMESTAMP = 1535097824 +SHA256 (zerotier-ZeroTierOne-1.2.12_GH0.tar.gz) = 212799bfaeb5e7dff20f2cd83f15742c8e13b8e9535606cfb85abcfb5fb6fed4 +SIZE (zerotier-ZeroTierOne-1.2.12_GH0.tar.gz) = 6058902 Added: head/net/zerotier/files/patch-ext_json_json.hpp ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/net/zerotier/files/patch-ext_json_json.hpp Fri Aug 24 19:12:40 2018 (r477979) @@ -0,0 +1,10678 @@ +--- ext/json/json.hpp.orig 2018-05-11 20:40:22 UTC ++++ ext/json/json.hpp +@@ -1,11 +1,12 @@ + /* + __ _____ _____ _____ + __| | __| | | | JSON for Modern C++ +-| | |__ | | | | | | version 3.0.1 ++| | |__ | | | | | | version 3.2.0 + |_____|_____|_____|_|___| https://github.com/nlohmann/json + + Licensed under the MIT License <http://opensource.org/licenses/MIT>. +-Copyright (c) 2013-2017 Niels Lohmann <http://nlohmann.me>. ++SPDX-License-Identifier: MIT ++Copyright (c) 2013-2018 Niels Lohmann <http://nlohmann.me>. + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal +@@ -29,43 +30,105 @@ SOFTWARE. + #ifndef NLOHMANN_JSON_HPP + #define NLOHMANN_JSON_HPP + +-#include <algorithm> // all_of, copy, fill, find, for_each, generate_n, none_of, remove, reverse, transform +-#include <array> // array ++#define NLOHMANN_JSON_VERSION_MAJOR 3 ++#define NLOHMANN_JSON_VERSION_MINOR 2 ++#define NLOHMANN_JSON_VERSION_PATCH 0 ++ ++#include <algorithm> // all_of, find, for_each + #include <cassert> // assert + #include <ciso646> // and, not, or +-#include <clocale> // lconv, localeconv +-#include <cmath> // isfinite, labs, ldexp, signbit + #include <cstddef> // nullptr_t, ptrdiff_t, size_t +-#include <cstdint> // int64_t, uint64_t +-#include <cstdlib> // abort, strtod, strtof, strtold, strtoul, strtoll, strtoull +-#include <cstring> // memcpy, strlen +-#include <forward_list> // forward_list +-#include <functional> // function, hash, less ++#include <functional> // hash, less + #include <initializer_list> // initializer_list +-#include <iomanip> // hex +-#include <iosfwd> // istream, ostream +-#include <iterator> // advance, begin, back_inserter, bidirectional_iterator_tag, distance, end, inserter, iterator, iterator_traits, next, random_access_iterator_tag, reverse_iterator +-#include <limits> // numeric_limits +-#include <locale> // locale +-#include <map> // map +-#include <memory> // addressof, allocator, allocator_traits, unique_ptr ++#include <iosfwd> // istream, ostream ++#include <iterator> // iterator_traits, random_access_iterator_tag + #include <numeric> // accumulate +-#include <sstream> // stringstream +-#include <string> // getline, stoi, string, to_string +-#include <type_traits> // add_pointer, conditional, decay, enable_if, false_type, integral_constant, is_arithmetic, is_base_of, is_const, is_constructible, is_convertible, is_default_constructible, is_enum, is_floating_point, is_integral, is_nothrow_move_assignable, is_nothrow_move_constructible, is_pointer, is_reference, is_same, is_scalar, is_signed, remove_const, remove_cv, remove_pointer, remove_reference, true_type, underlying_type +-#include <utility> // declval, forward, make_pair, move, pair, swap +-#include <valarray> // valarray ++#include <string> // string, stoi, to_string ++#include <utility> // declval, forward, move, pair, swap ++ ++// #include <nlohmann/json_fwd.hpp> ++#ifndef NLOHMANN_JSON_FWD_HPP ++#define NLOHMANN_JSON_FWD_HPP ++ ++#include <cstdint> // int64_t, uint64_t ++#include <map> // map ++#include <memory> // allocator ++#include <string> // string + #include <vector> // vector + ++/*! ++@brief namespace for Niels Lohmann ++@see https://github.com/nlohmann ++@since version 1.0.0 ++*/ ++namespace nlohmann ++{ ++/*! ++@brief default JSONSerializer template argument ++ ++This serializer ignores the template arguments and uses ADL ++([argument-dependent lookup](https://en.cppreference.com/w/cpp/language/adl)) ++for serialization. ++*/ ++template<typename T = void, typename SFINAE = void> ++struct adl_serializer; ++ ++template<template<typename U, typename V, typename... Args> class ObjectType = ++ std::map, ++ template<typename U, typename... Args> class ArrayType = std::vector, ++ class StringType = std::string, class BooleanType = bool, ++ class NumberIntegerType = std::int64_t, ++ class NumberUnsignedType = std::uint64_t, ++ class NumberFloatType = double, ++ template<typename U> class AllocatorType = std::allocator, ++ template<typename T, typename SFINAE = void> class JSONSerializer = ++ adl_serializer> ++class basic_json; ++ ++/*! ++@brief JSON Pointer ++ ++A JSON pointer defines a string syntax for identifying a specific value ++within a JSON document. It can be used with functions `at` and ++`operator[]`. Furthermore, JSON pointers are the base for JSON patches. ++ ++@sa [RFC 6901](https://tools.ietf.org/html/rfc6901) ++ ++@since version 2.0.0 ++*/ ++template<typename BasicJsonType> ++class json_pointer; ++ ++/*! ++@brief default JSON class ++ ++This type is the default specialization of the @ref basic_json class which ++uses the standard template types. ++ ++@since version 1.0.0 ++*/ ++using json = basic_json<>; ++} ++ ++#endif ++ ++// #include <nlohmann/detail/macro_scope.hpp> ++ ++ ++// This file contains all internal macro definitions ++// You MUST include macro_unscope.hpp at the end of json.hpp to undef all of them ++ + // exclude unsupported compilers +-#if defined(__clang__) +- #if (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) < 30400 +- #error "unsupported Clang version - see https://github.com/nlohmann/json#supported-compilers" ++#if !defined(JSON_SKIP_UNSUPPORTED_COMPILER_CHECK) ++ #if defined(__clang__) ++ #if (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) < 30400 ++ #error "unsupported Clang version - see https://github.com/nlohmann/json#supported-compilers" ++ #endif ++ #elif defined(__GNUC__) && !(defined(__ICC) || defined(__INTEL_COMPILER)) ++ #if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) < 40900 ++ #error "unsupported GCC version - see https://github.com/nlohmann/json#supported-compilers" ++ #endif + #endif +-#elif defined(__GNUC__) && !(defined(__ICC) || defined(__INTEL_COMPILER)) +- #if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) < 40900 +- #error "unsupported GCC version - see https://github.com/nlohmann/json#supported-compilers" +- #endif + #endif + + // disable float-equal warnings on GCC/clang +@@ -90,16 +153,37 @@ SOFTWARE. + #endif + + // allow to disable exceptions +-#if (defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND)) && not defined(JSON_NOEXCEPTION) ++#if (defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND)) && !defined(JSON_NOEXCEPTION) + #define JSON_THROW(exception) throw exception + #define JSON_TRY try + #define JSON_CATCH(exception) catch(exception) ++ #define JSON_INTERNAL_CATCH(exception) catch(exception) + #else + #define JSON_THROW(exception) std::abort() + #define JSON_TRY if(true) + #define JSON_CATCH(exception) if(false) ++ #define JSON_INTERNAL_CATCH(exception) if(false) + #endif + ++// override exception macros ++#if defined(JSON_THROW_USER) ++ #undef JSON_THROW ++ #define JSON_THROW JSON_THROW_USER ++#endif ++#if defined(JSON_TRY_USER) ++ #undef JSON_TRY ++ #define JSON_TRY JSON_TRY_USER ++#endif ++#if defined(JSON_CATCH_USER) ++ #undef JSON_CATCH ++ #define JSON_CATCH JSON_CATCH_USER ++ #define JSON_INTERNAL_CATCH JSON_CATCH_USER ++#endif ++#if defined(JSON_INTERNAL_CATCH_USER) ++ #undef JSON_INTERNAL_CATCH ++ #define JSON_INTERNAL_CATCH JSON_INTERNAL_CATCH_USER ++#endif ++ + // manual branch prediction + #if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__) + #define JSON_LIKELY(x) __builtin_expect(!!(x), 1) +@@ -117,27 +201,6 @@ SOFTWARE. + #define JSON_HAS_CPP_14 + #endif + +-/*! +-@brief namespace for Niels Lohmann +-@see https://github.com/nlohmann +-@since version 1.0.0 +-*/ +-namespace nlohmann +-{ +-template<typename = void, typename = void> +-struct adl_serializer; +- +-// forward declaration of basic_json (required to split the class) +-template<template<typename, typename, typename...> class ObjectType = std::map, +- template<typename, typename...> class ArrayType = std::vector, +- class StringType = std::string, class BooleanType = bool, +- class NumberIntegerType = std::int64_t, +- class NumberUnsignedType = std::uint64_t, +- class NumberFloatType = double, +- template<typename> class AllocatorType = std::allocator, +- template<typename, typename = void> class JSONSerializer = adl_serializer> +-class basic_json; +- + // Ugly macros to avoid uglier copy-paste when specializing basic_json. They + // may be removed in the future once the class is split. + +@@ -154,17 +217,334 @@ class basic_json; + NumberIntegerType, NumberUnsignedType, NumberFloatType, \ + AllocatorType, JSONSerializer> + ++/*! ++@brief Helper to determine whether there's a key_type for T. + ++This helper is used to tell associative containers apart from other containers ++such as sequence containers. For instance, `std::map` passes the test as it ++contains a `mapped_type`, whereas `std::vector` fails the test. ++ ++@sa http://stackoverflow.com/a/7728728/266378 ++@since version 1.0.0, overworked in version 2.0.6 ++*/ ++#define NLOHMANN_JSON_HAS_HELPER(type) \ ++ template<typename T> struct has_##type { \ ++ private: \ ++ template<typename U, typename = typename U::type> \ ++ static int detect(U &&); \ ++ static void detect(...); \ ++ public: \ ++ static constexpr bool value = \ ++ std::is_integral<decltype(detect(std::declval<T>()))>::value; \ ++ } ++ ++// #include <nlohmann/detail/meta/cpp_future.hpp> ++ ++ ++#include <ciso646> // not ++#include <cstddef> // size_t ++#include <type_traits> // conditional, enable_if, false_type, integral_constant, is_constructible, is_integral, is_same, remove_cv, remove_reference, true_type ++ ++namespace nlohmann ++{ ++namespace detail ++{ ++// alias templates to reduce boilerplate ++template<bool B, typename T = void> ++using enable_if_t = typename std::enable_if<B, T>::type; ++ ++template<typename T> ++using uncvref_t = typename std::remove_cv<typename std::remove_reference<T>::type>::type; ++ ++// implementation of C++14 index_sequence and affiliates ++// source: https://stackoverflow.com/a/32223343 ++template<std::size_t... Ints> ++struct index_sequence ++{ ++ using type = index_sequence; ++ using value_type = std::size_t; ++ static constexpr std::size_t size() noexcept ++ { ++ return sizeof...(Ints); ++ } ++}; ++ ++template<class Sequence1, class Sequence2> ++struct merge_and_renumber; ++ ++template<std::size_t... I1, std::size_t... I2> ++struct merge_and_renumber<index_sequence<I1...>, index_sequence<I2...>> ++ : index_sequence < I1..., (sizeof...(I1) + I2)... > {}; ++ ++template<std::size_t N> ++struct make_index_sequence ++ : merge_and_renumber < typename make_index_sequence < N / 2 >::type, ++ typename make_index_sequence < N - N / 2 >::type > {}; ++ ++template<> struct make_index_sequence<0> : index_sequence<> {}; ++template<> struct make_index_sequence<1> : index_sequence<0> {}; ++ ++template<typename... Ts> ++using index_sequence_for = make_index_sequence<sizeof...(Ts)>; ++ ++/* ++Implementation of two C++17 constructs: conjunction, negation. This is needed ++to avoid evaluating all the traits in a condition ++ ++For example: not std::is_same<void, T>::value and has_value_type<T>::value ++will not compile when T = void (on MSVC at least). Whereas ++conjunction<negation<std::is_same<void, T>>, has_value_type<T>>::value will ++stop evaluating if negation<...>::value == false ++ ++Please note that those constructs must be used with caution, since symbols can ++become very long quickly (which can slow down compilation and cause MSVC ++internal compiler errors). Only use it when you have to (see example ahead). ++*/ ++template<class...> struct conjunction : std::true_type {}; ++template<class B1> struct conjunction<B1> : B1 {}; ++template<class B1, class... Bn> ++struct conjunction<B1, Bn...> : std::conditional<bool(B1::value), conjunction<Bn...>, B1>::type {}; ++ ++template<class B> struct negation : std::integral_constant<bool, not B::value> {}; ++ ++// dispatch utility (taken from ranges-v3) ++template<unsigned N> struct priority_tag : priority_tag < N - 1 > {}; ++template<> struct priority_tag<0> {}; ++ ++// taken from ranges-v3 ++template<typename T> ++struct static_const ++{ ++ static constexpr T value{}; ++}; ++ ++template<typename T> ++constexpr T static_const<T>::value; ++} ++} ++ ++// #include <nlohmann/detail/meta/type_traits.hpp> ++ ++ ++#include <ciso646> // not ++#include <limits> // numeric_limits ++#include <type_traits> // false_type, is_constructible, is_integral, is_same, true_type ++#include <utility> // declval ++ ++// #include <nlohmann/json_fwd.hpp> ++ ++// #include <nlohmann/detail/meta/cpp_future.hpp> ++ ++// #include <nlohmann/detail/macro_scope.hpp> ++ ++ ++namespace nlohmann ++{ + /*! +-@brief unnamed namespace with internal helper functions ++@brief detail namespace with internal helper functions + +-This namespace collects some functions that could not be defined inside the +-@ref basic_json class. ++This namespace collects functions that should not be exposed, ++implementations of some @ref basic_json methods, and meta-programming helpers. + + @since version 2.1.0 + */ + namespace detail + { ++///////////// ++// helpers // ++///////////// ++ ++template<typename> struct is_basic_json : std::false_type {}; ++ ++NLOHMANN_BASIC_JSON_TPL_DECLARATION ++struct is_basic_json<NLOHMANN_BASIC_JSON_TPL> : std::true_type {}; ++ ++//////////////////////// ++// has_/is_ functions // ++//////////////////////// ++ ++// source: https://stackoverflow.com/a/37193089/4116453 ++ ++template <typename T, typename = void> ++struct is_complete_type : std::false_type {}; ++ ++template <typename T> ++struct is_complete_type<T, decltype(void(sizeof(T)))> : std::true_type {}; ++ ++NLOHMANN_JSON_HAS_HELPER(mapped_type); ++NLOHMANN_JSON_HAS_HELPER(key_type); ++NLOHMANN_JSON_HAS_HELPER(value_type); ++NLOHMANN_JSON_HAS_HELPER(iterator); ++ ++template<bool B, class RealType, class CompatibleObjectType> ++struct is_compatible_object_type_impl : std::false_type {}; ++ ++template<class RealType, class CompatibleObjectType> ++struct is_compatible_object_type_impl<true, RealType, CompatibleObjectType> ++{ ++ static constexpr auto value = ++ std::is_constructible<typename RealType::key_type, typename CompatibleObjectType::key_type>::value and ++ std::is_constructible<typename RealType::mapped_type, typename CompatibleObjectType::mapped_type>::value; ++}; ++ ++template<bool B, class RealType, class CompatibleStringType> ++struct is_compatible_string_type_impl : std::false_type {}; ++ ++template<class RealType, class CompatibleStringType> ++struct is_compatible_string_type_impl<true, RealType, CompatibleStringType> ++{ ++ static constexpr auto value = ++ std::is_same<typename RealType::value_type, typename CompatibleStringType::value_type>::value and ++ std::is_constructible<RealType, CompatibleStringType>::value; ++}; ++ ++template<class BasicJsonType, class CompatibleObjectType> ++struct is_compatible_object_type ++{ ++ static auto constexpr value = is_compatible_object_type_impl < ++ conjunction<negation<std::is_same<void, CompatibleObjectType>>, ++ has_mapped_type<CompatibleObjectType>, ++ has_key_type<CompatibleObjectType>>::value, ++ typename BasicJsonType::object_t, CompatibleObjectType >::value; ++}; ++ ++template<class BasicJsonType, class CompatibleStringType> ++struct is_compatible_string_type ++{ ++ static auto constexpr value = is_compatible_string_type_impl < ++ conjunction<negation<std::is_same<void, CompatibleStringType>>, ++ has_value_type<CompatibleStringType>>::value, ++ typename BasicJsonType::string_t, CompatibleStringType >::value; ++}; ++ ++template<typename BasicJsonType, typename T> ++struct is_basic_json_nested_type ++{ ++ static auto constexpr value = std::is_same<T, typename BasicJsonType::iterator>::value or ++ std::is_same<T, typename BasicJsonType::const_iterator>::value or ++ std::is_same<T, typename BasicJsonType::reverse_iterator>::value or ++ std::is_same<T, typename BasicJsonType::const_reverse_iterator>::value; ++}; ++ ++template<class BasicJsonType, class CompatibleArrayType> ++struct is_compatible_array_type ++{ ++ static auto constexpr value = ++ conjunction<negation<std::is_same<void, CompatibleArrayType>>, ++ negation<is_compatible_object_type< ++ BasicJsonType, CompatibleArrayType>>, ++ negation<std::is_constructible<typename BasicJsonType::string_t, ++ CompatibleArrayType>>, ++ negation<is_basic_json_nested_type<BasicJsonType, CompatibleArrayType>>, ++ has_value_type<CompatibleArrayType>, ++ has_iterator<CompatibleArrayType>>::value; ++}; ++ ++template<bool, typename, typename> ++struct is_compatible_integer_type_impl : std::false_type {}; ++ ++template<typename RealIntegerType, typename CompatibleNumberIntegerType> ++struct is_compatible_integer_type_impl<true, RealIntegerType, CompatibleNumberIntegerType> ++{ ++ // is there an assert somewhere on overflows? ++ using RealLimits = std::numeric_limits<RealIntegerType>; ++ using CompatibleLimits = std::numeric_limits<CompatibleNumberIntegerType>; ++ ++ static constexpr auto value = ++ std::is_constructible<RealIntegerType, CompatibleNumberIntegerType>::value and ++ CompatibleLimits::is_integer and ++ RealLimits::is_signed == CompatibleLimits::is_signed; ++}; ++ ++template<typename RealIntegerType, typename CompatibleNumberIntegerType> ++struct is_compatible_integer_type ++{ ++ static constexpr auto value = ++ is_compatible_integer_type_impl < ++ std::is_integral<CompatibleNumberIntegerType>::value and ++ not std::is_same<bool, CompatibleNumberIntegerType>::value, ++ RealIntegerType, CompatibleNumberIntegerType > ::value; ++}; ++ ++// trait checking if JSONSerializer<T>::from_json(json const&, udt&) exists ++template<typename BasicJsonType, typename T> ++struct has_from_json ++{ ++ private: ++ // also check the return type of from_json ++ template<typename U, typename = enable_if_t<std::is_same<void, decltype(uncvref_t<U>::from_json( ++ std::declval<BasicJsonType>(), std::declval<T&>()))>::value>> ++ static int detect(U&&); ++ static void detect(...); ++ ++ public: ++ static constexpr bool value = std::is_integral<decltype( ++ detect(std::declval<typename BasicJsonType::template json_serializer<T, void>>()))>::value; ++}; ++ ++// This trait checks if JSONSerializer<T>::from_json(json const&) exists ++// this overload is used for non-default-constructible user-defined-types ++template<typename BasicJsonType, typename T> ++struct has_non_default_from_json ++{ ++ private: ++ template < ++ typename U, ++ typename = enable_if_t<std::is_same< ++ T, decltype(uncvref_t<U>::from_json(std::declval<BasicJsonType>()))>::value >> ++ static int detect(U&&); ++ static void detect(...); ++ ++ public: ++ static constexpr bool value = std::is_integral<decltype(detect( ++ std::declval<typename BasicJsonType::template json_serializer<T, void>>()))>::value; ++}; ++ ++// This trait checks if BasicJsonType::json_serializer<T>::to_json exists ++template<typename BasicJsonType, typename T> ++struct has_to_json ++{ ++ private: ++ template<typename U, typename = decltype(uncvref_t<U>::to_json( ++ std::declval<BasicJsonType&>(), std::declval<T>()))> ++ static int detect(U&&); ++ static void detect(...); ++ ++ public: ++ static constexpr bool value = std::is_integral<decltype(detect( ++ std::declval<typename BasicJsonType::template json_serializer<T, void>>()))>::value; ++}; ++ ++template <typename BasicJsonType, typename CompatibleCompleteType> ++struct is_compatible_complete_type ++{ ++ static constexpr bool value = ++ not std::is_base_of<std::istream, CompatibleCompleteType>::value and ++ not is_basic_json<CompatibleCompleteType>::value and ++ not is_basic_json_nested_type<BasicJsonType, CompatibleCompleteType>::value and ++ has_to_json<BasicJsonType, CompatibleCompleteType>::value; ++}; ++ ++template <typename BasicJsonType, typename CompatibleType> ++struct is_compatible_type ++ : conjunction<is_complete_type<CompatibleType>, ++ is_compatible_complete_type<BasicJsonType, CompatibleType>> ++{ ++}; ++} ++} ++ ++// #include <nlohmann/detail/exceptions.hpp> ++ ++ ++#include <exception> // exception ++#include <stdexcept> // runtime_error ++#include <string> // to_string ++ ++namespace nlohmann ++{ ++namespace detail ++{ + //////////////// + // exceptions // + //////////////// +@@ -419,6 +799,8 @@ json.exception.out_of_range.403 | key 'foo' not found + json.exception.out_of_range.404 | unresolved reference token 'foo' | A reference token in a JSON Pointer could not be resolved. + json.exception.out_of_range.405 | JSON pointer has no parent | The JSON Patch operations 'remove' and 'add' can not be applied to the root element of the JSON value. + json.exception.out_of_range.406 | number overflow parsing '10E1000' | A parsed number could not be stored as without changing it to NaN or INF. ++json.exception.out_of_range.407 | number overflow serializing '9223372036854775808' | UBJSON only supports integers numbers up to 9223372036854775807. | ++json.exception.out_of_range.408 | excessive array size: 8658170730974374167 | The size (following `#`) of an UBJSON array or object exceeds the maximal capacity. | + + @liveexample{The following code shows how an `out_of_range` exception can be + caught.,out_of_range} +@@ -481,9 +863,21 @@ class other_error : public exception + private: + other_error(int id_, const char* what_arg) : exception(id_, what_arg) {} + }; ++} ++} + ++// #include <nlohmann/detail/value_t.hpp> + + ++#include <array> // array ++#include <ciso646> // and ++#include <cstddef> // size_t ++#include <cstdint> // uint8_t ++ ++namespace nlohmann ++{ ++namespace detail ++{ + /////////////////////////// + // JSON type enumeration // + /////////////////////////// +@@ -512,7 +906,7 @@ value with the default value for a given type + + @since version 1.0.0 + */ +-enum class value_t : uint8_t ++enum class value_t : std::uint8_t + { + null, ///< null value + object, ///< object (unordered set of name/value pairs) +@@ -537,7 +931,7 @@ Returns an ordering that is similar to Python: + */ + inline bool operator<(const value_t lhs, const value_t rhs) noexcept + { +- static constexpr std::array<uint8_t, 8> order = {{ ++ static constexpr std::array<std::uint8_t, 8> order = {{ + 0 /* null */, 3 /* object */, 4 /* array */, 5 /* string */, + 1 /* boolean */, 2 /* integer */, 2 /* unsigned */, 2 /* float */ + } +@@ -547,80 +941,558 @@ inline bool operator<(const value_t lhs, const value_t + const auto r_index = static_cast<std::size_t>(rhs); + return l_index < order.size() and r_index < order.size() and order[l_index] < order[r_index]; + } ++} ++} + ++// #include <nlohmann/detail/conversions/from_json.hpp> + +-///////////// +-// helpers // +-///////////// + +-template<typename> struct is_basic_json : std::false_type {}; ++#include <algorithm> // transform ++#include <array> // array ++#include <ciso646> // and, not ++#include <forward_list> // forward_list ++#include <iterator> // inserter, front_inserter, end ++#include <map> // map ++#include <string> // string ++#include <tuple> // tuple, make_tuple ++#include <type_traits> // is_arithmetic, is_same, is_enum, underlying_type, is_convertible ++#include <unordered_map> // unordered_map ++#include <utility> // pair, declval ++#include <valarray> // valarray + +-NLOHMANN_BASIC_JSON_TPL_DECLARATION +-struct is_basic_json<NLOHMANN_BASIC_JSON_TPL> : std::true_type {}; ++// #include <nlohmann/detail/exceptions.hpp> + +-// alias templates to reduce boilerplate +-template<bool B, typename T = void> +-using enable_if_t = typename std::enable_if<B, T>::type; ++// #include <nlohmann/detail/macro_scope.hpp> + +-template<typename T> +-using uncvref_t = typename std::remove_cv<typename std::remove_reference<T>::type>::type; ++// #include <nlohmann/detail/meta/cpp_future.hpp> + +-// implementation of C++14 index_sequence and affiliates +-// source: https://stackoverflow.com/a/32223343 +-template<std::size_t... Ints> +-struct index_sequence ++// #include <nlohmann/detail/meta/type_traits.hpp> ++ ++// #include <nlohmann/detail/value_t.hpp> ++ ++ ++namespace nlohmann + { +- using type = index_sequence; +- using value_type = std::size_t; +- static constexpr std::size_t size() noexcept ++namespace detail ++{ ++template<typename BasicJsonType> ++void from_json(const BasicJsonType& j, typename std::nullptr_t& n) ++{ ++ if (JSON_UNLIKELY(not j.is_null())) + { +- return sizeof...(Ints); ++ JSON_THROW(type_error::create(302, "type must be null, but is " + std::string(j.type_name()))); + } ++ n = nullptr; ++} ++ ++// overloads for basic_json template parameters ++template<typename BasicJsonType, typename ArithmeticType, ++ enable_if_t<std::is_arithmetic<ArithmeticType>::value and ++ not std::is_same<ArithmeticType, typename BasicJsonType::boolean_t>::value, ++ int> = 0> ++void get_arithmetic_value(const BasicJsonType& j, ArithmeticType& val) ++{ ++ switch (static_cast<value_t>(j)) ++ { ++ case value_t::number_unsigned: ++ { ++ val = static_cast<ArithmeticType>(*j.template get_ptr<const typename BasicJsonType::number_unsigned_t*>()); ++ break; ++ } ++ case value_t::number_integer: ++ { ++ val = static_cast<ArithmeticType>(*j.template get_ptr<const typename BasicJsonType::number_integer_t*>()); ++ break; ++ } ++ case value_t::number_float: ++ { ++ val = static_cast<ArithmeticType>(*j.template get_ptr<const typename BasicJsonType::number_float_t*>()); ++ break; ++ } ++ ++ default: ++ JSON_THROW(type_error::create(302, "type must be number, but is " + std::string(j.type_name()))); ++ } ++} ++ ++template<typename BasicJsonType> ++void from_json(const BasicJsonType& j, typename BasicJsonType::boolean_t& b) ++{ ++ if (JSON_UNLIKELY(not j.is_boolean())) ++ { ++ JSON_THROW(type_error::create(302, "type must be boolean, but is " + std::string(j.type_name()))); ++ } ++ b = *j.template get_ptr<const typename BasicJsonType::boolean_t*>(); ++} ++ ++template<typename BasicJsonType> ++void from_json(const BasicJsonType& j, typename BasicJsonType::string_t& s) ++{ ++ if (JSON_UNLIKELY(not j.is_string())) ++ { ++ JSON_THROW(type_error::create(302, "type must be string, but is " + std::string(j.type_name()))); ++ } ++ s = *j.template get_ptr<const typename BasicJsonType::string_t*>(); ++} ++ ++template < ++ typename BasicJsonType, typename CompatibleStringType, ++ enable_if_t < ++ is_compatible_string_type<BasicJsonType, CompatibleStringType>::value and ++ not std::is_same<typename BasicJsonType::string_t, ++ CompatibleStringType>::value, ++ int > = 0 > ++void from_json(const BasicJsonType& j, CompatibleStringType& s) ++{ ++ if (JSON_UNLIKELY(not j.is_string())) ++ { ++ JSON_THROW(type_error::create(302, "type must be string, but is " + std::string(j.type_name()))); ++ } ++ ++ s = *j.template get_ptr<const typename BasicJsonType::string_t*>(); ++} ++ ++template<typename BasicJsonType> ++void from_json(const BasicJsonType& j, typename BasicJsonType::number_float_t& val) ++{ ++ get_arithmetic_value(j, val); ++} ++ ++template<typename BasicJsonType> ++void from_json(const BasicJsonType& j, typename BasicJsonType::number_unsigned_t& val) ++{ ++ get_arithmetic_value(j, val); ++} ++ ++template<typename BasicJsonType> ++void from_json(const BasicJsonType& j, typename BasicJsonType::number_integer_t& val) ++{ ++ get_arithmetic_value(j, val); ++} ++ ++template<typename BasicJsonType, typename EnumType, ++ enable_if_t<std::is_enum<EnumType>::value, int> = 0> ++void from_json(const BasicJsonType& j, EnumType& e) ++{ ++ typename std::underlying_type<EnumType>::type val; ++ get_arithmetic_value(j, val); ++ e = static_cast<EnumType>(val); ++} ++ ++template<typename BasicJsonType> ++void from_json(const BasicJsonType& j, typename BasicJsonType::array_t& arr) ++{ ++ if (JSON_UNLIKELY(not j.is_array())) ++ { ++ JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()))); ++ } ++ arr = *j.template get_ptr<const typename BasicJsonType::array_t*>(); ++} ++ ++// forward_list doesn't have an insert method ++template<typename BasicJsonType, typename T, typename Allocator, ++ enable_if_t<std::is_convertible<BasicJsonType, T>::value, int> = 0> ++void from_json(const BasicJsonType& j, std::forward_list<T, Allocator>& l) ++{ ++ if (JSON_UNLIKELY(not j.is_array())) ++ { ++ JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()))); ++ } ++ std::transform(j.rbegin(), j.rend(), ++ std::front_inserter(l), [](const BasicJsonType & i) ++ { ++ return i.template get<T>(); ++ }); ++} ++ ++// valarray doesn't have an insert method ++template<typename BasicJsonType, typename T, ++ enable_if_t<std::is_convertible<BasicJsonType, T>::value, int> = 0> ++void from_json(const BasicJsonType& j, std::valarray<T>& l) ++{ ++ if (JSON_UNLIKELY(not j.is_array())) ++ { ++ JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()))); ++ } ++ l.resize(j.size()); ++ std::copy(j.m_value.array->begin(), j.m_value.array->end(), std::begin(l)); ++} ++ ++template<typename BasicJsonType, typename CompatibleArrayType> ++void from_json_array_impl(const BasicJsonType& j, CompatibleArrayType& arr, priority_tag<0> /*unused*/) ++{ ++ using std::end; ++ ++ std::transform(j.begin(), j.end(), ++ std::inserter(arr, end(arr)), [](const BasicJsonType & i) ++ { ++ // get<BasicJsonType>() returns *this, this won't call a from_json ++ // method when value_type is BasicJsonType ++ return i.template get<typename CompatibleArrayType::value_type>(); ++ }); ++} ++ ++template<typename BasicJsonType, typename CompatibleArrayType> ++auto from_json_array_impl(const BasicJsonType& j, CompatibleArrayType& arr, priority_tag<1> /*unused*/) ++-> decltype( ++ arr.reserve(std::declval<typename CompatibleArrayType::size_type>()), ++ void()) ++{ ++ using std::end; ++ ++ arr.reserve(j.size()); ++ std::transform(j.begin(), j.end(), ++ std::inserter(arr, end(arr)), [](const BasicJsonType & i) ++ { ++ // get<BasicJsonType>() returns *this, this won't call a from_json ++ // method when value_type is BasicJsonType ++ return i.template get<typename CompatibleArrayType::value_type>(); ++ }); ++} ++ ++template<typename BasicJsonType, typename T, std::size_t N> ++void from_json_array_impl(const BasicJsonType& j, std::array<T, N>& arr, priority_tag<2> /*unused*/) ++{ ++ for (std::size_t i = 0; i < N; ++i) ++ { ++ arr[i] = j.at(i).template get<T>(); ++ } ++} ++ ++template < ++ typename BasicJsonType, typename CompatibleArrayType, ++ enable_if_t < ++ is_compatible_array_type<BasicJsonType, CompatibleArrayType>::value and ++ not std::is_same<typename BasicJsonType::array_t, ++ CompatibleArrayType>::value and ++ std::is_constructible < ++ BasicJsonType, typename CompatibleArrayType::value_type >::value, ++ int > = 0 > ++void from_json(const BasicJsonType& j, CompatibleArrayType& arr) ++{ ++ if (JSON_UNLIKELY(not j.is_array())) ++ { ++ JSON_THROW(type_error::create(302, "type must be array, but is " + ++ std::string(j.type_name()))); ++ } ++ ++ from_json_array_impl(j, arr, priority_tag<2> {}); ++} ++ ++template<typename BasicJsonType, typename CompatibleObjectType, ++ enable_if_t<is_compatible_object_type<BasicJsonType, CompatibleObjectType>::value, int> = 0> ++void from_json(const BasicJsonType& j, CompatibleObjectType& obj) ++{ ++ if (JSON_UNLIKELY(not j.is_object())) ++ { ++ JSON_THROW(type_error::create(302, "type must be object, but is " + std::string(j.type_name()))); ++ } ++ ++ auto inner_object = j.template get_ptr<const typename BasicJsonType::object_t*>(); ++ using value_type = typename CompatibleObjectType::value_type; ++ std::transform( ++ inner_object->begin(), inner_object->end(), ++ std::inserter(obj, obj.begin()), ++ [](typename BasicJsonType::object_t::value_type const & p) ++ { ++ return value_type(p.first, p.second.template get<typename CompatibleObjectType::mapped_type>()); ++ }); ++} ++ ++// overload for arithmetic types, not chosen for basic_json template arguments ++// (BooleanType, etc..); note: Is it really necessary to provide explicit ++// overloads for boolean_t etc. in case of a custom BooleanType which is not ++// an arithmetic type? ++template<typename BasicJsonType, typename ArithmeticType, ++ enable_if_t < ++ std::is_arithmetic<ArithmeticType>::value and ++ not std::is_same<ArithmeticType, typename BasicJsonType::number_unsigned_t>::value and ++ not std::is_same<ArithmeticType, typename BasicJsonType::number_integer_t>::value and ++ not std::is_same<ArithmeticType, typename BasicJsonType::number_float_t>::value and ++ not std::is_same<ArithmeticType, typename BasicJsonType::boolean_t>::value, ++ int> = 0> ++void from_json(const BasicJsonType& j, ArithmeticType& val) ++{ ++ switch (static_cast<value_t>(j)) ++ { ++ case value_t::number_unsigned: ++ { ++ val = static_cast<ArithmeticType>(*j.template get_ptr<const typename BasicJsonType::number_unsigned_t*>()); ++ break; ++ } ++ case value_t::number_integer: ++ { ++ val = static_cast<ArithmeticType>(*j.template get_ptr<const typename BasicJsonType::number_integer_t*>()); ++ break; ++ } ++ case value_t::number_float: ++ { ++ val = static_cast<ArithmeticType>(*j.template get_ptr<const typename BasicJsonType::number_float_t*>()); ++ break; ++ } ++ case value_t::boolean: ++ { ++ val = static_cast<ArithmeticType>(*j.template get_ptr<const typename BasicJsonType::boolean_t*>()); ++ break; ++ } ++ ++ default: ++ JSON_THROW(type_error::create(302, "type must be number, but is " + std::string(j.type_name()))); ++ } ++} ++ ++template<typename BasicJsonType, typename A1, typename A2> ++void from_json(const BasicJsonType& j, std::pair<A1, A2>& p) ++{ ++ p = {j.at(0).template get<A1>(), j.at(1).template get<A2>()}; ++} ++ ++template<typename BasicJsonType, typename Tuple, std::size_t... Idx> ++void from_json_tuple_impl(const BasicJsonType& j, Tuple& t, index_sequence<Idx...>) ++{ ++ t = std::make_tuple(j.at(Idx).template get<typename std::tuple_element<Idx, Tuple>::type>()...); ++} ++ ++template<typename BasicJsonType, typename... Args> ++void from_json(const BasicJsonType& j, std::tuple<Args...>& t) ++{ ++ from_json_tuple_impl(j, t, index_sequence_for<Args...> {}); ++} ++ ++template <typename BasicJsonType, typename Key, typename Value, typename Compare, typename Allocator, ++ typename = enable_if_t<not std::is_constructible< ++ typename BasicJsonType::string_t, Key>::value>> ++void from_json(const BasicJsonType& j, std::map<Key, Value, Compare, Allocator>& m) ++{ ++ if (JSON_UNLIKELY(not j.is_array())) ++ { ++ JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()))); ++ } ++ for (const auto& p : j) ++ { ++ if (JSON_UNLIKELY(not p.is_array())) ++ { ++ JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(p.type_name()))); ++ } ++ m.emplace(p.at(0).template get<Key>(), p.at(1).template get<Value>()); *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201808241912.w7OJCecK044854>