29 #ifndef CEREAL_ACCESS_HPP_
30 #define CEREAL_ACCESS_HPP_
32 #include <type_traits>
113 namespace memory_detail{
template <
class Ar,
class T>
struct LoadAndConstructLoadWrapper; }
114 namespace boost_variant_detail{
template <
class Ar,
class T>
struct LoadAndConstructLoadWrapper; }
176 template <
class ... Args>
188 throw Exception(
"Object must be initialized prior to accessing members");
207 template <
class Ar,
class TT>
friend struct ::cereal::memory_detail::LoadAndConstructLoadWrapper;
208 template <
class Ar,
class TT>
friend struct ::cereal::boost_variant_detail::LoadAndConstructLoadWrapper;
211 construct( T * p, std::function<
void()> enableSharedFunc ) :
244 template<
class Archive,
class T>
inline
245 static auto member_serialize(Archive & ar, T & t) -> decltype(t.CEREAL_SERIALIZE_FUNCTION_NAME(ar))
246 {
return t.CEREAL_SERIALIZE_FUNCTION_NAME(ar); }
248 template<
class Archive,
class T>
inline
249 static auto member_save(Archive & ar, T
const & t) -> decltype(t.CEREAL_SAVE_FUNCTION_NAME(ar))
250 {
return t.CEREAL_SAVE_FUNCTION_NAME(ar); }
252 template<
class Archive,
class T>
inline
254 {
return t.CEREAL_SAVE_FUNCTION_NAME(ar); }
256 template<
class Archive,
class T>
inline
257 static auto member_load(Archive & ar, T & t) -> decltype(t.CEREAL_LOAD_FUNCTION_NAME(ar))
258 {
return t.CEREAL_LOAD_FUNCTION_NAME(ar); }
260 template<
class Archive,
class T>
inline
261 static auto member_save_minimal(Archive
const & ar, T
const & t) -> decltype(t.CEREAL_SAVE_MINIMAL_FUNCTION_NAME(ar))
262 {
return t.CEREAL_SAVE_MINIMAL_FUNCTION_NAME(ar); }
264 template<
class Archive,
class T>
inline
266 {
return t.CEREAL_SAVE_MINIMAL_FUNCTION_NAME(ar); }
268 template<
class Archive,
class T,
class U>
inline
269 static auto member_load_minimal(Archive
const & ar, T & t, U && u) -> decltype(t.CEREAL_LOAD_MINIMAL_FUNCTION_NAME(ar, std::forward<U>(u)))
270 {
return t.CEREAL_LOAD_MINIMAL_FUNCTION_NAME(ar, std::forward<U>(u)); }
273 template<
class Archive,
class T>
inline
275 {
return t.CEREAL_SERIALIZE_FUNCTION_NAME(ar, version); }
277 template<
class Archive,
class T>
inline
278 static auto member_save(Archive & ar, T
const & t,
const std::uint32_t version ) -> decltype(t.CEREAL_SAVE_FUNCTION_NAME(ar, version))
279 {
return t.CEREAL_SAVE_FUNCTION_NAME(ar, version); }
281 template<
class Archive,
class T>
inline
283 {
return t.CEREAL_SAVE_FUNCTION_NAME(ar, version); }
285 template<
class Archive,
class T>
inline
287 {
return t.CEREAL_LOAD_FUNCTION_NAME(ar, version); }
289 template<
class Archive,
class T>
inline
291 {
return t.CEREAL_SAVE_MINIMAL_FUNCTION_NAME(ar, version); }
293 template<
class Archive,
class T>
inline
295 {
return t.CEREAL_SAVE_MINIMAL_FUNCTION_NAME(ar, version); }
297 template<
class Archive,
class T,
class U>
inline
298 static auto member_load_minimal(Archive
const & ar, T & t, U && u,
const std::uint32_t version) -> decltype(t.CEREAL_LOAD_MINIMAL_FUNCTION_NAME(ar, std::forward<U>(u), version))
299 {
return t.CEREAL_LOAD_MINIMAL_FUNCTION_NAME(ar, std::forward<U>(u), version); }
303 template <
class T>
inline
307 template <
class T,
class ... Args>
inline
310 new (ptr) T( std::forward<Args>( args )... );
314 template <
class T>
inline
320 template <
class T>
inline
322 {
return std::false_type(); }
324 template<
class T,
class Archive>
inline
330 template<
class T,
class Archive>
inline
333 T::load_and_construct( ar,
construct, version );
339 template <
class T>
template <
class ... Args>
inline
343 throw Exception(
"Attempting to construct an already initialized object");
346 itsEnableSharedRestoreFunction();
A class that can be made a friend to give cereal access to non public functions.
Definition: access.hpp:241
static auto member_load(Archive &ar, T &t, const std::uint32_t version) -> decltype(t.CEREAL_LOAD_FUNCTION_NAME(ar, version))
Definition: access.hpp:286
static void construct(T *&ptr, Args &&... args)
Definition: access.hpp:308
static auto load_and_construct(Archive &ar, ::cereal::construct< T > &construct) -> decltype(T::load_and_construct(ar, construct))
Definition: access.hpp:325
static auto member_save_minimal(Archive const &ar, T const &t, const std::uint32_t version) -> decltype(t.CEREAL_SAVE_MINIMAL_FUNCTION_NAME(ar, version))
Definition: access.hpp:290
static auto member_serialize(Archive &ar, T &t, const std::uint32_t version) -> decltype(t.CEREAL_SERIALIZE_FUNCTION_NAME(ar, version))
Definition: access.hpp:274
static std::false_type load_and_construct(...)
Definition: access.hpp:321
static auto member_save(Archive &ar, T const &t, const std::uint32_t version) -> decltype(t.CEREAL_SAVE_FUNCTION_NAME(ar, version))
Definition: access.hpp:278
static auto shared_from_this(T &t) -> decltype(t.shared_from_this())
static auto member_save_non_const(Archive &ar, T &t, const std::uint32_t version) -> decltype(t.CEREAL_SAVE_FUNCTION_NAME(ar, version))
Definition: access.hpp:282
static auto member_save_minimal_non_const(Archive const &ar, T &t, const std::uint32_t version) -> decltype(t.CEREAL_SAVE_MINIMAL_FUNCTION_NAME(ar, version))
Definition: access.hpp:294
static auto load_and_construct(Archive &ar, ::cereal::construct< T > &construct, const std::uint32_t version) -> decltype(T::load_and_construct(ar, construct, version))
Definition: access.hpp:331
static auto member_load(Archive &ar, T &t) -> decltype(t.CEREAL_LOAD_FUNCTION_NAME(ar))
Definition: access.hpp:257
static T * construct()
Definition: access.hpp:315
static auto member_load_minimal(Archive const &ar, T &t, U &&u) -> decltype(t.CEREAL_LOAD_MINIMAL_FUNCTION_NAME(ar, std::forward< U >(u)))
Definition: access.hpp:269
static auto member_save_minimal_non_const(Archive const &ar, T &t) -> decltype(t.CEREAL_SAVE_MINIMAL_FUNCTION_NAME(ar))
Definition: access.hpp:265
static auto member_load_minimal(Archive const &ar, T &t, U &&u, const std::uint32_t version) -> decltype(t.CEREAL_LOAD_MINIMAL_FUNCTION_NAME(ar, std::forward< U >(u), version))
Definition: access.hpp:298
static auto member_save(Archive &ar, T const &t) -> decltype(t.CEREAL_SAVE_FUNCTION_NAME(ar))
Definition: access.hpp:249
static auto member_save_non_const(Archive &ar, T &t) -> decltype(t.CEREAL_SAVE_FUNCTION_NAME(ar))
Definition: access.hpp:253
static auto member_serialize(Archive &ar, T &t) -> decltype(t.CEREAL_SERIALIZE_FUNCTION_NAME(ar))
Definition: access.hpp:245
static auto member_save_minimal(Archive const &ar, T const &t) -> decltype(t.CEREAL_SAVE_MINIMAL_FUNCTION_NAME(ar))
Definition: access.hpp:261
Used to construct types with no default constructor.
Definition: access.hpp:165
T * ptr()
Returns a raw pointer to the initialized underlying object.
Definition: access.hpp:201
construct & operator=(construct const &)=delete
construct(T *p, std::function< void()> enableSharedFunc)
Definition: access.hpp:211
bool itsValid
Definition: access.hpp:218
construct(construct const &)=delete
construct(T *p)
Definition: access.hpp:210
void operator()(Args &&... args)
Construct and initialize the type T with the given arguments.
Definition: access.hpp:340
T * itsPtr
Definition: access.hpp:216
T * operator->()
Get a reference to the initialized underlying object.
Definition: access.hpp:185
std::function< void()> itsEnableSharedRestoreFunction
Definition: access.hpp:217
Internal helper functionality.
Preprocessor macros that can customise the cereal library.
in certain simple scenarios. They should probably not be used if maximizing performance is the main o...
Definition: access.hpp:42
Serialization disambiguation.
unsigned int uint32_t
Definition: stdint.h:126
An exception class thrown when things go wrong at runtime.
Definition: helpers.hpp:49
A class that allows cereal to load smart pointers to types that have no default constructor.
Definition: access.hpp:109