diff --git a/include/cereal/archives/xml.hpp b/include/cereal/archives/xml.hpp index 0858e2ad..a227f7b3 100644 --- a/include/cereal/archives/xml.hpp +++ b/include/cereal/archives/xml.hpp @@ -76,8 +76,8 @@ namespace cereal and instead infer it from the number of children for a node. This means that data can be hand edited for dynamic sized structures and will still be readable. This is accomplished through the cereal::SizeTag object, which will also add an attribute - to its parent field. */ - /*! \ingroup Archives */ + to its parent field. + \ingroup Archives */ class XMLOutputArchive : public OutputArchive { public: @@ -212,9 +212,12 @@ namespace cereal itsNodes.top().node->append_attribute( itsXML.allocate_attribute( "type", namePtr ) ); } - void markDynamicSize() + //! Appends an attribute to the current top level node + void appendAttribute( const char * name, const char * value ) { - itsNodes.top().node->append_attribute( itsXML.allocate_attribute( "size", "dynamic" ) ); + auto namePtr = itsXML.allocate_string( name ); + auto valuePtr = itsXML.allocate_string( value ); + itsNodes.top().node->append_attribute( itsXML.allocate_attribute( namePtr, valuePtr ) ); } protected: @@ -259,7 +262,10 @@ namespace cereal // ###################################################################### //! An output archive designed to save data to XML - /*! \ingroup Archives */ + /*! This archive uses RapidXML to build an in memory XML tree of the + data in the stream it is given before loading any types serialized. + + \ingroup Archives */ class XMLInputArchive : public InputArchive { public: @@ -497,7 +503,7 @@ namespace cereal template void prologue( XMLOutputArchive & ar, SizeTag const & ) { - ar.markDynamicSize(); + ar.appendAttribute( "size", "dynamic" ); } template diff --git a/include/cereal/types/array.hpp b/include/cereal/types/array.hpp index dfc1759e..3fc9766e 100644 --- a/include/cereal/types/array.hpp +++ b/include/cereal/types/array.hpp @@ -55,7 +55,7 @@ namespace cereal ar( binary_data( array.data(), N * sizeof(T) ) ); } - //! Saving for std::array all other types to binary + //! Saving for std::array all other types template inline typename std::enable_if, Archive>() || !std::is_arithmetic::value, void>::type @@ -65,7 +65,7 @@ namespace cereal ar( i ); } - //! Loading for std::array all other types to binary + //! Loading for std::array all other types template inline typename std::enable_if, Archive>() || !std::is_arithmetic::value, void>::type diff --git a/include/cereal/types/bitset.hpp b/include/cereal/types/bitset.hpp index fcc4d60e..3b022c17 100644 --- a/include/cereal/types/bitset.hpp +++ b/include/cereal/types/bitset.hpp @@ -37,6 +37,8 @@ namespace cereal { namespace bitset_detail { + //! The type the bitset is encoded with + /*! @internal */ enum class type : uint8_t { ulong, diff --git a/include/cereal/types/boost_variant.hpp b/include/cereal/types/boost_variant.hpp index f66561f9..90ead2be 100644 --- a/include/cereal/types/boost_variant.hpp +++ b/include/cereal/types/boost_variant.hpp @@ -38,6 +38,7 @@ namespace cereal { namespace binary_detail { + //! @internal template struct variant_save_visitor : boost::static_visitor<> { @@ -52,6 +53,7 @@ namespace cereal Archive & ar; }; + //! @internal template typename std::enable_if::value, void>::type load_variant(Archive & ar, int target, Variant & variant) @@ -59,6 +61,7 @@ namespace cereal throw ::cereal::Exception("Error traversing variant during load"); } + //! @internal template typename std::enable_if::value, void>::type load_variant(Archive & ar, int target, Variant & variant) diff --git a/include/cereal/types/memory.hpp b/include/cereal/types/memory.hpp index 533733c3..83ab1504 100644 --- a/include/cereal/types/memory.hpp +++ b/include/cereal/types/memory.hpp @@ -111,6 +111,7 @@ namespace cereal // Pointer wrapper implementations follow below //! Saving std::shared_ptr (wrapper implementation) + /*! @internal */ template inline void save( Archive & ar, memory_detail::PtrWrapper const &> const & wrapper ) { @@ -126,6 +127,7 @@ namespace cereal } //! Loading std::shared_ptr, case when user load and allocate (wrapper implementation) + /*! @internal */ template inline typename std::enable_if(), void>::type load( Archive & ar, memory_detail::PtrWrapper &> & wrapper ) @@ -148,6 +150,7 @@ namespace cereal } //! Loading std::shared_ptr, case when no user load and allocate (wrapper implementation) + /*! @internal */ template inline typename std::enable_if(), void>::type load( Archive & ar, memory_detail::PtrWrapper &> & wrapper ) @@ -171,6 +174,7 @@ namespace cereal } //! Saving std::unique_ptr (wrapper implementation) + /*! @internal */ template inline void save( Archive & ar, memory_detail::PtrWrapper const &> const & wrapper ) { @@ -190,6 +194,7 @@ namespace cereal } //! Loading std::unique_ptr, case when user provides load_and_allocate (wrapper implementation) + /*! @internal */ template inline typename std::enable_if(), void>::type load( Archive & ar, memory_detail::PtrWrapper &> & wrapper ) @@ -206,6 +211,7 @@ namespace cereal } //! Loading std::unique_ptr, case when no load_and_allocate (wrapper implementation) + /*! @internal */ template inline typename std::enable_if(), void>::type load( Archive & ar, memory_detail::PtrWrapper &> & wrapper ) diff --git a/include/cereal/types/queue.hpp b/include/cereal/types/queue.hpp index f97d1116..4a4b78b8 100644 --- a/include/cereal/types/queue.hpp +++ b/include/cereal/types/queue.hpp @@ -38,6 +38,7 @@ namespace cereal namespace queue_detail { //! Allows access to the protected container in queue + /*! @internal */ template inline C const & container( std::queue const & queue ) { @@ -53,6 +54,7 @@ namespace cereal } //! Allows access to the protected container in priority queue + /*! @internal */ template inline C const & container( std::priority_queue const & priority_queue ) { @@ -68,6 +70,7 @@ namespace cereal } //! Allows access to the protected comparator in priority queue + /*! @internal */ template inline Comp const & comparator( std::priority_queue const & priority_queue ) { diff --git a/include/cereal/types/set.hpp b/include/cereal/types/set.hpp index 2a6c3aaa..8dde4296 100644 --- a/include/cereal/types/set.hpp +++ b/include/cereal/types/set.hpp @@ -37,6 +37,7 @@ namespace cereal { namespace set_detail { + //! @internal template inline void save( Archive & ar, SetT const & set ) { @@ -46,6 +47,7 @@ namespace cereal ar( i ); } + //! @internal template inline void load( Archive & ar, SetT & set ) { diff --git a/include/cereal/types/tuple.hpp b/include/cereal/types/tuple.hpp index bd6521ec..27619359 100644 --- a/include/cereal/types/tuple.hpp +++ b/include/cereal/types/tuple.hpp @@ -38,6 +38,7 @@ namespace cereal namespace tuple_detail { // unwinds a tuple to save it + //! @internal template struct serialize { @@ -50,6 +51,7 @@ namespace cereal }; // Zero height specialization - nothing to do here + //! @internal template <> struct serialize<0> { diff --git a/include/cereal/types/unordered_map.hpp b/include/cereal/types/unordered_map.hpp index 7566d1c6..8d51dfbc 100644 --- a/include/cereal/types/unordered_map.hpp +++ b/include/cereal/types/unordered_map.hpp @@ -37,6 +37,7 @@ namespace cereal { namespace unordered_map_detail { + //! @internal template inline void save( Archive & ar, MapT const & map ) { @@ -46,6 +47,7 @@ namespace cereal ar( make_map_item(i.first, i.second) ); } + //! @internal template inline void load( Archive & ar, MapT & map ) { diff --git a/include/cereal/types/unordered_set.hpp b/include/cereal/types/unordered_set.hpp index 77efba7d..804df56c 100644 --- a/include/cereal/types/unordered_set.hpp +++ b/include/cereal/types/unordered_set.hpp @@ -37,6 +37,7 @@ namespace cereal { namespace unordered_set_detail { + //! @internal template inline void save( Archive & ar, SetT const & set ) { @@ -46,6 +47,7 @@ namespace cereal ar( i ); } + //! @internal template inline void load( Archive & ar, SetT & set ) { diff --git a/unittests.cpp b/unittests.cpp index 42343b39..88881b53 100644 --- a/unittests.cpp +++ b/unittests.cpp @@ -59,6 +59,14 @@ namespace boost } } + +namespace cereal +{ + template + void serialize( Archive &, std::less & ) + { } +} + #define BOOST_TEST_DYN_LINK #define BOOST_TEST_MODULE Cereal #include @@ -1072,11 +1080,10 @@ BOOST_AUTO_TEST_CASE( binary_priority_queue ) test_priority_queue(); } -// TODO: xml doesn't do empty classes by default, need std::less -//BOOST_AUTO_TEST_CASE( xml_priority_queue ) -//{ -// test_priority_queue(); -//} +BOOST_AUTO_TEST_CASE( xml_priority_queue ) +{ + test_priority_queue(); +} // ###################################################################### template