mirror of
https://github.com/USCiLab/cereal.git
synced 2025-10-18 01:45:52 +02:00
2
Makefile
2
Makefile
@@ -1,4 +1,4 @@
|
|||||||
CPPFLAGS=-std=c++11 -I./include -Wall -Werror -g -Wextra -Wshadow
|
CPPFLAGS=-std=c++11 -I./include -Wall -Werror -g -Wextra -Wshadow -pedantic
|
||||||
CXX=g++
|
CXX=g++
|
||||||
COVERAGE_OUTPUT=out
|
COVERAGE_OUTPUT=out
|
||||||
|
|
||||||
|
|||||||
@@ -148,7 +148,7 @@ namespace cereal
|
|||||||
} // namespace cereal
|
} // namespace cereal
|
||||||
|
|
||||||
// register archives for polymorphic support
|
// register archives for polymorphic support
|
||||||
CEREAL_REGISTER_ARCHIVE(cereal::BinaryOutputArchive);
|
CEREAL_REGISTER_ARCHIVE(cereal::BinaryOutputArchive)
|
||||||
CEREAL_REGISTER_ARCHIVE(cereal::BinaryInputArchive);
|
CEREAL_REGISTER_ARCHIVE(cereal::BinaryInputArchive)
|
||||||
|
|
||||||
#endif // CEREAL_ARCHIVES_BINARY_HPP_
|
#endif // CEREAL_ARCHIVES_BINARY_HPP_
|
||||||
|
|||||||
@@ -765,7 +765,7 @@ namespace cereal
|
|||||||
} // namespace cereal
|
} // namespace cereal
|
||||||
|
|
||||||
// register archives for polymorphic support
|
// register archives for polymorphic support
|
||||||
CEREAL_REGISTER_ARCHIVE(cereal::JSONInputArchive);
|
CEREAL_REGISTER_ARCHIVE(cereal::JSONInputArchive)
|
||||||
CEREAL_REGISTER_ARCHIVE(cereal::JSONOutputArchive);
|
CEREAL_REGISTER_ARCHIVE(cereal::JSONOutputArchive)
|
||||||
|
|
||||||
#endif // CEREAL_ARCHIVES_JSON_HPP_
|
#endif // CEREAL_ARCHIVES_JSON_HPP_
|
||||||
|
|||||||
@@ -228,7 +228,7 @@ namespace cereal
|
|||||||
} // namespace cereal
|
} // namespace cereal
|
||||||
|
|
||||||
// register archives for polymorphic support
|
// register archives for polymorphic support
|
||||||
CEREAL_REGISTER_ARCHIVE(cereal::PortableBinaryOutputArchive);
|
CEREAL_REGISTER_ARCHIVE(cereal::PortableBinaryOutputArchive)
|
||||||
CEREAL_REGISTER_ARCHIVE(cereal::PortableBinaryInputArchive);
|
CEREAL_REGISTER_ARCHIVE(cereal::PortableBinaryInputArchive)
|
||||||
|
|
||||||
#endif // CEREAL_ARCHIVES_PORTABLE_BINARY_HPP_
|
#endif // CEREAL_ARCHIVES_PORTABLE_BINARY_HPP_
|
||||||
|
|||||||
@@ -778,7 +778,7 @@ namespace cereal
|
|||||||
} // namespace cereal
|
} // namespace cereal
|
||||||
|
|
||||||
// register archives for polymorphic support
|
// register archives for polymorphic support
|
||||||
CEREAL_REGISTER_ARCHIVE(cereal::XMLOutputArchive);
|
CEREAL_REGISTER_ARCHIVE(cereal::XMLOutputArchive)
|
||||||
CEREAL_REGISTER_ARCHIVE(cereal::XMLInputArchive);
|
CEREAL_REGISTER_ARCHIVE(cereal::XMLInputArchive)
|
||||||
|
|
||||||
#endif // CEREAL_ARCHIVES_XML_HPP_
|
#endif // CEREAL_ARCHIVES_XML_HPP_
|
||||||
|
|||||||
@@ -340,7 +340,7 @@ namespace cereal
|
|||||||
|
|
||||||
See the documentation for the other functions to try and understand this */
|
See the documentation for the other functions to try and understand this */
|
||||||
template <class T>
|
template <class T>
|
||||||
void instantiate_polymorphic_binding( T*, int, adl_tag ) {};
|
void instantiate_polymorphic_binding( T*, int, adl_tag ) {}
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
} // namespace cereal
|
} // namespace cereal
|
||||||
|
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ namespace cereal
|
|||||||
}; \
|
}; \
|
||||||
} /* end namespace detail */ \
|
} /* end namespace detail */ \
|
||||||
template <class T, class A> \
|
template <class T, class A> \
|
||||||
struct has_member_##name : std::integral_constant<bool, detail::has_member_##name##_impl<T, A>::value> {};
|
struct has_member_##name : std::integral_constant<bool, detail::has_member_##name##_impl<T, A>::value> {}
|
||||||
|
|
||||||
//! Creates a test for whether a non const non-member function exists
|
//! Creates a test for whether a non const non-member function exists
|
||||||
/*! This creates a class derived from std::integral_constant that will be true if
|
/*! This creates a class derived from std::integral_constant that will be true if
|
||||||
@@ -79,7 +79,7 @@ namespace cereal
|
|||||||
}; \
|
}; \
|
||||||
} /* end namespace detail */ \
|
} /* end namespace detail */ \
|
||||||
template <class T, class A> \
|
template <class T, class A> \
|
||||||
struct has_non_member_##name : std::integral_constant<bool, detail::has_non_member_##name##_impl<T, A>::value> {};
|
struct has_non_member_##name : std::integral_constant<bool, detail::has_non_member_##name##_impl<T, A>::value> {}
|
||||||
|
|
||||||
//! Creates a test for whether a non const member function exists with a version parameter
|
//! Creates a test for whether a non const member function exists with a version parameter
|
||||||
/*! This creates a class derived from std::integral_constant that will be true if
|
/*! This creates a class derived from std::integral_constant that will be true if
|
||||||
@@ -98,7 +98,7 @@ namespace cereal
|
|||||||
}; \
|
}; \
|
||||||
} /* end namespace detail */ \
|
} /* end namespace detail */ \
|
||||||
template <class T, class A> \
|
template <class T, class A> \
|
||||||
struct has_member_versioned_##name : std::integral_constant<bool, detail::has_member_versioned_##name##_impl<T, A>::value> {};
|
struct has_member_versioned_##name : std::integral_constant<bool, detail::has_member_versioned_##name##_impl<T, A>::value> {}
|
||||||
|
|
||||||
//! Creates a test for whether a non const non-member function exists with a version parameter
|
//! Creates a test for whether a non const non-member function exists with a version parameter
|
||||||
/*! This creates a class derived from std::integral_constant that will be true if
|
/*! This creates a class derived from std::integral_constant that will be true if
|
||||||
@@ -117,7 +117,7 @@ namespace cereal
|
|||||||
}; \
|
}; \
|
||||||
} /* end namespace detail */ \
|
} /* end namespace detail */ \
|
||||||
template <class T, class A> \
|
template <class T, class A> \
|
||||||
struct has_non_member_versioned_##name : std::integral_constant<bool, detail::has_non_member_versioned_##name##_impl<T, A>::value> {};
|
struct has_non_member_versioned_##name : std::integral_constant<bool, detail::has_non_member_versioned_##name##_impl<T, A>::value> {}
|
||||||
|
|
||||||
// ######################################################################
|
// ######################################################################
|
||||||
// Member load_and_allocate
|
// Member load_and_allocate
|
||||||
|
|||||||
@@ -68,7 +68,7 @@
|
|||||||
static CONSTEXPR char const * name() { return #T; }; \
|
static CONSTEXPR char const * name() { return #T; }; \
|
||||||
}; \
|
}; \
|
||||||
} } /* end namespaces */ \
|
} } /* end namespaces */ \
|
||||||
CEREAL_BIND_TO_ARCHIVES(T);
|
CEREAL_BIND_TO_ARCHIVES(T)
|
||||||
|
|
||||||
//! Registers a polymorphic type with cereal, giving it a
|
//! Registers a polymorphic type with cereal, giving it a
|
||||||
//! user defined name
|
//! user defined name
|
||||||
@@ -83,7 +83,7 @@
|
|||||||
struct binding_name<T> \
|
struct binding_name<T> \
|
||||||
{ static CONSTEXPR char const * name() { return Name; }; }; \
|
{ static CONSTEXPR char const * name() { return Name; }; }; \
|
||||||
} } /* end namespaces */ \
|
} } /* end namespaces */ \
|
||||||
CEREAL_BIND_TO_ARCHIVES(T);
|
CEREAL_BIND_TO_ARCHIVES(T)
|
||||||
|
|
||||||
namespace cereal
|
namespace cereal
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -289,7 +289,7 @@ struct PoDStructCereal
|
|||||||
void serialize( Archive & ar )
|
void serialize( Archive & ar )
|
||||||
{
|
{
|
||||||
ar(a, b, c, d);
|
ar(a, b, c, d);
|
||||||
};
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct PoDStructBoost
|
struct PoDStructBoost
|
||||||
@@ -303,7 +303,7 @@ struct PoDStructBoost
|
|||||||
void serialize( Archive & ar, const unsigned int /*version*/ )
|
void serialize( Archive & ar, const unsigned int /*version*/ )
|
||||||
{
|
{
|
||||||
ar & a & b & c & d;
|
ar & a & b & c & d;
|
||||||
};
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct PoDChildCereal : virtual PoDStructCereal
|
struct PoDChildCereal : virtual PoDStructCereal
|
||||||
@@ -317,7 +317,7 @@ struct PoDChildCereal : virtual PoDStructCereal
|
|||||||
void serialize( Archive & ar )
|
void serialize( Archive & ar )
|
||||||
{
|
{
|
||||||
ar( cereal::virtual_base_class<PoDStructCereal>(this), v );
|
ar( cereal::virtual_base_class<PoDStructCereal>(this), v );
|
||||||
};
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct PoDChildBoost : virtual PoDStructBoost
|
struct PoDChildBoost : virtual PoDStructBoost
|
||||||
@@ -332,7 +332,7 @@ struct PoDChildBoost : virtual PoDStructBoost
|
|||||||
{
|
{
|
||||||
ar & boost::serialization::base_object<PoDStructBoost>(*this);
|
ar & boost::serialization::base_object<PoDStructBoost>(*this);
|
||||||
ar & v;
|
ar & v;
|
||||||
};
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
|
|||||||
10
sandbox.cpp
10
sandbox.cpp
@@ -104,7 +104,7 @@ namespace cereal
|
|||||||
template <class Archive> struct specialize<Archive, Derived, cereal::specialization::member_load_save> {};
|
template <class Archive> struct specialize<Archive, Derived, cereal::specialization::member_load_save> {};
|
||||||
}
|
}
|
||||||
|
|
||||||
CEREAL_REGISTER_TYPE(Derived);
|
CEREAL_REGISTER_TYPE(Derived)
|
||||||
|
|
||||||
// ###################################
|
// ###################################
|
||||||
struct Test1
|
struct Test1
|
||||||
@@ -235,7 +235,7 @@ struct EmptyStruct
|
|||||||
void serialize(Archive &)
|
void serialize(Archive &)
|
||||||
{
|
{
|
||||||
std::cout << "Side effects!" << std::endl;
|
std::cout << "Side effects!" << std::endl;
|
||||||
};
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct NonEmptyStruct
|
struct NonEmptyStruct
|
||||||
@@ -776,7 +776,7 @@ int main()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
CEREAL_CLASS_VERSION(BoostTransitionMS, 1);
|
CEREAL_CLASS_VERSION(BoostTransitionMS, 1)
|
||||||
CEREAL_CLASS_VERSION(BoostTransitionSplit, 2);
|
CEREAL_CLASS_VERSION(BoostTransitionSplit, 2)
|
||||||
CEREAL_CLASS_VERSION(BoostTransitionNMS, 3);
|
CEREAL_CLASS_VERSION(BoostTransitionNMS, 3)
|
||||||
// keep the other at default version (0)
|
// keep the other at default version (0)
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ struct MyType : public Base
|
|||||||
ar( cereal::base_class<Base>( this ) );
|
ar( cereal::base_class<Base>( this ) );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
CEREAL_REGISTER_TYPE(MyType);
|
CEREAL_REGISTER_TYPE(MyType)
|
||||||
|
|
||||||
struct YourType : public Base
|
struct YourType : public Base
|
||||||
{
|
{
|
||||||
@@ -97,7 +97,7 @@ struct YourType : public Base
|
|||||||
ar( x );
|
ar( x );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
CEREAL_REGISTER_TYPE(YourType);
|
CEREAL_REGISTER_TYPE(YourType)
|
||||||
|
|
||||||
struct OurBase
|
struct OurBase
|
||||||
{
|
{
|
||||||
@@ -159,7 +159,7 @@ struct TestType
|
|||||||
void serialize( Archive & ar )
|
void serialize( Archive & ar )
|
||||||
{
|
{
|
||||||
ar( x );
|
ar( x );
|
||||||
};
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace cereal
|
namespace cereal
|
||||||
@@ -180,7 +180,7 @@ struct BBB : AAA
|
|||||||
void serialize( Archive & ) {}
|
void serialize( Archive & ) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
CEREAL_REGISTER_TYPE(BBB);
|
CEREAL_REGISTER_TYPE(BBB)
|
||||||
|
|
||||||
template <class T> void nop(T&&) {}
|
template <class T> void nop(T&&) {}
|
||||||
|
|
||||||
|
|||||||
@@ -2816,7 +2816,7 @@ std::ostream& operator<<(std::ostream& os, PolyDerived const & s)
|
|||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
CEREAL_REGISTER_TYPE(PolyDerived);
|
CEREAL_REGISTER_TYPE(PolyDerived)
|
||||||
|
|
||||||
template <class IArchive, class OArchive>
|
template <class IArchive, class OArchive>
|
||||||
void test_polymorphic()
|
void test_polymorphic()
|
||||||
|
|||||||
Reference in New Issue
Block a user