From: tho Date: Mon, 17 Dec 2007 14:41:04 +0000 (+0000) Subject: renamed all parsers from parse_X to XParser. X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=a1001797645cc68c869ef296f5e9ba13aa8e80c4;p=senf.git renamed all parsers from parse_X to XParser. git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@571 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/Packets/ParseArray.ct b/Packets/ArrayParser.ct similarity index 88% rename from Packets/ParseArray.ct rename to Packets/ArrayParser.ct index 087f371..ba07050 100644 --- a/Packets/ParseArray.ct +++ b/Packets/ArrayParser.ct @@ -21,9 +21,9 @@ // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /** \file - \brief ParseArray non-inline template implementation */ + \brief ArrayParser non-inline template implementation */ -#include "ParseArray.ih" +#include "ArrayParser.ih" // Custom includes @@ -31,10 +31,10 @@ ///////////////////////////////ct.p//////////////////////////////////////// /////////////////////////////////////////////////////////////////////////// -// senf::Parse_Array +// senf::ArrayParser template -prefix_ void senf::Parse_Array::init() +prefix_ void senf::ArrayParser::init() const { iterator i (begin()); diff --git a/Packets/ParseArray.cti b/Packets/ArrayParser.cti similarity index 67% rename from Packets/ParseArray.cti rename to Packets/ArrayParser.cti index ee2732d..8ed78e1 100644 --- a/Packets/ParseArray.cti +++ b/Packets/ArrayParser.cti @@ -21,9 +21,9 @@ // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /** \file - \brief ParseArray inline template implementation */ + \brief ArrayParser inline template implementation */ -#include "ParseArray.ih" +#include "ArrayParser.ih" // Custom includes @@ -31,41 +31,41 @@ ///////////////////////////////cti.p/////////////////////////////////////// /////////////////////////////////////////////////////////////////////////// -// senf::Parse_Array +// senf::ArrayParser template -prefix_ senf::Parse_Array::Parse_Array(data_iterator i, state_type s) +prefix_ senf::ArrayParser::ArrayParser(data_iterator i, state_type s) : PacketParserBase(i,s,fixed_bytes) {} // Container interface template -prefix_ typename senf::Parse_Array::size_type -senf::Parse_Array::size() +prefix_ typename senf::ArrayParser::size_type +senf::ArrayParser::size() { return elements; } template -prefix_ typename senf::Parse_Array::iterator -senf::Parse_Array::begin() +prefix_ typename senf::ArrayParser::iterator +senf::ArrayParser::begin() const { return iterator(i(),state()); } template -prefix_ typename senf::Parse_Array::iterator -senf::Parse_Array::end() +prefix_ typename senf::ArrayParser::iterator +senf::ArrayParser::end() const { return iterator(boost::next(i(),fixed_bytes),state()); } template -prefix_ typename senf::Parse_Array::value_type -senf::Parse_Array::operator[](difference_type i) +prefix_ typename senf::ArrayParser::value_type +senf::ArrayParser::operator[](difference_type i) const { BOOST_ASSERT( i>=0 && i < difference_type(elements) ); @@ -73,22 +73,22 @@ senf::Parse_Array::operator[](difference_type i) } /////////////////////////////////////////////////////////////////////////// -// senf::detail::Parse_Array_iterator +// senf::detail::ArrayParser_iterator template -prefix_ senf::detail::Parse_Array_iterator::Parse_Array_iterator() +prefix_ senf::detail::ArrayParser_iterator::ArrayParser_iterator() : i_() {} template -prefix_ senf::detail::Parse_Array_iterator:: -Parse_Array_iterator(PacketParserBase::data_iterator const & i, PacketParserBase::state_type s) +prefix_ senf::detail::ArrayParser_iterator:: +ArrayParser_iterator(PacketParserBase::data_iterator const & i, PacketParserBase::state_type s) : i_(i), s_(s) {} template prefix_ ElementParser -senf::detail::Parse_Array_iterator::operator[](int i) +senf::detail::ArrayParser_iterator::operator[](int i) const { return (*this+i).dereference(); @@ -96,7 +96,7 @@ senf::detail::Parse_Array_iterator::operator[](int i) template prefix_ senf::PacketParserBase::data_iterator -senf::detail::Parse_Array_iterator::raw() +senf::detail::ArrayParser_iterator::raw() const { return i_; @@ -106,7 +106,7 @@ senf::detail::Parse_Array_iterator::raw() template prefix_ ElementParser -senf::detail::Parse_Array_iterator::dereference() +senf::detail::ArrayParser_iterator::dereference() const { return ElementParser(i_,s_); @@ -114,35 +114,35 @@ senf::detail::Parse_Array_iterator::dereference() template prefix_ bool -senf::detail::Parse_Array_iterator:: -equal(Parse_Array_iterator const & other) +senf::detail::ArrayParser_iterator:: +equal(ArrayParser_iterator const & other) const { return i_==other.i_; } template -prefix_ int senf::detail::Parse_Array_iterator:: -distance_to(Parse_Array_iterator const & other) +prefix_ int senf::detail::ArrayParser_iterator:: +distance_to(ArrayParser_iterator const & other) const { return (other.i_-i_)/ElementParser::fixed_bytes; } template -prefix_ void senf::detail::Parse_Array_iterator::increment() +prefix_ void senf::detail::ArrayParser_iterator::increment() { i_ += ElementParser::fixed_bytes; } template -prefix_ void senf::detail::Parse_Array_iterator::decrement() +prefix_ void senf::detail::ArrayParser_iterator::decrement() { i_ -= ElementParser::fixed_bytes; } template -prefix_ void senf::detail::Parse_Array_iterator::advance(int n) +prefix_ void senf::detail::ArrayParser_iterator::advance(int n) { i_ += n*ElementParser::fixed_bytes; } diff --git a/Packets/ParseArray.hh b/Packets/ArrayParser.hh similarity index 85% rename from Packets/ParseArray.hh rename to Packets/ArrayParser.hh index b7e40bd..4f8943e 100644 --- a/Packets/ParseArray.hh +++ b/Packets/ArrayParser.hh @@ -21,10 +21,10 @@ // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /** \file - \brief ParseArray public header */ + \brief ArrayParser public header */ -#ifndef HH_ParseArray_ -#define HH_ParseArray_ 1 +#ifndef HH_ArrayParser_ +#define HH_ArrayParser_ 1 /** \defgroup parsecollection Collection parsers @@ -53,16 +53,16 @@ // Custom includes #include "PacketParser.hh" -//#include "ParseArray.mpp" +//#include "ArrayParser.mpp" ///////////////////////////////hh.p//////////////////////////////////////// namespace senf { - namespace detail { template class Parse_Array_iterator; } + namespace detail { template class ArrayParser_iterator; } /** \brief Fixed size collection of fixed size elements - Parse_Array will parse a sequence of fixed size parsers. The number of array + ArrayParser will parse a sequence of fixed size parsers. The number of array elements is given by the \e elements template parameter and is fixed at compile time. Each element will be parsed by \a ElementParser, which can be any fixed size @@ -72,9 +72,9 @@ namespace senf { \ingroup parsecollection */ template - struct Parse_Array : public PacketParserBase + struct ArrayParser : public PacketParserBase { - Parse_Array(data_iterator i, state_type s); + ArrayParser(data_iterator i, state_type s); static size_type const fixed_bytes = elements*ElementParser::fixed_bytes; @@ -84,7 +84,7 @@ namespace senf { // Container interface typedef ElementParser value_type; - typedef detail::Parse_Array_iterator iterator; + typedef detail::ArrayParser_iterator iterator; typedef iterator const_iterator; static size_type size(); @@ -97,7 +97,7 @@ namespace senf { /** \brief Define array field - This macro is a special helper to define a senf::Parse_Array type field, a fixed size + This macro is a special helper to define a senf::ArrayParser type field, a fixed size collection of fixed size elements. \param[in] name field name @@ -107,18 +107,18 @@ namespace senf { \ingroup packetparsermacros */ # define SENF_PARSER_ARRAY(name, elt_type, size) \ - typedef senf::Parse_Array BOOST_PP_CAT(name, _array_t); \ + typedef senf::ArrayParser BOOST_PP_CAT(name, _array_t); \ SENF_PARSER_FIELD( name, BOOST_PP_CAT(name, _array_t) ) } ///////////////////////////////hh.e//////////////////////////////////////// #endif -#if !defined(HH_Packets__decls_) && !defined(HH_ParseArray_i_) -#define HH_ParseArray_i_ -//#include "ParseArray.cci" -#include "ParseArray.ct" -#include "ParseArray.cti" +#if !defined(HH_Packets__decls_) && !defined(HH_ArrayParser_i_) +#define HH_ArrayParser_i_ +//#include "ArrayParser.cci" +#include "ArrayParser.ct" +#include "ArrayParser.cti" #endif diff --git a/Packets/ParseArray.ih b/Packets/ArrayParser.ih similarity index 82% rename from Packets/ParseArray.ih rename to Packets/ArrayParser.ih index d07c26f..090270c 100644 --- a/Packets/ParseArray.ih +++ b/Packets/ArrayParser.ih @@ -21,10 +21,10 @@ // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /** \file - \brief ParseArray internal header */ + \brief ArrayParser internal header */ -#ifndef IH_ParseArray_ -#define IH_ParseArray_ 1 +#ifndef IH_ArrayParser_ +#define IH_ArrayParser_ 1 // Custom includes #include @@ -35,19 +35,19 @@ \internal - This is the iterator type used for both Parse_Array and Parse_Vector. It is a model of random + This is the iterator type used for both ArrayParser and VectorParser. It is a model of random access iterator. */ template -class senf::detail::Parse_Array_iterator - : public boost::iterator_facade< Parse_Array_iterator, +class senf::detail::ArrayParser_iterator + : public boost::iterator_facade< ArrayParser_iterator, ElementParser, boost::random_access_traversal_tag, ElementParser > { public: - Parse_Array_iterator(); - Parse_Array_iterator(PacketParserBase::data_iterator const & i, + ArrayParser_iterator(); + ArrayParser_iterator(PacketParserBase::data_iterator const & i, PacketParserBase::state_type s); // Needed to elide the []-proxy of iterator_facade @@ -65,8 +65,8 @@ private: // iterator_facade interface ElementParser dereference() const; - bool equal(Parse_Array_iterator const & other) const; - int distance_to(Parse_Array_iterator const & other) const; + bool equal(ArrayParser_iterator const & other) const; + int distance_to(ArrayParser_iterator const & other) const; void increment(); void decrement(); void advance(int n); diff --git a/Packets/ParseArray.test.cc b/Packets/ArrayParser.test.cc similarity index 79% rename from Packets/ParseArray.test.cc rename to Packets/ArrayParser.test.cc index 2d21600..733be50 100644 --- a/Packets/ParseArray.test.cc +++ b/Packets/ArrayParser.test.cc @@ -22,8 +22,8 @@ // Unit tests -//#include "ParseArray.test.hh" -//#include "ParseArray.test.ih" +//#include "ArrayParser.test.hh" +//#include "ArrayParser.test.ih" // Custom includes #include "Packets.hh" @@ -42,10 +42,10 @@ namespace { { # include SENF_FIXED_PARSER() - typedef senf::Parse_Array<2,senf::Parse_UInt24> Parse_Array2; + typedef senf::ArrayParser<2,senf::UInt24Parser> ArrayParser2; - SENF_PARSER_FIELD( array, Parse_Array2 ); - SENF_PARSER_FIELD( index, senf::Parse_UInt16 ); + SENF_PARSER_FIELD( array, ArrayParser2 ); + SENF_PARSER_FIELD( index, senf::UInt16Parser ); SENF_PARSER_FINALIZE(SomePacketParser); }; @@ -54,31 +54,31 @@ namespace { { # include SENF_FIXED_PARSER() - typedef senf::Parse_Array<1,SomePacketParser> Parse_Array1; + typedef senf::ArrayParser<1,SomePacketParser> ArrayParser1; - SENF_PARSER_FIELD( fields, Parse_Array1 ); + SENF_PARSER_FIELD( fields, ArrayParser1 ); SENF_PARSER_FINALIZE(SomeOtherParser); }; } -BOOST_AUTO_UNIT_TEST(parseArray_test) +BOOST_AUTO_UNIT_TEST(ArrayParser_test) { senf::PacketParserBase::byte data[] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05 }; senf::PacketInterpreterBase::ptr p (senf::PacketInterpreter::create(data)); { - typedef senf::Parse_Array<6,senf::Parse_UInt8> Parse_UInt8Array6; - Parse_UInt8Array6 v (p->data().begin(),&p->data()); + typedef senf::ArrayParser<6,senf::UInt8Parser> UInt8ParserArray6; + UInt8ParserArray6 v (p->data().begin(),&p->data()); BOOST_CHECK_EQUAL( v[0], 0x00 ); BOOST_CHECK_EQUAL( v[5], 0x05 ); BOOST_CHECK_EQUAL( *v.begin(), 0x00 ); BOOST_CHECK_EQUAL( std::distance(v.begin(),v.end()), - Parse_UInt8Array6::difference_type(v.size()) ); + UInt8ParserArray6::difference_type(v.size()) ); BOOST_CHECK_EQUAL( v.size(), 6u ); - Parse_UInt8Array6::iterator i1 (v.begin()); - Parse_UInt8Array6::iterator i2 (v.begin()); + UInt8ParserArray6::iterator i1 (v.begin()); + UInt8ParserArray6::iterator i2 (v.begin()); ++i1; BOOST_CHECK_EQUAL( *i1, 0x01 ); BOOST_CHECK_EQUAL( i1[-1], 0x00 ); diff --git a/Packets/DefaultBundle/EthernetPacket.hh b/Packets/DefaultBundle/EthernetPacket.hh index 0d7cd74..df67fea 100644 --- a/Packets/DefaultBundle/EthernetPacket.hh +++ b/Packets/DefaultBundle/EthernetPacket.hh @@ -43,9 +43,9 @@ namespace senf { \see MACAddress \n EthernetPacket */ - struct Parse_MAC : public PacketParserBase + struct MACAddressParser : public PacketParserBase { - Parse_MAC(data_iterator i, state_type s) : PacketParserBase(i,s,fixed_bytes) {} + MACAddressParser(data_iterator i, state_type s) : PacketParserBase(i,s,fixed_bytes) {} /////////////////////////////////////////////////////////////////////////// @@ -57,7 +57,7 @@ namespace senf { operator value_type () { return value(); } byte & operator[](size_type index) { return *boost::next(i(),index); } - Parse_MAC const & operator= (value_type const & other) { value(other); return *this; } + MACAddressParser const & operator= (value_type const & other) { value(other); return *this; } }; /** \brief Parse an Ethernet packet @@ -66,15 +66,15 @@ namespace senf { \see EthernetPacketType */ - struct Parse_Ethernet : public PacketParserBase + struct EthernetPacketParser : public PacketParserBase { # include SENF_FIXED_PARSER() - SENF_PARSER_FIELD( destination, Parse_MAC ); - SENF_PARSER_FIELD( source, Parse_MAC ); - SENF_PARSER_FIELD( type_length, Parse_UInt16 ); + SENF_PARSER_FIELD( destination, MACAddressParser ); + SENF_PARSER_FIELD( source, MACAddressParser ); + SENF_PARSER_FIELD( type_length, UInt16Parser ); - SENF_PARSER_FINALIZE(Parse_Ethernet); + SENF_PARSER_FINALIZE(EthernetPacketParser); }; /** \brief EtherType registry @@ -95,7 +95,7 @@ namespace senf { \ref EthernetPacket \par Fields: - \ref Parse_Ethernet + \ref EthernetPacketParser \par Associated registries: \ref EtherTypes @@ -112,7 +112,7 @@ namespace senf { #ifndef DOXYGEN typedef PacketTypeMixin mixin; typedef ConcretePacket packet; - typedef Parse_Ethernet parser; + typedef EthernetPacketParser parser; #endif using mixin::nextPacketRange; using mixin::initSize; @@ -132,7 +132,7 @@ namespace senf { \see EthVLanPacketType */ - struct Parse_EthVLan : public PacketParserBase + struct EthVLanPacketParser : public PacketParserBase { # include SENF_FIXED_PARSER() @@ -140,9 +140,9 @@ namespace senf { SENF_PARSER_BITFIELD( cfi, 1, bool ); SENF_PARSER_BITFIELD( vlanId, 12, unsigned ); - SENF_PARSER_FIELD( type, Parse_UInt16 ); + SENF_PARSER_FIELD( type, UInt16Parser ); - SENF_PARSER_FINALIZE(Parse_EthVLan); + SENF_PARSER_FINALIZE(EthVLanPacketParser); }; /** \brief Ethernet VLAN tag @@ -151,7 +151,7 @@ namespace senf { \ref EthVLanPacket \par Fields: - \ref Parse_EthVLan + \ref EthVLanPacketParser \par Associated registries: \ref EtherTypes @@ -168,7 +168,7 @@ namespace senf { #ifndef DOXYGEN typedef PacketTypeMixin mixin; typedef ConcretePacket packet; - typedef Parse_EthVLan parser; + typedef EthVLanPacketParser parser; #endif using mixin::nextPacketRange; using mixin::nextPacketType; diff --git a/Packets/DefaultBundle/IPv4Packet.cc b/Packets/DefaultBundle/IPv4Packet.cc index 8cac8ca..3ddffb9 100644 --- a/Packets/DefaultBundle/IPv4Packet.cc +++ b/Packets/DefaultBundle/IPv4Packet.cc @@ -47,9 +47,9 @@ namespace { } /////////////////////////////////////////////////////////////////////////// -// senf::Parse_IPv4 +// senf::IPv4PacketParser -prefix_ boost::uint16_t senf::Parse_IPv4::calcChecksum() +prefix_ boost::uint16_t senf::IPv4PacketParser::calcChecksum() const { validate(bytes(*this)); diff --git a/Packets/DefaultBundle/IPv4Packet.hh b/Packets/DefaultBundle/IPv4Packet.hh index c047b96..ebde238 100644 --- a/Packets/DefaultBundle/IPv4Packet.hh +++ b/Packets/DefaultBundle/IPv4Packet.hh @@ -39,9 +39,9 @@ namespace senf { \see INet4Address */ - struct Parse_INet4Address : public PacketParserBase + struct INet4AddressParser : public PacketParserBase { - Parse_INet4Address(data_iterator i, state_type s) : PacketParserBase(i,s,fixed_bytes) {} + INet4AddressParser(data_iterator i, state_type s) : PacketParserBase(i,s,fixed_bytes) {} /////////////////////////////////////////////////////////////////////////// @@ -52,7 +52,7 @@ namespace senf { void value(value_type const & v) { std::copy(v.begin(), v.end(), i()); } operator value_type() { return value(); } byte & operator[](size_type index) { return *boost::next(i(),index); } - Parse_INet4Address const & operator= (value_type const & other) + INet4AddressParser const & operator= (value_type const & other) { value(other); return *this; } }; @@ -65,27 +65,27 @@ namespace senf { \todo Implement options */ - struct Parse_IPv4 : public PacketParserBase + struct IPv4PacketParser : public PacketParserBase { # include SENF_FIXED_PARSER() SENF_PARSER_BITFIELD( version, 4, unsigned ); SENF_PARSER_BITFIELD( ihl, 4, unsigned ); - SENF_PARSER_FIELD( tos, Parse_UInt8 ); - SENF_PARSER_FIELD( length, Parse_UInt16 ); - SENF_PARSER_FIELD( identifier, Parse_UInt16 ); + SENF_PARSER_FIELD( tos, UInt8Parser ); + SENF_PARSER_FIELD( length, UInt16Parser ); + SENF_PARSER_FIELD( identifier, UInt16Parser ); SENF_PARSER_BITFIELD( reserved, 1, bool ); SENF_PARSER_BITFIELD( df, 1, bool ); SENF_PARSER_BITFIELD( mf, 1, bool ); SENF_PARSER_BITFIELD( frag, 13, unsigned ); - SENF_PARSER_FIELD( ttl, Parse_UInt8 ); - SENF_PARSER_FIELD( protocol, Parse_UInt8 ); - SENF_PARSER_FIELD( checksum, Parse_UInt16 ); - SENF_PARSER_FIELD( source, Parse_INet4Address ); - SENF_PARSER_FIELD( destination, Parse_INet4Address ); + SENF_PARSER_FIELD( ttl, UInt8Parser ); + SENF_PARSER_FIELD( protocol, UInt8Parser ); + SENF_PARSER_FIELD( checksum, UInt16Parser ); + SENF_PARSER_FIELD( source, INet4AddressParser ); + SENF_PARSER_FIELD( destination, INet4AddressParser ); SENF_PARSER_INIT() { version() = 4; @@ -93,7 +93,7 @@ namespace senf { ihl() = 5; } - SENF_PARSER_FINALIZE(Parse_IPv4); + SENF_PARSER_FINALIZE(IPv4PacketParser); boost::uint16_t calcChecksum() const; @@ -123,24 +123,24 @@ namespace senf { 20 24 28 31 - \ref Parse_IPv4::version() "Version" - \ref Parse_IPv4::ihl() "IHL" - \ref Parse_IPv4::tos() "TOS" - \ref Parse_IPv4::length() "Length" + \ref IPv4PacketParser::version() "Version" + \ref IPv4PacketParser::ihl() "IHL" + \ref IPv4PacketParser::tos() "TOS" + \ref IPv4PacketParser::length() "Length" - \ref Parse_IPv4::identifier() "Identifier" - \ref Parse_IPv4::reserved() "R" - \ref Parse_IPv4::df() "DF" - \ref Parse_IPv4::mf() "MF" - \ref Parse_IPv4::frag() "Fragment Offset" + \ref IPv4PacketParser::identifier() "Identifier" + \ref IPv4PacketParser::reserved() "R" + \ref IPv4PacketParser::df() "DF" + \ref IPv4PacketParser::mf() "MF" + \ref IPv4PacketParser::frag() "Fragment Offset" - \ref Parse_IPv4::ttl() "Time to Live (ttl)" - \ref Parse_IPv4::protocol() "Protocol" - \ref Parse_IPv4::checksum() "Header Checksum" + \ref IPv4PacketParser::ttl() "Time to Live (ttl)" + \ref IPv4PacketParser::protocol() "Protocol" + \ref IPv4PacketParser::checksum() "Header Checksum" - \ref Parse_IPv4::source() "Source Address" + \ref IPv4PacketParser::source() "Source Address" - \ref Parse_IPv4::destination() "Destination Address" + \ref IPv4PacketParser::destination() "Destination Address" @@ -148,7 +148,7 @@ namespace senf { \ref IPv4Packet \par Fields: - \ref Parse_IPv4 + \ref IPv4PacketParser \par Associated registries: \ref IpTypes @@ -167,7 +167,7 @@ namespace senf { #ifndef DOXYGEN typedef PacketTypeMixin mixin; typedef ConcretePacket packet; - typedef Parse_IPv4 parser; + typedef IPv4PacketParser parser; #endif using mixin::nextPacketRange; using mixin::nextPacketType; diff --git a/Packets/DefaultBundle/IPv6Extensions.hh b/Packets/DefaultBundle/IPv6Extensions.hh index e351a43..954de89 100644 --- a/Packets/DefaultBundle/IPv6Extensions.hh +++ b/Packets/DefaultBundle/IPv6Extensions.hh @@ -41,20 +41,20 @@ namespace senf { \see IPv6ExtensionType_Fragment \n RFC 2460 */ - struct Parse_IPv6Extension_Fragment : public PacketParserBase + struct IPv6PacketParserExtension_Fragment : public PacketParserBase { # include SENF_FIXED_PARSER() - SENF_PARSER_FIELD( nextHeader , Parse_UInt8 ); - SENF_PARSER_FIELD( reserved1 , Parse_UInt8 ); + SENF_PARSER_FIELD( nextHeader , UInt8Parser ); + SENF_PARSER_FIELD( reserved1 , UInt8Parser ); SENF_PARSER_BITFIELD( fragmentOffset, 13, unsigned ); SENF_PARSER_BITFIELD( reserved2, 2, unsigned ); SENF_PARSER_BITFIELD( moreFragments, 1, bool ); - SENF_PARSER_FIELD( id , Parse_UInt32 ); + SENF_PARSER_FIELD( id , UInt32Parser ); - SENF_PARSER_FINALIZE(Parse_IPv6Extension_Fragment); + SENF_PARSER_FINALIZE(IPv6PacketParserExtension_Fragment); }; /** \brief IPv6 fragment extension @@ -63,7 +63,7 @@ namespace senf { \ref IPv6Extension_Fragment \par Fields: - \ref Parse_IPv6Extension_Fragment + \ref IPv6PacketParserExtension_Fragment \par Associated registries: \par IpTypes @@ -80,7 +80,7 @@ namespace senf { #ifndef DOXYGEN typedef PacketTypeMixin mixin; typedef ConcretePacket packet; - typedef Parse_IPv6Extension_Fragment parser; + typedef IPv6PacketParserExtension_Fragment parser; #endif using mixin::nextPacketRange; using mixin::nextPacketType; diff --git a/Packets/DefaultBundle/IPv6Packet.cc b/Packets/DefaultBundle/IPv6Packet.cc index 4841834..18ca266 100644 --- a/Packets/DefaultBundle/IPv6Packet.cc +++ b/Packets/DefaultBundle/IPv6Packet.cc @@ -65,7 +65,7 @@ prefix_ void senf::IPv6PacketType::dump(packet p, std::ostream & os) prefix_ void senf::IPv6PacketType::finalize(packet p) { - p->length() << (p.size() - Parse_IPv6::fixed_bytes); + p->length() << (p.size() - IPv6PacketParser::fixed_bytes); p->nextHeader() << key(p.next()); } diff --git a/Packets/DefaultBundle/IPv6Packet.hh b/Packets/DefaultBundle/IPv6Packet.hh index a7006e9..a02efde 100644 --- a/Packets/DefaultBundle/IPv6Packet.hh +++ b/Packets/DefaultBundle/IPv6Packet.hh @@ -40,9 +40,9 @@ namespace senf { \see INet6Address */ - struct Parse_INet6Address : public PacketParserBase + struct INet6AddressParser : public PacketParserBase { - Parse_INet6Address(data_iterator i, state_type s) : PacketParserBase(i,s,fixed_bytes) {} + INet6AddressParser(data_iterator i, state_type s) : PacketParserBase(i,s,fixed_bytes) {} /////////////////////////////////////////////////////////////////////////// @@ -53,7 +53,7 @@ namespace senf { void value(value_type const & v) { std::copy(v.begin(), v.end(), i()); } operator value_type() { return value(); } byte & operator[](size_type index) { return *boost::next(i(),index); } - Parse_INet6Address const & operator= (value_type const & other) + INet6AddressParser const & operator= (value_type const & other) { value(other); return *this; } }; @@ -62,7 +62,7 @@ namespace senf { \see IPv6PacketType \n RFC 2460 */ - struct Parse_IPv6 : public PacketParserBase + struct IPv6PacketParser : public PacketParserBase { # include SENF_FIXED_PARSER() @@ -70,17 +70,17 @@ namespace senf { SENF_PARSER_BITFIELD( trafficClass, 8, unsigned ); SENF_PARSER_BITFIELD( flowLabel, 20, unsigned ); - SENF_PARSER_FIELD( length, Parse_UInt16 ); - SENF_PARSER_FIELD( nextHeader, Parse_UInt8 ); - SENF_PARSER_FIELD( hopLimit, Parse_UInt8 ); - SENF_PARSER_FIELD( source, Parse_INet6Address ); - SENF_PARSER_FIELD( destination, Parse_INet6Address ); + SENF_PARSER_FIELD( length, UInt16Parser ); + SENF_PARSER_FIELD( nextHeader, UInt8Parser ); + SENF_PARSER_FIELD( hopLimit, UInt8Parser ); + SENF_PARSER_FIELD( source, INet6AddressParser ); + SENF_PARSER_FIELD( destination, INet6AddressParser ); SENF_PARSER_INIT() { version() = 6; } - SENF_PARSER_FINALIZE(Parse_IPv6); + SENF_PARSER_FINALIZE(IPv6PacketParser); }; /** \brief IPv6 packet @@ -89,7 +89,7 @@ namespace senf { \ref IPv6Packet \par Fields: - \ref Parse_IPv6 + \ref IPv6PacketParser \par Associated registries: \ref IpTypes @@ -107,7 +107,7 @@ namespace senf { #ifndef DOXYGEN typedef PacketTypeMixin mixin; typedef ConcretePacket packet; - typedef Parse_IPv6 parser; + typedef IPv6PacketParser parser; #endif using mixin::nextPacketRange; using mixin::nextPacketType; diff --git a/Packets/DefaultBundle/LlcSnapPacket.hh b/Packets/DefaultBundle/LlcSnapPacket.hh index 22febc5..9612690 100644 --- a/Packets/DefaultBundle/LlcSnapPacket.hh +++ b/Packets/DefaultBundle/LlcSnapPacket.hh @@ -40,18 +40,18 @@ namespace senf { \todo document me */ - struct Parse_LlcSnapPacket : public PacketParserBase + struct LlcSnapPacketParser : public PacketParserBase { # include SENF_FIXED_PARSER() - SENF_PARSER_FIELD( dsap, Parse_UInt8 ); - SENF_PARSER_FIELD( ssap, Parse_UInt8 ); - SENF_PARSER_FIELD( ctrl, Parse_UInt8 ); + SENF_PARSER_FIELD( dsap, UInt8Parser ); + SENF_PARSER_FIELD( ssap, UInt8Parser ); + SENF_PARSER_FIELD( ctrl, UInt8Parser ); - SENF_PARSER_FIELD( protocolId, Parse_UInt24 ); - SENF_PARSER_FIELD( type_length, Parse_UInt16 ); + SENF_PARSER_FIELD( protocolId, UInt24Parser ); + SENF_PARSER_FIELD( type_length, UInt16Parser ); - SENF_PARSER_FINALIZE(Parse_LlcSnapPacket); + SENF_PARSER_FINALIZE(LlcSnapPacketParser); SENF_PARSER_INIT() { dsap() = 0xaa; @@ -69,7 +69,7 @@ namespace senf { \ref LlcSnapPacketType \par Fields: - \ref Parse_LlcSnapPacket + \ref LlcSnapPacketParser \par Associated registries: \ref EtherTypes @@ -86,7 +86,7 @@ namespace senf { #ifndef DOXYGEN typedef PacketTypeMixin mixin; typedef ConcretePacket packet; - typedef Parse_LlcSnapPacket parser; + typedef LlcSnapPacketParser parser; #endif using mixin::nextPacketRange; using mixin::initSize; diff --git a/Packets/DefaultBundle/UDPPacket.cc b/Packets/DefaultBundle/UDPPacket.cc index d3808e4..20b07ca 100644 --- a/Packets/DefaultBundle/UDPPacket.cc +++ b/Packets/DefaultBundle/UDPPacket.cc @@ -44,9 +44,9 @@ namespace { } /////////////////////////////////////////////////////////////////////////// -// senf::Parse_UDP +// senf::UDPPacketParser -prefix_ boost::uint16_t senf::Parse_UDP::calcChecksum() +prefix_ boost::uint16_t senf::UDPPacketParser::calcChecksum() const { IpChecksum summer; @@ -58,10 +58,10 @@ prefix_ boost::uint16_t senf::Parse_UDP::calcChecksum() if (ipv4) { // Pseudo header defined in RFC768 summer.feed( ipv4->source().i(), - ipv4->source().i() + Parse_IPv4::source_t::fixed_bytes ); + ipv4->source().i() + IPv4PacketParser::source_t::fixed_bytes ); ///\fixme What about a hop-by-hop routing option? Which destination is used in IPv4 ? summer.feed( ipv4->destination().i(), - ipv4->destination().i() + Parse_IPv4::destination_t::fixed_bytes ); + ipv4->destination().i() + IPv4PacketParser::destination_t::fixed_bytes ); summer.feed( 0u ); ///\fixme May there be another header between the IPv4 header and UDP? if so, we /// need to hack the correct protocol number here ... @@ -73,11 +73,11 @@ prefix_ boost::uint16_t senf::Parse_UDP::calcChecksum() IPv6Packet ipv6 (packet().prev(nothrow)); if (ipv6) { summer.feed( ipv6->source().i(), - ipv6->source().i() + Parse_IPv6::source_t::fixed_bytes ); + ipv6->source().i() + IPv6PacketParser::source_t::fixed_bytes ); ///\todo Implement routing header support // The destination used here must be the *final* destination ... summer.feed( ipv6->destination().i(), - ipv6->destination().i() + Parse_IPv6::destination_t::fixed_bytes ); + ipv6->destination().i() + IPv6PacketParser::destination_t::fixed_bytes ); /// This is a simplification. The value is really 32bit to support UDP Jumbograms /// (RFC2147). However, skipping an even number of 0 bytes does not change the checksum summer.feed( i() + length_offset, i() + length_offset + 2 ); diff --git a/Packets/DefaultBundle/UDPPacket.hh b/Packets/DefaultBundle/UDPPacket.hh index 2c662d3..c7e7d49 100644 --- a/Packets/DefaultBundle/UDPPacket.hh +++ b/Packets/DefaultBundle/UDPPacket.hh @@ -41,16 +41,16 @@ namespace senf { \see UDPPacketType RFC 768 */ - struct Parse_UDP : public PacketParserBase + struct UDPPacketParser : public PacketParserBase { # include SENF_FIXED_PARSER() - SENF_PARSER_FIELD( source, senf::Parse_UInt16 ); - SENF_PARSER_FIELD( destination, senf::Parse_UInt16 ); - SENF_PARSER_FIELD( length, senf::Parse_UInt16 ); - SENF_PARSER_FIELD( checksum, senf::Parse_UInt16 ); + SENF_PARSER_FIELD( source, senf::UInt16Parser ); + SENF_PARSER_FIELD( destination, senf::UInt16Parser ); + SENF_PARSER_FIELD( length, senf::UInt16Parser ); + SENF_PARSER_FIELD( checksum, senf::UInt16Parser ); - SENF_PARSER_FINALIZE(Parse_UDP); + SENF_PARSER_FINALIZE(UDPPacketParser); boost::uint16_t calcChecksum() const; @@ -65,7 +65,7 @@ namespace senf { \ref UDPPacket \par Fields: - \ref Parse_UDP + \ref UDPPacketParser \par Finalize action: Set \a length from payload size\n @@ -80,7 +80,7 @@ namespace senf { #ifndef DOXYGEN typedef PacketTypeMixin mixin; typedef ConcretePacket packet; - typedef Parse_UDP parser; + typedef UDPPacketParser parser; #endif using mixin::nextPacketRange; using mixin::initSize; diff --git a/Packets/ParseInt.hh b/Packets/IntParser.hh similarity index 77% rename from Packets/ParseInt.hh rename to Packets/IntParser.hh index 32ae476..fb2a0fc 100644 --- a/Packets/ParseInt.hh +++ b/Packets/IntParser.hh @@ -21,10 +21,10 @@ // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /** \file - \brief ParseInt public header */ + \brief IntParser public header */ -#ifndef HH_ParseInt_ -#define HH_ParseInt_ 1 +#ifndef HH_IntParser_ +#define HH_IntParser_ 1 // Custom includes #include @@ -33,9 +33,9 @@ #include #include "PacketParser.hh" -//#include "ParseInt.mpp" +//#include "IntParser.mpp" ///////////////////////////////hh.p//////////////////////////////////////// -#include "ParseInt.ih" +#include "IntParser.ih" namespace senf { @@ -70,11 +70,11 @@ namespace senf { \see parseint \ingroup parseint */ - struct Parse_Int8 - : public detail::packet::ParseIntOps, + struct Int8Parser + : public detail::packet::IntParserOps, public PacketParserBase { - Parse_Int8(data_iterator i, state_type s) : PacketParserBase(i,s,fixed_bytes) {} + Int8Parser(data_iterator i, state_type s) : PacketParserBase(i,s,fixed_bytes) {} /////////////////////////////////////////////////////////////////////////// @@ -85,23 +85,23 @@ namespace senf { value_type value() const { return i()[0]; } void value(value_type v) { i()[0] = v; } - Parse_Int8 const & operator= (value_type other) { value(other); return *this; } + Int8Parser const & operator= (value_type other) { value(other); return *this; } }; /** \brief Write parsed value to stream - \related Parse_Int8 + \related Int8Parser */ - inline std::ostream & operator<<(std::ostream & os, Parse_Int8 const & i) + inline std::ostream & operator<<(std::ostream & os, Int8Parser const & i) { os << i.value(); return os; } /** \brief Parse 8bit unsigned byte aligned integer \see parseint \ingroup parseint */ - struct Parse_UInt8 - : public detail::packet::ParseIntOps, + struct UInt8Parser + : public detail::packet::IntParserOps, public PacketParserBase { - Parse_UInt8(data_iterator i, state_type s) : PacketParserBase(i,s,fixed_bytes) {} + UInt8Parser(data_iterator i, state_type s) : PacketParserBase(i,s,fixed_bytes) {} /////////////////////////////////////////////////////////////////////////// @@ -112,23 +112,23 @@ namespace senf { value_type value() const { return i()[0]; } void value(value_type v) { i()[0] = v; } - Parse_UInt8 const & operator= (value_type other) { value(other); return *this; } + UInt8Parser const & operator= (value_type other) { value(other); return *this; } }; /** \brief Write parsed value to stream - \related Parse_UInt8 + \related UInt8Parser */ - inline std::ostream & operator<<(std::ostream & os, Parse_UInt8 const & i) + inline std::ostream & operator<<(std::ostream & os, UInt8Parser const & i) { os << i.value(); return os; } /** \brief Parse 16bit signed byte aligned integer \see parseint \ingroup parseint */ - struct Parse_Int16 - : public detail::packet::ParseIntOps, + struct Int16Parser + : public detail::packet::IntParserOps, public PacketParserBase { - Parse_Int16(data_iterator i, state_type s) : PacketParserBase(i,s,fixed_bytes) {} + Int16Parser(data_iterator i, state_type s) : PacketParserBase(i,s,fixed_bytes) {} /////////////////////////////////////////////////////////////////////////// @@ -140,23 +140,23 @@ namespace senf { value_type value() const { return detail::packet::parse_uint16(i()); } void value(value_type v) { detail::packet::write_uint16(i(),v); } - Parse_Int16 const & operator= (value_type other) { value(other); return *this; } + Int16Parser const & operator= (value_type other) { value(other); return *this; } }; /** \brief Write parsed value to stream - \related Parse_Int16 + \related Int16Parser */ - inline std::ostream & operator<<(std::ostream & os, Parse_Int16 const & i) + inline std::ostream & operator<<(std::ostream & os, Int16Parser const & i) { os << i.value(); return os; } /** \brief Parse 16bit unsigned byte aligned integer \see parseint \ingroup parseint */ - struct Parse_UInt16 - : public detail::packet::ParseIntOps, + struct UInt16Parser + : public detail::packet::IntParserOps, public PacketParserBase { - Parse_UInt16(data_iterator i, state_type s) : PacketParserBase(i,s,fixed_bytes) {} + UInt16Parser(data_iterator i, state_type s) : PacketParserBase(i,s,fixed_bytes) {} /////////////////////////////////////////////////////////////////////////// @@ -167,23 +167,23 @@ namespace senf { value_type value() const { return detail::packet::parse_uint16(i()); } void value(value_type v) { detail::packet::write_uint16(i(),v); } - Parse_UInt16 const & operator= (value_type other) { value(other); return *this; } + UInt16Parser const & operator= (value_type other) { value(other); return *this; } }; /** \brief Write parsed value to stream - \related Parse_UInt16 + \related UInt16Parser */ - inline std::ostream & operator<<(std::ostream & os, Parse_UInt16 const & i) + inline std::ostream & operator<<(std::ostream & os, UInt16Parser const & i) { os << i.value(); return os; } /** \brief Parse 24bit signed byte aligned integer \see parseint \ingroup parseint */ - struct Parse_Int24 - : public detail::packet::ParseIntOps, + struct Int24Parser + : public detail::packet::IntParserOps, public PacketParserBase { - Parse_Int24(data_iterator i, state_type s) : PacketParserBase(i,s,fixed_bytes) {} + Int24Parser(data_iterator i, state_type s) : PacketParserBase(i,s,fixed_bytes) {} /////////////////////////////////////////////////////////////////////////// @@ -195,23 +195,23 @@ namespace senf { value_type value() const { value_type v (detail::packet::parse_uint24(i())); return v&0x800000 ? v|0xff000000 : v; } void value(value_type v) { detail::packet::write_uint24(i(),v); } - Parse_Int24 const & operator= (value_type other) { value(other); return *this; } + Int24Parser const & operator= (value_type other) { value(other); return *this; } }; /** \brief Write parsed value to stream - \related Parse_Int24 + \related Int24Parser */ - inline std::ostream & operator<<(std::ostream & os, Parse_Int24 const & i) + inline std::ostream & operator<<(std::ostream & os, Int24Parser const & i) { os << i.value(); return os; } /** \brief Parse 24bit unsigned byte aligned integer \see parseint \ingroup parseint */ - struct Parse_UInt24 - : public detail::packet::ParseIntOps, + struct UInt24Parser + : public detail::packet::IntParserOps, public PacketParserBase { - Parse_UInt24(data_iterator i, state_type s) : PacketParserBase(i,s,fixed_bytes) {} + UInt24Parser(data_iterator i, state_type s) : PacketParserBase(i,s,fixed_bytes) {} /////////////////////////////////////////////////////////////////////////// @@ -222,23 +222,23 @@ namespace senf { value_type value() const { return detail::packet::parse_uint24(i()); } void value(value_type v) { detail::packet::write_uint24(i(),v); } - Parse_UInt24 const & operator= (value_type other) { value(other); return *this; } + UInt24Parser const & operator= (value_type other) { value(other); return *this; } }; /** \brief Write parsed value to stream - \related Parse_UInt24 + \related UInt24Parser */ - inline std::ostream & operator<<(std::ostream & os, Parse_UInt24 const & i) + inline std::ostream & operator<<(std::ostream & os, UInt24Parser const & i) { os << i.value(); return os; } /** \brief Parse 32bit signed byte aligned integer \see parseint \ingroup parseint */ - struct Parse_Int32 - : public detail::packet::ParseIntOps, + struct Int32Parser + : public detail::packet::IntParserOps, public PacketParserBase { - Parse_Int32(data_iterator i, state_type s) : PacketParserBase(i,s,fixed_bytes) {} + Int32Parser(data_iterator i, state_type s) : PacketParserBase(i,s,fixed_bytes) {} /////////////////////////////////////////////////////////////////////////// @@ -249,23 +249,23 @@ namespace senf { value_type value() const { return detail::packet::parse_uint32(i()); } void value(value_type v) { detail::packet::write_uint32(i(),v); } - Parse_Int32 const & operator= (value_type other) { value(other); return *this; } + Int32Parser const & operator= (value_type other) { value(other); return *this; } }; /** \brief Write parsed value to stream - \related Parse_Int32 + \related Int32Parser */ - inline std::ostream & operator<<(std::ostream & os, Parse_Int32 const & i) + inline std::ostream & operator<<(std::ostream & os, Int32Parser const & i) { os << i.value(); return os; } /** \brief Parse 32bit unsigned byte aligned integer \see parseint \ingroup parseint */ - struct Parse_UInt32 - : public detail::packet::ParseIntOps, + struct UInt32Parser + : public detail::packet::IntParserOps, public PacketParserBase { - Parse_UInt32(data_iterator i, state_type s) : PacketParserBase(i,s,fixed_bytes) {} + UInt32Parser(data_iterator i, state_type s) : PacketParserBase(i,s,fixed_bytes) {} /////////////////////////////////////////////////////////////////////////// @@ -276,12 +276,12 @@ namespace senf { value_type value() const { return detail::packet::parse_uint32(i()); } void value(value_type v) { detail::packet::write_uint32(i(),v); } - Parse_UInt32 const & operator= (value_type other) { value(other); return *this; } + UInt32Parser const & operator= (value_type other) { value(other); return *this; } }; /** \brief Write parsed value to stream - \related Parse_UInt32 + \related UInt32Parser */ - inline std::ostream & operator<<(std::ostream & os, Parse_UInt32 const & i) + inline std::ostream & operator<<(std::ostream & os, UInt32Parser const & i) { os << i.value(); return os; } /** \brief Parse signed bitfield with up to 32bit's @@ -290,7 +290,7 @@ namespace senf { End. Bits are numbered most significant bit first as this is the customary numbering used when defining packet data structures. \a Start and \a End can be \e arbitrary as long as the field is between 1 and 32 bits in size. In other words, \c - Parse_IntField<53,81> is a valid 30 bit field. + IntFieldParser<53,81> is a valid 30 bit field. When defining a compound parser with several bit fields, you need to take care of the fact, that several integer field parsers will interpret the same data \e bytes (but not the same @@ -307,11 +307,11 @@ namespace senf { \ingroup parseint */ template - struct Parse_IntField - : public detail::packet::ParseIntOps,boost::int32_t>, + struct IntFieldParser + : public detail::packet::IntParserOps,boost::int32_t>, public PacketParserBase { - Parse_IntField(data_iterator i, state_type s) : PacketParserBase(i,s,fixed_bytes) {} + IntFieldParser(data_iterator i, state_type s) : PacketParserBase(i,s,fixed_bytes) {} /////////////////////////////////////////////////////////////////////////// @@ -329,17 +329,17 @@ namespace senf { v | ~boost::low_bits_mask_t::sig_bits : v; } void value(value_type v) { detail::packet::parse_bitfield::write(i(),v); } - Parse_IntField const & operator= (value_type other) { value(other); return *this; } + IntFieldParser const & operator= (value_type other) { value(other); return *this; } private: BOOST_STATIC_ASSERT( Start - inline std::ostream & operator<<(std::ostream & os, Parse_IntField const & i) + inline std::ostream & operator<<(std::ostream & os, IntFieldParser const & i) { os << i.value(); return os; } /** \brief Parse unsigned bitfield with up to 32bit's @@ -348,7 +348,7 @@ namespace senf { End. Bits are numbered most significant bit first as this is the customary numbering used when defining packet data structures. \a Start and \a End can be \e arbitrary as long as the field is between 1 and 32 bits in size. In other words, \c - Parse_IntField<53,81> is a valid 30 bit field. + IntFieldParser<53,81> is a valid 30 bit field. When defining a compound parser with several bit fields, you need to take care of the fact, that several integer field parsers will interpret the same data \e bytes (but not the same @@ -365,11 +365,11 @@ namespace senf { \ingroup parseint */ template - struct Parse_UIntField - : public detail::packet::ParseIntOps,boost::uint32_t>, + struct UIntFieldParser + : public detail::packet::IntParserOps,boost::uint32_t>, public PacketParserBase { - Parse_UIntField(data_iterator i, state_type s) : PacketParserBase(i,s,fixed_bytes) {} + UIntFieldParser(data_iterator i, state_type s) : PacketParserBase(i,s,fixed_bytes) {} /////////////////////////////////////////////////////////////////////////// @@ -382,24 +382,24 @@ namespace senf { value_type value() const { return detail::packet::parse_bitfield::parse(i()); } void value(value_type v) { detail::packet::parse_bitfield::write(i(),v); } - Parse_UIntField const & operator= (value_type other) { value(other); return *this; } + UIntFieldParser const & operator= (value_type other) { value(other); return *this; } private: BOOST_STATIC_ASSERT( Start - inline std::ostream & operator<<(std::ostream & os, Parse_UIntField const & i) + inline std::ostream & operator<<(std::ostream & os, UIntFieldParser const & i) { os << i.value(); return os; } /** \brief Parse single-bit flag This parser will parse a single bit as True/False value. Bits are numbered most significant bit first as this is the customary numbering used when defining packet data - structures. \a Bit can be arbitrary, \c Parse_Flag<75> is a valid flag parser. + structures. \a Bit can be arbitrary, \c FlagParser<75> is a valid flag parser. When defining a compound parser with several bit fields, you need to take care of the fact, that several integer field parsers will interpret the same data \e bytes (but not the same @@ -410,11 +410,11 @@ namespace senf { \ingroup parseint */ template - struct Parse_Flag - : public detail::packet::ParseIntOps,bool>, + struct FlagParser + : public detail::packet::IntParserOps,bool>, public PacketParserBase { - Parse_Flag(data_iterator i, state_type s) : PacketParserBase(i,s,fixed_bytes) {} + FlagParser(data_iterator i, state_type s) : PacketParserBase(i,s,fixed_bytes) {} /////////////////////////////////////////////////////////////////////////// @@ -429,24 +429,24 @@ namespace senf { if (v) i()[0] |= 1<<(7-(Bit%8)); else i()[0] &= ~(1<<(7-(Bit%8))); } - Parse_Flag const & operator= (value_type other) { value(other); return *this; } + FlagParser const & operator= (value_type other) { value(other); return *this; } }; /** \brief Write parsed value to stream - \related Parse_Flag + \related FlagParser */ template - inline std::ostream & operator<<(std::ostream & os, Parse_Flag const & i) + inline std::ostream & operator<<(std::ostream & os, FlagParser const & i) { os << i.value(); return os; } } ///////////////////////////////hh.e//////////////////////////////////////// #endif -#if !defined(HH_Packets__decls_) && !defined(HH_ParseInt_i_) -#define HH_ParseInt_i_ -//#include "ParseInt.cci" -//#include "ParseInt.ct" -//#include "ParseInt.cti" +#if !defined(HH_Packets__decls_) && !defined(HH_IntParser_i_) +#define HH_IntParser_i_ +//#include "IntParser.cci" +//#include "IntParser.ct" +//#include "IntParser.cti" #endif diff --git a/Packets/ParseInt.ih b/Packets/IntParser.ih similarity index 98% rename from Packets/ParseInt.ih rename to Packets/IntParser.ih index 80b8d7f..e342f95 100644 --- a/Packets/ParseInt.ih +++ b/Packets/IntParser.ih @@ -21,10 +21,10 @@ // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /** \file - \brief ParseInt internal header */ + \brief IntParser internal header */ -#ifndef IH_ParseInt_ -#define IH_ParseInt_ 1 +#ifndef IH_IntParser_ +#define IH_IntParser_ 1 // Custom includes #include "PacketTypes.hh" @@ -46,7 +46,7 @@ namespace packet { inherited by each integer parser. */ template - class ParseIntOps + class IntParserOps { public: typedef Value value_type; diff --git a/Packets/ParseInt.test.cc b/Packets/IntParser.test.cc similarity index 66% rename from Packets/ParseInt.test.cc rename to Packets/IntParser.test.cc index 0f6f095..db1175c 100644 --- a/Packets/ParseInt.test.cc +++ b/Packets/IntParser.test.cc @@ -22,8 +22,8 @@ // Unit tests -//#include "ParseInt.test.hh" -//#include "ParseInt.test.ih" +//#include "IntParser.test.hh" +//#include "IntParser.test.ih" // Custom includes #include "Packets.hh" @@ -46,21 +46,21 @@ BOOST_AUTO_UNIT_TEST(parseInt_fixedSizes) PacketInterpreterBase::byte data[] = { 0x8e, 0x2f, 0x57, 0x12, 0xd1 }; PacketInterpreterBase::ptr p (PacketInterpreter::create(data)); - BOOST_CHECK_EQUAL(Parse_Int8(p->data().begin(),&p->data()).value(), -114); - BOOST_CHECK_EQUAL(Parse_Int8(p->data().begin()+1,&p->data()).value(), 47); - BOOST_CHECK_EQUAL(Parse_UInt8(p->data().begin(),&p->data()).value(), 142u); + BOOST_CHECK_EQUAL(Int8Parser(p->data().begin(),&p->data()).value(), -114); + BOOST_CHECK_EQUAL(Int8Parser(p->data().begin()+1,&p->data()).value(), 47); + BOOST_CHECK_EQUAL(UInt8Parser(p->data().begin(),&p->data()).value(), 142u); - BOOST_CHECK_EQUAL(Parse_Int16(p->data().begin(),&p->data()).value(), -29137); - BOOST_CHECK_EQUAL(Parse_Int16(p->data().begin()+1,&p->data()).value(), 12119); - BOOST_CHECK_EQUAL(Parse_UInt16(p->data().begin(),&p->data()).value(), 36399u); + BOOST_CHECK_EQUAL(Int16Parser(p->data().begin(),&p->data()).value(), -29137); + BOOST_CHECK_EQUAL(Int16Parser(p->data().begin()+1,&p->data()).value(), 12119); + BOOST_CHECK_EQUAL(UInt16Parser(p->data().begin(),&p->data()).value(), 36399u); - BOOST_CHECK_EQUAL(Parse_Int24(p->data().begin(),&p->data()).value(), -7458985); - BOOST_CHECK_EQUAL(Parse_Int24(p->data().begin()+1,&p->data()).value(), 3102482); - BOOST_CHECK_EQUAL(Parse_UInt24(p->data().begin(),&p->data()).value(), 9318231u); + BOOST_CHECK_EQUAL(Int24Parser(p->data().begin(),&p->data()).value(), -7458985); + BOOST_CHECK_EQUAL(Int24Parser(p->data().begin()+1,&p->data()).value(), 3102482); + BOOST_CHECK_EQUAL(UInt24Parser(p->data().begin(),&p->data()).value(), 9318231u); - BOOST_CHECK_EQUAL(Parse_Int32(p->data().begin(),&p->data()).value(), -1909500142); - BOOST_CHECK_EQUAL(Parse_Int32(p->data().begin()+1,&p->data()).value(), 794235601); - BOOST_CHECK_EQUAL(Parse_UInt32(p->data().begin(),&p->data()).value(), 2385467154u); + BOOST_CHECK_EQUAL(Int32Parser(p->data().begin(),&p->data()).value(), -1909500142); + BOOST_CHECK_EQUAL(Int32Parser(p->data().begin()+1,&p->data()).value(), 794235601); + BOOST_CHECK_EQUAL(UInt32Parser(p->data().begin(),&p->data()).value(), 2385467154u); } BOOST_AUTO_UNIT_TEST(parseInt_bits) @@ -73,37 +73,37 @@ BOOST_AUTO_UNIT_TEST(parseInt_bits) PacketInterpreterBase::ptr p (PacketInterpreter::create(data)); // 1 byte - BOOST_CHECK_EQUAL((Parse_UIntField<2,7>(p->data().begin(),&p->data()).value()), 17u); - BOOST_CHECK_EQUAL((Parse_IntField<2,7>(p->data().begin(),&p->data()).value()), -15); - BOOST_CHECK_EQUAL((Parse_UIntField<3,7>(p->data().begin(),&p->data()).value()), 1u); - BOOST_CHECK_EQUAL((Parse_IntField<3,7>(p->data().begin(),&p->data()).value()), 1); - BOOST_CHECK_EQUAL((Parse_UIntField<0,8>(p->data().begin(),&p->data()).value()), 99u); + BOOST_CHECK_EQUAL((UIntFieldParser<2,7>(p->data().begin(),&p->data()).value()), 17u); + BOOST_CHECK_EQUAL((IntFieldParser<2,7>(p->data().begin(),&p->data()).value()), -15); + BOOST_CHECK_EQUAL((UIntFieldParser<3,7>(p->data().begin(),&p->data()).value()), 1u); + BOOST_CHECK_EQUAL((IntFieldParser<3,7>(p->data().begin(),&p->data()).value()), 1); + BOOST_CHECK_EQUAL((UIntFieldParser<0,8>(p->data().begin(),&p->data()).value()), 99u); // 2 byte - BOOST_CHECK_EQUAL((Parse_UIntField<5,12>(p->data().begin(),&p->data()).value()), 61u); - BOOST_CHECK_EQUAL((Parse_UIntField<0,12>(p->data().begin(),&p->data()).value()), 1597u); - BOOST_CHECK_EQUAL((Parse_UIntField<8,13>(p->data().begin(),&p->data()).value()), 26u); - BOOST_CHECK_EQUAL((Parse_UIntField<8,16>(p->data().begin(),&p->data()).value()), 215u); - BOOST_CHECK_EQUAL((Parse_UIntField<0,16>(p->data().begin(),&p->data()).value()), 25559u); + BOOST_CHECK_EQUAL((UIntFieldParser<5,12>(p->data().begin(),&p->data()).value()), 61u); + BOOST_CHECK_EQUAL((UIntFieldParser<0,12>(p->data().begin(),&p->data()).value()), 1597u); + BOOST_CHECK_EQUAL((UIntFieldParser<8,13>(p->data().begin(),&p->data()).value()), 26u); + BOOST_CHECK_EQUAL((UIntFieldParser<8,16>(p->data().begin(),&p->data()).value()), 215u); + BOOST_CHECK_EQUAL((UIntFieldParser<0,16>(p->data().begin(),&p->data()).value()), 25559u); // 3 byte - BOOST_CHECK_EQUAL((Parse_UIntField<6,20>(p->data().begin(),&p->data()).value()), 15733u); - BOOST_CHECK_EQUAL((Parse_IntField<6,20>(p->data().begin(),&p->data()).value()), -651); - BOOST_CHECK_EQUAL((Parse_UIntField<13,22>(p->data().begin(),&p->data()).value()), 470u); + BOOST_CHECK_EQUAL((UIntFieldParser<6,20>(p->data().begin(),&p->data()).value()), 15733u); + BOOST_CHECK_EQUAL((IntFieldParser<6,20>(p->data().begin(),&p->data()).value()), -651); + BOOST_CHECK_EQUAL((UIntFieldParser<13,22>(p->data().begin(),&p->data()).value()), 470u); // 4 byte - BOOST_CHECK_EQUAL((Parse_UIntField<3,28>(p->data().begin(),&p->data()).value()), 4027811u); - BOOST_CHECK_EQUAL((Parse_UIntField<13,38>(p->data().begin(),&p->data()).value()), 30837865u); - BOOST_CHECK_EQUAL((Parse_UIntField<8,40>(p->data().begin(),&p->data()).value()), 3613012388u); - BOOST_CHECK_EQUAL((Parse_IntField<8,40>(p->data().begin(),&p->data()).value()), -681954908); + BOOST_CHECK_EQUAL((UIntFieldParser<3,28>(p->data().begin(),&p->data()).value()), 4027811u); + BOOST_CHECK_EQUAL((UIntFieldParser<13,38>(p->data().begin(),&p->data()).value()), 30837865u); + BOOST_CHECK_EQUAL((UIntFieldParser<8,40>(p->data().begin(),&p->data()).value()), 3613012388u); + BOOST_CHECK_EQUAL((IntFieldParser<8,40>(p->data().begin(),&p->data()).value()), -681954908); // 5 byte - BOOST_CHECK_EQUAL((Parse_UIntField<3,34>(p->data().begin(),&p->data()).value()), 257779910u); - BOOST_CHECK_EQUAL((Parse_IntField<13,41>(p->data().begin(),&p->data()).value()), -21732536); + BOOST_CHECK_EQUAL((UIntFieldParser<3,34>(p->data().begin(),&p->data()).value()), 257779910u); + BOOST_CHECK_EQUAL((IntFieldParser<13,41>(p->data().begin(),&p->data()).value()), -21732536); // single bit - BOOST_CHECK_EQUAL((Parse_Flag<32>(p->data().begin(),&p->data()).value()), true); - BOOST_CHECK_EQUAL((Parse_Flag<12>(p->data().begin(),&p->data()).value()), false); + BOOST_CHECK_EQUAL((FlagParser<32>(p->data().begin(),&p->data()).value()), true); + BOOST_CHECK_EQUAL((FlagParser<12>(p->data().begin(),&p->data()).value()), false); } BOOST_AUTO_UNIT_TEST(parseInt_assign) @@ -111,41 +111,41 @@ BOOST_AUTO_UNIT_TEST(parseInt_assign) PacketInterpreterBase::byte data[] = { 0x00, 0x00, 0x00, 0x00, 0x00 }; PacketInterpreterBase::ptr p (PacketInterpreter::create(data)); - Parse_Int8(p->data().begin(),&p->data()).value(0x2f); + Int8Parser(p->data().begin(),&p->data()).value(0x2f); BOOST_CHECK_EQUAL( p->data()[0], 0x2f ); - Parse_Int16(p->data().begin(),&p->data()).value(0xa341); + Int16Parser(p->data().begin(),&p->data()).value(0xa341); BOOST_CHECK_EQUAL( p->data()[0], 0xa3 ); BOOST_CHECK_EQUAL( p->data()[1], 0x41 ); - Parse_Int24(p->data().begin(),&p->data()).value(0x234567); + Int24Parser(p->data().begin(),&p->data()).value(0x234567); BOOST_CHECK_EQUAL( p->data()[0], 0x23 ); BOOST_CHECK_EQUAL( p->data()[1], 0x45 ); BOOST_CHECK_EQUAL( p->data()[2], 0x67 ); - Parse_Int32(p->data().begin(),&p->data()).value(0xfedcba98); + Int32Parser(p->data().begin(),&p->data()).value(0xfedcba98); BOOST_CHECK_EQUAL( p->data()[0], 0xfe ); BOOST_CHECK_EQUAL( p->data()[1], 0xdc ); BOOST_CHECK_EQUAL( p->data()[2], 0xba ); BOOST_CHECK_EQUAL( p->data()[3], 0x98 ); - Parse_IntField<2,6>(p->data().begin(),&p->data()).value(0x3); + IntFieldParser<2,6>(p->data().begin(),&p->data()).value(0x3); BOOST_CHECK_EQUAL( p->data()[0], 0xce ); BOOST_CHECK_EQUAL( p->data()[1], 0xdc ); - Parse_IntField<6,9>(p->data().begin(),&p->data()).value(0x2); + IntFieldParser<6,9>(p->data().begin(),&p->data()).value(0x2); BOOST_CHECK_EQUAL( p->data()[0], 0xcd ); BOOST_CHECK_EQUAL( p->data()[1], 0x5c ); BOOST_CHECK_EQUAL( p->data()[2], 0xba ); - Parse_IntField<2,21>(p->data().begin(),&p->data()).value(0x13d75); + IntFieldParser<2,21>(p->data().begin(),&p->data()).value(0x13d75); BOOST_CHECK_EQUAL( p->data()[0], 0xc9 ); BOOST_CHECK_EQUAL( p->data()[1], 0xeb ); BOOST_CHECK_EQUAL( p->data()[2], 0xaa ); BOOST_CHECK_EQUAL( p->data()[3], 0x98 ); - Parse_UIntField<4,34>(p->data().begin(),&p->data()).value(0x268ad497u); - BOOST_CHECK_EQUAL( (Parse_UIntField<4,34>(p->data().begin(),&p->data()).value()), 0x268ad497u ); + UIntFieldParser<4,34>(p->data().begin(),&p->data()).value(0x268ad497u); + BOOST_CHECK_EQUAL( (UIntFieldParser<4,34>(p->data().begin(),&p->data()).value()), 0x268ad497u ); } BOOST_AUTO_UNIT_TEST(parseInt_operators) @@ -153,8 +153,8 @@ BOOST_AUTO_UNIT_TEST(parseInt_operators) PacketInterpreterBase::byte data[] = { 0x63, 0xd7, 0x5a, 0x31, 0xa4, 0x46 }; PacketInterpreterBase::ptr p (PacketInterpreter::create(data)); - Parse_UInt24 p1(p->data().begin(),&p->data()); - Parse_UInt16 p2(p->data().begin()+3,&p->data()); + UInt24Parser p1(p->data().begin(),&p->data()); + UInt16Parser p2(p->data().begin()+3,&p->data()); BOOST_CHECK_EQUAL( ~p1, 4288424101u ); BOOST_CHECK ( !!p1 ); diff --git a/Packets/ParseListB.cti b/Packets/ListBParser.cti similarity index 74% rename from Packets/ParseListB.cti rename to Packets/ListBParser.cti index 057640a..ee17d81 100644 --- a/Packets/ParseListB.cti +++ b/Packets/ListBParser.cti @@ -21,9 +21,9 @@ // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /** \file - \brief ParseListB inline template implementation */ + \brief ListBParser inline template implementation */ -#include "ParseListB.ih" +#include "ListBParser.ih" // Custom includes @@ -31,19 +31,19 @@ ///////////////////////////////cti.p/////////////////////////////////////// /////////////////////////////////////////////////////////////////////////// -// senf::detail::Parse_ListB_Policy +// senf::detail::ListBParser_Policy template -prefix_ typename senf::detail::Parse_ListB_Policy::size_type -senf::detail::Parse_ListB_Policy::bytes(iterator i, state_type s) +prefix_ typename senf::detail::ListBParser_Policy::size_type +senf::detail::ListBParser_Policy::bytes(iterator i, state_type s) const { return BytesParser(i,s) + BytesParser::fixed_bytes; } template -prefix_ typename senf::detail::Parse_ListB_Policy::size_type -senf::detail::Parse_ListB_Policy::size(iterator i, state_type s) +prefix_ typename senf::detail::ListBParser_Policy::size_type +senf::detail::ListBParser_Policy::size(iterator i, state_type s) const { parser_type l (i,s); @@ -51,25 +51,25 @@ senf::detail::Parse_ListB_Policy::size(iterator i, st } template -prefix_ void senf::detail::Parse_ListB_Policy::init(iterator i, +prefix_ void senf::detail::ListBParser_Policy::init(iterator i, state_type s) const {} /////////////////////////////////////////////////////////////////////////// -// senf::detail::Parse_ListB_Policy::iterator_policy +// senf::detail::ListBParser_Policy::iterator_policy template -prefix_ typename senf::detail::Parse_ListB_Policy::iterator -senf::detail::Parse_ListB_Policy::iterator_policy:: +prefix_ typename senf::detail::ListBParser_Policy::iterator +senf::detail::ListBParser_Policy::iterator_policy:: setBegin(iterator i, state_type s) { return boost::next(i,BytesParser::fixed_bytes); } template -prefix_ typename senf::detail::Parse_ListB_Policy::iterator -senf::detail::Parse_ListB_Policy::iterator_policy:: +prefix_ typename senf::detail::ListBParser_Policy::iterator +senf::detail::ListBParser_Policy::iterator_policy:: setEnd(iterator i, state_type s) { return boost::next(i,BytesParser(i,s) + BytesParser::fixed_bytes); @@ -77,21 +77,21 @@ setEnd(iterator i, state_type s) template prefix_ void -senf::detail::Parse_ListB_Policy::iterator_policy:: +senf::detail::ListBParser_Policy::iterator_policy:: setFromPosition(iterator i, state_type s, iterator p) {} template -prefix_ typename senf::detail::Parse_ListB_Policy::iterator -senf::detail::Parse_ListB_Policy::iterator_policy::next(iterator i, +prefix_ typename senf::detail::ListBParser_Policy::iterator +senf::detail::ListBParser_Policy::iterator_policy::next(iterator i, state_type s) { return boost::next(i,senf::bytes(ElementParser(i,s))); } template -prefix_ typename senf::detail::Parse_ListB_Policy::iterator -senf::detail::Parse_ListB_Policy::iterator_policy::raw(iterator i, +prefix_ typename senf::detail::ListBParser_Policy::iterator +senf::detail::ListBParser_Policy::iterator_policy::raw(iterator i, state_type s) const { @@ -99,11 +99,11 @@ senf::detail::Parse_ListB_Policy::iterator_policy::ra } /////////////////////////////////////////////////////////////////////////// -// senf::detail::Parse_ListB_Policy +// senf::detail::ListBParser_Policy template prefix_ -senf::detail::Parse_ListB_Policy::container_policy:: +senf::detail::ListBParser_Policy::container_policy:: container_policy(parser_type const & list) { iterator const e (boost::next(list.i(),list.bytes())); @@ -113,8 +113,8 @@ container_policy(parser_type const & list) } template -prefix_ typename senf::detail::Parse_ListB_Policy::size_type -senf::detail::Parse_ListB_Policy::container_policy:: +prefix_ typename senf::detail::ListBParser_Policy::size_type +senf::detail::ListBParser_Policy::container_policy:: bytes(iterator i, state_type s) const { @@ -122,8 +122,8 @@ bytes(iterator i, state_type s) } template -prefix_ typename senf::detail::Parse_ListB_Policy::size_type -senf::detail::Parse_ListB_Policy::container_policy:: +prefix_ typename senf::detail::ListBParser_Policy::size_type +senf::detail::ListBParser_Policy::container_policy:: size(iterator i, state_type s) const { @@ -132,7 +132,7 @@ size(iterator i, state_type s) template prefix_ void -senf::detail::Parse_ListB_Policy::container_policy:: +senf::detail::ListBParser_Policy::container_policy:: erase(iterator i, state_type s, iterator p) { size_type b (senf::bytes(ElementParser(p,s))); @@ -144,7 +144,7 @@ erase(iterator i, state_type s, iterator p) template prefix_ void -senf::detail::Parse_ListB_Policy::container_policy:: +senf::detail::ListBParser_Policy::container_policy:: insert(iterator i, state_type s, iterator p) { BytesParser(i,s) += senf::bytes(ElementParser(p,s)); @@ -154,7 +154,7 @@ insert(iterator i, state_type s, iterator p) template prefix_ void -senf::detail::Parse_ListB_Policy::container_policy:: +senf::detail::ListBParser_Policy::container_policy:: init(iterator i, state_type s) { n_ = 0; @@ -163,7 +163,7 @@ init(iterator i, state_type s) template prefix_ void -senf::detail::Parse_ListB_Policy::container_policy:: +senf::detail::ListBParser_Policy::container_policy:: update(iterator i, state_type s) const { diff --git a/Packets/ParseListB.hh b/Packets/ListBParser.hh similarity index 78% rename from Packets/ParseListB.hh rename to Packets/ListBParser.hh index ce94153..7de7ea8 100644 --- a/Packets/ParseListB.hh +++ b/Packets/ListBParser.hh @@ -21,29 +21,29 @@ // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /** \file - \brief ParseListB public header */ + \brief ListBParser public header */ -#ifndef HH_ParseListB_ -#define HH_ParseListB_ 1 +#ifndef HH_ListBParser_ +#define HH_ListBParser_ 1 // Custom includes -#include "ParseList.hh" +#include "ListParser.hh" -//#include "ParseListB.mpp" +//#include "ListBParser.mpp" ///////////////////////////////hh.p//////////////////////////////////////// namespace senf { namespace detail { template - class Parse_ListB_Policy; } + class ListBParser_Policy; } /** \brief List parser with size-field in bytes This list parser will parse a list which size is given by a preceding field containing the length of the list in bytes. This struct is just a template typedef: \code - typedef senf::Parse_VectorN< Parser_UInt32, Parser_UInt16 >::parser Parse_MyVector; - typedef senf::Parse_ListB< Parse_MyVector, Parse_UInt16 >::parser Parse_MyList; + typedef senf::VectorNParser< Parser_UInt32, Parser_UInt16 >::parser MyVectorParser; + typedef senf::ListBParser< MyVectorParser, UInt16Parser >::parser MyListParser; \endcode This first defines a Vector of 32 bit unsigned integers with 16 bit length counter. Then it defines a list of such vectors with a 16 bit bytes field. @@ -57,19 +57,19 @@ namespace senf { access the packet through the lowest-level active container wrapper. \implementation These restrictions are necessary to ensure correct recalculation of the - bytes field. For more info, see the comments in \ref ParseListB.ih + bytes field. For more info, see the comments in \ref ListBParser.ih - \see Parse_List + \see ListParser \ingroup parsecollection */ template - struct Parse_ListB { - typedef Parse_List< detail::Parse_ListB_Policy > parser; + struct ListBParser { + typedef ListParser< detail::ListBParser_Policy > parser; }; - /** \brief Define Parse_ListB field + /** \brief Define ListBParser field - This macro is a special helper to define a senf::Parse_ListB type field, a list of elements + This macro is a special helper to define a senf::ListBParser type field, a list of elements of type \a elt_type (a parser type) directly preceded by a numeric size field of type \a size_type (another parser type) giving the total number of bytes of the list (not the element count). @@ -81,18 +81,18 @@ namespace senf { \ingroup packetparsermacros */ # define SENF_PARSER_LIST_B(name, elt_type, size_type) \ - typedef senf::Parse_ListB::parser BOOST_PP_CAT(name, _list_t); \ + typedef senf::ListBParser::parser BOOST_PP_CAT(name, _list_t); \ SENF_PARSER_FIELD( name, BOOST_PP_CAT(name, _list_t) ) } ///////////////////////////////hh.e//////////////////////////////////////// #endif -#if !defined(HH_Packets__decls_) && !defined(HH_ParseListB_i_) -#define HH_ParseListB_i_ -//#include "ParseListB.cci" -//#include "ParseListB.ct" -#include "ParseListB.cti" +#if !defined(HH_Packets__decls_) && !defined(HH_ListBParser_i_) +#define HH_ListBParser_i_ +//#include "ListBParser.cci" +//#include "ListBParser.ct" +#include "ListBParser.cti" #endif diff --git a/Packets/ParseListB.ih b/Packets/ListBParser.ih similarity index 88% rename from Packets/ParseListB.ih rename to Packets/ListBParser.ih index d5db7b9..f7e2cf5 100644 --- a/Packets/ParseListB.ih +++ b/Packets/ListBParser.ih @@ -21,10 +21,10 @@ // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /** \file - \brief ParseListB internal header */ + \brief ListBParser internal header */ -#ifndef IH_ParseListB_ -#define IH_ParseListB_ 1 +#ifndef IH_ListBParser_ +#define IH_ListBParser_ 1 // Custom includes @@ -33,12 +33,12 @@ namespace senf { namespace detail { - /** \brief Internal: ListPolicy defing the Parse_ListB parser + /** \brief Internal: ListPolicy defing the ListBParser parser \internal - \see \ref Parse_ListB + \see \ref ListBParser */ template - struct Parse_ListB_Policy + struct ListBParser_Policy { // This policy needs to work around a serious problem with this type of list: When we change // the size of any (direct or indirect) subelement of the list, This will change will render @@ -70,8 +70,8 @@ namespace detail { typedef PacketParserBase::state_type state_type; typedef PacketParserBase::size_type size_type; typedef ElementParser element_type; - typedef Parse_List< Parse_ListB_Policy > parser_type; - typedef Parse_List_Container< container_policy > container_type; + typedef ListParser< ListBParser_Policy > parser_type; + typedef ListParser_Container< container_policy > container_type; static const size_type init_bytes = BytesParser::fixed_bytes; @@ -79,7 +79,7 @@ namespace detail { size_type size (iterator i, state_type s) const; void init (iterator i, state_type s) const; - /** \brief Internal: Parse_ListB_Policy's iterator policy + /** \brief Internal: ListBParser_Policy's iterator policy \internal */ struct iterator_policy @@ -91,19 +91,19 @@ namespace detail { iterator raw (iterator i, state_type s) const; }; - /** \brief Internal: Parse_ListB_Policy's container policy + /** \brief Internal: ListBParser_Policy's container policy \internal */ struct container_policy { - typedef typename Parse_ListB_Policy< + typedef typename ListBParser_Policy< ElementParser,BytesParser>::iterator_policy iterator_policy; - typedef typename Parse_ListB_Policy< + typedef typename ListBParser_Policy< ElementParser,BytesParser>::parser_type parser_type; - typedef typename Parse_ListB_Policy< + typedef typename ListBParser_Policy< ElementParser,BytesParser>::element_type element_type; - static const size_type init_bytes = Parse_ListB_Policy< + static const size_type init_bytes = ListBParser_Policy< ElementParser,BytesParser>::init_bytes; container_policy(parser_type const & list); diff --git a/Packets/ParseListB.test.cc b/Packets/ListBParser.test.cc similarity index 81% rename from Packets/ParseListB.test.cc rename to Packets/ListBParser.test.cc index 3264cbf..19c28d9 100644 --- a/Packets/ParseListB.test.cc +++ b/Packets/ListBParser.test.cc @@ -21,10 +21,10 @@ // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /** \file - \brief ParseListB.test unit tests */ + \brief ListBParser.test unit tests */ -//#include "ParseListB.test.hh" -//#include "ParseListB.test.ih" +//#include "ListBParser.test.hh" +//#include "ListBParser.test.ih" // Custom includes #include "Packets.hh" @@ -39,25 +39,25 @@ namespace { struct VoidPacket : public senf::PacketTypeBase {}; - struct ParseVec : public senf::PacketParserBase + struct VectorParser : public senf::PacketParserBase { # include SENF_PARSER() - SENF_PARSER_PRIVATE_FIELD( size, senf::Parse_UInt8 ); - SENF_PARSER_VEC_N( vec, size, senf::Parse_UInt16 ); + SENF_PARSER_PRIVATE_FIELD( size, senf::UInt8Parser ); + SENF_PARSER_VEC_N( vec, size, senf::UInt16Parser ); - SENF_PARSER_FINALIZE(ParseVec); + SENF_PARSER_FINALIZE(VectorParser); }; - typedef senf::Parse_ListB::parser ParseList; + typedef senf::ListBParser::parser MyListBParser; } -BOOST_AUTO_UNIT_TEST(parseListB) +BOOST_AUTO_UNIT_TEST(ListBParser) { senf::PacketInterpreterBase::ptr pi (senf::PacketInterpreter::create( - ParseList::init_bytes)); + MyListBParser::init_bytes)); - ParseList p (pi->data().begin(),&pi->data()); + MyListBParser p (pi->data().begin(),&pi->data()); p.init(); BOOST_CHECK_EQUAL( p.size(), 0u ); BOOST_CHECK_EQUAL( p.bytes(), 2u ); @@ -68,20 +68,20 @@ BOOST_AUTO_UNIT_TEST(parseListB) // on the container wrapper. Here we only need one call to make the list larger ... p.push_back_space(); - p = ParseList(pi->data().begin(),&pi->data()); + p = MyListBParser(pi->data().begin(),&pi->data()); BOOST_CHECK_EQUAL( p.bytes(), 3u ); BOOST_CHECK_EQUAL( p.size(), 1u ); BOOST_CHECK( ! p.empty() ); BOOST_CHECK( p.begin() != p.end() ); } -BOOST_AUTO_UNIT_TEST(parseListB_container) +BOOST_AUTO_UNIT_TEST(ListBParser_container) { senf::PacketInterpreterBase::ptr pi (senf::PacketInterpreter::create( - ParseList::init_bytes)); + MyListBParser::init_bytes)); { - ParseList::container c (ParseList(pi->data().begin(),&pi->data())); + MyListBParser::container c (MyListBParser(pi->data().begin(),&pi->data())); BOOST_CHECK_EQUAL( c.size(), 0u ); BOOST_CHECK_EQUAL( c.bytes(), 2u ); @@ -97,11 +97,11 @@ BOOST_AUTO_UNIT_TEST(parseListB_container) { senf::PacketInterpreterBase::ptr pi2 (senf::PacketInterpreter::create( - ParseList::init_bytes)); - ParseList::container c2 (ParseList(pi2->data().begin(),&pi2->data())); + MyListBParser::init_bytes)); + MyListBParser::container c2 (MyListBParser(pi2->data().begin(),&pi2->data())); c2.push_back_space(); { - ParseVec::vec_t::container c2v (c2.front().vec()); + VectorParser::vec_t::container c2v (c2.front().vec()); c2v.push_back(0x2345u); c2v.push_back(0x3456u); } diff --git a/Packets/ParseListN.ct b/Packets/ListNParser.ct similarity index 88% rename from Packets/ParseListN.ct rename to Packets/ListNParser.ct index 2d48e46..584a6e2 100644 --- a/Packets/ParseListN.ct +++ b/Packets/ListNParser.ct @@ -21,9 +21,9 @@ // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /** \file - \brief ParseListN non-inline template implementation */ + \brief ListNParser non-inline template implementation */ -#include "ParseListN.ih" +#include "ListNParser.ih" // Custom includes @@ -32,7 +32,7 @@ template prefix_ void -senf::detail::Parse_ListN_Policy::iterator_policy:: +senf::detail::ListNParser_Policy::iterator_policy:: setFromPosition(iterator i, state_type s, iterator p) { l_ = i; @@ -49,8 +49,8 @@ setFromPosition(iterator i, state_type s, iterator p) } template -prefix_ typename senf::detail::Parse_ListN_Policy::iterator -senf::detail::Parse_ListN_Policy::iterator_policy::raw(iterator i, +prefix_ typename senf::detail::ListNParser_Policy::iterator +senf::detail::ListNParser_Policy::iterator_policy::raw(iterator i, state_type s) const { diff --git a/Packets/ParseListN.cti b/Packets/ListNParser.cti similarity index 76% rename from Packets/ParseListN.cti rename to Packets/ListNParser.cti index e784a46..3045d1a 100644 --- a/Packets/ParseListN.cti +++ b/Packets/ListNParser.cti @@ -21,9 +21,9 @@ // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /** \file - \brief ParseListN inline template implementation */ + \brief ListNParser inline template implementation */ -#include "ParseListN.ih" +#include "ListNParser.ih" // Custom includes @@ -31,29 +31,29 @@ ///////////////////////////////cti.p/////////////////////////////////////// template -prefix_ typename senf::detail::Parse_ListN_Policy::size_type -senf::detail::Parse_ListN_Policy::bytes(iterator i, state_type s) +prefix_ typename senf::detail::ListNParser_Policy::size_type +senf::detail::ListNParser_Policy::bytes(iterator i, state_type s) const { return std::distance(i,parser_type(i,s).end().raw()); } template -prefix_ typename senf::detail::Parse_ListN_Policy::size_type -senf::detail::Parse_ListN_Policy::size(iterator i, state_type s) +prefix_ typename senf::detail::ListNParser_Policy::size_type +senf::detail::ListNParser_Policy::size(iterator i, state_type s) const { return SizeParser(i,s); } template -prefix_ void senf::detail::Parse_ListN_Policy::init(iterator i, +prefix_ void senf::detail::ListNParser_Policy::init(iterator i, state_type s) const {} template -prefix_ void senf::detail::Parse_ListN_Policy::erase(iterator i, +prefix_ void senf::detail::ListNParser_Policy::erase(iterator i, state_type s, iterator p) const @@ -62,7 +62,7 @@ prefix_ void senf::detail::Parse_ListN_Policy::erase(i } template -prefix_ void senf::detail::Parse_ListN_Policy::insert(iterator i, +prefix_ void senf::detail::ListNParser_Policy::insert(iterator i, state_type s, iterator p) const @@ -71,14 +71,14 @@ prefix_ void senf::detail::Parse_ListN_Policy::insert( } template -prefix_ void senf::detail::Parse_ListN_Policy::update(iterator i, +prefix_ void senf::detail::ListNParser_Policy::update(iterator i, state_type s) const {} template -prefix_ typename senf::detail::Parse_ListN_Policy::iterator -senf::detail::Parse_ListN_Policy::iterator_policy:: +prefix_ typename senf::detail::ListNParser_Policy::iterator +senf::detail::ListNParser_Policy::iterator_policy:: setBegin(iterator i, state_type s) { l_ = i; @@ -87,8 +87,8 @@ setBegin(iterator i, state_type s) } template -prefix_ typename senf::detail::Parse_ListN_Policy::iterator -senf::detail::Parse_ListN_Policy::iterator_policy:: +prefix_ typename senf::detail::ListNParser_Policy::iterator +senf::detail::ListNParser_Policy::iterator_policy:: setEnd(iterator i, state_type s) { l_ = i; @@ -97,8 +97,8 @@ setEnd(iterator i, state_type s) } template -prefix_ typename senf::detail::Parse_ListN_Policy::iterator -senf::detail::Parse_ListN_Policy::iterator_policy::next(iterator i, +prefix_ typename senf::detail::ListNParser_Policy::iterator +senf::detail::ListNParser_Policy::iterator_policy::next(iterator i, state_type s) { --n_; @@ -107,7 +107,7 @@ senf::detail::Parse_ListN_Policy::iterator_policy::nex template prefix_ senf::PacketData & -senf::detail::Parse_ListN_Policy::data(state_type s) +senf::detail::ListNParser_Policy::data(state_type s) { return *s; } diff --git a/Packets/ParseListN.hh b/Packets/ListNParser.hh similarity index 74% rename from Packets/ParseListN.hh rename to Packets/ListNParser.hh index a6cd9e0..af56bc3 100644 --- a/Packets/ParseListN.hh +++ b/Packets/ListNParser.hh @@ -21,44 +21,44 @@ // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /** \file - \brief ParseListN public header */ + \brief ListNParser public header */ -#ifndef HH_ParseListN_ -#define HH_ParseListN_ 1 +#ifndef HH_ListNParser_ +#define HH_ListNParser_ 1 // Custom includes -#include "ParseList.hh" +#include "ListParser.hh" -//#include "ParseListN.mpp" +//#include "ListNParser.mpp" ///////////////////////////////hh.p//////////////////////////////////////// namespace senf { namespace detail { template - class Parse_ListN_Policy; } + class ListNParser_Policy; } /** \brief List parser with size-field giving number of list elements This parser will parse a list which size is giving by a preceding field containing the number of list elements. This struct is just a 'template typedef': \code - senf::Parse_VectorN< Parser_UInt32, Parser_UInt16 >::parser Parse_MyVector; - senf::Parse_ListN< Parse_MyVector, Parse_UInt16 >::parser Parse_MyList; + senf::VectorNParser< Parser_UInt32, Parser_UInt16 >::parser MyVectorParser; + senf::ListNParser< MyVectorParser, UInt16Parser >::parser MyListParser; \endcode This first defines a Vector of 32 bit unsigned integers with 16 bit length counter. Then it defines a list of such vectors with a 16 bit size field. - \see Parse_List + \see ListParser \ingroup parsecollection */ template - struct Parse_ListN { - typedef Parse_List< detail::Parse_ListN_Policy > parser; + struct ListNParser { + typedef ListParser< detail::ListNParser_Policy > parser; }; - /** \brief Define Parse_ListN field + /** \brief Define ListNParser field - This macro is a special helper to define a senf::Parse_ListN type field, a list of elements + This macro is a special helper to define a senf::ListNParser type field, a list of elements of type \a elt_type (a parser type) directly preceded by a numeric size field of type \a size_type (another parser type). @@ -69,18 +69,18 @@ namespace senf { \ingroup packetparsermacros */ # define SENF_PARSER_LIST_N(name, elt_type, size_type) \ - typedef senf::Parse_ListN::parser BOOST_PP_CAT(name, _list_t); \ + typedef senf::ListNParser::parser BOOST_PP_CAT(name, _list_t); \ SENF_PARSER_FIELD( name, BOOST_PP_CAT(name, _list_t) ) } ///////////////////////////////hh.e//////////////////////////////////////// #endif -#if !defined(HH_Packets__decls_) && !defined(HH_ParseListN_i_) -#define HH_ParseListN_i_ -//#include "ParseListN.cci" -#include "ParseListN.ct" -#include "ParseListN.cti" +#if !defined(HH_Packets__decls_) && !defined(HH_ListNParser_i_) +#define HH_ListNParser_i_ +//#include "ListNParser.cci" +#include "ListNParser.ct" +#include "ListNParser.cti" #endif diff --git a/Packets/ParseListN.ih b/Packets/ListNParser.ih similarity index 86% rename from Packets/ParseListN.ih rename to Packets/ListNParser.ih index 8088fad..9aa1312 100644 --- a/Packets/ParseListN.ih +++ b/Packets/ListNParser.ih @@ -21,10 +21,10 @@ // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /** \file - \brief ParseListN internal header */ + \brief ListNParser internal header */ -#ifndef IH_ParseListN_ -#define IH_ParseListN_ 1 +#ifndef IH_ListNParser_ +#define IH_ListNParser_ 1 // Custom includes @@ -33,19 +33,19 @@ namespace senf { namespace detail { - /** \brief Internal: ListPolicy defining the Parse_ListN parser + /** \brief Internal: ListPolicy defining the ListNParser parser \internal - \see \ref Parse_ListN + \see \ref ListNParser */ template - struct Parse_ListN_Policy + struct ListNParser_Policy { typedef PacketParserBase::data_iterator iterator; typedef PacketParserBase::state_type state_type; typedef PacketParserBase::size_type size_type; typedef ElementParser element_type; - typedef Parse_List< Parse_ListN_Policy > parser_type; - typedef Parse_List_Container< Parse_ListN_Policy > container_type; + typedef ListParser< ListNParser_Policy > parser_type; + typedef ListParser_Container< ListNParser_Policy > container_type; static const size_type init_bytes = SizeParser::fixed_bytes; @@ -56,7 +56,7 @@ namespace detail { void insert (iterator i, state_type s, iterator p) const; void update (iterator i, state_type s) const; - /** \brief Iternal: Parse_ListN_Policy's iterator policy + /** \brief Iternal: ListNParser_Policy's iterator policy \internal */ struct iterator_policy diff --git a/Packets/ParseListN.test.cc b/Packets/ListNParser.test.cc similarity index 80% rename from Packets/ParseListN.test.cc rename to Packets/ListNParser.test.cc index 44a7b08..f2d7182 100644 --- a/Packets/ParseListN.test.cc +++ b/Packets/ListNParser.test.cc @@ -21,10 +21,10 @@ // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /** \file - \brief ParseListN.test unit tests */ + \brief ListNParser.test unit tests */ -//#include "ParseListN.test.hh" -//#include "ParseListN.test.ih" +//#include "ListNParser.test.hh" +//#include "ListNParser.test.ih" // Custom includes #include "Packets.hh" @@ -44,21 +44,21 @@ namespace { { # include SENF_PARSER() - SENF_PARSER_PRIVATE_FIELD( size, senf::Parse_UInt8 ); - SENF_PARSER_VEC_N( vec, size, senf::Parse_UInt16 ); + SENF_PARSER_PRIVATE_FIELD( size, senf::UInt8Parser ); + SENF_PARSER_VEC_N( vec, size, senf::UInt16Parser ); SENF_PARSER_FINALIZE(MyVec); }; } -BOOST_AUTO_UNIT_TEST(parseListN) +BOOST_AUTO_UNIT_TEST(ListNParser) { - typedef senf::Parse_ListN::parser ParseList; + typedef senf::ListNParser::parser MyListNParser; - VoidPacket vp (VoidPacket::create(ParseList::init_bytes)); + VoidPacket vp (VoidPacket::create(MyListNParser::init_bytes)); { - ParseList p (vp.data().begin(),&vp.data()); + MyListNParser p (vp.data().begin(),&vp.data()); p.init(); BOOST_CHECK_EQUAL( p.size(), 0u ); BOOST_CHECK_EQUAL( p.bytes(), 2u ); @@ -67,7 +67,7 @@ BOOST_AUTO_UNIT_TEST(parseListN) } { -# define p ParseList(vp.data().begin(),&vp.data()) +# define p MyListNParser(vp.data().begin(),&vp.data()) p.push_back_space(); BOOST_CHECK_EQUAL( p.bytes(), 3u ); @@ -108,13 +108,13 @@ BOOST_AUTO_UNIT_TEST(parseListN) } } -BOOST_AUTO_UNIT_TEST(parseListN_container) +BOOST_AUTO_UNIT_TEST(ListNParser_container) { - typedef senf::Parse_ListN::parser ParseList; + typedef senf::ListNParser::parser MyListNParser; - VoidPacket vp (VoidPacket::create(ParseList::init_bytes)); + VoidPacket vp (VoidPacket::create(MyListNParser::init_bytes)); - ParseList(vp.data().begin(),&vp.data()).init(); + MyListNParser(vp.data().begin(),&vp.data()).init(); } diff --git a/Packets/ParseList.ct b/Packets/ListParser.ct similarity index 84% rename from Packets/ParseList.ct rename to Packets/ListParser.ct index 85fbcf7..883fef6 100644 --- a/Packets/ParseList.ct +++ b/Packets/ListParser.ct @@ -21,9 +21,9 @@ // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /** \file - \brief ParseList non-inline template implementation */ + \brief ListParser non-inline template implementation */ -#include "ParseList.ih" +#include "ListParser.ih" // Custom includes @@ -31,10 +31,10 @@ ///////////////////////////////ct.p//////////////////////////////////////// /////////////////////////////////////////////////////////////////////////// -// senf::Parse_List +// senf::ListParser template -prefix_ void senf::Parse_List::init() +prefix_ void senf::ListParser::init() const { ListPolicy::init(i(),state()); @@ -45,8 +45,8 @@ prefix_ void senf::Parse_List::init() } template -prefix_ typename senf::Parse_List::value_type -senf::Parse_List::back() +prefix_ typename senf::ListParser::value_type +senf::ListParser::back() const { BOOST_ASSERT( ! empty() ); @@ -57,11 +57,11 @@ senf::Parse_List::back() } /////////////////////////////////////////////////////////////////////////// -// senf::Parse_List_Container +// senf::ListParser_Container template -prefix_ typename senf::Parse_List_Container::value_type -senf::Parse_List_Container::back() +prefix_ typename senf::ListParser_Container::value_type +senf::ListParser_Container::back() const { BOOST_ASSERT( ! empty() ); @@ -72,7 +72,7 @@ senf::Parse_List_Container::back() } template -prefix_ void senf::Parse_List_Container::shift(iterator pos, size_type n) +prefix_ void senf::ListParser_Container::shift(iterator pos, size_type n) { ListPolicy::update(i(),state()); safe_data_iterator sp (data(),pos.raw()); @@ -86,7 +86,7 @@ prefix_ void senf::Parse_List_Container::shift(iterator pos, size_ty template template -prefix_ void senf::Parse_List_Container::insert(iterator pos, +prefix_ void senf::ListParser_Container::insert(iterator pos, size_type n, Value const & t) { @@ -104,7 +104,7 @@ prefix_ void senf::Parse_List_Container::insert(iterator pos, #ifndef DOXYGEN template template -prefix_ void senf::Parse_List_Container:: +prefix_ void senf::ListParser_Container:: insert(iterator pos, ForwardIterator f, ForwardIterator l, typename boost::disable_if< boost::is_convertible >::type *) { @@ -122,13 +122,13 @@ insert(iterator pos, ForwardIterator f, ForwardIterator l, #else template template -prefix_ void senf::Parse_List_Container:: +prefix_ void senf::ListParser_Container:: insert(iterator pos, ForwardIterator f, ForwardIterator l) {} #endif template -prefix_ void senf::Parse_List_Container::erase(iterator pos, +prefix_ void senf::ListParser_Container::erase(iterator pos, size_type n) { ListPolicy::update(i(),state()); @@ -141,7 +141,7 @@ prefix_ void senf::Parse_List_Container::erase(iterator pos, } template -prefix_ void senf::Parse_List_Container::clear() +prefix_ void senf::ListParser_Container::clear() { size_type sz (bytes()); if (sz > ListPolicy::init_bytes) @@ -153,7 +153,7 @@ prefix_ void senf::Parse_List_Container::clear() } template -prefix_ void senf::Parse_List_Container::resize(size_type n) +prefix_ void senf::ListParser_Container::resize(size_type n) { size_type sz (size()); if (sz>n) @@ -164,7 +164,7 @@ prefix_ void senf::Parse_List_Container::resize(size_type n) template template -prefix_ void senf::Parse_List_Container::resize(size_type n, +prefix_ void senf::ListParser_Container::resize(size_type n, Value value) { size_type sz (size()); diff --git a/Packets/ParseList.cti b/Packets/ListParser.cti similarity index 64% rename from Packets/ParseList.cti rename to Packets/ListParser.cti index d80dd58..3e81bda 100644 --- a/Packets/ParseList.cti +++ b/Packets/ListParser.cti @@ -21,9 +21,9 @@ // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /** \file - \brief ParseList inline template implementation */ + \brief ListParser inline template implementation */ -#include "ParseList.ih" +#include "ListParser.ih" // Custom includes @@ -31,22 +31,22 @@ ///////////////////////////////cti.p/////////////////////////////////////// /////////////////////////////////////////////////////////////////////////// -// senf::Parse_List +// senf::ListParser template -prefix_ senf::Parse_List::Parse_List(data_iterator i, state_type s) +prefix_ senf::ListParser::ListParser(data_iterator i, state_type s) : PacketParserBase(i,s), ListPolicy() {} template -prefix_ senf::Parse_List::Parse_List(ListPolicy policy, +prefix_ senf::ListParser::ListParser(ListPolicy policy, data_iterator i, state_type s) : PacketParserBase(i,s), ListPolicy(policy) {} template prefix_ senf::PacketParserBase::size_type -senf::Parse_List::bytes() +senf::ListParser::bytes() const { return ListPolicy::bytes(i(),state()); @@ -57,38 +57,38 @@ senf::Parse_List::bytes() template prefix_ senf::PacketParserBase::size_type -senf::Parse_List::size() +senf::ListParser::size() const { return ListPolicy::size(i(),state()); } template -prefix_ bool senf::Parse_List::empty() +prefix_ bool senf::ListParser::empty() const { return begin() == end(); } template -prefix_ typename senf::Parse_List::iterator -senf::Parse_List::begin() +prefix_ typename senf::ListParser::iterator +senf::ListParser::begin() const { return iterator(i(),state(),iterator::Begin); } template -prefix_ typename senf::Parse_List::iterator -senf::Parse_List::end() +prefix_ typename senf::ListParser::iterator +senf::ListParser::end() const { return iterator(i(),state(),iterator::End); } template -prefix_ typename senf::Parse_List::value_type -senf::Parse_List::front() +prefix_ typename senf::ListParser::value_type +senf::ListParser::front() const { BOOST_ASSERT( ! empty() ); @@ -97,7 +97,7 @@ senf::Parse_List::front() template template -prefix_ void senf::Parse_List::push_back(Value value, size_type n) +prefix_ void senf::ListParser::push_back(Value value, size_type n) const { container c(*this); @@ -105,7 +105,7 @@ prefix_ void senf::Parse_List::push_back(Value value, size_type n) } template -prefix_ void senf::Parse_List::push_back_space(size_type n) +prefix_ void senf::ListParser::push_back_space(size_type n) const { container c(*this); @@ -114,7 +114,7 @@ prefix_ void senf::Parse_List::push_back_space(size_type n) template template -prefix_ void senf::Parse_List::push_front(Value value, size_type n) +prefix_ void senf::ListParser::push_front(Value value, size_type n) const { container c(*this); @@ -122,7 +122,7 @@ prefix_ void senf::Parse_List::push_front(Value value, size_type n) } template -prefix_ void senf::Parse_List::push_front_space(size_type n) +prefix_ void senf::ListParser::push_front_space(size_type n) const { container c(*this); @@ -130,7 +130,7 @@ prefix_ void senf::Parse_List::push_front_space(size_type n) } template -prefix_ void senf::Parse_List::resize(size_type n) +prefix_ void senf::ListParser::resize(size_type n) const { container c(*this); @@ -139,7 +139,7 @@ prefix_ void senf::Parse_List::resize(size_type n) template template -prefix_ void senf::Parse_List::resize(size_type n, Value value) +prefix_ void senf::ListParser::resize(size_type n, Value value) const { container c(*this); @@ -147,27 +147,27 @@ prefix_ void senf::Parse_List::resize(size_type n, Value value) } /////////////////////////////////////////////////////////////////////////// -// senf::detail::Parse_List_Iterator +// senf::detail::ListParser_Iterator template -prefix_ senf::detail::Parse_List_Iterator::Parse_List_Iterator() +prefix_ senf::detail::ListParser_Iterator::ListParser_Iterator() {} template -prefix_ senf::detail::Parse_List_Iterator:: -Parse_List_Iterator(PacketParserBase::data_iterator i, PacketParserBase::state_type s, Begin_t) +prefix_ senf::detail::ListParser_Iterator:: +ListParser_Iterator(PacketParserBase::data_iterator i, PacketParserBase::state_type s, Begin_t) : IteratorPolicy(), i_(IteratorPolicy::setBegin(i,s)), s_(s) {} template -prefix_ senf::detail::Parse_List_Iterator:: -Parse_List_Iterator(PacketParserBase::data_iterator i, PacketParserBase::state_type s, End_t) +prefix_ senf::detail::ListParser_Iterator:: +ListParser_Iterator(PacketParserBase::data_iterator i, PacketParserBase::state_type s, End_t) : IteratorPolicy(), i_(IteratorPolicy::setEnd(i,s)), s_(s) {} template -prefix_ senf::detail::Parse_List_Iterator:: -Parse_List_Iterator(PacketParserBase::data_iterator i, PacketParserBase::state_type s, +prefix_ senf::detail::ListParser_Iterator:: +ListParser_Iterator(PacketParserBase::data_iterator i, PacketParserBase::state_type s, PacketParserBase::data_iterator p) : IteratorPolicy(), i_(p), s_(s) { @@ -176,7 +176,7 @@ Parse_List_Iterator(PacketParserBase::data_iterator i, PacketParserBase::state_t template prefix_ senf::PacketParserBase::data_iterator -senf::detail::Parse_List_Iterator::raw() +senf::detail::ListParser_Iterator::raw() const { return IteratorPolicy::raw(i_,s_); @@ -184,39 +184,39 @@ senf::detail::Parse_List_Iterator::raw() template prefix_ ElementParser -senf::detail::Parse_List_Iterator::dereference() +senf::detail::ListParser_Iterator::dereference() const { return ElementParser(i_,s_); } template -prefix_ bool senf::detail::Parse_List_Iterator:: -equal(Parse_List_Iterator const & other) +prefix_ bool senf::detail::ListParser_Iterator:: +equal(ListParser_Iterator const & other) const { return i_ == other.i_; } template -prefix_ void senf::detail::Parse_List_Iterator::increment() +prefix_ void senf::detail::ListParser_Iterator::increment() { i_ = IteratorPolicy::next(i_,s_); } /////////////////////////////////////////////////////////////////////////// -// senf::Parse_List_Container +// senf::ListParser_Container // Structors and default members template -prefix_ senf::Parse_List_Container:: -Parse_List_Container(parser_type const & list) +prefix_ senf::ListParser_Container:: +ListParser_Container(parser_type const & list) : ListPolicy(list), state_(list.state()), i_(std::distance(data().begin(),list.i())) {} template -prefix_ senf::Parse_List_Container::~Parse_List_Container() +prefix_ senf::ListParser_Container::~ListParser_Container() { ListPolicy::update(i(),state()); } @@ -224,8 +224,8 @@ prefix_ senf::Parse_List_Container::~Parse_List_Container() // Accessors template -prefix_ typename senf::Parse_List_Container::size_type -senf::Parse_List_Container::size() +prefix_ typename senf::ListParser_Container::size_type +senf::ListParser_Container::size() const { ListPolicy::update(i(),state()); @@ -233,7 +233,7 @@ senf::Parse_List_Container::size() } template -prefix_ bool senf::Parse_List_Container::empty() +prefix_ bool senf::ListParser_Container::empty() const { ListPolicy::update(i(),state()); @@ -241,8 +241,8 @@ prefix_ bool senf::Parse_List_Container::empty() } template -prefix_ typename senf::Parse_List_Container::iterator -senf::Parse_List_Container::begin() +prefix_ typename senf::ListParser_Container::iterator +senf::ListParser_Container::begin() const { ListPolicy::update(i(),state()); @@ -250,8 +250,8 @@ senf::Parse_List_Container::begin() } template -prefix_ typename senf::Parse_List_Container::iterator -senf::Parse_List_Container::end() +prefix_ typename senf::ListParser_Container::iterator +senf::ListParser_Container::end() const { ListPolicy::update(i(),state()); @@ -259,8 +259,8 @@ senf::Parse_List_Container::end() } template -prefix_ typename senf::Parse_List_Container::value_type -senf::Parse_List_Container::front() +prefix_ typename senf::ListParser_Container::value_type +senf::ListParser_Container::front() const { BOOST_ASSERT( ! empty() ); @@ -271,42 +271,42 @@ senf::Parse_List_Container::front() template template -prefix_ void senf::Parse_List_Container::insert(iterator pos, +prefix_ void senf::ListParser_Container::insert(iterator pos, Value const & t) { insert(pos,1,t); } template -prefix_ void senf::Parse_List_Container::erase(iterator f, iterator l) +prefix_ void senf::ListParser_Container::erase(iterator f, iterator l) { erase(f,std::distance(f,l)); } template template -prefix_ void senf::Parse_List_Container::push_back(Value value, +prefix_ void senf::ListParser_Container::push_back(Value value, size_type n) { insert(end(),n,value); } template -prefix_ void senf::Parse_List_Container::push_back_space(size_type n) +prefix_ void senf::ListParser_Container::push_back_space(size_type n) { shift(end(),n); } template template -prefix_ void senf::Parse_List_Container::push_front(Value value, +prefix_ void senf::ListParser_Container::push_front(Value value, size_type n) { insert(begin(),n,value); } template -prefix_ void senf::Parse_List_Container::push_front_space(size_type n) +prefix_ void senf::ListParser_Container::push_front_space(size_type n) { shift(begin(),n); } @@ -314,8 +314,8 @@ prefix_ void senf::Parse_List_Container::push_front_space(size_type // Parser interface template -prefix_ typename senf::Parse_List_Container::parser_type -senf::Parse_List_Container::parser() +prefix_ typename senf::ListParser_Container::parser_type +senf::ListParser_Container::parser() const { ListPolicy::update(i(),state()); @@ -323,31 +323,31 @@ senf::Parse_List_Container::parser() } template -prefix_ typename senf::Parse_List_Container::data_iterator -senf::Parse_List_Container::i() +prefix_ typename senf::ListParser_Container::data_iterator +senf::ListParser_Container::i() const { return boost::next(data().begin(),i_); } template -prefix_ typename senf::Parse_List_Container::state_type -senf::Parse_List_Container::state() +prefix_ typename senf::ListParser_Container::state_type +senf::ListParser_Container::state() const { return state_; } template -prefix_ senf::PacketData & senf::Parse_List_Container::data() +prefix_ senf::PacketData & senf::ListParser_Container::data() const { return *state_; } template -prefix_ typename senf::Parse_List_Container::size_type -senf::Parse_List_Container::bytes() +prefix_ typename senf::ListParser_Container::size_type +senf::ListParser_Container::bytes() const { ListPolicy::update(i(),state()); @@ -355,7 +355,7 @@ senf::Parse_List_Container::bytes() } template -prefix_ void senf::Parse_List_Container::init() +prefix_ void senf::ListParser_Container::init() const { parser().init(); diff --git a/Packets/ParseList.dox b/Packets/ListParser.dox similarity index 100% rename from Packets/ParseList.dox rename to Packets/ListParser.dox diff --git a/Packets/ParseList.hh b/Packets/ListParser.hh similarity index 90% rename from Packets/ParseList.hh rename to Packets/ListParser.hh index 6f0387f..d0d30e8 100644 --- a/Packets/ParseList.hh +++ b/Packets/ListParser.hh @@ -21,25 +21,25 @@ // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /** \file - \brief ParseList public header */ + \brief ListParser public header */ -#ifndef HH_ParseList_ -#define HH_ParseList_ 1 +#ifndef HH_ListParser_ +#define HH_ListParser_ 1 // Custom includes #include #include "PacketParser.hh" -//#include "ParseList.mpp" +//#include "ListParser.mpp" ///////////////////////////////hh.p//////////////////////////////////////// namespace senf { namespace detail { template - class Parse_List_Iterator; } + class ListParser_Iterator; } template - class Parse_List_Container; + class ListParser_Container; /** \brief Arbitrary sequential element collection @@ -60,13 +60,13 @@ namespace senf { \ingroup parsecollection */ template - class Parse_List + class ListParser : public PacketParserBase, private ListPolicy { public: - Parse_List(data_iterator i, state_type s); - Parse_List(ListPolicy policy, data_iterator i, state_type s); + ListParser(data_iterator i, state_type s); + ListParser(ListPolicy policy, data_iterator i, state_type s); ///< Additional policy specific constructor /**< This constructor may be used, if the policy needs additional parameters. */ @@ -80,7 +80,7 @@ namespace senf { // Container interface typedef typename ListPolicy::element_type value_type; - typedef detail::Parse_List_Iterator< + typedef detail::ListParser_Iterator< value_type, typename ListPolicy::iterator_policy > iterator; typedef iterator const_iterator; typedef typename ListPolicy::container_type container; @@ -102,10 +102,10 @@ namespace senf { template void resize (size_type n, Value value) const; private: - template friend class Parse_List_Container; + template friend class ListParser_Container; }; - /** \brief Parse_List container wrapper + /** \brief ListParser container wrapper This is the container wrapper used for list parsers. The container wrapper will stay valid after changing the collection. However the container still depends on the packet and will be @@ -121,10 +121,10 @@ namespace senf { c.insert(c.begin(), ... ); \endcode - \see Parse_List + \see ListParser */ template - class Parse_List_Container + class ListParser_Container : private ListPolicy { public: @@ -136,7 +136,7 @@ namespace senf { typedef PacketParserBase::size_type size_type; typedef PacketParserBase::difference_type difference_type; typedef typename ListPolicy::element_type value_type; - typedef detail::Parse_List_Iterator< + typedef detail::ListParser_Iterator< value_type, typename ListPolicy::iterator_policy> iterator; typedef iterator const_iterator; typedef PacketParserBase::state_type state_type; @@ -150,8 +150,8 @@ namespace senf { // default destructor // conversion constructors - Parse_List_Container(parser_type const & list); - ~Parse_List_Container(); + ListParser_Container(parser_type const & list); + ~ListParser_Container(); ///@} /////////////////////////////////////////////////////////////////////////// @@ -222,11 +222,11 @@ namespace senf { ///////////////////////////////hh.e//////////////////////////////////////// #endif -#if !defined(HH_Packets__decls_) && !defined(HH_ParseList_i_) -#define HH_ParseList_i_ -//#include "ParseList.cci" -#include "ParseList.ct" -#include "ParseList.cti" +#if !defined(HH_Packets__decls_) && !defined(HH_ListParser_i_) +#define HH_ListParser_i_ +//#include "ListParser.cci" +#include "ListParser.ct" +#include "ListParser.cti" #endif diff --git a/Packets/ParseList.ih b/Packets/ListParser.ih similarity index 81% rename from Packets/ParseList.ih rename to Packets/ListParser.ih index a3695f1..5fd149e 100644 --- a/Packets/ParseList.ih +++ b/Packets/ListParser.ih @@ -21,10 +21,10 @@ // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /** \file - \brief ParseList internal header */ + \brief ListParser internal header */ -#ifndef IH_ParseList_ -#define IH_ParseList_ 1 +#ifndef IH_ListParser_ +#define IH_ListParser_ 1 // Custom includes #include @@ -34,13 +34,13 @@ namespace senf { namespace detail { - /** \brief Internal: Iterator used by Parse_List + /** \brief Internal: Iterator used by ListParser \internal */ template - class Parse_List_Iterator - : public boost::iterator_facade< Parse_List_Iterator, + class ListParser_Iterator + : public boost::iterator_facade< ListParser_Iterator, ElementParser, boost::forward_traversal_tag, ElementParser >, @@ -50,12 +50,12 @@ namespace detail { enum Begin_t { Begin }; enum End_t { End }; - Parse_List_Iterator(); - Parse_List_Iterator(PacketParserBase::data_iterator i, PacketParserBase::state_type s, + ListParser_Iterator(); + ListParser_Iterator(PacketParserBase::data_iterator i, PacketParserBase::state_type s, Begin_t); - Parse_List_Iterator(PacketParserBase::data_iterator i, PacketParserBase::state_type s, + ListParser_Iterator(PacketParserBase::data_iterator i, PacketParserBase::state_type s, End_t); - Parse_List_Iterator(PacketParserBase::data_iterator i, PacketParserBase::state_type s, + ListParser_Iterator(PacketParserBase::data_iterator i, PacketParserBase::state_type s, PacketParserBase::data_iterator p); PacketParserBase::data_iterator raw() const; @@ -64,7 +64,7 @@ namespace detail { friend class boost::iterator_core_access; ElementParser dereference() const; - bool equal(Parse_List_Iterator const & other) const; + bool equal(ListParser_Iterator const & other) const; void increment(); PacketParserBase::data_iterator i_; diff --git a/Packets/ParseList.test.cc b/Packets/ListParser.test.cc similarity index 85% rename from Packets/ParseList.test.cc rename to Packets/ListParser.test.cc index 52d0d5b..c08881c 100644 --- a/Packets/ParseList.test.cc +++ b/Packets/ListParser.test.cc @@ -21,10 +21,10 @@ // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /** \file - \brief ParseList.test unit tests */ + \brief ListParser.test unit tests */ -//#include "ParseList.test.hh" -//#include "ParseList.test.ih" +//#include "ListParser.test.hh" +//#include "ListParser.test.ih" // Custom includes #include "Packets.hh" @@ -36,8 +36,8 @@ ///////////////////////////////cc.p//////////////////////////////////////// // Since the list cannot be instantiated without a policy, there is nothing to test without atleast -// a very simple policy. Since ParseListB provides a policy which is as simple as it can get, all -// testing is performed in ParseListB.test.cc +// a very simple policy. Since ListBParser provides a policy which is as simple as it can get, all +// testing is performed in ListBParser.test.cc ///////////////////////////////cc.e//////////////////////////////////////// #undef prefix_ diff --git a/Packets/MPEGDVBBundle/DTCPPacket.hh b/Packets/MPEGDVBBundle/DTCPPacket.hh index eca766e..1412805 100644 --- a/Packets/MPEGDVBBundle/DTCPPacket.hh +++ b/Packets/MPEGDVBBundle/DTCPPacket.hh @@ -33,18 +33,18 @@ namespace senf { //first we have to define some helpers struct DTCPIPv4AddressListParser : public PacketParserBase { # include SENF_PARSER() - SENF_PARSER_PRIVATE_FIELD ( num_of_fbips, Parse_UInt8 ); - SENF_PARSER_PRIVATE_FIELD ( reserved , Parse_UInt8 ); //must be zero - SENF_PARSER_VEC_N ( fbiplist, num_of_fbips, Parse_INet4Address ); + SENF_PARSER_PRIVATE_FIELD ( num_of_fbips, UInt8Parser ); + SENF_PARSER_PRIVATE_FIELD ( reserved , UInt8Parser ); //must be zero + SENF_PARSER_VEC_N ( fbiplist, num_of_fbips, INet4AddressParser ); SENF_PARSER_FINALIZE(DTCPIPv4AddressListParser); }; struct DTCPIPv6AddressListParser : public PacketParserBase { # include SENF_PARSER() - SENF_PARSER_PRIVATE_FIELD ( num_of_fbips, Parse_UInt8 ); - SENF_PARSER_PRIVATE_FIELD ( reserved, Parse_UInt8 ); //must be zero - SENF_PARSER_VEC_N ( fbiplist, num_of_fbips, Parse_INet6Address ); + SENF_PARSER_PRIVATE_FIELD ( num_of_fbips, UInt8Parser ); + SENF_PARSER_PRIVATE_FIELD ( reserved, UInt8Parser ); //must be zero + SENF_PARSER_VEC_N ( fbiplist, num_of_fbips, INet6AddressParser ); SENF_PARSER_FINALIZE(DTCPIPv6AddressListParser); }; @@ -55,18 +55,18 @@ namespace senf { \see DTCPPacketType */ - struct Parse_DTCPPacket : public PacketParserBase + struct DTCPPacketParser : public PacketParserBase { # include SENF_PARSER() SENF_PARSER_BITFIELD ( version_number, 4, unsigned ); // =1 according to rfc3077 SENF_PARSER_BITFIELD ( command, 4, unsigned ); // 1=JOIN 2=LEAVE - SENF_PARSER_FIELD ( interval, Parse_UInt8 ); // 5 according to rfc3077 - SENF_PARSER_FIELD ( sequence_number, Parse_UInt16 ); + SENF_PARSER_FIELD ( interval, UInt8Parser ); // 5 according to rfc3077 + SENF_PARSER_FIELD ( sequence_number, UInt16Parser ); SENF_PARSER_PRIVATE_BITFIELD ( reserved, 3, unsigned ); SENF_PARSER_BITFIELD ( receive_capable_feed, 1, bool ); // 0=send only, 1=receive_capable_feed SENF_PARSER_BITFIELD ( ip_version, 4, unsigned ); // 4=IPv4, 6=IPv6 - SENF_PARSER_FIELD ( tunnel_protocol, Parse_UInt8 ); + SENF_PARSER_FIELD ( tunnel_protocol, UInt8Parser ); /* Please consider the following comments on the implementation given in this class: * 1. you could think of simply using SENF_PARSER_PRIVATE_VARIANT and List / Vectorparser like this: * SENF_PARSER_PRIVATE_VARIANT ( fbiplist, ip_version, @@ -74,9 +74,9 @@ namespace senf { * (senf::VoidPacketParser) //1 * (senf::VoidPacketParser) //2 * (senf::VoidPacketParser) //3 - * (senf::Parse_ListB< IPv4Packet, num_of_fbips>) //4 + * (senf::ListBParser< IPv4Packet, num_of_fbips>) //4 * (senf::VoidPacketParser) //5 - * (senf::Parse_ListB< IPv6Packet, num_of_fbips>) ); //6 + * (senf::ListBParser< IPv6Packet, num_of_fbips>) ); //6 * This can't work for two reasons: * -SENF_PARSER_PRIVATE_VARIANT only accepts 6 templates in types but you have to start from 0. * -you NEVER can use templated Parsers in these macros since the macro-preprocessor won't recognize the <> brackets and will @@ -108,7 +108,7 @@ namespace senf { (senf::DTCPIPv4AddressListParser) //IPv4 (senf::DTCPIPv6AddressListParser) ); //IPv6 - SENF_PARSER_FINALIZE(Parse_DTCPPacket); + SENF_PARSER_FINALIZE(DTCPPacketParser); }; /** \brief DTCP packet @@ -117,7 +117,7 @@ namespace senf { \ref DTCPPacket \par Fields: - \ref Parse_DTCPPacket + \ref DTCPPacketParser \ingroup protocolbundle_mpegdvb */ @@ -127,7 +127,7 @@ namespace senf { { typedef PacketTypeMixin mixin; typedef ConcretePacket packet; - typedef Parse_DTCPPacket parser; + typedef DTCPPacketParser parser; using mixin::nextPacketRange; using mixin::init; diff --git a/Packets/MPEGDVBBundle/GREPacket.hh b/Packets/MPEGDVBBundle/GREPacket.hh index bbf21f8..2bdf24f 100644 --- a/Packets/MPEGDVBBundle/GREPacket.hh +++ b/Packets/MPEGDVBBundle/GREPacket.hh @@ -44,26 +44,26 @@ namespace senf { */ struct GREChecksumParser : public PacketParserBase { # include SENF_PARSER() - SENF_PARSER_FIELD ( checksum1_, Parse_UInt16 ); - SENF_PARSER_PRIVATE_FIELD ( reserved1_, Parse_UInt16 ); + SENF_PARSER_FIELD ( checksum1_, UInt16Parser ); + SENF_PARSER_PRIVATE_FIELD ( reserved1_, UInt16Parser ); SENF_PARSER_FINALIZE(GREChecksumParser); }; - struct Parse_GREPacket : public PacketParserBase + struct GREPacketParser : public PacketParserBase { # include SENF_PARSER() SENF_PARSER_BITFIELD ( checksum_present, 1, bool ); SENF_PARSER_PRIVATE_BITFIELD ( reserved0_, 12, unsigned ); // TODO: SKIP !! SENF_PARSER_BITFIELD ( version_number, 3, unsigned ); // TODO: Always Zero !! - SENF_PARSER_FIELD ( protocol_type, Parse_UInt16 ); + SENF_PARSER_FIELD ( protocol_type, UInt16Parser ); SENF_PARSER_PRIVATE_VARIANT ( checksum_, checksum_present, (VoidPacketParser) (GREChecksumParser) ); - SENF_PARSER_FINALIZE( Parse_GREPacket ); + SENF_PARSER_FINALIZE( GREPacketParser ); private: - Parse_UInt16 checksum() const /// only defined if checksum_present() == \c true + UInt16Parser checksum() const /// only defined if checksum_present() == \c true { return checksum_().get<1>().checksum1_(); } }; @@ -73,7 +73,7 @@ namespace senf { \ref GREPacket \par Fields: - \ref Parse_GREPacket + \ref GREPacketParser \ingroup protocolbundle_mpegdvb */ @@ -83,7 +83,7 @@ namespace senf { { typedef PacketTypeMixin mixin; typedef ConcretePacket packet; - typedef Parse_GREPacket parser; + typedef GREPacketParser parser; using mixin::nextPacketRange; using mixin::nextPacketType; diff --git a/Packets/MPEGDVBBundle/GREPacket.test.cc b/Packets/MPEGDVBBundle/GREPacket.test.cc index 52d38ef..e9a41a9 100644 --- a/Packets/MPEGDVBBundle/GREPacket.test.cc +++ b/Packets/MPEGDVBBundle/GREPacket.test.cc @@ -1,4 +1,4 @@ -// $Id$ +// $Id:GREPacket.test.cc 560 2007-12-13 14:39:37Z tho $ // // Copyright (C) 2007 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS) @@ -40,7 +40,7 @@ BOOST_AUTO_UNIT_TEST(GREPacket_packet) { senf::GREPacket p (senf::GREPacket::create()); - BOOST_CHECK_EQUAL( senf::Parse_GREPacket::init_bytes+0u, 4u ); + BOOST_CHECK_EQUAL( senf::GREPacketParser::init_bytes+0u, 4u ); //BOOST_CHECK_EQUAL( p->bytes(), 4u ); } diff --git a/Packets/MPEGDVBBundle/MPESection.cc b/Packets/MPEGDVBBundle/MPESection.cc index d6b2d5e..1459639 100644 --- a/Packets/MPEGDVBBundle/MPESection.cc +++ b/Packets/MPEGDVBBundle/MPESection.cc @@ -36,7 +36,7 @@ #define prefix_ ///////////////////////////////cc.p//////////////////////////////////////// -//prefix_ boost::uint32_t senf::Parse_MPESection::calcCrc() +//prefix_ boost::uint32_t senf::MPESectionParser::calcCrc() // const //{ // return std::for_each( diff --git a/Packets/MPEGDVBBundle/MPESection.hh b/Packets/MPEGDVBBundle/MPESection.hh index 33a9fdf..dee67d2 100644 --- a/Packets/MPEGDVBBundle/MPESection.hh +++ b/Packets/MPEGDVBBundle/MPESection.hh @@ -1,4 +1,4 @@ -// $Id$ +// $Id:MPESection.hh 560 2007-12-13 14:39:37Z tho $ // // Copyright (C) 2007 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS) @@ -36,7 +36,7 @@ namespace senf { - struct Parse_MPERealTimeParameters : public PacketParserBase + struct MPERealTimeParametersParser : public PacketParserBase { # include SENF_FIXED_PARSER() @@ -45,7 +45,7 @@ namespace senf { SENF_PARSER_BITFIELD ( frame_boundary, 1, bool ); SENF_PARSER_BITFIELD ( address, 18, unsigned ); - SENF_PARSER_FINALIZE( Parse_MPERealTimeParameters ); + SENF_PARSER_FINALIZE( MPERealTimeParametersParser ); }; @@ -55,19 +55,19 @@ namespace senf { \see MPESectionType */ - struct Parse_MPESection : public PacketParserBase + struct MPESectionParser : public PacketParserBase { # include SENF_FIXED_PARSER() - SENF_PARSER_FIELD( table_id, Parse_UInt8 ); + SENF_PARSER_FIELD( table_id, UInt8Parser ); SENF_PARSER_BITFIELD ( section_syntax_indicator, 1, bool ); SENF_PARSER_BITFIELD ( private_indicator, 1, bool ); SENF_PARSER_PRIVATE_BITFIELD( reserved_1, 2, unsigned ); SENF_PARSER_BITFIELD ( section_length, 12, unsigned ); - SENF_PARSER_FIELD( mac_addr_6, Parse_UInt8 ); - SENF_PARSER_FIELD( mac_addr_5, Parse_UInt8 ); + SENF_PARSER_FIELD( mac_addr_6, UInt8Parser ); + SENF_PARSER_FIELD( mac_addr_5, UInt8Parser ); SENF_PARSER_PRIVATE_BITFIELD( reserved_2, 2, unsigned ); SENF_PARSER_BITFIELD ( payload_scrmbl_ctrl, 2, unsigned ); @@ -75,12 +75,12 @@ namespace senf { SENF_PARSER_BITFIELD ( llc_snap_flag, 1, bool ); SENF_PARSER_BITFIELD ( curr_next_indicator, 1, bool ); - SENF_PARSER_FIELD( section_num, Parse_UInt8 ); - SENF_PARSER_FIELD( last_section_num, Parse_UInt8 ); + SENF_PARSER_FIELD( section_num, UInt8Parser ); + SENF_PARSER_FIELD( last_section_num, UInt8Parser ); - SENF_PARSER_FIELD( real_time_parameters, Parse_MPERealTimeParameters ); + SENF_PARSER_FIELD( real_time_parameters, MPERealTimeParametersParser ); - SENF_PARSER_FINALIZE( Parse_MPESection ); + SENF_PARSER_FINALIZE( MPESectionParser ); SENF_PARSER_PRIVATE_BITFIELD( ip_datagram_version, 4, unsigned ); @@ -95,7 +95,7 @@ namespace senf { curr_next_indicator() = 1; } - Parse_UInt32 crc() const { return parse( data().size()-4 ); } + UInt32Parser crc() const { return parse( data().size()-4 ); } // typedef boost::crc_optimal<32, 0x04C11DB7, 0xFFFFFFFF, 0, false, false> crc32_t; // boost::uint32_t calcCrc() const; @@ -110,7 +110,7 @@ namespace senf { \ref MPESection \par Fields: - \ref Parse_MPESection + \ref MPESectionParser \ingroup protocolbundle_mpegdvb */ @@ -120,7 +120,7 @@ namespace senf { { typedef PacketTypeMixin mixin; typedef ConcretePacket packet; - typedef Parse_MPESection parser; + typedef MPESectionParser parser; using mixin::nextPacketRange; using mixin::init; diff --git a/Packets/MPEGDVBBundle/SNDUPacket.cc b/Packets/MPEGDVBBundle/SNDUPacket.cc index 8b5d048..372d0f1 100644 --- a/Packets/MPEGDVBBundle/SNDUPacket.cc +++ b/Packets/MPEGDVBBundle/SNDUPacket.cc @@ -41,7 +41,7 @@ //} -prefix_ boost::uint32_t senf::Parse_SNDUPacket::calcCrc() +prefix_ boost::uint32_t senf::SNDUPacketParser::calcCrc() const { return std::for_each( diff --git a/Packets/MPEGDVBBundle/SNDUPacket.hh b/Packets/MPEGDVBBundle/SNDUPacket.hh index 7cb9e76..50a90db 100644 --- a/Packets/MPEGDVBBundle/SNDUPacket.hh +++ b/Packets/MPEGDVBBundle/SNDUPacket.hh @@ -43,7 +43,7 @@ namespace senf { \see SNDUPacketType */ - struct Parse_SNDUPacket : public PacketParserBase + struct SNDUPacketParser : public PacketParserBase { # include SENF_PARSER() @@ -52,13 +52,13 @@ namespace senf { SENF_PARSER_PRIVATE_BITFIELD ( d_bit_ , 1 , unsigned ); SENF_PARSER_BITFIELD ( length , 15 , unsigned ); - SENF_PARSER_FIELD ( type , Parse_UInt16 ); + SENF_PARSER_FIELD ( type , UInt16Parser ); SENF_PARSER_PRIVATE_VARIANT ( destination_ , d_bit_ , - (Parse_MAC) (VoidPacketParser) ); + (MACAddressParser) (VoidPacketParser) ); - SENF_PARSER_FINALIZE( Parse_SNDUPacket ); + SENF_PARSER_FINALIZE( SNDUPacketParser ); - Parse_MAC destination() /// Only defined if d_bit() == \c false + MACAddressParser destination() /// Only defined if d_bit() == \c false { return destination_().get<0>(); } bool d_bit() /// Destination absent bit @@ -70,8 +70,8 @@ namespace senf { void withoutDestination() /// Set destination absent bit { destination_().init<1>(); } - Parse_UInt32 crc() - { return parse( data().size() - 4 ); } + UInt32Parser crc() + { return parse( data().size() - 4 ); } boost::uint32_t calcCrc() const; }; @@ -87,7 +87,7 @@ namespace senf { \ref SNDUPacket \par Fields: - \ref Parse_SNDUPacket + \ref SNDUPacketParser \ingroup protocolbundle_mpegdvb */ @@ -97,7 +97,7 @@ namespace senf { { // typedef PacketTypeMixin mixin; typedef ConcretePacket packet; - typedef Parse_SNDUPacket parser; + typedef SNDUPacketParser parser; // using mixin::nextPacketRange; // using mixin::nextPacketType; diff --git a/Packets/MPEGDVBBundle/TLVPacket.cc b/Packets/MPEGDVBBundle/TLVPacket.cc index f5ddb53..0f896c4 100644 --- a/Packets/MPEGDVBBundle/TLVPacket.cc +++ b/Packets/MPEGDVBBundle/TLVPacket.cc @@ -33,30 +33,30 @@ #define prefix_ ///////////////////////////////cc.p//////////////////////////////////////// -prefix_ senf::Parse_TLVPacketLength::value_type senf::Parse_TLVPacketLength::value() const +prefix_ senf::TLVPacketLengthParser::value_type senf::TLVPacketLengthParser::value() const { switch (bytes() ) { case 1: return fixed_length_field().value(); case 2: - return parse( 1 ).value(); + return parse( 1 ).value(); case 3: - return parse( 1 ).value(); + return parse( 1 ).value(); case 4: - return parse( 1 ).value(); + return parse( 1 ).value(); case 5: - return parse( 1 ).value(); + return parse( 1 ).value(); default: throw(UnsuportedTLVPacketException()); }; } -prefix_ void senf::Parse_TLVPacketLength::value(value_type const & v) +prefix_ void senf::TLVPacketLengthParser::value(value_type const & v) { if (v > 4294967295u) throw(UnsuportedTLVPacketException()); - SafePacketParser safeThis (*this); + SafePacketParserWrapper safeThis (*this); if (v < 128u) { if (bytes() != 1) { resize(1); @@ -71,7 +71,7 @@ prefix_ void senf::Parse_TLVPacketLength::value(value_type const & v) safeThis->extended_length_flag() = true; safeThis->fixed_length_field() = 1; } - safeThis->parse(1) = v; + safeThis->parse(1) = v; return; } if (v < 65536u) { @@ -80,7 +80,7 @@ prefix_ void senf::Parse_TLVPacketLength::value(value_type const & v) safeThis->extended_length_flag() = true; safeThis->fixed_length_field() = 2; } - safeThis->parse(1) = v; + safeThis->parse(1) = v; return; } if (v < 16777216u) { @@ -89,7 +89,7 @@ prefix_ void senf::Parse_TLVPacketLength::value(value_type const & v) safeThis->extended_length_flag() = true; safeThis->fixed_length_field() = 3; } - safeThis->parse(1) = v; + safeThis->parse(1) = v; return; } if (v <= 4294967295u) { @@ -98,18 +98,18 @@ prefix_ void senf::Parse_TLVPacketLength::value(value_type const & v) safeThis->extended_length_flag() = true; safeThis->fixed_length_field() = 4; } - safeThis->parse(1) = v; + safeThis->parse(1) = v; return; } } -prefix_ senf::Parse_TLVPacketLength const & senf::Parse_TLVPacketLength::operator= (value_type other) +prefix_ senf::TLVPacketLengthParser const & senf::TLVPacketLengthParser::operator= (value_type other) { value(other); return *this; } -prefix_ senf::Parse_TLVPacketLength::size_type senf::Parse_TLVPacketLength::bytes() const +prefix_ senf::TLVPacketLengthParser::size_type senf::TLVPacketLengthParser::bytes() const { if ( extended_length_flag() ) return 1 + fixed_length_field(); @@ -117,13 +117,13 @@ prefix_ senf::Parse_TLVPacketLength::size_type senf::Parse_TLVPacketLength::byte return 1; } -prefix_ void senf::Parse_TLVPacketLength::init() const +prefix_ void senf::TLVPacketLengthParser::init() const { defaultInit(); extended_length_flag() = 0; } -prefix_ void senf::Parse_TLVPacketLength::resize(size_type size) +prefix_ void senf::TLVPacketLengthParser::resize(size_type size) { size_type current_size (bytes()); safe_data_iterator si (data(), i()); diff --git a/Packets/MPEGDVBBundle/TLVPacket.hh b/Packets/MPEGDVBBundle/TLVPacket.hh index 3954df9..d33c48c 100644 --- a/Packets/MPEGDVBBundle/TLVPacket.hh +++ b/Packets/MPEGDVBBundle/TLVPacket.hh @@ -51,12 +51,12 @@ namespace senf { /** \brief xxx \todo document me */ - class Parse_TLVPacketLength - : public detail::packet::ParseIntOps, + class TLVPacketLengthParser + : public detail::packet::IntParserOps, public PacketParserBase { public: - Parse_TLVPacketLength(data_iterator i, state_type s) : PacketParserBase(i,s) {} + TLVPacketLengthParser(data_iterator i, state_type s) : PacketParserBase(i,s) {} typedef boost::uint32_t value_type; static const size_type init_bytes = 1; @@ -66,22 +66,22 @@ namespace senf { value_type value() const; void value(value_type const & v); - Parse_TLVPacketLength const & operator= (value_type other); + TLVPacketLengthParser const & operator= (value_type other); size_type bytes() const; void init() const; private: - typedef Parse_Flag < 0 > Parse_extended_length_flag; - typedef Parse_UIntField < 1, 8 > Parse_fixed_length; + typedef FlagParser < 0 > ExtendedLengthFlagParser; + typedef UIntFieldParser < 1, 8 > FixedLengthParser; - Parse_extended_length_flag extended_length_flag() const { - return parse( 0 ); + ExtendedLengthFlagParser extended_length_flag() const { + return parse( 0 ); } - Parse_fixed_length fixed_length_field() const { - return parse( 0 ); + FixedLengthParser fixed_length_field() const { + return parse( 0 ); } void resize(size_type size); @@ -94,14 +94,14 @@ namespace senf { \see TLVPacketType */ template - struct Parse_TLVPacket : public PacketParserBase + struct TLVPacketParser : public PacketParserBase { # include SENF_PARSER() - SENF_PARSER_FIELD( type, Parse_UInt32 ); + SENF_PARSER_FIELD( type, UInt32Parser ); SENF_PARSER_FIELD( length, LengthParser ); - SENF_PARSER_FINALIZE(Parse_TLVPacket); + SENF_PARSER_FINALIZE(TLVPacketParser); }; /** \brief generic TLV Packet type @@ -116,7 +116,7 @@ namespace senf { { #ifndef DOXYGEN typedef ConcretePacket > packet; - typedef Parse_TLVPacket parser; + typedef TLVPacketParser parser; #endif static optional_range nextPacketRange(packet p); static size_type initSize(); @@ -126,12 +126,12 @@ namespace senf { static void dump(packet p, std::ostream & os); }; - typedef TLVPacketType::packet TLVPacket; + typedef TLVPacketType::packet TLVPacket; - typedef ConcretePacket > TLVFix8Packet; - typedef ConcretePacket > TLVFix16Packet; - typedef ConcretePacket > TLVFix24Packet; - typedef ConcretePacket > TLVFix32Packet; + typedef ConcretePacket > TLVFix8Packet; + typedef ConcretePacket > TLVFix16Packet; + typedef ConcretePacket > TLVFix24Packet; + typedef ConcretePacket > TLVFix32Packet; } diff --git a/Packets/MPEGDVBBundle/TLVPacket.test.cc b/Packets/MPEGDVBBundle/TLVPacket.test.cc index 86ee6bf..3d7a76c 100644 --- a/Packets/MPEGDVBBundle/TLVPacket.test.cc +++ b/Packets/MPEGDVBBundle/TLVPacket.test.cc @@ -158,10 +158,10 @@ void test_TLVFixPacket_parsing(unsigned lengthParser_size) BOOST_AUTO_UNIT_TEST(TLVFixPacket_parse_packet) { - test_TLVFixPacket_parsing( Parse_UInt8::fixed_bytes); - test_TLVFixPacket_parsing( Parse_UInt16::fixed_bytes); - test_TLVFixPacket_parsing( Parse_UInt24::fixed_bytes); - test_TLVFixPacket_parsing( Parse_UInt32::fixed_bytes); + test_TLVFixPacket_parsing( UInt8Parser::fixed_bytes); + test_TLVFixPacket_parsing( UInt16Parser::fixed_bytes); + test_TLVFixPacket_parsing( UInt24Parser::fixed_bytes); + test_TLVFixPacket_parsing( UInt32Parser::fixed_bytes); } @@ -202,10 +202,10 @@ void test_invalid_TLVFixPacket_creating(boost::uint32_t max_value) BOOST_AUTO_UNIT_TEST(TLVFixPacket_create_invalid_packet) { - test_invalid_TLVFixPacket_creating ( Parse_UInt8::max_value); - test_invalid_TLVFixPacket_creating( Parse_UInt16::max_value); - test_invalid_TLVFixPacket_creating( Parse_UInt24::max_value); - //test_invalid_TLVFixPacket_creating( Parse_UInt32::max_value); + test_invalid_TLVFixPacket_creating ( UInt8Parser::max_value); + test_invalid_TLVFixPacket_creating( UInt16Parser::max_value); + test_invalid_TLVFixPacket_creating( UInt24Parser::max_value); + //test_invalid_TLVFixPacket_creating( UInt32Parser::max_value); } diff --git a/Packets/MPEGDVBBundle/TransportPacket.hh b/Packets/MPEGDVBBundle/TransportPacket.hh index 83406f5..7363783 100644 --- a/Packets/MPEGDVBBundle/TransportPacket.hh +++ b/Packets/MPEGDVBBundle/TransportPacket.hh @@ -1,4 +1,4 @@ -// $Id$ +// $Id:TransportPacket.hh 560 2007-12-13 14:39:37Z tho $ // // Copyright (C) 2007 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS) @@ -41,11 +41,11 @@ namespace senf { \see TransportPacketType */ - struct Parse_TransportPacket : public PacketParserBase + struct TransportPacketParser : public PacketParserBase { # include SENF_FIXED_PARSER() - SENF_PARSER_FIELD ( sync_byte , Parse_UInt8 ); + SENF_PARSER_FIELD ( sync_byte , UInt8Parser ); SENF_PARSER_BITFIELD ( transport_error_indicator , 1 , bool ); SENF_PARSER_BITFIELD ( pusi , 1 , bool ); @@ -55,10 +55,10 @@ namespace senf { SENF_PARSER_BITFIELD ( adaptation_field_ctrl , 2 , unsigned ); SENF_PARSER_BITFIELD ( continuity_counter , 4 , unsigned ); - SENF_PARSER_FINALIZE( Parse_TransportPacket ); + SENF_PARSER_FINALIZE( TransportPacketParser ); -// Parse_UInt8 payload_pointer() const { -// return parse( Parse_TransportPacket::fixed_bytes ); +// UInt8Parser payload_pointer() const { +// return parse( TransportPacketParser::fixed_bytes ); // } }; @@ -71,28 +71,28 @@ namespace senf { transport_packet() { - \ref Parse_TransportPacket::sync_byte() "sync_byte" + \ref TransportPacketParser::sync_byte() "sync_byte" 8 - \ref Parse_TransportPacket::transport_error_indicator() "transport_error_indicator" + \ref TransportPacketParser::transport_error_indicator() "transport_error_indicator" 1 - \ref Parse_TransportPacket::pusi() "payload_uni_start_indicator" + \ref TransportPacketParser::pusi() "payload_uni_start_indicator" 1 - \ref Parse_TransportPacket::transport_priority() "transport_priority" + \ref TransportPacketParser::transport_priority() "transport_priority" 1 - \ref Parse_TransportPacket::pid() "PID" + \ref TransportPacketParser::pid() "PID" 13 - \ref Parse_TransportPacket::transport_scrmbl_ctrl() "transport_scrambling_control" + \ref TransportPacketParser::transport_scrmbl_ctrl() "transport_scrambling_control" 2 - \ref Parse_TransportPacket::adaptation_field_ctrl() "adaptation_field_control" + \ref TransportPacketParser::adaptation_field_ctrl() "adaptation_field_control" 2 - \ref Parse_TransportPacket::continuity_counter() "continuity_counter" + \ref TransportPacketParser::continuity_counter() "continuity_counter" 4 } @@ -102,7 +102,7 @@ namespace senf { \ref TransportPacket \par Fields: - \ref Parse_TransportPacket + \ref TransportPacketParser \ingroup protocolbundle_mpegdvb */ @@ -112,7 +112,7 @@ namespace senf { { typedef PacketTypeMixin mixin; typedef ConcretePacket packet; - typedef Parse_TransportPacket parser; + typedef TransportPacketParser parser; using mixin::nextPacketRange; using mixin::init; diff --git a/Packets/Packet.test.cc b/Packets/Packet.test.cc index 24121a3..73432f0 100644 --- a/Packets/Packet.test.cc +++ b/Packets/Packet.test.cc @@ -59,9 +59,9 @@ namespace { { # include SENF_FIXED_PARSER() - SENF_PARSER_FIELD( type, senf::Parse_UInt16 ); - SENF_PARSER_FIELD( length, senf::Parse_Int32 ); - SENF_PARSER_FIELD( reserved, senf::Parse_UInt16 ); + SENF_PARSER_FIELD( type, senf::UInt16Parser ); + SENF_PARSER_FIELD( length, senf::Int32Parser ); + SENF_PARSER_FIELD( reserved, senf::UInt16Parser ); SENF_PARSER_FINALIZE(BarPacketParser); }; diff --git a/Packets/PacketParser.ct b/Packets/PacketParser.ct index 8fbb244..7f320a1 100644 --- a/Packets/PacketParser.ct +++ b/Packets/PacketParser.ct @@ -38,7 +38,7 @@ prefix_ typename boost::enable_if< { PacketParserBase::size_type target_sz (bytes(target)); PacketParserBase::size_type source_sz (bytes(source)); - SafePacketParser safe_target (target); + SafePacketParserWrapper safe_target (target); if (target_sz > source_sz) target.data().erase(boost::next(target.i(),source_sz),boost::next(target.i(),target_sz)); else if (target_sz < source_sz) diff --git a/Packets/PacketParser.cti b/Packets/PacketParser.cti index 03a41b4..276361e 100644 --- a/Packets/PacketParser.cti +++ b/Packets/PacketParser.cti @@ -105,20 +105,20 @@ prefix_ senf::PacketParserBase::size_type senf::detail::packetParserSize(Parser } /////////////////////////////////////////////////////////////////////////// -// senf::SafePacketParser +// senf::SafePacketParserWrapper template -prefix_ senf::SafePacketParser::SafePacketParser() +prefix_ senf::SafePacketParserWrapper::SafePacketParserWrapper() : parser_(), i_() {} template -prefix_ senf::SafePacketParser::SafePacketParser(Parser parser) +prefix_ senf::SafePacketParserWrapper::SafePacketParserWrapper(Parser parser) : parser_(parser), i_(parser) {} template -prefix_ senf::SafePacketParser & senf::SafePacketParser::operator=(Parser parser) +prefix_ senf::SafePacketParserWrapper & senf::SafePacketParserWrapper::operator=(Parser parser) { parser_ = parser; i_ = parser; @@ -126,7 +126,7 @@ prefix_ senf::SafePacketParser & senf::SafePacketParser::operato } template -prefix_ Parser senf::SafePacketParser::operator*() +prefix_ Parser senf::SafePacketParserWrapper::operator*() const { BOOST_ASSERT( i_ ); @@ -135,7 +135,7 @@ prefix_ Parser senf::SafePacketParser::operator*() } template -prefix_ Parser const * senf::SafePacketParser::operator->() +prefix_ Parser const * senf::SafePacketParserWrapper::operator->() const { BOOST_ASSERT( i_ ); @@ -144,7 +144,7 @@ prefix_ Parser const * senf::SafePacketParser::operator->() } template -prefix_ bool senf::SafePacketParser::boolean_test() +prefix_ bool senf::SafePacketParserWrapper::boolean_test() const { return i_; diff --git a/Packets/PacketParser.hh b/Packets/PacketParser.hh index d093fd7..5265872 100644 --- a/Packets/PacketParser.hh +++ b/Packets/PacketParser.hh @@ -59,23 +59,23 @@ Here \c someField(), \c someOtherField() and \c someVector() are accessor methods named after the field name. Each returns a parser object. Simple parsers can be used like their - corresponding basic type (e.g. a Parse_UInt16 field can be used like an unsigned integer), more + corresponding basic type (e.g. a UInt16Parser field can be used like an unsigned integer), more complex parsers provide type specific access members. Assigning a value to a parser will change the underlying representation (the packet data). Parsers can be grouped into several categories. These categories are not all defined rigorously but are nevertheless helpful when working with the parsers: - \li \ref parserimpl_value provide the lowest level parsers (e.g. senf::Parse_UInt16 which + \li \ref parserimpl_value provide the lowest level parsers (e.g. senf::UInt16Parser which returns an integer value). \li \ref parserimpl_collection are parsers which model a collection of sub-elements like - senf::Parse_List or senf::Parse_Vector. + senf::ListParser or senf::VectorParser. \li \ref parserimpl_composite collect several fields of arbitrary type into a new parser. Parsers defined using the \ref packetparsermacros fall under this category. \li \ref parserimpl_packet are used to define a packet type. \warning Parsers are like iterators: They are invalidated whenever the size of the packet's data is changed. You should not store a parser anywhere. If you want to keep a parser - reference, use the senf::SafePacketParser wrapper. You still will need to take extra care to + reference, use the senf::SafePacketParserWrapper wrapper. You still will need to take extra care to ensure the parser is not invalidated. \section parserimpl Packet parser categories @@ -121,7 +121,7 @@ \endcode You will probably only very seldom need to implement a completely new collection - parser. Instead, you can rely on senf::Parse_Vector or senf::Parse_List and implement new + parser. Instead, you can rely on senf::VectorParser or senf::ListParser and implement new policies. \see parsecollection @@ -218,8 +218,8 @@ namespace senf { // used to construct the sub-parsers. This member either takes an iterator to the // data to be parsed or just an offset in bytes. - senf::Parse_UInt16 type() const { return parse( 0 ); } - senf::Parse_UInt16 size() const { return parse( 2 ); } + senf::UInt16Parser type() const { return parse( 0 ); } + senf::UInt16Parser size() const { return parse( 2 ); } }; \endcode @@ -333,7 +333,7 @@ namespace senf { data_iterator i_; PacketData * data_; - template friend class SafePacketParser; + template friend class SafePacketParserWrapper; }; /** \brief Return raw size parsed by the given parser object @@ -461,14 +461,14 @@ namespace senf { location will \e not be updated accordingly and therefore the parser will be invalid. - Additionally a SafePacketParser has an uninitialized state. The only allowed operations in + Additionally a SafePacketParserWrapper has an uninitialized state. The only allowed operations in this state are the boolean test for validity and assigning another parser. \ingroup packetparser */ template - class SafePacketParser - : public safe_bool< SafePacketParser > + class SafePacketParserWrapper + : public safe_bool< SafePacketParserWrapper > { public: /////////////////////////////////////////////////////////////////////////// @@ -481,12 +481,12 @@ namespace senf { // default copy constructor // default copy assignment // default destructor - SafePacketParser(); ///< Create an empty uninitialized SafePacketParser + SafePacketParserWrapper(); ///< Create an empty uninitialized SafePacketParserWrapper // conversion constructors - SafePacketParser(Parser parser); ///< Initialize SafePacketParser from \a parser + SafePacketParserWrapper(Parser parser); ///< Initialize SafePacketParserWrapper from \a parser - SafePacketParser & operator=(Parser parser); ///< Assign \a parser to \c this + SafePacketParserWrapper & operator=(Parser parser); ///< Assign \a parser to \c this ///@} /////////////////////////////////////////////////////////////////////////// diff --git a/Packets/PacketParser.test.cc b/Packets/PacketParser.test.cc index 49760ce..d371848 100644 --- a/Packets/PacketParser.test.cc +++ b/Packets/PacketParser.test.cc @@ -51,8 +51,8 @@ namespace { { # include SENF_FIXED_PARSER() - SENF_PARSER_FIELD( name, senf::Parse_UInt16 ); - SENF_PARSER_FIELD( id, senf::Parse_Int32 ); + SENF_PARSER_FIELD( name, senf::UInt16Parser ); + SENF_PARSER_FIELD( id, senf::Int32Parser ); SENF_PARSER_FINALIZE(FooParser); }; @@ -61,8 +61,8 @@ namespace { { # include SENF_PARSER() - SENF_PARSER_FIELD( name, senf::Parse_UInt16 ); - SENF_PARSER_FIELD( id, senf::Parse_Int32 ); + SENF_PARSER_FIELD( name, senf::UInt16Parser ); + SENF_PARSER_FIELD( id, senf::Int32Parser ); SENF_PARSER_FINALIZE(BarParser); }; @@ -83,7 +83,7 @@ BOOST_AUTO_UNIT_TEST(packetParserBase) // otherwise ... BOOST_CHECK_EQUAL( FooParser::fixed_bytes+0, 6u ); BOOST_CHECK_EQUAL( BarParser(pi->data().begin(),&pi->data()).bytes(), 6u ); - BOOST_CHECK_EQUAL( senf::bytes(senf::Parse_UInt16(pi->data().begin(),&pi->data())), 2u ); + BOOST_CHECK_EQUAL( senf::bytes(senf::UInt16Parser(pi->data().begin(),&pi->data())), 2u ); BOOST_CHECK_EQUAL( senf::bytes(FooParser(pi->data().begin(),&pi->data())), 6u ); BOOST_CHECK_EQUAL( senf::bytes(BarParser(pi->data().begin(),&pi->data())), 6u ); @@ -94,11 +94,11 @@ BOOST_AUTO_UNIT_TEST(packetParserBase) BOOST_AUTO_UNIT_TEST(safePacketParser) { senf::PacketInterpreter::ptr pi (senf::PacketInterpreter::create(6u)); - senf::SafePacketParser p; + senf::SafePacketParserWrapper p; BOOST_CHECK( !p ); - p = senf::Parse_UInt16(pi->data().begin(),&pi->data()); + p = senf::UInt16Parser(pi->data().begin(),&pi->data()); BOOST_CHECK( p ); (*p) = 0x1234u; diff --git a/Packets/PacketTypes.hh b/Packets/PacketTypes.hh index f468de8..35a4025 100644 --- a/Packets/PacketTypes.hh +++ b/Packets/PacketTypes.hh @@ -47,7 +47,7 @@ namespace detail { namespace packet { - /** \brief Internal: Tempalte typedef for used smart pointer + /** \brief Internal: Template typedef for used smart pointer \internal */ diff --git a/Packets/ParseHelpers.hh b/Packets/ParseHelpers.hh index a5d761e..b9c6647 100644 --- a/Packets/ParseHelpers.hh +++ b/Packets/ParseHelpers.hh @@ -47,7 +47,7 @@ the ethernet packet in DefaultBundle/EthernetPacket.hh) \code - struct Parse_EthVLan : public PacketParserBase + struct EthVLanPacketParser : public PacketParserBase { # include SENF_FIXED_PARSER() @@ -55,9 +55,9 @@ SENF_PARSER_BITFIELD( cfi, 1, bool ); SENF_PARSER_BITFIELD( vlanId, 12, unsigned ); - SENF_PARSER_FIELD( type, Parse_UInt16 ); + SENF_PARSER_FIELD( type, UInt16Parser ); - SENF_PARSER_FINALIZE(Parse_EthVLan); + SENF_PARSER_FINALIZE(EthVLanPacketParser); }; \endcode @@ -102,14 +102,14 @@ { # include SENF_FIXED_PARSER() - SENF_PARSER_FIELD ( table_id , Parse_UInt8 ); + SENF_PARSER_FIELD ( table_id , UInt8Parser ); SENF_PARSER_BITFIELD ( ssi , 1 , bool ); SENF_PARSER_BITFIELD ( private_indicator , 1 , bool ); SENF_PARSER_SKIP_BITS( 2 ); SENF_PARSER_BITFIELD ( sec_length , 12 , unsigned ); - SENF_PARSER_FIELD ( table_id_extension , Parse_UInt16 ); + SENF_PARSER_FIELD ( table_id_extension , UInt16Parser ); SENF_PARSER_FINALIZE( Parse_DSMCCSection ); }; @@ -120,15 +120,15 @@ SENF_PARSER_INHERIT( Parse_DSMCCSection ); - SENF_PARSER_FIELD ( mac_addr_4 , Parse_UInt8 ); - SENF_PARSER_FIELD ( mac_addr_3 , Parse_UInt8 ); + SENF_PARSER_FIELD ( mac_addr_4 , UInt8Parser ); + SENF_PARSER_FIELD ( mac_addr_3 , UInt8Parser ); SENF_PARSER_FINALIZE( Parse_DatagramSection ); // Parse table_id_extension as two bytes SENF_PARSER_GOTO( table_id_extension ); - SENF_PARSER_FIELD ( mac_addr_6 , Parse_UInt8 ); - SENF_PARSER_FIELD ( mac_addr_5 , Parse_UInt8 ); + SENF_PARSER_FIELD ( mac_addr_6 , UInt8Parser ); + SENF_PARSER_FIELD ( mac_addr_5 , UInt8Parser ); }; \endcode @@ -225,7 +225,7 @@ Bit-fields play a special role. They are quite frequent in packet definitions but don't fit into the byte offset based parsing infrastructure defined so far. Since defining the correctly - parameterized senf::Parse_IntField, senf::Parse_UIntField and senf::Parse_Flag typedefs is quite + parameterized senf::IntFieldParser, senf::UIntFieldParser and senf::FlagParser typedefs is quite tedious, these helper macros are provided. It is important to recognize, that the current offset does \e not include the current bit @@ -463,10 +463,10 @@ This macro is used to define a field using a custom access method: \code - // The following is the same as SENF_PARSER_FIELD( xyz, senf::Parse_UInt16 ) + // The following is the same as SENF_PARSER_FIELD( xyz, senf::UInt16Parser ) // in a fixed size parser. - SENF_PARSER_CUSTOM_FIELD(xyz, senf::Parse_UInt16, xyz_t::fixed_bytes) { + SENF_PARSER_CUSTOM_FIELD(xyz, senf::UInt16Parser, xyz_t::fixed_bytes) { return parse( xyz_offset ); } \endcode @@ -498,13 +498,13 @@ /** \brief Define bit-field Bit fields are supported by a special family of parser macros. These macros simplify defining - fields using the senf::Parse_Int, senf::Parse_UInt and senf::Parse_Flag parsers by keeping track + fields using the senf::Parse_Int, senf::Parse_UInt and senf::FlagParser parsers by keeping track of the current bit position and automatically creating the correct template parameters. The \a type parameter specifies the type of bitfield to define. This value is one of - \li \c signed, for signed bit fields (senf::Parse_IntField) - \li \c unsigned, for unsigned bit fields (senf::Parse_UIntField) or - \li \c bool, for single-bit flags (senf::Parse_Flag). + \li \c signed, for signed bit fields (senf::IntFieldParser) + \li \c unsigned, for unsigned bit fields (senf::UIntFieldParser) or + \li \c bool, for single-bit flags (senf::FlagParser). The \a bits parameter specifies the number of bits the field covers. For \c signed or \c unsigned fields, this value may be any numeric value from 1 to 32, for \c bool fields, this diff --git a/Packets/ParseHelpers.ih b/Packets/ParseHelpers.ih index 56bda6a..7daeb55 100644 --- a/Packets/ParseHelpers.ih +++ b/Packets/ParseHelpers.ih @@ -232,9 +232,9 @@ # //////////////////////////////////////// # // SENF_PARSER_BITFIELD_I # -# define SENF_PARSER_BITFIELD_TYPE_signed(start, bits) senf::Parse_IntField -# define SENF_PARSER_BITFIELD_TYPE_unsigned(start, bits) senf::Parse_UIntField -# define SENF_PARSER_BITFIELD_TYPE_bool(start, bits) senf::Parse_Flag +# define SENF_PARSER_BITFIELD_TYPE_signed(start, bits) senf::IntFieldParser +# define SENF_PARSER_BITFIELD_TYPE_unsigned(start, bits) senf::UIntFieldParser +# define SENF_PARSER_BITFIELD_TYPE_bool(start, bits) senf::FlagParser # # define SENF_PARSER_BITFIELD_I(name, bits, type, ofstype, rwtype, access) \ access: \ diff --git a/Packets/ParseHelpers.test.cc b/Packets/ParseHelpers.test.cc index 1fa89cb..decb057 100644 --- a/Packets/ParseHelpers.test.cc +++ b/Packets/ParseHelpers.test.cc @@ -41,11 +41,11 @@ namespace { { # include SENF_FIXED_PARSER() - SENF_PARSER_FIELD ( normalField , senf::Parse_UInt16 ); - SENF_PARSER_FIELD_RO ( roField , senf::Parse_UInt16 ); + SENF_PARSER_FIELD ( normalField , senf::UInt16Parser ); + SENF_PARSER_FIELD_RO ( roField , senf::UInt16Parser ); SENF_PARSER_CUSTOM_FIELD ( customField , int, 2 ) { - return parse(customField_offset); + return parse(customField_offset); } SENF_PARSER_BITFIELD ( signedBitfield , 4, signed ); @@ -59,13 +59,13 @@ namespace { SENF_PARSER_LABEL( end ); SENF_PARSER_GOTO( roField ); - SENF_PARSER_FIELD ( overlayOfRoField , senf::Parse_Int16 ); + SENF_PARSER_FIELD ( overlayOfRoField , senf::Int16Parser ); SENF_PARSER_SKIP( 2 ); - SENF_PARSER_FIELD ( overlayOfBitfield , senf::Parse_UInt8 ); + SENF_PARSER_FIELD ( overlayOfBitfield , senf::UInt8Parser ); SENF_PARSER_GOTO_OFFSET( 1 ); - SENF_PARSER_PRIVATE_FIELD ( privLowbyteOfNormalField , senf::Parse_UInt8 ); + SENF_PARSER_PRIVATE_FIELD ( privLowbyteOfNormalField , senf::UInt8Parser ); unsigned lowbyteOfNormalField() { return privLowbyteOfNormalField(); @@ -82,12 +82,12 @@ namespace { SENF_PARSER_INHERIT( FixedBaseParser ); - SENF_PARSER_FIELD ( derivedField , senf::Parse_UInt16 ); + SENF_PARSER_FIELD ( derivedField , senf::UInt16Parser ); SENF_PARSER_LABEL( end ); SENF_PARSER_GOTO( signedBitfield ); - SENF_PARSER_FIELD ( anotherOverlay , senf::Parse_UInt16 ); + SENF_PARSER_FIELD ( anotherOverlay , senf::UInt16Parser ); SENF_PARSER_GOTO( end ); @@ -151,11 +151,11 @@ namespace { { # include SENF_PARSER() - SENF_PARSER_FIELD ( normalField , senf::Parse_UInt16 ); - SENF_PARSER_FIELD_RO ( roField , senf::Parse_UInt16 ); + SENF_PARSER_FIELD ( normalField , senf::UInt16Parser ); + SENF_PARSER_FIELD_RO ( roField , senf::UInt16Parser ); SENF_PARSER_CUSTOM_FIELD ( customField , int, 2, 2 ) { - return parse(customField_offset()); + return parse(customField_offset()); } SENF_PARSER_BITFIELD ( signedBitfield , 4, signed ); @@ -169,13 +169,13 @@ namespace { SENF_PARSER_LABEL( end ); SENF_PARSER_GOTO( roField ); - SENF_PARSER_FIELD ( overlayOfRoField , senf::Parse_Int16 ); + SENF_PARSER_FIELD ( overlayOfRoField , senf::Int16Parser ); SENF_PARSER_SKIP( 2, 2 ); - SENF_PARSER_FIELD ( overlayOfBitfield , senf::Parse_UInt8 ); + SENF_PARSER_FIELD ( overlayOfBitfield , senf::UInt8Parser ); SENF_PARSER_GOTO_OFFSET( 1, 1 ); - SENF_PARSER_PRIVATE_FIELD ( privLowbyteOfNormalField , senf::Parse_UInt8 ); + SENF_PARSER_PRIVATE_FIELD ( privLowbyteOfNormalField , senf::UInt8Parser ); unsigned lowbyteOfNormalField() { return privLowbyteOfNormalField(); @@ -192,12 +192,12 @@ namespace { SENF_PARSER_INHERIT( VariableBaseParser ); - SENF_PARSER_FIELD ( derivedField , senf::Parse_UInt16 ); + SENF_PARSER_FIELD ( derivedField , senf::UInt16Parser ); SENF_PARSER_LABEL( end ); SENF_PARSER_GOTO( signedBitfield ); - SENF_PARSER_FIELD ( anotherOverlay , senf::Parse_UInt16 ); + SENF_PARSER_FIELD ( anotherOverlay , senf::UInt16Parser ); SENF_PARSER_GOTO( end ); diff --git a/Packets/ParseVariant.ct b/Packets/VariantParser.ct similarity index 93% rename from Packets/ParseVariant.ct rename to Packets/VariantParser.ct index d147776..43ca23b 100644 --- a/Packets/ParseVariant.ct +++ b/Packets/VariantParser.ct @@ -21,9 +21,9 @@ // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /** \file - \brief ParseVariant non-inline template implementation */ + \brief VariantParser non-inline template implementation */ -#include "ParseVariant.ih" +#include "VariantParser.ih" // Custom includes #include @@ -33,7 +33,7 @@ template template -prefix_ void senf::Parse_Variant::init() +prefix_ void senf::VariantParser::init() { unsigned oldSize( bytes() ); typedef typename boost::mpl::at >::type NewParser; diff --git a/Packets/ParseVariant.cti b/Packets/VariantParser.cti similarity index 80% rename from Packets/ParseVariant.cti rename to Packets/VariantParser.cti index f3ca98e..69169d2 100644 --- a/Packets/ParseVariant.cti +++ b/Packets/VariantParser.cti @@ -21,9 +21,9 @@ // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /** \file - \brief ParseVariant inline template implementation */ + \brief VariantParser inline template implementation */ -#include "ParseVariant.ih" +#include "VariantParser.ih" // Custom includes #include @@ -32,39 +32,39 @@ ///////////////////////////////cti.p/////////////////////////////////////// /////////////////////////////////////////////////////////////////////////// -// senf::Parse_Variant +// senf::VariantParser template -prefix_ senf::Parse_Variant:: -Parse_Variant(data_iterator i, state_type s) +prefix_ senf::VariantParser:: +VariantParser(data_iterator i, state_type s) : PacketParserBase(i,s) {} template -prefix_ senf::Parse_Variant:: -Parse_Variant(VariantPolicy policy, data_iterator i, state_type s) +prefix_ senf::VariantParser:: +VariantParser(VariantPolicy policy, data_iterator i, state_type s) : PacketParserBase(i,s), VariantPolicy(policy) {} template prefix_ senf::PacketParserBase::size_type -senf::Parse_Variant::bytes() +senf::VariantParser::bytes() const { - return detail::VariantBytes< Parse_Variant, boost::mpl::size::value - 1 > + return detail::VariantBytes< VariantParser, boost::mpl::size::value - 1 > ::bytes(*this, variant()) + VariantPolicy::bytes(i(),state()); } template prefix_ void -senf::Parse_Variant::init() +senf::VariantParser::init() { VariantPolicy::variant(0,i(),state()); get<0>().init(); } template -prefix_ unsigned senf::Parse_Variant::variant() +prefix_ unsigned senf::VariantParser::variant() const { return VariantPolicy::variant(i(),state()); @@ -73,9 +73,9 @@ prefix_ unsigned senf::Parse_Variant template prefix_ typename boost::mpl::at< - typename senf::Parse_Variant::parsers, + typename senf::VariantParser::parsers, boost::mpl::int_ >::type -senf::Parse_Variant::get() +senf::VariantParser::get() const { BOOST_ASSERT( variant() == N ); diff --git a/Packets/ParseVariant.dox b/Packets/VariantParser.dox similarity index 100% rename from Packets/ParseVariant.dox rename to Packets/VariantParser.dox diff --git a/Packets/ParseVariant.hh b/Packets/VariantParser.hh similarity index 83% rename from Packets/ParseVariant.hh rename to Packets/VariantParser.hh index f7e9670..0bba1b1 100644 --- a/Packets/ParseVariant.hh +++ b/Packets/VariantParser.hh @@ -21,13 +21,13 @@ // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /** \file - \brief ParseVariant public header */ + \brief VariantParser public header */ -#ifndef HH_ParseVariant_ -#define HH_ParseVariant_ 1 +#ifndef HH_VariantParser_ +#define HH_VariantParser_ 1 #ifndef HH_Packets_ -#error "Don't include 'ParseVariant.hh' directly, include 'Packets.hh'" +#error "Don't include 'VariantParser.hh' directly, include 'Packets.hh'" #endif // Custom includes @@ -38,16 +38,16 @@ #include #include "PacketParser.hh" -//#include "ParseVariant.mpp" -#include "ParseVariant.ih" +//#include "VariantParser.mpp" +#include "VariantParser.ih" ///////////////////////////////hh.p//////////////////////////////////////// namespace senf { # ifndef SENF_LIMIT_PARSE_VARIANT - /** \brief Maximum number of senf::Parse_Variant sub-parsers. + /** \brief Maximum number of senf::VariantParser sub-parsers. - This number defines the maximum number of parser arguments senf::Parse_Variant takes. + This number defines the maximum number of parser arguments senf::VariantParser takes. */ # define SENF_LIMIT_PARSE_VARIANT 6 # endif @@ -61,9 +61,9 @@ namespace senf { defined condition. This is the parser to use, if the type and/or number of fields of a packet change depending on some condition. \code - typedef senf::Parse_Variant< + typedef senf::VariantParser< MyVariantPolicy, - senf::VoidPacketParser, Parse_TypeA, Parse_TypeB> MyVariant; + senf::VoidPacketParser, TypeAParser, TypeBParser> MyVariantParser; \endcode This typedef defines a variant parser choosing one of three sub parsers. senf::VoidPacketParser is an empty parser, it effectively makes this parser @@ -78,7 +78,7 @@ namespace senf { \ingroup parsecollection */ template - class Parse_Variant + class VariantParser : public PacketParserBase, private VariantPolicy { typedef boost::mpl::vector< SENF_PARSE_VARIANT_TPL_ARGS(P) > parsers; @@ -87,8 +87,8 @@ namespace senf { ///\name Parser interface ///\{ - Parse_Variant(data_iterator i, state_type s); - Parse_Variant(VariantPolicy policy, data_iterator i, state_type s); + VariantParser(data_iterator i, state_type s); + VariantParser(VariantPolicy policy, data_iterator i, state_type s); size_type bytes() const; void init(); @@ -127,14 +127,14 @@ namespace senf { This struct is a template typedef defining a senf::Parser_Variant instantiation. It defines a variant parser which interprets the value returned by some other parser directly as index - into the list of sub parsers (the numeric template argument to senf::Parse_Variant::get() + into the list of sub parsers (the numeric template argument to senf::VariantParser::get() and senf::Parser_Variant::init()). \code - // Define a variant choosing between Parse_Foo and Parse_Bar depending on the directly + // Define a variant choosing between FooParser and BarParser depending on the directly // preceding 1-byte 8bit uint value - typedef senf::Parse_Variant_Direct< senf::Parse_UInt8, 1u, - Parse_Foo, Parse_Bar >::parser MyVariant; + typedef senf::DirectVariantParser< senf::UInt8Parser, 1u, + FooParser, BarParser >::parser MyVariant; \endcode \a ChooserType defines the type of the field used to choose the sub parser. This must be a @@ -153,15 +153,15 @@ namespace senf { */ template - struct Parse_Variant_Direct + struct DirectVariantParser { - typedef Parse_Variant< detail::Parse_Variant_Direct, + typedef VariantParser< detail::DirectVariantParser, SENF_PARSE_VARIANT_TPL_ARGS(P) > parser; }; - /** \brief Define Parse_Variant_Direct field + /** \brief Define DirectVariantParser field - This macro is a special helper to define a senf::Parse_Variant_Direct type field. This is a + This macro is a special helper to define a senf::DirectVariantParser type field. This is a variant field which chooses the sub-type by directly taking the value of some other field. \warning @@ -173,18 +173,18 @@ namespace senf { { # include SENF_PARSER() - SENF_PARSER_PRIVATE_FIELD( type, senf::Parse_UInt8 ); + SENF_PARSER_PRIVATE_FIELD( type, senf::UInt8Parser ); SENF_PARSER_PRIVATE_VARIANT( content, type, (senf::VoidPacketParser) - (senf::Parse_UInt8) - (senf::Parse_UInt16) - (senf::Parse_UInt24) - (senf::Parse_UInt32) ); + (senf::UInt8Parser) + (senf::UInt16Parser) + (senf::UInt24Parser) + (senf::UInt32Parser) ); - senf::Parse_UInt8 uint8() const { return content().get<1>(); } - senf::Parse_UInt16 uint16() const { return content().get<2>(); } - senf::Parse_UInt24 uint24() const { return content().get<3>(); } - senf::Parse_UInt32 uint32() const { return content().get<4>(); } + senf::UInt8Parser uint8() const { return content().get<1>(); } + senf::UInt16Parser uint16() const { return content().get<2>(); } + senf::UInt24Parser uint24() const { return content().get<3>(); } + senf::UInt32Parser uint32() const { return content().get<4>(); } void disable() const { content().init<0>(); } void set_uint8() const { content().init<1>(); } @@ -197,7 +197,7 @@ namespace senf { \endcode The variant \c content chooses one of the sub parsers depending on the \c type field. If \c - type is 0, senf::VoidPacketParser is selected, if it is 1, senf::Parse_UInt8 and so on. + type is 0, senf::VoidPacketParser is selected, if it is 1, senf::UInt8Parser and so on. It is customary, to hide the variant parser (by defining it private) and provide more conveniently named accessors. @@ -207,7 +207,7 @@ namespace senf { \param[in] types a Boost.Preprocessor style sequence of sub-parser types \see - senf::Parse_Variant \n + senf::VariantParser \n \ref SENF_PARSER_PRIVATE_VARIANT() \hideinitializer \ingroup packetparsermacros @@ -216,10 +216,10 @@ namespace senf { SENF_PARSER_VARIANT_I(SENF_PARSER_FIELD, \ name, \ chooser, \ - senf::detail::Parse_Variant_IdentityTranslator, \ + senf::detail::VariantParser_IdentityTranslator, \ types) - /** \brief Define Parse_Variant_Direct field (private) + /** \brief Define DirectVariantParser field (private) \see \ref SENF_PARSER_VARIANT() \hideinitializer @@ -229,10 +229,10 @@ namespace senf { SENF_PARSER_VARIANT_I(SENF_PARSER_PRIVATE_FIELD, \ name, \ chooser, \ - senf::detail::Parse_Variant_IdentityTranslator, \ + senf::detail::VariantParser_IdentityTranslator, \ types) - /** \brief Define Parse_Variant_Direct field with translator + /** \brief Define DirectVariantParser field with translator This is like \ref SENF_PARSER_VARIANT(), however it allows to specify a \a translator argument which translates between \a chooser values and type indices: @@ -267,7 +267,7 @@ namespace senf { translator, \ types) - /** \brief Define Parse_Variant_Direct field with translator (private) + /** \brief Define DirectVariantParser field with translator (private) \see \ref SENF_PARSER_VARIANT_TRANS() \hideinitializer @@ -284,11 +284,11 @@ namespace senf { ///////////////////////////////hh.e//////////////////////////////////////// #endif -#if !defined(HH_Packets__decls_) && !defined(HH_ParseVariant_i_) -#define HH_ParseVariant_i_ -//#include "ParseVariant.cci" -#include "ParseVariant.ct" -#include "ParseVariant.cti" +#if !defined(HH_Packets__decls_) && !defined(HH_VariantParser_i_) +#define HH_VariantParser_i_ +//#include "VariantParser.cci" +#include "VariantParser.ct" +#include "VariantParser.cti" #endif diff --git a/Packets/ParseVariant.ih b/Packets/VariantParser.ih similarity index 91% rename from Packets/ParseVariant.ih rename to Packets/VariantParser.ih index 1166077..5e1a4a8 100644 --- a/Packets/ParseVariant.ih +++ b/Packets/VariantParser.ih @@ -21,10 +21,10 @@ // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /** \file - \brief ParseVariant internal header */ + \brief VariantParser internal header */ -#ifndef IH_ParseVariant_ -#define IH_ParseVariant_ 1 +#ifndef IH_VariantParser_ +#define IH_VariantParser_ 1 // Custom includes #include "PacketParser.hh" @@ -55,9 +55,9 @@ namespace detail { # endif - /** \brief Internal: Variant Policy used by senf::Parse_Variant_Direct */ + /** \brief Internal: Variant Policy used by senf::DirectVariantParser */ template - struct Parse_Variant_Direct + struct DirectVariantParser { typedef PacketParserBase::data_iterator data_iterator; typedef PacketParserBase::state_type state_type; @@ -81,7 +81,7 @@ namespace detail { }; /** \brief Internal: Identity chooser translator */ - struct Parse_Variant_IdentityTranslator { + struct VariantParser_IdentityTranslator { static unsigned fromChooser(unsigned value) { return value; } static unsigned toChooser(unsigned value) { return value; } }; @@ -89,7 +89,7 @@ namespace detail { # define SENF_PARSER_VARIANT_(r, data, elem) ,elem # define SENF_PARSER_VARIANT_I(field, name, chooser, translator, types) \ - typedef senf::Parse_Variant_Direct< \ + typedef senf::DirectVariantParser< \ BOOST_PP_CAT(chooser, _t), \ SENF_PARSER_CURRENT_FIXED_OFFSET() - SENF_PARSER_FIXED_OFFSET(chooser), \ translator \ diff --git a/Packets/ParseVariant.test.cc b/Packets/VariantParser.test.cc similarity index 89% rename from Packets/ParseVariant.test.cc rename to Packets/VariantParser.test.cc index 41935d5..68fbcd7 100644 --- a/Packets/ParseVariant.test.cc +++ b/Packets/VariantParser.test.cc @@ -21,10 +21,10 @@ // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /** \file - \brief ParseVariant.test unit tests */ + \brief VariantParser.test unit tests */ -//#include "ParseVariant.test.hh" -//#include "ParseVariant.test.ih" +//#include "VariantParser.test.hh" +//#include "VariantParser.test.ih" // Custom includes #include "Packets.hh" @@ -35,13 +35,13 @@ #define prefix_ ///////////////////////////////cc.p//////////////////////////////////////// -BOOST_AUTO_UNIT_TEST(parseVariant) +BOOST_AUTO_UNIT_TEST(VariantParser) { - typedef senf::Parse_Array<10, senf::Parse_UInt8> Array10; - typedef senf::Parse_Variant_Direct< senf::Parse_UInt8, 1, senf::detail::Parse_Variant_IdentityTranslator, + typedef senf::ArrayParser<10, senf::UInt8Parser> Array10; + typedef senf::DirectVariantParser< senf::UInt8Parser, 1, senf::detail::VariantParser_IdentityTranslator, senf::VoidPacketParser, Array10, - senf:: Parse_UInt32 + senf:: UInt32Parser >::parser Variant; unsigned char data[] = { 0x01, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, @@ -87,8 +87,8 @@ namespace { { # include SENF_FIXED_PARSER() - SENF_PARSER_FIELD( foo, senf::Parse_UInt32 ); - SENF_PARSER_FIELD( bar, senf::Parse_Int16 ); + SENF_PARSER_FIELD( foo, senf::UInt32Parser ); + SENF_PARSER_FIELD( bar, senf::Int16Parser ); SENF_PARSER_FINALIZE(SubParser); }; @@ -110,7 +110,7 @@ namespace { } -BOOST_AUTO_UNIT_TEST(parseVariantMacro) +BOOST_AUTO_UNIT_TEST(VariantParserMacro) { senf::DataPacket p (senf::DataPacket::create(senf::init_bytes::value)); diff --git a/Packets/ParseVec.ct b/Packets/VectorParser.ct similarity index 81% rename from Packets/ParseVec.ct rename to Packets/VectorParser.ct index d76caf3..6b004c9 100644 --- a/Packets/ParseVec.ct +++ b/Packets/VectorParser.ct @@ -21,9 +21,9 @@ // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /** \file - \brief ParseVec non-inline template implementation */ + \brief VectorParser non-inline template implementation */ -#include "ParseVec.ih" +#include "VectorParser.ih" // Custom includes @@ -31,10 +31,10 @@ ///////////////////////////////ct.p//////////////////////////////////////// /////////////////////////////////////////////////////////////////////////// -// senf::Parse_Vector +// senf::VectorParser template -prefix_ void senf::Parse_Vector::init() +prefix_ void senf::VectorParser::init() const { sizer_.init(i(),state()); @@ -45,10 +45,10 @@ prefix_ void senf::Parse_Vector::init() } /////////////////////////////////////////////////////////////////////////// -// senf::Parse_Vector_Container +// senf::VectorParser_Container template -prefix_ void senf::Parse_Vector_Container::init() +prefix_ void senf::VectorParser_Container::init() const { iterator i (begin()); @@ -60,8 +60,8 @@ prefix_ void senf::Parse_Vector_Container::init() // Mutators template -prefix_ typename senf::Parse_Vector_Container::iterator -senf::Parse_Vector_Container::shift(iterator pos, size_type n) +prefix_ typename senf::VectorParser_Container::iterator +senf::VectorParser_Container::shift(iterator pos, size_type n) { size_type ix (std::distance(data().begin(),pos.raw())); data().insert(pos.raw(),n*ElementParser::fixed_bytes,0); @@ -71,7 +71,7 @@ senf::Parse_Vector_Container::shift(iterator pos, size_type template template -prefix_ void senf::Parse_Vector_Container::insert(iterator pos, +prefix_ void senf::VectorParser_Container::insert(iterator pos, size_type n, Value const & t) { @@ -82,7 +82,7 @@ prefix_ void senf::Parse_Vector_Container::insert(iterator #ifndef DOXYGEN template template -prefix_ void senf::Parse_Vector_Container:: +prefix_ void senf::VectorParser_Container:: insert(iterator pos, ForwardIterator f, ForwardIterator l, typename boost::disable_if< boost::is_convertible >::type *) { @@ -92,13 +92,13 @@ insert(iterator pos, ForwardIterator f, ForwardIterator l, #else template template -prefix_ void senf::Parse_Vector_Container:: +prefix_ void senf::VectorParser_Container:: insert(iterator pos, ForwardIterator f, ForwardIterator l) {} #endif template -prefix_ void senf::Parse_Vector_Container::resize(size_type n) +prefix_ void senf::VectorParser_Container::resize(size_type n) { if (size()>=n) erase(boost::next(begin(),n),end()); @@ -108,7 +108,7 @@ prefix_ void senf::Parse_Vector_Container::resize(size_type template template -prefix_ void senf::Parse_Vector_Container::resize(size_type n, Value value) +prefix_ void senf::VectorParser_Container::resize(size_type n, Value value) { if (size()>=n) erase(boost::next(begin(),n),end()); diff --git a/Packets/ParseVec.cti b/Packets/VectorParser.cti similarity index 65% rename from Packets/ParseVec.cti rename to Packets/VectorParser.cti index 962ded0..428dd35 100644 --- a/Packets/ParseVec.cti +++ b/Packets/VectorParser.cti @@ -21,9 +21,9 @@ // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /** \file - \brief ParseVec inline template implementation */ + \brief VectorParser inline template implementation */ -#include "ParseVec.ih" +#include "VectorParser.ih" // Custom includes @@ -31,22 +31,22 @@ ///////////////////////////////cti.p/////////////////////////////////////// /////////////////////////////////////////////////////////////////////////// -// senf::Parse_Vector +// senf::VectorParser template -prefix_ senf::Parse_Vector::Parse_Vector(data_iterator i, state_type s) +prefix_ senf::VectorParser::VectorParser(data_iterator i, state_type s) : PacketParserBase(i,s), sizer_() {} template -prefix_ senf::Parse_Vector::Parse_Vector(Sizer sizer, data_iterator i, +prefix_ senf::VectorParser::VectorParser(Sizer sizer, data_iterator i, state_type s) : PacketParserBase(i,s), sizer_(sizer) {} template -prefix_ typename senf::Parse_Vector::size_type -senf::Parse_Vector::bytes() +prefix_ typename senf::VectorParser::size_type +senf::VectorParser::bytes() const { return size()*ElementParser::fixed_bytes + sizer_.bytes(i(),state()); @@ -55,55 +55,55 @@ senf::Parse_Vector::bytes() // Container interface template -prefix_ typename senf::Parse_Vector::size_type -senf::Parse_Vector::size() +prefix_ typename senf::VectorParser::size_type +senf::VectorParser::size() const { return sizer_.size(i(),state()); } template -prefix_ bool senf::Parse_Vector::empty() +prefix_ bool senf::VectorParser::empty() const { return size()==0; } template -prefix_ typename senf::Parse_Vector::iterator -senf::Parse_Vector::begin() +prefix_ typename senf::VectorParser::iterator +senf::VectorParser::begin() const { return iterator(sizer_.begin(i(),state()),state()); } template -prefix_ typename senf::Parse_Vector::iterator -senf::Parse_Vector::end() +prefix_ typename senf::VectorParser::iterator +senf::VectorParser::end() const { return boost::next(begin(),size()); } template -prefix_ typename senf::Parse_Vector::value_type -senf::Parse_Vector::operator[](difference_type i) +prefix_ typename senf::VectorParser::value_type +senf::VectorParser::operator[](difference_type i) const { return begin()[i]; } template -prefix_ typename senf::Parse_Vector::value_type -senf::Parse_Vector::front() +prefix_ typename senf::VectorParser::value_type +senf::VectorParser::front() const { return begin()[0]; } template -prefix_ typename senf::Parse_Vector::value_type -senf::Parse_Vector::back() +prefix_ typename senf::VectorParser::value_type +senf::VectorParser::back() const { return begin()[size()-1]; @@ -113,7 +113,7 @@ senf::Parse_Vector::back() template template -prefix_ void senf::Parse_Vector::push_back(Value value, size_type n) +prefix_ void senf::VectorParser::push_back(Value value, size_type n) const { container c (*this); @@ -121,7 +121,7 @@ prefix_ void senf::Parse_Vector::push_back(Value value, siz } template -prefix_ void senf::Parse_Vector::push_back_space(size_type n) +prefix_ void senf::VectorParser::push_back_space(size_type n) const { container c (*this); @@ -130,7 +130,7 @@ prefix_ void senf::Parse_Vector::push_back_space(size_type template template -prefix_ void senf::Parse_Vector::push_front(Value value, size_type n) +prefix_ void senf::VectorParser::push_front(Value value, size_type n) const { container c (*this); @@ -138,7 +138,7 @@ prefix_ void senf::Parse_Vector::push_front(Value value, si } template -prefix_ void senf::Parse_Vector::push_front_space(size_type n) +prefix_ void senf::VectorParser::push_front_space(size_type n) const { container c (*this); @@ -146,7 +146,7 @@ prefix_ void senf::Parse_Vector::push_front_space(size_type } template -prefix_ void senf::Parse_Vector::resize(size_type n) +prefix_ void senf::VectorParser::resize(size_type n) const { container c (*this); @@ -155,7 +155,7 @@ prefix_ void senf::Parse_Vector::resize(size_type n) template template -prefix_ void senf::Parse_Vector::resize(size_type n, Value value) +prefix_ void senf::VectorParser::resize(size_type n, Value value) const { container c (*this); @@ -166,15 +166,15 @@ prefix_ void senf::Parse_Vector::resize(size_type n, Value // senf::SimpleSizeParser template -prefix_ typename senf::detail::Parse_VectorN_Sizer::size_type -senf::detail::Parse_VectorN_Sizer::size(iterator i, state_type s) +prefix_ typename senf::detail::VectorNParser_Sizer::size_type +senf::detail::VectorNParser_Sizer::size(iterator i, state_type s) const { return SizeParser(boost::prior(i, Distance), s).value(); } template -prefix_ void senf::detail::Parse_VectorN_Sizer::size(iterator i, +prefix_ void senf::detail::VectorNParser_Sizer::size(iterator i, state_type s, size_type v) const @@ -183,29 +183,29 @@ prefix_ void senf::detail::Parse_VectorN_Sizer::size(iterat } template -prefix_ typename senf::detail::Parse_VectorN_Sizer::iterator -senf::detail::Parse_VectorN_Sizer::begin(iterator i, state_type s) +prefix_ typename senf::detail::VectorNParser_Sizer::iterator +senf::detail::VectorNParser_Sizer::begin(iterator i, state_type s) const { return i; } template -prefix_ typename senf::detail::Parse_VectorN_Sizer::size_type -senf::detail::Parse_VectorN_Sizer::bytes(iterator i, state_type s) +prefix_ typename senf::detail::VectorNParser_Sizer::size_type +senf::detail::VectorNParser_Sizer::bytes(iterator i, state_type s) const { return 0; } template -prefix_ void senf::detail::Parse_VectorN_Sizer::init(iterator i, +prefix_ void senf::detail::VectorNParser_Sizer::init(iterator i, state_type s) const {} /////////////////////////////////////////////////////////////////////////// -// senf::Parse_Vector_wrapper +// senf::VectorParser_wrapper // structors and default members @@ -213,8 +213,8 @@ prefix_ void senf::detail::Parse_VectorN_Sizer::init(iterat // instance. However, data() only depends on state_ which is initialized before the call. YOU MUST // NOT CHANGE THE ORDERING OF THE DATA MEMBERS template -prefix_ senf::Parse_Vector_Container:: -Parse_Vector_Container(parser_type const & vector) +prefix_ senf::VectorParser_Container:: +VectorParser_Container(parser_type const & vector) : sizer_ (vector.sizer_), state_ (vector.state()), i_ (std::distance(data().begin(),vector.i())) {} @@ -222,55 +222,55 @@ Parse_Vector_Container(parser_type const & vector) // accessors template -prefix_ typename senf::Parse_Vector_Container::size_type -senf::Parse_Vector_Container::size() +prefix_ typename senf::VectorParser_Container::size_type +senf::VectorParser_Container::size() const { return sizer_.size(i(),state()); } template -prefix_ bool senf::Parse_Vector_Container::empty() +prefix_ bool senf::VectorParser_Container::empty() const { return size() == 0; } template -prefix_ typename senf::Parse_Vector_Container::iterator -senf::Parse_Vector_Container::begin() +prefix_ typename senf::VectorParser_Container::iterator +senf::VectorParser_Container::begin() const { return iterator(sizer_.begin(i(),state()),state()); } template -prefix_ typename senf::Parse_Vector_Container::iterator -senf::Parse_Vector_Container::end() +prefix_ typename senf::VectorParser_Container::iterator +senf::VectorParser_Container::end() const { return boost::next(begin(),size()); } template -prefix_ typename senf::Parse_Vector_Container::value_type -senf::Parse_Vector_Container::operator[](difference_type i) +prefix_ typename senf::VectorParser_Container::value_type +senf::VectorParser_Container::operator[](difference_type i) const { return begin()[i]; } template -prefix_ typename senf::Parse_Vector_Container::value_type -senf::Parse_Vector_Container::front() +prefix_ typename senf::VectorParser_Container::value_type +senf::VectorParser_Container::front() const { return begin()[0]; } template -prefix_ typename senf::Parse_Vector_Container::value_type -senf::Parse_Vector_Container::back() +prefix_ typename senf::VectorParser_Container::value_type +senf::VectorParser_Container::back() const { return begin()[size()-1]; @@ -280,55 +280,55 @@ senf::Parse_Vector_Container::back() template template -prefix_ void senf::Parse_Vector_Container::insert(iterator pos, +prefix_ void senf::VectorParser_Container::insert(iterator pos, Value const & t) { *shift(pos) << t; } template -prefix_ void senf::Parse_Vector_Container::erase(iterator pos, size_type n) +prefix_ void senf::VectorParser_Container::erase(iterator pos, size_type n) { data().erase(pos.raw(),boost::next(pos.raw(),n*ElementParser::fixed_bytes)); setSize(size()-n); } template -prefix_ void senf::Parse_Vector_Container::erase(iterator f, iterator l) +prefix_ void senf::VectorParser_Container::erase(iterator f, iterator l) { erase(f,std::distance(f,l)); } template -prefix_ void senf::Parse_Vector_Container::clear() +prefix_ void senf::VectorParser_Container::clear() { erase(begin(),end()); } template template -prefix_ void senf::Parse_Vector_Container::push_back(Value value, +prefix_ void senf::VectorParser_Container::push_back(Value value, size_type n) { insert(end(),n,value); } template -prefix_ void senf::Parse_Vector_Container::push_back_space(size_type n) +prefix_ void senf::VectorParser_Container::push_back_space(size_type n) { shift(end(),n); } template template -prefix_ void senf::Parse_Vector_Container::push_front(Value value, +prefix_ void senf::VectorParser_Container::push_front(Value value, size_type n) { insert(begin(),n,value); } template -prefix_ void senf::Parse_Vector_Container::push_front_space(size_type n) +prefix_ void senf::VectorParser_Container::push_front_space(size_type n) { shift(begin(),n); } @@ -336,24 +336,24 @@ prefix_ void senf::Parse_Vector_Container::push_front_space // Parser interface template -prefix_ typename senf::Parse_Vector_Container::parser_type -senf::Parse_Vector_Container::parser() +prefix_ typename senf::VectorParser_Container::parser_type +senf::VectorParser_Container::parser() const { return parser_type(i(),state()); } template -prefix_ typename senf::Parse_Vector_Container::data_iterator -senf::Parse_Vector_Container::i() +prefix_ typename senf::VectorParser_Container::data_iterator +senf::VectorParser_Container::i() const { return boost::next(data().begin(),i_); } template -prefix_ typename senf::Parse_Vector_Container::state_type -senf::Parse_Vector_Container::state() +prefix_ typename senf::VectorParser_Container::state_type +senf::VectorParser_Container::state() const { return state_; @@ -361,15 +361,15 @@ senf::Parse_Vector_Container::state() template prefix_ senf::PacketData & -senf::Parse_Vector_Container::data() +senf::VectorParser_Container::data() const { return *state_; } template -prefix_ typename senf::Parse_Vector_Container::size_type -senf::Parse_Vector_Container::bytes() +prefix_ typename senf::VectorParser_Container::size_type +senf::VectorParser_Container::bytes() const { return size()*ElementParser::fixed_bytes + sizer_.bytes(i(),state()); @@ -378,7 +378,7 @@ senf::Parse_Vector_Container::bytes() // private members template -prefix_ void senf::Parse_Vector_Container::setSize(size_type value) +prefix_ void senf::VectorParser_Container::setSize(size_type value) { sizer_.size(i(),state(),value); } diff --git a/Packets/ParseVec.dox b/Packets/VectorParser.dox similarity index 100% rename from Packets/ParseVec.dox rename to Packets/VectorParser.dox diff --git a/Packets/ParseVec.hh b/Packets/VectorParser.hh similarity index 84% rename from Packets/ParseVec.hh rename to Packets/VectorParser.hh index 5d8d180..b98e406 100644 --- a/Packets/ParseVec.hh +++ b/Packets/VectorParser.hh @@ -21,10 +21,10 @@ // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /** \file - \brief ParseVec public header */ + \brief VectorParser public header */ -#ifndef HH_ParseVec_ -#define HH_ParseVec_ 1 +#ifndef HH_VectorParser_ +#define HH_VectorParser_ 1 // Custom includes #include @@ -32,15 +32,15 @@ #include #include #include "PacketParser.hh" -#include "ParseArray.hh" // for Parse_Array_iterator +#include "ArrayParser.hh" // for ArrayParser_iterator -//#include "ParseVec.mpp" -#include "ParseVec.ih" +//#include "VectorParser.mpp" +#include "VectorParser.ih" ///////////////////////////////hh.p//////////////////////////////////////// namespace senf { - template class Parse_Vector_Container; + template class VectorParser_Container; /** \brief Collection of fixed-size elements @@ -51,7 +51,7 @@ namespace senf { A vector is a model of an STL random-access sequence. The parser only provides a reduced interface, the container wrapper however completes this interface. - Parse_Vector makes use of a policy template argument, \a Sizer, to customize the way the + VectorParser makes use of a policy template argument, \a Sizer, to customize the way the containers size is obtained. You will normally not instantiate Parser_Vector directly, you will use one of the 'template typedefs' (which are templated structures since C++ does not provide real template typedefs) provided with the policy implementations. @@ -62,10 +62,10 @@ namespace senf { \ingroup parsecollection */ template - struct Parse_Vector : public PacketParserBase + struct VectorParser : public PacketParserBase { - Parse_Vector(data_iterator i, state_type s); - Parse_Vector(Sizer sizer, data_iterator i, state_type s); + VectorParser(data_iterator i, state_type s); + VectorParser(Sizer sizer, data_iterator i, state_type s); ///< Additional sizer specific constructor /**< This constructor may be used, if the sizer needs additional parameters. */ @@ -79,9 +79,9 @@ namespace senf { // Container interface typedef ElementParser value_type; - typedef detail::Parse_Array_iterator iterator; + typedef detail::ArrayParser_iterator iterator; typedef iterator const_iterator; - typedef Parse_Vector_Container container; + typedef VectorParser_Container container; size_type size() const; bool empty() const; @@ -109,7 +109,7 @@ namespace senf { private: Sizer sizer_; - friend class Parse_Vector_Container; + friend class VectorParser_Container; }; /** \brief Vector with prefix sizing @@ -120,32 +120,32 @@ namespace senf { \code // Define MyVector as a vector of 16bit unsigned elements with a directly preceding // 8bit unsigned size field - typedef senf::Parse_VectorN::parser MyVector; + typedef senf::VectorNParser::parser MyVector; \endcode \param ElementParser \e fixed-size parser for parsing the vector elements \param SizeParser parser for parsing the vector size (number of elements) - \see Parse_Vector + \see VectorParser \ingroup parsecollection */ template - struct Parse_VectorN + struct VectorNParser { - typedef Parse_Vector< ElementParser, - detail::Parse_VectorN_Sizer > parser; + typedef VectorParser< ElementParser, + detail::VectorNParser_Sizer > parser; }; - /** \brief Define Parse_VectorN field + /** \brief Define VectorNParser field - This macro is a special helper to define a senf::Parse_VectorN type field, a vector of + This macro is a special helper to define a senf::VectorNParser type field, a vector of elements of type \a elt_type (a parser) which size is given by the \a size field. \code // The size field should be declared private (size is accessible via the vector) - SENF_PARSER_PRIVATE_FIELD ( vec_size_, senf::Parse_UInt16 ); + SENF_PARSER_PRIVATE_FIELD ( vec_size_, senf::UInt16Parser ); // Define the vector, here it has 32bit unsigned integer elements - SENF_PARSER_VEC_N ( vec, _vec_size, senf::Parse_UInt32 ); + SENF_PARSER_VEC_N ( vec, _vec_size, senf::UInt32Parser ); \endcode \param[in] name field name @@ -157,7 +157,7 @@ namespace senf { # define SENF_PARSER_VEC_N(name, size, elt_type) \ SENF_PARSER_VEC_N_I(SENF_PARSER_FIELD, name, size, elt_type) - /** \brief Define Parse_VectorN field + /** \brief Define VectorNParser field \see \ref SENF_PARSER_VEC_N() \hideinitializer @@ -166,7 +166,7 @@ namespace senf { # define SENF_PARSER_PRIVATE_VEC_N(name, size, elt_type) \ SENF_PARSER_VEC_N_I(SENF_PARSER_PRIVATE_FIELD, name, size, elt_type) - /** \brief Parse_Vector container wrapper + /** \brief VectorParser container wrapper This is the container wrapper used for vector parsers. The container wrapper will stay valid after changing the collection. However the container still depends on the packet and will be @@ -182,21 +182,21 @@ namespace senf { c.insert(c.begin(), ... ); \endcode - \see Parse_Vector + \see VectorParser */ template - class Parse_Vector_Container + class VectorParser_Container { public: /////////////////////////////////////////////////////////////////////////// // Types - typedef Parse_Vector parser_type; + typedef VectorParser parser_type; typedef PacketParserBase::data_iterator data_iterator; typedef PacketParserBase::size_type size_type; typedef PacketParserBase::difference_type difference_type; typedef ElementParser value_type; - typedef detail::Parse_Array_iterator iterator; + typedef detail::ArrayParser_iterator iterator; typedef iterator const_iterator; typedef PacketParserBase::state_type state_type; @@ -209,7 +209,7 @@ namespace senf { // default destructor // conversion constructors - Parse_Vector_Container(parser_type const & vector); + VectorParser_Container(parser_type const & vector); ///@} /////////////////////////////////////////////////////////////////////////// @@ -285,11 +285,11 @@ namespace senf { ///////////////////////////////hh.e//////////////////////////////////////// #endif -#if !defined(HH_Packets__decls_) && !defined(HH_ParseVec_i_) -#define HH_ParseVec_i_ -//#include "ParseVec.cci" -#include "ParseVec.ct" -#include "ParseVec.cti" +#if !defined(HH_Packets__decls_) && !defined(HH_VectorParser_i_) +#define HH_VectorParser_i_ +//#include "VectorParser.cci" +#include "VectorParser.ct" +#include "VectorParser.cti" #endif diff --git a/Packets/ParseVec.ih b/Packets/VectorParser.ih similarity index 91% rename from Packets/ParseVec.ih rename to Packets/VectorParser.ih index 3b485d0..377758b 100644 --- a/Packets/ParseVec.ih +++ b/Packets/VectorParser.ih @@ -21,10 +21,10 @@ // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /** \file - \brief ParseVec internal header */ + \brief VectorParser internal header */ -#ifndef IH_ParseVec_ -#define IH_ParseVec_ 1 +#ifndef IH_VectorParser_ +#define IH_VectorParser_ 1 // Custom includes @@ -37,10 +37,10 @@ namespace detail { \internal - This is the sizer policy used by Parse_VectorN + This is the sizer policy used by VectorNParser */ template - struct Parse_VectorN_Sizer + struct VectorNParser_Sizer { typedef PacketParserBase::size_type size_type; typedef PacketParserBase::data_iterator iterator; @@ -56,7 +56,7 @@ namespace detail { }; # define SENF_PARSER_VEC_N_I(field, name, size, elt_type) \ - typedef senf::Parse_VectorN< elt_type, \ + typedef senf::VectorNParser< elt_type, \ BOOST_PP_CAT(size, _t), \ SENF_PARSER_CURRENT_FIXED_OFFSET() \ - SENF_PARSER_FIXED_OFFSET(size) \ diff --git a/Packets/ParseVec.test.cc b/Packets/VectorParser.test.cc similarity index 81% rename from Packets/ParseVec.test.cc rename to Packets/VectorParser.test.cc index 74e028f..c085039 100644 --- a/Packets/ParseVec.test.cc +++ b/Packets/VectorParser.test.cc @@ -22,8 +22,8 @@ // Unit tests -//#include "ParseVec.test.hh" -//#include "ParseVec.test.ih" +//#include "VectorParser.test.hh" +//#include "VectorParser.test.ih" // Custom includes #include "Packets.hh" @@ -40,19 +40,19 @@ namespace { {}; } -BOOST_AUTO_UNIT_TEST(parseVec) +BOOST_AUTO_UNIT_TEST(VectorParser) { unsigned char data[] = { 0x03, // size 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, // data 0x20, 0x21, 0x22, 0x23, 0x24, 0x25 }; senf::PacketInterpreterBase::ptr p (senf::PacketInterpreter::create(data)); - typedef senf::Parse_Vector< - senf::Parse_UInt16, - senf::detail::Parse_VectorN_Sizer - > Parse_UInt16Vec; + typedef senf::VectorParser< + senf::UInt16Parser, + senf::detail::VectorNParser_Sizer + > UInt16VectorParser; { - Parse_UInt16Vec v (boost::next(p->data().begin(), 1), &p->data()); + UInt16VectorParser v (boost::next(p->data().begin(), 1), &p->data()); BOOST_CHECK_EQUAL( v[0], 0x1011 ); BOOST_CHECK_EQUAL( v[2], 0x1415 ); @@ -63,9 +63,9 @@ BOOST_AUTO_UNIT_TEST(parseVec) BOOST_CHECK_EQUAL( v.size(), 6u ); BOOST_CHECK_EQUAL( v.bytes(), 12u ); - Parse_UInt16Vec::iterator b (v.begin()); - Parse_UInt16Vec::iterator e (v.end()); - BOOST_CHECK_EQUAL(std::distance(b,e), Parse_UInt16Vec::difference_type(v.size())); + UInt16VectorParser::iterator b (v.begin()); + UInt16VectorParser::iterator e (v.end()); + BOOST_CHECK_EQUAL(std::distance(b,e), UInt16VectorParser::difference_type(v.size())); } // Warning: Each of the following operations invalidate the parser -> we need to recreate it at @@ -75,7 +75,7 @@ BOOST_AUTO_UNIT_TEST(parseVec) // we don't need to check them again below ... { -# define v Parse_UInt16Vec(boost::next(p->data().begin(),1),&p->data()) +# define v UInt16VectorParser(boost::next(p->data().begin(),1),&p->data()) v.push_back(0xf0f1u,2); BOOST_CHECK_EQUAL( v.size(), 8u ); @@ -115,18 +115,18 @@ BOOST_AUTO_UNIT_TEST(parseVec) } } -BOOST_AUTO_UNIT_TEST(parseVec_wrapper) +BOOST_AUTO_UNIT_TEST(VectorParser_wrapper) { unsigned char data[] = { 0x03, // size 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, // data 0x20, 0x21, 0x22, 0x23, 0x24, 0x25 }; senf::PacketInterpreterBase::ptr p (senf::PacketInterpreter::create(data)); - typedef senf::Parse_Vector< - senf::Parse_UInt16, - senf::detail::Parse_VectorN_Sizer - > Parse_UInt16Vec; - Parse_UInt16Vec v (boost::next(p->data().begin(),1), &p->data()); - Parse_UInt16Vec::container w (v); + typedef senf::VectorParser< + senf::UInt16Parser, + senf::detail::VectorNParser_Sizer + > UInt16VectorParser; + UInt16VectorParser v (boost::next(p->data().begin(),1), &p->data()); + UInt16VectorParser::container w (v); BOOST_CHECK_EQUAL( w[0], 0x1011 ); BOOST_CHECK_EQUAL( w[2], 0x1415 ); @@ -134,7 +134,7 @@ BOOST_AUTO_UNIT_TEST(parseVec_wrapper) p->data()[0] = 0x06; BOOST_CHECK_EQUAL( w.size(), 6u ); BOOST_CHECK_EQUAL( std::distance(w.begin(),w.end()), - Parse_UInt16Vec::difference_type(w.size()) ); + UInt16VectorParser::difference_type(w.size()) ); w.shift(w.begin()+1); BOOST_CHECK_EQUAL( w.size(), 7u ); @@ -157,10 +157,10 @@ BOOST_AUTO_UNIT_TEST(parseVec_wrapper) { senf::PacketData::iterator i (p->data().begin()+1); - Parse_UInt16Vec::iterator j (w.begin()); - Parse_UInt16Vec::iterator e (w.end()); + UInt16VectorParser::iterator j (w.begin()); + UInt16VectorParser::iterator e (w.end()); for (;j!=e;++j, i+=2) - BOOST_CHECK_EQUAL( senf::Parse_UInt16(i,&p->data()), *j ); + BOOST_CHECK_EQUAL( senf::UInt16Parser(i,&p->data()), *j ); BOOST_CHECK_EQUAL(p->data().end()-i, 0); }