mirror of
https://github.com/USCiLab/cereal.git
synced 2025-10-18 01:45:52 +02:00
adding version macro for boost transition layer
This commit is contained in:
7
.gitignore
vendored
7
.gitignore
vendored
@@ -23,6 +23,7 @@
|
|||||||
*.log
|
*.log
|
||||||
*.tlog*
|
*.tlog*
|
||||||
|
|
||||||
|
# misc files mostly used for testing
|
||||||
out.txt
|
out.txt
|
||||||
ptr.txt
|
ptr.txt
|
||||||
test.txt
|
test.txt
|
||||||
@@ -30,9 +31,9 @@ unittests
|
|||||||
boost_serialize
|
boost_serialize
|
||||||
arr.txt
|
arr.txt
|
||||||
performance
|
performance
|
||||||
./sandbox
|
sandbox
|
||||||
./sandbox_rtti
|
sandbox_json
|
||||||
./sandbox_json
|
sandbox_rtti
|
||||||
include_renamed
|
include_renamed
|
||||||
.ycm_extra_conf.py*
|
.ycm_extra_conf.py*
|
||||||
doc/html
|
doc/html
|
||||||
|
|||||||
@@ -384,6 +384,9 @@ namespace cereal
|
|||||||
|
|
||||||
//! The id to be given to the next polymorphic type name
|
//! The id to be given to the next polymorphic type name
|
||||||
std::uint32_t itsCurrentPolymorphicTypeId;
|
std::uint32_t itsCurrentPolymorphicTypeId;
|
||||||
|
|
||||||
|
//! Keeps track of classes that have versioning information associated with them
|
||||||
|
std::unordered_set<size_type> itsVersionedTypes;
|
||||||
}; // class OutputArchive
|
}; // class OutputArchive
|
||||||
|
|
||||||
// ######################################################################
|
// ######################################################################
|
||||||
|
|||||||
@@ -36,7 +36,6 @@
|
|||||||
|
|
||||||
namespace cereal
|
namespace cereal
|
||||||
{
|
{
|
||||||
|
|
||||||
//! The size type used by cereal
|
//! The size type used by cereal
|
||||||
/*! To ensure compatability between 32, 64, etc bit machines, we need to use
|
/*! 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
|
* 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)};
|
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
|
} // namespace cereal
|
||||||
|
|
||||||
#endif // CEREAL_DETAILS_HELPERS_HPP_
|
#endif // CEREAL_DETAILS_HELPERS_HPP_
|
||||||
|
|||||||
@@ -316,7 +316,6 @@ namespace cereal
|
|||||||
struct base_class_id_hash { size_t operator()(base_class_id const & id) const { return id.hash; } };
|
struct base_class_id_hash { size_t operator()(base_class_id const & id) const { return id.hash; } };
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
||||||
|
|
||||||
// ######################################################################
|
// ######################################################################
|
||||||
//! A macro to use to restrict which types of archives your function will work for.
|
//! 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
|
/*! 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 );
|
return LoadAndAllocate<T>::load_and_allocate( ar );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//! Version information class - used in Boost Transition Layer
|
||||||
|
template <class T> struct Version;
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
} // namespace cereal
|
} // namespace cereal
|
||||||
|
|
||||||
|
|||||||
@@ -656,3 +656,5 @@ int main()
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CEREAL_CLASS_VERSION(std::vector<int>, 1);
|
||||||
|
|||||||
Reference in New Issue
Block a user