Changeset View
Changeset View
Standalone View
Standalone View
src/serialize.h
Show First 20 Lines • Show All 146 Lines • ▼ Show 20 Lines | |||||
enum { | enum { | ||||
// primary actions | // primary actions | ||||
SER_NETWORK = (1 << 0), | SER_NETWORK = (1 << 0), | ||||
SER_DISK = (1 << 1), | SER_DISK = (1 << 1), | ||||
SER_GETHASH = (1 << 2), | SER_GETHASH = (1 << 2), | ||||
}; | }; | ||||
//! Convert the reference base type to X, without changing constness or | |||||
//! reference type. | |||||
template <typename X> X &ReadWriteAsHelper(X &x) { | |||||
return x; | |||||
} | |||||
template <typename X> const X &ReadWriteAsHelper(const X &x) { | |||||
return x; | |||||
} | |||||
#define READWRITE(...) (::SerReadWriteMany(s, ser_action, __VA_ARGS__)) | #define READWRITE(...) (::SerReadWriteMany(s, ser_action, __VA_ARGS__)) | ||||
#define READWRITEAS(type, obj) \ | |||||
(::SerReadWriteMany(s, ser_action, ReadWriteAsHelper<type>(obj))) | |||||
/** | /** | ||||
* Implement three methods for serializable objects. These are actually wrappers | * Implement three methods for serializable objects. These are actually wrappers | ||||
* over "SerializationOp" template, which implements the body of each class' | * over "SerializationOp" template, which implements the body of each class' | ||||
* serialization code. Adding "ADD_SERIALIZE_METHODS" in the body of the class | * serialization code. Adding "ADD_SERIALIZE_METHODS" in the body of the class | ||||
* causes these wrappers to be added as members. | * causes these wrappers to be added as members. | ||||
*/ | */ | ||||
#define ADD_SERIALIZE_METHODS \ | #define ADD_SERIALIZE_METHODS \ | ||||
▲ Show 20 Lines • Show All 742 Lines • Show Last 20 Lines |