template<typename C, typename S>
struct CompoundDef: public CompoundTypeDef<C>
{
- S *serializer;
+ S serializer;
CompoundDef(const S &);
- virtual ~CompoundDef();
virtual std::string describe() const;
virtual char *serialize(const C &, char *, char *) const;
const CompoundTypeDef<P> &get_compound() const { return *compound; }
- virtual std::string describe() const;
+ virtual std::string describe() const { return compound->describe(); }
char *serialize(const P &, char *, char *) const;
const char *deserialize(P &, const char *, const char *) const;
virtual const char *dispatch(ReceiverBase &, const char *, const char *) const;
template<typename C, typename S>
Protocol::CompoundDef<C, S>::CompoundDef(const S &s):
- serializer(new S(s))
+ serializer(s)
{ }
-template<typename C, typename S>
-Protocol::CompoundDef<C, S>::~CompoundDef()
-{
- delete serializer;
-}
-
template<typename C, typename S>
std::string Protocol::CompoundDef<C, S>::describe() const
{
- return "{"+serializer->describe()+"}";
+ return "{"+serializer.describe()+"}";
}
template<typename C, typename S>
char *Protocol::CompoundDef<C, S>::serialize(const C &com, char *buf, char *end) const
{
- return serializer->serialize(com, buf, end);
+ return serializer.serialize(com, buf, end);
}
template<typename C, typename S>
const char *Protocol::CompoundDef<C, S>::deserialize(C &com, const char *buf, const char *end) const
{
- return serializer->deserialize(com, buf, end);
+ return serializer.deserialize(com, buf, end);
}
}
template<typename P, typename Head, typename S>
-char * Protocol::Serializer<P, Head, S>::serialize(const P &pkt, char *buf, char *end) const
+char *Protocol::Serializer<P, Head, S>::serialize(const P &pkt, char *buf, char *end) const
{
buf = Head::serialize(pkt, buf, end);
return ser.serialize(pkt.*ptr, buf, end);
}
template<typename P, typename Head, typename S>
-const char * Protocol::Serializer<P, Head, S>::deserialize(P &pkt, const char *buf, const char *end) const
+const char *Protocol::Serializer<P, Head, S>::deserialize(P &pkt, const char *buf, const char *end) const
{
buf = Head::deserialize(pkt, buf, end);
return ser.deserialize(pkt.*ptr, buf, end);
compound = new CompoundDef<P, S>(ser);
}
-template<typename P>
-std::string Protocol::PacketTypeDef<P>::describe() const
-{
- return compound->describe();
-}
-
template<typename P>
char *Protocol::PacketTypeDef<P>::serialize(const P &pkt, char *buf, char *end) const
{