diff --git a/.azure-pipelines.yml b/.azure-pipelines.yml index d958e52e..bea33b4b 100644 --- a/.azure-pipelines.yml +++ b/.azure-pipelines.yml @@ -89,13 +89,6 @@ stages: CXX: clang++-7 PACKAGES: clang-7 LLVM_REPO: llvm-toolchain-xenial-7 - Clang 6: - B2_TOOLSET: clang - B2_CXXSTD: 03,11,14,17,2a - B2_CXXFLAGS: -stdlib=libc++ - CXX: clang++-6.0 - PACKAGES: clang-6.0 - LLVM_REPO: llvm-toolchain-xenial-6.0 Clang 6: B2_TOOLSET: clang B2_CXXSTD: 14,17,2a diff --git a/.gitignore b/.gitignore index 2aad01e8..217a2c3a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,5 @@ bin/ bin64/ -build/ *.*# # Because of CMake and VS2017 diff --git a/CMakeLists.txt b/CMakeLists.txt index 909a1486..4bcca4dd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -139,6 +139,8 @@ endif() # Tests and examples # +add_definitions(-DBOOST_JSON_HEADER_ONLY=1) + file (GLOB_RECURSE PROJECT_FILES ${PROJECT_SOURCE_DIR}/include/boost/json/*.hpp ${PROJECT_SOURCE_DIR}/include/boost/json/*.ipp diff --git a/Jamfile b/Jamfile index 8ad05233..90f8ec9d 100644 --- a/Jamfile +++ b/Jamfile @@ -1,46 +1,10 @@ # -# Copyright (c) 2019 Vinnie Falco (vinnie dot falco at gmail dot com) +# Copyright (c) 2013-2019 Vinnie Falco (vinnie dot falco at gmail dot com) # # Distributed under the Boost Software License, Version 1.0. (See accompanying # file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) # -# Official repository: https://github.com/boostorg/json +# Official repository: https://github.com/vinniefalco/json # -import ac ; -import os ; -import feature ; -import boost ; -import modules ; -import testing ; -import ../../config/checks/config : requires ; - -boost.use-project ; - -local defines = - [ requires - cxx11_constexpr - cxx11_decltype - cxx11_hdr_tuple - cxx11_template_aliases - cxx11_variadic_templates - ] - . - /boost//headers - BOOST_ALL_NO_LIB=1 - msvc-14.1:"/permissive-" - msvc-14.2:"/permissive-" - msvc,release:"/Ob2 /Oi /Ot" - msvc:"/D_ITERATOR_DEBUG_LEVEL=0" - windows:_WIN32_WINNT=0x0601 - ; - -project /boost/json - : requirements - static - $(defines) - : usage-requirements - $(defines) - ; - build-project test ; diff --git a/README.md b/README.md index 49f32054..6f291fc3 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,8 @@ Branch | Travis | Appveyor | Azure Pipelines | codecov.io | Docs | Matrix | :-------------: | ------ | -------- | --------------- | ---------- | ---- | ------ | -[`master`](https://github.com/vinniefalco/json/tree/master) | [![Build Status](https://travis-ci.org/vinniefalco/json.svg?branch=master)](https://travis-ci.org/vinniefalco/json) | [![Build status](https://ci.appveyor.com/api/projects/status/github/vinniefalco/json?branch=master&svg=true)](https://ci.appveyor.com/project/vinniefalco/fixed-string/branch/master) | [![Build Status](https://dev.azure.com/vinniefalco/fixed-string/_apis/build/status/pipeline?branchName=master)](https://dev.azure.com/vinniefalco/fixed-string/_build/latest?definitionId=6&branchName=master) | [![codecov](https://codecov.io/gh/vinniefalco/json/branch/master/graph/badge.svg)](https://codecov.io/gh/vinniefalco/json/branch/master) | [![Documentation](https://img.shields.io/badge/docs-master-brightgreen.svg)](http://www.boost.org/doc/libs/master/doc/html/json.html) | [![Matrix](https://img.shields.io/badge/matrix-master-brightgreen.svg)](http://www.boost.org/development/tests/master/developer/json.html) -[`develop`](https://github.com/vinniefalco/json/tree/develop) | [![Build Status](https://travis-ci.org/vinniefalco/json.svg?branch=develop)](https://travis-ci.org/vinniefalco/json) | [![Build status](https://ci.appveyor.com/api/projects/status/github/vinniefalco/json?branch=develop&svg=true)](https://ci.appveyor.com/project/vinniefalco/fixed-string/branch/develop) | [![Build Status](https://dev.azure.com/vinniefalco/fixed-string/_apis/build/status/pipeline?branchName=develop)](https://dev.azure.com/vinniefalco/fixed-string/_build/latest?definitionId=6&branchName=master) | [![codecov](https://codecov.io/gh/vinniefalco/json/branch/develop/graph/badge.svg)](https://codecov.io/gh/vinniefalco/json/branch/develop) | [![Documentation](https://img.shields.io/badge/docs-develop-brightgreen.svg)](http://www.boost.org/doc/libs/develop/doc/html/json.html) | [![Matrix](https://img.shields.io/badge/matrix-develop-brightgreen.svg)](http://www.boost.org/development/tests/develop/developer/json.html) +[`master`](https://github.com/vinniefalco/json/tree/master) | [![Build Status](https://travis-ci.org/vinniefalco/json.svg?branch=master)](https://travis-ci.org/vinniefalco/json) | [![Build status](https://ci.appveyor.com/api/projects/status/github/vinniefalco/json?branch=master&svg=true)](https://ci.appveyor.com/project/vinniefalco/json/branch/master) | [![Build Status](https://dev.azure.com/vinniefalco/json/_apis/build/status/pipeline?branchName=master)](https://dev.azure.com/vinniefalco/json/_build/latest?definitionId=6&branchName=master) | [![codecov](https://codecov.io/gh/vinniefalco/json/branch/master/graph/badge.svg)](https://codecov.io/gh/vinniefalco/json/branch/master) | [![Documentation](https://img.shields.io/badge/docs-master-brightgreen.svg)](http://www.boost.org/doc/libs/master/doc/html/json.html) | [![Matrix](https://img.shields.io/badge/matrix-master-brightgreen.svg)](http://www.boost.org/development/tests/master/developer/json.html) +[`develop`](https://github.com/vinniefalco/json/tree/develop) | [![Build Status](https://travis-ci.org/vinniefalco/json.svg?branch=develop)](https://travis-ci.org/vinniefalco/json) | [![Build status](https://ci.appveyor.com/api/projects/status/github/vinniefalco/json?branch=develop&svg=true)](https://ci.appveyor.com/project/vinniefalco/json/branch/develop) | [![Build Status](https://dev.azure.com/vinniefalco/json/_apis/build/status/pipeline?branchName=develop)](https://dev.azure.com/vinniefalco/json/_build/latest?definitionId=6&branchName=master) | [![codecov](https://codecov.io/gh/vinniefalco/json/branch/develop/graph/badge.svg)](https://codecov.io/gh/vinniefalco/json/branch/develop) | [![Documentation](https://img.shields.io/badge/docs-develop-brightgreen.svg)](http://www.boost.org/doc/libs/develop/doc/html/json.html) | [![Matrix](https://img.shields.io/badge/matrix-develop-brightgreen.svg)](http://www.boost.org/development/tests/develop/developer/json.html) ## This is currently **NOT** an official Boost library. diff --git a/build/Jamfile b/build/Jamfile new file mode 100644 index 00000000..3fd86a01 --- /dev/null +++ b/build/Jamfile @@ -0,0 +1,31 @@ +# +# Copyright (c) 2019 Vinnie Falco (vinnie dot falco at gmail dot com) +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# Official repository: https://github.com/boostorg/json +# + +project boost/json + : requirements + shared:BOOST_JSON_DYN_LINK=1 + static:BOOST_JSON_STATIC_LINK=1 + BOOST_JSON_SOURCE + : usage-requirements + shared:BOOST_JSON_DYN_LINK=1 + static:BOOST_JSON_STATIC_LINK=1 + : source-location ../src + ; + +alias json_sources + : src.cpp + ; + +explicit json_sources ; + +lib boost_json + : json_sources + ; + +boost-install boost_json ; diff --git a/doc/source.dox b/doc/source.dox index 6242cf96..6fdaaebd 100644 --- a/doc/source.dox +++ b/doc/source.dox @@ -53,6 +53,7 @@ INCLUDE_FILE_PATTERNS = PREDEFINED = \ GENERATING_DOCUMENTATION \ BOOST_JSON_DECL \ + BOOST_JSON_PUBLIC \ "BOOST_JSON_INLINE_VARIABLE(v, t)= " EXPAND_AS_DEFINED = diff --git a/include/boost/json/array.hpp b/include/boost/json/array.hpp index e2af199e..5fb10416 100644 --- a/include/boost/json/array.hpp +++ b/include/boost/json/array.hpp @@ -73,7 +73,7 @@ class value; ReversibleContainer, and SequenceContainer. */ -class array +class BOOST_SYMBOL_VISIBLE array { struct table; @@ -1559,11 +1559,11 @@ private: const_iterator pos, Arg&& arg); - BOOST_JSON_DECL + inline void copy(array const& other); - BOOST_JSON_DECL + inline void assign(std::initializer_list init); }; diff --git a/include/boost/json/basic_parser.hpp b/include/boost/json/basic_parser.hpp index c728029a..a36f264d 100644 --- a/include/boost/json/basic_parser.hpp +++ b/include/boost/json/basic_parser.hpp @@ -27,7 +27,7 @@ namespace json { /** A parser for serialized JSON */ -class basic_parser +class BOOST_SYMBOL_VISIBLE basic_parser #ifndef GENERATING_DOCUMENTATION : private detail::parser_base #endif @@ -45,14 +45,14 @@ class basic_parser bool n_exp_neg_; bool is_key_; - BOOST_JSON_DECL + inline static bool append_digit( number::mantissa_type* value, char digit); - BOOST_JSON_DECL + inline static bool append_digit( @@ -120,58 +120,70 @@ protected: BOOST_JSON_DECL basic_parser(); + BOOST_JSON_DECL virtual void on_document_begin(error_code& ec) = 0; + BOOST_JSON_DECL virtual void on_object_begin(error_code& ec) = 0; + BOOST_JSON_DECL virtual void on_object_end(error_code& ec) = 0; + BOOST_JSON_DECL virtual void on_array_begin(error_code& ec) = 0; + BOOST_JSON_DECL virtual void on_array_end(error_code& ec) = 0; + BOOST_JSON_DECL virtual void on_key_data( string_view s, error_code& ec) = 0; + BOOST_JSON_DECL virtual void on_key_end( string_view s, error_code& ec) = 0; + BOOST_JSON_DECL virtual void on_string_data( string_view s, error_code& ec) = 0; + BOOST_JSON_DECL virtual void on_string_end( string_view, error_code& ec) = 0; + BOOST_JSON_DECL virtual void on_number(number n, error_code& ec) = 0; + BOOST_JSON_DECL virtual void on_bool(bool b, error_code& ec) = 0; + BOOST_JSON_DECL virtual void on_null(error_code& ec) = 0; @@ -181,7 +193,7 @@ protected: } // boost #include -#if BOOST_JSON_HEADER_ONLY +#ifdef BOOST_JSON_HEADER_ONLY #include #endif diff --git a/include/boost/json/detail/config.hpp b/include/boost/json/detail/config.hpp index 71226621..98252445 100644 --- a/include/boost/json/detail/config.hpp +++ b/include/boost/json/detail/config.hpp @@ -10,20 +10,32 @@ #ifndef BOOST_JSON_DETAIL_CONFIG_HPP #define BOOST_JSON_DETAIL_CONFIG_HPP -// Default to a header-only implementation. The user must specifically -// request separate compilation by defining BOOST_JSON_SEPARATE_COMPILATION -#ifndef BOOST_JSON_HEADER_ONLY -# ifndef BOOST_JSON_SEPARATE_COMPILATION -# define BOOST_JSON_HEADER_ONLY 1 -# endif -#endif +#include -#if GENERATING_DOCUMENTATION +#if defined(GENERATING_DOCUMENTATION) # define BOOST_JSON_DECL #elif defined(BOOST_JSON_HEADER_ONLY) # define BOOST_JSON_DECL inline +# define BOOST_JSON_PUBLIC #else -# define BOOST_JSON_DECL +# if (defined(BOOST_JSON_DYN_LINK) || defined(BOOST_ALL_DYN_LINK)) && !defined(BOOST_JSON_STATIC_LINK) +# if defined(BOOST_JSON_SOURCE) +# define BOOST_JSON_DECL BOOST_SYMBOL_EXPORT +# define BOOST_JSON_BUILD_DLL +# else +# define BOOST_JSON_DECL BOOST_SYMBOL_IMPORT +# endif +# endif // shared lib +# ifndef BOOST_JSON_DECL +# define BOOST_JSON_DECL +# endif +# if !defined(BOOST_JSON_SOURCE) && !defined(BOOST_ALL_NO_LIB) && !defined(BOOST_JSON_NO_LIB) +# define BOOST_LIB_NAME boost_json +# if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_JSON_DYN_LINK) +# define BOOST_DYN_LINK +# endif +# include +# endif // auto-linking disabled #endif #endif diff --git a/include/boost/json/detail/varint.hpp b/include/boost/json/detail/varint.hpp index 49a30489..abd44d74 100644 --- a/include/boost/json/detail/varint.hpp +++ b/include/boost/json/detail/varint.hpp @@ -10,6 +10,7 @@ #ifndef BOOST_JSON_DETAIL_VARINT_HPP #define BOOST_JSON_DETAIL_VARINT_HPP +#include #include #include #include @@ -18,26 +19,60 @@ namespace boost { namespace json { namespace detail { -BOOST_JSON_DECL +inline int -varint_size(std::uint64_t value); +varint_size(std::uint64_t value) +{ + int n = 1; + while(value > 127) + { + ++n; + value /= 128; + } + return n; +} -BOOST_JSON_DECL +inline std::pair -varint_read(void const* src); +varint_read(void const* src) +{ + auto cp0 = reinterpret_cast< + unsigned char const*>(src); + auto cp = cp0; + std::size_t value = 0; + std::size_t factor = 1; + while(*cp > 127) + { + value += (*cp++ & 0x7f) * factor; + factor *= 128; + } + value += *cp++ * factor; + return {value, + static_cast(cp - cp0)}; +} -BOOST_JSON_DECL +inline int varint_write( void* dest, - std::uint64_t value); + std::uint64_t value) +{ + auto cp0 = reinterpret_cast< + unsigned char*>(dest); + auto cp = cp0; + while(value > 127) + { + *cp++ = static_cast< + unsigned char>(value & 0x7f); + value >>= 7; + } + *cp++ = static_cast< + unsigned char>(value); + return static_cast(cp - cp0); +} } // detail } // json } // boost -#ifdef BOOST_JSON_HEADER_ONLY -#include -#endif - #endif diff --git a/include/boost/json/detail/varint.ipp b/include/boost/json/detail/varint.ipp deleted file mode 100644 index eca077cd..00000000 --- a/include/boost/json/detail/varint.ipp +++ /dev/null @@ -1,73 +0,0 @@ -// -// Copyright (c) 2018-2019 Vinnie Falco (vinnie dot falco at gmail dot com) -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// -// Official repository: https://github.com/vinniefalco/json -// - -#ifndef BOOST_JSON_DETAIL_VARINT_IPP -#define BOOST_JSON_DETAIL_VARINT_IPP - -#include -#include - -namespace boost { -namespace json { -namespace detail { - -int -varint_size(std::uint64_t value) -{ - int n = 1; - while(value > 127) - { - ++n; - value /= 128; - } - return n; -} - -std::pair -varint_read(void const* src) -{ - auto cp0 = reinterpret_cast< - unsigned char const*>(src); - auto cp = cp0; - std::size_t value = 0; - std::size_t factor = 1; - while(*cp > 127) - { - value += (*cp++ & 0x7f) * factor; - factor *= 128; - } - value += *cp++ * factor; - return {value, - static_cast(cp - cp0)}; -} - -int -varint_write( - void* dest, - std::uint64_t value) -{ - auto cp0 = reinterpret_cast< - unsigned char*>(dest); - auto cp = cp0; - while(value > 127) - { - *cp++ = static_cast< - unsigned char>(value & 0x7f); - value >>= 7; - } - *cp++ = static_cast< - unsigned char>(value); - return static_cast(cp - cp0); -} - -} // detail -} // json -} // boost - -#endif diff --git a/include/boost/json/impl/array.hpp b/include/boost/json/impl/array.hpp index d7c93508..2de8a6dd 100644 --- a/include/boost/json/impl/array.hpp +++ b/include/boost/json/impl/array.hpp @@ -135,7 +135,13 @@ struct array::undo_insert template void - emplace(Arg&& arg); + emplace(Arg&& arg) + { + ::new(it) value( + std::forward(arg), + self.sp_); + ++it; + } }; //------------------------------------------------------------------------------ diff --git a/include/boost/json/impl/array.ipp b/include/boost/json/impl/array.ipp index a3cf0c24..21dbe8cf 100644 --- a/include/boost/json/impl/array.ipp +++ b/include/boost/json/impl/array.ipp @@ -180,18 +180,6 @@ undo_insert( self.tab_->d.size += n; } -template -void -array:: -undo_insert:: -emplace(Arg&& arg) -{ - ::new(it) value( - std::forward(arg), - self.sp_); - ++it; -} - //------------------------------------------------------------------------------ // // Special Members diff --git a/include/boost/json/impl/object.hpp b/include/boost/json/impl/object.hpp index 53567709..591e17b8 100644 --- a/include/boost/json/impl/object.hpp +++ b/include/boost/json/impl/object.hpp @@ -60,7 +60,7 @@ struct object::element : list_hook //------------------------------------------------------------------------------ -class object::undo_range +class BOOST_SYMBOL_VISIBLE object::undo_range { object& self_; element* head_ = nullptr; @@ -88,15 +88,15 @@ public: //------------------------------------------------------------------------------ -class object::hasher +class BOOST_SYMBOL_VISIBLE object::hasher { - BOOST_JSON_DECL + inline static std::pair< std::uint64_t, std::uint64_t> init(std::true_type) noexcept; - BOOST_JSON_DECL + inline static std::pair< std::uint32_t, std::uint32_t> @@ -110,9 +110,10 @@ public: //------------------------------------------------------------------------------ -class object::key_equal +class BOOST_SYMBOL_VISIBLE object::key_equal { public: + BOOST_JSON_DECL bool operator()( string_view lhs, @@ -124,16 +125,18 @@ public: //------------------------------------------------------------------------------ -class object::pointer +class BOOST_SYMBOL_VISIBLE object::pointer { reference t_; public: + BOOST_JSON_DECL pointer(reference t) : t_(t) { } + BOOST_JSON_DECL reference* operator->() noexcept { @@ -143,17 +146,19 @@ public: //------------------------------------------------------------------------------ -class object::const_pointer +class BOOST_SYMBOL_VISIBLE object::const_pointer { const_reference t_; public: + BOOST_JSON_DECL const_pointer( const_reference t) : t_(t) { } + BOOST_JSON_DECL const_reference* operator->() noexcept { @@ -163,12 +168,13 @@ public: //------------------------------------------------------------------------------ -class object::const_iterator +class BOOST_SYMBOL_VISIBLE object::const_iterator { element* e_ = nullptr; friend class object; + BOOST_JSON_DECL const_iterator(element* e) : e_(e) { @@ -182,14 +188,15 @@ public: using iterator_category = std::bidirectional_iterator_tag; - const_iterator() = default; - const_iterator(const_iterator const&) = default; - const_iterator& operator=(const_iterator const&) = default; + BOOST_JSON_DECL const_iterator() = default; + BOOST_JSON_DECL const_iterator(const_iterator const&) = default; + BOOST_JSON_DECL const_iterator& operator=(const_iterator const&) = default; - const_iterator(iterator it) noexcept; - const_iterator(local_iterator it) noexcept; - const_iterator(const_local_iterator it) noexcept; + BOOST_JSON_DECL const_iterator(iterator it) noexcept; + BOOST_JSON_DECL const_iterator(local_iterator it) noexcept; + BOOST_JSON_DECL const_iterator(const_local_iterator it) noexcept; + BOOST_JSON_DECL const_iterator& operator++() noexcept { @@ -197,6 +204,7 @@ public: return *this; } + BOOST_JSON_DECL const_iterator operator++(int) noexcept { @@ -205,6 +213,7 @@ public: return tmp; } + BOOST_JSON_DECL const_iterator& operator--() noexcept { @@ -212,6 +221,7 @@ public: return *this; } + BOOST_JSON_DECL const_iterator operator--(int) noexcept { @@ -220,6 +230,7 @@ public: return tmp; } + BOOST_JSON_DECL pointer operator->() const noexcept { @@ -227,6 +238,7 @@ public: e_->key(), e_->v }; } + BOOST_JSON_DECL reference operator*() const noexcept { @@ -234,12 +246,14 @@ public: e_->key(), e_->v }; } + BOOST_JSON_DECL bool operator==(const_iterator other) const noexcept { return e_ == other.e_; } + BOOST_JSON_DECL bool operator!=(const_iterator other) const noexcept { @@ -268,12 +282,13 @@ public: using iterator_category = std::bidirectional_iterator_tag; - iterator() = default; - iterator(iterator const&) = default; - iterator& operator=(iterator const&) = default; + BOOST_JSON_DECL iterator() = default; + BOOST_JSON_DECL iterator(iterator const&) = default; + BOOST_JSON_DECL iterator& operator=(iterator const&) = default; - iterator(local_iterator it) noexcept; + BOOST_JSON_DECL iterator(local_iterator it) noexcept; + BOOST_JSON_DECL iterator& operator++() noexcept { @@ -281,6 +296,7 @@ public: return *this; } + BOOST_JSON_DECL iterator operator++(int) noexcept { @@ -289,6 +305,7 @@ public: return tmp; } + BOOST_JSON_DECL iterator& operator--() noexcept { @@ -296,6 +313,7 @@ public: return *this; } + BOOST_JSON_DECL iterator operator--(int) noexcept { @@ -304,6 +322,7 @@ public: return tmp; } + BOOST_JSON_DECL pointer operator->() const noexcept { @@ -311,6 +330,7 @@ public: e_->key(), e_->v }; } + BOOST_JSON_DECL reference operator*() const noexcept { @@ -318,12 +338,14 @@ public: e_->key(), e_->v }; } + BOOST_JSON_DECL bool operator==(const_iterator other) const noexcept { return const_iterator(*this) == other; } + BOOST_JSON_DECL bool operator!=(const_iterator other) const noexcept { @@ -333,7 +355,7 @@ public: //------------------------------------------------------------------------------ -class object::local_iterator +class BOOST_SYMBOL_VISIBLE object::local_iterator { element* e_ = nullptr; @@ -352,12 +374,11 @@ public: using iterator_category = std::forward_iterator_tag; - local_iterator() = default; - local_iterator( - local_iterator const&) = default; - local_iterator& - operator=(local_iterator const&) = default; + BOOST_JSON_DECL local_iterator() = default; + BOOST_JSON_DECL local_iterator(local_iterator const&) = default; + BOOST_JSON_DECL local_iterator& operator=(local_iterator const&) = default; + BOOST_JSON_DECL local_iterator& operator++() noexcept { @@ -365,6 +386,7 @@ public: return *this; } + BOOST_JSON_DECL local_iterator operator++(int) noexcept { @@ -373,6 +395,7 @@ public: return tmp; } + BOOST_JSON_DECL const_pointer operator->() const noexcept { @@ -380,6 +403,7 @@ public: e_->key(), e_->v }; } + BOOST_JSON_DECL const_reference operator*() const noexcept { @@ -387,12 +411,14 @@ public: e_->key(), e_->v }; } + BOOST_JSON_DECL bool operator==(const_iterator other) const noexcept { return const_iterator(*this) == other; } + BOOST_JSON_DECL bool operator!=(const_iterator other) const noexcept { @@ -402,12 +428,13 @@ public: //------------------------------------------------------------------------------ -class object::const_local_iterator +class BOOST_SYMBOL_VISIBLE object::const_local_iterator { element* e_ = nullptr; friend class object; + BOOST_JSON_DECL const_local_iterator(element* e) : e_(e) { @@ -421,15 +448,14 @@ public: using iterator_category = std::forward_iterator_tag; - const_local_iterator() = default; - const_local_iterator( - const_local_iterator const&) = default; - const_local_iterator& - operator=( + BOOST_JSON_DECL const_local_iterator() = default; + BOOST_JSON_DECL const_local_iterator(const_local_iterator const&) = default; + BOOST_JSON_DECL const_local_iterator& operator=( const_local_iterator const&) = default; - const_local_iterator(local_iterator it) noexcept; + BOOST_JSON_DECL const_local_iterator(local_iterator it) noexcept; + BOOST_JSON_DECL const_local_iterator& operator++() noexcept { @@ -437,6 +463,7 @@ public: return *this; } + BOOST_JSON_DECL const_local_iterator operator++(int) noexcept { @@ -445,6 +472,7 @@ public: return tmp; } + BOOST_JSON_DECL const_pointer operator->() const noexcept { @@ -452,6 +480,7 @@ public: e_->key(), e_->v }; } + BOOST_JSON_DECL const_reference operator*() const noexcept { @@ -459,12 +488,14 @@ public: e_->key(), e_->v }; } + BOOST_JSON_DECL bool operator==(const_iterator other) const noexcept { return const_iterator(*this) == other; } + BOOST_JSON_DECL bool operator!=(const_iterator other) const noexcept { @@ -474,54 +505,7 @@ public: //------------------------------------------------------------------------------ -inline -object:: -const_iterator:: -const_iterator( - iterator it) noexcept - : e_(it.e_) -{ -} - -inline -object:: -const_iterator:: -const_iterator( - local_iterator it) noexcept - : e_(it.e_) -{ -} - -inline -object:: -const_iterator:: -const_iterator( - const_local_iterator it) noexcept - : e_(it.e_) -{ -} - -inline -object:: -iterator:: -iterator( - local_iterator it) noexcept - : e_(it.e_) -{ -} - -inline -object:: -const_local_iterator:: -const_local_iterator( - local_iterator it) noexcept - : e_(it.e_) -{ -} - -//------------------------------------------------------------------------------ - -class object::node_type +class BOOST_SYMBOL_VISIBLE object::node_type { element* e_ = nullptr; storage_ptr sp_; @@ -537,8 +521,8 @@ public: using key_type = string_view; using mapped_type = json::value; - node_type() = default; - node_type(node_type const&) = delete; + BOOST_JSON_DECL node_type() = default; + BOOST_JSON_DECL node_type(node_type const&) = delete; BOOST_JSON_DECL ~node_type(); @@ -551,42 +535,49 @@ public: node_type& operator=(node_type&& other) noexcept; + BOOST_JSON_DECL storage_ptr const& get_storage() const noexcept { return sp_; } + BOOST_JSON_DECL bool empty() const noexcept { return e_ == nullptr; } + BOOST_JSON_DECL explicit operator bool() const noexcept { return ! empty(); } + BOOST_JSON_DECL key_type const key() const { return e_->key(); } + BOOST_JSON_DECL mapped_type& mapped() { return e_->v; } + BOOST_JSON_DECL mapped_type const& mapped() const { return e_->v; } + BOOST_JSON_DECL void swap(node_type& other) noexcept { @@ -595,18 +586,15 @@ public: } }; -inline +BOOST_JSON_DECL void swap( object::node_type& lhs, - object::node_type& rhs) noexcept -{ - lhs.swap(rhs); -} + object::node_type& rhs) noexcept; //------------------------------------------------------------------------------ -struct object::insert_return_type +struct BOOST_SYMBOL_VISIBLE object::insert_return_type { iterator position; node_type node; @@ -779,29 +767,11 @@ emplace( return { iterator(e), true }; } -inline -auto -object:: -hash_function() const noexcept -> - hasher -{ - return hasher{}; -} - -inline -auto -object:: -key_eq() const noexcept -> - key_equal -{ - return key_equal{}; -} - //------------------------------------------------------------------------------ // type-erased constructor to // reduce template instantiations. -struct object::construct_base +struct BOOST_SYMBOL_VISIBLE object::construct_base { virtual ~construct_base() = default; diff --git a/include/boost/json/impl/object.ipp b/include/boost/json/impl/object.ipp index bedae5d6..c4d5c97d 100644 --- a/include/boost/json/impl/object.ipp +++ b/include/boost/json/impl/object.ipp @@ -338,6 +338,60 @@ operator=(node_type&& other) noexcept -> return *this; } +void +swap( + object::node_type& lhs, + object::node_type& rhs) noexcept +{ + lhs.swap(rhs); +} + +//------------------------------------------------------------------------------ +// +// Iterators +// +//------------------------------------------------------------------------------ + +object:: +const_iterator:: +const_iterator( + iterator it) noexcept + : e_(it.e_) +{ +} + +object:: +const_iterator:: +const_iterator( + local_iterator it) noexcept + : e_(it.e_) +{ +} + +object:: +const_iterator:: +const_iterator( + const_local_iterator it) noexcept + : e_(it.e_) +{ +} + +object:: +iterator:: +iterator( + local_iterator it) noexcept + : e_(it.e_) +{ +} + +object:: +const_local_iterator:: +const_local_iterator( + local_iterator it) noexcept + : e_(it.e_) +{ +} + //------------------------------------------------------------------------------ // // Special Members @@ -1240,6 +1294,24 @@ reserve(size_type n) //------------------------------------------------------------------------------ +auto +object:: +hash_function() const noexcept -> + hasher +{ + return hasher{}; +} + +auto +object:: +key_eq() const noexcept -> + key_equal +{ + return key_equal{}; +} + +//------------------------------------------------------------------------------ + // allocate a new element auto object:: @@ -1417,6 +1489,12 @@ remove(element* e) --tab_->size; } +void +swap(object& lhs, object& rhs) +{ + lhs.swap(rhs); +} + } // json } // boost diff --git a/include/boost/json/impl/storage.ipp b/include/boost/json/impl/storage.ipp index 21c230f9..9009b923 100644 --- a/include/boost/json/impl/storage.ipp +++ b/include/boost/json/impl/storage.ipp @@ -52,6 +52,44 @@ default_storage(storage_ptr sp) noexcept detail::raw_default_storage() = std::move(sp); } +//------------------------------------------------------------------------------ + +bool +operator==(storage_ptr const& lhs, storage_ptr const& rhs) noexcept +{ + return lhs.get() == rhs.get(); +} + +bool +operator==(storage* lhs, storage_ptr const& rhs) noexcept +{ + return lhs == rhs.get(); +} + +bool +operator==(storage_ptr const& lhs, storage* rhs) noexcept +{ + return lhs.get() == rhs; +} + +bool +operator!=(storage_ptr const& lhs, storage_ptr const& rhs) noexcept +{ + return lhs.get() != rhs.get(); +} + +bool +operator!=(storage* lhs, storage_ptr const& rhs) noexcept +{ + return lhs != rhs.get(); +} + +bool +operator!=(storage_ptr const& lhs, storage* rhs) noexcept +{ + return lhs.get() != rhs; +} + } // json } // boost diff --git a/include/boost/json/impl/string.hpp b/include/boost/json/impl/string.hpp index 02914722..4544e86a 100644 --- a/include/boost/json/impl/string.hpp +++ b/include/boost/json/impl/string.hpp @@ -20,70 +20,6 @@ namespace json { //------------------------------------------------------------------------------ -auto -string:: -impl:: -growth( - size_type new_size, - size_type capacity) -> - size_type -{ - if(new_size > max_size_) - BOOST_THROW_EXCEPTION( - std::length_error( - "size > max_size()")); - new_size |= mask_; - if( new_size > max_size_) - return max_size_; - if( capacity > - max_size_ - capacity / 2) - return max_size_; // overflow - return (std::max)(new_size, - capacity + capacity / 2); -} - -void -string:: -impl:: -destroy( - storage_ptr const& sp) -{ - if(! in_sbo()) - sp->deallocate( - p, capacity + 1, 1); -} - -void -string:: -impl:: -construct() noexcept -{ - size = 0; - capacity = sizeof(buf) - 1; - buf[0] = 0; -} - -char* -string:: -impl:: -construct( - size_type new_size, - storage_ptr const& sp) -{ - if(new_size < sizeof(buf)) - { - // SBO - capacity = sizeof(buf) - 1; - return buf; - } - - capacity = growth(new_size, - sizeof(buf) - 1); - p = static_cast( - sp->allocate(capacity + 1, 1)); - return p; -} - template void string:: @@ -142,111 +78,6 @@ construct( u.commit = true; } -char* -string:: -impl:: -assign( - size_type new_size, - storage_ptr const& sp) -{ - if(new_size > capacity) - { - impl tmp; - tmp.construct(growth( - new_size, capacity), sp); - destroy(sp); - *this = tmp; - } - term(new_size); - return data(); -} - -char* -string:: -impl:: -append( - size_type n, - storage_ptr const& sp) -{ - if(n > max_size_ - size) - BOOST_THROW_EXCEPTION( - std::length_error( - "size > max_size()")); - if(n <= capacity - size) - { - term(size + n); - return end() - n; - } - impl tmp; - traits_type::copy( - tmp.construct(growth( - size + n, capacity), sp), - data(), size); - tmp.term(size + n); - destroy(sp); - *this = tmp; - return end() - n; -} - -char* -string:: -impl:: -insert( - size_type pos, - size_type n, - storage_ptr const& sp) -{ - if(pos > size) - BOOST_THROW_EXCEPTION( - std::out_of_range( - "pos > size()")); - if(n <= capacity - size) - { - auto const dest = - data() + pos; - traits_type::move( - dest + n, - dest, - size + 1 - pos); - size += n; - return dest; - } - if(n > max_size_ - size) - BOOST_THROW_EXCEPTION( - std::length_error( - "size > max_size()")); - impl tmp; - tmp.construct(growth( - size + n, capacity), sp); - tmp.size = size + n; - traits_type::copy( - tmp.data(), - data(), - pos); - traits_type::copy( - tmp.data() + pos + n, - data() + pos, - size + 1 - pos); - destroy(sp); - *this = tmp; - return data() + pos; -} - -void -string:: -impl:: -unalloc(storage_ptr const& sp) noexcept -{ - BOOST_ASSERT(size < sizeof(buf)); - BOOST_ASSERT(! in_sbo()); - auto const p_ = p; - traits_type::copy( - buf, data(), size + 1); - sp->deallocate( - p_, capacity + 1, 1); - capacity = sizeof(buf) - 1; -} - //------------------------------------------------------------------------------ template diff --git a/include/boost/json/impl/string.ipp b/include/boost/json/impl/string.ipp index 94a682d6..a1f2c440 100644 --- a/include/boost/json/impl/string.ipp +++ b/include/boost/json/impl/string.ipp @@ -22,6 +22,180 @@ namespace boost { namespace json { +//------------------------------------------------------------------------------ + +auto +string:: +impl:: +growth( + size_type new_size, + impl_size_type capacity) -> + impl_size_type +{ + if(new_size > max_size_) + BOOST_THROW_EXCEPTION( + std::length_error( + "size > max_size()")); + new_size |= mask_; + if( new_size > max_size_) + return max_size_; + if( capacity > + max_size_ - capacity / 2) + return max_size_; // overflow + return (std::max)( + capacity + capacity / 2, + new_size); +} + +void +string:: +impl:: +destroy( + storage_ptr const& sp) +{ + if(! in_sbo()) + sp->deallocate( + p, capacity + 1, 1); +} + +void +string:: +impl:: +construct() noexcept +{ + size = 0; + capacity = sizeof(buf) - 1; + buf[0] = 0; +} + +char* +string:: +impl:: +construct( + size_type new_size, + storage_ptr const& sp) +{ + if(new_size < sizeof(buf)) + { + // SBO + capacity = sizeof(buf) - 1; + return buf; + } + + capacity = growth(new_size, + sizeof(buf) - 1); + p = static_cast( + sp->allocate(capacity + 1, 1)); + return p; +} + +char* +string:: +impl:: +assign( + size_type new_size, + storage_ptr const& sp) +{ + if(new_size > capacity) + { + impl tmp; + tmp.construct(growth( + new_size, capacity), sp); + destroy(sp); + *this = tmp; + } + term(new_size); + return data(); +} + +char* +string:: +impl:: +append( + size_type n, + storage_ptr const& sp) +{ + if(n > max_size_ - size) + BOOST_THROW_EXCEPTION( + std::length_error( + "size > max_size()")); + if(n <= capacity - size) + { + term(size + n); + return end() - n; + } + impl tmp; + traits_type::copy( + tmp.construct(growth( + size + n, capacity), sp), + data(), size); + tmp.term(size + n); + destroy(sp); + *this = tmp; + return end() - n; +} + +char* +string:: +impl:: +insert( + size_type pos, + size_type n, + storage_ptr const& sp) +{ + if(pos > size) + BOOST_THROW_EXCEPTION( + std::out_of_range( + "pos > size()")); + if(n <= capacity - size) + { + auto const dest = + data() + pos; + traits_type::move( + dest + n, + dest, + size + 1 - pos); + size += n; + return dest; + } + if(n > max_size_ - size) + BOOST_THROW_EXCEPTION( + std::length_error( + "size > max_size()")); + impl tmp; + tmp.construct(growth( + size + n, capacity), sp); + tmp.size = size + n; + traits_type::copy( + tmp.data(), + data(), + pos); + traits_type::copy( + tmp.data() + pos + n, + data() + pos, + size + 1 - pos); + destroy(sp); + *this = tmp; + return data() + pos; +} + +void +string:: +impl:: +unalloc(storage_ptr const& sp) noexcept +{ + BOOST_ASSERT(size < sizeof(buf)); + BOOST_ASSERT(! in_sbo()); + auto const p_ = p; + traits_type::copy( + buf, data(), size + 1); + sp->deallocate( + p_, capacity + 1, 1); + capacity = sizeof(buf) - 1; +} + +//------------------------------------------------------------------------------ + string:: ~string() { diff --git a/include/boost/json/iterator.hpp b/include/boost/json/iterator.hpp index f0bdc304..3c426a08 100644 --- a/include/boost/json/iterator.hpp +++ b/include/boost/json/iterator.hpp @@ -28,7 +28,7 @@ BOOST_JSON_INLINE_VARIABLE(end, end_t) /** A generator to perform a depth-first traversal of a JSON value. */ -class const_iterator +class BOOST_SYMBOL_VISIBLE const_iterator { #ifndef GENERATING_DOCUMENTATION struct node @@ -91,18 +91,21 @@ public: const_iterator& operator++() noexcept; + BOOST_JSON_DECL void operator++(int) noexcept { ++*this; } + BOOST_JSON_DECL value_type operator->() const noexcept { return *(*this); } + BOOST_JSON_DECL friend bool operator==( @@ -112,6 +115,7 @@ public: return lhs.stack_.empty(); } + BOOST_JSON_DECL friend bool operator==( @@ -121,6 +125,7 @@ public: return rhs.stack_.empty(); } + BOOST_JSON_DECL friend bool operator!=( @@ -130,6 +135,7 @@ public: return ! lhs.stack_.empty(); } + BOOST_JSON_DECL friend bool operator!=( @@ -143,7 +149,7 @@ public: } // json } // boost -#if BOOST_JSON_HEADER_ONLY +#ifdef BOOST_JSON_HEADER_ONLY #include #endif diff --git a/include/boost/json/number.hpp b/include/boost/json/number.hpp index 7b7b6ac7..4b76d82a 100644 --- a/include/boost/json/number.hpp +++ b/include/boost/json/number.hpp @@ -21,7 +21,7 @@ namespace json { /** The representation of parsed numbers. */ -class number +class BOOST_SYMBOL_VISIBLE number { struct base10_ieee { @@ -185,30 +185,33 @@ public: private: struct pow10; - BOOST_JSON_DECL + inline void assign_signed( long long i) noexcept; - BOOST_JSON_DECL + inline void assign_unsigned( unsigned long long i) noexcept; - BOOST_JSON_DECL + inline void assign_double(double f) noexcept; + BOOST_JSON_DECL friend std::ostream& operator<<(std::ostream& os, number const& n); + BOOST_JSON_DECL friend bool operator==( number const& lhs, number const& rhs) noexcept; + BOOST_JSON_DECL friend bool operator!=( diff --git a/include/boost/json/object.hpp b/include/boost/json/object.hpp index 00d99c1b..ea02139a 100644 --- a/include/boost/json/object.hpp +++ b/include/boost/json/object.hpp @@ -54,17 +54,8 @@ class value; SequenceContainer, and UnorderedAssociativeContainer. */ -class object +class BOOST_SYMBOL_VISIBLE object { - struct list_hook; - struct element; - struct table; - class undo_range; - - storage_ptr sp_; - table* tab_ = nullptr; - float mf_ = 1.0; - public: /// The type of keys using key_type = string_view; @@ -150,16 +141,16 @@ public: }; #else - class hasher; - class key_equal; - class pointer; - class const_pointer; - class iterator; - class const_iterator; - class local_iterator; - class const_local_iterator; - class node_type; - struct insert_return_type; + class BOOST_SYMBOL_VISIBLE hasher; + class BOOST_SYMBOL_VISIBLE key_equal; + class BOOST_SYMBOL_VISIBLE pointer; + class BOOST_SYMBOL_VISIBLE const_pointer; + class BOOST_SYMBOL_VISIBLE iterator; + class BOOST_SYMBOL_VISIBLE const_iterator; + class BOOST_SYMBOL_VISIBLE local_iterator; + class BOOST_SYMBOL_VISIBLE const_local_iterator; + class BOOST_SYMBOL_VISIBLE node_type; + struct BOOST_SYMBOL_VISIBLE insert_return_type; #endif #if 0 @@ -175,6 +166,23 @@ public: /// The value type of initializer lists using init_value = std::pair; +private: + struct list_hook; + struct element; + struct table; + class undo_range; + + storage_ptr sp_; + table* tab_ = nullptr; + float mf_ = 1.0; + + template + using is_inputit = typename std::enable_if< + std::is_convertible::value_type, + const_reference>::value>::type; + +public: //-------------------------------------------------------------------------- /** Destroy the container @@ -313,14 +321,9 @@ public: template< class InputIt #ifndef GENERATING_DOCUMENTATION - ,class = typename std::enable_if< - std::is_convertible< - typename std::iterator_traits< - InputIt>::value_type, - const_reference>::value>::type + ,class = is_inputit #endif > - BOOST_JSON_DECL object( InputIt first, InputIt last); @@ -365,14 +368,9 @@ public: template< class InputIt #ifndef GENERATING_DOCUMENTATION - ,class = typename std::enable_if< - std::is_convertible< - typename std::iterator_traits< - InputIt>::value_type, - const_reference>::value>::type + ,class = is_inputit #endif > - BOOST_JSON_DECL object( InputIt first, InputIt last, @@ -416,14 +414,9 @@ public: template< class InputIt #ifndef GENERATING_DOCUMENTATION - ,class = typename std::enable_if< - std::is_convertible< - typename std::iterator_traits< - InputIt>::value_type, - const_reference>::value>::type + ,class = is_inputit #endif > - BOOST_JSON_DECL object( InputIt first, InputIt last, @@ -472,14 +465,9 @@ public: template< class InputIt #ifndef GENERATING_DOCUMENTATION - ,class = typename std::enable_if< - std::is_convertible< - typename std::iterator_traits< - InputIt>::value_type, - const_reference>::value>::type + ,class = is_inputit #endif > - BOOST_JSON_DECL object( InputIt first, InputIt last, @@ -1114,11 +1102,7 @@ public: template< class InputIt #ifndef GENERATING_DOCUMENTATION - ,class = typename std::enable_if< - std::is_convertible< - typename std::iterator_traits< - InputIt>::value_type, - const_reference>::value>::type + ,class = is_inputit #endif > void @@ -1164,11 +1148,7 @@ public: template< class InputIt #ifndef GENERATING_DOCUMENTATION - ,class = typename std::enable_if< - std::is_convertible< - typename std::iterator_traits< - InputIt>::value_type, - const_reference>::value>::type + ,class = is_inputit #endif > void @@ -2146,8 +2126,9 @@ private: size_type bucket_count) noexcept; BOOST_JSON_DECL - std::pair - find_impl(key_type key) const noexcept; + auto + find_impl(key_type key) const noexcept -> + std::pair; BOOST_JSON_DECL void @@ -2169,12 +2150,9 @@ private: remove(element* e); }; -inline +BOOST_JSON_DECL void -swap(object& lhs, object& rhs) -{ - lhs.swap(rhs); -} +swap(object& lhs, object& rhs); } // json } // boost diff --git a/include/boost/json/parser.hpp b/include/boost/json/parser.hpp index a611585a..14c26185 100644 --- a/include/boost/json/parser.hpp +++ b/include/boost/json/parser.hpp @@ -21,7 +21,8 @@ namespace boost { namespace json { -class parser : public basic_parser +class BOOST_SYMBOL_VISIBLE parser + : public basic_parser { static std::size_t const default_max_depth = 32; @@ -70,7 +71,7 @@ private: void assign(T&& t); - BOOST_JSON_DECL + inline void reset(); diff --git a/include/boost/json/serializer.hpp b/include/boost/json/serializer.hpp index a2994cf0..f9707b11 100644 --- a/include/boost/json/serializer.hpp +++ b/include/boost/json/serializer.hpp @@ -19,7 +19,7 @@ namespace boost { namespace json { -class serializer +class BOOST_SYMBOL_VISIBLE serializer { struct base { @@ -56,24 +56,24 @@ class serializer bool last_; public: - BOOST_JSON_DECL + inline impl(value const& jv); - BOOST_JSON_DECL + inline bool is_done() const noexcept override; - BOOST_JSON_DECL + inline std::size_t next(boost::asio::mutable_buffer) override; private: - BOOST_JSON_DECL + inline void append(char c, boost::asio::mutable_buffer& b); - BOOST_JSON_DECL + inline void append( char const* s, std::size_t n, diff --git a/include/boost/json/lib.hpp b/include/boost/json/src.hpp similarity index 89% rename from include/boost/json/lib.hpp rename to include/boost/json/src.hpp index 6dd676de..089280f3 100644 --- a/include/boost/json/lib.hpp +++ b/include/boost/json/src.hpp @@ -7,8 +7,8 @@ // Official repository: https://github.com/vinniefalco/json // -#ifndef BOOST_JSON_LIB_HPP -#define BOOST_JSON_LIB_HPP +#ifndef BOOST_JSON_SRC_HPP +#define BOOST_JSON_SRC_HPP /* @@ -17,15 +17,12 @@ the program, with the macro BOOST_BEAST_SPLIT_COMPILATION defined. */ -#define BOOST_JSON_SOURCE - #include #if defined(BOOST_JSON_HEADER_ONLY) # error Do not compile library source with the header only macro defined #endif -#include #include #include #include @@ -36,6 +33,7 @@ the program, with the macro BOOST_BEAST_SPLIT_COMPILATION defined. #include #include #include +#include #include #endif diff --git a/include/boost/json/storage.hpp b/include/boost/json/storage.hpp index f2b84c8b..77761bcd 100644 --- a/include/boost/json/storage.hpp +++ b/include/boost/json/storage.hpp @@ -24,7 +24,7 @@ namespace json { /** Abstract interface to a memory resource used with JSON. */ -class storage +class BOOST_SYMBOL_VISIBLE storage { template friend class basic_storage_ptr; @@ -233,47 +233,29 @@ public: using storage_ptr = basic_storage_ptr; -inline +BOOST_JSON_DECL bool -operator==(storage_ptr const& lhs, storage_ptr const& rhs) noexcept -{ - return lhs.get() == rhs.get(); -} +operator==(storage_ptr const& lhs, storage_ptr const& rhs) noexcept; -inline +BOOST_JSON_DECL bool -operator==(storage* lhs, storage_ptr const& rhs) noexcept -{ - return lhs == rhs.get(); -} +operator==(storage* lhs, storage_ptr const& rhs) noexcept; -inline +BOOST_JSON_DECL bool -operator==(storage_ptr const& lhs, storage* rhs) noexcept -{ - return lhs.get() == rhs; -} +operator==(storage_ptr const& lhs, storage* rhs) noexcept; -inline +BOOST_JSON_DECL bool -operator!=(storage_ptr const& lhs, storage_ptr const& rhs) noexcept -{ - return lhs.get() != rhs.get(); -} +operator!=(storage_ptr const& lhs, storage_ptr const& rhs) noexcept; -inline +BOOST_JSON_DECL bool -operator!=(storage* lhs, storage_ptr const& rhs) noexcept -{ - return lhs != rhs.get(); -} +operator!=(storage* lhs, storage_ptr const& rhs) noexcept; -inline +BOOST_JSON_DECL bool -operator!=(storage_ptr const& lhs, storage* rhs) noexcept -{ - return lhs.get() != rhs; -} +operator!=(storage_ptr const& lhs, storage* rhs) noexcept; //------------------------------------------------------------------------------ diff --git a/include/boost/json/string.hpp b/include/boost/json/string.hpp index ff3ae007..4bdb11aa 100644 --- a/include/boost/json/string.hpp +++ b/include/boost/json/string.hpp @@ -39,7 +39,7 @@ using is_viewy = typename std::enable_if< /** The native type of string values */ -class string +class BOOST_SYMBOL_VISIBLE string { public: using traits_type = std::char_traits; @@ -141,10 +141,10 @@ private: BOOST_JSON_DECL static - size_type + impl_size_type growth( size_type new_size, - size_type capacity); + impl_size_type capacity); BOOST_JSON_DECL void @@ -1789,7 +1789,7 @@ operator<<(std::ostream& os, string const& s); } // boost #include -#if BOOST_JSON_HEADER_ONLY +#ifdef BOOST_JSON_HEADER_ONLY #include #endif diff --git a/test/lib.cpp b/src/src.cpp similarity index 81% rename from test/lib.cpp rename to src/src.cpp index 2032ae0b..516d5f0a 100644 --- a/test/lib.cpp +++ b/src/src.cpp @@ -7,4 +7,6 @@ // Official repository: https://github.com/vinniefalco/json // -//#include +#ifndef BOOST_JSON_HEADER_ONLY +#include +#endif diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 3deaadea..2c28b296 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -18,9 +18,9 @@ add_executable (json-tests ${PROJECT_FILES} ${PROJECT_SOURCE_DIR}/include/boost/json.hpp ${PROJECT_SOURCE_DIR}/include/boost/pilfer.hpp + ${PROJECT_SOURCE_DIR}/src/src.cpp Jamfile test_storage.hpp - lib.cpp main.cpp _detail_stack.cpp allocator.cpp diff --git a/test/Jamfile b/test/Jamfile index fcb1bc2c..4a2b55a4 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -7,6 +7,24 @@ # Official repository: https://github.com/vinniefalco/json # +import testing ; +import ../../config/checks/config : requires ; + +project + : requirements + /boost/json//boost_json + [ requires + cxx11_constexpr + cxx11_decltype + cxx11_hdr_tuple + cxx11_template_aliases + cxx11_variadic_templates + ] + msvc-14.1:"/permissive-" + msvc-14.2:"/permissive-" + windows:_WIN32_WINNT=0x0601 + ; + local SOURCES = _detail_stack.cpp allocator.cpp @@ -29,24 +47,9 @@ local SOURCES = ; local RUN_TESTS ; - for local f in $(SOURCES) { - RUN_TESTS += [ run $(f) lib.cpp main.cpp ] ; + RUN_TESTS += [ run $(f) main.cpp ] ; } alias run-tests : $(RUN_TESTS) ; - -exe fat-tests : - $(SOURCES) - lib.cpp - main.cpp - ; - -explicit fat-tests ; - -run $(SOURCES) - lib.cpp - : : : : run-fat-tests ; - -explicit run-fat-tests ; diff --git a/test/object.cpp b/test/object.cpp index 44f3fcc3..8e6e0b55 100644 --- a/test/object.cpp +++ b/test/object.cpp @@ -12,6 +12,7 @@ #include #include +#include #include #include "test_storage.hpp"