From f9f7ac094303701d84946b0b2ea9933265bd43b0 Mon Sep 17 00:00:00 2001 From: Shane Grant Date: Fri, 23 Jan 2015 11:47:04 -0800 Subject: [PATCH 1/6] Remove boost include and unused sandbox Should be no problem compiling when boost isn't found #162 --- sandbox/sandbox_boostcompat.cpp | 57 --------------------------------- sandbox/sandbox_vs.cpp | 1 - 2 files changed, 58 deletions(-) delete mode 100644 sandbox/sandbox_boostcompat.cpp diff --git a/sandbox/sandbox_boostcompat.cpp b/sandbox/sandbox_boostcompat.cpp deleted file mode 100644 index 6d72090eb..000000000 --- a/sandbox/sandbox_boostcompat.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/* - Copyright (c) 2014, Randolph Voorhies, Shane Grant - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * Neither the name of cereal nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL RANDOLPH VOORHIES AND SHANE GRANT BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include -#include - -#include - -class Test -{ - public: - - private: - friend class cereal::access; - template - void serialize( Archive & ar, const unsigned int version ) - { - - } -}; - -int main() -{ - { - cereal::XMLOutputArchive ar(std::cout); - - Test a; - - ar( a ); - } - - return 0; -} diff --git a/sandbox/sandbox_vs.cpp b/sandbox/sandbox_vs.cpp index 9e5ffd56c..954d74c85 100644 --- a/sandbox/sandbox_vs.cpp +++ b/sandbox/sandbox_vs.cpp @@ -9,7 +9,6 @@ #include #include -#include #include #include #include From 93e075f008b8fa983a1acb2d4763086f0c42e280 Mon Sep 17 00:00:00 2001 From: Joel Holdsworth Date: Wed, 4 Feb 2015 16:24:06 +0000 Subject: [PATCH 2/6] Fixed parameter naming in CEREAL_REGISTER_DYNAMIC_INIT and CEREAL_FORCE_DYNAMIC_INIT --- include/cereal/types/polymorphic.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/cereal/types/polymorphic.hpp b/include/cereal/types/polymorphic.hpp index 4f5288a92..6cd85f68b 100644 --- a/include/cereal/types/polymorphic.hpp +++ b/include/cereal/types/polymorphic.hpp @@ -131,7 +131,7 @@ @relates CEREAL_FORCE_DYNAMIC_INIT */ -#define CEREAL_REGISTER_DYNAMIC_INIT(Name) \ +#define CEREAL_REGISTER_DYNAMIC_INIT(LibName) \ namespace cereal { \ namespace detail { \ void CEREAL_DLL_EXPORT dynamic_init_dummy_##LibName() {} \ @@ -144,7 +144,7 @@ See CEREAL_REGISTER_DYNAMIC_INIT for detailed explanation of how this macro should be used. The name used should match that for CEREAL_REGISTER_DYNAMIC_INIT. */ -#define CEREAL_FORCE_DYNAMIC_INIT(Name) \ +#define CEREAL_FORCE_DYNAMIC_INIT(LibName) \ namespace cereal { \ namespace detail { \ void dynamic_init_dummy_##LibName(); \ From c6b899ef1fec1a1d5d7210a10038eab0ce895709 Mon Sep 17 00:00:00 2001 From: Shane Grant Date: Wed, 4 Feb 2015 10:40:59 -0800 Subject: [PATCH 3/6] Add getNodeName API see #166, #66 --- include/cereal/archives/json.hpp | 7 +++++++ include/cereal/archives/xml.hpp | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/include/cereal/archives/json.hpp b/include/cereal/archives/json.hpp index fc55e3c18..3a1c6acac 100644 --- a/include/cereal/archives/json.hpp +++ b/include/cereal/archives/json.hpp @@ -560,6 +560,13 @@ namespace cereal ++itsIteratorStack.back(); } + //! Retrieves the current node name + /*! @return nullptr if no name exists */ + const char * getNodeName() const + { + return itsIteratorStack.back().name(); + } + //! Sets the name for the next node created with startNode void setNextName( const char * name ) { diff --git a/include/cereal/archives/xml.hpp b/include/cereal/archives/xml.hpp index d8f3a46a6..0f5f70a08 100644 --- a/include/cereal/archives/xml.hpp +++ b/include/cereal/archives/xml.hpp @@ -475,6 +475,13 @@ namespace cereal itsNodes.top().name = nullptr; } + //! Retrieves the current node name + //! will return @c nullptr if the node does not have a name + const char * getNodeName() const + { + return itsNodes.top().node->name(); + } + //! Sets the name for the next node created with startNode void setNextName( const char * name ) { From 9c9ca5482973f067e006256b54fd5a4066ab0f5b Mon Sep 17 00:00:00 2001 From: Shane Grant Date: Thu, 12 Feb 2015 11:52:35 -0800 Subject: [PATCH 4/6] doxygen comment fix --- include/cereal/access.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/cereal/access.hpp b/include/cereal/access.hpp index db8e8972b..60437e68c 100644 --- a/include/cereal/access.hpp +++ b/include/cereal/access.hpp @@ -403,7 +403,7 @@ namespace cereal @code{cpp} struct MyType {}; - CEREAL_SPECIALIZE_FOR_ALL_ARCHIVES( cereal::XMLInputArchive, MyType, cereal::specialization::member_load_save ); + CEREAL_SPECIALIZE_FOR_ARCHIVE( cereal::XMLInputArchive, MyType, cereal::specialization::member_load_save ); @endcode @relates specialize From 4f1dc224e63412dde0c6c4a5d4f68af253c5f012 Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Tue, 3 Mar 2015 21:29:04 -0500 Subject: [PATCH 5/6] Prevent infinite template recursion for 11-element tuples --- include/cereal/types/tuple.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/cereal/types/tuple.hpp b/include/cereal/types/tuple.hpp index eed71fa2d..2831728ae 100644 --- a/include/cereal/types/tuple.hpp +++ b/include/cereal/types/tuple.hpp @@ -63,7 +63,7 @@ namespace cereal template struct to_string_impl { - using type = typename to_string_impl::type; + using type = typename to_string_impl::type; }; //! Base case with no quotient From 0d8cebe6f33fa407d923aa8ff141a17ec324f9ea Mon Sep 17 00:00:00 2001 From: Shane Grant Date: Wed, 4 Mar 2015 15:24:11 -0800 Subject: [PATCH 6/6] Add unit tests for size 11 tuple, re: #175 --- unittests/tuple.cpp | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/unittests/tuple.cpp b/unittests/tuple.cpp index e3de57ac0..973b1a15b 100644 --- a/unittests/tuple.cpp +++ b/unittests/tuple.cpp @@ -38,6 +38,8 @@ void test_tuple() for(int ii=0; ii<100; ++ii) { auto o_podtuple = std::make_tuple( rng(), rng(), rng(), rng() ); + auto o_podtuple11 = std::make_tuple( rng(), rng(), rng(), rng(), rng(), rng(), + rng(), rng(), rng(), rng(), rng() ); auto o_isertuple = std::make_tuple( StructInternalSerialize( rng(), rng() ), StructInternalSerialize( rng(), rng() ), StructInternalSerialize( rng(), rng() ), @@ -60,34 +62,38 @@ void test_tuple() OArchive oar(os); oar(o_podtuple); + oar(o_podtuple11); oar(o_isertuple); oar(o_ispltuple); oar(o_esertuple); oar(o_espltuple); } - decltype( o_podtuple ) i_podtuple; - decltype( o_isertuple ) i_isertuple; - decltype( o_ispltuple ) i_ispltuple; - decltype( o_esertuple ) i_esertuple; - decltype( o_espltuple ) i_espltuple; + decltype( o_podtuple ) i_podtuple; + decltype( o_podtuple11 ) i_podtuple11; + decltype( o_isertuple ) i_isertuple; + decltype( o_ispltuple ) i_ispltuple; + decltype( o_esertuple ) i_esertuple; + decltype( o_espltuple ) i_espltuple; std::istringstream is(os.str()); { IArchive iar(is); iar(i_podtuple); + iar(i_podtuple11); iar(i_isertuple); iar(i_ispltuple); iar(i_esertuple); iar(i_espltuple); } - BOOST_CHECK_EQUAL( i_podtuple == o_podtuple, true ); - BOOST_CHECK_EQUAL( i_isertuple == o_isertuple, true ); - BOOST_CHECK_EQUAL( i_ispltuple == o_ispltuple, true ); - BOOST_CHECK_EQUAL( i_esertuple == o_esertuple, true ); - BOOST_CHECK_EQUAL( i_espltuple == o_espltuple, true ); + BOOST_CHECK_EQUAL( i_podtuple == o_podtuple, true ); + BOOST_CHECK_EQUAL( i_podtuple11 == o_podtuple11, true ); + BOOST_CHECK_EQUAL( i_isertuple == o_isertuple, true ); + BOOST_CHECK_EQUAL( i_ispltuple == o_ispltuple, true ); + BOOST_CHECK_EQUAL( i_esertuple == o_esertuple, true ); + BOOST_CHECK_EQUAL( i_espltuple == o_espltuple, true ); } }