Skip to content

Commit

Permalink
Remove old serialization primitives
Browse files Browse the repository at this point in the history
  • Loading branch information
sipa authored and furszy committed Jul 3, 2021
1 parent 060d62b commit bd4b846
Showing 1 changed file with 1 addition and 39 deletions.
40 changes: 1 addition & 39 deletions src/serialize.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,26 +52,6 @@ static const unsigned int MAX_VECTOR_ALLOCATE = 5000000;
struct deserialize_type {};
constexpr deserialize_type deserialize {};

/**
* Used to bypass the rule against non-const reference to temporary
* where it makes sense with wrappers.
*/
template <typename T>
inline T& REF(const T& val)
{
return const_cast<T&>(val);
}

/**
* Used to acquire a non-const pointer "this" to generate bodies
* of const serialization operations from a template
*/
template <typename T>
inline T* NCONST_PTR(const T* val)
{
return const_cast<T*>(val);
}

//! Safely convert odd char pointer types to standard ones.
inline char* CharCast(char* c) { return c; }
inline char* CharCast(unsigned char* c) { return (char*)c; }
Expand Down Expand Up @@ -190,24 +170,6 @@ template<typename X> const X& ReadWriteAsHelper(const X& x) { return x; }
#define SER_READ(obj, code) ::SerRead(s, ser_action, obj, [&](Stream& s, typename std::remove_const<Type>::type& obj) { code; })
#define SER_WRITE(obj, code) ::SerWrite(s, ser_action, obj, [&](Stream& s, const Type& obj) { code; })

/**
* Implement three methods for serializable objects. These are actually wrappers over
* "SerializationOp" template, which implements the body of each class' serialization
* code. Adding "ADD_SERIALIZE_METHODS" in the body of the class causes these wrappers to be
* added as members.
*/
#define ADD_SERIALIZE_METHODS \
template <typename Stream> \
void Serialize(Stream& s) const \
{ \
NCONST_PTR(this)->SerializationOp(s, CSerActionSerialize()); \
} \
template <typename Stream> \
void Unserialize(Stream& s) \
{ \
SerializationOp(s, CSerActionUnserialize()); \
}

/**
* Implement the Ser and Unser methods needed for implementing a formatter (see Using below).
*
Expand Down Expand Up @@ -1136,7 +1098,7 @@ void Unserialize(Stream& is, std::shared_ptr<T>& p)
}

/**
* Support for ADD_SERIALIZE_METHODS and READWRITE macro
* Support for SERIALIZE_METHODS and READWRITE macro.
*/
struct CSerActionSerialize {
constexpr bool ForRead() const { return false; }
Expand Down

0 comments on commit bd4b846

Please sign in to comment.