├── .clang-format ├── .gitignore ├── .travis.yml ├── .ycm_extra_conf.py ├── CMakeLists.txt ├── CONTRIBUTING.md ├── CREDITS.json ├── DOXYGEN_README.md ├── Doxyfile ├── LICENSE ├── README.md ├── build └── .gitignore ├── buildscripts └── generate_macros.py ├── etc ├── clang_format.py ├── memcheck.suppressions ├── small_logo.png └── ubsan.blacklist ├── examples ├── CMakeLists.txt ├── boson │ └── CMakeLists.txt └── mangrove │ ├── CMakeLists.txt │ └── demo.cpp ├── generate_docs.sh ├── hugo ├── config.toml ├── content │ ├── 1-basics │ │ ├── index.md │ │ ├── installation.md │ │ ├── quick-tour.md │ │ └── what-is-mangrove.md │ ├── 2-models │ │ ├── allowed-types.md │ │ ├── custom_id.md │ │ ├── dynamic-schemas.md │ │ ├── index.md │ │ └── introduction.md │ ├── 3-queries │ │ ├── index.md │ │ ├── introduction.md │ │ └── operators.md │ ├── 4-updates │ │ ├── index.md │ │ ├── introduction.md │ │ └── operators.md │ └── 5-the-bson-mapper │ │ └── index.md ├── layouts │ ├── index.html │ ├── partials │ │ ├── logo.html │ │ ├── menu.html │ │ └── style.html │ └── shortcodes │ │ └── a_blank.html ├── static │ ├── css │ │ └── docs.css │ └── images │ │ ├── favicon.png │ │ └── logo.png └── themes │ └── hugo-theme-learn │ ├── .gitignore │ ├── LICENSE.md │ ├── README.md │ ├── archetypes │ ├── chapter.md │ └── default.md │ ├── images │ ├── screenshot.png │ └── tn.png │ ├── layouts │ ├── 404.html │ ├── _default │ │ ├── list.html │ │ └── single.html │ ├── index.html │ ├── partials │ │ ├── favicon.html │ │ ├── footer.html │ │ ├── header.html │ │ ├── logo.html │ │ ├── menu.html │ │ ├── meta.html │ │ ├── script.html │ │ ├── style.html │ │ └── toc.html │ └── shortcodes │ │ ├── button.html │ │ └── notice.html │ ├── static │ ├── css │ │ ├── featherlight.min.css │ │ ├── font-awesome.min.css │ │ ├── hugo-theme.css │ │ ├── hybrid.css │ │ ├── nucleus.css │ │ ├── perfect-scrollbar.min.css │ │ └── theme.css │ ├── fonts │ │ ├── FontAwesome.otf │ │ ├── Inconsolata.eot │ │ ├── Inconsolata.svg │ │ ├── Inconsolata.ttf │ │ ├── Inconsolata.woff │ │ ├── Novecentosanswide-Normal-webfont.eot │ │ ├── Novecentosanswide-Normal-webfont.svg │ │ ├── Novecentosanswide-Normal-webfont.ttf │ │ ├── Novecentosanswide-Normal-webfont.woff │ │ ├── Novecentosanswide-Normal-webfont.woff2 │ │ ├── Novecentosanswide-UltraLight-webfont.eot │ │ ├── Novecentosanswide-UltraLight-webfont.svg │ │ ├── Novecentosanswide-UltraLight-webfont.ttf │ │ ├── Novecentosanswide-UltraLight-webfont.woff │ │ ├── Novecentosanswide-UltraLight-webfont.woff2 │ │ ├── Work_Sans_200.eot │ │ ├── Work_Sans_200.svg │ │ ├── Work_Sans_200.ttf │ │ ├── Work_Sans_200.woff │ │ ├── Work_Sans_200.woff2 │ │ ├── Work_Sans_300.eot │ │ ├── Work_Sans_300.svg │ │ ├── Work_Sans_300.ttf │ │ ├── Work_Sans_300.woff │ │ ├── Work_Sans_300.woff2 │ │ ├── Work_Sans_500.eot │ │ ├── Work_Sans_500.svg │ │ ├── Work_Sans_500.ttf │ │ ├── Work_Sans_500.woff │ │ ├── Work_Sans_500.woff2 │ │ ├── fontawesome-webfont.eot │ │ ├── fontawesome-webfont.svg │ │ ├── fontawesome-webfont.ttf │ │ ├── fontawesome-webfont.woff │ │ └── fontawesome-webfont.woff2 │ ├── images │ │ ├── clippy.svg │ │ ├── favicon.png │ │ └── gopher-404.jpg │ └── js │ │ ├── clipboard.min.js │ │ ├── featherlight.min.js │ │ ├── highlight.pack.js │ │ ├── html5shiv-printshiv.min.js │ │ ├── hugo-learn.js │ │ ├── jquery-2.x.min.js │ │ ├── jquery.sticky-kit.min.js │ │ ├── learn.js │ │ ├── modernizr.custom.71422.js │ │ ├── perfect-scrollbar.jquery.min.js │ │ └── perfect-scrollbar.min.js │ └── theme.toml ├── src ├── CMakeLists.txt ├── boson │ ├── CMakeLists.txt │ ├── bson_archiver.hpp │ ├── bson_streambuf.cpp │ ├── bson_streambuf.hpp │ ├── cmake │ │ └── libboson-config.cmake.in │ ├── config │ │ ├── CMakeLists.txt │ │ ├── compiler.hpp │ │ ├── config.hpp.in │ │ ├── libboson.pc.in │ │ ├── postlude.hpp │ │ ├── prelude.hpp │ │ └── version.hpp.in │ ├── mapping_functions.hpp │ ├── stdx │ │ └── optional.hpp │ └── test │ │ ├── CMakeLists.txt │ │ ├── archiver_test.cpp │ │ ├── bson_streambuf.cpp │ │ ├── main.cpp │ │ ├── mapping_functions.cpp │ │ └── stdx_optional_archiver_test.cpp ├── mangrove │ ├── .gitignore │ ├── CMakeLists.txt │ ├── cmake │ │ └── libmangrove-config.cmake.in │ ├── collection_wrapper.cpp │ ├── collection_wrapper.hpp │ ├── config │ │ ├── CMakeLists.txt │ │ ├── compiler.hpp │ │ ├── config.hpp.in │ │ ├── libmangrove.pc.in │ │ ├── postlude.hpp │ │ ├── prelude.hpp │ │ └── version.hpp.in │ ├── deserializing_cursor.hpp │ ├── expression_syntax.hpp │ ├── macros.hpp │ ├── model.cpp │ ├── model.hpp │ ├── nvp.hpp │ ├── query_builder.hpp │ ├── test │ │ ├── CMakeLists.txt │ │ ├── collection_wrapper.cpp │ │ ├── deserializing_cursor.cpp │ │ ├── main.cpp │ │ ├── model.cpp │ │ ├── query_builder.cpp │ │ └── util.cpp │ └── util.hpp └── third_party │ ├── catch │ ├── include │ │ ├── catch.hpp │ │ └── helpers.hpp │ └── main.cpp │ └── cereal │ ├── LICENSE │ └── include │ └── cereal │ ├── access.hpp │ ├── archives │ ├── adapters.hpp │ ├── binary.hpp │ ├── json.hpp │ ├── portable_binary.hpp │ └── xml.hpp │ ├── cereal.hpp │ ├── details │ ├── helpers.hpp │ ├── polymorphic_impl.hpp │ ├── static_object.hpp │ ├── traits.hpp │ └── util.hpp │ ├── external │ ├── base64.hpp │ ├── rapidjson │ │ ├── document.h │ │ ├── filestream.h │ │ ├── genericstream.h │ │ ├── internal │ │ │ ├── pow10.h │ │ │ ├── stack.h │ │ │ └── strfunc.h │ │ ├── license.txt │ │ ├── prettywriter.h │ │ ├── rapidjson.h │ │ ├── reader.h │ │ ├── stringbuffer.h │ │ └── writer.h │ └── rapidxml │ │ ├── license.txt │ │ ├── manual.html │ │ ├── rapidxml.hpp │ │ ├── rapidxml_iterators.hpp │ │ ├── rapidxml_print.hpp │ │ └── rapidxml_utils.hpp │ ├── macros.hpp │ └── types │ ├── array.hpp │ ├── base_class.hpp │ ├── bitset.hpp │ ├── boost_variant.hpp │ ├── chrono.hpp │ ├── common.hpp │ ├── complex.hpp │ ├── deque.hpp │ ├── forward_list.hpp │ ├── list.hpp │ ├── map.hpp │ ├── memory.hpp │ ├── polymorphic.hpp │ ├── queue.hpp │ ├── set.hpp │ ├── stack.hpp │ ├── string.hpp │ ├── tuple.hpp │ ├── unordered_map.hpp │ ├── unordered_set.hpp │ ├── utility.hpp │ ├── valarray.hpp │ └── vector.hpp └── travis-install-deps.sh /.clang-format: -------------------------------------------------------------------------------- 1 | BasedOnStyle: Google 2 | ColumnLimit: 100 3 | Cpp11BracedListStyle: true 4 | IndentWidth: 4 5 | MaxEmptyLinesToKeep: 1 6 | NamespaceIndentation: None 7 | SpaceBeforeAssignmentOperators: true 8 | Standard: Cpp11 9 | UseTab: Never 10 | AllowShortFunctionsOnASingleLine: false 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Directories that are generated 2 | /docs 3 | /hugo/public 4 | /tags 5 | 6 | 7 | # Filetypes 8 | *~ 9 | *.pyc 10 | *.swp 11 | 12 | # OSX 13 | .DS_Store 14 | 15 | # Editor-specific settings 16 | .clang_complete 17 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: cpp 2 | 3 | sudo: false 4 | 5 | branches: 6 | only: 7 | - master 8 | 9 | compiler: 10 | - gcc 11 | - clang 12 | 13 | env: 14 | global: 15 | - CMAKE_VERSION="cmake-3.2.3-Linux-x86_64" 16 | - CMAKE_BINARY="${CMAKE_VERSION}/bin/cmake" 17 | - CDRIVER_VERSION="1.7.0" 18 | 19 | matrix: 20 | - CONFIG=Release 21 | - CONFIG=Debug 22 | 23 | addons: 24 | apt: 25 | sources: 26 | # Add the modern toolchain repositories (llvm repo depends on ubunut-toolchain-r + gcc) 27 | - ubuntu-toolchain-r-test 28 | - llvm-toolchain-precise-3.8 29 | # Add the MongoDB 3.2 repository 30 | - mongodb-3.2-precise 31 | packages: 32 | - mongodb-org-server 33 | - g++-6 34 | - clang-3.8 35 | 36 | install: 37 | # GCC 38 | - if [ "$CXX" = "g++" ]; then export CXX="g++-6"; export CC="gcc-6"; export NO_ERROR_ON_MAYBE_UNINITIALIZED="-Wno-error=maybe-uninitialized"; fi 39 | 40 | # Clang 41 | - if [ "$CXX" == "clang++" ]; then export CXX="clang++-3.8"; export CC="clang-3.8"; fi 42 | 43 | # Don't Wno-error-maybe-uninitialized if we're in a Debug build 44 | - if [ "$CONFIG" == "Debug"]; then export NO_ERROR_ON_MAYBE_UNINITIALIZED=""; fi 45 | 46 | # Prepare pkg-config path 47 | - export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$HOME/deps/lib/pkgconfig/ 48 | 49 | # Install dependencies 50 | - curl -O https://cmake.org/files/v3.2/${CMAKE_VERSION}.tar.gz 51 | - tar -zxf ${CMAKE_VERSION}.tar.gz -C build 52 | - bash travis-install-deps.sh 53 | 54 | before_script: 55 | - $CC --version 56 | - $CXX --version 57 | 58 | # Build Mangrove and its tests 59 | - export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$HOME/install/lib/pkgconfig 60 | - cd build 61 | - export CC_FLAGS="-Wall -Wextra -Wno-attributes -Werror -Wno-error=missing-field-initializers ${NO_ERROR_ON_MAYBE_UNINITIALIZED}" 62 | - ${CMAKE_BINARY} -DCMAKE_BUILD_TYPE=$CONFIG -DCMAKE_MODULE_PATH=$HOME/deps/mongo-cxx-driver/cmake -Dlibbsoncxx_DIR=$HOME/deps/lib/cmake/libbsoncxx-3.1.3 -Dlibmongocxx_DIR=$HOME/deps/lib/cmake/libmongocxx-3.1.3 -DCMAKE_INSTALL_PREFIX=$HOME/install -DCMAKE_C_FLAGS="${CC_FLAGS}" -DCMAKE_CXX_FLAGS="${CC_FLAGS}" .. 63 | script: 64 | - make format-lint 65 | 66 | - make -j$(grep -c ^processor /proc/cpuinfo) all 67 | 68 | # Run boson tests with catch 69 | - ./src/boson/test/test_boson 70 | 71 | # Run boson tests with catch 72 | - ./src/mangrove/test/test_mangrove 73 | 74 | # Install headers and libs for the examples 75 | - make install 76 | 77 | # Make the examples 78 | - make examples 79 | 80 | # Run the examples 81 | - make run-examples 82 | 83 | cache: 84 | directories: 85 | - $HOME/deps 86 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2016 MongoDB Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | cmake_minimum_required(VERSION 3.2 FATAL_ERROR) 16 | 17 | if(POLICY CMP0025) 18 | cmake_policy(SET CMP0025 NEW) 19 | endif() 20 | 21 | project(MANGROVE LANGUAGES CXX) 22 | 23 | if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") 24 | if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.8.2") 25 | message(FATAL_ERROR "Insufficient GCC version - GCC 4.8.2+ required") 26 | endif() 27 | elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") 28 | if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "19.0.23506") 29 | message(FATAL_ERROR "Insufficient Microsoft Visual C++ version - MSVC 2015 Update 1+ required") 30 | endif() 31 | elseif(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") 32 | if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "5.1") 33 | message(FATAL_ERROR "Insufficient Apple clang version - XCode 5.1+ required") 34 | endif() 35 | elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") 36 | if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "3.5") 37 | message(FATAL_ERROR "Insufficient clang version - clang 3.5+ required") 38 | endif() 39 | else() 40 | message(WARNING "Unknown compiler... recklessly proceeding without a version check") 41 | endif() 42 | 43 | set (CMAKE_SKIP_BUILD_RPATH false) 44 | set (CMAKE_BUILD_WITH_INSTALL_RPATH false) 45 | set (CMAKE_INSTALL_RPATH_USE_LINK_PATH true) 46 | # Ensure that RPATH is used on OSX 47 | set(CMAKE_MACOSX_RPATH 1) 48 | 49 | # Enforce the C++ standard, and disable extensions 50 | if(NOT DEFINED CMAKE_CXX_STANDARD) 51 | set(CMAKE_CXX_STANDARD 14) 52 | endif() 53 | 54 | set(CMAKE_CXX_EXTENSIONS OFF) 55 | 56 | # Include the required modules 57 | include(GenerateExportHeader) 58 | include(InstallRequiredSystemLibraries) 59 | 60 | # If the user did not customize the install prefix, 61 | # set it to live under build so we don't inadverently pollute /usr/local 62 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) 63 | set (CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install" CACHE PATH "default install path" FORCE) 64 | endif() 65 | 66 | if(NOT CMAKE_BUILD_TYPE) 67 | message(STATUS "No build type selected, default is Release") 68 | set(CMAKE_BUILD_TYPE "Release") 69 | endif() 70 | 71 | set(CMAKE_EXPORT_COMPILE_COMMANDS ON) 72 | 73 | add_custom_target(format 74 | python ${CMAKE_SOURCE_DIR}/etc/clang_format.py format 75 | VERBATIM 76 | ) 77 | 78 | add_custom_target(format-lint 79 | python ${CMAKE_SOURCE_DIR}/etc/clang_format.py lint 80 | VERBATIM 81 | ) 82 | 83 | set(THIRD_PARTY_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/third_party) 84 | 85 | enable_testing() 86 | 87 | set(LIBBSONCXX_REQUIRED_VERSION 3.1.3) 88 | set(LIBBSONCXX_REQUIRED_ABI_VERSION v_noabi) 89 | find_package(libbsoncxx ${LIBBSONCXX_REQUIRED_VERSION} REQUIRED) 90 | 91 | set(LIBMONGOCXX_REQUIRED_VERSION 3.1.3) 92 | set(LIBMONGOCXX_REQUIRED_ABI_VERSION v_noabi) 93 | find_package(libmongocxx ${LIBMONGOCXX_REQUIRED_VERSION} REQUIRED) 94 | 95 | set(LIBBSON_REQUIRED_VERSION 1.7.0) 96 | set(LIBBSON_REQUIRED_ABI_VERSION 1.0) 97 | find_package(LibBSON ${LIBBSON_REQUIRED_VERSION} REQUIRED) 98 | 99 | set(LIBMONGOC_REQUIRED_VERSION 1.7.0) 100 | set(LIBMONGOC_REQUIRED_ABI_VERSION 1.0) 101 | find_package(LibMongoC ${LIBMONGOC_REQUIRED_VERSION} REQUIRED) 102 | 103 | add_subdirectory(src) 104 | 105 | add_subdirectory(examples EXCLUDE_FROM_ALL) 106 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing Guidelines 2 | 3 | ### Lifecycle Methods 4 | 5 | - default-or-argument-bearing 'user' constructors 6 | 7 | - declaration-or-deletion-of-copy-contructor 8 | - declaration-or-deletetion-of-move-constructor 9 | 10 | - declaration-or-deletion-of-copy-assignment-operator 11 | - declaration-or-deletion-of-move-assignment-operator 12 | 13 | - declaration-of-dtor 14 | 15 | ### Headers 16 | 17 | - License 18 | - Include Guard (`#pragma once`) 19 | - Header Prelude 20 | - System Headers `` (alphabetical order) 21 | - Driver Headers `` (alphabetical order) 22 | - Open Namespace mongocxx 23 | - `MONGOCXX_INLINE_NAMESPACE_BEGIN` 24 | - Code 25 | - `MONGOCXX_INLINE_NAMESPACE_END` 26 | - Close Namespace mongocxx 27 | - Header Postlude 28 | 29 | Example: 30 | 31 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp} 32 | // Copyright 2016 MongoDB Inc. 33 | // 34 | // Licensed under the Apache License, Version 2.0 (the "License"); 35 | // you may not use this file except in compliance with the License. 36 | // You may obtain a copy of the License at 37 | // 38 | // http://www.apache.org/licenses/LICENSE-2.0 39 | // 40 | // Unless required by applicable law or agreed to in writing, software 41 | // distributed under the License is distributed on an "AS IS" BASIS, 42 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 43 | // See the License for the specific language governing permissions and 44 | // limitations under the License. 45 | 46 | #pragma once 47 | 48 | #include 49 | 50 | #include 51 | 52 | #include 53 | 54 | namespace mongocxx { 55 | MONGOCXX_INLINE_NAMESPACE_BEGIN 56 | 57 | // Declarations 58 | 59 | // Inline Implementations 60 | 61 | MONGOCXX_INLINE_NAMESPACE_END 62 | } // namespace mongocxx 63 | 64 | #include 65 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 66 | 67 | ### Class Declarations 68 | 69 | Guidelines: 70 | 71 | - Blank line at beginning and end of class declaration 72 | - Public section up top / private at bottom 73 | - Lifecycle methods first (see rules above) 74 | - Private Member Ordering 75 | - Friendships 76 | - Private Constructors 77 | - Private Methods 78 | - Private Variables 79 | 80 | Example: 81 | 82 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp} 83 | class foo { 84 | 85 | public: 86 | foo(); 87 | 88 | foo(foo&& other) noexcept; 89 | foo& operator=(foo&& other) noexcept; 90 | 91 | ~foo(); 92 | 93 | private: 94 | friend baz; 95 | 96 | class MONGOCXX_PRIVATE impl; 97 | std::unique_ptr _impl; 98 | 99 | }; 100 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 101 | 102 | ### Inlines 103 | - Define outside of class declaration 104 | - Specify inline keyword in declaration and definition (for clarity) 105 | 106 | ### Relational Operators 107 | - Prefer to use free functions 108 | -------------------------------------------------------------------------------- /CREDITS.json: -------------------------------------------------------------------------------- 1 | { 2 | "readme": "Chronological by date of first commit: add yourself at the end", 3 | "contributors": [ 4 | { 5 | "name" : "Matt Cotter", 6 | "email" : [ 7 | "mc@mongodb.com" 8 | ], 9 | "description" : "Provided boilerplate code and performed many code reviews." 10 | }, 11 | { 12 | "name" : "Adam Chelminski", 13 | "email" : [ 14 | "adam.chelminski@mongodb.com", 15 | "chelminski.adam@gmail.com" 16 | ], 17 | "description" : "Principal author of BSON serializer, mangrove::model, Travis CI integration, and Hugo-generated documentation." 18 | }, 19 | { 20 | "name" : "Raphael Kargon", 21 | "email" : [ 22 | "raphael.kargon@mongodb.com", 23 | "raphael.kargon@gmail.com" 24 | ], 25 | "description" : "Principal author of ODM collection wrapper, query builder, update builder." 26 | } 27 | ] 28 | } 29 | -------------------------------------------------------------------------------- /DOXYGEN_README.md: -------------------------------------------------------------------------------- 1 | # Mangrove 2 | 3 | Welcome to the generated API reference for Mangrove, the MongoDB C++ ODM! 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Mangrove [![Build Status](https://travis-ci.org/mongodb-labs/mangrove.svg?branch=master)](https://travis-ci.org/mongodb-labs/mangrove) 2 | 3 | Welcome to Mangrove, the MongoDB C++ ODM! 4 | 5 | Mangrove lets you map your C++ classes to collections in MongoDB for seamless data retrieval and manipulation. 6 | 7 | #### Documentation 8 | 9 | The documentation for Mangrove is currently hosted at . 10 | 11 | We generate the documentation with the following commands: 12 | 13 | ``` 14 | hugo -b http://mongodb-labs.github.io/mangrove/ --canonifyURLs=true -s ./hugo -d ../docs 15 | doxygen 16 | ``` 17 | 18 | We then host `docs` by copying its contents to the `gh-pages` branch. 19 | 20 | You can generate the documentation on your own by running the `generate_docs.sh` script in this root directory. It requires that you have [Hugo](https://gohugo.io/) and [Doxygen](http://www.stack.nl/~dimitri/doxygen/) installed on your system. If you're on OS X, both can be installed with [Homebrew](http://brew.sh/). 21 | 22 | The documentation will be installed in `./docs` with a base URL of `http://localhost:8080/` and contains an installation guide, a quick tour of Mangrove's features, detailed chapters about each of the features, and a Doxygen-generated API reference. The documentation must be viewed on a static web server, even when viewing locally. If you have Node.js intalled, you can use the [`http-server`](https://www.npmjs.com/package/http-server) package to host the docs locally: 23 | 24 | ``` 25 | ./generate_docs.sh 26 | npm install -g http-server 27 | http-server ./docs 28 | ``` 29 | 30 | If you'd like to run the docs in such a way that the page will refresh when the content is updated, you can run `hugo serve` in the `hugo` directory: 31 | 32 | ``` 33 | cd hugo 34 | hugo serve 35 | ``` 36 | 37 | Note that the Doxygen API will be unavailable in this served documentation. 38 | 39 | ## Bugs and Issues 40 | 41 | You can report any bugs or issues you find in the Github Issues tab for this repository. 42 | 43 | ## Mailing Lists and IRC 44 | 45 | The [mongodb-user group](https://groups.google.com/forum/#!forum/mongodb-user) is the main forum for MongoDB technical questions. 46 | 47 | Other community resources are outlined on the [MongoDB Community site](http://dochub.mongodb.org/core/community). 48 | 49 | ## License 50 | 51 | The source files in this repository are made available under the terms of the Apache License, version 2.0. 52 | 53 | The BSON mapper in Mangrove (Boson) is powered by the [Cereal](http://uscilab.github.io/cereal/) C++11 serialization library, which is made available under the BSD 3-Clause License. 54 | 55 | The documentation for Mangrove utilizes the Hugo [Learn](https://github.com/matcornic/hugo-theme-learn) theme (Copyright (c) 2014 Grav Copyright (c) 2016 MATHIEU CORNIC) which is made available under the MIT License. 56 | 57 | 58 | -------------------------------------------------------------------------------- /build/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore 5 | -------------------------------------------------------------------------------- /etc/memcheck.suppressions: -------------------------------------------------------------------------------- 1 | { 2 | 3 | Memcheck:Leak 4 | match-leak-kinds: definite 5 | fun:malloc 6 | ... 7 | fun:sasl_client_add_plugin 8 | obj:*libsasl2.so* 9 | fun:sasl_client_init 10 | } 11 | -------------------------------------------------------------------------------- /etc/small_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mongodb-labs/mangrove/3e6f383af01f9fcee58b1d433415573a3b76c360/etc/small_logo.png -------------------------------------------------------------------------------- /etc/ubsan.blacklist: -------------------------------------------------------------------------------- 1 | # Blacklisting these functions due to a bug in libstdc++: 2 | # http://stackoverflow.com/questions/30122500/is-this-code-really-undefined-as-clang-seems-to-indicate 3 | fun:_ZStaNRSt13_Ios_FmtflagsS_ 4 | fun:_ZStanSt13_Ios_FmtflagsS_ 5 | -------------------------------------------------------------------------------- /examples/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2016 MongoDB Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # NOTE: The targets in this directory will only build if you have 16 | # installed the boson libraries via the 'install' targets. 17 | 18 | # TODO: Ideally, there would be dependencies here on the install targets 19 | # for bsonc_mapper. However, there is currently no way to express 20 | # that dependency in CMake (see https://cmake.org/Bug/view.php?id=8438) 21 | 22 | # Build the examples with vectorcall as the default on Windows 23 | # so that we shake out missing _CALL macros. 24 | if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") 25 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Gv") 26 | endif() 27 | 28 | add_subdirectory(boson) 29 | add_subdirectory(mangrove) 30 | 31 | add_custom_target(examples DEPENDS ${BOSON_EXAMPLE_EXECUTABLES} ${MANGROVE_EXAMPLE_EXECUTABLES}) 32 | 33 | add_custom_target(run-examples DEPENDS examples) 34 | 35 | # Run all boson examples on `make run-examples`. 36 | foreach(EXAMPLE ${BOSON_EXAMPLE_EXECUTABLES}) 37 | get_filename_component(EXAMPLE_EXECUTABLE "${CMAKE_BINARY_DIR}/examples/boson/${EXAMPLE}" ABSOLUTE) 38 | add_custom_command(TARGET run-examples POST_BUILD COMMAND ${EXAMPLE_EXECUTABLE}) 39 | endforeach(EXAMPLE) 40 | 41 | # Run all mangrove examples on `make run-examples`. 42 | foreach(EXAMPLE ${MANGROVE_EXAMPLE_EXECUTABLES}) 43 | get_filename_component(EXAMPLE_EXECUTABLE "${CMAKE_BINARY_DIR}/examples/mangrove/${EXAMPLE}" ABSOLUTE) 44 | add_custom_command(TARGET run-examples POST_BUILD COMMAND ${EXAMPLE_EXECUTABLE}) 45 | endforeach(EXAMPLE) 46 | -------------------------------------------------------------------------------- /examples/boson/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2016 MongoDB Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | include_directories( 16 | ${CMAKE_INSTALL_PREFIX}/${BOSON_HEADER_INSTALL_DIR} 17 | ) 18 | 19 | link_directories( 20 | ${CMAKE_INSTALL_PREFIX}/lib 21 | ) 22 | 23 | set(BOSON_EXAMPLES ) 24 | 25 | foreach(EXAMPLE_SRC ${BOSON_EXAMPLES}) 26 | get_filename_component(EXAMPLE_TARGET ${EXAMPLE_SRC} NAME_WE) 27 | add_executable(${EXAMPLE_TARGET} ${EXAMPLE_SRC}) 28 | target_link_libraries(${EXAMPLE_TARGET} boson) 29 | set(BOSON_EXAMPLE_EXECUTABLES ${BOSON_EXAMPLE_EXECUTABLES} ${EXAMPLE_TARGET}) 30 | endforeach(EXAMPLE_SRC) 31 | 32 | set(BOSON_EXAMPLE_EXECUTABLES ${BOSON_EXAMPLE_EXECUTABLES} PARENT_SCOPE) 33 | -------------------------------------------------------------------------------- /examples/mangrove/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2016 MongoDB Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | include_directories( 16 | ${LIBBSON_INCLUDE_DIRS} 17 | ${LIBMONGOC_INCLUDE_DIRS} 18 | ${LIBBSONCXX_INCLUDE_DIRS} 19 | ${LIBMONGOCXX_INCLUDE_DIRS} 20 | ${CMAKE_INSTALL_PREFIX}/${MANGROVE_HEADER_INSTALL_DIR} 21 | ${CMAKE_INSTALL_PREFIX}/${BOSON_HEADER_INSTALL_DIR} 22 | ${CMAKE_INSTALL_PREFIX}/include/ 23 | ${CMAKE_INSTALL_PREFIX}/${BOSON_HEADER_INSTALL_DIR}/boson/third_party 24 | ) 25 | 26 | link_directories( 27 | ${LIBBSONCXX_LIBRARY_DIRS} 28 | ${LIBMONGOCXX_LIBRARY_DIRS} 29 | ${LIBBSON_LIBRARY_DIRS} 30 | ${LIBMONGOC_LIBRARY_DIRS} 31 | 32 | ${CMAKE_INSTALL_PREFIX}/lib/ 33 | ) 34 | 35 | set(MANGROVE_EXAMPLES 36 | demo.cpp 37 | ) 38 | 39 | foreach(EXAMPLE_SRC ${MANGROVE_EXAMPLES}) 40 | get_filename_component(EXAMPLE_TARGET ${EXAMPLE_SRC} NAME_WE) 41 | add_executable(${EXAMPLE_TARGET} ${EXAMPLE_SRC}) 42 | target_link_libraries(${EXAMPLE_TARGET} mangrove boson mongocxx bsoncxx) 43 | set(MANGROVE_EXAMPLE_EXECUTABLES ${MANGROVE_EXAMPLE_EXECUTABLES} ${EXAMPLE_TARGET}) 44 | endforeach(EXAMPLE_SRC) 45 | 46 | set(MANGROVE_EXAMPLE_EXECUTABLES ${MANGROVE_EXAMPLE_EXECUTABLES} PARENT_SCOPE) 47 | -------------------------------------------------------------------------------- /generate_docs.sh: -------------------------------------------------------------------------------- 1 | mkdir -p docs && hugo -s ./hugo -d ../docs && doxygen 2 | -------------------------------------------------------------------------------- /hugo/config.toml: -------------------------------------------------------------------------------- 1 | baseurl = "http://localhost:8080" 2 | languageCode = "en-us" 3 | title = "Mangrove" 4 | theme = "hugo-theme-learn" 5 | -------------------------------------------------------------------------------- /hugo/content/1-basics/index.md: -------------------------------------------------------------------------------- 1 | +++ 2 | chapter = true 3 | icon = "1. " 4 | next = "/1-basics/what-is-mangrove" 5 | title = "Basics" 6 | weight = 0 7 | 8 | +++ 9 | 10 | ### Chapter 1 11 | 12 | # Basics 13 | 14 | Learn what **Mangrove** is and how it can help you build C++ applications with MongoDB. 15 | -------------------------------------------------------------------------------- /hugo/content/1-basics/installation.md: -------------------------------------------------------------------------------- 1 | +++ 2 | next = "/1-basics/quick-tour" 3 | prev = "/1-basics/what-is-mangrove" 4 | title = "Installation" 5 | toc = true 6 | weight = 2 7 | 8 | +++ 9 | 10 | To get Mangrove up and running in your project, simply follow these instructions to install Mangrove on your system. 11 | 12 | ## Prerequisites 13 | 14 | 1. Any little-endian platform. 15 | 2. A modern compiler that supports C++14. 16 | * Mangrove has been confirmed to work with Clang 3.8+, Apple Clang 7.3+, or GCC 6.1+. 17 | 3. CMake 3.2+. 18 | 4. The MongoDB C driver version 1.3.5+. (see below) 19 | 5. The MongoDB C++ driver version 3.0.2+. (see below) 20 | 6. *(Optional)* pkg-config 21 | 22 | {{% notice note %}} 23 | As of this writing, the MongoDB C++ driver version 3.0.2 has not been released. When installing the C++ driver, simply `git checkout master` if `git checkout r3.0.2` does not work. 24 | {{% /notice %}} 25 | 26 | ## Build and install the C driver 27 | 28 | Mangrove uses {{% a_blank "libbson" "https://api.mongodb.com/libbson/current/" %}} and {{% a_blank "libmongoc" "https://api.mongodb.com/c/current/" %}} internally. If you don't already have a new enough version of libmongoc and libbson installed, then you need to build them. 29 | 30 | Build and install libmongoc according to the section {{% a_blank "Building From a Release Tarball" "https://api.mongodb.com/c/current/installing.html#unix-build" %}} in the install instructions. libmongoc installs libbson if necessary. 31 | 32 | ## Build and install the C++11 driver 33 | 34 | Mangrove also uses the {{% a_blank "MongoDB C++11 Driver" "https://github.com/mongodb/mongo-cxx-driver" %}} internally. 35 | 36 | Build and install the C++ driver according to its {{% a_blank "quickstart guide" "https://github.com/mongodb/mongo-cxx-driver/wiki/Quickstart-Guide-(New-Driver)" %}}. 37 | 38 | ## Build and install Mangrove 39 | 40 | Clone the repository, and check out the latest stable release. 41 | 42 | * `git clone -b master https://github.com/mongodb-labs/mangrove` 43 | 44 | Build Mangrove with the following commands: 45 | 46 | * `cd mangrove/build` 47 | * `[PKG_CONFIG_PATH=CXXDRIVER_INSTALL_PATH/lib/pkgconfig] cmake -DCMAKE_BUILD_TYPE=Release [-DCMAKE_INSTALL_PREFIX=DESIRED_INSTALL_PATH] ..` 48 | * `make && sudo make install` 49 | 50 | {{% notice note %}} 51 | Note that if you installed the C driver and C++ driver to a path that is automatically searched by `pkg-config`, you can omit the `PKG_CONFIG_PATH` environment variable. If you don't have `pkg-config`, you can explicitly set the path to the libbson, libmongoc, libbsoncxx, and libmongocxx install prefixes with the `-DLIBBSON_DIR`, `-DLIBMONGOC_DIR`, -`Dlibbsoncxx_DIR`, and `-Dlibmongocxx_DIR` CMake arguments. 52 | {{% /notice %}} 53 | 54 | ## Using Mangrove 55 | 56 | Once you've installed Mangrove, you can start using it by including and linking `libmangrove`, `libboson`, and `libmongocxx` in your project. `libmangrove` is the library that contains the actual ODM, `libboson` is the BSON serialization library that powers `libmangrove`, and `libmongocxx` is the MongoDB C++ Driver. 57 | 58 | If you're using `pkg-config`, using Mangrove is incredibly simple. Simply add the following two flags to your compiler invocation: 59 | 60 | * `--std=c++14` 61 | * `$(pkg-config --libs --cflags libmangrove libboson libmongocxx)` 62 | - You may need to preface this with `PKG_CONFIG_PATH=MANGROVE_INSTALL_PATH/lib/pkgconfig` if you installed Mangrove in a directory not automatically searched for by pkg-config. 63 | 64 | If you're not using `pkg-config`, you'll need to add the following flags to your compiler invocation: 65 | 66 | * `--std=c++14` 67 | * `-IMANGROVE_INSTALL_PATH/include/mangrove/v_noabi` 68 | * `-IMANGROVE_INSTALL_PATH/include/boson/v_noabi` 69 | * `-IMANGROVE_INSTALL_PATH/include/boson/v_noabi/boson/third_party` 70 | * `-ICXXDRIVER_INSTALL_PATH/include/mongocxx/v_noabi` 71 | * `-ICDRIVER_INSTALL_PATH/include/libmongoc-1.0` 72 | * `-ICXXDRIVER_INSTALL_PATH/include/bsoncxx/v_noabi` 73 | * `-ICDRIVER_INSTALL_PATH/include/libbson-1.0` 74 | * `-LMANGROVE_INSTALL_PATH/lib` 75 | - If the install prefixes for the C and C++ Drivers are different than the one for Mangrove, also include `-LCDRIVER_INSTALL_PATH/lib` and `-LCXX_DRIVER_INSTALL_PATH/lib` 76 | * `-lmangrove` 77 | * `-lboson` 78 | * `-lmongocxx` 79 | * `-lbsoncxx` 80 | -------------------------------------------------------------------------------- /hugo/content/1-basics/what-is-mangrove.md: -------------------------------------------------------------------------------- 1 | +++ 2 | next = "/1-basics/installation" 3 | prev = "/1-basics" 4 | title = "What is Mangrove?" 5 | toc = true 6 | weight = 1 7 | 8 | +++ 9 | 10 | Mangrove is a C++ **object document mapper (ODM)** for MongoDB. An **ODM** lets you map classes in an object-oriented programming language to collections in a document-oriented database like MongoDB. 11 | 12 | If you've ever used an **object relational mapper (ORM)**, an **ODM** is quite similar, except that the underlying structure of the data in the database is actually very similar to the structure of your objects. 13 | 14 | If you know how to create and manipulate classes in C++, you can easily get started with Mangrove! 15 | 16 | ```cpp 17 | 18 | class BlogEntry : public mangrove::model { 19 | public: 20 | std::string title; 21 | std::string contents; 22 | std::string author; 23 | std::chrono::system_clock::time_point time_posted; 24 | 25 | // Register fields with Mangrove. 26 | MANGROVE_MAKE_KEYS_MODEL(BlogEntry, 27 | MANGROVE_NVP(title), 28 | MANGROVE_NVP(contents), 29 | MANGROVE_NVP(author), 30 | MANGROVE_NVP(time_posted)) 31 | }; 32 | 33 | int main() { 34 | mongocxx::instance{}; 35 | mongocxx::client conn{mongocxx::uri{}}; 36 | 37 | // Map the BlogEntry class to the 'entries' collection 38 | // in the 'my_blog' database. 39 | auto db = conn["my_blog"]; 40 | BlogEntry::setCollection(db["entries"]); 41 | 42 | // Create a new entry just like any other C++ object. 43 | BlogEntry new_entry{"Check out Mangrove", 44 | "It's really cool!", 45 | "Ben Franklin", 46 | std::chrono::system_clock::now()} 47 | 48 | 49 | // Save the entry in the collection. 50 | new_entry.save(); 51 | 52 | // There is now a document in the 'entries' collection 53 | // and it looks like this: 54 | // { 55 | // "_id" : ObjectId("577d5b36e24939f3b82e2331"), 56 | // "title" : "Check out Mangrove!", 57 | // "contents" : "It's really cool", 58 | // "author" : "Ben Franklin", 59 | // "time_posted" : ISODate("2016-07-15T19:25:42.073Z") 60 | // } 61 | } 62 | 63 | 64 | ``` 65 | -------------------------------------------------------------------------------- /hugo/content/2-models/custom_id.md: -------------------------------------------------------------------------------- 1 | +++ 2 | next = "/2-models/dynamic-schemas" 3 | prev = "/2-models/allowed-types" 4 | title = "Custom _id Type" 5 | toc = true 6 | weight = 3 7 | 8 | +++ 9 | 10 | As we mentioned in the chapter's [Introduction](/2-models/introduction), Mangrove **models** automatically include an `_id` field that is automatically an ObjectID of type `bsoncxx::oid`. 11 | 12 | There are various reasons that you might not want to use an ObjectId for the `_id` field. Therefore, Mangrove supports the customization of the `_id` type via a second template parameter to `mangrove::model`. 13 | 14 | Below is an exampe of a model that uses std::string as an `_id` instead of an ObjectID: 15 | 16 | ```cpp 17 | class User : public mangrove::model { 18 | std::string username; 19 | std::string password_hash; 20 | } 21 | ``` 22 | 23 | The resulting BSON document may look something like this: 24 | ```json 25 | { 26 | "_id" : "alan.turing@mongodb.com", 27 | "username" : "aturing", 28 | "password_hash" : 29 | "e9f5bd2bae1c70770ff8c6e6cf2d7b76" 30 | } 31 | ``` 32 | 33 | ## Supported Types 34 | 35 | Mangrove supports any type discussed in [Allowed Types](/2-models/allowed-types) as `_id`'s type, except for container types, `b_regex`, and `b_array`. This means that you can even use an embedded document as your `_id` type! 36 | 37 | You can read {{% a_blank "this article" "https://docs.mongodb.com/manual/core/document/#document-id-field" %}} in the MongoDB Manual to learn more about the exact limitations of the `_id` field. 38 | 39 | -------------------------------------------------------------------------------- /hugo/content/2-models/dynamic-schemas.md: -------------------------------------------------------------------------------- 1 | +++ 2 | next = "/3-queries/" 3 | prev = "/2-models/custom_id" 4 | title = "Dynamic Schemas" 5 | toc = true 6 | weight = 4 7 | 8 | +++ 9 | 10 | One of MongoDB's most attractive features is its ability to store "unstructured" data. While this seems irrelevant in the context of an ODM like Mangrove, we can actually take advantage of this. 11 | 12 | Let's say that you are storing a collection of web video metadata. You might want to store the number of views, the length of the video in seconds, and the web URL to access the video. If the video is hosted on YouTube, you may also want to store the name of the channel it's hosted on. MongoDB lets you do this by having a "youtube_channel" field that only exists in some documents. 13 | 14 | You can accomplish this in Mangrove with `optional` fields. 15 | 16 | ```cpp 17 | using boson::stdx::optional; 18 | 19 | class VideoMetadata : public mangrove::model { 20 | int64_t view_count; 21 | int32_t video_length; 22 | 23 | std::string url; 24 | optional youtube_channel; 25 | 26 | MANGROVE_MAKE_KEYS_MODEL(VideoMetadata, 27 | MANGROVE_NVP(view_count), 28 | MANGROVE_NVP(video_length), 29 | MANGROVE_NVP(url), 30 | MANGROVE_NVP(youtube_channel)) 31 | } 32 | ``` 33 | 34 | An `optional` in C++ either contains a value of type `T`, or contains nothing at all. When the optional is holding a type, Mangrove will serialize it normally. When it isn't, Mangrove will exclude it entirely. 35 | 36 | Here are two sample documents that could be produced by the above model: 37 | 38 | ```json 39 | { 40 | "view_count" : 224651625, 41 | "video_length" : 212, 42 | "url" : "https://www.youtube.com/watch?v=dQw4w9WgXcQ", 43 | "youtube_channel" : "RickAstleyVEVO" 44 | } 45 | 46 | { 47 | "view_count" : 305420, 48 | "video_length" : 193, 49 | "url" : "https://vimeo.com/53520224" 50 | } 51 | ``` 52 | 53 | You can have as many optional types as you want in a model (and you can even have only optionals) so that your model can be as flexible as your data. -------------------------------------------------------------------------------- /hugo/content/2-models/index.md: -------------------------------------------------------------------------------- 1 | +++ 2 | chapter = true 3 | icon = "2. " 4 | next = "/2-models/introduction" 5 | prev = "/1-basics/quick-tour" 6 | title = "Models" 7 | weight = 0 8 | 9 | +++ 10 | 11 | ### Chapter 2 12 | 13 | # Models 14 | 15 | Learn how to make the most of Mangrove **models**, which allow you to map C++ classes to MongoDB collections. 16 | -------------------------------------------------------------------------------- /hugo/content/3-queries/index.md: -------------------------------------------------------------------------------- 1 | +++ 2 | chapter = true 3 | icon = "3. " 4 | next = "/3-queries/introduction" 5 | prev = "/2-models/dynamic-schemas" 6 | title = "Queries" 7 | weight = 0 8 | 9 | +++ 10 | 11 | ### Chapter 3 12 | 13 | # Queries 14 | 15 | Learn about the rich **query** system supported by Mangrove's **models**. 16 | -------------------------------------------------------------------------------- /hugo/content/4-updates/index.md: -------------------------------------------------------------------------------- 1 | +++ 2 | chapter = true 3 | icon = "4. " 4 | next = "/4-updates/introduction" 5 | prev = "/3-queries/operators" 6 | title = "Updates" 7 | weight = 0 8 | 9 | +++ 10 | 11 | ### Chapter 4 12 | 13 | # Updates 14 | 15 | Learn how to use Mangrove's **update** builder to perform advanced bulk updates. 16 | -------------------------------------------------------------------------------- /hugo/content/4-updates/introduction.md: -------------------------------------------------------------------------------- 1 | +++ 2 | next = "/4-updates/operators" 3 | prev = "/4-updates/" 4 | title = "Introduction" 5 | toc = true 6 | weight = 1 7 | 8 | +++ 9 | 10 | Mangrove's expression builder also provides the ability to construct **update** expressions. 11 | The syntax is pretty much the same as for query expressions --- you refer to fields 12 | using `MANGROVE_KEY` and the other macros, and update them using 13 | C++ operators such as `=` and `+=`. Member functions are provided for operators which don't have 14 | a built-in C++ operator analog, such as the `$addToSet` operator. 15 | 16 | The following is an example of a bulk update which would edit sales tax info for users who live in 17 | New York: 18 | 19 | ```cpp 20 | // In the Mongo shell, this would be: 21 | // db.collection.updateMany({"addr.state": "NY"}, {$set: {sales_tax: 0.10}}); 22 | auto res = User::update_many(MANGROVE_CHILD(User, addr, state) == "NY", MANGROVE_KEY(User::sales_tax) = 0.10); 23 | ``` 24 | 25 | Note that a query, as seen in {{% a_blank "chapter 3" "/3-queries/" %}}, 26 | is given as the first argument, and an update is given as the second. 27 | 28 | The next section contains a reference of the available update operators. 29 | -------------------------------------------------------------------------------- /hugo/content/5-the-bson-mapper/index.md: -------------------------------------------------------------------------------- 1 | +++ 2 | chapter = true 3 | icon = "5. " 4 | prev = "/4-updates/operators/" 5 | title = "The BSON Mapper" 6 | weight = 0 7 | 8 | +++ 9 | 10 | ### Chapter 5 11 | 12 | # The BSON Mapper 13 | 14 | Learn about **Boson**, the {{% a_blank "Cereal" "http://uscilab.github.io/cereal/" %}}-powered **BSON serializer** that makes Mangrove work, and how you can use it in your own applications. 15 | 16 | {{% notice note %}} 17 | 18 | This chapter has not been written yet. Check back soon! 19 | 20 | {{% /notice %}} 21 | -------------------------------------------------------------------------------- /hugo/layouts/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /hugo/layouts/partials/logo.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /hugo/layouts/partials/menu.html: -------------------------------------------------------------------------------- 1 | 76 | -------------------------------------------------------------------------------- /hugo/layouts/partials/style.html: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /hugo/layouts/shortcodes/a_blank.html: -------------------------------------------------------------------------------- 1 | 4 | {{ .Get 0 | markdownify }} 5 | -------------------------------------------------------------------------------- /hugo/static/css/docs.css: -------------------------------------------------------------------------------- 1 | /* background behind the logo*/ 2 | #header { 3 | background: #4ba749; 4 | border-color: #449b45; 5 | } 6 | 7 | /* Background color of the menu */ 8 | #sidebar { 9 | background-color: #424242; 10 | } 11 | 12 | 13 | /* Background color of the menu, when clicked */ 14 | #sidebar ul.topics > li.parent, #sidebar ul.topics > li.active { 15 | background-color: #282828; 16 | } 17 | -------------------------------------------------------------------------------- /hugo/static/images/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mongodb-labs/mangrove/3e6f383af01f9fcee58b1d433415573a3b76c360/hugo/static/images/favicon.png -------------------------------------------------------------------------------- /hugo/static/images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mongodb-labs/mangrove/3e6f383af01f9fcee58b1d433415573a3b76c360/hugo/static/images/logo.png -------------------------------------------------------------------------------- /hugo/themes/hugo-theme-learn/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | public/ 3 | -------------------------------------------------------------------------------- /hugo/themes/hugo-theme-learn/LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Grav 4 | Copyright (c) 2016 MATHIEU CORNIC 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy of 7 | this software and associated documentation files (the "Software"), to deal in 8 | the Software without restriction, including without limitation the rights to 9 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 10 | the Software, and to permit persons to whom the Software is furnished to do so, 11 | subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 18 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 19 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 20 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /hugo/themes/hugo-theme-learn/README.md: -------------------------------------------------------------------------------- 1 | # Hugo Learn Theme 2 | 3 | This repository contains a theme for [Hugo](https://gohugo.io/), based on great [Grav Learn Theme](http://learn.getgrav.org/). 4 | 5 | Visit the [theme documentation](https://matcornic.github.io/hugo-learn-doc/basics/what-is-this-hugo-theme/) to see what is going on. It is actually built with this theme. 6 | 7 | ### Installation 8 | Navigate to your themes folder in your Hugo site and use the following commands: 9 | ``` 10 | $ cd themes 11 | $ git clone https://github.com/matcornic/hugo-theme-learn.git 12 | ``` 13 | 14 | ![Overview](images/tn.png) 15 | 16 | # Main functionalities 17 | 18 | - Handle two levels of documentation 19 | - Tip/Note/Info and Warning boxes 20 | - Resize images 21 | - Preview of original image size 22 | - Add shadow or border on images 23 | - Automatic table of contents 24 | - Create buttons (typically used to provide a link to a demo) 25 | 26 | # TODO 27 | 28 | - Handling more than 2 levels in documentation. 29 | - Search in site 30 | - Handling videos 31 | - Add optional button to create doc issue (like github) 32 | -------------------------------------------------------------------------------- /hugo/themes/hugo-theme-learn/archetypes/chapter.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Some Chapter title" 3 | weight: 0 4 | prev: /prev/path 5 | next: /next/path 6 | chapter: true 7 | icon: "X. " # HTML code as prefix in the menu 8 | --- 9 | 10 | ### Chapter X 11 | 12 | # Some Chapter title 13 | 14 | Lorem ipsum 15 | -------------------------------------------------------------------------------- /hugo/themes/hugo-theme-learn/archetypes/default.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Some Title" 3 | weight: 5 4 | prev: /prev/path 5 | next: /next/path 6 | toc: true 7 | --- 8 | 9 | Lorem Ipsum 10 | -------------------------------------------------------------------------------- /hugo/themes/hugo-theme-learn/images/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mongodb-labs/mangrove/3e6f383af01f9fcee58b1d433415573a3b76c360/hugo/themes/hugo-theme-learn/images/screenshot.png -------------------------------------------------------------------------------- /hugo/themes/hugo-theme-learn/images/tn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mongodb-labs/mangrove/3e6f383af01f9fcee58b1d433415573a3b76c360/hugo/themes/hugo-theme-learn/images/tn.png -------------------------------------------------------------------------------- /hugo/themes/hugo-theme-learn/layouts/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {{ partial "meta.html" . }} {{ partial "favicon.html" . }} {{ .Scratch.Add "title" "" }}{{ if isset .Site.Data.titles .Title }}{{ .Scratch.Set "title" (index .Site.Data.titles .Title).title }}{{ else }}{{ .Scratch.Set "title" .Title}}{{end}} 6 | {{ .Scratch.Get "title" }} 7 | {{ partial "style.html" . }} 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 30 | 31 | 32 | 33 | 34 | 35 | 36 |
37 |
38 |
39 |
40 |

Error

41 |

42 |

43 |

Woops. Looks like this page doesn't exist.

44 |

45 |

Go to homepage

46 |

47 |
48 |
49 | 50 |
51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /hugo/themes/hugo-theme-learn/layouts/_default/list.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mongodb-labs/mangrove/3e6f383af01f9fcee58b1d433415573a3b76c360/hugo/themes/hugo-theme-learn/layouts/_default/list.html -------------------------------------------------------------------------------- /hugo/themes/hugo-theme-learn/layouts/_default/single.html: -------------------------------------------------------------------------------- 1 | {{ partial "header.html" . }} 2 | {{ .Content }} 3 | {{ partial "footer.html" . }} 4 | -------------------------------------------------------------------------------- /hugo/themes/hugo-theme-learn/layouts/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {{ partial "meta.html" . }} 6 | {{ partial "favicon.html" . }} 7 | {{ .Scratch.Add "title" "" }}{{ if isset .Site.Data.titles .Title }}{{ .Scratch.Set "title" (index .Site.Data.titles .Title).title }}{{ else }}{{ .Scratch.Set "title" .Title}}{{end}} 8 | {{ .Scratch.Get "title" }} 9 | {{ partial "style.html" . }} 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 31 | 32 | 33 | 34 | 35 |
36 |
37 | 38 |
39 |

Customize your own home page

40 |

41 | The site is working, change the URL in your browser to get to any custom page. But, don't forget to overwrite this index.html with your own. You typically have 3 choices : 42 |

43 |
    44 |
  • 1. Create an overview page for your project
  • 45 |
  • 2. Create an empty html page with this code in the head tag to redirect to one of your documentation page : <meta http-equiv="refresh" content="0; url=http://example.com/"/>
  • 46 |
  • 3. Configure your server to automatically redirect home page to one your documentation page
  • 47 |
48 |

49 |
50 |
51 | 52 | 53 | -------------------------------------------------------------------------------- /hugo/themes/hugo-theme-learn/layouts/partials/favicon.html: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /hugo/themes/hugo-theme-learn/layouts/partials/footer.html: -------------------------------------------------------------------------------- 1 | 2 | {{ if .Params.chapter }} 3 | 4 | {{ end }} 5 | 6 | 7 | 8 | 12 | 13 | 14 |
15 |
16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | {{ partial "script.html" . }} 30 | 31 | 32 | -------------------------------------------------------------------------------- /hugo/themes/hugo-theme-learn/layouts/partials/header.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | {{ .Hugo.Generator }} 7 | {{ partial "meta.html" . }} 8 | {{ partial "favicon.html" . }} 9 | {{ .Scratch.Add "title" "" }}{{ if isset .Site.Data.titles .Title }}{{ .Scratch.Set "title" (index .Site.Data.titles .Title).title }}{{ else }}{{ .Scratch.Set "title" .Title}}{{end}} 10 | {{ .Scratch.Get "title" }} 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 20 | {{ partial "style.html" . }} 21 | 22 | 23 | {{ partial "menu.html" . }} 24 |
25 |
26 | 27 |
28 | 29 |
30 | {{ if and .IsPage .Site.Params.editURL }} 31 | {{ $File := .File }} 32 | {{ $Site := .Site }} 33 | {{with $File.Path }} 34 | 40 | {{ end }} 41 | {{ end }} 42 | 63 | {{ if .Params.toc }} 64 | {{ partial "toc.html" . }} 65 | {{ end }} 66 | 67 |
68 | {{ if .Params.chapter }} 69 |
70 | {{ end }} 71 |
72 | {{ if not .Params.chapter }} 73 |

{{.Title}}

74 | {{ end }} 75 | -------------------------------------------------------------------------------- /hugo/themes/hugo-theme-learn/layouts/partials/menu.html: -------------------------------------------------------------------------------- 1 | 61 | -------------------------------------------------------------------------------- /hugo/themes/hugo-theme-learn/layouts/partials/meta.html: -------------------------------------------------------------------------------- 1 | 2 | {{ with .Site.Params.author }}{{ end }} 3 | -------------------------------------------------------------------------------- /hugo/themes/hugo-theme-learn/layouts/partials/script.html: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /hugo/themes/hugo-theme-learn/layouts/partials/style.html: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /hugo/themes/hugo-theme-learn/layouts/partials/toc.html: -------------------------------------------------------------------------------- 1 |
2 |
3 | {{ .TableOfContents }} 4 |
5 |
6 | -------------------------------------------------------------------------------- /hugo/themes/hugo-theme-learn/layouts/shortcodes/button.html: -------------------------------------------------------------------------------- 1 | 2 | {{ $icon := .Get "icon" }} 3 | {{ $iconposition := .Get "icon-position" }} 4 | {{ if ($icon) }} 5 | {{ if or (not ($iconposition)) (eq $iconposition "left") }} 6 | 7 | {{ end }} 8 | {{ end }} 9 | {{ .Inner }} 10 | {{ if and ($icon) (eq $iconposition "right")}} 11 | 12 | {{ end }} 13 | 14 | -------------------------------------------------------------------------------- /hugo/themes/hugo-theme-learn/layouts/shortcodes/notice.html: -------------------------------------------------------------------------------- 1 |
{{ .Inner }}
2 | -------------------------------------------------------------------------------- /hugo/themes/hugo-theme-learn/static/css/featherlight.min.css: -------------------------------------------------------------------------------- 1 | /** 2 | * Featherlight - ultra slim jQuery lightbox 3 | * Version 1.2.3 - http://noelboss.github.io/featherlight/ 4 | * 5 | * Copyright 2015, Noël Raoul Bossart (http://www.noelboss.com) 6 | * MIT Licensed. 7 | **/ 8 | @media all{.featherlight{display:none;position:fixed;top:0;right:0;bottom:0;left:0;z-index:2147483647;text-align:center;white-space:nowrap;cursor:pointer;background:#333;background:rgba(0,0,0,0)}.featherlight:last-of-type{background:rgba(0,0,0,.8)}.featherlight:before{content:'';display:inline-block;height:100%;vertical-align:middle;margin-right:-.25em}.featherlight .featherlight-content{position:relative;text-align:left;vertical-align:middle;display:inline-block;overflow:auto;padding:25px 25px 0;border-bottom:25px solid transparent;min-width:30%;margin-left:5%;margin-right:5%;max-height:95%;background:#fff;cursor:auto;white-space:normal}.featherlight .featherlight-inner{display:block}.featherlight .featherlight-close-icon{position:absolute;z-index:9999;top:0;right:0;line-height:25px;width:25px;cursor:pointer;text-align:center;font:Arial,sans-serif;background:#fff;background:rgba(255,255,255,.3);color:#000}.featherlight .featherlight-image{width:100%}.featherlight-iframe .featherlight-content{border-bottom:0;padding:0}.featherlight iframe{border:0}}@media only screen and (max-width:1024px){.featherlight .featherlight-content{margin-left:10px;margin-right:10px;max-height:98%;padding:10px 10px 0;border-bottom:10px solid transparent}} -------------------------------------------------------------------------------- /hugo/themes/hugo-theme-learn/static/css/hybrid.css: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | vim-hybrid theme by w0ng (https://github.com/w0ng/vim-hybrid) 4 | 5 | */ 6 | 7 | /*background color*/ 8 | .hljs { 9 | display: block; 10 | overflow-x: auto; 11 | padding: 0.5em; 12 | background: #1d1f21; 13 | } 14 | 15 | /*selection color*/ 16 | .hljs::selection, 17 | .hljs span::selection { 18 | background: #373b41; 19 | } 20 | 21 | .hljs::-moz-selection, 22 | .hljs span::-moz-selection { 23 | background: #373b41; 24 | } 25 | 26 | /*foreground color*/ 27 | .hljs { 28 | color: #c5c8c6; 29 | } 30 | 31 | /*color: fg_yellow*/ 32 | .hljs-title, 33 | .hljs-name { 34 | color: #f0c674; 35 | } 36 | 37 | /*color: fg_comment*/ 38 | .hljs-comment, 39 | .hljs-meta, 40 | .hljs-meta .hljs-keyword { 41 | color: #707880; 42 | } 43 | 44 | /*color: fg_red*/ 45 | .hljs-number, 46 | .hljs-symbol, 47 | .hljs-literal, 48 | .hljs-deletion, 49 | .hljs-link { 50 | color: #cc6666 51 | } 52 | 53 | /*color: fg_green*/ 54 | .hljs-string, 55 | .hljs-doctag, 56 | .hljs-addition, 57 | .hljs-regexp, 58 | .hljs-selector-attr, 59 | .hljs-selector-pseudo { 60 | color: #b5bd68; 61 | } 62 | 63 | /*color: fg_purple*/ 64 | .hljs-attribute, 65 | .hljs-code, 66 | .hljs-selector-id { 67 | color: #b294bb; 68 | } 69 | 70 | /*color: fg_blue*/ 71 | .hljs-keyword, 72 | .hljs-selector-tag, 73 | .hljs-bullet, 74 | .hljs-tag { 75 | color: #81a2be; 76 | } 77 | 78 | /*color: fg_aqua*/ 79 | .hljs-subst, 80 | .hljs-variable, 81 | .hljs-template-tag, 82 | .hljs-template-variable { 83 | color: #8abeb7; 84 | } 85 | 86 | /*color: fg_orange*/ 87 | .hljs-type, 88 | .hljs-built_in, 89 | .hljs-builtin-name, 90 | .hljs-quote, 91 | .hljs-section, 92 | .hljs-selector-class { 93 | color: #de935f; 94 | } 95 | 96 | .hljs-emphasis { 97 | font-style: italic; 98 | } 99 | 100 | .hljs-strong { 101 | font-weight: bold; 102 | } 103 | -------------------------------------------------------------------------------- /hugo/themes/hugo-theme-learn/static/css/perfect-scrollbar.min.css: -------------------------------------------------------------------------------- 1 | /* perfect-scrollbar v0.6.10 */ 2 | .ps-container{-ms-touch-action:none;touch-action:none;overflow:hidden !important;-ms-overflow-style:none}@supports (-ms-overflow-style: none){.ps-container{overflow:auto !important}}@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none){.ps-container{overflow:auto !important}}.ps-container.ps-active-x>.ps-scrollbar-x-rail,.ps-container.ps-active-y>.ps-scrollbar-y-rail{display:block;background-color:transparent}.ps-container.ps-in-scrolling{pointer-events:none}.ps-container.ps-in-scrolling.ps-x>.ps-scrollbar-x-rail{background-color:#eee;opacity:0.9}.ps-container.ps-in-scrolling.ps-x>.ps-scrollbar-x-rail>.ps-scrollbar-x{background-color:#999}.ps-container.ps-in-scrolling.ps-y>.ps-scrollbar-y-rail{background-color:#eee;opacity:0.9}.ps-container.ps-in-scrolling.ps-y>.ps-scrollbar-y-rail>.ps-scrollbar-y{background-color:#999}.ps-container>.ps-scrollbar-x-rail{display:none;position:absolute;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;opacity:0;-webkit-transition:background-color .2s linear, opacity .2s linear;-moz-transition:background-color .2s linear, opacity .2s linear;-o-transition:background-color .2s linear, opacity .2s linear;transition:background-color .2s linear, opacity .2s linear;bottom:3px;height:8px}.ps-container>.ps-scrollbar-x-rail>.ps-scrollbar-x{position:absolute;background-color:#aaa;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;-webkit-transition:background-color .2s linear;-moz-transition:background-color .2s linear;-o-transition:background-color .2s linear;transition:background-color .2s linear;bottom:0;height:8px}.ps-container>.ps-scrollbar-y-rail{display:none;position:absolute;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;opacity:0;-webkit-transition:background-color .2s linear, opacity .2s linear;-moz-transition:background-color .2s linear, opacity .2s linear;-o-transition:background-color .2s linear, opacity .2s linear;transition:background-color .2s linear, opacity .2s linear;right:3px;width:8px}.ps-container>.ps-scrollbar-y-rail>.ps-scrollbar-y{position:absolute;background-color:#aaa;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;-webkit-transition:background-color .2s linear;-moz-transition:background-color .2s linear;-o-transition:background-color .2s linear;transition:background-color .2s linear;right:0;width:8px}.ps-container:hover.ps-in-scrolling{pointer-events:none}.ps-container:hover.ps-in-scrolling.ps-x>.ps-scrollbar-x-rail{background-color:#eee;opacity:0.9}.ps-container:hover.ps-in-scrolling.ps-x>.ps-scrollbar-x-rail>.ps-scrollbar-x{background-color:#999}.ps-container:hover.ps-in-scrolling.ps-y>.ps-scrollbar-y-rail{background-color:#eee;opacity:0.9}.ps-container:hover.ps-in-scrolling.ps-y>.ps-scrollbar-y-rail>.ps-scrollbar-y{background-color:#999}.ps-container:hover>.ps-scrollbar-x-rail,.ps-container:hover>.ps-scrollbar-y-rail{opacity:0.6}.ps-container:hover>.ps-scrollbar-x-rail:hover{background-color:#eee;opacity:0.9}.ps-container:hover>.ps-scrollbar-x-rail:hover>.ps-scrollbar-x{background-color:#999}.ps-container:hover>.ps-scrollbar-y-rail:hover{background-color:#eee;opacity:0.9}.ps-container:hover>.ps-scrollbar-y-rail:hover>.ps-scrollbar-y{background-color:#999} 3 | -------------------------------------------------------------------------------- /hugo/themes/hugo-theme-learn/static/fonts/FontAwesome.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mongodb-labs/mangrove/3e6f383af01f9fcee58b1d433415573a3b76c360/hugo/themes/hugo-theme-learn/static/fonts/FontAwesome.otf -------------------------------------------------------------------------------- /hugo/themes/hugo-theme-learn/static/fonts/Inconsolata.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mongodb-labs/mangrove/3e6f383af01f9fcee58b1d433415573a3b76c360/hugo/themes/hugo-theme-learn/static/fonts/Inconsolata.eot -------------------------------------------------------------------------------- /hugo/themes/hugo-theme-learn/static/fonts/Inconsolata.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mongodb-labs/mangrove/3e6f383af01f9fcee58b1d433415573a3b76c360/hugo/themes/hugo-theme-learn/static/fonts/Inconsolata.ttf -------------------------------------------------------------------------------- /hugo/themes/hugo-theme-learn/static/fonts/Inconsolata.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mongodb-labs/mangrove/3e6f383af01f9fcee58b1d433415573a3b76c360/hugo/themes/hugo-theme-learn/static/fonts/Inconsolata.woff -------------------------------------------------------------------------------- /hugo/themes/hugo-theme-learn/static/fonts/Novecentosanswide-Normal-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mongodb-labs/mangrove/3e6f383af01f9fcee58b1d433415573a3b76c360/hugo/themes/hugo-theme-learn/static/fonts/Novecentosanswide-Normal-webfont.eot -------------------------------------------------------------------------------- /hugo/themes/hugo-theme-learn/static/fonts/Novecentosanswide-Normal-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mongodb-labs/mangrove/3e6f383af01f9fcee58b1d433415573a3b76c360/hugo/themes/hugo-theme-learn/static/fonts/Novecentosanswide-Normal-webfont.ttf -------------------------------------------------------------------------------- /hugo/themes/hugo-theme-learn/static/fonts/Novecentosanswide-Normal-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mongodb-labs/mangrove/3e6f383af01f9fcee58b1d433415573a3b76c360/hugo/themes/hugo-theme-learn/static/fonts/Novecentosanswide-Normal-webfont.woff -------------------------------------------------------------------------------- /hugo/themes/hugo-theme-learn/static/fonts/Novecentosanswide-Normal-webfont.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mongodb-labs/mangrove/3e6f383af01f9fcee58b1d433415573a3b76c360/hugo/themes/hugo-theme-learn/static/fonts/Novecentosanswide-Normal-webfont.woff2 -------------------------------------------------------------------------------- /hugo/themes/hugo-theme-learn/static/fonts/Novecentosanswide-UltraLight-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mongodb-labs/mangrove/3e6f383af01f9fcee58b1d433415573a3b76c360/hugo/themes/hugo-theme-learn/static/fonts/Novecentosanswide-UltraLight-webfont.eot -------------------------------------------------------------------------------- /hugo/themes/hugo-theme-learn/static/fonts/Novecentosanswide-UltraLight-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mongodb-labs/mangrove/3e6f383af01f9fcee58b1d433415573a3b76c360/hugo/themes/hugo-theme-learn/static/fonts/Novecentosanswide-UltraLight-webfont.ttf -------------------------------------------------------------------------------- /hugo/themes/hugo-theme-learn/static/fonts/Novecentosanswide-UltraLight-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mongodb-labs/mangrove/3e6f383af01f9fcee58b1d433415573a3b76c360/hugo/themes/hugo-theme-learn/static/fonts/Novecentosanswide-UltraLight-webfont.woff -------------------------------------------------------------------------------- /hugo/themes/hugo-theme-learn/static/fonts/Novecentosanswide-UltraLight-webfont.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mongodb-labs/mangrove/3e6f383af01f9fcee58b1d433415573a3b76c360/hugo/themes/hugo-theme-learn/static/fonts/Novecentosanswide-UltraLight-webfont.woff2 -------------------------------------------------------------------------------- /hugo/themes/hugo-theme-learn/static/fonts/Work_Sans_200.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mongodb-labs/mangrove/3e6f383af01f9fcee58b1d433415573a3b76c360/hugo/themes/hugo-theme-learn/static/fonts/Work_Sans_200.eot -------------------------------------------------------------------------------- /hugo/themes/hugo-theme-learn/static/fonts/Work_Sans_200.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mongodb-labs/mangrove/3e6f383af01f9fcee58b1d433415573a3b76c360/hugo/themes/hugo-theme-learn/static/fonts/Work_Sans_200.ttf -------------------------------------------------------------------------------- /hugo/themes/hugo-theme-learn/static/fonts/Work_Sans_200.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mongodb-labs/mangrove/3e6f383af01f9fcee58b1d433415573a3b76c360/hugo/themes/hugo-theme-learn/static/fonts/Work_Sans_200.woff -------------------------------------------------------------------------------- /hugo/themes/hugo-theme-learn/static/fonts/Work_Sans_200.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mongodb-labs/mangrove/3e6f383af01f9fcee58b1d433415573a3b76c360/hugo/themes/hugo-theme-learn/static/fonts/Work_Sans_200.woff2 -------------------------------------------------------------------------------- /hugo/themes/hugo-theme-learn/static/fonts/Work_Sans_300.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mongodb-labs/mangrove/3e6f383af01f9fcee58b1d433415573a3b76c360/hugo/themes/hugo-theme-learn/static/fonts/Work_Sans_300.eot -------------------------------------------------------------------------------- /hugo/themes/hugo-theme-learn/static/fonts/Work_Sans_300.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mongodb-labs/mangrove/3e6f383af01f9fcee58b1d433415573a3b76c360/hugo/themes/hugo-theme-learn/static/fonts/Work_Sans_300.ttf -------------------------------------------------------------------------------- /hugo/themes/hugo-theme-learn/static/fonts/Work_Sans_300.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mongodb-labs/mangrove/3e6f383af01f9fcee58b1d433415573a3b76c360/hugo/themes/hugo-theme-learn/static/fonts/Work_Sans_300.woff -------------------------------------------------------------------------------- /hugo/themes/hugo-theme-learn/static/fonts/Work_Sans_300.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mongodb-labs/mangrove/3e6f383af01f9fcee58b1d433415573a3b76c360/hugo/themes/hugo-theme-learn/static/fonts/Work_Sans_300.woff2 -------------------------------------------------------------------------------- /hugo/themes/hugo-theme-learn/static/fonts/Work_Sans_500.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mongodb-labs/mangrove/3e6f383af01f9fcee58b1d433415573a3b76c360/hugo/themes/hugo-theme-learn/static/fonts/Work_Sans_500.eot -------------------------------------------------------------------------------- /hugo/themes/hugo-theme-learn/static/fonts/Work_Sans_500.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mongodb-labs/mangrove/3e6f383af01f9fcee58b1d433415573a3b76c360/hugo/themes/hugo-theme-learn/static/fonts/Work_Sans_500.ttf -------------------------------------------------------------------------------- /hugo/themes/hugo-theme-learn/static/fonts/Work_Sans_500.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mongodb-labs/mangrove/3e6f383af01f9fcee58b1d433415573a3b76c360/hugo/themes/hugo-theme-learn/static/fonts/Work_Sans_500.woff -------------------------------------------------------------------------------- /hugo/themes/hugo-theme-learn/static/fonts/Work_Sans_500.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mongodb-labs/mangrove/3e6f383af01f9fcee58b1d433415573a3b76c360/hugo/themes/hugo-theme-learn/static/fonts/Work_Sans_500.woff2 -------------------------------------------------------------------------------- /hugo/themes/hugo-theme-learn/static/fonts/fontawesome-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mongodb-labs/mangrove/3e6f383af01f9fcee58b1d433415573a3b76c360/hugo/themes/hugo-theme-learn/static/fonts/fontawesome-webfont.eot -------------------------------------------------------------------------------- /hugo/themes/hugo-theme-learn/static/fonts/fontawesome-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mongodb-labs/mangrove/3e6f383af01f9fcee58b1d433415573a3b76c360/hugo/themes/hugo-theme-learn/static/fonts/fontawesome-webfont.ttf -------------------------------------------------------------------------------- /hugo/themes/hugo-theme-learn/static/fonts/fontawesome-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mongodb-labs/mangrove/3e6f383af01f9fcee58b1d433415573a3b76c360/hugo/themes/hugo-theme-learn/static/fonts/fontawesome-webfont.woff -------------------------------------------------------------------------------- /hugo/themes/hugo-theme-learn/static/fonts/fontawesome-webfont.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mongodb-labs/mangrove/3e6f383af01f9fcee58b1d433415573a3b76c360/hugo/themes/hugo-theme-learn/static/fonts/fontawesome-webfont.woff2 -------------------------------------------------------------------------------- /hugo/themes/hugo-theme-learn/static/images/clippy.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /hugo/themes/hugo-theme-learn/static/images/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mongodb-labs/mangrove/3e6f383af01f9fcee58b1d433415573a3b76c360/hugo/themes/hugo-theme-learn/static/images/favicon.png -------------------------------------------------------------------------------- /hugo/themes/hugo-theme-learn/static/images/gopher-404.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mongodb-labs/mangrove/3e6f383af01f9fcee58b1d433415573a3b76c360/hugo/themes/hugo-theme-learn/static/images/gopher-404.jpg -------------------------------------------------------------------------------- /hugo/themes/hugo-theme-learn/static/js/html5shiv-printshiv.min.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @preserve HTML5 Shiv prev3.7.1 | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed 3 | */ 4 | !function(a,b){function c(a,b){var c=a.createElement("p"),d=a.getElementsByTagName("head")[0]||a.documentElement;return c.innerHTML="x",d.insertBefore(c.lastChild,d.firstChild)}function d(){var a=x.elements;return"string"==typeof a?a.split(" "):a}function e(a){var b=w[a[u]];return b||(b={},v++,a[u]=v,w[v]=b),b}function f(a,c,d){if(c||(c=b),p)return c.createElement(a);d||(d=e(c));var f;return f=d.cache[a]?d.cache[a].cloneNode():t.test(a)?(d.cache[a]=d.createElem(a)).cloneNode():d.createElem(a),!f.canHaveChildren||s.test(a)||f.tagUrn?f:d.frag.appendChild(f)}function g(a,c){if(a||(a=b),p)return a.createDocumentFragment();c=c||e(a);for(var f=c.frag.cloneNode(),g=0,h=d(),i=h.length;i>g;g++)f.createElement(h[g]);return f}function h(a,b){b.cache||(b.cache={},b.createElem=a.createElement,b.createFrag=a.createDocumentFragment,b.frag=b.createFrag()),a.createElement=function(c){return x.shivMethods?f(c,a,b):b.createElem(c)},a.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+d().join().replace(/[\w\-:]+/g,function(a){return b.createElem(a),b.frag.createElement(a),'c("'+a+'")'})+");return n}")(x,b.frag)}function i(a){a||(a=b);var d=e(a);return!x.shivCSS||o||d.hasCSS||(d.hasCSS=!!c(a,"article,aside,dialog,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}mark{background:#FF0;color:#000}template{display:none}")),p||h(a,d),a}function j(a){for(var b,c=a.getElementsByTagName("*"),e=c.length,f=RegExp("^(?:"+d().join("|")+")$","i"),g=[];e--;)b=c[e],f.test(b.nodeName)&&g.push(b.applyElement(k(b)));return g}function k(a){for(var b,c=a.attributes,d=c.length,e=a.ownerDocument.createElement(z+":"+a.nodeName);d--;)b=c[d],b.specified&&e.setAttribute(b.nodeName,b.nodeValue);return e.style.cssText=a.style.cssText,e}function l(a){for(var b,c=a.split("{"),e=c.length,f=RegExp("(^|[\\s,>+~])("+d().join("|")+")(?=[[\\s,>+~#.:]|$)","gi"),g="$1"+z+"\\:$2";e--;)b=c[e]=c[e].split("}"),b[b.length-1]=b[b.length-1].replace(f,g),c[e]=b.join("}");return c.join("{")}function m(a){for(var b=a.length;b--;)a[b].removeNode()}function n(a){function b(){clearTimeout(g._removeSheetTimer),d&&d.removeNode(!0),d=null}var d,f,g=e(a),h=a.namespaces,i=a.parentWindow;return!A||a.printShived?a:("undefined"==typeof h[z]&&h.add(z),i.attachEvent("onbeforeprint",function(){b();for(var e,g,h,i=a.styleSheets,k=[],m=i.length,n=Array(m);m--;)n[m]=i[m];for(;h=n.pop();)if(!h.disabled&&y.test(h.media)){try{e=h.imports,g=e.length}catch(o){g=0}for(m=0;g>m;m++)n.push(e[m]);try{k.push(h.cssText)}catch(o){}}k=l(k.reverse().join("")),f=j(a),d=c(a,k)}),i.attachEvent("onafterprint",function(){m(f),clearTimeout(g._removeSheetTimer),g._removeSheetTimer=setTimeout(b,500)}),a.printShived=!0,a)}var o,p,q="3.7.0",r=a.html5||{},s=/^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i,t=/^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i,u="_html5shiv",v=0,w={};!function(){try{var a=b.createElement("a");a.innerHTML="",o="hidden"in a,p=1==a.childNodes.length||function(){b.createElement("a");var a=b.createDocumentFragment();return"undefined"==typeof a.cloneNode||"undefined"==typeof a.createDocumentFragment||"undefined"==typeof a.createElement}()}catch(c){o=!0,p=!0}}();var x={elements:r.elements||"abbr article aside audio bdi canvas data datalist details dialog figcaption figure footer header hgroup main mark meter nav output picture progress section summary template time video",version:q,shivCSS:r.shivCSS!==!1,supportsUnknownElements:p,shivMethods:r.shivMethods!==!1,type:"default",shivDocument:i,createElement:f,createDocumentFragment:g};a.html5=x,i(b);var y=/^$|\b(?:all|print)\b/,z="html5shiv",A=!p&&function(){var c=b.documentElement;return!("undefined"==typeof b.namespaces||"undefined"==typeof b.parentWindow||"undefined"==typeof c.applyElement||"undefined"==typeof c.removeNode||"undefined"==typeof a.attachEvent)}();x.type+=" print",x.shivPrint=n,n(b)}(this,document); -------------------------------------------------------------------------------- /hugo/themes/hugo-theme-learn/static/js/hugo-learn.js: -------------------------------------------------------------------------------- 1 | // Get Parameters from some url 2 | var getUrlParameter = function getUrlParameter(sPageURL) { 3 | var url = sPageURL.split('?'); 4 | var obj = {}; 5 | if (url.length == 2) { 6 | var sURLVariables = url[1].split('&'), 7 | sParameterName, 8 | i; 9 | for (i = 0; i < sURLVariables.length; i++) { 10 | sParameterName = sURLVariables[i].split('='); 11 | obj[sParameterName[0]] = sParameterName[1]; 12 | } 13 | return obj; 14 | } else { 15 | return undefined; 16 | } 17 | }; 18 | 19 | // Execute actions on images generated from Markdown pages 20 | var images = $("div#body-inner img"); 21 | // Wrap image inside a featherlight (to get a full size view in a popup) 22 | images.wrap(function(){ 23 | var image =$(this); 24 | return ""; 25 | }); 26 | 27 | // Change styles, depending on parameters set to the image 28 | images.each(function(index){ 29 | var image = $(this) 30 | var o = getUrlParameter(image[0].src); 31 | if (typeof o !== "undefined") { 32 | var h = o["height"]; 33 | var w = o["width"]; 34 | var c = o["classes"]; 35 | image.css("width", function() { 36 | if (typeof w !== "undefined") { 37 | return w; 38 | } else { 39 | return "auto"; 40 | } 41 | }); 42 | image.css("height", function() { 43 | if (typeof h !== "undefined") { 44 | return h; 45 | } else { 46 | return "auto"; 47 | } 48 | }); 49 | if (typeof c !== "undefined") { 50 | var classes = c.split(','); 51 | for (i = 0; i < classes.length; i++) { 52 | image.addClass(classes[i]); 53 | } 54 | } 55 | } 56 | }); 57 | 58 | // Stick the top to the top of the screen when scrolling 59 | $("#top-bar").stick_in_parent(); 60 | 61 | 62 | jQuery(document).ready(function() { 63 | // Add link button for every 64 | var text, clip = new Clipboard('.anchor'); 65 | $("h1~h2,h1~h3,h1~h4,h1~h5,h1~h6").append(function(index, html){ 66 | var element = $(this); 67 | var url = document.location.origin + document.location.pathname; 68 | var link = url + "#"+element[0].id; 69 | return " " + 70 | "" + 71 | "" 72 | ; 73 | }); 74 | 75 | $(".anchor").on('mouseleave', function(e) { 76 | $(this).attr('aria-label', null).removeClass('tooltipped tooltipped-s tooltipped-w'); 77 | }); 78 | 79 | clip.on('success', function(e) { 80 | e.clearSelection(); 81 | $(e.trigger).attr('aria-label', 'Link copied to clipboard!').addClass('tooltipped tooltipped-s'); 82 | }); 83 | 84 | }); 85 | -------------------------------------------------------------------------------- /hugo/themes/hugo-theme-learn/static/js/jquery.sticky-kit.min.js: -------------------------------------------------------------------------------- 1 | /* 2 | Sticky-kit v1.1.2 | WTFPL | Leaf Corcoran 2015 | http://leafo.net 3 | */ 4 | (function(){var b,f;b=this.jQuery||window.jQuery;f=b(window);b.fn.stick_in_parent=function(d){var A,w,J,n,B,K,p,q,k,E,t;null==d&&(d={});t=d.sticky_class;B=d.inner_scrolling;E=d.recalc_every;k=d.parent;q=d.offset_top;p=d.spacer;w=d.bottoming;null==q&&(q=0);null==k&&(k=void 0);null==B&&(B=!0);null==t&&(t="is_stuck");A=b(document);null==w&&(w=!0);J=function(a,d,n,C,F,u,r,G){var v,H,m,D,I,c,g,x,y,z,h,l;if(!a.data("sticky_kit")){a.data("sticky_kit",!0);I=A.height();g=a.parent();null!=k&&(g=g.closest(k)); 5 | if(!g.length)throw"failed to find stick parent";v=m=!1;(h=null!=p?p&&a.closest(p):b("
"))&&h.css("position",a.css("position"));x=function(){var c,f,e;if(!G&&(I=A.height(),c=parseInt(g.css("border-top-width"),10),f=parseInt(g.css("padding-top"),10),d=parseInt(g.css("padding-bottom"),10),n=g.offset().top+c+f,C=g.height(),m&&(v=m=!1,null==p&&(a.insertAfter(h),h.detach()),a.css({position:"",top:"",width:"",bottom:""}).removeClass(t),e=!0),F=a.offset().top-(parseInt(a.css("margin-top"),10)||0)-q, 6 | u=a.outerHeight(!0),r=a.css("float"),h&&h.css({width:a.outerWidth(!0),height:u,display:a.css("display"),"vertical-align":a.css("vertical-align"),"float":r}),e))return l()};x();if(u!==C)return D=void 0,c=q,z=E,l=function(){var b,l,e,k;if(!G&&(e=!1,null!=z&&(--z,0>=z&&(z=E,x(),e=!0)),e||A.height()===I||x(),e=f.scrollTop(),null!=D&&(l=e-D),D=e,m?(w&&(k=e+u+c>C+n,v&&!k&&(v=!1,a.css({position:"fixed",bottom:"",top:c}).trigger("sticky_kit:unbottom"))),eb&&!v&&(c-=l,c=Math.max(b-u,c),c=Math.min(q,c),m&&a.css({top:c+"px"})))):e>F&&(m=!0,b={position:"fixed",top:c},b.width="border-box"===a.css("box-sizing")?a.outerWidth()+"px":a.width()+"px",a.css(b).addClass(t),null==p&&(a.after(h),"left"!==r&&"right"!==r||h.append(a)),a.trigger("sticky_kit:stick")),m&&w&&(null==k&&(k=e+u+c>C+n),!v&&k)))return v=!0,"static"===g.css("position")&&g.css({position:"relative"}), 8 | a.css({position:"absolute",bottom:d,top:"auto"}).trigger("sticky_kit:bottom")},y=function(){x();return l()},H=function(){G=!0;f.off("touchmove",l);f.off("scroll",l);f.off("resize",y);b(document.body).off("sticky_kit:recalc",y);a.off("sticky_kit:detach",H);a.removeData("sticky_kit");a.css({position:"",bottom:"",top:"",width:""});g.position("position","");if(m)return null==p&&("left"!==r&&"right"!==r||a.insertAfter(h),h.remove()),a.removeClass(t)},f.on("touchmove",l),f.on("scroll",l),f.on("resize", 9 | y),b(document.body).on("sticky_kit:recalc",y),a.on("sticky_kit:detach",H),setTimeout(l,0)}};n=0;for(K=this.length;n= @LIBBSONCXX_REQUIRED_VERSION@ 24 | Cflags: -I${includedir}/boson/@BOSON_INLINE_NAMESPACE@ -I${includedir}/boson/@BOSON_INLINE_NAMESPACE@/boson/third_party 25 | Libs: -L${libdir} -lboson 26 | -------------------------------------------------------------------------------- /src/boson/config/postlude.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2016 MongoDB Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // src/boson/config/compiler.hpp 16 | #undef BOSON_INLINE 17 | #pragma pop_macro("BOSON_INLINE") 18 | #if defined(_MSC_VER) 19 | #pragma warning(pop) 20 | #endif 21 | #undef BOSON_CALL 22 | #pragma pop_macro("BOSON_CALL") 23 | 24 | // src/boson/config/config.hpp.in 25 | #undef BOSON_INLINE_NAMESPACE_BEGIN 26 | #pragma pop_macro("BOSON_INLINE_NAMESPACE_BEGIN") 27 | #undef BOSON_INLINE_NAMESPACE_END 28 | #pragma pop_macro("BOSON_INLINE_NAMESPACE_END") 29 | #undef BOSON_POLY_USE_MNMLSTC 30 | #pragma pop_macro("BOSON_POLY_USE_MNMLSTC") 31 | #undef BOSON_POLY_USE_STD_EXPERIMENTAL 32 | #pragma pop_macro("BOSON_POLY_USE_STD_EXPERIMENTAL") 33 | #undef BOSON_POLY_USE_SYSTEM_MNMLSTC 34 | #pragma pop_macro("BOSON_POLY_USE_SYSTEM_MNMLSTC") 35 | #undef BOSON_POLY_USE_BOOST 36 | #pragma pop_macro("BOSON_POLY_USE_BOOST") 37 | 38 | // src/boson/config/version.hpp.in 39 | #undef BOSON_VERSION_EXTRA 40 | #pragma pop_macro("BOSON_VERSION_EXTRA") 41 | #undef BOSON_VERSION_MAJOR 42 | #pragma pop_macro("BOSON_VERSION_MAJOR") 43 | #undef BOSON_VERSION_MINOR 44 | #pragma pop_macro("BOSON_VERSION_MINOR") 45 | #undef BOSON_VERSION_PATCH 46 | #pragma pop_macro("BOSON_VERSION_PATCH") 47 | 48 | // export.hpp (generated by cmake) 49 | #undef BOSON_API_H 50 | #pragma pop_macro("BOSON_API_H") 51 | #undef BOSON_API 52 | #pragma pop_macro("BOSON_API") 53 | #undef BOSON_PRIVATE 54 | #pragma pop_macro("BOSON_PRIVATE") 55 | #undef BOSON_DEPRECATED 56 | #pragma pop_macro("BOSON_DEPRECATED") 57 | #undef BOSON_DEPRECATED_EXPORT 58 | #pragma pop_macro("BOSON_DEPRECATED_EXPORT") 59 | #undef BOSON_DEPRECATED_NO_EXPORT 60 | #pragma pop_macro("BOSON_DEPRECATED_NO_EXPORT") 61 | #undef DEFINE_NO_DEPRECATED 62 | #pragma pop_macro("DEFINE_NO_DEPRECATED") 63 | #undef BOSON_NO_DEPRECATED 64 | #pragma pop_macro("BOSON_NO_DEPRECATED") 65 | 66 | // prelude.hpp 67 | #undef BOSON_UNREACHABLE 68 | #pragma pop_macro("BOSON_UNREACHABLE") 69 | -------------------------------------------------------------------------------- /src/boson/config/prelude.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2016 MongoDB Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // src/boson/config/compiler.hpp 16 | #pragma push_macro("BOSON_INLINE") 17 | #undef BOSON_INLINE 18 | #pragma push_macro("BOSON_CALL") 19 | #undef BOSON_CALL 20 | 21 | // src/boson/config/config.hpp.in 22 | #pragma push_macro("BOSON_INLINE_NAMESPACE_BEGIN") 23 | #undef BOSON_INLINE_NAMESPACE_BEGIN 24 | #pragma push_macro("BOSON_INLINE_NAMESPACE_END") 25 | #undef BOSON_INLINE_NAMESPACE_END 26 | #pragma push_macro("BOSON_POLY_USE_MNMLSTC") 27 | #undef BOSON_POLY_USE_MNMLSTC 28 | #pragma push_macro("BOSON_POLY_USE_STD_EXPERIMENTAL") 29 | #undef BOSON_POLY_USE_STD_EXPERIMENTAL 30 | #pragma push_macro("BOSON_POLY_USE_SYSTEM_MNMLSTC") 31 | #undef BOSON_POLY_USE_SYSTEM_MNMLSTC 32 | #pragma push_macro("BOSON_POLY_USE_BOOST") 33 | #undef BOSON_POLY_USE_BOOST 34 | 35 | // src/boson/config/version.hpp.in 36 | #pragma push_macro("BOSON_VERSION_EXTRA") 37 | #undef BOSON_VERSION_EXTRA 38 | #pragma push_macro("BOSON_VERSION_MAJOR") 39 | #undef BOSON_VERSION_MAJOR 40 | #pragma push_macro("BOSON_VERSION_MINOR") 41 | #undef BOSON_VERSION_MINOR 42 | #pragma push_macro("BOSON_VERSION_PATCH") 43 | #undef BOSON_VERSION_PATCH 44 | 45 | // export.hpp (generated by cmake) 46 | #pragma push_macro("BOSON_API_H") 47 | #undef BOSON_API_H 48 | #pragma push_macro("BOSON_API") 49 | #undef BOSON_API 50 | #pragma push_macro("BOSON_PRIVATE") 51 | #undef BOSON_PRIVATE 52 | #pragma push_macro("BOSON_DEPRECATED") 53 | #undef BOSON_DEPRECATED 54 | #pragma push_macro("BOSON_DEPRECATED_EXPORT") 55 | #undef BOSON_DEPRECATED_EXPORT 56 | #pragma push_macro("BOSON_DEPRECATED_NO_EXPORT") 57 | #undef BOSON_DEPRECATED_NO_EXPORT 58 | #pragma push_macro("DEFINE_NO_DEPRECATED") 59 | #undef DEFINE_NO_DEPRECATED 60 | #pragma push_macro("BOSON_NO_DEPRECATED") 61 | #undef BOSON_NO_DEPRECATED 62 | 63 | #include 64 | #include 65 | #include 66 | #include 67 | 68 | #pragma push_macro("BOSON_UNREACHABLE") 69 | #undef BOSON_UNREACHABLE 70 | #define BOSON_UNREACHABLE std::abort() 71 | -------------------------------------------------------------------------------- /src/boson/config/version.hpp.in: -------------------------------------------------------------------------------- 1 | // Copyright 2016 MongoDB Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #define BOSON_VERSION_MAJOR @BOSON_VERSION_MAJOR@ 16 | #define BOSON_VERSION_MINOR @BOSON_VERSION_MINOR@ 17 | #define BOSON_VERSION_PATCH @BOSON_VERSION_PATCH@ 18 | #define BOSON_VERSION_EXTRA @BOSON_VERSION_EXTRA@ 19 | -------------------------------------------------------------------------------- /src/boson/stdx/optional.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2016 MongoDB Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #pragma once 16 | 17 | #include 18 | 19 | namespace boson { 20 | namespace stdx { 21 | 22 | using bsoncxx::stdx::optional; 23 | using bsoncxx::stdx::nullopt; 24 | using bsoncxx::stdx::make_optional; 25 | } // namespace stdx 26 | } // namespace boson 27 | -------------------------------------------------------------------------------- /src/boson/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2016 MongoDB Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | include_directories( 16 | ${CMAKE_SOURCE_DIR}/src/third_party/catch/include 17 | ) 18 | 19 | add_executable(test_boson 20 | archiver_test.cpp 21 | bson_streambuf.cpp 22 | main.cpp 23 | mapping_functions.cpp 24 | stdx_optional_archiver_test.cpp 25 | ) 26 | 27 | target_link_libraries(test_boson boson_static) 28 | add_test(boson test_boson) 29 | -------------------------------------------------------------------------------- /src/boson/test/main.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2016 MongoDB Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #define CATCH_CONFIG_RUNNER 16 | #include "catch.hpp" 17 | 18 | int main(int argc, char** argv) { 19 | int result = Catch::Session().run(argc, argv); 20 | return result; 21 | } 22 | -------------------------------------------------------------------------------- /src/boson/test/mapping_functions.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2016 MongoDB Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "catch.hpp" 16 | 17 | #include 18 | 19 | #include 20 | 21 | using namespace boson; 22 | using namespace bsoncxx; 23 | 24 | class Foo { 25 | public: 26 | int a, b, c; 27 | 28 | bool operator==(const Foo& rhs) { 29 | return (a == rhs.a) && (b == rhs.b) && (c == rhs.c); 30 | } 31 | 32 | template 33 | void serialize(Archive& ar) { 34 | ar(CEREAL_NVP(a), CEREAL_NVP(b), CEREAL_NVP(c)); 35 | } 36 | }; 37 | 38 | // set up test BSON documents and objects 39 | std::string json_str = R"({"a": 1, "b":4, "c": 9})"; 40 | auto doc = from_json(json_str); 41 | auto doc_view = doc.view(); 42 | 43 | std::string json_str_2 = R"({"a": 1, "b":4, "c": 900})"; 44 | auto doc_2 = from_json(json_str_2); 45 | auto doc_2_view = doc_2.view(); 46 | 47 | Foo obj{1, 4, 9}; 48 | 49 | TEST_CASE("Function to_document can faithfully convert objects to BSON documents.", 50 | "[mangrove::to_document]") { 51 | document::value val = to_document(obj); 52 | auto v = val.view(); 53 | 54 | REQUIRE(v["a"].get_int32() == obj.a); 55 | REQUIRE(v["b"].get_int32() == obj.b); 56 | REQUIRE(v["c"].get_int32() == obj.c); 57 | } 58 | 59 | TEST_CASE("Function to_obj can faithfully convert documents to objects.", "[mangrove::to_obj]") { 60 | // Test return-by-value 61 | Foo obj1 = to_obj(doc_view); 62 | // Test fill-by-reference 63 | Foo obj2; 64 | to_obj(doc_view, obj2); 65 | 66 | REQUIRE(doc_view["a"].get_int32() == obj1.a); 67 | REQUIRE(doc_view["b"].get_int32() == obj1.b); 68 | REQUIRE(doc_view["c"].get_int32() == obj1.c); 69 | // 70 | REQUIRE(doc_view["a"].get_int32() == obj2.a); 71 | REQUIRE(doc_view["b"].get_int32() == obj2.b); 72 | REQUIRE(doc_view["c"].get_int32() == obj2.c); 73 | } 74 | 75 | TEST_CASE("Function to_optional_obj can convert optional documents to optional objects.", 76 | "[mangrove::to_optional_obj]") { 77 | auto empty_optional = bsoncxx::stdx::optional(); 78 | bsoncxx::stdx::optional should_be_empty = to_optional_obj(empty_optional); 79 | 80 | REQUIRE(!should_be_empty); 81 | 82 | auto should_be_filled = to_optional_obj(bsoncxx::stdx::optional(doc)); 83 | REQUIRE(should_be_filled); 84 | if (should_be_filled) { 85 | } 86 | REQUIRE(doc_view["a"].get_int32() == should_be_filled->a); 87 | REQUIRE(doc_view["b"].get_int32() == should_be_filled->b); 88 | REQUIRE(doc_view["c"].get_int32() == should_be_filled->c); 89 | } 90 | -------------------------------------------------------------------------------- /src/mangrove/.gitignore: -------------------------------------------------------------------------------- 1 | mangrove_child_autogen.hpp 2 | -------------------------------------------------------------------------------- /src/mangrove/cmake/libmangrove-config.cmake.in: -------------------------------------------------------------------------------- 1 | # Copyright 2016 MongoDB Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | set(LIBMANGROVE_VERSION_MAJOR @MANGROVE_VERSION_MAJOR@) 16 | set(LIBMANGROVE_VERSION_MINOR @MANGROVE_VERSION_MINOR@) 17 | set(LIBMANGROVE_VERSION_PATCH @MANGROVE_VERSION_PATCH@) 18 | set(LIBMANGROVE_PACKAGE_VERSION @MANGROVE_VERSION@) 19 | set(LIBMANGROVE_LIBRARIES mangrove) 20 | 21 | @PACKAGE_INIT@ 22 | 23 | set_and_check(LIBMANGROVE_INCLUDE_DIRS "${PACKAGE_PREFIX_DIR}/@PACKAGE_INCLUDE_INSTALL_DIRS@") 24 | set_and_check(LIBMANGROVE_LIBRARY_DIRS "${PACKAGE_PREFIX_DIR}/@PACKAGE_LIBRARY_INSTALL_DIRS@") 25 | 26 | -------------------------------------------------------------------------------- /src/mangrove/collection_wrapper.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2016 MongoDB Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "collection_wrapper.hpp" 16 | -------------------------------------------------------------------------------- /src/mangrove/config/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2016 MongoDB Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | configure_file( 16 | ${CMAKE_CURRENT_SOURCE_DIR}/config.hpp.in 17 | ${CMAKE_CURRENT_BINARY_DIR}/config.hpp 18 | ) 19 | 20 | configure_file( 21 | ${CMAKE_CURRENT_SOURCE_DIR}/version.hpp.in 22 | ${CMAKE_CURRENT_BINARY_DIR}/version.hpp 23 | ) 24 | 25 | install(FILES 26 | ${CMAKE_CURRENT_BINARY_DIR}/config.hpp 27 | ${CMAKE_CURRENT_BINARY_DIR}/version.hpp 28 | DESTINATION ${MANGROVE_HEADER_INSTALL_DIR}/mangrove/config 29 | COMPONENT dev 30 | ) 31 | 32 | configure_file( 33 | ${CMAKE_CURRENT_SOURCE_DIR}/libmangrove.pc.in 34 | ${CMAKE_CURRENT_BINARY_DIR}/libmangrove.pc 35 | @ONLY 36 | ) 37 | 38 | install(FILES 39 | "${CMAKE_CURRENT_BINARY_DIR}/libmangrove.pc" 40 | DESTINATION lib/pkgconfig 41 | COMPONENT dev 42 | ) 43 | -------------------------------------------------------------------------------- /src/mangrove/config/compiler.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2016 MongoDB Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #if defined(_MSC_VER) 16 | 17 | // Disable MSVC warnings that cause a lot of noise related to DLL visibility 18 | // for types that we don't control (like std::unique_ptr). 19 | #pragma warning(push) 20 | #pragma warning(disable : 4251 4275) 21 | 22 | #define MANGROVE_INLINE inline __forceinline MANGROVE_PRIVATE 23 | 24 | #define MANGROVE_CALL __cdecl 25 | 26 | #else 27 | 28 | #define MANGROVE_INLINE inline __attribute__((__always_inline__)) MANGROVE_PRIVATE 29 | 30 | #define MANGROVE_CALL 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /src/mangrove/config/config.hpp.in: -------------------------------------------------------------------------------- 1 | // Copyright 2016 MongoDB Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #define MANGROVE_INLINE_NAMESPACE_BEGIN inline namespace @MANGROVE_INLINE_NAMESPACE@ { 16 | 17 | #define MANGROVE_INLINE_NAMESPACE_END } // namespace @MANGROVE_INLINE_NAMESPACE@ 18 | -------------------------------------------------------------------------------- /src/mangrove/config/libmangrove.pc.in: -------------------------------------------------------------------------------- 1 | # Copyright 2016 MongoDB Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | prefix=@CMAKE_INSTALL_PREFIX@ 16 | includedir=${prefix}/include 17 | libdir=${prefix}/lib 18 | 19 | Name: libmangrove 20 | Description: Mangrove: MongoDB C++14 ODM Library 21 | URL: http://github.com/mongodb-labs/mangrove 22 | Version: @MANGROVE_VERSION@ 23 | Requires.private: libbsoncxx >= @LIBBSONCXX_REQUIRED_VERSION@ 24 | Cflags: -I${includedir}/mangrove/@MANGROVE_INLINE_NAMESPACE@ 25 | Libs: -L${libdir} -lmangrove 26 | -------------------------------------------------------------------------------- /src/mangrove/config/postlude.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2016 MongoDB Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // src/mangrove/config/compiler.hpp 16 | #undef MANGROVE_INLINE 17 | #pragma pop_macro("MANGROVE_INLINE") 18 | #if defined(_MSC_VER) 19 | #pragma warning(pop) 20 | #endif 21 | #undef MANGROVE_CALL 22 | #pragma pop_macro("MANGROVE_CALL") 23 | 24 | // src/mangrove/config/config.hpp.in 25 | #undef MANGROVE_INLINE_NAMESPACE_BEGIN 26 | #pragma pop_macro("MANGROVE_INLINE_NAMESPACE_BEGIN") 27 | #undef MANGROVE_INLINE_NAMESPACE_END 28 | #pragma pop_macro("MANGROVE_INLINE_NAMESPACE_END") 29 | 30 | // src/mangrove/config/version.hpp.in 31 | #undef MANGROVE_VERSION_EXTRA 32 | #pragma pop_macro("MANGROVE_VERSION_EXTRA") 33 | #undef MANGROVE_VERSION_MAJOR 34 | #pragma pop_macro("MANGROVE_VERSION_MAJOR") 35 | #undef MANGROVE_VERSION_MINOR 36 | #pragma pop_macro("MANGROVE_VERSION_MINOR") 37 | #undef MANGROVE_VERSION_PATCH 38 | #pragma pop_macro("MANGROVE_VERSION_PATCH") 39 | 40 | // export.hpp (generated by cmake) 41 | #undef MANGROVE_API_H 42 | #pragma pop_macro("MANGROVE_API_H") 43 | #undef MANGROVE_API 44 | #pragma pop_macro("MANGROVE_API") 45 | #undef MANGROVE_PRIVATE 46 | #pragma pop_macro("MANGROVE_PRIVATE") 47 | #undef MANGROVE_DEPRECATED 48 | #pragma pop_macro("MANGROVE_DEPRECATED") 49 | #undef MANGROVE_DEPRECATED_EXPORT 50 | #pragma pop_macro("MANGROVE_DEPRECATED_EXPORT") 51 | #undef MANGROVE_DEPRECATED_NO_EXPORT 52 | #pragma pop_macro("MANGROVE_DEPRECATED_NO_EXPORT") 53 | #undef DEFINE_NO_DEPRECATED 54 | #pragma pop_macro("DEFINE_NO_DEPRECATED") 55 | #undef MANGROVE_NO_DEPRECATED 56 | #pragma pop_macro("MANGROVE_NO_DEPRECATED") 57 | 58 | // prelude.hpp 59 | #undef MANGROVE_UNREACHABLE 60 | #pragma pop_macro("MANGROVE_UNREACHABLE") 61 | -------------------------------------------------------------------------------- /src/mangrove/config/prelude.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2016 MongoDB Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // src/mangrove/config/compiler.hpp 16 | #pragma push_macro("MANGROVE_INLINE") 17 | #undef MANGROVE_INLINE 18 | #pragma push_macro("MANGROVE_CALL") 19 | #undef MANGROVE_CALL 20 | 21 | // src/mangrove/config/config.hpp.in 22 | #pragma push_macro("MANGROVE_INLINE_NAMESPACE_BEGIN") 23 | #undef MANGROVE_INLINE_NAMESPACE_BEGIN 24 | #pragma push_macro("MANGROVE_INLINE_NAMESPACE_END") 25 | #undef MANGROVE_INLINE_NAMESPACE_END 26 | 27 | // src/mangrove/config/version.hpp.in 28 | #pragma push_macro("MANGROVE_VERSION_EXTRA") 29 | #undef MANGROVE_VERSION_EXTRA 30 | #pragma push_macro("MANGROVE_VERSION_MAJOR") 31 | #undef MANGROVE_VERSION_MAJOR 32 | #pragma push_macro("MANGROVE_VERSION_MINOR") 33 | #undef MANGROVE_VERSION_MINOR 34 | #pragma push_macro("MANGROVE_VERSION_PATCH") 35 | #undef MANGROVE_VERSION_PATCH 36 | 37 | // export.hpp (generated by cmake) 38 | #pragma push_macro("MANGROVE_API_H") 39 | #undef MANGROVE_API_H 40 | #pragma push_macro("MANGROVE_API") 41 | #undef MANGROVE_API 42 | #pragma push_macro("MANGROVE_PRIVATE") 43 | #undef MANGROVE_PRIVATE 44 | #pragma push_macro("MANGROVE_DEPRECATED") 45 | #undef MANGROVE_DEPRECATED 46 | #pragma push_macro("MANGROVE_DEPRECATED_EXPORT") 47 | #undef MANGROVE_DEPRECATED_EXPORT 48 | #pragma push_macro("MANGROVE_DEPRECATED_NO_EXPORT") 49 | #undef MANGROVE_DEPRECATED_NO_EXPORT 50 | #pragma push_macro("DEFINE_NO_DEPRECATED") 51 | #undef DEFINE_NO_DEPRECATED 52 | #pragma push_macro("MANGROVE_NO_DEPRECATED") 53 | #undef MANGROVE_NO_DEPRECATED 54 | 55 | #include 56 | #include 57 | #include 58 | #include 59 | 60 | #pragma push_macro("MANGROVE_UNREACHABLE") 61 | #undef MANGROVE_UNREACHABLE 62 | #define MANGROVE_UNREACHABLE std::abort() 63 | -------------------------------------------------------------------------------- /src/mangrove/config/version.hpp.in: -------------------------------------------------------------------------------- 1 | // Copyright 2016 MongoDB Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #define MANGROVE_VERSION_MAJOR @MANGROVE_VERSION_MAJOR@ 16 | #define MANGROVE_VERSION_MINOR @MANGROVE_VERSION_MINOR@ 17 | #define MANGROVE_VERSION_PATCH @MANGROVE_VERSION_PATCH@ 18 | #define MANGROVE_VERSION_EXTRA @MANGROVE_VERSION_EXTRA@ 19 | -------------------------------------------------------------------------------- /src/mangrove/deserializing_cursor.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2016 MongoDB Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #pragma once 16 | 17 | #include 18 | 19 | #include 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | #include 26 | 27 | namespace mangrove { 28 | MANGROVE_INLINE_NAMESPACE_BEGIN 29 | 30 | /** 31 | * A class that wraps a mongocxx::cursor. It provides an iterator that deserializes the 32 | * documents yielded by the underlying mongocxx cursor. 33 | * NOTE: This iterator will skip documents that fail to be deserialized, e.g. due to non-matching 34 | * schemas. 35 | */ 36 | template 37 | class deserializing_cursor { 38 | public: 39 | deserializing_cursor(mongocxx::cursor&& c) : _c(std::move(c)) { 40 | } 41 | 42 | class iterator; 43 | 44 | iterator begin() { 45 | return iterator(_c.begin(), _c.end()); 46 | } 47 | 48 | iterator end() { 49 | return iterator(_c.end(), _c.end()); 50 | } 51 | 52 | private: 53 | mongocxx::cursor _c; 54 | }; 55 | 56 | template 57 | class deserializing_cursor::iterator : public std::iterator { 58 | public: 59 | iterator(mongocxx::cursor::iterator ci, mongocxx::cursor::iterator ci_end) 60 | : _ci(ci), _ci_end(ci_end) { 61 | skip_invalid_documents(); 62 | } 63 | 64 | iterator(const deserializing_cursor::iterator& dsi) : _ci(dsi._ci), _ci_end(dsi._ci_end) { 65 | skip_invalid_documents(); 66 | } 67 | 68 | iterator& operator++() { 69 | ++_ci; 70 | _opt = mongocxx::stdx::nullopt; 71 | skip_invalid_documents(); 72 | return *this; 73 | } 74 | 75 | void operator++(int) { 76 | operator++(); 77 | } 78 | 79 | bool operator==(const iterator& rhs) { 80 | return _ci == rhs._ci; 81 | } 82 | 83 | bool operator!=(const iterator& rhs) { 84 | return _ci != rhs._ci; 85 | } 86 | 87 | /** 88 | * Returns a deserialized object that corresponds to the current document pointed to by the 89 | * underlying collection cursor iterator. 90 | */ 91 | T operator*() { 92 | return _opt.value(); 93 | } 94 | 95 | private: 96 | mongocxx::cursor::iterator _ci; 97 | // Keeps track of the end of the underlying cursor to enable skipping invalid documents. 98 | mongocxx::cursor::iterator _ci_end; 99 | // Cached object value. When this is non-empty, this always contains the current object pointed 100 | // to by the cursor. 101 | mongocxx::stdx::optional _opt; 102 | 103 | /** 104 | * Iterates over documents, and skips documents that cannot be properly deserialized into an 105 | * object. 106 | * This stop when a valid document is found, or when the end of the underlying cursor is 107 | * reached. 108 | * When a document is successfully converted, it is cached in _opt and used later when 109 | * dereferencing. 110 | */ 111 | void skip_invalid_documents() { 112 | while (_ci != _ci_end) { 113 | try { 114 | if (!_opt) { 115 | _opt = boson::to_obj(*_ci); 116 | } 117 | return; 118 | } catch (boson::Exception& e) { 119 | ++_ci; 120 | _opt = mongocxx::stdx::nullopt; 121 | } 122 | } 123 | } 124 | }; 125 | 126 | MANGROVE_INLINE_NAMESPACE_END 127 | } // namespace boson 128 | 129 | #include 130 | -------------------------------------------------------------------------------- /src/mangrove/macros.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2016 MongoDB Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #pragma once 16 | 17 | #include 18 | 19 | #define MANGROVE_PASTE_IMPL(s1, s2) s1##s2 20 | #define MANGROVE_PASTE(s1, s2) MANGROVE_PASTE_IMPL(s1, s2) 21 | 22 | // Wrap a field name to create a corresponding NVP 23 | #define MANGROVE_NVP(x) mangrove::make_nvp(&mangrove_wrap_base::x, #x) 24 | 25 | // Macro for creating custom field name 26 | #define MANGROVE_CUSTOM_NVP(x, name) mangrove::make_nvp(&mangrove_wrap_base::x, name) 27 | 28 | // Creates serialize() function 29 | #define MANGROVE_SERIALIZE_KEYS \ 30 | template \ 31 | void serialize(Archive& ar) { \ 32 | mangrove_serialize_recur::value>(ar); \ 34 | } \ 35 | template \ 36 | std::enable_if_t<(I < N), void> mangrove_serialize_recur(Archive& ar) { \ 37 | auto nvp = std::get(mangrove_mapped_fields()); \ 38 | ar(cereal::make_nvp(nvp.name, this->*(nvp.t))); \ 39 | mangrove_serialize_recur(ar); \ 40 | } \ 41 | \ 42 | template \ 43 | std::enable_if_t<(I == N), void> mangrove_serialize_recur(Archive&) { \ 44 | ; \ 45 | } 46 | 47 | // Register members and create serialize() function 48 | #define MANGROVE_MAKE_KEYS(Base, ...) \ 49 | using mangrove_wrap_base = Base; \ 50 | constexpr static auto mangrove_mapped_fields() { \ 51 | return std::make_tuple(__VA_ARGS__); \ 52 | } \ 53 | MANGROVE_SERIALIZE_KEYS 54 | 55 | // If using the mangrove::model, then also register _id as a field. 56 | #define MANGROVE_MAKE_KEYS_MODEL(Base, ...) MANGROVE_MAKE_KEYS(Base, MANGROVE_NVP(_id), __VA_ARGS__) 57 | 58 | #define MANGROVE_KEY(value) mangrove::hasCallIfFieldIsPresent::call() 59 | // convenience macro for accessing scalar elements of array fields in query builder. 60 | #define MANGROVE_ELEM(value) MANGROVE_KEY(value).element() 61 | 62 | #define MANGROVE_KEY_BY_VALUE(value) \ 63 | mangrove::hasCallIfFieldIsPresent::call() 64 | 65 | // MANGROVE_CHILD* macros, autogenerated to 100 levels (maximum BSON depth) 66 | #include 67 | 68 | #define MANGROVE_CHILD(type, ...) \ 69 | MANGROVE_PASTE(MANGROVE_CHILD, MANGROVE_PP_NARG(__VA_ARGS__))(type, __VA_ARGS__) 70 | 71 | #define MANGROVE_CHILD_ELEM(...) MANGROVE_CHILD(__VA_ARGS__).element() 72 | 73 | #include 74 | -------------------------------------------------------------------------------- /src/mangrove/model.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2016 MongoDB Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "model.hpp" 16 | -------------------------------------------------------------------------------- /src/mangrove/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2016 MongoDB Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | include_directories( 16 | ${CMAKE_SOURCE_DIR}/src/third_party/catch/include 17 | ) 18 | 19 | add_executable(test_mangrove 20 | main.cpp 21 | model.cpp 22 | collection_wrapper.cpp 23 | deserializing_cursor.cpp 24 | query_builder.cpp 25 | util.cpp 26 | ) 27 | 28 | target_link_libraries(test_mangrove mangrove_static) 29 | add_test(mangrove test_mangrove) 30 | -------------------------------------------------------------------------------- /src/mangrove/test/deserializing_cursor.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2016 MongoDB Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "catch.hpp" 16 | 17 | #include 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | #include 26 | #include 27 | 28 | using namespace bsoncxx; 29 | using namespace mongocxx; 30 | using namespace mangrove; 31 | 32 | class Foo { 33 | public: 34 | int a, b, c; 35 | 36 | bool operator==(const Foo& rhs) { 37 | return (a == rhs.a) && (b == rhs.b) && (c == rhs.c); 38 | } 39 | 40 | template 41 | void serialize(Archive& ar) { 42 | ar(CEREAL_NVP(a), CEREAL_NVP(b), CEREAL_NVP(c)); 43 | } 44 | }; 45 | 46 | TEST_CASE("Test deserializing cursor", "[mangrove::deserializing_cursor]") { 47 | // set up test BSON documents and objects 48 | std::string json_str = R"({"a": 1, "b":4, "c": 9})"; 49 | auto doc = from_json(json_str); 50 | auto doc_view = doc.view(); 51 | 52 | std::string json_str_2 = R"({"a": 1, "b":4, "c": 900})"; 53 | auto doc_2 = from_json(json_str_2); 54 | auto doc_2_view = doc_2.view(); 55 | 56 | Foo obj{1, 4, 9}; 57 | 58 | instance::current(); 59 | client conn{uri{}}; 60 | collection coll = conn["testdb"]["testcollection"]; 61 | collection_wrapper foo_coll(coll); 62 | 63 | SECTION("Deserializing cursor automatically converts documents from cursors to objects.", 64 | "[mangrove::deserializing_cursor]") { 65 | coll.delete_many({}); 66 | 67 | for (int i = 0; i < 5; i++) { 68 | coll.insert_one(doc_view); 69 | coll.insert_one(doc_2_view); 70 | } 71 | 72 | deserializing_cursor cur = foo_coll.find(from_json(R"({"c": {"$gt": 100}})")); 73 | int i = 0; 74 | for (Foo f : cur) { 75 | REQUIRE(f.c > 100); 76 | i++; 77 | } 78 | REQUIRE(i == 5); 79 | } 80 | 81 | SECTION("Deserializing cursor skips invalid documents.", "[mangrove::deserializing_cursor]") { 82 | coll.delete_many({}); 83 | // populate collection with documents, some of which don't match the Foo's schema 84 | // Also specify id's so that we can have invalid documents at the end and beginning 85 | // of the iterator, for testing. 86 | coll.insert_one(from_json(R"({"_id": 1, "c": 900})")); 87 | coll.insert_one(from_json(R"({"_id": 2, "a": 100, "b": 200, "c": 900})")); 88 | coll.insert_one(from_json(R"({"_id": 3, "a": 100, "b": 200, "c": 900})")); 89 | coll.insert_one(from_json(R"({"_id": 4, "c": 900})")); 90 | coll.insert_one(from_json(R"({"_id": 5, "c": 900})")); 91 | coll.insert_one(from_json(R"({"_id": 6, "a": 100, "b": 200, "c": 900})")); 92 | coll.insert_one(from_json(R"({"_id": 7, "a": 100, "b": 200, "c": 900})")); 93 | coll.insert_one(from_json(R"({"_id": 8, "c": 900})")); 94 | 95 | // set up sort options. 96 | mongocxx::options::find opts; 97 | opts.sort(from_json(R"({"_id": 1})")); 98 | 99 | auto filter = from_json(R"({"c": {"$gt": 100}})"); 100 | deserializing_cursor cur = foo_coll.find(filter.view(), opts); 101 | int i = 0; 102 | for (Foo f : cur) { 103 | REQUIRE(f.c > 100); 104 | i++; 105 | } 106 | REQUIRE(i == 4); 107 | } 108 | 109 | coll.delete_many({}); 110 | } 111 | -------------------------------------------------------------------------------- /src/mangrove/test/main.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2016 MongoDB Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #define CATCH_CONFIG_RUNNER 16 | #include "catch.hpp" 17 | 18 | int main(int argc, char** argv) { 19 | int result = Catch::Session().run(argc, argv); 20 | return result; 21 | } 22 | -------------------------------------------------------------------------------- /src/third_party/catch/main.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2016 MongoDB Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #define CATCH_CONFIG_MAIN 16 | #include "catch.hpp" 17 | -------------------------------------------------------------------------------- /src/third_party/cereal/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014, 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 cereal 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 RANDOLPH VOORHIES OR SHANE GRANT 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 | -------------------------------------------------------------------------------- /src/third_party/cereal/include/cereal/details/static_object.hpp: -------------------------------------------------------------------------------- 1 | /*! \file static_object.hpp 2 | \brief Internal polymorphism static object support 3 | \ingroup Internal */ 4 | /* 5 | Copyright (c) 2014, Randolph Voorhies, Shane Grant 6 | All rights reserved. 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | * Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | * Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | * Neither the name of cereal nor the 15 | names of its contributors may be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL RANDOLPH VOORHIES OR SHANE GRANT BE LIABLE FOR ANY 21 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | #ifndef CEREAL_DETAILS_STATIC_OBJECT_HPP_ 29 | #define CEREAL_DETAILS_STATIC_OBJECT_HPP_ 30 | 31 | //! Prevent link optimization from removing non-referenced static objects 32 | /*! Especially for polymorphic support, we create static objects which 33 | may not ever be explicitly referenced. Most linkers will detect this 34 | and remove the code causing various unpleasant runtime errors. These 35 | macros, adopted from Boost (see force_include.hpp) prevent this 36 | (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . 37 | Use, modification and distribution is subject to the Boost Software 38 | License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at 39 | http://www.boost.org/LICENSE_1_0.txt) */ 40 | 41 | #ifdef _MSC_VER 42 | # define CEREAL_DLL_EXPORT __declspec(dllexport) 43 | # define CEREAL_USED 44 | #else // clang or gcc 45 | # define CEREAL_DLL_EXPORT 46 | # define CEREAL_USED __attribute__ ((__used__)) 47 | #endif 48 | 49 | namespace cereal 50 | { 51 | namespace detail 52 | { 53 | //! A static, pre-execution object 54 | /*! This class will create a single copy (singleton) of some 55 | type and ensures that merely referencing this type will 56 | cause it to be instantiated and initialized pre-execution. 57 | For example, this is used heavily in the polymorphic pointer 58 | serialization mechanisms to bind various archive types with 59 | different polymorphic classes */ 60 | template 61 | class CEREAL_DLL_EXPORT StaticObject 62 | { 63 | private: 64 | //! Forces instantiation at pre-execution time 65 | static void instantiate( T const & ) {} 66 | 67 | static T & create() 68 | { 69 | static T t; 70 | instantiate(instance); 71 | return t; 72 | } 73 | 74 | StaticObject( StaticObject const & /*other*/ ) {} 75 | 76 | public: 77 | static T & getInstance() 78 | { 79 | return create(); 80 | } 81 | 82 | private: 83 | static T & instance; 84 | }; 85 | 86 | template T & StaticObject::instance = StaticObject::create(); 87 | } // namespace detail 88 | } // namespace cereal 89 | 90 | #endif // CEREAL_DETAILS_STATIC_OBJECT_HPP_ -------------------------------------------------------------------------------- /src/third_party/cereal/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 cereal 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 RANDOLPH VOORHIES OR SHANE GRANT 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 | -------------------------------------------------------------------------------- /src/third_party/cereal/include/cereal/external/rapidjson/filestream.h: -------------------------------------------------------------------------------- 1 | #ifndef RAPIDJSON_FILESTREAM_H_ 2 | #define RAPIDJSON_FILESTREAM_H_ 3 | 4 | #include 5 | 6 | namespace rapidjson { 7 | 8 | //! Wrapper of C file stream for input or output. 9 | /*! 10 | This simple wrapper does not check the validity of the stream. 11 | \implements Stream 12 | */ 13 | class FileStream { 14 | public: 15 | typedef char Ch; //!< Character type. Only support char. 16 | 17 | FileStream(FILE* fp) : fp_(fp), count_(0) { Read(); } 18 | 19 | char Peek() const { return current_; } 20 | char Take() { char c = current_; Read(); return c; } 21 | size_t Tell() const { return count_; } 22 | void Put(char c) { fputc(c, fp_); } 23 | 24 | // Not implemented 25 | char* PutBegin() { return 0; } 26 | size_t PutEnd(char*) { return 0; } 27 | 28 | private: 29 | void Read() { 30 | RAPIDJSON_ASSERT(fp_ != 0); 31 | int c = fgetc(fp_); 32 | if (c != EOF) { 33 | current_ = (char)c; 34 | count_++; 35 | } 36 | else 37 | current_ = '\0'; 38 | } 39 | 40 | FILE* fp_; 41 | char current_; 42 | size_t count_; 43 | }; 44 | 45 | } // namespace rapidjson 46 | 47 | #endif // RAPIDJSON_FILESTREAM_H_ 48 | -------------------------------------------------------------------------------- /src/third_party/cereal/include/cereal/external/rapidjson/genericstream.h: -------------------------------------------------------------------------------- 1 | // Generic*Stream code from https://code.google.com/p/rapidjson/issues/detail?id=20 2 | #ifndef RAPIDJSON_GENERICSTREAM_H_ 3 | #define RAPIDJSON_GENERICSTREAM_H_ 4 | 5 | #include "rapidjson.h" 6 | #include 7 | 8 | #ifdef _MSC_VER 9 | #pragma warning(push) 10 | #pragma warning(disable: 4127) // conditional expression is constant 11 | #pragma warning(disable: 4512) // assignment operator could not be generated 12 | #pragma warning(disable: 4100) // unreferenced formal parameter 13 | #endif 14 | 15 | namespace rapidjson { 16 | 17 | //! Wrapper of std::istream for input. 18 | class GenericReadStream { 19 | public: 20 | typedef char Ch; //!< Character type (byte). 21 | 22 | //! Constructor. 23 | /*! 24 | \param is Input stream. 25 | */ 26 | GenericReadStream(std::istream & is) : is_(&is) { 27 | } 28 | 29 | 30 | Ch Peek() const { 31 | if(is_->eof()) return '\0'; 32 | return static_cast(is_->peek()); 33 | } 34 | 35 | Ch Take() { 36 | if(is_->eof()) return '\0'; 37 | return static_cast(is_->get()); 38 | } 39 | 40 | size_t Tell() const { 41 | return (int)is_->tellg(); 42 | } 43 | 44 | // Not implemented 45 | void Put(Ch) { RAPIDJSON_ASSERT(false); } 46 | void Flush() { RAPIDJSON_ASSERT(false); } 47 | Ch* PutBegin() { RAPIDJSON_ASSERT(false); return 0; } 48 | size_t PutEnd(Ch*) { RAPIDJSON_ASSERT(false); return 0; } 49 | 50 | std::istream * is_; 51 | }; 52 | 53 | 54 | //! Wrapper of std::ostream for output. 55 | class GenericWriteStream { 56 | public: 57 | typedef char Ch; //!< Character type. Only support char. 58 | 59 | //! Constructor 60 | /*! 61 | \param os Output stream. 62 | */ 63 | GenericWriteStream(std::ostream& os) : os_(os) { 64 | } 65 | 66 | void Put(char c) { 67 | os_.put(c); 68 | } 69 | 70 | void PutN(char c, size_t n) { 71 | for (size_t i = 0; i < n; ++i) { 72 | Put(c); 73 | } 74 | } 75 | 76 | void Flush() { 77 | os_.flush(); 78 | } 79 | 80 | size_t Tell() const { 81 | return (int)os_.tellp(); 82 | } 83 | 84 | // Not implemented 85 | char Peek() const { RAPIDJSON_ASSERT(false); } 86 | char Take() { RAPIDJSON_ASSERT(false); } 87 | char* PutBegin() { RAPIDJSON_ASSERT(false); return 0; } 88 | size_t PutEnd(char*) { RAPIDJSON_ASSERT(false); return 0; } 89 | 90 | private: 91 | std::ostream& os_; 92 | }; 93 | 94 | template<> 95 | inline void PutN(GenericWriteStream& stream, char c, size_t n) { 96 | stream.PutN(c, n); 97 | } 98 | 99 | } // namespace rapidjson 100 | 101 | // On MSVC, restore warnings state 102 | #ifdef _MSC_VER 103 | #pragma warning(pop) 104 | #endif 105 | #endif // RAPIDJSON_GENERICSTREAM_H_ 106 | -------------------------------------------------------------------------------- /src/third_party/cereal/include/cereal/external/rapidjson/internal/stack.h: -------------------------------------------------------------------------------- 1 | #ifndef RAPIDJSON_INTERNAL_STACK_H_ 2 | #define RAPIDJSON_INTERNAL_STACK_H_ 3 | 4 | namespace rapidjson { 5 | namespace internal { 6 | 7 | /////////////////////////////////////////////////////////////////////////////// 8 | // Stack 9 | 10 | //! A type-unsafe stack for storing different types of data. 11 | /*! \tparam Allocator Allocator for allocating stack memory. 12 | */ 13 | template 14 | class Stack { 15 | public: 16 | Stack(Allocator* allocator, size_t stack_capacity) : allocator_(allocator), own_allocator_(0), stack_(0), stack_top_(0), stack_end_(0), stack_capacity_(stack_capacity) { 17 | RAPIDJSON_ASSERT(stack_capacity_ > 0); 18 | if (!allocator_) 19 | own_allocator_ = allocator_ = new Allocator(); 20 | stack_top_ = stack_ = (char*)allocator_->Malloc(stack_capacity_); 21 | stack_end_ = stack_ + stack_capacity_; 22 | } 23 | 24 | ~Stack() { 25 | Allocator::Free(stack_); 26 | delete own_allocator_; // Only delete if it is owned by the stack 27 | } 28 | 29 | void Clear() { /*stack_top_ = 0;*/ stack_top_ = stack_; } 30 | 31 | template 32 | T* Push(size_t count = 1) { 33 | // Expand the stack if needed 34 | if (stack_top_ + sizeof(T) * count >= stack_end_) { 35 | size_t new_capacity = stack_capacity_ * 2; 36 | size_t size = GetSize(); 37 | size_t new_size = GetSize() + sizeof(T) * count; 38 | if (new_capacity < new_size) 39 | new_capacity = new_size; 40 | stack_ = (char*)allocator_->Realloc(stack_, stack_capacity_, new_capacity); 41 | stack_capacity_ = new_capacity; 42 | stack_top_ = stack_ + size; 43 | stack_end_ = stack_ + stack_capacity_; 44 | } 45 | T* ret = (T*)stack_top_; 46 | stack_top_ += sizeof(T) * count; 47 | return ret; 48 | } 49 | 50 | template 51 | T* Pop(size_t count) { 52 | RAPIDJSON_ASSERT(GetSize() >= count * sizeof(T)); 53 | stack_top_ -= count * sizeof(T); 54 | return (T*)stack_top_; 55 | } 56 | 57 | template 58 | T* Top() { 59 | RAPIDJSON_ASSERT(GetSize() >= sizeof(T)); 60 | return (T*)(stack_top_ - sizeof(T)); 61 | } 62 | 63 | template 64 | T* Bottom() { return (T*)stack_; } 65 | 66 | Allocator& GetAllocator() { return *allocator_; } 67 | size_t GetSize() const { return stack_top_ - stack_; } 68 | size_t GetCapacity() const { return stack_capacity_; } 69 | 70 | private: 71 | Allocator* allocator_; 72 | Allocator* own_allocator_; 73 | char *stack_; 74 | char *stack_top_; 75 | char *stack_end_; 76 | size_t stack_capacity_; 77 | }; 78 | 79 | } // namespace internal 80 | } // namespace rapidjson 81 | 82 | #endif // RAPIDJSON_STACK_H_ 83 | -------------------------------------------------------------------------------- /src/third_party/cereal/include/cereal/external/rapidjson/internal/strfunc.h: -------------------------------------------------------------------------------- 1 | #ifndef RAPIDJSON_INTERNAL_STRFUNC_H_ 2 | #define RAPIDJSON_INTERNAL_STRFUNC_H_ 3 | 4 | namespace rapidjson { 5 | namespace internal { 6 | 7 | //! Custom strlen() which works on different character types. 8 | /*! \tparam Ch Character type (e.g. char, wchar_t, short) 9 | \param s Null-terminated input string. 10 | \return Number of characters in the string. 11 | \note This has the same semantics as strlen(), the return value is not number of Unicode codepoints. 12 | */ 13 | template 14 | inline SizeType StrLen(const Ch* s) { 15 | const Ch* p = s; 16 | while (*p != '\0') 17 | ++p; 18 | return SizeType(p - s); 19 | } 20 | 21 | } // namespace internal 22 | } // namespace rapidjson 23 | 24 | #endif // RAPIDJSON_INTERNAL_STRFUNC_H_ 25 | -------------------------------------------------------------------------------- /src/third_party/cereal/include/cereal/external/rapidjson/license.txt: -------------------------------------------------------------------------------- 1 | Copyright (C) 2011 Milo Yip 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. -------------------------------------------------------------------------------- /src/third_party/cereal/include/cereal/external/rapidjson/stringbuffer.h: -------------------------------------------------------------------------------- 1 | #ifndef RAPIDJSON_STRINGBUFFER_H_ 2 | #define RAPIDJSON_STRINGBUFFER_H_ 3 | 4 | #include "rapidjson.h" 5 | #include "internal/stack.h" 6 | 7 | namespace rapidjson { 8 | 9 | //! Represents an in-memory output stream. 10 | /*! 11 | \tparam Encoding Encoding of the stream. 12 | \tparam Allocator type for allocating memory buffer. 13 | \implements Stream 14 | */ 15 | template 16 | struct GenericStringBuffer { 17 | typedef typename Encoding::Ch Ch; 18 | 19 | GenericStringBuffer(Allocator* allocator = 0, size_t capacity = kDefaultCapacity) : stack_(allocator, capacity) {} 20 | 21 | void Put(Ch c) { *stack_.template Push() = c; } 22 | 23 | void Clear() { stack_.Clear(); } 24 | 25 | const char* GetString() const { 26 | // Push and pop a null terminator. This is safe. 27 | *stack_.template Push() = '\0'; 28 | stack_.template Pop(1); 29 | 30 | return stack_.template Bottom(); 31 | } 32 | 33 | size_t Size() const { return stack_.GetSize(); } 34 | 35 | static const size_t kDefaultCapacity = 256; 36 | mutable internal::Stack stack_; 37 | }; 38 | 39 | typedef GenericStringBuffer > StringBuffer; 40 | 41 | //! Implement specialized version of PutN() with memset() for better performance. 42 | template<> 43 | inline void PutN(GenericStringBuffer >& stream, char c, size_t n) { 44 | memset(stream.stack_.Push(n), c, n * sizeof(c)); 45 | } 46 | 47 | } // namespace rapidjson 48 | 49 | #endif // RAPIDJSON_STRINGBUFFER_H_ 50 | -------------------------------------------------------------------------------- /src/third_party/cereal/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 | -------------------------------------------------------------------------------- /src/third_party/cereal/include/cereal/external/rapidxml/rapidxml_utils.hpp: -------------------------------------------------------------------------------- 1 | #ifndef RAPIDXML_UTILS_HPP_INCLUDED 2 | #define RAPIDXML_UTILS_HPP_INCLUDED 3 | 4 | // Copyright (C) 2006, 2009 Marcin Kalicinski 5 | // Version 1.13 6 | // Revision $DateTime: 2009/05/13 01:46:17 $ 7 | //! in certain simple scenarios. They should probably not be used if maximizing performance is the main objective. 8 | 9 | #include "rapidxml.hpp" 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | namespace rapidxml 16 | { 17 | 18 | //! Represents data loaded from a file 19 | template 20 | class file 21 | { 22 | 23 | public: 24 | 25 | //! Loads file into the memory. Data will be automatically destroyed by the destructor. 26 | //! \param filename Filename to load. 27 | file(const char *filename) 28 | { 29 | using namespace std; 30 | 31 | // Open stream 32 | basic_ifstream stream(filename, ios::binary); 33 | if (!stream) 34 | throw runtime_error(string("cannot open file ") + filename); 35 | stream.unsetf(ios::skipws); 36 | 37 | // Determine stream size 38 | stream.seekg(0, ios::end); 39 | size_t size = stream.tellg(); 40 | stream.seekg(0); 41 | 42 | // Load data and add terminating 0 43 | m_data.resize(size + 1); 44 | stream.read(&m_data.front(), static_cast(size)); 45 | m_data[size] = 0; 46 | } 47 | 48 | //! Loads file into the memory. Data will be automatically destroyed by the destructor 49 | //! \param stream Stream to load from 50 | file(std::basic_istream &stream) 51 | { 52 | using namespace std; 53 | 54 | // Load data and add terminating 0 55 | stream.unsetf(ios::skipws); 56 | m_data.assign(istreambuf_iterator(stream), istreambuf_iterator()); 57 | if (stream.fail() || stream.bad()) 58 | throw runtime_error("error reading stream"); 59 | m_data.push_back(0); 60 | } 61 | 62 | //! Gets file data. 63 | //! \return Pointer to data of file. 64 | Ch *data() 65 | { 66 | return &m_data.front(); 67 | } 68 | 69 | //! Gets file data. 70 | //! \return Pointer to data of file. 71 | const Ch *data() const 72 | { 73 | return &m_data.front(); 74 | } 75 | 76 | //! Gets file data size. 77 | //! \return Size of file data, in characters. 78 | std::size_t size() const 79 | { 80 | return m_data.size(); 81 | } 82 | 83 | private: 84 | 85 | std::vector m_data; // File data 86 | 87 | }; 88 | 89 | //! Counts children of node. Time complexity is O(n). 90 | //! \return Number of children of node 91 | template 92 | inline std::size_t count_children(xml_node *node) 93 | { 94 | xml_node *child = node->first_node(); 95 | std::size_t count = 0; 96 | while (child) 97 | { 98 | ++count; 99 | child = child->next_sibling(); 100 | } 101 | return count; 102 | } 103 | 104 | //! Counts attributes of node. Time complexity is O(n). 105 | //! \return Number of attributes of node 106 | template 107 | inline std::size_t count_attributes(xml_node *node) 108 | { 109 | xml_attribute *attr = node->first_attribute(); 110 | std::size_t count = 0; 111 | while (attr) 112 | { 113 | ++count; 114 | attr = attr->next_attribute(); 115 | } 116 | return count; 117 | } 118 | 119 | } 120 | 121 | #endif 122 | -------------------------------------------------------------------------------- /src/third_party/cereal/include/cereal/macros.hpp: -------------------------------------------------------------------------------- 1 | /*! \file macros.hpp 2 | \brief Preprocessor macros that can customise the cereal library 3 | 4 | By default, cereal looks for serialization functions with very 5 | specific names, that is: serialize, load, save, load_minimal, 6 | or save_minimal. 7 | 8 | This file allows an advanced user to change these names to conform 9 | to some other style or preference. This is implemented using 10 | preprocessor macros. 11 | 12 | As a result of this, in internal cereal code you will see macros 13 | used for these function names. In user code, you should name 14 | the functions like you normally would and not use the macros 15 | to improve readability. 16 | \ingroup utility */ 17 | /* 18 | Copyright (c) 2014, Randolph Voorhies, Shane Grant 19 | All rights reserved. 20 | 21 | Redistribution and use in source and binary forms, with or without 22 | modification, are permitted provided that the following conditions are met: 23 | * Redistributions of source code must retain the above copyright 24 | notice, this list of conditions and the following disclaimer. 25 | * Redistributions in binary form must reproduce the above copyright 26 | notice, this list of conditions and the following disclaimer in the 27 | documentation and/or other materials provided with the distribution. 28 | * Neither the name of cereal nor the 29 | names of its contributors may be used to endorse or promote products 30 | derived from this software without specific prior written permission. 31 | 32 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 33 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 34 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 35 | DISCLAIMED. IN NO EVENT SHALL RANDOLPH VOORHIES OR SHANE GRANT BE LIABLE FOR ANY 36 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 37 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 38 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 39 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 40 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 41 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 42 | */ 43 | 44 | #ifndef CEREAL_MACROS_HPP_ 45 | #define CEREAL_MACROS_HPP_ 46 | 47 | #ifndef CEREAL_SERIALIZE_FUNCTION_NAME 48 | //! The serialization/deserialization function name to search for. 49 | /*! You can define @c CEREAL_SERIALIZE_FUNCTION_NAME to be different assuming 50 | you do so before this file is included. */ 51 | #define CEREAL_SERIALIZE_FUNCTION_NAME serialize 52 | #endif // CEREAL_SERIALIZE_FUNCTION_NAME 53 | 54 | #ifndef CEREAL_LOAD_FUNCTION_NAME 55 | //! The deserialization (load) function name to search for. 56 | /*! You can define @c CEREAL_LOAD_FUNCTION_NAME to be different assuming you do so 57 | before this file is included. */ 58 | #define CEREAL_LOAD_FUNCTION_NAME load 59 | #endif // CEREAL_LOAD_FUNCTION_NAME 60 | 61 | #ifndef CEREAL_SAVE_FUNCTION_NAME 62 | //! The serialization (save) function name to search for. 63 | /*! You can define @c CEREAL_SAVE_FUNCTION_NAME to be different assuming you do so 64 | before this file is included. */ 65 | #define CEREAL_SAVE_FUNCTION_NAME save 66 | #endif // CEREAL_SAVE_FUNCTION_NAME 67 | 68 | #ifndef CEREAL_LOAD_MINIMAL_FUNCTION_NAME 69 | //! The deserialization (load_minimal) function name to search for. 70 | /*! You can define @c CEREAL_LOAD_MINIMAL_FUNCTION_NAME to be different assuming you do so 71 | before this file is included. */ 72 | #define CEREAL_LOAD_MINIMAL_FUNCTION_NAME load_minimal 73 | #endif // CEREAL_LOAD_MINIMAL_FUNCTION_NAME 74 | 75 | #ifndef CEREAL_SAVE_MINIMAL_FUNCTION_NAME 76 | //! The serialization (save_minimal) function name to search for. 77 | /*! You can define @c CEREAL_SAVE_MINIMAL_FUNCTION_NAME to be different assuming you do so 78 | before this file is included. */ 79 | #define CEREAL_SAVE_MINIMAL_FUNCTION_NAME save_minimal 80 | #endif // CEREAL_SAVE_MINIMAL_FUNCTION_NAME 81 | 82 | #endif // CEREAL_MACROS_HPP_ 83 | -------------------------------------------------------------------------------- /src/third_party/cereal/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 cereal 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 RANDOLPH VOORHIES OR SHANE GRANT 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 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(), sizeof(array) ) ); 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(), sizeof(array) ) ); 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 | -------------------------------------------------------------------------------- /src/third_party/cereal/include/cereal/types/bitset.hpp: -------------------------------------------------------------------------------- 1 | /*! \file bitset.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 cereal 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 RANDOLPH VOORHIES OR SHANE GRANT 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_BITSET_HPP_ 31 | #define CEREAL_TYPES_BITSET_HPP_ 32 | 33 | #include 34 | #include 35 | 36 | namespace cereal 37 | { 38 | namespace bitset_detail 39 | { 40 | //! The type the bitset is encoded with 41 | /*! @internal */ 42 | enum class type : uint8_t 43 | { 44 | ulong, 45 | ullong, 46 | string 47 | }; 48 | } 49 | 50 | //! Serializing (save) for std::bitset 51 | template inline 52 | void CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::bitset const & bits ) 53 | { 54 | try 55 | { 56 | auto const b = bits.to_ulong(); 57 | ar( CEREAL_NVP_("type", bitset_detail::type::ulong) ); 58 | ar( CEREAL_NVP_("data", b) ); 59 | } 60 | catch( std::overflow_error const & ) 61 | { 62 | try 63 | { 64 | auto const b = bits.to_ullong(); 65 | ar( CEREAL_NVP_("type", bitset_detail::type::ullong) ); 66 | ar( CEREAL_NVP_("data", b) ); 67 | } 68 | catch( std::overflow_error const & ) 69 | { 70 | ar( CEREAL_NVP_("type", bitset_detail::type::string) ); 71 | ar( CEREAL_NVP_("data", bits.to_string()) ); 72 | } 73 | } 74 | } 75 | 76 | //! Serializing (load) for std::bitset 77 | template inline 78 | void CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::bitset & bits ) 79 | { 80 | bitset_detail::type t; 81 | ar( CEREAL_NVP_("type", t) ); 82 | 83 | switch( t ) 84 | { 85 | case bitset_detail::type::ulong: 86 | { 87 | unsigned long b; 88 | ar( CEREAL_NVP_("data", b) ); 89 | bits = std::bitset( b ); 90 | break; 91 | } 92 | case bitset_detail::type::ullong: 93 | { 94 | unsigned long long b; 95 | ar( CEREAL_NVP_("data", b) ); 96 | bits = std::bitset( b ); 97 | break; 98 | } 99 | case bitset_detail::type::string: 100 | { 101 | std::string b; 102 | ar( CEREAL_NVP_("data", b) ); 103 | bits = std::bitset( b ); 104 | break; 105 | } 106 | default: 107 | throw Exception("Invalid bitset data representation"); 108 | } 109 | } 110 | } // namespace cereal 111 | 112 | #endif // CEREAL_TYPES_BITSET_HPP_ 113 | -------------------------------------------------------------------------------- /src/third_party/cereal/include/cereal/types/boost_variant.hpp: -------------------------------------------------------------------------------- 1 | /*! \file boost_variant.hpp 2 | \brief Support for boost::variant 3 | \ingroup OtherTypes */ 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 cereal 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 RANDOLPH VOORHIES OR SHANE GRANT 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_BOOST_VARIANT_HPP_ 31 | #define CEREAL_TYPES_BOOST_VARIANT_HPP_ 32 | 33 | #include 34 | #include 35 | #include 36 | 37 | namespace cereal 38 | { 39 | namespace variant_detail 40 | { 41 | //! @internal 42 | template 43 | struct variant_save_visitor : boost::static_visitor<> 44 | { 45 | variant_save_visitor(Archive & ar_) : ar(ar_) {} 46 | 47 | template 48 | void operator()(T const & value) const 49 | { 50 | ar( CEREAL_NVP_("data", value) ); 51 | } 52 | 53 | Archive & ar; 54 | }; 55 | 56 | //! @internal 57 | template 58 | typename std::enable_if::value, void>::type 59 | load_variant(Archive & /*ar*/, int /*target*/, Variant & /*variant*/) 60 | { 61 | throw ::cereal::Exception("Error traversing variant during load"); 62 | } 63 | 64 | //! @internal 65 | template 66 | typename std::enable_if::value, void>::type 67 | load_variant(Archive & ar, int target, Variant & variant) 68 | { 69 | if(N == target) 70 | { 71 | H value; 72 | ar( CEREAL_NVP_("data", value) ); 73 | variant = value; 74 | } 75 | else 76 | load_variant(ar, target, variant); 77 | } 78 | 79 | } // namespace variant_detail 80 | 81 | //! Saving for boost::variant 82 | template inline 83 | void CEREAL_SAVE_FUNCTION_NAME( Archive & ar, boost::variant const & variant ) 84 | { 85 | int32_t which = variant.which(); 86 | ar( CEREAL_NVP_("which", which) ); 87 | variant_detail::variant_save_visitor visitor(ar); 88 | variant.apply_visitor(visitor); 89 | } 90 | 91 | //! Loading for boost::variant 92 | template inline 93 | void CEREAL_LOAD_FUNCTION_NAME( Archive & ar, boost::variant & variant ) 94 | { 95 | typedef typename boost::variant::types types; 96 | 97 | int32_t which; 98 | ar( CEREAL_NVP_("which", which) ); 99 | if(which >= boost::mpl::size::value) 100 | throw Exception("Invalid 'which' selector when deserializing boost::variant"); 101 | 102 | variant_detail::load_variant<0, boost::variant, VariantTypes...>(ar, which, variant); 103 | } 104 | } // namespace cereal 105 | 106 | #endif // CEREAL_TYPES_BOOST_VARIANT_HPP_ 107 | -------------------------------------------------------------------------------- /src/third_party/cereal/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 cereal 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 RANDOLPH VOORHIES OR SHANE GRANT 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 | -------------------------------------------------------------------------------- /src/third_party/cereal/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 cereal 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 RANDOLPH VOORHIES OR SHANE GRANT 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 | -------------------------------------------------------------------------------- /src/third_party/cereal/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 cereal 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 RANDOLPH VOORHIES OR SHANE GRANT 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 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 | -------------------------------------------------------------------------------- /src/third_party/cereal/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 cereal 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 RANDOLPH VOORHIES OR SHANE GRANT 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 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 | -------------------------------------------------------------------------------- /src/third_party/cereal/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 cereal 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 RANDOLPH VOORHIES OR SHANE GRANT 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 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 | -------------------------------------------------------------------------------- /src/third_party/cereal/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 cereal 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 RANDOLPH VOORHIES OR SHANE GRANT 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 34 | #include 35 | 36 | namespace cereal 37 | { 38 | namespace map_detail 39 | { 40 | //! @internal 41 | template inline 42 | void save( Archive & ar, MapT const & map ) 43 | { 44 | ar( make_size_tag( static_cast(map.size()) ) ); 45 | 46 | for( const auto & i : map ) 47 | { 48 | ar( make_map_item(i.first, i.second) ); 49 | } 50 | } 51 | 52 | //! @internal 53 | template inline 54 | void load( Archive & ar, MapT & map ) 55 | { 56 | size_type size; 57 | ar( make_size_tag( size ) ); 58 | 59 | map.clear(); 60 | 61 | auto hint = map.begin(); 62 | for( size_t i = 0; i < size; ++i ) 63 | { 64 | typename MapT::key_type key; 65 | typename MapT::mapped_type value; 66 | 67 | ar( make_map_item(key, value) ); 68 | #ifdef CEREAL_OLDER_GCC 69 | hint = map.insert( hint, std::make_pair(std::move(key), std::move(value)) ); 70 | #else // NOT CEREAL_OLDER_GCC 71 | hint = map.emplace_hint( hint, std::move( key ), std::move( value ) ); 72 | #endif // NOT CEREAL_OLDER_GCC 73 | } 74 | } 75 | } 76 | 77 | //! Saving for std::map 78 | template inline 79 | void CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::map const & map ) 80 | { 81 | map_detail::save( ar, map ); 82 | } 83 | 84 | //! Loading for std::map 85 | template inline 86 | void CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::map & map ) 87 | { 88 | map_detail::load( ar, map ); 89 | } 90 | 91 | //! Saving for std::multimap 92 | /*! @note serialization for this type is not guaranteed to preserve ordering */ 93 | template inline 94 | void CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::multimap const & multimap ) 95 | { 96 | map_detail::save( ar, multimap ); 97 | } 98 | 99 | //! Loading for std::multimap 100 | /*! @note serialization for this type is not guaranteed to preserve ordering */ 101 | template inline 102 | void CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::multimap & multimap ) 103 | { 104 | map_detail::load( ar, multimap ); 105 | } 106 | } // namespace cereal 107 | 108 | #endif // CEREAL_TYPES_MAP_HPP_ 109 | -------------------------------------------------------------------------------- /src/third_party/cereal/include/cereal/types/set.hpp: -------------------------------------------------------------------------------- 1 | /*! \file set.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 cereal 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 RANDOLPH VOORHIES OR SHANE GRANT 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_SET_HPP_ 31 | #define CEREAL_TYPES_SET_HPP_ 32 | 33 | #include 34 | #include 35 | 36 | namespace cereal 37 | { 38 | namespace set_detail 39 | { 40 | //! @internal 41 | template inline 42 | void save( Archive & ar, SetT const & set ) 43 | { 44 | ar( make_size_tag( static_cast(set.size()) ) ); 45 | 46 | for( const auto & i : set ) 47 | ar( i ); 48 | } 49 | 50 | //! @internal 51 | template inline 52 | void load( Archive & ar, SetT & set ) 53 | { 54 | size_type size; 55 | ar( make_size_tag( size ) ); 56 | 57 | set.clear(); 58 | 59 | auto hint = set.begin(); 60 | for( size_type i = 0; i < size; ++i ) 61 | { 62 | typename SetT::key_type key; 63 | 64 | ar( key ); 65 | #ifdef CEREAL_OLDER_GCC 66 | hint = set.insert( hint, std::move( key ) ); 67 | #else // NOT CEREAL_OLDER_GCC 68 | hint = set.emplace_hint( hint, std::move( key ) ); 69 | #endif // NOT CEREAL_OLDER_GCC 70 | } 71 | } 72 | } 73 | 74 | //! Saving for std::set 75 | template inline 76 | void CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::set const & set ) 77 | { 78 | set_detail::save( ar, set ); 79 | } 80 | 81 | //! Loading for std::set 82 | template inline 83 | void CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::set & set ) 84 | { 85 | set_detail::load( ar, set ); 86 | } 87 | 88 | //! Saving for std::multiset 89 | template inline 90 | void CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::multiset const & multiset ) 91 | { 92 | set_detail::save( ar, multiset ); 93 | } 94 | 95 | //! Loading for std::multiset 96 | template inline 97 | void CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::multiset & multiset ) 98 | { 99 | set_detail::load( ar, multiset ); 100 | } 101 | } // namespace cereal 102 | 103 | #endif // CEREAL_TYPES_SET_HPP_ 104 | -------------------------------------------------------------------------------- /src/third_party/cereal/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 cereal 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 RANDOLPH VOORHIES OR SHANE GRANT 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 34 | #include 35 | 36 | // The default container for stack is deque, so let's include that too 37 | #include 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 | -------------------------------------------------------------------------------- /src/third_party/cereal/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 cereal 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 RANDOLPH VOORHIES OR SHANE GRANT 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 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 | -------------------------------------------------------------------------------- /src/third_party/cereal/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 cereal 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 RANDOLPH VOORHIES OR SHANE GRANT 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 34 | #include 35 | 36 | namespace cereal 37 | { 38 | namespace unordered_map_detail 39 | { 40 | //! @internal 41 | template inline 42 | void save( Archive & ar, MapT const & map ) 43 | { 44 | ar( make_size_tag( static_cast(map.size()) ) ); 45 | 46 | for( const auto & i : map ) 47 | ar( make_map_item(i.first, i.second) ); 48 | } 49 | 50 | //! @internal 51 | template inline 52 | void load( Archive & ar, MapT & map ) 53 | { 54 | size_type size; 55 | ar( make_size_tag( size ) ); 56 | 57 | map.clear(); 58 | map.reserve( static_cast( size ) ); 59 | 60 | for( size_type i = 0; i < size; ++i ) 61 | { 62 | typename MapT::key_type key; 63 | typename MapT::mapped_type value; 64 | 65 | ar( make_map_item(key, value) ); 66 | map.emplace( std::move( key ), std::move( value ) ); 67 | } 68 | } 69 | } 70 | 71 | //! Saving for std::unordered_map 72 | template inline 73 | void CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::unordered_map const & unordered_map ) 74 | { 75 | unordered_map_detail::save( ar, unordered_map ); 76 | } 77 | 78 | //! Loading for std::unordered_map 79 | template inline 80 | void CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::unordered_map & unordered_map ) 81 | { 82 | unordered_map_detail::load( ar, unordered_map ); 83 | } 84 | 85 | //! Saving for std::unordered_multimap 86 | template inline 87 | void CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::unordered_multimap const & unordered_multimap ) 88 | { 89 | unordered_map_detail::save( ar, unordered_multimap ); 90 | } 91 | 92 | //! Loading for std::unordered_multimap 93 | template inline 94 | void CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::unordered_multimap & unordered_multimap ) 95 | { 96 | unordered_map_detail::load( ar, unordered_multimap ); 97 | } 98 | } // namespace cereal 99 | 100 | #endif // CEREAL_TYPES_UNORDERED_MAP_HPP_ 101 | -------------------------------------------------------------------------------- /src/third_party/cereal/include/cereal/types/unordered_set.hpp: -------------------------------------------------------------------------------- 1 | /*! \file unordered_set.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 cereal 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 RANDOLPH VOORHIES OR SHANE GRANT 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_SET_HPP_ 31 | #define CEREAL_TYPES_UNORDERED_SET_HPP_ 32 | 33 | #include 34 | #include 35 | 36 | namespace cereal 37 | { 38 | namespace unordered_set_detail 39 | { 40 | //! @internal 41 | template inline 42 | void save( Archive & ar, SetT const & set ) 43 | { 44 | ar( make_size_tag( static_cast(set.size()) ) ); 45 | 46 | for( const auto & i : set ) 47 | ar( i ); 48 | } 49 | 50 | //! @internal 51 | template inline 52 | void load( Archive & ar, SetT & set ) 53 | { 54 | size_type size; 55 | ar( make_size_tag( size ) ); 56 | 57 | set.clear(); 58 | set.reserve( static_cast( size ) ); 59 | 60 | for( size_type i = 0; i < size; ++i ) 61 | { 62 | typename SetT::key_type key; 63 | 64 | ar( key ); 65 | set.emplace( std::move( key ) ); 66 | } 67 | } 68 | } 69 | 70 | //! Saving for std::unordered_set 71 | template inline 72 | void CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::unordered_set const & unordered_set ) 73 | { 74 | unordered_set_detail::save( ar, unordered_set ); 75 | } 76 | 77 | //! Loading for std::unordered_set 78 | template inline 79 | void CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::unordered_set & unordered_set ) 80 | { 81 | unordered_set_detail::load( ar, unordered_set ); 82 | } 83 | 84 | //! Saving for std::unordered_multiset 85 | template inline 86 | void CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::unordered_multiset const & unordered_multiset ) 87 | { 88 | unordered_set_detail::save( ar, unordered_multiset ); 89 | } 90 | 91 | //! Loading for std::unordered_multiset 92 | template inline 93 | void CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::unordered_multiset & unordered_multiset ) 94 | { 95 | unordered_set_detail::load( ar, unordered_multiset ); 96 | } 97 | } // namespace cereal 98 | 99 | #endif // CEREAL_TYPES_UNORDERED_SET_HPP_ 100 | -------------------------------------------------------------------------------- /src/third_party/cereal/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 cereal 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 RANDOLPH VOORHIES OR SHANE GRANT 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 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 | -------------------------------------------------------------------------------- /src/third_party/cereal/include/cereal/types/valarray.hpp: -------------------------------------------------------------------------------- 1 | /*! \file valarray.hpp 2 | \brief Support for types found in \ 3 | \ingroup STLSupport */ 4 | 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 cereal 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 RANDOLPH VOORHIES OR SHANE GRANT 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 | 32 | #ifndef CEREAL_TYPES_VALARRAY_HPP_ 33 | #define CEREAL_TYPES_VALARRAY_HPP_ 34 | 35 | #include 36 | #include 37 | 38 | namespace cereal 39 | { 40 | //! Saving for std::valarray arithmetic types, using binary serialization, if supported 41 | template inline 42 | typename std::enable_if, Archive>::value 43 | && std::is_arithmetic::value, void>::type 44 | CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::valarray const & valarray ) 45 | { 46 | ar( make_size_tag( static_cast(valarray.size()) ) ); // number of elements 47 | ar( binary_data( &valarray[0], valarray.size() * sizeof(T) ) ); // &valarray[0] ok since guaranteed contiguous 48 | } 49 | 50 | //! Loading for std::valarray arithmetic types, using binary serialization, if supported 51 | template inline 52 | typename std::enable_if, Archive>::value 53 | && std::is_arithmetic::value, void>::type 54 | CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::valarray & valarray ) 55 | { 56 | size_type valarraySize; 57 | ar( make_size_tag( valarraySize ) ); 58 | 59 | valarray.resize( static_cast( valarraySize ) ); 60 | ar( binary_data( &valarray[0], static_cast( valarraySize ) * sizeof(T) ) ); 61 | } 62 | 63 | //! Saving for std::valarray all other types 64 | template inline 65 | typename std::enable_if, Archive>::value 66 | || !std::is_arithmetic::value, void>::type 67 | CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::valarray const & valarray ) 68 | { 69 | ar( make_size_tag( static_cast(valarray.size()) ) ); // number of elements 70 | for(auto && v : valarray) 71 | ar(v); 72 | } 73 | 74 | //! Loading for std::valarray all other types 75 | template inline 76 | typename std::enable_if, Archive>::value 77 | || !std::is_arithmetic::value, void>::type 78 | CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::valarray & valarray ) 79 | { 80 | size_type valarraySize; 81 | ar( make_size_tag( valarraySize ) ); 82 | 83 | valarray.resize( static_cast( valarraySize ) ); 84 | for(auto && v : valarray) 85 | ar(v); 86 | } 87 | } // namespace cereal 88 | 89 | #endif // CEREAL_TYPES_VALARRAY_HPP_ 90 | -------------------------------------------------------------------------------- /travis-install-deps.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e; 4 | 5 | if [ ! -d "$HOME/deps/lib" ]; then 6 | # Make the deps directory 7 | mkdir -p $HOME/deps; 8 | 9 | # Download and Install Mongo C Driver 10 | curl -O -L https://github.com/mongodb/mongo-c-driver/releases/download/${CDRIVER_VERSION}/mongo-c-driver-${CDRIVER_VERSION}.tar.gz 11 | tar -zxf mongo-c-driver-${CDRIVER_VERSION}.tar.gz 12 | pushd mongo-c-driver-${CDRIVER_VERSION}; 13 | ./configure --prefix=$HOME/deps && make -j$(grep -c ^processor /proc/cpuinfo) && make install; 14 | popd; 15 | 16 | # Enter deps directory 17 | pushd $HOME/deps; 18 | 19 | # Download and Install Mongo C++ Driver 20 | git clone -b 'r3.1.3' --single-branch https://github.com/mongodb/mongo-cxx-driver.git; 21 | pushd mongo-cxx-driver/build; 22 | $HOME/build/mongodb-labs/mangrove/build/${CMAKE_BINARY} -DCMAKE_CXX_FLAGS="-Wno-ignored-attributes" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$HOME/deps/ .. && make -j$(grep -c ^processor /proc/cpuinfo) && make install; 23 | popd; 24 | 25 | # Leave deps directory 26 | popd; 27 | else 28 | echo 'Using cached directory for dependencies.'; 29 | fi 30 | --------------------------------------------------------------------------------