17 #ifndef HH_SENF_Packets_Packet_ 18 #define HH_SENF_Packets_Packet_ 1 21 #include <boost/operators.hpp> 22 #include <boost/utility/enable_if.hpp> 23 #include <boost/type_traits/is_integral.hpp> 133 public boost::equality_comparable<Packet>
166 template <
class PacketType>
180 static std::int32_t
const &
pktCount();
194 template <
class OtherPacket> OtherPacket
next()
const;
200 template <
class OtherPacket> OtherPacket
next(
NoThrow_t)
const;
205 template <
class OtherPacket> OtherPacket
find()
const;
210 template <
class OtherPacket> OtherPacket
find(
NoThrow_t)
const;
222 template <
class OtherPacket> OtherPacket
prev()
const;
228 template <
class OtherPacket> OtherPacket
prev(
NoThrow_t)
const;
233 template <
class OtherPacket> OtherPacket
rfind()
const;
246 template <
class OtherPacket> OtherPacket
first()
const;
252 template <
class OtherPacket> OtherPacket
last()
const;
258 template <
class OtherPacket> OtherPacket
parseNextAs()
const;
283 template <
class OtherPacket>
bool is()
const;
285 template <
class OtherPacket> OtherPacket
const &
as()
const;
293 template <
class OtherPacket> OtherPacket &
as();
294 template <
class OtherPacket> OtherPacket
const &
as(
NoThrow_t)
const;
303 template <
class OtherPacket> OtherPacket &
as(
NoThrow_t);
321 template <
class OtherPacket>
322 OtherPacket
replaceAs(difference_type offset=0, difference_type tailOffset=0);
338 size_type
size()
const;
347 template <
class Annotation>
404 template <
class Annotation>
437 template <
class Other>
510 unsigned long id()
const;
518 void memDebug(std::ostream & os)
const;
535 static std::int32_t pktCount_;
537 template <
class PacketType>
581 template <
class PacketType>
590 typedef typename PacketType::parser
Parser;
638 template <
class ForwardReadableRange>
640 ForwardReadableRange
const & range,
641 typename boost::disable_if< boost::is_integral<ForwardReadableRange> >::type * = 0);
643 template <
class ForwardReadableRange>
721 template <
class ForwardReadableRange>
724 ForwardReadableRange
const & range,
725 typename boost::disable_if< boost::is_integral<ForwardReadableRange> >::type * = 0);
727 template <
class ForwardReadableRange>
729 ForwardReadableRange
const & range);
827 template <
class OtherPacket>
836 interpreter *
ptr()
const;
849 template <
class PacketType,
class Parser>
850 Parser operator<<(Parser target, ConcretePacket<PacketType>
const & packet);
854 #ifdef SENF_CXX11_ENABLED 855 # define SENF_PACKET_PREVENT_TEMPLATE_INSTANTIATION(Packet) \ 856 extern template class senf::ConcretePacket<Packet##Type>; \ 857 extern template class senf::PacketInterpreter<Packet##Type>; 858 # define SENF_PACKET_INSTANTIATE_TEMPLATE(Packet) \ 859 template class senf::ConcretePacket<Packet##Type>; \ 860 template class senf::PacketInterpreter<Packet##Type>; 862 # define SENF_PACKET_PREVENT_TEMPLATE_INSTANTIATION(Packet) 863 # define SENF_PACKET_INSTANTIATE_TEMPLATE(Packet) 870 #if !defined(HH_SENF_Packets_Packets__decls_) && !defined(HH_SENF_Packets_Packet_i_) 871 #define HH_SENF_Packets_Packet_i_
OtherPacket replaceAs(difference_type offset=0, difference_type tailOffset=0)
Replace the complete packet chain with a new chain.
Packet append(Packet const &packet) const
Append the given packet to this packet.
bool operator==(Packet const &other) const
Check for packet identity.
senf::detail::packet::smart_pointer< PacketInterpreter >::ptr_t ptr
bool is_shared() const
check if this packet shares data with any another packet handle.
static std::int32_t const & pktCount()
OtherPacket rfind() const
Search chain backwards for packet of type OtherPacket.
unspecified_keyword_type parser
std::ostream & operator<<(std::ostream &os, Packet const &packet)
Internal: Concrete packet interpreter.
OtherPacket find() const
Search chain forward for packet of type OtherPacket.
PacketData & data() const
Access the packets raw data container.
Packet last() const
Return last packet in chain.
void type
Type of the packet.
senf::detail::packet::byte byte
senf::detail::packet::difference_type difference_type
Unsigned type to represent packet size.
Protocol specific packet handle.
Packet data STL-sequence view.
OtherPacket const & as() const
Cast current packet to the given type.
raw_container::size_type size_type
PacketInterpreter public header.
void clearAnnotations()
Clear all packet annotations.
Packet next() const
Get next packet in chain.
void memDebug(std::ostream &os) const
senf::detail::packet::size_type size_type
Packet & operator=(Packet const &)
OtherPacket parseNextAs() const
Interpret payload of this as OtherPacket.
PacketType::parser Parser
senf::detail::packet::smart_pointer< PacketInterpreterBase >::ptr_t ptr
Annotation & annotation()
Get packet annotation.
void reparse() const
Reparse the payload the packet.
PacketInterpreterBase::ptr getNext(PacketInterpreterBase::optional_range const &range) const
void dump(std::ostream &os, DumpPacketAnnotations_t dumpAnnotationsSwitch=dumpAnnotations) const
Write out a printable packet representation.
Packet clone() const
Create copy packet.
unsigned long id() const
Unique packet id.
PacketInterpreterBase::ptr const & ptr() const
ParserProxy(Parser const &p)
void finalizeTo()
Update calculated fields.
Packet first() const
Return first packet in chain.
raw_container::difference_type difference_type
boost::optional< range > optional_range
size_type size() const
Return size of packet in bytes.
friend class ConcretePacket
TypeIdValue typeId() const
Get type of this packet.
void finalizeThis()
Update calculated fields.
PacketInterpreterBase::factory_t factory_t
Packet factory type (see below)
void finalizeAll()
Update calculated fields.
Packet prev() const
Get previous packet in chain.
factory_t factory() const
Return factory instance of this packet.
Packet()
Create uninitialized packet handle.
bool is() const
Check, whether this packet is of the given type.
bool boolean_test() const
Check, whether the packet is valid() (not null)
Factory const * factory_t