1 #ifndef _SERIALIZE_MAP_HPP 2 #define _SERIALIZE_MAP_HPP 11 #include <yaml-cpp/yaml.h> 13 #include <metaprogramming/CRTP.hpp> 14 #include <serialize/Base.hpp> 15 #include <serialize/Serializable.hpp> 16 #include <tuple/TupleClass.hpp> 18 #include <ios/Logger.hpp> 23 template <
typename...Ts>
27 static_assert((isSerializable<Ts> && ...),
"All arguments need to be Serializable");
30 std::forward_as_tuple(ts...);
34 #define CONST_OR_NOT_SERIALIZABLE_MEMBERS(CONST, 37 auto serializableMembers() 41 std::forward_as_tuple(__VA_ARGS__); 73 const bool& onlyNonDefault=
false)
77 [&node,&onlyNonDefault](
auto& s)
79 s.serialize(node,onlyNonDefault);
94 serialize(node,onlyNonDefault);
111 std::string spurious;
113 for(
auto& subNode : node)
120 const std::string name=
121 subNode.first.as<std::string>();
124 [name,&found](
auto& s)
142 CRASH<<
"Spurious tags: "<<spurious;
149 CRASH<<
"Needs to be a map, is: "<<(node.IsNull()?
"Null":(node.IsScalar()?
"Scalar":(node.IsSequence()?
"Sequence":
"Unknown")));
194 #define DEFINE_SERIALIZABLE_CLASS(T) 196 public SerializableClass<T> 199 #define SERIALIZABLE_CLASS(TYPE,NAME) 200 Serializable<TYPE> NAME{#NAME} 203 #define LIST_SERIALIZABLE_MEMBERS(...) auto _serializableMembers(Ts &&...ts)
Helper function to create the serializable members.
bool deSerialize(const YAML::Node &node)
Convert from a YAML node.
#define CRTP_THIS
Access to the inheriting class.
Binarizer & deBinarize(B &&in)
Convert from binary.
#define CRASH
Initialize the crasher.
#define PROVIDE_CRTP_CAST_OPERATOR(CLASS)
Binarizer & binarize(B &&out={}) const
Convert to binary.
void clear()
Restart to write.
YAML::Node serialize(YAML::Node &node, const bool &onlyNonDefault=false) const
Convert to YAML node.
YAML::Node serialize(const bool &onlyNonDefault=false) const
Convert to YAML node.
void checkNoSpuriousSubNodes(const YAML::Node &node)
Check that no spurious subnodes are contained.
#define CONST_OR_NOT_SERIALIZABLE_MEMBERS(CONST,...)
Provides the class embedding with a serializableMemebers method.
decltype(auto) operator+(T1 &&smet1, T2 &&smet2)
Implement smet1+smet2.
bool isDefault() const
Check if the class is default.
static bool decode(const Node &node, T &rhs)
Decode from a node.
Provides serialization features to a class.
void putToDefault()
Put the class to the default value.