Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit aa891a4
Author: Shane Grant <w.shane.grant@gmail.com>
Date:   Mon Jun 26 13:42:08 2017 -0700

    Resolves USCiLab#414

commit fcef0da
Author: Shane Grant <w.shane.grant@gmail.com>
Date:   Fri May 5 11:37:12 2017 -0700

    Fix shadowing issue for USCiLab#401, recent osx compile issue re: USCiLab#354

commit 950aca4
Merge: ad90557 35a36af
Author: Shane Grant <w.shane.grant@gmail.com>
Date:   Fri May 5 11:09:34 2017 -0700

    Merge branch 'hoensr-xml-no-size-attributes' into develop

commit 35a36af
Author: Shane Grant <w.shane.grant@gmail.com>
Date:   Fri May 5 10:54:25 2017 -0700

    Standardize interface for options (xml)
    see USCiLab#401

commit ad90557
Merge: f031131 2ab15f7
Author: Shane Grant <w.shane.grant@gmail.com>
Date:   Wed May 3 11:39:02 2017 -0700

    Merge branch 'develop' of github.com:USCiLab/cereal into develop

commit f031131
Author: Shane Grant <w.shane.grant@gmail.com>
Date:   Wed May 3 11:38:35 2017 -0700

    modifications for g47 and comment out memory intensive testing

commit c4dcc8d
Merge: 68f56ee 676d329
Author: Shane Grant <w.shane.grant@gmail.com>
Date:   Wed May 3 11:11:08 2017 -0700

    Merge branch 'issue_354' into develop

    still needs more work but this is an improvement for now
    see USCiLab#354

commit 52b03d5
Author: Robin Hoens <robin.hoens@qiagen.com>
Date:   Mon Apr 10 17:13:39 2017 +0200

    Add option to turn off the size=dynamic attributes of lists

commit 2ab15f7
Merge: 68f56ee 7723503
Author: Shane Grant <w.shane.grant@gmail.com>
Date:   Tue Apr 11 16:17:51 2017 -0700

    Merge pull request USCiLab#397 from albertziegenhagel/issue_396

    Add remove_reference to determine whether template argument to BinaryData is const

commit 7723503
Author: Albert Ziegenhagel <albert.ziegenhagel@scai.fraunhofer.de>
Date:   Tue Apr 11 10:32:55 2017 +0200

    Add remove_reference to determine whether template argument to BinaryData is const

commit 68f56ee
Author: Shane Grant <w.shane.grant@gmail.com>
Date:   Mon Apr 10 11:22:38 2017 -0700

    Remove undefined behavior, see USCiLab#390

commit 676d329
Author: Shane Grant <w.shane.grant@gmail.com>
Date:   Wed Feb 22 14:43:31 2017 -0800

    adventures in microoptimization USCiLab#354

commit 546fd9b
Author: Shane Grant <w.shane.grant@gmail.com>
Date:   Sun Feb 19 16:25:32 2017 -0800

    tinkering on USCiLab#354

commit 8b8f581
Author: Shane Grant <w.shane.grant@gmail.com>
Date:   Wed Feb 15 13:39:42 2017 -0800

    Fix macro for double comparison in unit test
    relates USCiLab#338

commit 51cbda5
Merge: 70c4420 e38d6fe
Author: Shane Grant <w.shane.grant@gmail.com>
Date:   Sun Feb 12 14:06:58 2017 -0800

    Merge branch 'develop' for release 1.2.2

commit e38d6fe
Author: Shane Grant <w.shane.grant@gmail.com>
Date:   Sun Feb 12 13:46:25 2017 -0800

    fix update doc script

commit 70c4420
Author: Shane Grant <w.shane.grant@gmail.com>
Date:   Sun Feb 12 00:25:30 2017 -0800

    Update README.md

    add appveyor badge

commit 2590f21
Author: Shane Grant <w.shane.grant@gmail.com>
Date:   Sat Feb 11 23:47:00 2017 -0800

    Properly use multimap for lookup in poly casting
    relates USCiLab#356, still need final testing on MSVC

commit a917374
Author: Shane Grant <w.shane.grant@gmail.com>
Date:   Wed Feb 8 10:47:02 2017 -0800

    size_type now specified by macro CEREAL_SIZE_TYPE
    resolves USCiLab#379

commit ee17db5
Merge: b827b95 f577fc4
Author: Shane Grant <w.shane.grant@gmail.com>
Date:   Mon Feb 6 22:51:29 2017 -0800

    Merge branch 'develop' of github.com:USCiLab/cereal into develop

commit b827b95
Author: Shane Grant <w.shane.grant@gmail.com>
Date:   Mon Feb 6 22:50:56 2017 -0800

    Fixes need for special MSVC case, see USCiLab#373

commit f577fc4
Author: Shane Grant <w.shane.grant@gmail.com>
Date:   Sun Feb 5 22:13:08 2017 -0800

    Turn on warnings as errors for MSVC, warning level to 3
    Can't do level 4 warnings yet - need to make an upstream change to doctest

commit fb6606d
Author: Shane Grant <w.shane.grant@gmail.com>
Date:   Sun Feb 5 18:13:37 2017 -0800

    Do not build coverage or valgrind for MSVC

commit a2d5a15
Merge: 4a92e29 e4d543d
Author: Shane Grant <w.shane.grant@gmail.com>
Date:   Fri Jan 27 10:29:51 2017 -0800

    Merge branch 'tusharpm-develop' into develop

    see USCiLab#373

    Still need to address why windows needed a modifcation to polymorphic test to compile

commit e4d543d
Author: Tushar Maheshwari <tushar27192@gmail.com>
Date:   Thu Jan 26 16:53:47 2017 +0530

    Fix merge issues

commit 2261fee
Author: Tushar Maheshwari <tushar27192@gmail.com>
Date:   Sun Dec 18 17:32:04 2016 +0530

    Pull requests to not increment build numbers

commit 4ff4db8
Author: Tushar Maheshwari <tushar27192@gmail.com>
Date:   Sun Dec 11 20:03:02 2016 +0530

    boost new version

commit 655696a
Author: Tushar Maheshwari <tushar27192@gmail.com>
Date:   Sun Dec 11 15:42:00 2016 +0530

    AppVeyor integration

commit df44243
Author: Tushar Maheshwari <tushar27192@gmail.com>
Date:   Sun Dec 11 01:01:10 2016 +0530

    Enable cross-platform portability test

    CMake fix 32-bit executable with generator Win64

commit 0a908bc
Author: Tushar Maheshwari <tushar27192@gmail.com>
Date:   Sat Dec 10 17:27:28 2016 +0530

    Make tests pass with Windows

commit 4a92e29
Author: Shane Grant <w.shane.grant@gmail.com>
Date:   Wed Jan 25 11:04:24 2017 -0800

    no longer need boost test in travis

commit a8e9963
Merge: 75e50ee 1d67d44
Author: Shane Grant <w.shane.grant@gmail.com>
Date:   Wed Jan 25 10:56:38 2017 -0800

    Merge branch 'develop_doctest' into develop

    see USCiLab#139

commit 75e50ee
Author: Shane Grant <w.shane.grant@gmail.com>
Date:   Mon Nov 28 13:48:46 2016 -0800

    remove old code from sandbox relates USCiLab#363

commit 507f97d
Author: Shane Grant <w.shane.grant@gmail.com>
Date:   Mon Nov 28 11:53:56 2016 -0800

    add -Wold-style-casts see USCiLab#363

commit f69ad7c
Author: Shane Grant <w.shane.grant@gmail.com>
Date:   Mon Nov 28 11:50:23 2016 -0800

    tab to space

commit d21b0c0
Merge: 29829c1 e63f08f
Author: Shane Grant <w.shane.grant@gmail.com>
Date:   Mon Nov 28 11:47:53 2016 -0800

    Merge branch 'laudrup-master' into develop
    see USCiLab#363

commit e63f08f
Author: Shane Grant <w.shane.grant@gmail.com>
Date:   Mon Nov 28 11:47:24 2016 -0800

    minor adjustments to casts, see comments on USCiLab#363

commit 29829c1
Merge: 9978e0c ad92746
Author: Shane Grant <w.shane.grant@gmail.com>
Date:   Mon Nov 28 10:41:27 2016 -0800

    Merge branch 'FlexCoreLib-doxygen_access_from_extern' into develop

    see USCiLab#365

commit ad92746
Author: Shane Grant <w.shane.grant@gmail.com>
Date:   Mon Nov 28 10:41:02 2016 -0800

    comment out obsolete doxygen

commit 9978e0c
Merge: 1edc5c6 6e71766
Author: Shane Grant <w.shane.grant@gmail.com>
Date:   Mon Nov 28 10:37:17 2016 -0800

    Merge pull request USCiLab#366 from headupinclouds/pr.is_loading.is_saving

    Add is_loading and is_saving values to cereal::{Input,Output}Archive

commit 1edc5c6
Merge: 72d7936 6086234
Author: Shane Grant <w.shane.grant@gmail.com>
Date:   Mon Nov 28 10:35:24 2016 -0800

    Merge pull request USCiLab#367 from tusharpm/develop

    Travis configuration updates

commit 6086234
Author: Tushar Maheshwari <tushar27192@gmail.com>
Date:   Sun Nov 27 13:57:26 2016 +0530

    Travis configuration updates
    - Switch to trusty container-based infrastructure for linux systems
    - Add a job to test with clang compiler (skips portability test)
    - Add a job to test on macOS with Xcode8

commit 6e71766
Author: David Hirvonen <dhirvonen@elucideye.com>
Date:   Sat Nov 26 12:31:56 2016 -0500

    Remove spurious character

commit 9376ca6
Author: Kasper Laudrup <laudrup@stacktrace.dk>
Date:   Wed Nov 23 01:34:53 2016 +0100

    Don't use C style casts

    Change C style casts to C++ static casts.

    This makes the code compile with the -Wold-style-cast warning enabled

commit 1d67d44
Author: Shane Grant <w.shane.grant@gmail.com>
Date:   Fri Nov 4 16:07:00 2016 -0700

    Removed boost_test as a requirement
    -Now build 32 bit unit tests if portability testing is enabled
    -No more boost+clang issues over std::string abi
    see USCiLab#139, USCiLab#123

commit 66528b6
Author: Shane Grant <w.shane.grant@gmail.com>
Date:   Fri Nov 4 15:51:57 2016 -0700

    last? conversions for USCiLab#139

commit 978b3b5
Author: Shane Grant <w.shane.grant@gmail.com>
Date:   Fri Nov 4 12:11:51 2016 -0700

    typo fix in comment USCiLab#139

commit 13ae560
Author: Shane Grant <w.shane.grant@gmail.com>
Date:   Fri Nov 4 12:10:24 2016 -0700

    more USCiLab#139

commit 07818f4
Author: Shane Grant <w.shane.grant@gmail.com>
Date:   Fri Nov 4 12:00:16 2016 -0700

    more USCiLab#139

commit b5e500d
Author: Shane Grant <w.shane.grant@gmail.com>
Date:   Wed Nov 2 16:32:35 2016 -0700

    more USCiLab#139

commit a6e59d7
Author: Shane Grant <w.shane.grant@gmail.com>
Date:   Wed Nov 2 13:38:33 2016 -0700

    more for USCiLab#139

commit cd46374
Author: Shane Grant <w.shane.grant@gmail.com>
Date:   Wed Nov 2 12:20:22 2016 -0700

    more converted for USCiLab#139

commit 38e1548
Author: Shane Grant <w.shane.grant@gmail.com>
Date:   Tue Nov 1 11:59:40 2016 -0700

    headers USCiLab#139

commit 15c7339
Author: Shane Grant <w.shane.grant@gmail.com>
Date:   Tue Nov 1 11:59:02 2016 -0700

    more conversions USCiLab#139

commit 928cd36
Author: Shane Grant <w.shane.grant@gmail.com>
Date:   Tue Nov 1 11:41:28 2016 -0700

    more conversions to CHECK_EQ
    see USCiLab#139

commit 0a262ec
Author: Shane Grant <w.shane.grant@gmail.com>
Date:   Tue Nov 1 11:36:22 2016 -0700

    More tests split, switch to CHECk_EQ over CHECK
    see USCiLab#139

commit 671999e
Author: Shane Grant <w.shane.grant@gmail.com>
Date:   Fri Oct 28 14:28:37 2016 -0700

    Initial progress on removing boost test and moving to doctest to better support modules

    relates USCiLab#123

commit a066808
Author: Caspar Kielwein <Caspar@Kielwein.de>
Date:   Sun Oct 2 16:09:04 2016 +0200

    Add cereal.doxytags as tagfile to allow external projects to link to cereal documentation.

commit 3fb59db
Author: Caspar Kielwein <Caspar@Kielwein.de>
Date:   Sun Oct 2 15:53:28 2016 +0200

    Build doxygen documentation with separate CMakeLists.

    Extracted CMakelists.txt to doc subdirectory.
    Changed paths in doxyfile.in and CMakeLists accordingly.
    added doc as subdirectory in main CMakeLists.txt.
  • Loading branch information
headupinclouds committed Aug 15, 2017
1 parent 4c84278 commit 1a4f05f
Show file tree
Hide file tree
Showing 95 changed files with 9,420 additions and 4,417 deletions.
63 changes: 26 additions & 37 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,49 +1,38 @@
language: cpp
dist: trusty
sudo: false
group: beta

addons:
apt:
sources:
- 'ubuntu-toolchain-r-test'
- 'boost-latest'
packages:
- 'g++-multilib'
- 'libboost-serialization-dev'
# - 'libboost-test-dev'

compiler:
# TODO: Clang is currently giving issues
#- clang
- gcc

before_install:
# Always install g++4.8.1
- sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test

# Install recent version of Boost
- sudo add-apt-repository -y ppa:boost-latest/ppa
matrix:
include:
- os: linux
compiler: clang
env: CMAKE_OPTIONS="-DSKIP_PORTABILITY_TEST=ON"

# clang 3.3
- if [ "$CXX" == "clang++" ]; then sudo add-apt-repository -y ppa:h-rayflood/llvm; fi
# TODO: Add an entry for valgrind
# after_script: make valgrind

- sudo apt-get update -qq

install:
- sudo apt-get install cmake
- sudo apt-get install libboost1.54-all-dev

# Always install valgrind
- sudo apt-get install valgrind

# Always install g++4.8.1
- sudo apt-get install -qq g++-4.8
- sudo apt-get install -qq g++-4.8-multilib
- if [ "$CXX" = "g++" ]; then export CMAKE_CXX_COMPILER="g++-4.8"; fi
- if [ "$CXX" = "g++" ]; then export CXX="g++-4.8"; fi

# clang 3.3
- if [ "$CXX" == "clang++" ]; then sudo apt-get install --allow-unauthenticated -qq clang-3.3; fi
- if [ "$CXX" == "clang++" ]; then export CMAKE_CXX_COMPILER="clang++-3.3"; fi
- if [ "$CXX" == "clang++" ]; then export CXX="clang++-3.3"; fi
- os: osx
osx_image: xcode8
compiler: clang

script:
- mkdir build
- cd build
- cmake ..
- make

after_script:
- ctest .
# - make valgrind
- mkdir build && cd build
- cmake ${CMAKE_OPTIONS} .. && make -j4
- ctest . --output-on-failure

branches:
only:
Expand Down
35 changes: 11 additions & 24 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required (VERSION 3.0) # hunter minimum
project (cereal VERSION 1.2.1)

option(SKIP_PORTABILITY_TEST "Skip portability tests" OFF)
option(SKIP_PORTABILITY_TEST "Skip portability (32 bit) tests" OFF)
if(NOT CMAKE_VERSION VERSION_LESS 3.0) # installing cereal requires INTERFACE lib
option(JUST_INSTALL_CEREAL "Don't do anything besides installing the library" OFF)
endif()
Expand Down Expand Up @@ -69,8 +69,10 @@ else()
set(CEREAL_THREAD_LIBS "")
endif()

if(NOT MSVC)
set(CMAKE_CXX_FLAGS "-Wall -g -Wextra -Wshadow -pedantic ${CMAKE_CXX_FLAGS}")
if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj /W3 /WX")
else()
set(CMAKE_CXX_FLAGS "-Wall -g -Wextra -Wshadow -pedantic -Wold-style-cast ${CMAKE_CXX_FLAGS}")
option(WITH_WERROR "Compile with '-Werror' C++ compiler flag" ON)
if(WITH_WERROR)
set(CMAKE_CXX_FLAGS "-Werror ${CMAKE_CXX_FLAGS}")
Expand All @@ -87,31 +89,16 @@ endif()

include_directories(./include)

find_package(Boost COMPONENTS serialization unit_test_framework)
# Boost serialization for performance sandbox
find_package(Boost COMPONENTS serialization)

if(Boost_FOUND)
include_directories(SYSTEM ${Boost_INCLUDE_DIRS})
enable_testing()
add_subdirectory(unittests)
endif(Boost_FOUND)

enable_testing()
add_subdirectory(unittests)

add_subdirectory(sandbox)

find_package(Doxygen)
if(DOXYGEN_FOUND)

configure_file("${CMAKE_CURRENT_SOURCE_DIR}/doc/doxygen.in" "${CMAKE_CURRENT_BINARY_DIR}/doxygen.cfg" @ONLY)
add_custom_target(doc
COMMAND ${DOXYGEN_EXECUTABLE} "${CMAKE_CURRENT_BINARY_DIR}/doxygen.cfg"
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
COMMENT "Generating API documentation with Doxygen" VERBATIM
)

configure_file("${CMAKE_CURRENT_SOURCE_DIR}/scripts/updatedoc.in" "${CMAKE_CURRENT_BINARY_DIR}/updatedoc.sh" @ONLY)
add_custom_target(update-doc
COMMAND "${CMAKE_CURRENT_BINARY_DIR}/updatedoc.sh"
DEPENDS doc
COMMENT "Copying documentation to gh-pages branch" VERBATIM
)

endif(DOXYGEN_FOUND)
add_subdirectory(doc)
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ cereal is licensed under the [BSD license](http://opensource.org/licenses/BSD-3-
## cereal build status

* develop : [![Build Status](https://travis-ci.org/USCiLab/cereal.png?branch=develop)](https://travis-ci.org/USCiLab/cereal)
[![Build status](https://ci.appveyor.com/api/projects/status/91aou6smj36or0vb/branch/develop?svg=true)](https://ci.appveyor.com/project/AzothAmmo/cereal/branch/develop)

---

Expand Down
35 changes: 35 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# can use variables like {build} and {branch}
version: 1.2.{build}
pull_requests:
do_not_increment_build_number: true

branches:
only:
- develop

configuration:
- Debug
- Release

environment:
matrix:
- VS_VERSION_MAJOR: 12
- VS_VERSION_MAJOR: 14
BOOST_ROOT: C:\Libraries\boost_1_59_0

platform:
- Win32
- x64

before_build: "scripts\\appveyor.bat"

build:
parallel: true
project: build/cereal.sln
verbosity: minimal

test_script: "scripts\\appveyor.bat test"

artifacts:
- path: build\Testing
- path: out
18 changes: 18 additions & 0 deletions doc/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
find_package(Doxygen)
if(DOXYGEN_FOUND)

configure_file("${CMAKE_CURRENT_SOURCE_DIR}/doxygen.in" "${CMAKE_CURRENT_BINARY_DIR}/doxygen.cfg" @ONLY)
add_custom_target(doc
COMMAND ${DOXYGEN_EXECUTABLE} "${CMAKE_CURRENT_BINARY_DIR}/doxygen.cfg"
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/.."
COMMENT "Generating API documentation with Doxygen" VERBATIM
)

configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../scripts/updatedoc.in" "${CMAKE_CURRENT_BINARY_DIR}/updatedoc.sh" @ONLY)
add_custom_target(update-doc
COMMAND "${CMAKE_CURRENT_BINARY_DIR}/updatedoc.sh"
DEPENDS doc
COMMENT "Copying documentation to gh-pages branch" VERBATIM
)

endif(DOXYGEN_FOUND)
16 changes: 8 additions & 8 deletions doc/doxygen.in
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ PROJECT_LOGO =
# If a relative path is entered, it will be relative to the location
# where doxygen was started. If left blank the current directory will be used.

OUTPUT_DIRECTORY = doc
OUTPUT_DIRECTORY = @CMAKE_CURRENT_BINARY_DIR@/

# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create
# 4096 sub-directories (in 2 levels) under the output directory of each output
Expand Down Expand Up @@ -595,7 +595,7 @@ FILE_VERSION_FILTER =
# You can optionally specify a file name after the option, if omitted
# DoxygenLayout.xml will be used as the name of the layout file.

LAYOUT_FILE = "@CMAKE_CURRENT_SOURCE_DIR@/doc/DoxygenLayout.xml"
LAYOUT_FILE = "@CMAKE_CURRENT_SOURCE_DIR@/DoxygenLayout.xml"

# The CITE_BIB_FILES tag can be used to specify one or more bib files
# containing the references data. This must be a list of .bib files. The
Expand Down Expand Up @@ -668,7 +668,7 @@ WARN_LOGFILE =
# directories like "/usr/src/myproject". Separate the files or directories
# with spaces.

INPUT = @CMAKE_CURRENT_SOURCE_DIR@/include @CMAKE_CURRENT_SOURCE_DIR@/doc #include doc
INPUT = @CMAKE_CURRENT_SOURCE_DIR@/../include @CMAKE_CURRENT_SOURCE_DIR@/

# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
Expand Down Expand Up @@ -701,7 +701,7 @@ RECURSIVE = YES
# Note that relative paths are relative to the directory from which doxygen is
# run.

EXCLUDE = external
EXCLUDE = @CMAKE_CURRENT_SOURCE_DIR@/../external

# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or
# directories that are symbolic links (a Unix file system feature) are excluded
Expand Down Expand Up @@ -911,7 +911,7 @@ HTML_HEADER =
# each generated HTML page. If it is left blank doxygen will generate a
# standard footer.

HTML_FOOTER ="@CMAKE_CURRENT_SOURCE_DIR@/doc/footer.html"
HTML_FOOTER ="@CMAKE_CURRENT_SOURCE_DIR@/footer.html"

# The HTML_STYLESHEET tag can be used to specify a user-defined cascading
# style sheet that is used by each HTML page. It can be used to
Expand Down Expand Up @@ -1476,13 +1476,13 @@ XML_OUTPUT = xml
# which can be used by a validating XML parser to check the
# syntax of the XML files.

XML_SCHEMA =
# XML_SCHEMA =

# The XML_DTD tag can be used to specify an XML DTD,
# which can be used by a validating XML parser to check the
# syntax of the XML files.

XML_DTD =
# XML_DTD =

# If the XML_PROGRAMLISTING tag is set to YES Doxygen will
# dump the program listings (including syntax highlighting
Expand Down Expand Up @@ -1626,7 +1626,7 @@ TAGFILES =
# When a file name is specified after GENERATE_TAGFILE, doxygen will create
# a tag file that is based on the input files it reads.

GENERATE_TAGFILE =
GENERATE_TAGFILE = cereal.doxytags

# If the ALLEXTERNALS tag is set to YES all external classes will be listed
# in the class index. If set to NO only the inherited external classes
Expand Down
6 changes: 6 additions & 0 deletions include/cereal/archives/json.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,14 @@ namespace cereal
#endif // RAPIDJSON_ASSERT

// Enable support for parsing of nan, inf, -inf
#ifndef CEREAL_RAPIDJSON_WRITE_DEFAULT_FLAGS
#define CEREAL_RAPIDJSON_WRITE_DEFAULT_FLAGS kWriteNanAndInfFlag
#endif

// Enable support for parsing of nan, inf, -inf
#ifndef CEREAL_RAPIDJSON_PARSE_DEFAULT_FLAGS
#define CEREAL_RAPIDJSON_PARSE_DEFAULT_FLAGS kParseFullPrecisionFlag | kParseNanAndInfFlag
#endif

#include "cereal/external/rapidjson/prettywriter.h"
#include "cereal/external/rapidjson/ostreamwrapper.h"
Expand Down
58 changes: 46 additions & 12 deletions include/cereal/archives/xml.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,31 +101,58 @@ namespace cereal
//! @{

//! A class containing various advanced options for the XML archive
/*! Options can either be directly passed to the constructor, or chained using the
modifier functions for an interface analogous to named parameters */
class Options
{
public:
//! Default options
static Options Default(){ return Options(); }

//! Default options with no indentation
static Options NoIndent(){ return Options( std::numeric_limits<double>::max_digits10, false ); }

//! Specify specific options for the XMLOutputArchive
/*! @param precision The precision used for floating point numbers
@param indent Whether to indent each line of XML
@param outputType Whether to output the type of each serialized object as an attribute */
explicit Options( int precision = std::numeric_limits<double>::max_digits10,
bool indent = true,
bool outputType = false ) :
itsPrecision( precision ),
itsIndent( indent ),
itsOutputType( outputType ) { }
@param outputType Whether to output the type of each serialized object as an attribute
@param sizeAttributes Whether dynamically sized containers output the size=dynamic attribute */
explicit Options( int precision_ = std::numeric_limits<double>::max_digits10,
bool indent_ = true,
bool outputType_ = false,
bool sizeAttributes_ = true ) :
itsPrecision( precision_ ),
itsIndent( indent_ ),
itsOutputType( outputType_ ),
itsSizeAttributes( sizeAttributes_ )
{ }

/*! @name Option Modifiers
An interface for setting option settings analogous to named parameters.
@code{cpp}
cereal::XMLOutputArchive ar( myStream,
cereal::XMLOutputArchive::Options()
.indent(true)
.sizeAttributes(false) );
@endcode
*/
//! @{

//! Sets the precision used for floaing point numbers
Options & precision( int value ){ itsPrecision = value; return * this; }
//! Whether to indent each line of XML
Options & indent( bool enable ){ itsIndent = enable; return *this; }
//! Whether to output the type of each serialized object as an attribute
Options & outputType( bool enable ){ itsOutputType = enable; return *this; }
//! Whether dynamically sized containers (e.g. vector) output the size=dynamic attribute
Options & sizeAttributes( bool enable ){ itsSizeAttributes = enable; return *this; }

//! @}

private:
friend class XMLOutputArchive;
int itsPrecision;
bool itsIndent;
bool itsOutputType;
bool itsSizeAttributes;
};

//! Construct, outputting to the provided stream upon destruction
Expand All @@ -137,7 +164,8 @@ namespace cereal
OutputArchive<XMLOutputArchive>(this),
itsStream(stream),
itsOutputType( options.itsOutputType ),
itsIndent( options.itsIndent )
itsIndent( options.itsIndent ),
itsSizeAttributes(options.itsSizeAttributes)
{
// rapidxml will delete all allocations when xml_document is cleared
auto node = itsXML.allocate_node( rapidxml::node_declaration );
Expand Down Expand Up @@ -289,6 +317,8 @@ namespace cereal
itsNodes.top().node->append_attribute( itsXML.allocate_attribute( namePtr, valuePtr ) );
}

bool hasSizeAttributes() const { return itsSizeAttributes; }

protected:
//! A struct that contains metadata about a node
struct NodeInfo
Expand Down Expand Up @@ -330,6 +360,7 @@ namespace cereal
std::ostringstream itsOS; //!< Used to format strings internally
bool itsOutputType; //!< Controls whether type information is printed
bool itsIndent; //!< Controls whether indenting is used
bool itsSizeAttributes; //!< Controls whether lists have a size attribute
}; // XMLOutputArchive

// ######################################################################
Expand Down Expand Up @@ -764,7 +795,10 @@ namespace cereal
template <class T> inline
void prologue( XMLOutputArchive & ar, SizeTag<T> const & )
{
ar.appendAttribute( "size", "dynamic" );
if (ar.hasSizeAttributes())
{
ar.appendAttribute("size", "dynamic");
}
}

template <class T> inline
Expand Down
Loading

0 comments on commit 1a4f05f

Please sign in to comment.