adding version macro for boost transition layer

This commit is contained in:
Shane Grant
2013-12-01 00:10:31 -08:00
parent 3411b0f3a8
commit 61315b09ec
5 changed files with 22 additions and 5 deletions

7
.gitignore vendored
View File

@@ -23,6 +23,7 @@
*.log
*.tlog*
# misc files mostly used for testing
out.txt
ptr.txt
test.txt
@@ -30,9 +31,9 @@ unittests
boost_serialize
arr.txt
performance
./sandbox
./sandbox_rtti
./sandbox_json
sandbox
sandbox_json
sandbox_rtti
include_renamed
.ycm_extra_conf.py*
doc/html

View File

@@ -384,6 +384,9 @@ namespace cereal
//! The id to be given to the next polymorphic type name
std::uint32_t itsCurrentPolymorphicTypeId;
//! Keeps track of classes that have versioning information associated with them
std::unordered_set<size_type> itsVersionedTypes;
}; // class OutputArchive
// ######################################################################

View File

@@ -36,7 +36,6 @@
namespace cereal
{
//! The size type used by cereal
/*! To ensure compatability between 32, 64, etc bit machines, we need to use
* a fixed size type instead of size_t, which may vary from machine to
@@ -305,6 +304,16 @@ namespace cereal
{
return {std::forward<KeyType>(key), std::forward<ValueType>(value)};
}
//! Defines a class version for some type
/*! This is part of the Boost Transition Layer and is not the recommended way
of using cereal. This works identically to how it does in Boost serialization,
providing a version number associated with some type that is available by specifying
a second parameter to serialize, save, or load. */
#define CEREAL_CLASS_VERSION(TYPE, VERSION_NUMBER) \
namespace cereal { namespace detail { \
template <> struct Version<TYPE> { static const std::uint32_t version = VERSION_NUMBER; };\
} } // end namespaces
} // namespace cereal
#endif // CEREAL_DETAILS_HELPERS_HPP_

View File

@@ -316,7 +316,6 @@ namespace cereal
struct base_class_id_hash { size_t operator()(base_class_id const & id) const { return id.hash; } };
} // namespace detail
// ######################################################################
//! A macro to use to restrict which types of archives your function will work for.
/*! This requires you to have a template class parameter named Archive and replaces the void return
@@ -388,6 +387,9 @@ namespace cereal
return LoadAndAllocate<T>::load_and_allocate( ar );
}
};
//! Version information class - used in Boost Transition Layer
template <class T> struct Version;
} // namespace detail
} // namespace cereal

View File

@@ -656,3 +656,5 @@ int main()
return 0;
}
CEREAL_CLASS_VERSION(std::vector<int>, 1);