public:
PacketDefBuilder(const Protocol &, PacketTypeDef<P> &, const S &);
-
+
template<typename T>
- PacketDefBuilder<P, typename S::template Next<T>> operator()(T P::*);
+ PacketDefBuilder<P, typename S::template Next<T>> fields(T P::*);
+
+ template<typename T1, typename T2, typename... Rest>
+ auto fields(T1 P::*first, T2 P::*second, Rest P::*...rest) { return fields(first).fields(second, rest...); }
};
struct PacketHeader
template<typename P>
PacketDefBuilder<P, Serializer<P>> add(unsigned);
+ template<typename P, typename T, typename... Rest>
+ auto add(unsigned id, T P::*field, Rest P::*...rest) { return add<P>(id).fields(field, rest...); }
+
template<typename P>
PacketDefBuilder<P, Serializer<P>> add();
+ template<typename P, typename T, typename... Rest>
+ auto add(T P::*field, Rest P::*...rest) { return add<P>().fields(field, rest...); }
+
const PacketDefBase &get_packet_by_class_id(unsigned) const;
const PacketDefBase &get_packet_by_id(unsigned) const;
template<typename P, typename S>
template<typename T>
-Protocol::PacketDefBuilder<P, typename S::template Next<T>> Protocol::PacketDefBuilder<P, S>::operator()(T P::*ptr)
+Protocol::PacketDefBuilder<P, typename S::template Next<T>> Protocol::PacketDefBuilder<P, S>::fields(T P::*ptr)
{
typename S::template Next<T> next_ser(serializer, ptr, protocol);
pktdef.set_serializer(next_ser);
Protocol::Protocol()
{
- add<Packet1>()(&Packet1::value);
- add<Packet2>()(&Packet2::value);
- add<Packet3>()(&Packet3::values);
- add<Packet4>()(&Packet4::sub1)(&Packet4::sub2);
+ add<Packet1>(&Packet1::value);
+ add<Packet2>(&Packet2::value);
+ add<Packet3>(&Packet3::values);
+ add<Packet4>(&Packet4::sub1, &Packet4::sub2);
}
template<typename T>