├── .github └── workflows │ ├── ci-macos.yml │ └── ci.yml ├── .gitignore ├── .travis.yml ├── CMakeLists.txt ├── Config.cmake.in ├── LICENSE ├── README.md ├── appveyor.yml ├── cereal.pc.in ├── doc ├── CMakeLists.txt ├── DoxygenLayout.xml ├── doxygen.in ├── footer.html └── mainpage.dox ├── include └── cereal │ ├── access.hpp │ ├── archives │ ├── adapters.hpp │ ├── binary.hpp │ ├── json.hpp │ ├── portable_binary.hpp │ └── xml.hpp │ ├── cereal.hpp │ ├── details │ ├── helpers.hpp │ ├── polymorphic_impl.hpp │ ├── polymorphic_impl_fwd.hpp │ ├── static_object.hpp │ ├── traits.hpp │ └── util.hpp │ ├── external │ ├── LICENSE │ ├── base64.hpp │ ├── rapidjson │ │ ├── LICENSE │ │ ├── allocators.h │ │ ├── cursorstreamwrapper.h │ │ ├── document.h │ │ ├── encodedstream.h │ │ ├── encodings.h │ │ ├── error │ │ │ ├── en.h │ │ │ └── error.h │ │ ├── filereadstream.h │ │ ├── filewritestream.h │ │ ├── fwd.h │ │ ├── internal │ │ │ ├── biginteger.h │ │ │ ├── diyfp.h │ │ │ ├── dtoa.h │ │ │ ├── ieee754.h │ │ │ ├── itoa.h │ │ │ ├── meta.h │ │ │ ├── pow10.h │ │ │ ├── regex.h │ │ │ ├── stack.h │ │ │ ├── strfunc.h │ │ │ ├── strtod.h │ │ │ └── swap.h │ │ ├── istreamwrapper.h │ │ ├── memorybuffer.h │ │ ├── memorystream.h │ │ ├── msinttypes │ │ │ ├── LICENSE │ │ │ ├── inttypes.h │ │ │ └── stdint.h │ │ ├── ostreamwrapper.h │ │ ├── pointer.h │ │ ├── prettywriter.h │ │ ├── rapidjson.h │ │ ├── reader.h │ │ ├── schema.h │ │ ├── stream.h │ │ ├── stringbuffer.h │ │ └── writer.h │ └── rapidxml │ │ ├── license.txt │ │ ├── manual.html │ │ ├── rapidxml.hpp │ │ ├── rapidxml_iterators.hpp │ │ ├── rapidxml_print.hpp │ │ └── rapidxml_utils.hpp │ ├── macros.hpp │ ├── specialize.hpp │ ├── types │ ├── array.hpp │ ├── atomic.hpp │ ├── base_class.hpp │ ├── bitset.hpp │ ├── boost_variant.hpp │ ├── chrono.hpp │ ├── common.hpp │ ├── complex.hpp │ ├── concepts │ │ └── pair_associative_container.hpp │ ├── deque.hpp │ ├── forward_list.hpp │ ├── functional.hpp │ ├── list.hpp │ ├── map.hpp │ ├── memory.hpp │ ├── optional.hpp │ ├── polymorphic.hpp │ ├── queue.hpp │ ├── set.hpp │ ├── stack.hpp │ ├── string.hpp │ ├── tuple.hpp │ ├── unordered_map.hpp │ ├── unordered_set.hpp │ ├── utility.hpp │ ├── valarray.hpp │ ├── variant.hpp │ └── vector.hpp │ └── version.hpp ├── sandbox ├── CMakeLists.txt ├── performance.cpp ├── sandbox.cpp ├── sandbox_json.cpp ├── sandbox_rtti.cpp ├── sandbox_shared_lib │ ├── CMakeLists.txt │ ├── base.cpp │ ├── base.hpp │ ├── derived.cpp │ └── derived.hpp └── sandbox_vs.cpp ├── scripts ├── add_rapidjson_prefix.sh ├── appveyor.bat ├── renameincludes.sh ├── updatecoverage.sh └── updatedoc.in └── unittests ├── CMakeLists.txt ├── array.cpp ├── array.hpp ├── atomic.cpp ├── atomic.hpp ├── basic_string.cpp ├── basic_string.hpp ├── bitset.cpp ├── bitset.hpp ├── boost ├── CMakeLists.txt ├── boost_variant.cpp └── boost_variant.hpp ├── chrono.cpp ├── chrono.hpp ├── cmake-config-module.cmake ├── common.hpp ├── complex.cpp ├── complex.hpp ├── cpp17 ├── CMakeLists.txt ├── optional.cpp ├── optional.hpp ├── variant.cpp └── variant.hpp ├── defer.cpp ├── defer.hpp ├── deque.cpp ├── deque.hpp ├── doctest.h ├── forward_list.cpp ├── forward_list.hpp ├── list.cpp ├── list.hpp ├── load_construct.cpp ├── load_construct.hpp ├── map.cpp ├── map.hpp ├── memory.cpp ├── memory.hpp ├── memory_cycles.cpp ├── memory_cycles.hpp ├── multimap.cpp ├── multimap.hpp ├── multiset.cpp ├── multiset.hpp ├── pair.cpp ├── pair.hpp ├── pod.cpp ├── pod.hpp ├── polymorphic.cpp ├── polymorphic.hpp ├── portability_test.cpp ├── portable_binary_archive.cpp ├── portable_binary_archive.hpp ├── priority_queue.cpp ├── priority_queue.hpp ├── queue.cpp ├── queue.hpp ├── run_portability_test.cmake ├── run_valgrind.sh ├── set.cpp ├── set.hpp ├── stack.cpp ├── stack.hpp ├── structs.cpp ├── structs.hpp ├── structs_minimal.cpp ├── structs_minimal.hpp ├── structs_specialized.cpp ├── structs_specialized.hpp ├── tuple.cpp ├── tuple.hpp ├── unordered_loads.cpp ├── unordered_loads.hpp ├── unordered_map.cpp ├── unordered_map.hpp ├── unordered_multimap.cpp ├── unordered_multimap.hpp ├── unordered_multiset.cpp ├── unordered_multiset.hpp ├── unordered_set.cpp ├── unordered_set.hpp ├── user_data_adapters.cpp ├── user_data_adapters.hpp ├── valarray.cpp ├── valarray.hpp ├── vector.cpp ├── vector.hpp ├── versioning.cpp └── versioning.hpp /.github/workflows/ci-macos.yml: -------------------------------------------------------------------------------- 1 | name: cereal mac ci 2 | on: [push, pull_request] 3 | 4 | jobs: 5 | test_cereal_macos: 6 | runs-on: macos-latest 7 | strategy: 8 | fail-fast: false 9 | matrix: 10 | include: 11 | - CMAKE_OPTIONS: '-DWITH_WERROR=OFF -DSKIP_PORTABILITY_TEST=ON -DSKIP_PERFORMANCE_COMPARISON=ON' 12 | COMPILER: 'clang++' 13 | XCODE_VERSION: 15 14 | NAME: macos-latest-clang-xcode15 15 | 16 | - CMAKE_OPTIONS: '-DWITH_WERROR=OFF -DSKIP_PORTABILITY_TEST=ON -DSKIP_PERFORMANCE_COMPARISON=ON' 17 | COMPILER: 'clang++' 18 | XCODE_VERSION: 16 19 | NAME: macos-latest-clang-xcode16 20 | name: ${{ matrix.name }} 21 | 22 | steps: 23 | - name: Checkout code 24 | uses: actions/checkout@v4 25 | 26 | - uses: maxim-lobanov/setup-xcode@v1 27 | with: 28 | xcode-version: ${{ matrix.XCODE_VERSION }} 29 | 30 | - name: build and test 31 | shell: bash 32 | env: 33 | CMAKE_OPTIONS: ${{ matrix.CMAKE_OPTIONS }} 34 | COMPILER: ${{ matrix.COMPILER }} 35 | run: | 36 | set -ex 37 | # Set compiler and env variables 38 | export CXX=${COMPILER} 39 | ${CXX} --version 40 | 41 | # Build cereal and test 42 | cmake --version 43 | mkdir build && cd build 44 | cmake ${CMAKE_OPTIONS} .. && make -j4 VERBOSE=1 45 | ctest . --output-on-failure 46 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files 2 | *.slo 3 | *.lo 4 | *.o 5 | 6 | # Compiled Dynamic libraries 7 | *.so 8 | *.dylib 9 | 10 | # Compiled Static libraries 11 | *.lai 12 | *.la 13 | *.a 14 | 15 | # Visual studio cruft 16 | *.opensdf 17 | *.sdf 18 | *.suo 19 | *.user 20 | */x64 21 | *\Debug* 22 | *\Release* 23 | *.log 24 | *.tlog* 25 | *.obj 26 | *.VC.db 27 | *.VC.VC.opendb 28 | *.pdb 29 | *.idb 30 | *\build_* 31 | .vs/ 32 | CMakeSettings.json 33 | 34 | # misc files mostly used for testing 35 | out.txt 36 | ptr.txt 37 | test.txt 38 | boost_serialize 39 | arr.txt 40 | performance 41 | include_renamed 42 | .ycm_extra_conf.py* 43 | doc/html 44 | rtti.txt 45 | doc/latex 46 | portability64 47 | portability32 48 | file.json 49 | out.xml 50 | cereal_version.out 51 | xml_ordering.out 52 | build 53 | /out/ -------------------------------------------------------------------------------- /Config.cmake.in: -------------------------------------------------------------------------------- 1 | @PACKAGE_INIT@ 2 | 3 | include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake") 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013-2022, Randolph Voorhies, Shane Grant 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the name of the copyright holder nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | cereal - A C++11 library for serialization 2 | ========================================== 3 | 4 |

cereal is a header-only C++11 serialization library. cereal takes arbitrary data types and reversibly turns them into different representations, such as compact binary encodings, XML, or JSON. cereal was designed to be fast, light-weight, and easy to extend - it has no external dependencies and can be easily bundled with other code or used standalone.

5 | 6 | ### cereal has great documentation 7 | 8 | Looking for more information on how cereal works and its documentation? Visit [cereal's web page](https://USCiLab.github.io/cereal) to get the latest information. 9 | 10 | ### cereal is easy to use 11 | 12 | Installation and use of of cereal is fully documented on the [main web page](https://USCiLab.github.io/cereal), but this is a quick and dirty version: 13 | 14 | * Download cereal and place the headers somewhere your code can see them 15 | * Write serialization functions for your custom types or use the built in support for the standard library cereal provides 16 | * Use the serialization archives to load and save data 17 | 18 | ```cpp 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | struct MyRecord 25 | { 26 | uint8_t x, y; 27 | float z; 28 | 29 | template 30 | void serialize( Archive & ar ) 31 | { 32 | ar( x, y, z ); 33 | } 34 | }; 35 | 36 | struct SomeData 37 | { 38 | int32_t id; 39 | std::shared_ptr> data; 40 | 41 | template 42 | void save( Archive & ar ) const 43 | { 44 | ar( data ); 45 | } 46 | 47 | template 48 | void load( Archive & ar ) 49 | { 50 | static int32_t idGen = 0; 51 | id = idGen++; 52 | ar( data ); 53 | } 54 | }; 55 | 56 | int main() 57 | { 58 | std::ofstream os("out.cereal", std::ios::binary); 59 | cereal::BinaryOutputArchive archive( os ); 60 | 61 | SomeData myData; 62 | archive( myData ); 63 | 64 | return 0; 65 | } 66 | ``` 67 | 68 | ### cereal has a mailing list 69 | 70 | Either get in touch over email or [on the web](https://groups.google.com/forum/#!forum/cerealcpp). 71 | 72 | 73 | 74 | ## cereal has a permissive license 75 | 76 | cereal is licensed under the [BSD license](http://opensource.org/licenses/BSD-3-Clause). 77 | 78 | ## cereal build status 79 | 80 | * [![Linux build status](https://github.com/USCiLab/cereal/actions/workflows/ci.yml/badge.svg)](https://github.com/USCiLab/cereal/actions/workflows/ci.yml) 81 | * [![Mac build status](https://github.com/USCiLab/cereal/actions/workflows/ci-macos.yml/badge.svg)](https://github.com/USCiLab/cereal/actions/workflows/ci-macos.yml) 82 | * [![Windows build status](https://ci.appveyor.com/api/projects/status/91aou6smj36or0vb/branch/master?svg=true)](https://ci.appveyor.com/project/AzothAmmo/cereal/branch/master) 83 | 84 | --- 85 | 86 | Were you looking for the Haskell cereal? Go here. 87 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | # can use variables like {build} and {branch} 2 | version: 1.3.{build} 3 | pull_requests: 4 | do_not_increment_build_number: true 5 | 6 | branches: 7 | only: 8 | - master 9 | 10 | configuration: 11 | - Debug 12 | - Release 13 | 14 | environment: 15 | matrix: 16 | - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013 17 | VS_VERSION_MAJOR: 12 18 | BOOST_ROOT: C:\Libraries\boost_1_58_0 19 | - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 20 | VS_VERSION_MAJOR: 14 21 | BOOST_ROOT: C:\Libraries\boost_1_60_0 22 | - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 23 | VS_VERSION_MAJOR: 15 24 | BOOST_ROOT: C:\Libraries\boost_1_66_0 25 | - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 26 | VS_VERSION_MAJOR: 16 27 | BOOST_ROOT: C:\Libraries\boost_1_73_0 28 | - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2022 29 | VS_VERSION_MAJOR: 17 30 | BOOST_ROOT: C:\Libraries\boost_1_73_0 31 | 32 | matrix: 33 | exclude: 34 | - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 35 | platform: Win32 36 | 37 | - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2022 38 | platform: Win32 39 | 40 | platform: 41 | - Win32 42 | - x64 43 | 44 | before_build: "scripts\\appveyor.bat" 45 | 46 | build: 47 | parallel: true 48 | project: build/cereal.sln 49 | verbosity: minimal 50 | 51 | test_script: "scripts\\appveyor.bat test" 52 | 53 | artifacts: 54 | - path: build\Testing 55 | - path: out 56 | -------------------------------------------------------------------------------- /cereal.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@CMAKE_INSTALL_PREFIX@ 2 | includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@ 3 | 4 | Name: @PROJECT_NAME@ 5 | Description: cereal is a header-only C++11 serialization library 6 | URL: https://uscilab.github.io/cereal/ 7 | Version: @PROJECT_VERSION@ 8 | Cflags: -I"${includedir}" 9 | -------------------------------------------------------------------------------- /doc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | find_package(Doxygen) 2 | if(DOXYGEN_FOUND) 3 | 4 | configure_file("${CMAKE_CURRENT_SOURCE_DIR}/doxygen.in" "${CMAKE_CURRENT_BINARY_DIR}/doxygen.cfg" @ONLY) 5 | add_custom_target(doc 6 | COMMAND ${DOXYGEN_EXECUTABLE} "${CMAKE_CURRENT_BINARY_DIR}/doxygen.cfg" 7 | WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/.." 8 | COMMENT "Generating API documentation with Doxygen" VERBATIM 9 | ) 10 | 11 | configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../scripts/updatedoc.in" "${CMAKE_CURRENT_BINARY_DIR}/updatedoc.sh" @ONLY) 12 | add_custom_target(update-doc 13 | COMMAND "${CMAKE_CURRENT_BINARY_DIR}/updatedoc.sh" 14 | DEPENDS doc 15 | COMMENT "Copying documentation to gh-pages branch" VERBATIM 16 | ) 17 | 18 | endif() 19 | -------------------------------------------------------------------------------- /doc/footer.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 12 | 13 | 14 | 19 | 20 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /doc/mainpage.dox: -------------------------------------------------------------------------------- 1 | /** 2 | \mainpage cereal code documentation 3 | 4 | \tableofcontents 5 | 6 | Aside from the documentation presented on the main cereal site, this doxygen 7 | page offers code level documentation. 8 | 9 | \section modules Browse modules 10 | 11 | cereal's code is organized into modules of similar functionality. Take a look at the modules 12 | section to learn more. Average users will not need to understand the workings of any code that falls under the 13 | internal module. 14 | 15 | \section files Browse files 16 | 17 | If you need reference on a specific file, the files page lists all files in cereal. 18 | */ 19 | 20 | //! \defgroup Archives Input and Output Archive Types 21 | 22 | /*! \defgroup Access Access Control and Disambiguation 23 | Provides ways to give cereal access to protected member functions, disambiguate 24 | which serialization function cereal should use, and provide ways of using smart 25 | pointers with types that have no default constructor. */ 26 | 27 | /*! \defgroup Utility Utility Functionality 28 | Name-value pairs, binary data wrappers, exceptions, and other utility functions */ 29 | 30 | /*! \defgroup TypeSupport Support for Serializing Various Types 31 | Serialization of many types is shipped with cereal, including most of the standard library as well as a few others. */ 32 | 33 | /*! \defgroup STLSupport Standard Library Support 34 | Serialization methods for nearly all types found in the C++ standard library. 35 | \ingroup TypeSupport */ 36 | 37 | /*! \defgroup TypeConcepts Abstract Type Concept Support 38 | Serialization methods for more abstract type concepts that can generalize over many types. 39 | \ingroup TypeSupport */ 40 | 41 | /*! \defgroup OtherTypes Miscellaneous Types Support 42 | Support for various other types such as smart pointers to polymorphic base classes, boost::variant, etc. 43 | \ingroup TypeSupport */ 44 | 45 | /*! \defgroup Internal Internal Functionality 46 | Various classes and functions that are critical for the operation of cereal but of no 47 | interest to users */ 48 | -------------------------------------------------------------------------------- /include/cereal/details/polymorphic_impl_fwd.hpp: -------------------------------------------------------------------------------- 1 | /*! \file polymorphic_impl_fwd.hpp 2 | \brief Internal polymorphism support forward declarations 3 | \ingroup Internal */ 4 | /* 5 | Copyright (c) 2014, Randolph Voorhies, Shane Grant 6 | All rights reserved. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | * Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | * Redistributions in binary form must reproduce the above copyright 13 | notice, this list of conditions and the following disclaimer in the 14 | documentation and/or other materials provided with the distribution. 15 | * Neither the name of the copyright holder nor the 16 | names of its contributors may be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY 23 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | /* This code is heavily inspired by the boost serialization implementation by the following authors 32 | 33 | (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . 34 | Use, modification and distribution is subject to the Boost Software 35 | License, Version 1.0. (See http://www.boost.org/LICENSE_1_0.txt) 36 | 37 | See http://www.boost.org for updates, documentation, and revision history. 38 | 39 | (C) Copyright 2006 David Abrahams - http://www.boost.org. 40 | 41 | See /boost/serialization/export.hpp and /boost/archive/detail/register_archive.hpp for their 42 | implementation. 43 | */ 44 | 45 | #ifndef CEREAL_DETAILS_POLYMORPHIC_IMPL_FWD_HPP_ 46 | #define CEREAL_DETAILS_POLYMORPHIC_IMPL_FWD_HPP_ 47 | 48 | namespace cereal 49 | { 50 | namespace detail 51 | { 52 | //! Forward declaration, see polymorphic_impl.hpp for more information 53 | template 54 | struct RegisterPolymorphicCaster; 55 | 56 | //! Forward declaration, see polymorphic_impl.hpp for more information 57 | struct PolymorphicCasters; 58 | 59 | //! Forward declaration, see polymorphic_impl.hpp for more information 60 | template 61 | struct PolymorphicRelation; 62 | } // namespace detail 63 | } // namespace cereal 64 | 65 | #endif // CEREAL_DETAILS_POLYMORPHIC_IMPL_FWD_HPP_ 66 | -------------------------------------------------------------------------------- /include/cereal/details/util.hpp: -------------------------------------------------------------------------------- 1 | /*! \file util.hpp 2 | \brief Internal misc utilities 3 | \ingroup Internal */ 4 | /* 5 | Copyright (c) 2014, Randolph Voorhies, Shane Grant 6 | All rights reserved. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | * Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | * Redistributions in binary form must reproduce the above copyright 13 | notice, this list of conditions and the following disclaimer in the 14 | documentation and/or other materials provided with the distribution. 15 | * Neither the name of the copyright holder nor the 16 | names of its contributors may be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY 23 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | #ifndef CEREAL_DETAILS_UTIL_HPP_ 31 | #define CEREAL_DETAILS_UTIL_HPP_ 32 | 33 | #include 34 | #include 35 | 36 | #ifdef _MSC_VER 37 | namespace cereal 38 | { 39 | namespace util 40 | { 41 | //! Demangles the type encoded in a string 42 | /*! @internal */ 43 | inline std::string demangle( std::string const & name ) 44 | { return name; } 45 | 46 | //! Gets the demangled name of a type 47 | /*! @internal */ 48 | template inline 49 | std::string demangledName() 50 | { return typeid( T ).name(); } 51 | } // namespace util 52 | } // namespace cereal 53 | #else // clang or gcc 54 | #include 55 | #include 56 | namespace cereal 57 | { 58 | namespace util 59 | { 60 | //! Demangles the type encoded in a string 61 | /*! @internal */ 62 | inline std::string demangle(std::string mangledName) 63 | { 64 | int status = 0; 65 | char *demangledName = nullptr; 66 | std::size_t len; 67 | 68 | demangledName = abi::__cxa_demangle(mangledName.c_str(), 0, &len, &status); 69 | 70 | std::string retName(demangledName); 71 | free(demangledName); 72 | 73 | return retName; 74 | } 75 | 76 | //! Gets the demangled name of a type 77 | /*! @internal */ 78 | template inline 79 | std::string demangledName() 80 | { return demangle(typeid(T).name()); } 81 | } 82 | } // namespace cereal 83 | #endif // clang or gcc branch of _MSC_VER 84 | #endif // CEREAL_DETAILS_UTIL_HPP_ 85 | -------------------------------------------------------------------------------- /include/cereal/external/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (C) 2004-2008 René Nyffenegger 2 | 3 | This source code is provided 'as-is', without any express or implied 4 | warranty. In no event will the author be held liable for any damages 5 | arising from the use of this software. 6 | 7 | Permission is granted to anyone to use this software for any purpose, 8 | including commercial applications, and to alter it and redistribute it 9 | freely, subject to the following restrictions: 10 | 11 | 1. The origin of this source code must not be misrepresented; you must not 12 | claim that you wrote the original source code. If you use this source code 13 | in a product, an acknowledgment in the product documentation would be 14 | appreciated but is not required. 15 | 16 | 2. Altered source versions must be plainly marked as such, and must not be 17 | misrepresented as being the original source code. 18 | 19 | 3. This notice may not be removed or altered from any source distribution. 20 | 21 | René Nyffenegger rene.nyffenegger@adp-gmbh.ch 22 | -------------------------------------------------------------------------------- /include/cereal/external/rapidjson/LICENSE: -------------------------------------------------------------------------------- 1 | Tencent is pleased to support the open source community by making RapidJSON available. 2 | 3 | Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. 4 | 5 | Licensed under the MIT License (the "License"); you may not use this file except 6 | in compliance with the License. You may obtain a copy of the License at 7 | 8 | http://opensource.org/licenses/MIT 9 | 10 | Unless required by applicable law or agreed to in writing, software distributed 11 | under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | specific language governing permissions and limitations under the License. 14 | -------------------------------------------------------------------------------- /include/cereal/external/rapidjson/cursorstreamwrapper.h: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making RapidJSON available. 2 | // 3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. 4 | // 5 | // Licensed under the MIT License (the "License"); you may not use this file except 6 | // in compliance with the License. You may obtain a copy of the License at 7 | // 8 | // http://opensource.org/licenses/MIT 9 | // 10 | // Unless required by applicable law or agreed to in writing, software distributed 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | // specific language governing permissions and limitations under the License. 14 | 15 | #ifndef CEREAL_RAPIDJSON_CURSORSTREAMWRAPPER_H_ 16 | #define CEREAL_RAPIDJSON_CURSORSTREAMWRAPPER_H_ 17 | 18 | #include "stream.h" 19 | 20 | #if defined(__GNUC__) 21 | CEREAL_RAPIDJSON_DIAG_PUSH 22 | CEREAL_RAPIDJSON_DIAG_OFF(effc++) 23 | #endif 24 | 25 | #if defined(_MSC_VER) && _MSC_VER <= 1800 26 | CEREAL_RAPIDJSON_DIAG_PUSH 27 | CEREAL_RAPIDJSON_DIAG_OFF(4702) // unreachable code 28 | CEREAL_RAPIDJSON_DIAG_OFF(4512) // assignment operator could not be generated 29 | #endif 30 | 31 | CEREAL_RAPIDJSON_NAMESPACE_BEGIN 32 | 33 | 34 | //! Cursor stream wrapper for counting line and column number if error exists. 35 | /*! 36 | \tparam InputStream Any stream that implements Stream Concept 37 | */ 38 | template > 39 | class CursorStreamWrapper : public GenericStreamWrapper { 40 | public: 41 | typedef typename Encoding::Ch Ch; 42 | 43 | CursorStreamWrapper(InputStream& is): 44 | GenericStreamWrapper(is), line_(1), col_(0) {} 45 | 46 | // counting line and column number 47 | Ch Take() { 48 | Ch ch = this->is_.Take(); 49 | if(ch == '\n') { 50 | line_ ++; 51 | col_ = 0; 52 | } else { 53 | col_ ++; 54 | } 55 | return ch; 56 | } 57 | 58 | //! Get the error line number, if error exists. 59 | size_t GetLine() const { return line_; } 60 | //! Get the error column number, if error exists. 61 | size_t GetColumn() const { return col_; } 62 | 63 | private: 64 | size_t line_; //!< Current Line 65 | size_t col_; //!< Current Column 66 | }; 67 | 68 | #if defined(_MSC_VER) && _MSC_VER <= 1800 69 | CEREAL_RAPIDJSON_DIAG_POP 70 | #endif 71 | 72 | #if defined(__GNUC__) 73 | CEREAL_RAPIDJSON_DIAG_POP 74 | #endif 75 | 76 | CEREAL_RAPIDJSON_NAMESPACE_END 77 | 78 | #endif // CEREAL_RAPIDJSON_CURSORSTREAMWRAPPER_H_ 79 | -------------------------------------------------------------------------------- /include/cereal/external/rapidjson/filereadstream.h: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making RapidJSON available. 2 | // 3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. 4 | // 5 | // Licensed under the MIT License (the "License"); you may not use this file except 6 | // in compliance with the License. You may obtain a copy of the License at 7 | // 8 | // http://opensource.org/licenses/MIT 9 | // 10 | // Unless required by applicable law or agreed to in writing, software distributed 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | // specific language governing permissions and limitations under the License. 14 | 15 | #ifndef CEREAL_RAPIDJSON_FILEREADSTREAM_H_ 16 | #define CEREAL_RAPIDJSON_FILEREADSTREAM_H_ 17 | 18 | #include "stream.h" 19 | #include 20 | 21 | #ifdef __clang__ 22 | CEREAL_RAPIDJSON_DIAG_PUSH 23 | CEREAL_RAPIDJSON_DIAG_OFF(padded) 24 | CEREAL_RAPIDJSON_DIAG_OFF(unreachable-code) 25 | CEREAL_RAPIDJSON_DIAG_OFF(missing-noreturn) 26 | #endif 27 | 28 | CEREAL_RAPIDJSON_NAMESPACE_BEGIN 29 | 30 | //! File byte stream for input using fread(). 31 | /*! 32 | \note implements Stream concept 33 | */ 34 | class FileReadStream { 35 | public: 36 | typedef char Ch; //!< Character type (byte). 37 | 38 | //! Constructor. 39 | /*! 40 | \param fp File pointer opened for read. 41 | \param buffer user-supplied buffer. 42 | \param bufferSize size of buffer in bytes. Must >=4 bytes. 43 | */ 44 | FileReadStream(std::FILE* fp, char* buffer, size_t bufferSize) : fp_(fp), buffer_(buffer), bufferSize_(bufferSize), bufferLast_(0), current_(buffer_), readCount_(0), count_(0), eof_(false) { 45 | CEREAL_RAPIDJSON_ASSERT(fp_ != 0); 46 | CEREAL_RAPIDJSON_ASSERT(bufferSize >= 4); 47 | Read(); 48 | } 49 | 50 | Ch Peek() const { return *current_; } 51 | Ch Take() { Ch c = *current_; Read(); return c; } 52 | size_t Tell() const { return count_ + static_cast(current_ - buffer_); } 53 | 54 | // Not implemented 55 | void Put(Ch) { CEREAL_RAPIDJSON_ASSERT(false); } 56 | void Flush() { CEREAL_RAPIDJSON_ASSERT(false); } 57 | Ch* PutBegin() { CEREAL_RAPIDJSON_ASSERT(false); return 0; } 58 | size_t PutEnd(Ch*) { CEREAL_RAPIDJSON_ASSERT(false); return 0; } 59 | 60 | // For encoding detection only. 61 | const Ch* Peek4() const { 62 | return (current_ + 4 - !eof_ <= bufferLast_) ? current_ : 0; 63 | } 64 | 65 | private: 66 | void Read() { 67 | if (current_ < bufferLast_) 68 | ++current_; 69 | else if (!eof_) { 70 | count_ += readCount_; 71 | readCount_ = std::fread(buffer_, 1, bufferSize_, fp_); 72 | bufferLast_ = buffer_ + readCount_ - 1; 73 | current_ = buffer_; 74 | 75 | if (readCount_ < bufferSize_) { 76 | buffer_[readCount_] = '\0'; 77 | ++bufferLast_; 78 | eof_ = true; 79 | } 80 | } 81 | } 82 | 83 | std::FILE* fp_; 84 | Ch *buffer_; 85 | size_t bufferSize_; 86 | Ch *bufferLast_; 87 | Ch *current_; 88 | size_t readCount_; 89 | size_t count_; //!< Number of characters read 90 | bool eof_; 91 | }; 92 | 93 | CEREAL_RAPIDJSON_NAMESPACE_END 94 | 95 | #ifdef __clang__ 96 | CEREAL_RAPIDJSON_DIAG_POP 97 | #endif 98 | 99 | #endif // CEREAL_RAPIDJSON_FILESTREAM_H_ 100 | -------------------------------------------------------------------------------- /include/cereal/external/rapidjson/filewritestream.h: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making RapidJSON available. 2 | // 3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. 4 | // 5 | // Licensed under the MIT License (the "License"); you may not use this file except 6 | // in compliance with the License. You may obtain a copy of the License at 7 | // 8 | // http://opensource.org/licenses/MIT 9 | // 10 | // Unless required by applicable law or agreed to in writing, software distributed 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | // specific language governing permissions and limitations under the License. 14 | 15 | #ifndef CEREAL_RAPIDJSON_FILEWRITESTREAM_H_ 16 | #define CEREAL_RAPIDJSON_FILEWRITESTREAM_H_ 17 | 18 | #include "stream.h" 19 | #include 20 | 21 | #ifdef __clang__ 22 | CEREAL_RAPIDJSON_DIAG_PUSH 23 | CEREAL_RAPIDJSON_DIAG_OFF(unreachable-code) 24 | #endif 25 | 26 | CEREAL_RAPIDJSON_NAMESPACE_BEGIN 27 | 28 | //! Wrapper of C file stream for output using fwrite(). 29 | /*! 30 | \note implements Stream concept 31 | */ 32 | class FileWriteStream { 33 | public: 34 | typedef char Ch; //!< Character type. Only support char. 35 | 36 | FileWriteStream(std::FILE* fp, char* buffer, size_t bufferSize) : fp_(fp), buffer_(buffer), bufferEnd_(buffer + bufferSize), current_(buffer_) { 37 | CEREAL_RAPIDJSON_ASSERT(fp_ != 0); 38 | } 39 | 40 | void Put(char c) { 41 | if (current_ >= bufferEnd_) 42 | Flush(); 43 | 44 | *current_++ = c; 45 | } 46 | 47 | void PutN(char c, size_t n) { 48 | size_t avail = static_cast(bufferEnd_ - current_); 49 | while (n > avail) { 50 | std::memset(current_, c, avail); 51 | current_ += avail; 52 | Flush(); 53 | n -= avail; 54 | avail = static_cast(bufferEnd_ - current_); 55 | } 56 | 57 | if (n > 0) { 58 | std::memset(current_, c, n); 59 | current_ += n; 60 | } 61 | } 62 | 63 | void Flush() { 64 | if (current_ != buffer_) { 65 | size_t result = std::fwrite(buffer_, 1, static_cast(current_ - buffer_), fp_); 66 | if (result < static_cast(current_ - buffer_)) { 67 | // failure deliberately ignored at this time 68 | // added to avoid warn_unused_result build errors 69 | } 70 | current_ = buffer_; 71 | } 72 | } 73 | 74 | // Not implemented 75 | char Peek() const { CEREAL_RAPIDJSON_ASSERT(false); return 0; } 76 | char Take() { CEREAL_RAPIDJSON_ASSERT(false); return 0; } 77 | size_t Tell() const { CEREAL_RAPIDJSON_ASSERT(false); return 0; } 78 | char* PutBegin() { CEREAL_RAPIDJSON_ASSERT(false); return 0; } 79 | size_t PutEnd(char*) { CEREAL_RAPIDJSON_ASSERT(false); return 0; } 80 | 81 | private: 82 | // Prohibit copy constructor & assignment operator. 83 | FileWriteStream(const FileWriteStream&); 84 | FileWriteStream& operator=(const FileWriteStream&); 85 | 86 | std::FILE* fp_; 87 | char *buffer_; 88 | char *bufferEnd_; 89 | char *current_; 90 | }; 91 | 92 | //! Implement specialized version of PutN() with memset() for better performance. 93 | template<> 94 | inline void PutN(FileWriteStream& stream, char c, size_t n) { 95 | stream.PutN(c, n); 96 | } 97 | 98 | CEREAL_RAPIDJSON_NAMESPACE_END 99 | 100 | #ifdef __clang__ 101 | CEREAL_RAPIDJSON_DIAG_POP 102 | #endif 103 | 104 | #endif // CEREAL_RAPIDJSON_FILESTREAM_H_ 105 | -------------------------------------------------------------------------------- /include/cereal/external/rapidjson/internal/ieee754.h: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making RapidJSON available. 2 | // 3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. 4 | // 5 | // Licensed under the MIT License (the "License"); you may not use this file except 6 | // in compliance with the License. You may obtain a copy of the License at 7 | // 8 | // http://opensource.org/licenses/MIT 9 | // 10 | // Unless required by applicable law or agreed to in writing, software distributed 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | // specific language governing permissions and limitations under the License. 14 | 15 | #ifndef CEREAL_RAPIDJSON_IEEE754_ 16 | #define CEREAL_RAPIDJSON_IEEE754_ 17 | 18 | #include "../rapidjson.h" 19 | 20 | CEREAL_RAPIDJSON_NAMESPACE_BEGIN 21 | namespace internal { 22 | 23 | class Double { 24 | public: 25 | Double() {} 26 | Double(double d) : d_(d) {} 27 | Double(uint64_t u) : u_(u) {} 28 | 29 | double Value() const { return d_; } 30 | uint64_t Uint64Value() const { return u_; } 31 | 32 | double NextPositiveDouble() const { 33 | CEREAL_RAPIDJSON_ASSERT(!Sign()); 34 | return Double(u_ + 1).Value(); 35 | } 36 | 37 | bool Sign() const { return (u_ & kSignMask) != 0; } 38 | uint64_t Significand() const { return u_ & kSignificandMask; } 39 | int Exponent() const { return static_cast(((u_ & kExponentMask) >> kSignificandSize) - kExponentBias); } 40 | 41 | bool IsNan() const { return (u_ & kExponentMask) == kExponentMask && Significand() != 0; } 42 | bool IsInf() const { return (u_ & kExponentMask) == kExponentMask && Significand() == 0; } 43 | bool IsNanOrInf() const { return (u_ & kExponentMask) == kExponentMask; } 44 | bool IsNormal() const { return (u_ & kExponentMask) != 0 || Significand() == 0; } 45 | bool IsZero() const { return (u_ & (kExponentMask | kSignificandMask)) == 0; } 46 | 47 | uint64_t IntegerSignificand() const { return IsNormal() ? Significand() | kHiddenBit : Significand(); } 48 | int IntegerExponent() const { return (IsNormal() ? Exponent() : kDenormalExponent) - kSignificandSize; } 49 | uint64_t ToBias() const { return (u_ & kSignMask) ? ~u_ + 1 : u_ | kSignMask; } 50 | 51 | static int EffectiveSignificandSize(int order) { 52 | if (order >= -1021) 53 | return 53; 54 | else if (order <= -1074) 55 | return 0; 56 | else 57 | return order + 1074; 58 | } 59 | 60 | private: 61 | static const int kSignificandSize = 52; 62 | static const int kExponentBias = 0x3FF; 63 | static const int kDenormalExponent = 1 - kExponentBias; 64 | static const uint64_t kSignMask = CEREAL_RAPIDJSON_UINT64_C2(0x80000000, 0x00000000); 65 | static const uint64_t kExponentMask = CEREAL_RAPIDJSON_UINT64_C2(0x7FF00000, 0x00000000); 66 | static const uint64_t kSignificandMask = CEREAL_RAPIDJSON_UINT64_C2(0x000FFFFF, 0xFFFFFFFF); 67 | static const uint64_t kHiddenBit = CEREAL_RAPIDJSON_UINT64_C2(0x00100000, 0x00000000); 68 | 69 | union { 70 | double d_; 71 | uint64_t u_; 72 | }; 73 | }; 74 | 75 | } // namespace internal 76 | CEREAL_RAPIDJSON_NAMESPACE_END 77 | 78 | #endif // CEREAL_RAPIDJSON_IEEE754_ 79 | -------------------------------------------------------------------------------- /include/cereal/external/rapidjson/internal/strfunc.h: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making RapidJSON available. 2 | // 3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. 4 | // 5 | // Licensed under the MIT License (the "License"); you may not use this file except 6 | // in compliance with the License. You may obtain a copy of the License at 7 | // 8 | // http://opensource.org/licenses/MIT 9 | // 10 | // Unless required by applicable law or agreed to in writing, software distributed 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | // specific language governing permissions and limitations under the License. 14 | 15 | #ifndef CEREAL_RAPIDJSON_INTERNAL_STRFUNC_H_ 16 | #define CEREAL_RAPIDJSON_INTERNAL_STRFUNC_H_ 17 | 18 | #include "../stream.h" 19 | #include 20 | 21 | CEREAL_RAPIDJSON_NAMESPACE_BEGIN 22 | namespace internal { 23 | 24 | //! Custom strlen() which works on different character types. 25 | /*! \tparam Ch Character type (e.g. char, wchar_t, short) 26 | \param s Null-terminated input string. 27 | \return Number of characters in the string. 28 | \note This has the same semantics as strlen(), the return value is not number of Unicode codepoints. 29 | */ 30 | template 31 | inline SizeType StrLen(const Ch* s) { 32 | CEREAL_RAPIDJSON_ASSERT(s != 0); 33 | const Ch* p = s; 34 | while (*p) ++p; 35 | return SizeType(p - s); 36 | } 37 | 38 | template <> 39 | inline SizeType StrLen(const char* s) { 40 | return SizeType(std::strlen(s)); 41 | } 42 | 43 | template <> 44 | inline SizeType StrLen(const wchar_t* s) { 45 | return SizeType(std::wcslen(s)); 46 | } 47 | 48 | //! Returns number of code points in a encoded string. 49 | template 50 | bool CountStringCodePoint(const typename Encoding::Ch* s, SizeType length, SizeType* outCount) { 51 | CEREAL_RAPIDJSON_ASSERT(s != 0); 52 | CEREAL_RAPIDJSON_ASSERT(outCount != 0); 53 | GenericStringStream is(s); 54 | const typename Encoding::Ch* end = s + length; 55 | SizeType count = 0; 56 | while (is.src_ < end) { 57 | unsigned codepoint; 58 | if (!Encoding::Decode(is, &codepoint)) 59 | return false; 60 | count++; 61 | } 62 | *outCount = count; 63 | return true; 64 | } 65 | 66 | } // namespace internal 67 | CEREAL_RAPIDJSON_NAMESPACE_END 68 | 69 | #endif // CEREAL_RAPIDJSON_INTERNAL_STRFUNC_H_ 70 | -------------------------------------------------------------------------------- /include/cereal/external/rapidjson/internal/swap.h: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making RapidJSON available. 2 | // 3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. 4 | // 5 | // Licensed under the MIT License (the "License"); you may not use this file except 6 | // in compliance with the License. You may obtain a copy of the License at 7 | // 8 | // http://opensource.org/licenses/MIT 9 | // 10 | // Unless required by applicable law or agreed to in writing, software distributed 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | // specific language governing permissions and limitations under the License. 14 | 15 | #ifndef CEREAL_RAPIDJSON_INTERNAL_SWAP_H_ 16 | #define CEREAL_RAPIDJSON_INTERNAL_SWAP_H_ 17 | 18 | #include "../rapidjson.h" 19 | 20 | #if defined(__clang__) 21 | CEREAL_RAPIDJSON_DIAG_PUSH 22 | CEREAL_RAPIDJSON_DIAG_OFF(c++98-compat) 23 | #endif 24 | 25 | CEREAL_RAPIDJSON_NAMESPACE_BEGIN 26 | namespace internal { 27 | 28 | //! Custom swap() to avoid dependency on C++ header 29 | /*! \tparam T Type of the arguments to swap, should be instantiated with primitive C++ types only. 30 | \note This has the same semantics as std::swap(). 31 | */ 32 | template 33 | inline void Swap(T& a, T& b) CEREAL_RAPIDJSON_NOEXCEPT { 34 | T tmp = a; 35 | a = b; 36 | b = tmp; 37 | } 38 | 39 | } // namespace internal 40 | CEREAL_RAPIDJSON_NAMESPACE_END 41 | 42 | #if defined(__clang__) 43 | CEREAL_RAPIDJSON_DIAG_POP 44 | #endif 45 | 46 | #endif // CEREAL_RAPIDJSON_INTERNAL_SWAP_H_ 47 | -------------------------------------------------------------------------------- /include/cereal/external/rapidjson/memorybuffer.h: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making RapidJSON available. 2 | // 3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. 4 | // 5 | // Licensed under the MIT License (the "License"); you may not use this file except 6 | // in compliance with the License. You may obtain a copy of the License at 7 | // 8 | // http://opensource.org/licenses/MIT 9 | // 10 | // Unless required by applicable law or agreed to in writing, software distributed 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | // specific language governing permissions and limitations under the License. 14 | 15 | #ifndef CEREAL_RAPIDJSON_MEMORYBUFFER_H_ 16 | #define CEREAL_RAPIDJSON_MEMORYBUFFER_H_ 17 | 18 | #include "stream.h" 19 | #include "internal/stack.h" 20 | 21 | CEREAL_RAPIDJSON_NAMESPACE_BEGIN 22 | 23 | //! Represents an in-memory output byte stream. 24 | /*! 25 | This class is mainly for being wrapped by EncodedOutputStream or AutoUTFOutputStream. 26 | 27 | It is similar to FileWriteBuffer but the destination is an in-memory buffer instead of a file. 28 | 29 | Differences between MemoryBuffer and StringBuffer: 30 | 1. StringBuffer has Encoding but MemoryBuffer is only a byte buffer. 31 | 2. StringBuffer::GetString() returns a null-terminated string. MemoryBuffer::GetBuffer() returns a buffer without terminator. 32 | 33 | \tparam Allocator type for allocating memory buffer. 34 | \note implements Stream concept 35 | */ 36 | template 37 | struct GenericMemoryBuffer { 38 | typedef char Ch; // byte 39 | 40 | GenericMemoryBuffer(Allocator* allocator = 0, size_t capacity = kDefaultCapacity) : stack_(allocator, capacity) {} 41 | 42 | void Put(Ch c) { *stack_.template Push() = c; } 43 | void Flush() {} 44 | 45 | void Clear() { stack_.Clear(); } 46 | void ShrinkToFit() { stack_.ShrinkToFit(); } 47 | Ch* Push(size_t count) { return stack_.template Push(count); } 48 | void Pop(size_t count) { stack_.template Pop(count); } 49 | 50 | const Ch* GetBuffer() const { 51 | return stack_.template Bottom(); 52 | } 53 | 54 | size_t GetSize() const { return stack_.GetSize(); } 55 | 56 | static const size_t kDefaultCapacity = 256; 57 | mutable internal::Stack stack_; 58 | }; 59 | 60 | typedef GenericMemoryBuffer<> MemoryBuffer; 61 | 62 | //! Implement specialized version of PutN() with memset() for better performance. 63 | template<> 64 | inline void PutN(MemoryBuffer& memoryBuffer, char c, size_t n) { 65 | std::memset(memoryBuffer.stack_.Push(n), c, n * sizeof(c)); 66 | } 67 | 68 | CEREAL_RAPIDJSON_NAMESPACE_END 69 | 70 | #endif // CEREAL_RAPIDJSON_MEMORYBUFFER_H_ 71 | -------------------------------------------------------------------------------- /include/cereal/external/rapidjson/memorystream.h: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making RapidJSON available. 2 | // 3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. 4 | // 5 | // Licensed under the MIT License (the "License"); you may not use this file except 6 | // in compliance with the License. You may obtain a copy of the License at 7 | // 8 | // http://opensource.org/licenses/MIT 9 | // 10 | // Unless required by applicable law or agreed to in writing, software distributed 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | // specific language governing permissions and limitations under the License. 14 | 15 | #ifndef CEREAL_RAPIDJSON_MEMORYSTREAM_H_ 16 | #define CEREAL_RAPIDJSON_MEMORYSTREAM_H_ 17 | 18 | #include "stream.h" 19 | 20 | #ifdef __clang__ 21 | CEREAL_RAPIDJSON_DIAG_PUSH 22 | CEREAL_RAPIDJSON_DIAG_OFF(unreachable-code) 23 | CEREAL_RAPIDJSON_DIAG_OFF(missing-noreturn) 24 | #endif 25 | 26 | CEREAL_RAPIDJSON_NAMESPACE_BEGIN 27 | 28 | //! Represents an in-memory input byte stream. 29 | /*! 30 | This class is mainly for being wrapped by EncodedInputStream or AutoUTFInputStream. 31 | 32 | It is similar to FileReadBuffer but the source is an in-memory buffer instead of a file. 33 | 34 | Differences between MemoryStream and StringStream: 35 | 1. StringStream has encoding but MemoryStream is a byte stream. 36 | 2. MemoryStream needs size of the source buffer and the buffer don't need to be null terminated. StringStream assume null-terminated string as source. 37 | 3. MemoryStream supports Peek4() for encoding detection. StringStream is specified with an encoding so it should not have Peek4(). 38 | \note implements Stream concept 39 | */ 40 | struct MemoryStream { 41 | typedef char Ch; // byte 42 | 43 | MemoryStream(const Ch *src, size_t size) : src_(src), begin_(src), end_(src + size), size_(size) {} 44 | 45 | Ch Peek() const { return CEREAL_RAPIDJSON_UNLIKELY(src_ == end_) ? '\0' : *src_; } 46 | Ch Take() { return CEREAL_RAPIDJSON_UNLIKELY(src_ == end_) ? '\0' : *src_++; } 47 | size_t Tell() const { return static_cast(src_ - begin_); } 48 | 49 | Ch* PutBegin() { CEREAL_RAPIDJSON_ASSERT(false); return 0; } 50 | void Put(Ch) { CEREAL_RAPIDJSON_ASSERT(false); } 51 | void Flush() { CEREAL_RAPIDJSON_ASSERT(false); } 52 | size_t PutEnd(Ch*) { CEREAL_RAPIDJSON_ASSERT(false); return 0; } 53 | 54 | // For encoding detection only. 55 | const Ch* Peek4() const { 56 | return Tell() + 4 <= size_ ? src_ : 0; 57 | } 58 | 59 | const Ch* src_; //!< Current read position. 60 | const Ch* begin_; //!< Original head of the string. 61 | const Ch* end_; //!< End of stream. 62 | size_t size_; //!< Size of the stream. 63 | }; 64 | 65 | CEREAL_RAPIDJSON_NAMESPACE_END 66 | 67 | #ifdef __clang__ 68 | CEREAL_RAPIDJSON_DIAG_POP 69 | #endif 70 | 71 | #endif // CEREAL_RAPIDJSON_MEMORYBUFFER_H_ 72 | -------------------------------------------------------------------------------- /include/cereal/external/rapidjson/msinttypes/LICENSE: -------------------------------------------------------------------------------- 1 | ISO C9x compliant stdint.h for Microsoft Visual Studio 2 | Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124 3 | 4 | Copyright (c) 2006-2013 Alexander Chemeris 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright notice, 10 | this list of conditions and the following disclaimer. 11 | 12 | 2. Redistributions in binary form must reproduce the above copyright 13 | notice, this list of conditions and the following disclaimer in the 14 | documentation and/or other materials provided with the distribution. 15 | 16 | 3. Neither the name of the product nor the names of its contributors may 17 | be used to endorse or promote products derived from this software 18 | without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 21 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 22 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 23 | EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 25 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 26 | OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 27 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 28 | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 29 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /include/cereal/external/rapidjson/ostreamwrapper.h: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making RapidJSON available. 2 | // 3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. 4 | // 5 | // Licensed under the MIT License (the "License"); you may not use this file except 6 | // in compliance with the License. You may obtain a copy of the License at 7 | // 8 | // http://opensource.org/licenses/MIT 9 | // 10 | // Unless required by applicable law or agreed to in writing, software distributed 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | // specific language governing permissions and limitations under the License. 14 | 15 | #ifndef CEREAL_RAPIDJSON_OSTREAMWRAPPER_H_ 16 | #define CEREAL_RAPIDJSON_OSTREAMWRAPPER_H_ 17 | 18 | #include "stream.h" 19 | #include 20 | 21 | #ifdef __clang__ 22 | CEREAL_RAPIDJSON_DIAG_PUSH 23 | CEREAL_RAPIDJSON_DIAG_OFF(padded) 24 | #endif 25 | 26 | CEREAL_RAPIDJSON_NAMESPACE_BEGIN 27 | 28 | //! Wrapper of \c std::basic_ostream into RapidJSON's Stream concept. 29 | /*! 30 | The classes can be wrapped including but not limited to: 31 | 32 | - \c std::ostringstream 33 | - \c std::stringstream 34 | - \c std::wpstringstream 35 | - \c std::wstringstream 36 | - \c std::ifstream 37 | - \c std::fstream 38 | - \c std::wofstream 39 | - \c std::wfstream 40 | 41 | \tparam StreamType Class derived from \c std::basic_ostream. 42 | */ 43 | 44 | template 45 | class BasicOStreamWrapper { 46 | public: 47 | typedef typename StreamType::char_type Ch; 48 | BasicOStreamWrapper(StreamType& stream) : stream_(stream) {} 49 | 50 | void Put(Ch c) { 51 | stream_.put(c); 52 | } 53 | 54 | void Flush() { 55 | stream_.flush(); 56 | } 57 | 58 | // Not implemented 59 | char Peek() const { CEREAL_RAPIDJSON_ASSERT(false); return 0; } 60 | char Take() { CEREAL_RAPIDJSON_ASSERT(false); return 0; } 61 | size_t Tell() const { CEREAL_RAPIDJSON_ASSERT(false); return 0; } 62 | char* PutBegin() { CEREAL_RAPIDJSON_ASSERT(false); return 0; } 63 | size_t PutEnd(char*) { CEREAL_RAPIDJSON_ASSERT(false); return 0; } 64 | 65 | private: 66 | BasicOStreamWrapper(const BasicOStreamWrapper&); 67 | BasicOStreamWrapper& operator=(const BasicOStreamWrapper&); 68 | 69 | StreamType& stream_; 70 | }; 71 | 72 | typedef BasicOStreamWrapper OStreamWrapper; 73 | typedef BasicOStreamWrapper WOStreamWrapper; 74 | 75 | #ifdef __clang__ 76 | CEREAL_RAPIDJSON_DIAG_POP 77 | #endif 78 | 79 | CEREAL_RAPIDJSON_NAMESPACE_END 80 | 81 | #endif // CEREAL_RAPIDJSON_OSTREAMWRAPPER_H_ 82 | -------------------------------------------------------------------------------- /include/cereal/external/rapidxml/license.txt: -------------------------------------------------------------------------------- 1 | Use of this software is granted under one of the following two licenses, 2 | to be chosen freely by the user. 3 | 4 | 1. Boost Software License - Version 1.0 - August 17th, 2003 5 | =============================================================================== 6 | 7 | Copyright (c) 2006, 2007 Marcin Kalicinski 8 | 9 | Permission is hereby granted, free of charge, to any person or organization 10 | obtaining a copy of the software and accompanying documentation covered by 11 | this license (the "Software") to use, reproduce, display, distribute, 12 | execute, and transmit the Software, and to prepare derivative works of the 13 | Software, and to permit third-parties to whom the Software is furnished to 14 | do so, all subject to the following: 15 | 16 | The copyright notices in the Software and this entire statement, including 17 | the above license grant, this restriction and the following disclaimer, 18 | must be included in all copies of the Software, in whole or in part, and 19 | all derivative works of the Software, unless such copies or derivative 20 | works are solely in the form of machine-executable object code generated by 21 | a source language processor. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 24 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 26 | SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE 27 | FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, 28 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 29 | DEALINGS IN THE SOFTWARE. 30 | 31 | 2. The MIT License 32 | =============================================================================== 33 | 34 | Copyright (c) 2006, 2007 Marcin Kalicinski 35 | 36 | Permission is hereby granted, free of charge, to any person obtaining a copy 37 | of this software and associated documentation files (the "Software"), to deal 38 | in the Software without restriction, including without limitation the rights 39 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 40 | of the Software, and to permit persons to whom the Software is furnished to do so, 41 | subject to the following conditions: 42 | 43 | The above copyright notice and this permission notice shall be included in all 44 | copies or substantial portions of the Software. 45 | 46 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 47 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 48 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 49 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 50 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 51 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 52 | IN THE SOFTWARE. 53 | -------------------------------------------------------------------------------- /include/cereal/types/array.hpp: -------------------------------------------------------------------------------- 1 | /*! \file array.hpp 2 | \brief Support for types found in \ 3 | \ingroup STLSupport */ 4 | /* 5 | Copyright (c) 2014, Randolph Voorhies, Shane Grant 6 | All rights reserved. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | * Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | * Redistributions in binary form must reproduce the above copyright 13 | notice, this list of conditions and the following disclaimer in the 14 | documentation and/or other materials provided with the distribution. 15 | * Neither the name of the copyright holder nor the 16 | names of its contributors may be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY 23 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | #ifndef CEREAL_TYPES_ARRAY_HPP_ 31 | #define CEREAL_TYPES_ARRAY_HPP_ 32 | 33 | #include "cereal/cereal.hpp" 34 | #include 35 | 36 | namespace cereal 37 | { 38 | //! Saving for std::array primitive types 39 | //! using binary serialization, if supported 40 | template inline 41 | typename std::enable_if, Archive>::value 42 | && std::is_arithmetic::value, void>::type 43 | CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::array const & array ) 44 | { 45 | ar( binary_data( array.data(), N*sizeof(T) ) ); 46 | } 47 | 48 | //! Loading for std::array primitive types 49 | //! using binary serialization, if supported 50 | template inline 51 | typename std::enable_if, Archive>::value 52 | && std::is_arithmetic::value, void>::type 53 | CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::array & array ) 54 | { 55 | ar( binary_data( array.data(), N*sizeof(T) ) ); 56 | } 57 | 58 | //! Saving for std::array all other types 59 | template inline 60 | typename std::enable_if, Archive>::value 61 | || !std::is_arithmetic::value, void>::type 62 | CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::array const & array ) 63 | { 64 | for( auto const & i : array ) 65 | ar( i ); 66 | } 67 | 68 | //! Loading for std::array all other types 69 | template inline 70 | typename std::enable_if, Archive>::value 71 | || !std::is_arithmetic::value, void>::type 72 | CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::array & array ) 73 | { 74 | for( auto & i : array ) 75 | ar( i ); 76 | } 77 | } // namespace cereal 78 | 79 | #endif // CEREAL_TYPES_ARRAY_HPP_ 80 | -------------------------------------------------------------------------------- /include/cereal/types/atomic.hpp: -------------------------------------------------------------------------------- 1 | /*! \file atomic.hpp 2 | \brief Support for types found in \ 3 | \ingroup STLSupport */ 4 | /* 5 | Copyright (c) 2014, Randolph Voorhies, Shane Grant 6 | All rights reserved. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | * Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | * Redistributions in binary form must reproduce the above copyright 13 | notice, this list of conditions and the following disclaimer in the 14 | documentation and/or other materials provided with the distribution. 15 | * Neither the name of the copyright holder nor the 16 | names of its contributors may be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY 23 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | #ifndef CEREAL_TYPES_ATOMIC_HPP_ 31 | #define CEREAL_TYPES_ATOMIC_HPP_ 32 | 33 | #include 34 | #include 35 | 36 | namespace cereal 37 | { 38 | //! Serializing (save) for std::atomic 39 | template inline 40 | void CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::atomic const & a ) 41 | { 42 | ar( CEREAL_NVP_("atomic_data", a.load()) ); 43 | } 44 | 45 | //! Serializing (load) for std::atomic 46 | template inline 47 | void CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::atomic & a ) 48 | { 49 | T tmp; 50 | ar( CEREAL_NVP_("atomic_data", tmp) ); 51 | a.store( tmp ); 52 | } 53 | } // namespace cereal 54 | 55 | #endif // CEREAL_TYPES_ATOMIC_HPP_ 56 | -------------------------------------------------------------------------------- /include/cereal/types/chrono.hpp: -------------------------------------------------------------------------------- 1 | /*! \file chrono.hpp 2 | \brief Support for types found in \ 3 | \ingroup STLSupport */ 4 | /* 5 | Copyright (c) 2014, Randolph Voorhies, Shane Grant 6 | All rights reserved. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | * Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | * Redistributions in binary form must reproduce the above copyright 13 | notice, this list of conditions and the following disclaimer in the 14 | documentation and/or other materials provided with the distribution. 15 | * Neither the name of the copyright holder nor the 16 | names of its contributors may be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY 23 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | #ifndef CEREAL_TYPES_CHRONO_HPP_ 31 | #define CEREAL_TYPES_CHRONO_HPP_ 32 | 33 | #include 34 | 35 | namespace cereal 36 | { 37 | //! Saving std::chrono::duration 38 | template inline 39 | void CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::chrono::duration const & dur ) 40 | { 41 | ar( CEREAL_NVP_("count", dur.count()) ); 42 | } 43 | 44 | //! Loading std::chrono::duration 45 | template inline 46 | void CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::chrono::duration & dur ) 47 | { 48 | R count; 49 | ar( CEREAL_NVP_("count", count) ); 50 | 51 | dur = std::chrono::duration{count}; 52 | } 53 | 54 | //! Saving std::chrono::time_point 55 | template inline 56 | void CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::chrono::time_point const & dur ) 57 | { 58 | ar( CEREAL_NVP_("time_since_epoch", dur.time_since_epoch()) ); 59 | } 60 | 61 | //! Loading std::chrono::time_point 62 | template inline 63 | void CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::chrono::time_point & dur ) 64 | { 65 | D elapsed; 66 | ar( CEREAL_NVP_("time_since_epoch", elapsed) ); 67 | 68 | dur = std::chrono::time_point{elapsed}; 69 | } 70 | } // namespace cereal 71 | 72 | #endif // CEREAL_TYPES_CHRONO_HPP_ 73 | -------------------------------------------------------------------------------- /include/cereal/types/complex.hpp: -------------------------------------------------------------------------------- 1 | /*! \file complex.hpp 2 | \brief Support for types found in \ 3 | \ingroup STLSupport */ 4 | /* 5 | Copyright (c) 2014, Randolph Voorhies, Shane Grant 6 | All rights reserved. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | * Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | * Redistributions in binary form must reproduce the above copyright 13 | notice, this list of conditions and the following disclaimer in the 14 | documentation and/or other materials provided with the distribution. 15 | * Neither the name of the copyright holder nor the 16 | names of its contributors may be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY 23 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | #ifndef CEREAL_TYPES_COMPLEX_HPP_ 31 | #define CEREAL_TYPES_COMPLEX_HPP_ 32 | 33 | #include 34 | 35 | namespace cereal 36 | { 37 | //! Serializing (save) for std::complex 38 | template inline 39 | void CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::complex const & comp ) 40 | { 41 | ar( CEREAL_NVP_("real", comp.real()), 42 | CEREAL_NVP_("imag", comp.imag()) ); 43 | } 44 | 45 | //! Serializing (load) for std::complex 46 | template inline 47 | void CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::complex & bits ) 48 | { 49 | T real, imag; 50 | ar( CEREAL_NVP_("real", real), 51 | CEREAL_NVP_("imag", imag) ); 52 | bits = {real, imag}; 53 | } 54 | } // namespace cereal 55 | 56 | #endif // CEREAL_TYPES_COMPLEX_HPP_ 57 | -------------------------------------------------------------------------------- /include/cereal/types/concepts/pair_associative_container.hpp: -------------------------------------------------------------------------------- 1 | /*! \file pair_associative_container.hpp 2 | \brief Support for the PairAssociativeContainer refinement of the 3 | AssociativeContainer concept. 4 | \ingroup TypeConcepts */ 5 | /* 6 | Copyright (c) 2014, Randolph Voorhies, Shane Grant 7 | All rights reserved. 8 | 9 | Redistribution and use in source and binary forms, with or without 10 | modification, are permitted provided that the following conditions are met: 11 | * Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | * Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | * Neither the name of the copyright holder nor the 17 | names of its contributors may be used to endorse or promote products 18 | derived from this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 21 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 22 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY 24 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 25 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 26 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 27 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 29 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | #ifndef CEREAL_CONCEPTS_PAIR_ASSOCIATIVE_CONTAINER_HPP_ 32 | #define CEREAL_CONCEPTS_PAIR_ASSOCIATIVE_CONTAINER_HPP_ 33 | 34 | #include "cereal/cereal.hpp" 35 | 36 | namespace cereal 37 | { 38 | //! Saving for std-like pair associative containers 39 | template class Map, typename... Args, typename = typename Map::mapped_type> inline 40 | void CEREAL_SAVE_FUNCTION_NAME( Archive & ar, Map const & map ) 41 | { 42 | ar( make_size_tag( static_cast(map.size()) ) ); 43 | 44 | for( const auto & i : map ) 45 | ar( make_map_item(i.first, i.second) ); 46 | } 47 | 48 | //! Loading for std-like pair associative containers 49 | template class Map, typename... Args, typename = typename Map::mapped_type> inline 50 | void CEREAL_LOAD_FUNCTION_NAME( Archive & ar, Map & map ) 51 | { 52 | size_type size; 53 | ar( make_size_tag( size ) ); 54 | 55 | map.clear(); 56 | 57 | auto hint = map.begin(); 58 | for( size_t i = 0; i < size; ++i ) 59 | { 60 | typename Map::key_type key; 61 | typename Map::mapped_type value; 62 | 63 | ar( make_map_item(key, value) ); 64 | #ifdef CEREAL_OLDER_GCC 65 | hint = map.insert( hint, std::make_pair(std::move(key), std::move(value)) ); 66 | #else // NOT CEREAL_OLDER_GCC 67 | hint = map.emplace_hint( hint, std::move( key ), std::move( value ) ); 68 | #endif // NOT CEREAL_OLDER_GCC 69 | } 70 | } 71 | } // namespace cereal 72 | 73 | #endif // CEREAL_CONCEPTS_PAIR_ASSOCIATIVE_CONTAINER_HPP_ 74 | -------------------------------------------------------------------------------- /include/cereal/types/deque.hpp: -------------------------------------------------------------------------------- 1 | /*! \file deque.hpp 2 | \brief Support for types found in \ 3 | \ingroup STLSupport */ 4 | /* 5 | Copyright (c) 2014, Randolph Voorhies, Shane Grant 6 | All rights reserved. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | * Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | * Redistributions in binary form must reproduce the above copyright 13 | notice, this list of conditions and the following disclaimer in the 14 | documentation and/or other materials provided with the distribution. 15 | * Neither the name of the copyright holder nor the 16 | names of its contributors may be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY 23 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | #ifndef CEREAL_TYPES_DEQUE_HPP_ 31 | #define CEREAL_TYPES_DEQUE_HPP_ 32 | 33 | #include "cereal/cereal.hpp" 34 | #include 35 | 36 | namespace cereal 37 | { 38 | //! Saving for std::deque 39 | template inline 40 | void CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::deque const & deque ) 41 | { 42 | ar( make_size_tag( static_cast(deque.size()) ) ); 43 | 44 | for( auto const & i : deque ) 45 | ar( i ); 46 | } 47 | 48 | //! Loading for std::deque 49 | template inline 50 | void CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::deque & deque ) 51 | { 52 | size_type size; 53 | ar( make_size_tag( size ) ); 54 | 55 | deque.resize( static_cast( size ) ); 56 | 57 | for( auto & i : deque ) 58 | ar( i ); 59 | } 60 | } // namespace cereal 61 | 62 | #endif // CEREAL_TYPES_DEQUE_HPP_ 63 | -------------------------------------------------------------------------------- /include/cereal/types/forward_list.hpp: -------------------------------------------------------------------------------- 1 | /*! \file forward_list.hpp 2 | \brief Support for types found in \ 3 | \ingroup STLSupport */ 4 | /* 5 | Copyright (c) 2014, Randolph Voorhies, Shane Grant 6 | All rights reserved. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | * Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | * Redistributions in binary form must reproduce the above copyright 13 | notice, this list of conditions and the following disclaimer in the 14 | documentation and/or other materials provided with the distribution. 15 | * Neither the name of the copyright holder nor the 16 | names of its contributors may be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY 23 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | #ifndef CEREAL_TYPES_FORWARD_LIST_HPP_ 31 | #define CEREAL_TYPES_FORWARD_LIST_HPP_ 32 | 33 | #include "cereal/cereal.hpp" 34 | #include 35 | 36 | namespace cereal 37 | { 38 | //! Saving for std::forward_list all other types 39 | template inline 40 | void CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::forward_list const & forward_list ) 41 | { 42 | // write the size - note that this is slow because we need to traverse 43 | // the entire list. there are ways we could avoid this but this was chosen 44 | // since it works in the most general fashion with any archive type 45 | size_type const size = std::distance( forward_list.begin(), forward_list.end() ); 46 | 47 | ar( make_size_tag( size ) ); 48 | 49 | // write the list 50 | for( const auto & i : forward_list ) 51 | ar( i ); 52 | } 53 | 54 | //! Loading for std::forward_list all other types from 55 | template 56 | void CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::forward_list & forward_list ) 57 | { 58 | size_type size; 59 | ar( make_size_tag( size ) ); 60 | 61 | forward_list.resize( static_cast( size ) ); 62 | 63 | for( auto & i : forward_list ) 64 | ar( i ); 65 | } 66 | } // namespace cereal 67 | 68 | #endif // CEREAL_TYPES_FORWARD_LIST_HPP_ 69 | -------------------------------------------------------------------------------- /include/cereal/types/functional.hpp: -------------------------------------------------------------------------------- 1 | /*! \file functional.hpp 2 | \brief Support for types found in \ 3 | \ingroup STLSupport */ 4 | /* 5 | Copyright (c) 2016, Randolph Voorhies, Shane Grant 6 | All rights reserved. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | * Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | * Redistributions in binary form must reproduce the above copyright 13 | notice, this list of conditions and the following disclaimer in the 14 | documentation and/or other materials provided with the distribution. 15 | * Neither the name of the copyright holder nor the 16 | names of its contributors may be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY 23 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | #ifndef CEREAL_TYPES_FUNCTIONAL_HPP_ 31 | #define CEREAL_TYPES_FUNCTIONAL_HPP_ 32 | 33 | #include 34 | 35 | namespace cereal 36 | { 37 | //! Saving for std::less 38 | template inline 39 | void serialize( Archive &, std::less & ) 40 | { } 41 | } // namespace cereal 42 | 43 | #endif // CEREAL_TYPES_FUNCTIONAL_HPP_ 44 | -------------------------------------------------------------------------------- /include/cereal/types/list.hpp: -------------------------------------------------------------------------------- 1 | /*! \file list.hpp 2 | \brief Support for types found in \ 3 | \ingroup STLSupport */ 4 | /* 5 | Copyright (c) 2014, Randolph Voorhies, Shane Grant 6 | All rights reserved. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | * Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | * Redistributions in binary form must reproduce the above copyright 13 | notice, this list of conditions and the following disclaimer in the 14 | documentation and/or other materials provided with the distribution. 15 | * Neither the name of the copyright holder nor the 16 | names of its contributors may be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY 23 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | #ifndef CEREAL_TYPES_LIST_HPP_ 31 | #define CEREAL_TYPES_LIST_HPP_ 32 | 33 | #include "cereal/cereal.hpp" 34 | #include 35 | 36 | namespace cereal 37 | { 38 | //! Saving for std::list 39 | template inline 40 | void CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::list const & list ) 41 | { 42 | ar( make_size_tag( static_cast(list.size()) ) ); 43 | 44 | for( auto const & i : list ) 45 | ar( i ); 46 | } 47 | 48 | //! Loading for std::list 49 | template inline 50 | void CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::list & list ) 51 | { 52 | size_type size; 53 | ar( make_size_tag( size ) ); 54 | 55 | list.resize( static_cast( size ) ); 56 | 57 | for( auto & i : list ) 58 | ar( i ); 59 | } 60 | } // namespace cereal 61 | 62 | #endif // CEREAL_TYPES_LIST_HPP_ 63 | -------------------------------------------------------------------------------- /include/cereal/types/map.hpp: -------------------------------------------------------------------------------- 1 | /*! \file map.hpp 2 | \brief Support for types found in \ 3 | \ingroup STLSupport */ 4 | /* 5 | Copyright (c) 2014, Randolph Voorhies, Shane Grant 6 | All rights reserved. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | * Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | * Redistributions in binary form must reproduce the above copyright 13 | notice, this list of conditions and the following disclaimer in the 14 | documentation and/or other materials provided with the distribution. 15 | * Neither the name of the copyright holder nor the 16 | names of its contributors may be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY 23 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | #ifndef CEREAL_TYPES_MAP_HPP_ 31 | #define CEREAL_TYPES_MAP_HPP_ 32 | 33 | #include "cereal/types/concepts/pair_associative_container.hpp" 34 | #include 35 | 36 | #endif // CEREAL_TYPES_MAP_HPP_ 37 | -------------------------------------------------------------------------------- /include/cereal/types/optional.hpp: -------------------------------------------------------------------------------- 1 | /*! \file optional.hpp 2 | \brief Support for std::optional 3 | \ingroup STLSupport */ 4 | /* 5 | Copyright (c) 2017, Juan Pedro Bolivar Puente 6 | All rights reserved. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | * Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | * Redistributions in binary form must reproduce the above copyright 13 | notice, this list of conditions and the following disclaimer in the 14 | documentation and/or other materials provided with the distribution. 15 | * Neither the name of the copyright holder nor the 16 | names of its contributors may be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY 23 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | #ifndef CEREAL_TYPES_STD_OPTIONAL_ 31 | #define CEREAL_TYPES_STD_OPTIONAL_ 32 | 33 | #include "cereal/cereal.hpp" 34 | #include 35 | 36 | namespace cereal { 37 | //! Saving for std::optional 38 | template inline 39 | void CEREAL_SAVE_FUNCTION_NAME(Archive& ar, const std::optional& optional) 40 | { 41 | if(!optional) { 42 | ar(CEREAL_NVP_("nullopt", true)); 43 | } else { 44 | ar(CEREAL_NVP_("nullopt", false), 45 | CEREAL_NVP_("data", *optional)); 46 | } 47 | } 48 | 49 | //! Loading for std::optional 50 | template inline 51 | void CEREAL_LOAD_FUNCTION_NAME(Archive& ar, std::optional& optional) 52 | { 53 | bool nullopt; 54 | ar(CEREAL_NVP_("nullopt", nullopt)); 55 | 56 | if (nullopt) { 57 | optional = std::nullopt; 58 | } else { 59 | optional.emplace(); 60 | ar(CEREAL_NVP_("data", *optional)); 61 | } 62 | } 63 | } // namespace cereal 64 | 65 | #endif // CEREAL_TYPES_STD_OPTIONAL_ 66 | -------------------------------------------------------------------------------- /include/cereal/types/stack.hpp: -------------------------------------------------------------------------------- 1 | /*! \file stack.hpp 2 | \brief Support for types found in \ 3 | \ingroup STLSupport */ 4 | /* 5 | Copyright (c) 2014, Randolph Voorhies, Shane Grant 6 | All rights reserved. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | * Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | * Redistributions in binary form must reproduce the above copyright 13 | notice, this list of conditions and the following disclaimer in the 14 | documentation and/or other materials provided with the distribution. 15 | * Neither the name of the copyright holder nor the 16 | names of its contributors may be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY 23 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | #ifndef CEREAL_TYPES_STACK_HPP_ 31 | #define CEREAL_TYPES_STACK_HPP_ 32 | 33 | #include "cereal/cereal.hpp" 34 | #include 35 | 36 | // The default container for stack is deque, so let's include that too 37 | #include "cereal/types/deque.hpp" 38 | 39 | namespace cereal 40 | { 41 | namespace stack_detail 42 | { 43 | //! Allows access to the protected container in stack 44 | template inline 45 | C const & container( std::stack const & stack ) 46 | { 47 | struct H : public std::stack 48 | { 49 | static C const & get( std::stack const & s ) 50 | { 51 | return s.*(&H::c); 52 | } 53 | }; 54 | 55 | return H::get( stack ); 56 | } 57 | } 58 | 59 | //! Saving for std::stack 60 | template inline 61 | void CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::stack const & stack ) 62 | { 63 | ar( CEREAL_NVP_("container", stack_detail::container( stack )) ); 64 | } 65 | 66 | //! Loading for std::stack 67 | template inline 68 | void CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::stack & stack ) 69 | { 70 | C container; 71 | ar( CEREAL_NVP_("container", container) ); 72 | stack = std::stack( std::move( container ) ); 73 | } 74 | } // namespace cereal 75 | 76 | #endif // CEREAL_TYPES_STACK_HPP_ 77 | -------------------------------------------------------------------------------- /include/cereal/types/string.hpp: -------------------------------------------------------------------------------- 1 | /*! \file string.hpp 2 | \brief Support for types found in \ 3 | \ingroup STLSupport */ 4 | /* 5 | Copyright (c) 2014, Randolph Voorhies, Shane Grant 6 | All rights reserved. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | * Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | * Redistributions in binary form must reproduce the above copyright 13 | notice, this list of conditions and the following disclaimer in the 14 | documentation and/or other materials provided with the distribution. 15 | * Neither the name of the copyright holder nor the 16 | names of its contributors may be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY 23 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | #ifndef CEREAL_TYPES_STRING_HPP_ 31 | #define CEREAL_TYPES_STRING_HPP_ 32 | 33 | #include "cereal/cereal.hpp" 34 | #include 35 | 36 | namespace cereal 37 | { 38 | //! Serialization for basic_string types, if binary data is supported 39 | template inline 40 | typename std::enable_if, Archive>::value, void>::type 41 | CEREAL_SAVE_FUNCTION_NAME(Archive & ar, std::basic_string const & str) 42 | { 43 | // Save number of chars + the data 44 | ar( make_size_tag( static_cast(str.size()) ) ); 45 | ar( binary_data( str.data(), str.size() * sizeof(CharT) ) ); 46 | } 47 | 48 | //! Serialization for basic_string types, if binary data is supported 49 | template inline 50 | typename std::enable_if, Archive>::value, void>::type 51 | CEREAL_LOAD_FUNCTION_NAME(Archive & ar, std::basic_string & str) 52 | { 53 | size_type size; 54 | ar( make_size_tag( size ) ); 55 | str.resize(static_cast(size)); 56 | ar( binary_data( const_cast( str.data() ), static_cast(size) * sizeof(CharT) ) ); 57 | } 58 | } // namespace cereal 59 | 60 | #endif // CEREAL_TYPES_STRING_HPP_ 61 | 62 | -------------------------------------------------------------------------------- /include/cereal/types/unordered_map.hpp: -------------------------------------------------------------------------------- 1 | /*! \file unordered_map.hpp 2 | \brief Support for types found in \ 3 | \ingroup STLSupport */ 4 | /* 5 | Copyright (c) 2014, Randolph Voorhies, Shane Grant 6 | All rights reserved. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | * Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | * Redistributions in binary form must reproduce the above copyright 13 | notice, this list of conditions and the following disclaimer in the 14 | documentation and/or other materials provided with the distribution. 15 | * Neither the name of the copyright holder nor the 16 | names of its contributors may be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY 23 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | #ifndef CEREAL_TYPES_UNORDERED_MAP_HPP_ 31 | #define CEREAL_TYPES_UNORDERED_MAP_HPP_ 32 | 33 | #include "cereal/types/concepts/pair_associative_container.hpp" 34 | #include 35 | 36 | #endif // CEREAL_TYPES_UNORDERED_MAP_HPP_ 37 | -------------------------------------------------------------------------------- /include/cereal/types/utility.hpp: -------------------------------------------------------------------------------- 1 | /*! \file utility.hpp 2 | \brief Support for types found in \ 3 | \ingroup STLSupport */ 4 | /* 5 | Copyright (c) 2014, Randolph Voorhies, Shane Grant 6 | All rights reserved. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | * Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | * Redistributions in binary form must reproduce the above copyright 13 | notice, this list of conditions and the following disclaimer in the 14 | documentation and/or other materials provided with the distribution. 15 | * Neither the name of the copyright holder nor the 16 | names of its contributors may be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY 23 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | #ifndef CEREAL_TYPES_UTILITY_HPP_ 31 | #define CEREAL_TYPES_UTILITY_HPP_ 32 | 33 | #include "cereal/cereal.hpp" 34 | #include 35 | 36 | namespace cereal 37 | { 38 | //! Serializing for std::pair 39 | template inline 40 | void CEREAL_SERIALIZE_FUNCTION_NAME( Archive & ar, std::pair & pair ) 41 | { 42 | ar( CEREAL_NVP_("first", pair.first), 43 | CEREAL_NVP_("second", pair.second) ); 44 | } 45 | } // namespace cereal 46 | 47 | #endif // CEREAL_TYPES_UTILITY_HPP_ 48 | -------------------------------------------------------------------------------- /include/cereal/version.hpp: -------------------------------------------------------------------------------- 1 | /*! \file version.hpp 2 | \brief Macros to detect cereal version 3 | 4 | These macros can assist in determining the version of cereal. Be 5 | warned that cereal is not guaranteed to be compatible across 6 | different versions. For more information on releases of cereal, 7 | see https://github.com/USCiLab/cereal/releases. 8 | 9 | \ingroup utility */ 10 | /* 11 | Copyright (c) 2018, Shane Grant 12 | All rights reserved. 13 | 14 | Redistribution and use in source and binary forms, with or without 15 | modification, are permitted provided that the following conditions are met: 16 | * Redistributions of source code must retain the above copyright 17 | notice, this list of conditions and the following disclaimer. 18 | * Redistributions in binary form must reproduce the above copyright 19 | notice, this list of conditions and the following disclaimer in the 20 | documentation and/or other materials provided with the distribution. 21 | * Neither the name of the copyright holder nor the 22 | names of its contributors may be used to endorse or promote products 23 | derived from this software without specific prior written permission. 24 | 25 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 26 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 27 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 28 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY 29 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 30 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 31 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 32 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 33 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 34 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | */ 36 | 37 | #ifndef CEREAL_VERSION_HPP_ 38 | #define CEREAL_VERSION_HPP_ 39 | 40 | //! The major version 41 | #define CEREAL_VERSION_MAJOR 1 42 | //! The minor version 43 | #define CEREAL_VERSION_MINOR 3 44 | //! The patch version 45 | #define CEREAL_VERSION_PATCH 2 46 | 47 | //! The full version as a single number 48 | #define CEREAL_VERSION (CEREAL_VERSION_MAJOR * 10000 \ 49 | + CEREAL_VERSION_MINOR * 100 \ 50 | + CEREAL_VERSION_PATCH) 51 | 52 | #endif // CEREAL_VERSION_HPP_ 53 | -------------------------------------------------------------------------------- /sandbox/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(sandbox_shared_lib) 2 | 3 | add_executable(sandbox sandbox.cpp) 4 | target_link_libraries(sandbox ${CEREAL_THREAD_LIBS}) 5 | 6 | add_executable(sandbox_json sandbox_json.cpp) 7 | target_link_libraries(sandbox_json ${CEREAL_THREAD_LIBS}) 8 | 9 | add_executable(sandbox_rtti sandbox_rtti.cpp) 10 | target_link_libraries(sandbox_rtti ${CEREAL_THREAD_LIBS}) 11 | 12 | add_executable(sandbox_vs sandbox_vs.cpp) 13 | target_link_libraries(sandbox_vs sandbox_vs_dll) 14 | 15 | if(Boost_FOUND AND NOT SKIP_PERFORMANCE_COMPARISON) 16 | add_executable(performance performance.cpp) 17 | if(MSVC) 18 | set_target_properties(performance PROPERTIES COMPILE_DEFINITIONS "BOOST_SERIALIZATION_DYN_LINK") 19 | endif() 20 | target_include_directories(performance PUBLIC ${Boost_INCLUDE_DIRS}) 21 | target_link_libraries(performance ${CEREAL_THREAD_LIBS} ${Boost_LIBRARIES}) 22 | endif() 23 | -------------------------------------------------------------------------------- /sandbox/sandbox_shared_lib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_library(sandbox_vs_dll SHARED base.cpp derived.cpp) 2 | target_link_libraries(sandbox_vs_dll ${CEREAL_THREAD_LIBS}) 3 | target_include_directories(sandbox_vs_dll PUBLIC 4 | $ 5 | $ 6 | ) 7 | -------------------------------------------------------------------------------- /sandbox/sandbox_shared_lib/base.cpp: -------------------------------------------------------------------------------- 1 | #ifndef CEREAL_DLL_USE 2 | #define CEREAL_DLL_MAKE 3 | #endif 4 | #include "base.hpp" 5 | 6 | template void Base::serialize 7 | ( cereal::XMLOutputArchive & ar, std::uint32_t const version ); 8 | template void Base::serialize 9 | ( cereal::XMLInputArchive & ar, std::uint32_t const version ); 10 | -------------------------------------------------------------------------------- /sandbox/sandbox_shared_lib/base.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #if defined (_WINDLL) 9 | #define DECLSPECIFIER __declspec(dllexport) 10 | #elif defined(MSC_VER) 11 | #define DECLSPECIFIER __declspec(dllimport) 12 | #else 13 | #define DECLSPECIFIER 14 | #endif 15 | 16 | int doit(); 17 | 18 | class VersionTest 19 | { 20 | public: 21 | int x; 22 | template 23 | void serialize( Archive & ar, const std::uint32_t /* version */ ) 24 | { ar( x ); } 25 | }; 26 | 27 | class Base 28 | { 29 | public: 30 | friend class cereal::access; 31 | 32 | template < class Archive > 33 | void serialize(Archive &, std::uint32_t const) {} 34 | virtual ~Base() {} 35 | }; 36 | 37 | extern template DECLSPECIFIER void Base::serialize 38 | ( cereal::XMLInputArchive & ar, std::uint32_t const version ); 39 | 40 | extern template DECLSPECIFIER void Base::serialize 41 | ( cereal::XMLOutputArchive & ar, std::uint32_t const version ); 42 | 43 | CEREAL_CLASS_VERSION(VersionTest, 1) 44 | -------------------------------------------------------------------------------- /sandbox/sandbox_shared_lib/derived.cpp: -------------------------------------------------------------------------------- 1 | #ifndef CEREAL_DLL_USE 2 | #define CEREAL_DLL_MAKE 3 | #endif 4 | #include "derived.hpp" 5 | 6 | template void Derived::serialize 7 | ( cereal::XMLOutputArchive & ar, std::uint32_t const version ); 8 | 9 | template void Derived::serialize 10 | ( cereal::XMLInputArchive & ar, std::uint32_t const version ); 11 | -------------------------------------------------------------------------------- /sandbox/sandbox_shared_lib/derived.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "base.hpp" 3 | class Derived : public Base 4 | { 5 | public: 6 | virtual ~Derived() {} 7 | 8 | private: 9 | friend class cereal::access; 10 | template 11 | void serialize(Archive & ar, std::uint32_t const) 12 | { 13 | ar(cereal::base_class(this)); 14 | } 15 | }; 16 | 17 | extern template DECLSPECIFIER void Derived::serialize 18 | ( cereal::XMLOutputArchive & ar, std::uint32_t const version ); 19 | extern template DECLSPECIFIER void Derived::serialize 20 | ( cereal::XMLInputArchive & ar, std::uint32_t const version ); 21 | 22 | CEREAL_REGISTER_TYPE(Derived) 23 | -------------------------------------------------------------------------------- /scripts/add_rapidjson_prefix.sh: -------------------------------------------------------------------------------- 1 | # Applies renaming within all of the rapidjson source files to add a cereal prefix 2 | find ./../include/cereal/external/rapidjson/ -type f -name \*.h -exec sed -i "s/RAPIDJSON_/CEREAL_RAPIDJSON_/g" {} \; 3 | echo "Remember to backport any cereal specific changes not in this version of RapidJSON!" 4 | echo "See https://github.com/USCiLab/cereal/commits/develop/include/cereal/external/rapidjson" 5 | -------------------------------------------------------------------------------- /scripts/appveyor.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | setlocal enabledelayedexpansion 3 | 4 | if not defined APPVEYOR ( 5 | @echo This script is meant to be used with AppVeyor CI. This can be used as reference. 6 | @echo I sincerely recommend not using it for building/testing cereal locally. 7 | exit /b 0 8 | ) 9 | 10 | if not defined BOOST_ROOT ( 11 | set BOOST_ROOT=C:\Libraries\boost 12 | ) 13 | 14 | if not defined VS_VERSION_MAJOR ( 15 | set VS_VERSION_MAJOR=14 16 | ) 17 | if not defined VS_VERSION_YEAR ( 18 | if "%VS_VERSION_MAJOR%" == "12" ( 19 | set VS_VERSION_YEAR=2013 20 | ) else if "%VS_VERSION_MAJOR%" == "14" ( 21 | set VS_VERSION_YEAR=2015 22 | ) else if "%VS_VERSION_MAJOR%" == "15" ( 23 | set VS_VERSION_YEAR=2017 24 | ) else if "%VS_VERSION_MAJOR%" == "16" ( 25 | set VS_VERSION_YEAR=2019 26 | ) else if "%VS_VERSION_MAJOR%" == "17" ( 27 | set VS_VERSION_YEAR=2022 28 | ) else ( 29 | @echo Cannot use Visual Studio version %VS_VERSION_MAJOR% 30 | exit /b 1 31 | ) 32 | ) 33 | if not defined CMAKE_GENERATOR_PREFIX ( 34 | set CMAKE_GENERATOR_PREFIX=Visual Studio %VS_VERSION_MAJOR% %VS_VERSION_YEAR% 35 | ) 36 | 37 | @rem CONFIGURATION is (one of the entries) defined in appveyor.yml 38 | if not defined CONFIGURATION ( 39 | set CONFIGURATION=Release 40 | ) 41 | @rem PLATFORM is (one of the entries) defined in appveyor.yml 42 | if "%PLATFORM%"=="x64" ( 43 | set BIT_COUNT=64 44 | ) else ( 45 | set BIT_COUNT=32 46 | ) 47 | 48 | set BOOST_LIBRARYDIR=%BOOST_ROOT%\lib%BIT_COUNT%-msvc-%VS_VERSION_MAJOR%.0 49 | 50 | set START_DIR=%CD% 51 | 52 | if not exist build\NUL mkdir build 53 | cd build 54 | 55 | if "%~1" == "test" ( 56 | @rem overloading the batch script; Run tests if the first argument is `test` (without quotes). 57 | @rem Cereal uses Boost Unit test framework. Rather than modifying the code to load boost test 58 | @rem dll from its location OR copying the boost dlls to the directory of every test being run, 59 | @rem we use another option Windows leaves us - modify the PATH. 60 | for %%i in (ctest.exe) do set CTEST_EXE=%%~$PATH:i 61 | PATH %BOOST_LIBRARYDIR% 62 | "!CTEST_EXE!" -C %CONFIGURATION% 63 | if %errorlevel% neq 0 exit /b %errorlevel% 64 | goto done 65 | ) 66 | 67 | if "%PLATFORM%" == "x64" ( 68 | @rem please excuse the hack - CMake is unable to produce multiarch MSVC projects 69 | cmake -G "%CMAKE_GENERATOR_PREFIX%" -DBOOST_ROOT=%BOOST_ROOT% -DBOOST_LIBRARYDIR=%BOOST_LIBRARYDIR% .. 70 | cmake --build . --config %CONFIGURATION% --target portability_test32 71 | del CMakeCache.txt 72 | rmdir /s /q CMakeFiles 73 | ) 74 | 75 | cmake -G "%CMAKE_GENERATOR_PREFIX%" -A %PLATFORM% -DBOOST_ROOT=%BOOST_ROOT% -DBOOST_LIBRARYDIR=%BOOST_LIBRARYDIR% .. 76 | @rem left the actual build for later - AppVeyor enables parallel jobs in a much cleaner way than msbuild 77 | 78 | :done 79 | @REM go back home 80 | cd %START_DIR% 81 | -------------------------------------------------------------------------------- /scripts/renameincludes.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | destdir="include_renamed" 4 | 5 | echo -n "New prefix: " 6 | read newprefix 7 | 8 | cp -r include ${destdir} 9 | 10 | newprefix=$(echo ${newprefix} | sed -e 's/\//\\\//') 11 | 12 | find ${destdir} -name '*.hpp' -exec sed -i "s/#include (); 35 | test_array(); 36 | } 37 | 38 | TEST_CASE("portable_binary_array") 39 | { 40 | test_array(); 41 | test_array(); 42 | } 43 | 44 | TEST_CASE("xml_array") 45 | { 46 | test_array(); 47 | test_array(); 48 | } 49 | 50 | TEST_CASE("json_array") 51 | { 52 | test_array(); 53 | test_array(); 54 | } 55 | 56 | TEST_SUITE_END(); 57 | -------------------------------------------------------------------------------- /unittests/atomic.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, Randolph Voorhies, Shane Grant 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of the copyright holder nor the 13 | names of its contributors may be used to endorse or promote products 14 | derived from this software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN 28 | #include "atomic.hpp" 29 | 30 | TEST_SUITE_BEGIN("atomic"); 31 | 32 | TEST_CASE("binary_atomic") 33 | { 34 | test_atomic(); 35 | } 36 | 37 | TEST_CASE("portable_binary_atomic") 38 | { 39 | test_atomic(); 40 | } 41 | 42 | TEST_CASE("xml_atomic") 43 | { 44 | test_atomic(); 45 | } 46 | 47 | TEST_CASE("json_atomic") 48 | { 49 | test_atomic(); 50 | } 51 | 52 | TEST_SUITE_END(); 53 | -------------------------------------------------------------------------------- /unittests/bitset.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, Randolph Voorhies, Shane Grant 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of the copyright holder nor the 13 | names of its contributors may be used to endorse or promote products 14 | derived from this software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN 28 | #include "bitset.hpp" 29 | 30 | TEST_SUITE_BEGIN("bitset"); 31 | 32 | TEST_CASE("binary_bitset") 33 | { 34 | test_bitset(); 35 | } 36 | 37 | TEST_CASE("portable_binary_bitset") 38 | { 39 | test_bitset(); 40 | } 41 | 42 | TEST_CASE("xml_bitset") 43 | { 44 | test_bitset(); 45 | } 46 | 47 | TEST_CASE("json_bitset") 48 | { 49 | test_bitset(); 50 | } 51 | 52 | TEST_SUITE_END(); 53 | -------------------------------------------------------------------------------- /unittests/bitset.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, Randolph Voorhies, Shane Grant 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of the copyright holder nor the 13 | names of its contributors may be used to endorse or promote products 14 | derived from this software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | #ifndef CEREAL_TEST_BITSET_H_ 28 | #define CEREAL_TEST_BITSET_H_ 29 | #include "common.hpp" 30 | 31 | template inline 32 | void test_bitset() 33 | { 34 | std::random_device rd; 35 | std::mt19937 gen(rd()); 36 | 37 | auto rng32 = [&](){ return random_binary_string<32>( gen ); }; 38 | auto rng65 = [&](){ return random_binary_string<65>( gen ); }; 39 | auto rng256 = [&](){ return random_binary_string<256>( gen ); }; 40 | auto rng512 = [&](){ return random_binary_string<512>( gen ); }; 41 | 42 | for(int ii=0; ii<100; ++ii) 43 | { 44 | std::bitset<32> o_bit32( rng32() ); 45 | std::bitset<65> o_bit65( rng65() ); 46 | std::bitset<256> o_bit256( rng256() ); 47 | std::bitset<512> o_bit512( rng512() ); 48 | std::bitset<32> o_bit32_low( 0 ); 49 | 50 | std::ostringstream os; 51 | { 52 | OArchive oar(os); 53 | 54 | oar(o_bit32); 55 | oar(o_bit65); 56 | oar(o_bit256); 57 | oar(o_bit512); 58 | oar(o_bit32_low); 59 | } 60 | 61 | std::bitset<32> i_bit32; 62 | std::bitset<65> i_bit65; 63 | std::bitset<256> i_bit256; 64 | std::bitset<512> i_bit512; 65 | std::bitset<32> i_bit32_low( 0xffffffff ); 66 | 67 | std::istringstream is(os.str()); 68 | { 69 | IArchive iar(is); 70 | 71 | iar(i_bit32); 72 | iar(i_bit65); 73 | iar(i_bit256); 74 | iar(i_bit512); 75 | iar(i_bit32_low); 76 | } 77 | 78 | CHECK_EQ( o_bit32, i_bit32 ); 79 | CHECK_EQ( o_bit65, i_bit65 ); 80 | CHECK_EQ( o_bit256, i_bit256 ); 81 | CHECK_EQ( o_bit512, i_bit512 ); 82 | 83 | CHECK_EQ( o_bit32_low, i_bit32_low ); 84 | } 85 | } 86 | 87 | #endif // CEREAL_TEST_BITSET_H_ 88 | -------------------------------------------------------------------------------- /unittests/boost/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB TESTS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp) 2 | 3 | include_directories(SYSTEM ${Boost_INCLUDE_DIRS}) 4 | 5 | # Build all of the non-special tests 6 | foreach(TEST_SOURCE ${TESTS}) 7 | message(STATUS ${TEST_SOURCE}) 8 | 9 | string(REPLACE ".cpp" "" TEST_TARGET "${TEST_SOURCE}") 10 | set(TEST_TARGET "test_${TEST_TARGET}") 11 | 12 | add_executable(${TEST_TARGET} ${TEST_SOURCE}) 13 | target_link_libraries(${TEST_TARGET} ${CEREAL_THREAD_LIBS}) 14 | add_test(NAME "${TEST_TARGET}" COMMAND "${TEST_TARGET}") 15 | 16 | # If we are on a 64-bit machine, create an extra 32-bit version of the test if portability testing is enabled 17 | if((NOT MSVC) AND (${CMAKE_SIZEOF_VOID_P} EQUAL 8) AND (NOT SKIP_PORTABILITY_TEST)) 18 | add_executable(${TEST_TARGET}_32 ${TEST_SOURCE}) 19 | target_link_libraries(${TEST_TARGET}_32 ${CEREAL_THREAD_LIBS}) 20 | set_target_properties(${TEST_TARGET}_32 PROPERTIES 21 | COMPILE_FLAGS "-m32" LINK_FLAGS "-m32") 22 | add_test(NAME "${TEST_TARGET}_32" COMMAND "${TEST_TARGET}_32") 23 | endif() 24 | 25 | endforeach() 26 | 27 | if(NOT MSVC) 28 | # add tests to coverage 29 | foreach(TEST_SOURCE ${TESTS}) 30 | string(REPLACE ".cpp" "" COVERAGE_TARGET "${TEST_SOURCE}") 31 | set(COVERAGE_TARGET "coverage_${COVERAGE_TARGET}") 32 | 33 | add_dependencies(coverage ${COVERAGE_TARGET}) 34 | 35 | add_executable(${COVERAGE_TARGET} EXCLUDE_FROM_ALL ${TEST_SOURCE}) 36 | set_target_properties(${COVERAGE_TARGET} PROPERTIES COMPILE_FLAGS "-coverage") 37 | set_target_properties(${COVERAGE_TARGET} PROPERTIES LINK_FLAGS "-coverage") 38 | set_target_properties(${COVERAGE_TARGET} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/coverage") 39 | target_link_libraries(${COVERAGE_TARGET} ${CEREAL_THREAD_LIBS}) 40 | endforeach() 41 | endif() 42 | -------------------------------------------------------------------------------- /unittests/boost/boost_variant.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2015, Kyle Fleming 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of the copyright holder nor the 13 | names of its contributors may be used to endorse or promote products 14 | derived from this software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN 28 | #include "boost_variant.hpp" 29 | 30 | TEST_SUITE_BEGIN("boost_variant"); 31 | 32 | TEST_CASE("binary_boost_variant") 33 | { 34 | test_boost_variant(); 35 | } 36 | 37 | TEST_CASE("portable_binary_boost_variant") 38 | { 39 | test_boost_variant(); 40 | } 41 | 42 | TEST_CASE("xml_boost_variant") 43 | { 44 | test_boost_variant(); 45 | } 46 | 47 | TEST_CASE("json_boost_variant") 48 | { 49 | test_boost_variant(); 50 | } 51 | 52 | TEST_SUITE_END(); 53 | -------------------------------------------------------------------------------- /unittests/chrono.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, Randolph Voorhies, Shane Grant 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of the copyright holder nor the 13 | names of its contributors may be used to endorse or promote products 14 | derived from this software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN 28 | #include "chrono.hpp" 29 | 30 | TEST_SUITE_BEGIN("chrono"); 31 | 32 | TEST_CASE("binary_chrono") 33 | { 34 | test_chrono(); 35 | } 36 | 37 | TEST_CASE("portable_binary_chrono") 38 | { 39 | test_chrono(); 40 | } 41 | 42 | TEST_CASE("xml_chrono") 43 | { 44 | test_chrono(); 45 | } 46 | 47 | TEST_CASE("json_chrono") 48 | { 49 | test_chrono(); 50 | } 51 | 52 | TEST_SUITE_END(); 53 | -------------------------------------------------------------------------------- /unittests/complex.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, Randolph Voorhies, Shane Grant 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of the copyright holder nor the 13 | names of its contributors may be used to endorse or promote products 14 | derived from this software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN 28 | #include "complex.hpp" 29 | 30 | TEST_SUITE_BEGIN("complex"); 31 | 32 | TEST_CASE("binary_complex") 33 | { 34 | test_complex(); 35 | } 36 | 37 | TEST_CASE("portable_binary_complex") 38 | { 39 | test_complex(); 40 | } 41 | 42 | TEST_CASE("xml_complex") 43 | { 44 | test_complex(); 45 | } 46 | 47 | TEST_CASE("json_complex") 48 | { 49 | test_complex(); 50 | } 51 | 52 | TEST_SUITE_END(); 53 | -------------------------------------------------------------------------------- /unittests/complex.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, Randolph Voorhies, Shane Grant 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of the copyright holder nor the 13 | names of its contributors may be used to endorse or promote products 14 | derived from this software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | #ifndef CEREAL_TEST_COMPLEX_H_ 28 | #define CEREAL_TEST_COMPLEX_H_ 29 | #include "common.hpp" 30 | 31 | template inline 32 | void test_complex() 33 | { 34 | std::random_device rd; 35 | std::mt19937 gen(rd()); 36 | 37 | auto rngF = [&](){ return random_value(gen); }; 38 | auto rngD = [&](){ return random_value(gen); }; 39 | auto rngLD = [&](){ return random_value(gen); }; 40 | 41 | for(int ii=0; ii<100; ++ii) 42 | { 43 | std::complex o_float( rngF(), rngF() ); 44 | std::complex o_double( rngD(), rngD() ); 45 | std::complex o_ldouble( rngLD(), rngLD() ); 46 | 47 | std::ostringstream os; 48 | { 49 | OArchive oar(os); 50 | 51 | oar(o_float); 52 | oar(o_double); 53 | oar(o_ldouble); 54 | } 55 | 56 | std::complex i_float; 57 | std::complex i_double; 58 | std::complex i_ldouble; 59 | 60 | std::istringstream is(os.str()); 61 | { 62 | IArchive iar(is); 63 | 64 | iar(i_float); 65 | iar(i_double); 66 | iar(i_ldouble); 67 | } 68 | 69 | CHECK_EQ( o_float, i_float ); 70 | CHECK_EQ( o_double.real(), doctest::Approx(i_double.real()).epsilon(1e-5) ); 71 | CHECK_EQ( o_double.imag(), doctest::Approx(i_double.imag()).epsilon(1e-5) ); 72 | CHECK_EQ( o_ldouble.real(), doctest::Approx(i_ldouble.real()).epsilon(1e-5L) ); 73 | CHECK_EQ( o_ldouble.imag(), doctest::Approx(i_ldouble.imag()).epsilon(1e-5L) ); 74 | } 75 | } 76 | 77 | #endif // CEREAL_TEST_COMPLEX_H_ 78 | -------------------------------------------------------------------------------- /unittests/cpp17/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB TESTS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp) 2 | 3 | # Build all of the non-special tests 4 | foreach(TEST_SOURCE ${TESTS}) 5 | message(STATUS ${TEST_SOURCE}) 6 | 7 | string(REPLACE ".cpp" "" TEST_TARGET "${TEST_SOURCE}") 8 | set(TEST_TARGET "test_cpp17_${TEST_TARGET}") 9 | 10 | add_executable(${TEST_TARGET} ${TEST_SOURCE}) 11 | target_link_libraries(${TEST_TARGET} ${CEREAL_THREAD_LIBS}) 12 | add_test(NAME "${TEST_TARGET}" COMMAND "${TEST_TARGET}") 13 | 14 | # If we are on a 64-bit machine, create an extra 32-bit version of the test if portability testing is enabled 15 | if((NOT MSVC) AND (${CMAKE_SIZEOF_VOID_P} EQUAL 8) AND (NOT SKIP_PORTABILITY_TEST)) 16 | add_executable(${TEST_TARGET}_32 ${TEST_SOURCE}) 17 | target_link_libraries(${TEST_TARGET}_32 ${CEREAL_THREAD_LIBS}) 18 | set_target_properties(${TEST_TARGET}_32 PROPERTIES 19 | COMPILE_FLAGS "-m32" LINK_FLAGS "-m32") 20 | add_test(NAME "${TEST_TARGET}_32" COMMAND "${TEST_TARGET}_32") 21 | endif() 22 | 23 | endforeach() 24 | 25 | if(NOT MSVC) 26 | # add tests to coverage 27 | foreach(TEST_SOURCE ${TESTS}) 28 | string(REPLACE ".cpp" "" COVERAGE_TARGET "${TEST_SOURCE}") 29 | set(COVERAGE_TARGET "coverage_cpp17_${COVERAGE_TARGET}") 30 | 31 | add_dependencies(coverage ${COVERAGE_TARGET}) 32 | 33 | add_executable(${COVERAGE_TARGET} EXCLUDE_FROM_ALL ${TEST_SOURCE}) 34 | set_target_properties(${COVERAGE_TARGET} PROPERTIES COMPILE_FLAGS "-coverage") 35 | set_target_properties(${COVERAGE_TARGET} PROPERTIES LINK_FLAGS "-coverage") 36 | set_target_properties(${COVERAGE_TARGET} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/coverage") 37 | target_link_libraries(${COVERAGE_TARGET} ${CEREAL_THREAD_LIBS}) 38 | endforeach() 39 | endif() 40 | -------------------------------------------------------------------------------- /unittests/cpp17/optional.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017, Juan Pedro Bolivar Puente 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of the copyright holder nor the 13 | names of its contributors may be used to endorse or promote products 14 | derived from this software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN 29 | #include "optional.hpp" 30 | 31 | #ifdef CEREAL_HAS_CPP17 32 | 33 | TEST_SUITE_BEGIN("std_optional"); 34 | 35 | TEST_CASE("binary_std_optional") 36 | { 37 | test_std_optional(); 38 | } 39 | 40 | TEST_CASE("portable_binary_std_optional") 41 | { 42 | test_std_optional(); 43 | } 44 | 45 | TEST_CASE("xml_std_optional") 46 | { 47 | test_std_optional(); 48 | } 49 | 50 | TEST_CASE("json_std_optional") 51 | { 52 | test_std_optional(); 53 | } 54 | 55 | TEST_SUITE_END(); 56 | 57 | #endif // CEREAL_HAS_CPP17 58 | -------------------------------------------------------------------------------- /unittests/cpp17/optional.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017, Juan Pedro Bolivar Puente 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of the copyright holder nor the 13 | names of its contributors may be used to endorse or promote products 14 | derived from this software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | #ifndef CEREAL_TEST_CPP17_OPTIONAL_H_ 28 | #define CEREAL_TEST_CPP17_OPTIONAL_H_ 29 | #include "../common.hpp" 30 | 31 | #ifdef CEREAL_HAS_CPP17 32 | #include 33 | 34 | template inline 35 | void test_std_optional() 36 | { 37 | std::random_device rd; 38 | std::mt19937 gen(rd()); 39 | 40 | std::optional o_o1 = random_value(gen); 41 | std::optional o_o2 = random_value(gen); 42 | std::optional o_o3 = random_basic_string(gen); 43 | std::optional o_o4 = std::nullopt; 44 | std::optional o_o5 = std::nullopt; 45 | std::optional o_o6 = std::nullopt; 46 | std::optional> o_o7 = std::make_optional>( std::make_optional( random_value(gen) ) ); 47 | 48 | std::ostringstream os; 49 | { 50 | OArchive oar(os); 51 | 52 | oar(o_o1); 53 | oar(o_o2); 54 | oar(o_o3); 55 | oar(o_o4); 56 | oar(o_o5); 57 | oar(o_o6); 58 | oar(o_o7); 59 | } 60 | 61 | decltype(o_o1) i_o1; 62 | decltype(o_o2) i_o2; 63 | decltype(o_o3) i_o3; 64 | decltype(o_o4) i_o4{1}; // initialize with non-nullopt 65 | decltype(o_o5) i_o5{1.0}; 66 | decltype(o_o6) i_o6{"1"}; 67 | decltype(o_o7) i_o7; 68 | 69 | std::istringstream is(os.str()); 70 | { 71 | IArchive iar(is); 72 | 73 | iar(i_o1); 74 | iar(i_o2); 75 | iar(i_o3); 76 | iar(i_o4); 77 | iar(i_o5); 78 | iar(i_o6); 79 | iar(i_o7); 80 | } 81 | 82 | CHECK_EQ( *i_o1, *o_o1 ); 83 | CHECK_EQ( *i_o2, doctest::Approx(*o_o2).epsilon(1e-5) ); 84 | CHECK_EQ( *i_o3, *o_o3 ); 85 | CHECK_EQ( i_o4.has_value(), o_o4.has_value() ); 86 | CHECK_EQ( i_o5.has_value(), o_o5.has_value() ); 87 | CHECK_EQ( i_o6.has_value(), o_o6.has_value() ); 88 | CHECK_EQ( **i_o7, **o_o7 ); 89 | } 90 | 91 | #endif // CEREAL_HAS_CPP17 92 | #endif // CEREAL_TEST_CPP17_OPTIONAL_H_ 93 | -------------------------------------------------------------------------------- /unittests/cpp17/variant.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2015, Kyle Fleming, Juan Pedro Bolivar Puente 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of the copyright holder nor the 13 | names of its contributors may be used to endorse or promote products 14 | derived from this software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN 29 | #include "variant.hpp" 30 | 31 | #ifdef CEREAL_HAS_CPP17 32 | 33 | TEST_SUITE_BEGIN("std_variant"); 34 | 35 | TEST_CASE("binary_std_variant") 36 | { 37 | test_std_variant(); 38 | } 39 | 40 | TEST_CASE("portable_binary_std_variant") 41 | { 42 | test_std_variant(); 43 | } 44 | 45 | TEST_CASE("xml_std_variant") 46 | { 47 | test_std_variant(); 48 | } 49 | 50 | TEST_CASE("json_std_variant") 51 | { 52 | test_std_variant(); 53 | } 54 | 55 | TEST_SUITE_END(); 56 | 57 | #endif // CEREAL_HAS_CPP17 58 | -------------------------------------------------------------------------------- /unittests/cpp17/variant.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2015, Kyle Fleming, Juan Pedro Bolivar Puente 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of the copyright holder nor the 13 | names of its contributors may be used to endorse or promote products 14 | derived from this software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef CEREAL_TEST_CPP17_VARIANT_H_ 29 | #define CEREAL_TEST_CPP17_VARIANT_H_ 30 | #include "../common.hpp" 31 | 32 | #ifdef CEREAL_HAS_CPP17 33 | 34 | #include 35 | 36 | template inline 37 | void test_std_variant() 38 | { 39 | std::random_device rd; 40 | std::mt19937 gen(rd()); 41 | 42 | std::variant o_bv1 = random_value(gen); 43 | std::variant o_bv2 = random_value(gen); 44 | std::variant o_bv3 = random_basic_string(gen); 45 | 46 | std::ostringstream os; 47 | { 48 | OArchive oar(os); 49 | 50 | oar(o_bv1); 51 | oar(o_bv2); 52 | oar(o_bv3); 53 | } 54 | 55 | decltype(o_bv1) i_bv1; 56 | decltype(o_bv2) i_bv2; 57 | decltype(o_bv3) i_bv3; 58 | 59 | std::istringstream is(os.str()); 60 | { 61 | IArchive iar(is); 62 | 63 | iar(i_bv1); 64 | iar(i_bv2); 65 | iar(i_bv3); 66 | } 67 | 68 | CHECK_EQ( std::get(i_bv1), std::get(o_bv1) ); 69 | CHECK_EQ( std::get(i_bv2), doctest::Approx(std::get(o_bv2)).epsilon(1e-5) ); 70 | CHECK_EQ( std::get(i_bv3), std::get(o_bv3) ); 71 | } 72 | 73 | #endif // CEREAL_HAS_CPP17 74 | #endif // CEREAL_TEST_CPP17_VARIANT_H_ 75 | -------------------------------------------------------------------------------- /unittests/defer.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, Randolph Voorhies, Shane Grant 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of the copyright holder nor the 13 | names of its contributors may be used to endorse or promote products 14 | derived from this software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN 28 | #include "defer.hpp" 29 | 30 | TEST_SUITE_BEGIN("defer"); 31 | 32 | TEST_CASE("binary_defer") 33 | { 34 | test_defer(); 35 | } 36 | 37 | TEST_CASE("portable_binary_defer") 38 | { 39 | test_defer(); 40 | } 41 | 42 | TEST_CASE("xml_defer") 43 | { 44 | test_defer(); 45 | } 46 | 47 | TEST_CASE("json_defer") 48 | { 49 | test_defer(); 50 | } 51 | 52 | TEST_SUITE_END(); 53 | -------------------------------------------------------------------------------- /unittests/deque.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, Randolph Voorhies, Shane Grant 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of the copyright holder nor the 13 | names of its contributors may be used to endorse or promote products 14 | derived from this software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN 28 | #include "deque.hpp" 29 | 30 | TEST_SUITE_BEGIN("deque"); 31 | 32 | TEST_CASE("binary_dequeue") 33 | { 34 | test_deque(); 35 | } 36 | 37 | TEST_CASE("portable_binary_dequeue") 38 | { 39 | test_deque(); 40 | } 41 | 42 | TEST_CASE("xml_dequeue") 43 | { 44 | test_deque(); 45 | } 46 | 47 | TEST_CASE("json_dequeue") 48 | { 49 | test_deque(); 50 | } 51 | 52 | TEST_SUITE_END(); 53 | -------------------------------------------------------------------------------- /unittests/forward_list.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, Randolph Voorhies, Shane Grant 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of the copyright holder nor the 13 | names of its contributors may be used to endorse or promote products 14 | derived from this software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN 28 | #include "forward_list.hpp" 29 | 30 | TEST_SUITE_BEGIN("forward_list"); 31 | 32 | TEST_CASE("binary_forward_list") 33 | { 34 | test_forward_list(); 35 | } 36 | 37 | TEST_CASE("portable_binary_forward_list") 38 | { 39 | test_forward_list(); 40 | } 41 | 42 | TEST_CASE("xml_forward_list") 43 | { 44 | test_forward_list(); 45 | } 46 | 47 | TEST_CASE("json_forward_list") 48 | { 49 | test_forward_list(); 50 | } 51 | 52 | TEST_SUITE_END(); 53 | -------------------------------------------------------------------------------- /unittests/list.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, Randolph Voorhies, Shane Grant 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of the copyright holder nor the 13 | names of its contributors may be used to endorse or promote products 14 | derived from this software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN 28 | #include "list.hpp" 29 | 30 | TEST_SUITE_BEGIN("list"); 31 | 32 | TEST_CASE("binary_list") 33 | { 34 | test_list(); 35 | } 36 | 37 | TEST_CASE("portable_binary_list") 38 | { 39 | test_list(); 40 | } 41 | 42 | TEST_CASE("xml_list") 43 | { 44 | test_list(); 45 | } 46 | 47 | TEST_CASE("json_list") 48 | { 49 | test_list(); 50 | } 51 | 52 | TEST_SUITE_END(); 53 | -------------------------------------------------------------------------------- /unittests/load_construct.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, Randolph Voorhies, Shane Grant 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of the copyright holder nor the 13 | names of its contributors may be used to endorse or promote products 14 | derived from this software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN 28 | #include "load_construct.hpp" 29 | 30 | TEST_SUITE_BEGIN("load_construct"); 31 | 32 | TEST_CASE("binary_memory_load_construct") 33 | { 34 | test_memory_load_construct(); 35 | } 36 | 37 | TEST_CASE("portable_binary_memory_load_construct") 38 | { 39 | test_memory_load_construct(); 40 | } 41 | 42 | TEST_CASE("xml_memory_load_construct") 43 | { 44 | test_memory_load_construct(); 45 | } 46 | 47 | TEST_CASE("json_memory_load_construct") 48 | { 49 | test_memory_load_construct(); 50 | } 51 | 52 | TEST_SUITE_END(); 53 | -------------------------------------------------------------------------------- /unittests/map.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, Randolph Voorhies, Shane Grant 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of the copyright holder nor the 13 | names of its contributors may be used to endorse or promote products 14 | derived from this software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN 28 | #include "map.hpp" 29 | 30 | TEST_SUITE_BEGIN("map"); 31 | 32 | TEST_CASE("binary_map") 33 | { 34 | test_map(); 35 | } 36 | 37 | TEST_CASE("portable_binary_map") 38 | { 39 | test_map(); 40 | } 41 | 42 | TEST_CASE("xml_map") 43 | { 44 | test_map(); 45 | } 46 | 47 | TEST_CASE("json_map") 48 | { 49 | test_map(); 50 | } 51 | 52 | TEST_CASE("binary_map_memory") 53 | { 54 | test_map_memory(); 55 | } 56 | 57 | TEST_CASE("portable_binary_map_memory") 58 | { 59 | test_map_memory(); 60 | } 61 | 62 | TEST_CASE("xml_map_memory") 63 | { 64 | test_map_memory(); 65 | } 66 | 67 | TEST_CASE("json_map_memory") 68 | { 69 | test_map_memory(); 70 | } 71 | 72 | TEST_SUITE_END(); 73 | -------------------------------------------------------------------------------- /unittests/memory.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, Randolph Voorhies, Shane Grant 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of the copyright holder nor the 13 | names of its contributors may be used to endorse or promote products 14 | derived from this software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN 28 | #include "memory.hpp" 29 | 30 | TEST_SUITE_BEGIN("memory"); 31 | 32 | TEST_CASE("binary_memory") 33 | { 34 | test_memory(); 35 | } 36 | 37 | TEST_CASE("portable_binary_memory") 38 | { 39 | test_memory(); 40 | } 41 | 42 | TEST_CASE("xml_memory") 43 | { 44 | test_memory(); 45 | } 46 | 47 | TEST_CASE("json_memory") 48 | { 49 | test_memory(); 50 | } 51 | 52 | TEST_CASE("binary_default_construction") 53 | { 54 | test_default_construction(); 55 | } 56 | 57 | TEST_CASE("portable_binary_default_construction") 58 | { 59 | test_default_construction(); 60 | } 61 | 62 | TEST_CASE("xml_default_construction") 63 | { 64 | test_default_construction(); 65 | } 66 | 67 | TEST_CASE("json_default_construction") 68 | { 69 | test_default_construction(); 70 | } 71 | 72 | TEST_SUITE_END(); 73 | -------------------------------------------------------------------------------- /unittests/memory_cycles.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, Randolph Voorhies, Shane Grant 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of the copyright holder nor the 13 | names of its contributors may be used to endorse or promote products 14 | derived from this software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN 28 | #include "memory_cycles.hpp" 29 | 30 | TEST_SUITE_BEGIN("memory_cycles"); 31 | 32 | TEST_CASE("binary_memory_cycles") 33 | { 34 | test_memory_cycles(); 35 | } 36 | 37 | TEST_CASE("portable_binary_memory_cycles") 38 | { 39 | test_memory_cycles(); 40 | } 41 | 42 | TEST_CASE("xml_memory_cycles") 43 | { 44 | test_memory_cycles(); 45 | } 46 | 47 | TEST_CASE("json_memory_cycles") 48 | { 49 | test_memory_cycles(); 50 | } 51 | 52 | TEST_SUITE_END(); 53 | -------------------------------------------------------------------------------- /unittests/multimap.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, Randolph Voorhies, Shane Grant 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of the copyright holder nor the 13 | names of its contributors may be used to endorse or promote products 14 | derived from this software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN 28 | #include "multimap.hpp" 29 | 30 | TEST_SUITE_BEGIN("multimap"); 31 | 32 | TEST_CASE("binary_multimap") 33 | { 34 | test_multimap(); 35 | } 36 | 37 | TEST_CASE("portable_binary_multimap") 38 | { 39 | test_multimap(); 40 | } 41 | 42 | TEST_CASE("xml_multimap") 43 | { 44 | test_multimap(); 45 | } 46 | 47 | TEST_CASE("json_multimap") 48 | { 49 | test_multimap(); 50 | } 51 | 52 | TEST_SUITE_END(); 53 | -------------------------------------------------------------------------------- /unittests/multiset.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, Randolph Voorhies, Shane Grant 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of the copyright holder nor the 13 | names of its contributors may be used to endorse or promote products 14 | derived from this software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN 28 | #include "multiset.hpp" 29 | 30 | TEST_SUITE_BEGIN("multiset"); 31 | 32 | TEST_CASE("binary_multiset") 33 | { 34 | test_multiset(); 35 | } 36 | 37 | TEST_CASE("portable_binary_multiset") 38 | { 39 | test_multiset(); 40 | } 41 | 42 | TEST_CASE("xml_multiset") 43 | { 44 | test_multiset(); 45 | } 46 | 47 | TEST_CASE("json_multiset") 48 | { 49 | test_multiset(); 50 | } 51 | 52 | TEST_SUITE_END(); 53 | -------------------------------------------------------------------------------- /unittests/pair.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, Randolph Voorhies, Shane Grant 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of the copyright holder nor the 13 | names of its contributors may be used to endorse or promote products 14 | derived from this software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN 28 | #include "pair.hpp" 29 | 30 | TEST_SUITE_BEGIN("pair"); 31 | 32 | TEST_CASE("binary_pair") 33 | { 34 | test_pair(); 35 | } 36 | 37 | TEST_CASE("portable_binary_pair") 38 | { 39 | test_pair(); 40 | } 41 | 42 | TEST_CASE("xml_pair") 43 | { 44 | test_pair(); 45 | } 46 | TEST_CASE("json_pair") 47 | { 48 | test_pair(); 49 | } 50 | 51 | TEST_SUITE_END(); 52 | -------------------------------------------------------------------------------- /unittests/pod.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, Randolph Voorhies, Shane Grant 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of the copyright holder nor the 13 | names of its contributors may be used to endorse or promote products 14 | derived from this software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN 28 | #include "pod.hpp" 29 | 30 | TEST_SUITE_BEGIN("pod"); 31 | 32 | TEST_CASE("binary_pod") 33 | { 34 | test_pod(); 35 | } 36 | 37 | TEST_CASE("portable_binary_pod") 38 | { 39 | test_pod(); 40 | } 41 | 42 | TEST_CASE("xml_pod") 43 | { 44 | test_pod(); 45 | } 46 | 47 | TEST_CASE("json_pod") 48 | { 49 | test_pod(); 50 | } 51 | 52 | TEST_CASE("xml_pod_serialization") 53 | { 54 | test_pod_serialization(); 55 | } 56 | 57 | TEST_CASE("json_pod_serialization") 58 | { 59 | test_pod_serialization(); 60 | } 61 | 62 | TEST_SUITE_END(); 63 | -------------------------------------------------------------------------------- /unittests/polymorphic.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, Randolph Voorhies, Shane Grant 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of the copyright holder nor the 13 | names of its contributors may be used to endorse or promote products 14 | derived from this software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN 28 | #include "polymorphic.hpp" 29 | 30 | TEST_SUITE_BEGIN("polymorphic"); 31 | 32 | TEST_CASE("binary_polymorphic") 33 | { 34 | test_polymorphic(); 35 | } 36 | 37 | TEST_CASE("portable_binary_polymorphic") 38 | { 39 | test_polymorphic(); 40 | } 41 | 42 | TEST_CASE("xml_polymorphic") 43 | { 44 | test_polymorphic(); 45 | } 46 | 47 | TEST_CASE("json_polymorphic") 48 | { 49 | test_polymorphic(); 50 | } 51 | 52 | #if CEREAL_THREAD_SAFE 53 | TEST_CASE("binary_polymorphic_threading") 54 | { 55 | test_polymorphic_threading(); 56 | } 57 | 58 | TEST_CASE("portable_binary_polymorphic_threading") 59 | { 60 | test_polymorphic_threading(); 61 | } 62 | 63 | TEST_CASE("xml_polymorphic_threading") 64 | { 65 | test_polymorphic_threading(); 66 | } 67 | 68 | TEST_CASE("json_polymorphic_threading") 69 | { 70 | test_polymorphic_threading(); 71 | } 72 | #endif // CEREAL_THREAD_SAFE 73 | 74 | TEST_SUITE_END(); 75 | -------------------------------------------------------------------------------- /unittests/priority_queue.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, Randolph Voorhies, Shane Grant 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of the copyright holder nor the 13 | names of its contributors may be used to endorse or promote products 14 | derived from this software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN 28 | #include "priority_queue.hpp" 29 | 30 | TEST_SUITE_BEGIN("priority_queue"); 31 | 32 | TEST_CASE("binary_priority_queue") 33 | { 34 | test_priority_queue(); 35 | } 36 | 37 | TEST_CASE("portable_binary_priority_queue") 38 | { 39 | test_priority_queue(); 40 | } 41 | 42 | TEST_CASE("xml_priority_queue") 43 | { 44 | test_priority_queue(); 45 | } 46 | 47 | TEST_CASE("json_priority_queue") 48 | { 49 | test_priority_queue(); 50 | } 51 | 52 | TEST_SUITE_END(); 53 | -------------------------------------------------------------------------------- /unittests/queue.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, Randolph Voorhies, Shane Grant 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of the copyright holder nor the 13 | names of its contributors may be used to endorse or promote products 14 | derived from this software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN 28 | #include "queue.hpp" 29 | 30 | TEST_SUITE_BEGIN("queue"); 31 | 32 | TEST_CASE("binary_queue") 33 | { 34 | test_queue(); 35 | } 36 | 37 | TEST_CASE("portable_binary_queue") 38 | { 39 | test_queue(); 40 | } 41 | 42 | TEST_CASE("xml_queue") 43 | { 44 | test_queue(); 45 | } 46 | 47 | TEST_CASE("json_queue") 48 | { 49 | test_queue(); 50 | } 51 | 52 | TEST_SUITE_END(); 53 | -------------------------------------------------------------------------------- /unittests/run_portability_test.cmake: -------------------------------------------------------------------------------- 1 | macro(EXEC_CMD_CHECK) 2 | message("running ${ARGN}") 3 | execute_process(COMMAND ${ARGN} RESULT_VARIABLE CMD_RESULT) 4 | if(CMD_RESULT) 5 | message(FATAL_ERROR "Error running ${ARGN}") 6 | endif() 7 | endmacro() 8 | 9 | set(PORTABILITY_TEST_32 "${PORTABILITY_TEST_DIR}/portability_test32") 10 | set(PORTABILITY_TEST_64 "${PORTABILITY_TEST_DIR}/portability_test64") 11 | 12 | exec_cmd_check(${PORTABILITY_TEST_64} save 64) 13 | exec_cmd_check(${PORTABILITY_TEST_32} load 32) 14 | exec_cmd_check(${PORTABILITY_TEST_32} save 32) 15 | exec_cmd_check(${PORTABILITY_TEST_64} load 64) 16 | exec_cmd_check(${PORTABILITY_TEST_64} remove 64) 17 | -------------------------------------------------------------------------------- /unittests/run_valgrind.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | TESTS=./test_* 6 | 7 | for f in $TESTS 8 | do 9 | valgrind --tool=memcheck --leak-check=full $f 10 | done 11 | -------------------------------------------------------------------------------- /unittests/set.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, Randolph Voorhies, Shane Grant 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of the copyright holder nor the 13 | names of its contributors may be used to endorse or promote products 14 | derived from this software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN 28 | #include "set.hpp" 29 | 30 | TEST_SUITE_BEGIN("set"); 31 | 32 | TEST_CASE("binary_set") 33 | { 34 | test_set(); 35 | } 36 | 37 | TEST_CASE("portable_binary_set") 38 | { 39 | test_set(); 40 | } 41 | 42 | TEST_CASE("xml_set") 43 | { 44 | test_set(); 45 | } 46 | 47 | TEST_CASE("json_set") 48 | { 49 | test_set(); 50 | } 51 | 52 | TEST_SUITE_END(); 53 | -------------------------------------------------------------------------------- /unittests/set.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, Randolph Voorhies, Shane Grant 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of the copyright holder nor the 13 | names of its contributors may be used to endorse or promote products 14 | derived from this software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | #ifndef CEREAL_TEST_SET_H_ 28 | #define CEREAL_TEST_SET_H_ 29 | #include "common.hpp" 30 | 31 | template inline 32 | void test_set() 33 | { 34 | std::random_device rd; 35 | std::mt19937 gen(rd()); 36 | 37 | for(int ii=0; ii<100; ++ii) 38 | { 39 | std::set o_podset; 40 | for(int j=0; j<100; ++j) 41 | o_podset.insert(random_value(gen)); 42 | 43 | std::set o_iserset; 44 | for(int j=0; j<100; ++j) 45 | o_iserset.insert({ random_value(gen), random_value(gen) }); 46 | 47 | std::set o_isplset; 48 | for(int j=0; j<100; ++j) 49 | o_isplset.insert({ random_value(gen), random_value(gen) }); 50 | 51 | std::set o_eserset; 52 | for(int j=0; j<100; ++j) 53 | o_eserset.insert({ random_value(gen), random_value(gen) }); 54 | 55 | std::set o_esplset; 56 | for(int j=0; j<100; ++j) 57 | o_esplset.insert({ random_value(gen), random_value(gen) }); 58 | 59 | std::ostringstream os; 60 | { 61 | OArchive oar(os); 62 | 63 | oar(o_podset); 64 | oar(o_iserset); 65 | oar(o_isplset); 66 | oar(o_eserset); 67 | oar(o_esplset); 68 | } 69 | 70 | std::set i_podset; 71 | std::set i_iserset; 72 | std::set i_isplset; 73 | std::set i_eserset; 74 | std::set i_esplset; 75 | 76 | std::istringstream is(os.str()); 77 | { 78 | IArchive iar(is); 79 | 80 | iar(i_podset); 81 | iar(i_iserset); 82 | iar(i_isplset); 83 | iar(i_eserset); 84 | iar(i_esplset); 85 | } 86 | 87 | check_collection(i_podset, o_podset); 88 | check_collection(i_iserset, o_iserset); 89 | check_collection(i_isplset, o_isplset); 90 | check_collection(i_eserset, o_eserset); 91 | check_collection(i_esplset, o_esplset); 92 | } 93 | } 94 | 95 | #endif // CEREAL_TEST_SET_H_ 96 | -------------------------------------------------------------------------------- /unittests/stack.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, Randolph Voorhies, Shane Grant 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of the copyright holder nor the 13 | names of its contributors may be used to endorse or promote products 14 | derived from this software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN 28 | #include "stack.hpp" 29 | 30 | TEST_SUITE_BEGIN("stack"); 31 | 32 | TEST_CASE("binary_stack") 33 | { 34 | test_stack(); 35 | } 36 | 37 | TEST_CASE("portable_binary_stack") 38 | { 39 | test_stack(); 40 | } 41 | 42 | TEST_CASE("xml_stack") 43 | { 44 | test_stack(); 45 | } 46 | 47 | TEST_CASE("json_stack") 48 | { 49 | test_stack(); 50 | } 51 | 52 | TEST_SUITE_END(); 53 | -------------------------------------------------------------------------------- /unittests/structs.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, Randolph Voorhies, Shane Grant 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of the copyright holder nor the 13 | names of its contributors may be used to endorse or promote products 14 | derived from this software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN 28 | #include "structs.hpp" 29 | 30 | TEST_SUITE_BEGIN("structs"); 31 | 32 | TEST_CASE("binary_structs") 33 | { 34 | test_structs(); 35 | } 36 | 37 | TEST_CASE("portable_binary_structs") 38 | { 39 | test_structs(); 40 | } 41 | 42 | TEST_CASE("xml_structs") 43 | { 44 | test_structs(); 45 | } 46 | 47 | TEST_CASE("json_structs") 48 | { 49 | test_structs(); 50 | } 51 | 52 | TEST_SUITE_END(); 53 | -------------------------------------------------------------------------------- /unittests/structs.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, Randolph Voorhies, Shane Grant 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of the copyright holder nor the 13 | names of its contributors may be used to endorse or promote products 14 | derived from this software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | #ifndef CEREAL_TEST_STRUCTS_H_ 28 | #define CEREAL_TEST_STRUCTS_H_ 29 | #include "common.hpp" 30 | 31 | template inline 32 | void test_structs() 33 | { 34 | std::random_device rd; 35 | std::mt19937 gen(rd()); 36 | 37 | for(int ii=0; ii<100; ++ii) 38 | { 39 | StructInternalSerialize o_iser = { random_value(gen), random_value(gen) }; 40 | StructInternalSplit o_ispl = { random_value(gen), random_value(gen) }; 41 | StructExternalSerialize o_eser = { random_value(gen), random_value(gen) }; 42 | StructExternalSplit o_espl = { random_value(gen), random_value(gen) }; 43 | 44 | std::ostringstream os; 45 | { 46 | OArchive oar(os); 47 | oar( o_iser, o_ispl, o_eser, o_espl); 48 | } 49 | 50 | StructInternalSerialize i_iser; 51 | StructInternalSplit i_ispl; 52 | StructExternalSerialize i_eser; 53 | StructExternalSplit i_espl; 54 | 55 | std::istringstream is(os.str()); 56 | { 57 | IArchive iar(is); 58 | iar( i_iser, i_ispl, i_eser, i_espl); 59 | } 60 | 61 | CHECK_EQ(i_iser, o_iser); 62 | CHECK_EQ(i_ispl, o_ispl); 63 | CHECK_EQ(i_eser, o_eser); 64 | CHECK_EQ(i_espl, o_espl); 65 | } 66 | } 67 | 68 | #endif // CEREAL_TEST_STRUCTS_H_ 69 | -------------------------------------------------------------------------------- /unittests/structs_minimal.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, Randolph Voorhies, Shane Grant 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of the copyright holder nor the 13 | names of its contributors may be used to endorse or promote products 14 | derived from this software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN 28 | #include "structs_minimal.hpp" 29 | 30 | TEST_SUITE_BEGIN("structs_minimal"); 31 | 32 | TEST_CASE("binary_structs_minimal") 33 | { 34 | test_structs_minimal(); 35 | } 36 | 37 | TEST_CASE("portable_binary_structs_minimal") 38 | { 39 | test_structs_minimal(); 40 | } 41 | 42 | TEST_CASE("xml_structs_minimal") 43 | { 44 | test_structs_minimal(); 45 | } 46 | 47 | TEST_CASE("json_structs_minimal") 48 | { 49 | test_structs_minimal(); 50 | } 51 | 52 | TEST_SUITE_END(); 53 | -------------------------------------------------------------------------------- /unittests/structs_specialized.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, Randolph Voorhies, Shane Grant 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of the copyright holder nor the 13 | names of its contributors may be used to endorse or promote products 14 | derived from this software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN 28 | #include "structs_specialized.hpp" 29 | 30 | TEST_SUITE_BEGIN("structs_specialized"); 31 | 32 | TEST_CASE("binary_structs_specialized") 33 | { 34 | test_structs_specialized(); 35 | } 36 | 37 | TEST_CASE("portable_binary_structs_specialized") 38 | { 39 | test_structs_specialized(); 40 | } 41 | 42 | TEST_CASE("xml_structs_specialized") 43 | { 44 | test_structs_specialized(); 45 | } 46 | 47 | TEST_CASE("json_structs_specialized") 48 | { 49 | test_structs_specialized(); 50 | } 51 | 52 | TEST_SUITE_END(); 53 | -------------------------------------------------------------------------------- /unittests/tuple.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, Randolph Voorhies, Shane Grant 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of the copyright holder nor the 13 | names of its contributors may be used to endorse or promote products 14 | derived from this software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN 28 | #include "tuple.hpp" 29 | 30 | TEST_SUITE_BEGIN("tuple"); 31 | 32 | TEST_CASE("binary_tuple") 33 | { 34 | test_tuple(); 35 | } 36 | 37 | TEST_CASE("portable_binary_tuple") 38 | { 39 | test_tuple(); 40 | } 41 | 42 | TEST_CASE("xml_tuple") 43 | { 44 | test_tuple(); 45 | } 46 | 47 | TEST_CASE("json_tuple") 48 | { 49 | test_tuple(); 50 | } 51 | 52 | TEST_SUITE_END(); 53 | -------------------------------------------------------------------------------- /unittests/unordered_loads.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, Randolph Voorhies, Shane Grant 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of the copyright holder nor the 13 | names of its contributors may be used to endorse or promote products 14 | derived from this software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN 28 | #include "unordered_loads.hpp" 29 | 30 | TEST_SUITE_BEGIN("unordered_loads"); 31 | 32 | TEST_CASE("xml_unordered_loads") 33 | { 34 | test_unordered_loads(); 35 | } 36 | 37 | TEST_CASE("json_unordered_loads") 38 | { 39 | test_unordered_loads(); 40 | } 41 | 42 | TEST_SUITE_END(); 43 | -------------------------------------------------------------------------------- /unittests/unordered_map.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, Randolph Voorhies, Shane Grant 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of the copyright holder nor the 13 | names of its contributors may be used to endorse or promote products 14 | derived from this software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN 28 | #include "unordered_map.hpp" 29 | 30 | TEST_SUITE_BEGIN("unordered_map"); 31 | 32 | TEST_CASE("binary_unordered_map") 33 | { 34 | test_unordered_map(); 35 | } 36 | 37 | TEST_CASE("portable_binary_unordered_map") 38 | { 39 | test_unordered_map(); 40 | } 41 | 42 | TEST_CASE("xml_unordered_map") 43 | { 44 | test_unordered_map(); 45 | } 46 | 47 | TEST_CASE("json_unordered_map") 48 | { 49 | test_unordered_map(); 50 | } 51 | 52 | TEST_SUITE_END(); 53 | -------------------------------------------------------------------------------- /unittests/unordered_multimap.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, Randolph Voorhies, Shane Grant 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of the copyright holder nor the 13 | names of its contributors may be used to endorse or promote products 14 | derived from this software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN 28 | #include "unordered_multimap.hpp" 29 | 30 | TEST_SUITE_BEGIN("unordered_multimap"); 31 | 32 | TEST_CASE("binary_unordered_multimap") 33 | { 34 | test_unordered_multimap(); 35 | } 36 | 37 | TEST_CASE("portable_binary_unordered_multimap") 38 | { 39 | test_unordered_multimap(); 40 | } 41 | 42 | TEST_CASE("xml_unordered_multimap") 43 | { 44 | test_unordered_multimap(); 45 | } 46 | 47 | TEST_CASE("json_unordered_multimap") 48 | { 49 | test_unordered_multimap(); 50 | } 51 | 52 | TEST_SUITE_END(); 53 | -------------------------------------------------------------------------------- /unittests/unordered_multiset.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, Randolph Voorhies, Shane Grant 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of the copyright holder nor the 13 | names of its contributors may be used to endorse or promote products 14 | derived from this software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN 28 | #include "unordered_multiset.hpp" 29 | 30 | TEST_SUITE_BEGIN("unordered_multiset"); 31 | 32 | TEST_CASE("binary_unordered_multiset") 33 | { 34 | test_unordered_multiset(); 35 | } 36 | 37 | TEST_CASE("portable_binary_unordered_multiset") 38 | { 39 | test_unordered_multiset(); 40 | } 41 | 42 | TEST_CASE("xml_unordered_multiset") 43 | { 44 | test_unordered_multiset(); 45 | } 46 | 47 | TEST_CASE("json_unordered_multiset") 48 | { 49 | test_unordered_multiset(); 50 | } 51 | 52 | TEST_SUITE_END(); 53 | -------------------------------------------------------------------------------- /unittests/unordered_set.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, Randolph Voorhies, Shane Grant 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of the copyright holder nor the 13 | names of its contributors may be used to endorse or promote products 14 | derived from this software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN 28 | #include "unordered_set.hpp" 29 | 30 | TEST_SUITE_BEGIN("unordered_set"); 31 | 32 | TEST_CASE("binary_unordered_set") 33 | { 34 | test_unordered_set(); 35 | } 36 | 37 | TEST_CASE("portable_binary_unordered_set") 38 | { 39 | test_unordered_set(); 40 | } 41 | 42 | TEST_CASE("xml_unordered_set") 43 | { 44 | test_unordered_set(); 45 | } 46 | 47 | TEST_CASE("json_unordered_set") 48 | { 49 | test_unordered_set(); 50 | } 51 | 52 | TEST_SUITE_END(); 53 | -------------------------------------------------------------------------------- /unittests/user_data_adapters.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, Randolph Voorhies, Shane Grant 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of the copyright holder nor the 13 | names of its contributors may be used to endorse or promote products 14 | derived from this software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN 28 | #include "user_data_adapters.hpp" 29 | 30 | TEST_SUITE_BEGIN("user_data_adapters"); 31 | 32 | TEST_CASE("binary_user_data_adapters") 33 | { 34 | test_user_data_adapters(); 35 | } 36 | 37 | TEST_CASE("portable_binary_user_data_adapters") 38 | { 39 | test_user_data_adapters(); 40 | } 41 | 42 | TEST_CASE("xml_user_data_adapters") 43 | { 44 | test_user_data_adapters(); 45 | } 46 | 47 | TEST_CASE("json_user_data_adapters") 48 | { 49 | test_user_data_adapters(); 50 | } 51 | 52 | TEST_SUITE_END(); 53 | -------------------------------------------------------------------------------- /unittests/valarray.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, Randolph Voorhies, Shane Grant 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of cereal nor the 13 | names of its contributors may be used to endorse or promote products 14 | derived from this software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL RANDOLPH VOORHIES AND SHANE GRANT BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN 28 | #include "valarray.hpp" 29 | 30 | TEST_SUITE_BEGIN("valarray"); 31 | 32 | TEST_CASE("binary_valarray") 33 | { 34 | test_valarray(); 35 | } 36 | 37 | TEST_CASE("portable_binary_valarray") 38 | { 39 | test_valarray(); 40 | } 41 | 42 | TEST_CASE("xml_valarray") 43 | { 44 | test_valarray(); 45 | } 46 | 47 | TEST_CASE("json_valarray") 48 | { 49 | test_valarray(); 50 | } 51 | 52 | TEST_SUITE_END(); 53 | -------------------------------------------------------------------------------- /unittests/vector.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, Randolph Voorhies, Shane Grant 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of the copyright holder nor the 13 | names of its contributors may be used to endorse or promote products 14 | derived from this software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN 28 | #include "vector.hpp" 29 | 30 | TEST_SUITE_BEGIN("vector"); 31 | 32 | TEST_CASE("binary_vector") 33 | { 34 | test_vector(); 35 | } 36 | 37 | TEST_CASE("portable_binary_vector") 38 | { 39 | test_vector(); 40 | } 41 | 42 | TEST_CASE("xml_vector") 43 | { 44 | test_vector(); 45 | } 46 | 47 | TEST_CASE("json_vector") 48 | { 49 | test_vector(); 50 | } 51 | 52 | TEST_SUITE_END(); 53 | -------------------------------------------------------------------------------- /unittests/versioning.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, Randolph Voorhies, Shane Grant 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of the copyright holder nor the 13 | names of its contributors may be used to endorse or promote products 14 | derived from this software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN 28 | #include "versioning.hpp" 29 | 30 | TEST_SUITE_BEGIN("versioning"); 31 | 32 | TEST_CASE("binary_versioning") 33 | { 34 | test_versioning(); 35 | } 36 | 37 | TEST_CASE("portable_binary_versioning") 38 | { 39 | test_versioning(); 40 | } 41 | 42 | TEST_CASE("xml_versioning") 43 | { 44 | test_versioning(); 45 | } 46 | 47 | TEST_CASE("json_versioning") 48 | { 49 | test_versioning(); 50 | } 51 | 52 | #if CEREAL_THREAD_SAFE 53 | TEST_CASE("binary_versioning_threading") 54 | { 55 | test_versioning_threading(); 56 | } 57 | 58 | TEST_CASE("portable_binary_versioning_threading") 59 | { 60 | test_versioning_threading(); 61 | } 62 | 63 | TEST_CASE("xml_versioning_threading") 64 | { 65 | test_versioning_threading(); 66 | } 67 | 68 | TEST_CASE("json_versioning_threading") 69 | { 70 | test_versioning_threading(); 71 | } 72 | #endif // CEREAL_THREAD_SAFE 73 | 74 | TEST_SUITE_END(); 75 | --------------------------------------------------------------------------------