From owner-svn-ports-all@freebsd.org Fri Aug 24 19:12:41 2018 Return-Path: Delivered-To: svn-ports-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 446871091C1B; Fri, 24 Aug 2018 19:12:41 +0000 (UTC) (envelope-from dch@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id EEFCD730B6; Fri, 24 Aug 2018 19:12:40 +0000 (UTC) (envelope-from dch@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D0AAE15327; Fri, 24 Aug 2018 19:12:40 +0000 (UTC) (envelope-from dch@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w7OJCeRn044859; Fri, 24 Aug 2018 19:12:40 GMT (envelope-from dch@FreeBSD.org) Received: (from dch@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w7OJCecK044854; Fri, 24 Aug 2018 19:12:40 GMT (envelope-from dch@FreeBSD.org) Message-Id: <201808241912.w7OJCecK044854@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dch set sender to dch@FreeBSD.org using -f From: Dave Cottlehuber Date: Fri, 24 Aug 2018 19:12:40 +0000 (UTC) To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r477979 - in head/net/zerotier: . files X-SVN-Group: ports-head X-SVN-Commit-Author: dch X-SVN-Commit-Paths: in head/net/zerotier: . files X-SVN-Commit-Revision: 477979 X-SVN-Commit-Repository: ports MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-ports-all@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for the ports tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 Aug 2018 19:12:41 -0000 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 . +-Copyright (c) 2013-2017 Niels Lohmann . ++SPDX-License-Identifier: MIT ++Copyright (c) 2013-2018 Niels Lohmann . + + 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 // all_of, copy, fill, find, for_each, generate_n, none_of, remove, reverse, transform +-#include // array ++#define NLOHMANN_JSON_VERSION_MAJOR 3 ++#define NLOHMANN_JSON_VERSION_MINOR 2 ++#define NLOHMANN_JSON_VERSION_PATCH 0 ++ ++#include // all_of, find, for_each + #include // assert + #include // and, not, or +-#include // lconv, localeconv +-#include // isfinite, labs, ldexp, signbit + #include // nullptr_t, ptrdiff_t, size_t +-#include // int64_t, uint64_t +-#include // abort, strtod, strtof, strtold, strtoul, strtoll, strtoull +-#include // memcpy, strlen +-#include // forward_list +-#include // function, hash, less ++#include // hash, less + #include // initializer_list +-#include // hex +-#include // istream, ostream +-#include // advance, begin, back_inserter, bidirectional_iterator_tag, distance, end, inserter, iterator, iterator_traits, next, random_access_iterator_tag, reverse_iterator +-#include // numeric_limits +-#include // locale +-#include // map +-#include // addressof, allocator, allocator_traits, unique_ptr ++#include // istream, ostream ++#include // iterator_traits, random_access_iterator_tag + #include // accumulate +-#include // stringstream +-#include // getline, stoi, string, to_string +-#include // 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 // declval, forward, make_pair, move, pair, swap +-#include // valarray ++#include // string, stoi, to_string ++#include // declval, forward, move, pair, swap ++ ++// #include ++#ifndef NLOHMANN_JSON_FWD_HPP ++#define NLOHMANN_JSON_FWD_HPP ++ ++#include // int64_t, uint64_t ++#include // map ++#include // allocator ++#include // string + #include // 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 ++struct adl_serializer; ++ ++template class ObjectType = ++ std::map, ++ template 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 class AllocatorType = std::allocator, ++ template 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 ++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 ++ ++ ++// 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 +-struct adl_serializer; +- +-// forward declaration of basic_json (required to split the class) +-template class ObjectType = std::map, +- template 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 class AllocatorType = std::allocator, +- template 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 struct has_##type { \ ++ private: \ ++ template \ ++ static int detect(U &&); \ ++ static void detect(...); \ ++ public: \ ++ static constexpr bool value = \ ++ std::is_integral()))>::value; \ ++ } ++ ++// #include ++ ++ ++#include // not ++#include // size_t ++#include // 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 ++using enable_if_t = typename std::enable_if::type; ++ ++template ++using uncvref_t = typename std::remove_cv::type>::type; ++ ++// implementation of C++14 index_sequence and affiliates ++// source: https://stackoverflow.com/a/32223343 ++template ++struct index_sequence ++{ ++ using type = index_sequence; ++ using value_type = std::size_t; ++ static constexpr std::size_t size() noexcept ++ { ++ return sizeof...(Ints); ++ } ++}; ++ ++template ++struct merge_and_renumber; ++ ++template ++struct merge_and_renumber, index_sequence> ++ : index_sequence < I1..., (sizeof...(I1) + I2)... > {}; ++ ++template ++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 ++using index_sequence_for = make_index_sequence; ++ ++/* ++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::value and has_value_type::value ++will not compile when T = void (on MSVC at least). Whereas ++conjunction>, has_value_type>::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 struct conjunction : std::true_type {}; ++template struct conjunction : B1 {}; ++template ++struct conjunction : std::conditional, B1>::type {}; ++ ++template struct negation : std::integral_constant {}; ++ ++// dispatch utility (taken from ranges-v3) ++template struct priority_tag : priority_tag < N - 1 > {}; ++template<> struct priority_tag<0> {}; ++ ++// taken from ranges-v3 ++template ++struct static_const ++{ ++ static constexpr T value{}; ++}; ++ ++template ++constexpr T static_const::value; ++} ++} ++ ++// #include ++ ++ ++#include // not ++#include // numeric_limits ++#include // false_type, is_constructible, is_integral, is_same, true_type ++#include // declval ++ ++// #include ++ ++// #include ++ ++// #include ++ ++ ++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 struct is_basic_json : std::false_type {}; ++ ++NLOHMANN_BASIC_JSON_TPL_DECLARATION ++struct is_basic_json : std::true_type {}; ++ ++//////////////////////// ++// has_/is_ functions // ++//////////////////////// ++ ++// source: https://stackoverflow.com/a/37193089/4116453 ++ ++template ++struct is_complete_type : std::false_type {}; ++ ++template ++struct is_complete_type : 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 ++struct is_compatible_object_type_impl : std::false_type {}; ++ ++template ++struct is_compatible_object_type_impl ++{ ++ static constexpr auto value = ++ std::is_constructible::value and ++ std::is_constructible::value; ++}; ++ ++template ++struct is_compatible_string_type_impl : std::false_type {}; ++ ++template ++struct is_compatible_string_type_impl ++{ ++ static constexpr auto value = ++ std::is_same::value and ++ std::is_constructible::value; ++}; ++ ++template ++struct is_compatible_object_type ++{ ++ static auto constexpr value = is_compatible_object_type_impl < ++ conjunction>, ++ has_mapped_type, ++ has_key_type>::value, ++ typename BasicJsonType::object_t, CompatibleObjectType >::value; ++}; ++ ++template ++struct is_compatible_string_type ++{ ++ static auto constexpr value = is_compatible_string_type_impl < ++ conjunction>, ++ has_value_type>::value, ++ typename BasicJsonType::string_t, CompatibleStringType >::value; ++}; ++ ++template ++struct is_basic_json_nested_type ++{ ++ static auto constexpr value = std::is_same::value or ++ std::is_same::value or ++ std::is_same::value or ++ std::is_same::value; ++}; ++ ++template ++struct is_compatible_array_type ++{ ++ static auto constexpr value = ++ conjunction>, ++ negation>, ++ negation>, ++ negation>, ++ has_value_type, ++ has_iterator>::value; ++}; ++ ++template ++struct is_compatible_integer_type_impl : std::false_type {}; ++ ++template ++struct is_compatible_integer_type_impl ++{ ++ // is there an assert somewhere on overflows? ++ using RealLimits = std::numeric_limits; ++ using CompatibleLimits = std::numeric_limits; ++ ++ static constexpr auto value = ++ std::is_constructible::value and ++ CompatibleLimits::is_integer and ++ RealLimits::is_signed == CompatibleLimits::is_signed; ++}; ++ ++template ++struct is_compatible_integer_type ++{ ++ static constexpr auto value = ++ is_compatible_integer_type_impl < ++ std::is_integral::value and ++ not std::is_same::value, ++ RealIntegerType, CompatibleNumberIntegerType > ::value; ++}; ++ ++// trait checking if JSONSerializer::from_json(json const&, udt&) exists ++template ++struct has_from_json ++{ ++ private: ++ // also check the return type of from_json ++ template::from_json( ++ std::declval(), std::declval()))>::value>> ++ static int detect(U&&); ++ static void detect(...); ++ ++ public: ++ static constexpr bool value = std::is_integral>()))>::value; ++}; ++ ++// This trait checks if JSONSerializer::from_json(json const&) exists ++// this overload is used for non-default-constructible user-defined-types ++template ++struct has_non_default_from_json ++{ ++ private: ++ template < ++ typename U, ++ typename = enable_if_t::from_json(std::declval()))>::value >> ++ static int detect(U&&); ++ static void detect(...); ++ ++ public: ++ static constexpr bool value = std::is_integral>()))>::value; ++}; ++ ++// This trait checks if BasicJsonType::json_serializer::to_json exists ++template ++struct has_to_json ++{ ++ private: ++ template::to_json( ++ std::declval(), std::declval()))> ++ static int detect(U&&); ++ static void detect(...); ++ ++ public: ++ static constexpr bool value = std::is_integral>()))>::value; ++}; ++ ++template ++struct is_compatible_complete_type ++{ ++ static constexpr bool value = ++ not std::is_base_of::value and ++ not is_basic_json::value and ++ not is_basic_json_nested_type::value and ++ has_to_json::value; ++}; ++ ++template ++struct is_compatible_type ++ : conjunction, ++ is_compatible_complete_type> ++{ ++}; ++} ++} ++ ++// #include ++ ++ ++#include // exception ++#include // runtime_error ++#include // 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 + + ++#include // array ++#include // and ++#include // size_t ++#include // 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 order = {{ ++ static constexpr std::array 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(rhs); + return l_index < order.size() and r_index < order.size() and order[l_index] < order[r_index]; + } ++} ++} + ++// #include + +-///////////// +-// helpers // +-///////////// + +-template struct is_basic_json : std::false_type {}; ++#include // transform ++#include // array ++#include // and, not ++#include // forward_list ++#include // inserter, front_inserter, end ++#include // map ++#include // string ++#include // tuple, make_tuple ++#include // is_arithmetic, is_same, is_enum, underlying_type, is_convertible ++#include // unordered_map ++#include // pair, declval ++#include // valarray + +-NLOHMANN_BASIC_JSON_TPL_DECLARATION +-struct is_basic_json : std::true_type {}; ++// #include + +-// alias templates to reduce boilerplate +-template +-using enable_if_t = typename std::enable_if::type; ++// #include + +-template +-using uncvref_t = typename std::remove_cv::type>::type; ++// #include + +-// implementation of C++14 index_sequence and affiliates +-// source: https://stackoverflow.com/a/32223343 +-template +-struct index_sequence ++// #include ++ ++// #include ++ ++ ++namespace nlohmann + { +- using type = index_sequence; +- using value_type = std::size_t; +- static constexpr std::size_t size() noexcept ++namespace detail ++{ ++template ++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::value and ++ not std::is_same::value, ++ int> = 0> ++void get_arithmetic_value(const BasicJsonType& j, ArithmeticType& val) ++{ ++ switch (static_cast(j)) ++ { ++ case value_t::number_unsigned: ++ { ++ val = static_cast(*j.template get_ptr()); ++ break; ++ } ++ case value_t::number_integer: ++ { ++ val = static_cast(*j.template get_ptr()); ++ break; ++ } ++ case value_t::number_float: ++ { ++ val = static_cast(*j.template get_ptr()); ++ break; ++ } ++ ++ default: ++ JSON_THROW(type_error::create(302, "type must be number, but is " + std::string(j.type_name()))); ++ } ++} ++ ++template ++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(); ++} ++ ++template ++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(); ++} ++ ++template < ++ typename BasicJsonType, typename CompatibleStringType, ++ enable_if_t < ++ is_compatible_string_type::value and ++ not std::is_same::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(); ++} ++ ++template ++void from_json(const BasicJsonType& j, typename BasicJsonType::number_float_t& val) ++{ ++ get_arithmetic_value(j, val); ++} ++ ++template ++void from_json(const BasicJsonType& j, typename BasicJsonType::number_unsigned_t& val) ++{ ++ get_arithmetic_value(j, val); ++} ++ ++template ++void from_json(const BasicJsonType& j, typename BasicJsonType::number_integer_t& val) ++{ ++ get_arithmetic_value(j, val); ++} ++ ++template::value, int> = 0> ++void from_json(const BasicJsonType& j, EnumType& e) ++{ ++ typename std::underlying_type::type val; ++ get_arithmetic_value(j, val); ++ e = static_cast(val); ++} ++ ++template ++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(); ++} ++ ++// forward_list doesn't have an insert method ++template::value, int> = 0> ++void from_json(const BasicJsonType& j, std::forward_list& 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(); ++ }); ++} ++ ++// valarray doesn't have an insert method ++template::value, int> = 0> ++void from_json(const BasicJsonType& j, std::valarray& 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 ++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() returns *this, this won't call a from_json ++ // method when value_type is BasicJsonType ++ return i.template get(); ++ }); ++} ++ ++template ++auto from_json_array_impl(const BasicJsonType& j, CompatibleArrayType& arr, priority_tag<1> /*unused*/) ++-> decltype( ++ arr.reserve(std::declval()), ++ void()) ++{ ++ using std::end; ++ ++ arr.reserve(j.size()); ++ std::transform(j.begin(), j.end(), ++ std::inserter(arr, end(arr)), [](const BasicJsonType & i) ++ { ++ // get() returns *this, this won't call a from_json ++ // method when value_type is BasicJsonType ++ return i.template get(); ++ }); ++} ++ ++template ++void from_json_array_impl(const BasicJsonType& j, std::array& arr, priority_tag<2> /*unused*/) ++{ ++ for (std::size_t i = 0; i < N; ++i) ++ { ++ arr[i] = j.at(i).template get(); ++ } ++} ++ ++template < ++ typename BasicJsonType, typename CompatibleArrayType, ++ enable_if_t < ++ is_compatible_array_type::value and ++ not std::is_same::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::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(); ++ 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()); ++ }); ++} ++ ++// 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::value and ++ not std::is_same::value and ++ not std::is_same::value and ++ not std::is_same::value and ++ not std::is_same::value, ++ int> = 0> ++void from_json(const BasicJsonType& j, ArithmeticType& val) ++{ ++ switch (static_cast(j)) ++ { ++ case value_t::number_unsigned: ++ { ++ val = static_cast(*j.template get_ptr()); ++ break; ++ } ++ case value_t::number_integer: ++ { ++ val = static_cast(*j.template get_ptr()); ++ break; ++ } ++ case value_t::number_float: ++ { ++ val = static_cast(*j.template get_ptr()); ++ break; ++ } ++ case value_t::boolean: ++ { ++ val = static_cast(*j.template get_ptr()); ++ break; ++ } ++ ++ default: ++ JSON_THROW(type_error::create(302, "type must be number, but is " + std::string(j.type_name()))); ++ } ++} ++ ++template ++void from_json(const BasicJsonType& j, std::pair& p) ++{ ++ p = {j.at(0).template get(), j.at(1).template get()}; ++} ++ ++template ++void from_json_tuple_impl(const BasicJsonType& j, Tuple& t, index_sequence) ++{ ++ t = std::make_tuple(j.at(Idx).template get::type>()...); ++} ++ ++template ++void from_json(const BasicJsonType& j, std::tuple& t) ++{ ++ from_json_tuple_impl(j, t, index_sequence_for {}); ++} ++ ++template ::value>> ++void from_json(const BasicJsonType& j, std::map& 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(), p.at(1).template get()); *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***