X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Packets%2FMPEGDVBBundle%2FTLVPacket.hh;h=f81eafd99b224ea72a71ca7297975603692c6aeb;hb=ab243554f940af9f873e1a920d0a6b7886c6f5cf;hp=a1b3628d463050ef9501ac523148acfe47aa4e21;hpb=3338998867a4d76adb58e93bd12ab8ff2a0cf4df;p=senf.git diff --git a/Packets/MPEGDVBBundle/TLVPacket.hh b/Packets/MPEGDVBBundle/TLVPacket.hh index a1b3628..f81eafd 100644 --- a/Packets/MPEGDVBBundle/TLVPacket.hh +++ b/Packets/MPEGDVBBundle/TLVPacket.hh @@ -28,9 +28,7 @@ // Custom includes #include -#include "../../Packets/PacketType.hh" -#include "../../Packets/ParseInt.hh" -#include "../../Packets/PacketParser.hh" +#include "../../Packets/Packets.hh" //#include "TLVPacket.mpp" ///////////////////////////////hh.p//////////////////////////////////////// @@ -44,18 +42,28 @@ namespace senf { } }; - struct Parse_TLVPacketLength + class Parse_TLVPacketLength : public detail::packet::ParseIntOps, public PacketParserBase { -# ifndef DOXYGEN - - SENF_PACKET_PARSER_NO_INIT(Parse_TLVPacketLength); - -# endif + public: + Parse_TLVPacketLength(data_iterator i, state_type s) : PacketParserBase(i,s) {} typedef boost::uint32_t value_type; + + value_type value() const; + + void value(value_type const & v); + Parse_TLVPacketLength const & operator= (value_type other); + + static const size_type init_bytes = 1; + + size_type bytes() const; + + void init() const; + + private: typedef Parse_Flag < 0 > Parse_extended_length_flag; typedef Parse_UIntField < 1, 8 > Parse_fixed_length; @@ -67,37 +75,7 @@ namespace senf { return parse( 0 ); } - value_type value() const { - switch( bytes() ) { - case 1: - return fixed_length_field().value(); - case 2: - return parse( 1 ).value(); - case 3: - return parse( 1 ).value(); - case 4: - return parse( 1 ).value(); - case 5: - return parse( 1 ).value(); - default: - throw(UnsuportedTLVPacketException()); - }; - } - - static const size_type init_bytes = 1; - - size_type bytes() const { - if ( extended_length_flag() ) - return 1 + fixed_length_field(); - else - return 1; - } - - void init() const { - defaultInit(); - extended_length_flag() = 0; - } - + void resize(size_type size); }; /** \brief parse TLVPacket Packet @@ -108,16 +86,12 @@ namespace senf { */ struct Parse_TLVPacket : public PacketParserBase { -# ifndef DOXYGEN +# include SENF_PARSER() - SENF_PACKET_PARSER_INIT(Parse_TLVPacket); + SENF_PARSER_FIELD( type, Parse_UInt32 ); + SENF_PARSER_FIELD( length, Parse_TLVPacketLength ); - SENF_PACKET_PARSER_DEFINE_FIELDS( - ((Field)( type, Parse_UInt32 )) - ((Field)( length, Parse_TLVPacketLength )) - ); - -# endif + SENF_PARSER_FINALIZE(Parse_TLVPacket); }; /** \brief TLV Packet @@ -137,7 +111,9 @@ namespace senf { typedef Parse_TLVPacket parser; static optional_range nextPacketRange(packet p); - + static void init(packet p); + static size_type initSize(); + static void finalize(packet p); static void dump(packet p, std::ostream & os); };