// 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
///////////////////////////////ct.p////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
-// senf::Parse_Array<elements,ElementParser>
+// senf::ArrayParser<elements,ElementParser>
template <unsigned elements, class ElementParser>
-prefix_ void senf::Parse_Array<elements,ElementParser>::init()
+prefix_ void senf::ArrayParser<elements,ElementParser>::init()
const
{
iterator i (begin());
// 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
///////////////////////////////cti.p///////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
-// senf::Parse_Array<elements,ElementParser>
+// senf::ArrayParser<elements,ElementParser>
template <unsigned elements, class ElementParser>
-prefix_ senf::Parse_Array<elements,ElementParser>::Parse_Array(data_iterator i, state_type s)
+prefix_ senf::ArrayParser<elements,ElementParser>::ArrayParser(data_iterator i, state_type s)
: PacketParserBase(i,s,fixed_bytes)
{}
// Container interface
template <unsigned elements, class ElementParser>
-prefix_ typename senf::Parse_Array<elements,ElementParser>::size_type
-senf::Parse_Array<elements,ElementParser>::size()
+prefix_ typename senf::ArrayParser<elements,ElementParser>::size_type
+senf::ArrayParser<elements,ElementParser>::size()
{
return elements;
}
template <unsigned elements, class ElementParser>
-prefix_ typename senf::Parse_Array<elements,ElementParser>::iterator
-senf::Parse_Array<elements,ElementParser>::begin()
+prefix_ typename senf::ArrayParser<elements,ElementParser>::iterator
+senf::ArrayParser<elements,ElementParser>::begin()
const
{
return iterator(i(),state());
}
template <unsigned elements, class ElementParser>
-prefix_ typename senf::Parse_Array<elements,ElementParser>::iterator
-senf::Parse_Array<elements,ElementParser>::end()
+prefix_ typename senf::ArrayParser<elements,ElementParser>::iterator
+senf::ArrayParser<elements,ElementParser>::end()
const
{
return iterator(boost::next(i(),fixed_bytes),state());
}
template <unsigned elements, class ElementParser>
-prefix_ typename senf::Parse_Array<elements,ElementParser>::value_type
-senf::Parse_Array<elements,ElementParser>::operator[](difference_type i)
+prefix_ typename senf::ArrayParser<elements,ElementParser>::value_type
+senf::ArrayParser<elements,ElementParser>::operator[](difference_type i)
const
{
BOOST_ASSERT( i>=0 && i < difference_type(elements) );
}
///////////////////////////////////////////////////////////////////////////
-// senf::detail::Parse_Array_iterator<ElementParser>
+// senf::detail::ArrayParser_iterator<ElementParser>
template <class ElementParser>
-prefix_ senf::detail::Parse_Array_iterator<ElementParser>::Parse_Array_iterator()
+prefix_ senf::detail::ArrayParser_iterator<ElementParser>::ArrayParser_iterator()
: i_()
{}
template <class ElementParser>
-prefix_ senf::detail::Parse_Array_iterator<ElementParser>::
-Parse_Array_iterator(PacketParserBase::data_iterator const & i, PacketParserBase::state_type s)
+prefix_ senf::detail::ArrayParser_iterator<ElementParser>::
+ArrayParser_iterator(PacketParserBase::data_iterator const & i, PacketParserBase::state_type s)
: i_(i), s_(s)
{}
template <class ElementParser>
prefix_ ElementParser
-senf::detail::Parse_Array_iterator<ElementParser>::operator[](int i)
+senf::detail::ArrayParser_iterator<ElementParser>::operator[](int i)
const
{
return (*this+i).dereference();
template <class ElementParser>
prefix_ senf::PacketParserBase::data_iterator
-senf::detail::Parse_Array_iterator<ElementParser>::raw()
+senf::detail::ArrayParser_iterator<ElementParser>::raw()
const
{
return i_;
template <class ElementParser>
prefix_ ElementParser
-senf::detail::Parse_Array_iterator<ElementParser>::dereference()
+senf::detail::ArrayParser_iterator<ElementParser>::dereference()
const
{
return ElementParser(i_,s_);
template <class ElementParser>
prefix_ bool
-senf::detail::Parse_Array_iterator<ElementParser>::
-equal(Parse_Array_iterator const & other)
+senf::detail::ArrayParser_iterator<ElementParser>::
+equal(ArrayParser_iterator const & other)
const
{
return i_==other.i_;
}
template <class ElementParser>
-prefix_ int senf::detail::Parse_Array_iterator<ElementParser>::
-distance_to(Parse_Array_iterator const & other)
+prefix_ int senf::detail::ArrayParser_iterator<ElementParser>::
+distance_to(ArrayParser_iterator const & other)
const
{
return (other.i_-i_)/ElementParser::fixed_bytes;
}
template <class ElementParser>
-prefix_ void senf::detail::Parse_Array_iterator<ElementParser>::increment()
+prefix_ void senf::detail::ArrayParser_iterator<ElementParser>::increment()
{
i_ += ElementParser::fixed_bytes;
}
template <class ElementParser>
-prefix_ void senf::detail::Parse_Array_iterator<ElementParser>::decrement()
+prefix_ void senf::detail::ArrayParser_iterator<ElementParser>::decrement()
{
i_ -= ElementParser::fixed_bytes;
}
template <class ElementParser>
-prefix_ void senf::detail::Parse_Array_iterator<ElementParser>::advance(int n)
+prefix_ void senf::detail::ArrayParser_iterator<ElementParser>::advance(int n)
{
i_ += n*ElementParser::fixed_bytes;
}
// 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
// Custom includes
#include "PacketParser.hh"
-//#include "ParseArray.mpp"
+//#include "ArrayParser.mpp"
///////////////////////////////hh.p////////////////////////////////////////
namespace senf {
- namespace detail { template <class> class Parse_Array_iterator; }
+ namespace detail { template <class> class ArrayParser_iterator; }
/** \brief Fixed size collection of fixed size elements
- Parse_Array will parse a sequence of <em>fixed size</em> parsers. The number of array
+ ArrayParser will parse a sequence of <em>fixed size</em> 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 <em>fixed size</em>
\ingroup parsecollection
*/
template <unsigned elements, class ElementParser>
- 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;
// Container interface
typedef ElementParser value_type;
- typedef detail::Parse_Array_iterator<value_type> iterator;
+ typedef detail::ArrayParser_iterator<value_type> iterator;
typedef iterator const_iterator;
static size_type size();
/** \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
\ingroup packetparsermacros
*/
# define SENF_PARSER_ARRAY(name, elt_type, size) \
- typedef senf::Parse_Array<size,elt_type> BOOST_PP_CAT(name, _array_t); \
+ typedef senf::ArrayParser<size,elt_type> 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
\f
// 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 <boost/iterator/iterator_facade.hpp>
\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 ElementParser>
-class senf::detail::Parse_Array_iterator
- : public boost::iterator_facade< Parse_Array_iterator<ElementParser>,
+class senf::detail::ArrayParser_iterator
+ : public boost::iterator_facade< ArrayParser_iterator<ElementParser>,
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
// 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);
// Unit tests
-//#include "ParseArray.test.hh"
-//#include "ParseArray.test.ih"
+//#include "ArrayParser.test.hh"
+//#include "ArrayParser.test.ih"
// Custom includes
#include "Packets.hh"
{
# 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);
};
{
# 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<VoidPacket>::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 );
\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) {}
///////////////////////////////////////////////////////////////////////////
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
\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
\ref EthernetPacket
\par Fields:
- \ref Parse_Ethernet
+ \ref EthernetPacketParser
\par Associated registries:
\ref EtherTypes
#ifndef DOXYGEN
typedef PacketTypeMixin<EthernetPacketType, EtherTypes> mixin;
typedef ConcretePacket<EthernetPacketType> packet;
- typedef Parse_Ethernet parser;
+ typedef EthernetPacketParser parser;
#endif
using mixin::nextPacketRange;
using mixin::initSize;
\see EthVLanPacketType
*/
- struct Parse_EthVLan : public PacketParserBase
+ struct EthVLanPacketParser : public PacketParserBase
{
# include SENF_FIXED_PARSER()
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
\ref EthVLanPacket
\par Fields:
- \ref Parse_EthVLan
+ \ref EthVLanPacketParser
\par Associated registries:
\ref EtherTypes
#ifndef DOXYGEN
typedef PacketTypeMixin<EthVLanPacketType, EtherTypes> mixin;
typedef ConcretePacket<EthVLanPacketType> packet;
- typedef Parse_EthVLan parser;
+ typedef EthVLanPacketParser parser;
#endif
using mixin::nextPacketRange;
using mixin::nextPacketType;
}
///////////////////////////////////////////////////////////////////////////
-// senf::Parse_IPv4
+// senf::IPv4PacketParser
-prefix_ boost::uint16_t senf::Parse_IPv4::calcChecksum()
+prefix_ boost::uint16_t senf::IPv4PacketParser::calcChecksum()
const
{
validate(bytes(*this));
\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) {}
///////////////////////////////////////////////////////////////////////////
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; }
};
\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;
ihl() = 5;
}
- SENF_PARSER_FINALIZE(Parse_IPv4);
+ SENF_PARSER_FINALIZE(IPv4PacketParser);
boost::uint16_t calcChecksum() const;
<th width="12%">20</th> <th width="12%">24</th> <th width="6%">28</th>
<th style="text-align:right" width="6%">31</th>
</tr><tr>
- <td>\ref Parse_IPv4::version() "Version"</td>
- <td>\ref Parse_IPv4::ihl() "IHL"</td>
- <td colspan="2">\ref Parse_IPv4::tos() "TOS"</td>
- <td colspan="8">\ref Parse_IPv4::length() "Length"</td>
+ <td>\ref IPv4PacketParser::version() "Version"</td>
+ <td>\ref IPv4PacketParser::ihl() "IHL"</td>
+ <td colspan="2">\ref IPv4PacketParser::tos() "TOS"</td>
+ <td colspan="8">\ref IPv4PacketParser::length() "Length"</td>
</tr><tr>
- <td colspan="4">\ref Parse_IPv4::identifier() "Identifier"</td>
- <td>\ref Parse_IPv4::reserved() "R"</td>
- <td>\ref Parse_IPv4::df() "DF"</td>
- <td>\ref Parse_IPv4::mf() "MF"</td>
- <td colspan="5">\ref Parse_IPv4::frag() "Fragment Offset"</td>
+ <td colspan="4">\ref IPv4PacketParser::identifier() "Identifier"</td>
+ <td>\ref IPv4PacketParser::reserved() "R"</td>
+ <td>\ref IPv4PacketParser::df() "DF"</td>
+ <td>\ref IPv4PacketParser::mf() "MF"</td>
+ <td colspan="5">\ref IPv4PacketParser::frag() "Fragment Offset"</td>
</tr><tr>
- <td colspan="2">\ref Parse_IPv4::ttl() "Time to Live (ttl)"</td>
- <td colspan="2">\ref Parse_IPv4::protocol() "Protocol"</td>
- <td colspan="8">\ref Parse_IPv4::checksum() "Header Checksum"</td>
+ <td colspan="2">\ref IPv4PacketParser::ttl() "Time to Live (ttl)"</td>
+ <td colspan="2">\ref IPv4PacketParser::protocol() "Protocol"</td>
+ <td colspan="8">\ref IPv4PacketParser::checksum() "Header Checksum"</td>
</tr><tr>
- <td colspan="12">\ref Parse_IPv4::source() "Source Address"</td>
+ <td colspan="12">\ref IPv4PacketParser::source() "Source Address"</td>
</tr><tr>
- <td colspan="12">\ref Parse_IPv4::destination() "Destination Address"</td>
+ <td colspan="12">\ref IPv4PacketParser::destination() "Destination Address"</td>
</tr>
</table>
\ref IPv4Packet
\par Fields:
- \ref Parse_IPv4
+ \ref IPv4PacketParser
\par Associated registries:
\ref IpTypes
#ifndef DOXYGEN
typedef PacketTypeMixin<IPv4PacketType, IpTypes> mixin;
typedef ConcretePacket<IPv4PacketType> packet;
- typedef Parse_IPv4 parser;
+ typedef IPv4PacketParser parser;
#endif
using mixin::nextPacketRange;
using mixin::nextPacketType;
\see IPv6ExtensionType_Fragment \n
<a href="http://tools.ietf.org/html/rfc2460">RFC 2460</a>
*/
- 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
\ref IPv6Extension_Fragment
\par Fields:
- \ref Parse_IPv6Extension_Fragment
+ \ref IPv6PacketParserExtension_Fragment
\par Associated registries:
\par IpTypes
#ifndef DOXYGEN
typedef PacketTypeMixin<IPv6ExtensionType_Fragment, IpTypes> mixin;
typedef ConcretePacket<IPv6ExtensionType_Fragment> packet;
- typedef Parse_IPv6Extension_Fragment parser;
+ typedef IPv6PacketParserExtension_Fragment parser;
#endif
using mixin::nextPacketRange;
using mixin::nextPacketType;
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());
}
\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) {}
///////////////////////////////////////////////////////////////////////////
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; }
};
\see IPv6PacketType \n
<a href="http://tools.ietf.org/html/rfc2460">RFC 2460</a>
*/
- struct Parse_IPv6 : public PacketParserBase
+ struct IPv6PacketParser : public PacketParserBase
{
# include SENF_FIXED_PARSER()
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
\ref IPv6Packet
\par Fields:
- \ref Parse_IPv6
+ \ref IPv6PacketParser
\par Associated registries:
\ref IpTypes
#ifndef DOXYGEN
typedef PacketTypeMixin<IPv6PacketType, IpTypes> mixin;
typedef ConcretePacket<IPv6PacketType> packet;
- typedef Parse_IPv6 parser;
+ typedef IPv6PacketParser parser;
#endif
using mixin::nextPacketRange;
using mixin::nextPacketType;
\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;
\ref LlcSnapPacketType
\par Fields:
- \ref Parse_LlcSnapPacket
+ \ref LlcSnapPacketParser
\par Associated registries:
\ref EtherTypes
#ifndef DOXYGEN
typedef PacketTypeMixin<LlcSnapPacketType, EtherTypes> mixin;
typedef ConcretePacket<LlcSnapPacketType> packet;
- typedef Parse_LlcSnapPacket parser;
+ typedef LlcSnapPacketParser parser;
#endif
using mixin::nextPacketRange;
using mixin::initSize;
}
///////////////////////////////////////////////////////////////////////////
-// senf::Parse_UDP
+// senf::UDPPacketParser
-prefix_ boost::uint16_t senf::Parse_UDP::calcChecksum()
+prefix_ boost::uint16_t senf::UDPPacketParser::calcChecksum()
const
{
IpChecksum summer;
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 ...
IPv6Packet ipv6 (packet().prev<IPv6Packet>(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 );
\see UDPPacketType
<a href="http://tools.ietf.org/html/rfc768">RFC 768</a>
*/
- 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;
\ref UDPPacket
\par Fields:
- \ref Parse_UDP
+ \ref UDPPacketParser
\par Finalize action:
Set \a length from payload size\n
#ifndef DOXYGEN
typedef PacketTypeMixin<UDPPacketType> mixin;
typedef ConcretePacket<UDPPacketType> packet;
- typedef Parse_UDP parser;
+ typedef UDPPacketParser parser;
#endif
using mixin::nextPacketRange;
using mixin::initSize;
// 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 <iostream>
#include <boost/integer/integer_mask.hpp>
#include "PacketParser.hh"
-//#include "ParseInt.mpp"
+//#include "IntParser.mpp"
///////////////////////////////hh.p////////////////////////////////////////
-#include "ParseInt.ih"
+#include "IntParser.ih"
namespace senf {
\see parseint
\ingroup parseint
*/
- struct Parse_Int8
- : public detail::packet::ParseIntOps<Parse_Int8,boost::int8_t>,
+ struct Int8Parser
+ : public detail::packet::IntParserOps<Int8Parser,boost::int8_t>,
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) {}
///////////////////////////////////////////////////////////////////////////
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<Parse_UInt8,boost::uint8_t>,
+ struct UInt8Parser
+ : public detail::packet::IntParserOps<UInt8Parser,boost::uint8_t>,
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) {}
///////////////////////////////////////////////////////////////////////////
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<Parse_Int16,boost::int16_t>,
+ struct Int16Parser
+ : public detail::packet::IntParserOps<Int16Parser,boost::int16_t>,
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) {}
///////////////////////////////////////////////////////////////////////////
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<Parse_UInt16,boost::uint16_t>,
+ struct UInt16Parser
+ : public detail::packet::IntParserOps<UInt16Parser,boost::uint16_t>,
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) {}
///////////////////////////////////////////////////////////////////////////
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<Parse_Int24,boost::int32_t>,
+ struct Int24Parser
+ : public detail::packet::IntParserOps<Int24Parser,boost::int32_t>,
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) {}
///////////////////////////////////////////////////////////////////////////
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<Parse_UInt24,boost::uint32_t>,
+ struct UInt24Parser
+ : public detail::packet::IntParserOps<UInt24Parser,boost::uint32_t>,
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) {}
///////////////////////////////////////////////////////////////////////////
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<Parse_Int32,boost::int32_t>,
+ struct Int32Parser
+ : public detail::packet::IntParserOps<Int32Parser,boost::int32_t>,
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) {}
///////////////////////////////////////////////////////////////////////////
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<Parse_UInt32,boost::uint32_t>,
+ struct UInt32Parser
+ : public detail::packet::IntParserOps<UInt32Parser,boost::uint32_t>,
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) {}
///////////////////////////////////////////////////////////////////////////
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
End. Bits are numbered <em>most significant bit first</em> 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
\ingroup parseint
*/
template <unsigned Start, unsigned End>
- struct Parse_IntField
- : public detail::packet::ParseIntOps<Parse_IntField<Start,End>,boost::int32_t>,
+ struct IntFieldParser
+ : public detail::packet::IntParserOps<IntFieldParser<Start,End>,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) {}
///////////////////////////////////////////////////////////////////////////
v | ~boost::low_bits_mask_t<End-Start>::sig_bits : v;
}
void value(value_type v) { detail::packet::parse_bitfield<Start,End>::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<End );
BOOST_STATIC_ASSERT( End-Start<=32 );
};
/** \brief Write parsed value to stream
- \related Parse_IntField
+ \related IntFieldParser
*/
template <unsigned Start, unsigned End>
- inline std::ostream & operator<<(std::ostream & os, Parse_IntField<Start,End> const & i)
+ inline std::ostream & operator<<(std::ostream & os, IntFieldParser<Start,End> const & i)
{ os << i.value(); return os; }
/** \brief Parse unsigned bitfield with up to 32bit's
End. Bits are numbered <em>most significant bit first</em> 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
\ingroup parseint
*/
template <unsigned Start, unsigned End>
- struct Parse_UIntField
- : public detail::packet::ParseIntOps<Parse_UIntField<Start,End>,boost::uint32_t>,
+ struct UIntFieldParser
+ : public detail::packet::IntParserOps<UIntFieldParser<Start,End>,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) {}
///////////////////////////////////////////////////////////////////////////
value_type value() const { return detail::packet::parse_bitfield<Start,End>::parse(i()); }
void value(value_type v) { detail::packet::parse_bitfield<Start,End>::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<End );
BOOST_STATIC_ASSERT( End-Start<=32 );
};
/** \brief Write parsed value to stream
- \related Parse_UIntField
+ \related UIntFieldParser
*/
template <unsigned Start, unsigned End>
- inline std::ostream & operator<<(std::ostream & os, Parse_UIntField<Start,End> const & i)
+ inline std::ostream & operator<<(std::ostream & os, UIntFieldParser<Start,End> 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 <em>most
significant bit first</em> 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
\ingroup parseint
*/
template <unsigned Bit>
- struct Parse_Flag
- : public detail::packet::ParseIntOps<Parse_Flag<Bit>,bool>,
+ struct FlagParser
+ : public detail::packet::IntParserOps<FlagParser<Bit>,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) {}
///////////////////////////////////////////////////////////////////////////
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 <unsigned Bit>
- inline std::ostream & operator<<(std::ostream & os, Parse_Flag<Bit> const & i)
+ inline std::ostream & operator<<(std::ostream & os, FlagParser<Bit> 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
\f
// 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"
inherited by each integer parser.
*/
template <class Derived, class Value>
- class ParseIntOps
+ class IntParserOps
{
public:
typedef Value value_type;
// Unit tests
-//#include "ParseInt.test.hh"
-//#include "ParseInt.test.ih"
+//#include "IntParser.test.hh"
+//#include "IntParser.test.ih"
// Custom includes
#include "Packets.hh"
PacketInterpreterBase::byte data[] = { 0x8e, 0x2f, 0x57, 0x12, 0xd1 };
PacketInterpreterBase::ptr p (PacketInterpreter<VoidPacket>::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)
PacketInterpreterBase::ptr p (PacketInterpreter<VoidPacket>::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)
PacketInterpreterBase::byte data[] = { 0x00, 0x00, 0x00, 0x00, 0x00 };
PacketInterpreterBase::ptr p (PacketInterpreter<VoidPacket>::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)
PacketInterpreterBase::byte data[] = { 0x63, 0xd7, 0x5a, 0x31, 0xa4, 0x46 };
PacketInterpreterBase::ptr p (PacketInterpreter<VoidPacket>::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 );
// 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
///////////////////////////////cti.p///////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
-// senf::detail::Parse_ListB_Policy<ElementParser,BytesParser>
+// senf::detail::ListBParser_Policy<ElementParser,BytesParser>
template <class ElementParser, class BytesParser>
-prefix_ typename senf::detail::Parse_ListB_Policy<ElementParser,BytesParser>::size_type
-senf::detail::Parse_ListB_Policy<ElementParser,BytesParser>::bytes(iterator i, state_type s)
+prefix_ typename senf::detail::ListBParser_Policy<ElementParser,BytesParser>::size_type
+senf::detail::ListBParser_Policy<ElementParser,BytesParser>::bytes(iterator i, state_type s)
const
{
return BytesParser(i,s) + BytesParser::fixed_bytes;
}
template <class ElementParser, class BytesParser>
-prefix_ typename senf::detail::Parse_ListB_Policy<ElementParser,BytesParser>::size_type
-senf::detail::Parse_ListB_Policy<ElementParser,BytesParser>::size(iterator i, state_type s)
+prefix_ typename senf::detail::ListBParser_Policy<ElementParser,BytesParser>::size_type
+senf::detail::ListBParser_Policy<ElementParser,BytesParser>::size(iterator i, state_type s)
const
{
parser_type l (i,s);
}
template <class ElementParser, class BytesParser>
-prefix_ void senf::detail::Parse_ListB_Policy<ElementParser,BytesParser>::init(iterator i,
+prefix_ void senf::detail::ListBParser_Policy<ElementParser,BytesParser>::init(iterator i,
state_type s)
const
{}
///////////////////////////////////////////////////////////////////////////
-// senf::detail::Parse_ListB_Policy<ElementParser,BytesParser>::iterator_policy
+// senf::detail::ListBParser_Policy<ElementParser,BytesParser>::iterator_policy
template <class ElementParser, class BytesParser>
-prefix_ typename senf::detail::Parse_ListB_Policy<ElementParser,BytesParser>::iterator
-senf::detail::Parse_ListB_Policy<ElementParser,BytesParser>::iterator_policy::
+prefix_ typename senf::detail::ListBParser_Policy<ElementParser,BytesParser>::iterator
+senf::detail::ListBParser_Policy<ElementParser,BytesParser>::iterator_policy::
setBegin(iterator i, state_type s)
{
return boost::next(i,BytesParser::fixed_bytes);
}
template <class ElementParser, class BytesParser>
-prefix_ typename senf::detail::Parse_ListB_Policy<ElementParser,BytesParser>::iterator
-senf::detail::Parse_ListB_Policy<ElementParser,BytesParser>::iterator_policy::
+prefix_ typename senf::detail::ListBParser_Policy<ElementParser,BytesParser>::iterator
+senf::detail::ListBParser_Policy<ElementParser,BytesParser>::iterator_policy::
setEnd(iterator i, state_type s)
{
return boost::next(i,BytesParser(i,s) + BytesParser::fixed_bytes);
template <class ElementParser, class BytesParser>
prefix_ void
-senf::detail::Parse_ListB_Policy<ElementParser,BytesParser>::iterator_policy::
+senf::detail::ListBParser_Policy<ElementParser,BytesParser>::iterator_policy::
setFromPosition(iterator i, state_type s, iterator p)
{}
template <class ElementParser, class BytesParser>
-prefix_ typename senf::detail::Parse_ListB_Policy<ElementParser,BytesParser>::iterator
-senf::detail::Parse_ListB_Policy<ElementParser,BytesParser>::iterator_policy::next(iterator i,
+prefix_ typename senf::detail::ListBParser_Policy<ElementParser,BytesParser>::iterator
+senf::detail::ListBParser_Policy<ElementParser,BytesParser>::iterator_policy::next(iterator i,
state_type s)
{
return boost::next(i,senf::bytes(ElementParser(i,s)));
}
template <class ElementParser, class BytesParser>
-prefix_ typename senf::detail::Parse_ListB_Policy<ElementParser,BytesParser>::iterator
-senf::detail::Parse_ListB_Policy<ElementParser,BytesParser>::iterator_policy::raw(iterator i,
+prefix_ typename senf::detail::ListBParser_Policy<ElementParser,BytesParser>::iterator
+senf::detail::ListBParser_Policy<ElementParser,BytesParser>::iterator_policy::raw(iterator i,
state_type s)
const
{
}
///////////////////////////////////////////////////////////////////////////
-// senf::detail::Parse_ListB_Policy<ElementParser,BytesParser>
+// senf::detail::ListBParser_Policy<ElementParser,BytesParser>
template <class ElementParser, class BytesParser>
prefix_
-senf::detail::Parse_ListB_Policy<ElementParser,BytesParser>::container_policy::
+senf::detail::ListBParser_Policy<ElementParser,BytesParser>::container_policy::
container_policy(parser_type const & list)
{
iterator const e (boost::next(list.i(),list.bytes()));
}
template <class ElementParser, class BytesParser>
-prefix_ typename senf::detail::Parse_ListB_Policy<ElementParser,BytesParser>::size_type
-senf::detail::Parse_ListB_Policy<ElementParser,BytesParser>::container_policy::
+prefix_ typename senf::detail::ListBParser_Policy<ElementParser,BytesParser>::size_type
+senf::detail::ListBParser_Policy<ElementParser,BytesParser>::container_policy::
bytes(iterator i, state_type s)
const
{
}
template <class ElementParser, class BytesParser>
-prefix_ typename senf::detail::Parse_ListB_Policy<ElementParser,BytesParser>::size_type
-senf::detail::Parse_ListB_Policy<ElementParser,BytesParser>::container_policy::
+prefix_ typename senf::detail::ListBParser_Policy<ElementParser,BytesParser>::size_type
+senf::detail::ListBParser_Policy<ElementParser,BytesParser>::container_policy::
size(iterator i, state_type s)
const
{
template <class ElementParser, class BytesParser>
prefix_ void
-senf::detail::Parse_ListB_Policy<ElementParser,BytesParser>::container_policy::
+senf::detail::ListBParser_Policy<ElementParser,BytesParser>::container_policy::
erase(iterator i, state_type s, iterator p)
{
size_type b (senf::bytes(ElementParser(p,s)));
template <class ElementParser, class BytesParser>
prefix_ void
-senf::detail::Parse_ListB_Policy<ElementParser,BytesParser>::container_policy::
+senf::detail::ListBParser_Policy<ElementParser,BytesParser>::container_policy::
insert(iterator i, state_type s, iterator p)
{
BytesParser(i,s) += senf::bytes(ElementParser(p,s));
template <class ElementParser, class BytesParser>
prefix_ void
-senf::detail::Parse_ListB_Policy<ElementParser,BytesParser>::container_policy::
+senf::detail::ListBParser_Policy<ElementParser,BytesParser>::container_policy::
init(iterator i, state_type s)
{
n_ = 0;
template <class ElementParser, class BytesParser>
prefix_ void
-senf::detail::Parse_ListB_Policy<ElementParser,BytesParser>::container_policy::
+senf::detail::ListBParser_Policy<ElementParser,BytesParser>::container_policy::
update(iterator i, state_type s)
const
{
// 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 ElementParser, class BytesParser>
- 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.
access the packet through the lowest-level active container wrapper.
\implementation These restrictions are necessary to ensure correct recalculation of the
- <tt>bytes</tt> field. For more info, see the comments in \ref ParseListB.ih
+ <tt>bytes</tt> field. For more info, see the comments in \ref ListBParser.ih
- \see Parse_List
+ \see ListParser
\ingroup parsecollection
*/
template <class ElementParser, class BytesParser>
- struct Parse_ListB {
- typedef Parse_List< detail::Parse_ListB_Policy<ElementParser,BytesParser> > parser;
+ struct ListBParser {
+ typedef ListParser< detail::ListBParser_Policy<ElementParser,BytesParser> > 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).
\ingroup packetparsermacros
*/
# define SENF_PARSER_LIST_B(name, elt_type, size_type) \
- typedef senf::Parse_ListB<elt_type, size_type>::parser BOOST_PP_CAT(name, _list_t); \
+ typedef senf::ListBParser<elt_type, size_type>::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
\f
// 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
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 <class ElementParser, class BytesParser>
- 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
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;
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
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);
// 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"
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<ParseVec,senf::Parse_UInt16>::parser ParseList;
+ typedef senf::ListBParser<VectorParser,senf::UInt16Parser>::parser MyListBParser;
}
-BOOST_AUTO_UNIT_TEST(parseListB)
+BOOST_AUTO_UNIT_TEST(ListBParser)
{
senf::PacketInterpreterBase::ptr pi (senf::PacketInterpreter<VoidPacket>::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 );
// 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<VoidPacket>::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 );
{
senf::PacketInterpreterBase::ptr pi2 (senf::PacketInterpreter<VoidPacket>::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);
}
// 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
template <class ElementParser, class SizeParser>
prefix_ void
-senf::detail::Parse_ListN_Policy<ElementParser,SizeParser>::iterator_policy::
+senf::detail::ListNParser_Policy<ElementParser,SizeParser>::iterator_policy::
setFromPosition(iterator i, state_type s, iterator p)
{
l_ = i;
}
template <class ElementParser, class SizeParser>
-prefix_ typename senf::detail::Parse_ListN_Policy<ElementParser,SizeParser>::iterator
-senf::detail::Parse_ListN_Policy<ElementParser,SizeParser>::iterator_policy::raw(iterator i,
+prefix_ typename senf::detail::ListNParser_Policy<ElementParser,SizeParser>::iterator
+senf::detail::ListNParser_Policy<ElementParser,SizeParser>::iterator_policy::raw(iterator i,
state_type s)
const
{
// 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
///////////////////////////////cti.p///////////////////////////////////////
template <class ElementParser, class SizeParser>
-prefix_ typename senf::detail::Parse_ListN_Policy<ElementParser,SizeParser>::size_type
-senf::detail::Parse_ListN_Policy<ElementParser,SizeParser>::bytes(iterator i, state_type s)
+prefix_ typename senf::detail::ListNParser_Policy<ElementParser,SizeParser>::size_type
+senf::detail::ListNParser_Policy<ElementParser,SizeParser>::bytes(iterator i, state_type s)
const
{
return std::distance(i,parser_type(i,s).end().raw());
}
template <class ElementParser, class SizeParser>
-prefix_ typename senf::detail::Parse_ListN_Policy<ElementParser,SizeParser>::size_type
-senf::detail::Parse_ListN_Policy<ElementParser,SizeParser>::size(iterator i, state_type s)
+prefix_ typename senf::detail::ListNParser_Policy<ElementParser,SizeParser>::size_type
+senf::detail::ListNParser_Policy<ElementParser,SizeParser>::size(iterator i, state_type s)
const
{
return SizeParser(i,s);
}
template <class ElementParser, class SizeParser>
-prefix_ void senf::detail::Parse_ListN_Policy<ElementParser,SizeParser>::init(iterator i,
+prefix_ void senf::detail::ListNParser_Policy<ElementParser,SizeParser>::init(iterator i,
state_type s)
const
{}
template <class ElementParser, class SizeParser>
-prefix_ void senf::detail::Parse_ListN_Policy<ElementParser,SizeParser>::erase(iterator i,
+prefix_ void senf::detail::ListNParser_Policy<ElementParser,SizeParser>::erase(iterator i,
state_type s,
iterator p)
const
}
template <class ElementParser, class SizeParser>
-prefix_ void senf::detail::Parse_ListN_Policy<ElementParser,SizeParser>::insert(iterator i,
+prefix_ void senf::detail::ListNParser_Policy<ElementParser,SizeParser>::insert(iterator i,
state_type s,
iterator p)
const
}
template <class ElementParser, class SizeParser>
-prefix_ void senf::detail::Parse_ListN_Policy<ElementParser,SizeParser>::update(iterator i,
+prefix_ void senf::detail::ListNParser_Policy<ElementParser,SizeParser>::update(iterator i,
state_type s)
const
{}
template <class ElementParser, class SizeParser>
-prefix_ typename senf::detail::Parse_ListN_Policy<ElementParser,SizeParser>::iterator
-senf::detail::Parse_ListN_Policy<ElementParser,SizeParser>::iterator_policy::
+prefix_ typename senf::detail::ListNParser_Policy<ElementParser,SizeParser>::iterator
+senf::detail::ListNParser_Policy<ElementParser,SizeParser>::iterator_policy::
setBegin(iterator i, state_type s)
{
l_ = i;
}
template <class ElementParser, class SizeParser>
-prefix_ typename senf::detail::Parse_ListN_Policy<ElementParser,SizeParser>::iterator
-senf::detail::Parse_ListN_Policy<ElementParser,SizeParser>::iterator_policy::
+prefix_ typename senf::detail::ListNParser_Policy<ElementParser,SizeParser>::iterator
+senf::detail::ListNParser_Policy<ElementParser,SizeParser>::iterator_policy::
setEnd(iterator i, state_type s)
{
l_ = i;
}
template <class ElementParser, class SizeParser>
-prefix_ typename senf::detail::Parse_ListN_Policy<ElementParser,SizeParser>::iterator
-senf::detail::Parse_ListN_Policy<ElementParser,SizeParser>::iterator_policy::next(iterator i,
+prefix_ typename senf::detail::ListNParser_Policy<ElementParser,SizeParser>::iterator
+senf::detail::ListNParser_Policy<ElementParser,SizeParser>::iterator_policy::next(iterator i,
state_type s)
{
--n_;
template <class ElementParser, class SizeParser>
prefix_ senf::PacketData &
-senf::detail::Parse_ListN_Policy<ElementParser,SizeParser>::data(state_type s)
+senf::detail::ListNParser_Policy<ElementParser,SizeParser>::data(state_type s)
{
return *s;
}
// 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 ElementParser, class SizeParser>
- 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 <class ElementParser, class SizeParser>
- struct Parse_ListN {
- typedef Parse_List< detail::Parse_ListN_Policy<ElementParser,SizeParser> > parser;
+ struct ListNParser {
+ typedef ListParser< detail::ListNParser_Policy<ElementParser,SizeParser> > 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).
\ingroup packetparsermacros
*/
# define SENF_PARSER_LIST_N(name, elt_type, size_type) \
- typedef senf::Parse_ListN<elt_type, size_type>::parser BOOST_PP_CAT(name, _list_t); \
+ typedef senf::ListNParser<elt_type, size_type>::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
\f
// 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
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 <class ElementParser, class SizeParser>
- 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;
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
// 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"
{
# 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<MyVec,senf::Parse_UInt16>::parser ParseList;
+ typedef senf::ListNParser<MyVec,senf::UInt16Parser>::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 );
}
{
-# 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 );
}
}
-BOOST_AUTO_UNIT_TEST(parseListN_container)
+BOOST_AUTO_UNIT_TEST(ListNParser_container)
{
- typedef senf::Parse_ListN<MyVec,senf::Parse_UInt16>::parser ParseList;
+ typedef senf::ListNParser<MyVec,senf::UInt16Parser>::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();
}
// 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
///////////////////////////////ct.p////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
-// senf::Parse_List<ElementParser,ListPolicy>
+// senf::ListParser<ElementParser,ListPolicy>
template <class ListPolicy>
-prefix_ void senf::Parse_List<ListPolicy>::init()
+prefix_ void senf::ListParser<ListPolicy>::init()
const
{
ListPolicy::init(i(),state());
}
template <class ListPolicy>
-prefix_ typename senf::Parse_List<ListPolicy>::value_type
-senf::Parse_List<ListPolicy>::back()
+prefix_ typename senf::ListParser<ListPolicy>::value_type
+senf::ListParser<ListPolicy>::back()
const
{
BOOST_ASSERT( ! empty() );
}
///////////////////////////////////////////////////////////////////////////
-// senf::Parse_List_Container<ListPolicy>
+// senf::ListParser_Container<ListPolicy>
template <class ListPolicy>
-prefix_ typename senf::Parse_List_Container<ListPolicy>::value_type
-senf::Parse_List_Container<ListPolicy>::back()
+prefix_ typename senf::ListParser_Container<ListPolicy>::value_type
+senf::ListParser_Container<ListPolicy>::back()
const
{
BOOST_ASSERT( ! empty() );
}
template <class ListPolicy>
-prefix_ void senf::Parse_List_Container<ListPolicy>::shift(iterator pos, size_type n)
+prefix_ void senf::ListParser_Container<ListPolicy>::shift(iterator pos, size_type n)
{
ListPolicy::update(i(),state());
safe_data_iterator sp (data(),pos.raw());
template <class ListPolicy>
template <class Value>
-prefix_ void senf::Parse_List_Container<ListPolicy>::insert(iterator pos,
+prefix_ void senf::ListParser_Container<ListPolicy>::insert(iterator pos,
size_type n,
Value const & t)
{
#ifndef DOXYGEN
template <class ListPolicy>
template <class ForwardIterator>
-prefix_ void senf::Parse_List_Container<ListPolicy>::
+prefix_ void senf::ListParser_Container<ListPolicy>::
insert(iterator pos, ForwardIterator f, ForwardIterator l,
typename boost::disable_if< boost::is_convertible<ForwardIterator,size_type> >::type *)
{
#else
template <class ListPolicy>
template <class ForwardIterator>
-prefix_ void senf::Parse_List_Container<ListPolicy>::
+prefix_ void senf::ListParser_Container<ListPolicy>::
insert(iterator pos, ForwardIterator f, ForwardIterator l)
{}
#endif
template <class ListPolicy>
-prefix_ void senf::Parse_List_Container<ListPolicy>::erase(iterator pos,
+prefix_ void senf::ListParser_Container<ListPolicy>::erase(iterator pos,
size_type n)
{
ListPolicy::update(i(),state());
}
template <class ListPolicy>
-prefix_ void senf::Parse_List_Container<ListPolicy>::clear()
+prefix_ void senf::ListParser_Container<ListPolicy>::clear()
{
size_type sz (bytes());
if (sz > ListPolicy::init_bytes)
}
template <class ListPolicy>
-prefix_ void senf::Parse_List_Container<ListPolicy>::resize(size_type n)
+prefix_ void senf::ListParser_Container<ListPolicy>::resize(size_type n)
{
size_type sz (size());
if (sz>n)
template <class ListPolicy>
template <class Value>
-prefix_ void senf::Parse_List_Container<ListPolicy>::resize(size_type n,
+prefix_ void senf::ListParser_Container<ListPolicy>::resize(size_type n,
Value value)
{
size_type sz (size());
// 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
///////////////////////////////cti.p///////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
-// senf::Parse_List<ListPolicy>
+// senf::ListParser<ListPolicy>
template <class ListPolicy>
-prefix_ senf::Parse_List<ListPolicy>::Parse_List(data_iterator i, state_type s)
+prefix_ senf::ListParser<ListPolicy>::ListParser(data_iterator i, state_type s)
: PacketParserBase(i,s), ListPolicy()
{}
template <class ListPolicy>
-prefix_ senf::Parse_List<ListPolicy>::Parse_List(ListPolicy policy,
+prefix_ senf::ListParser<ListPolicy>::ListParser(ListPolicy policy,
data_iterator i, state_type s)
: PacketParserBase(i,s), ListPolicy(policy)
{}
template <class ListPolicy>
prefix_ senf::PacketParserBase::size_type
-senf::Parse_List<ListPolicy>::bytes()
+senf::ListParser<ListPolicy>::bytes()
const
{
return ListPolicy::bytes(i(),state());
template <class ListPolicy>
prefix_ senf::PacketParserBase::size_type
-senf::Parse_List<ListPolicy>::size()
+senf::ListParser<ListPolicy>::size()
const
{
return ListPolicy::size(i(),state());
}
template <class ListPolicy>
-prefix_ bool senf::Parse_List<ListPolicy>::empty()
+prefix_ bool senf::ListParser<ListPolicy>::empty()
const
{
return begin() == end();
}
template <class ListPolicy>
-prefix_ typename senf::Parse_List<ListPolicy>::iterator
-senf::Parse_List<ListPolicy>::begin()
+prefix_ typename senf::ListParser<ListPolicy>::iterator
+senf::ListParser<ListPolicy>::begin()
const
{
return iterator(i(),state(),iterator::Begin);
}
template <class ListPolicy>
-prefix_ typename senf::Parse_List<ListPolicy>::iterator
-senf::Parse_List<ListPolicy>::end()
+prefix_ typename senf::ListParser<ListPolicy>::iterator
+senf::ListParser<ListPolicy>::end()
const
{
return iterator(i(),state(),iterator::End);
}
template <class ListPolicy>
-prefix_ typename senf::Parse_List<ListPolicy>::value_type
-senf::Parse_List<ListPolicy>::front()
+prefix_ typename senf::ListParser<ListPolicy>::value_type
+senf::ListParser<ListPolicy>::front()
const
{
BOOST_ASSERT( ! empty() );
template <class ListPolicy>
template <class Value>
-prefix_ void senf::Parse_List<ListPolicy>::push_back(Value value, size_type n)
+prefix_ void senf::ListParser<ListPolicy>::push_back(Value value, size_type n)
const
{
container c(*this);
}
template <class ListPolicy>
-prefix_ void senf::Parse_List<ListPolicy>::push_back_space(size_type n)
+prefix_ void senf::ListParser<ListPolicy>::push_back_space(size_type n)
const
{
container c(*this);
template <class ListPolicy>
template <class Value>
-prefix_ void senf::Parse_List<ListPolicy>::push_front(Value value, size_type n)
+prefix_ void senf::ListParser<ListPolicy>::push_front(Value value, size_type n)
const
{
container c(*this);
}
template <class ListPolicy>
-prefix_ void senf::Parse_List<ListPolicy>::push_front_space(size_type n)
+prefix_ void senf::ListParser<ListPolicy>::push_front_space(size_type n)
const
{
container c(*this);
}
template <class ListPolicy>
-prefix_ void senf::Parse_List<ListPolicy>::resize(size_type n)
+prefix_ void senf::ListParser<ListPolicy>::resize(size_type n)
const
{
container c(*this);
template <class ListPolicy>
template <class Value>
-prefix_ void senf::Parse_List<ListPolicy>::resize(size_type n, Value value)
+prefix_ void senf::ListParser<ListPolicy>::resize(size_type n, Value value)
const
{
container c(*this);
}
///////////////////////////////////////////////////////////////////////////
-// senf::detail::Parse_List_Iterator<ElementParser,IteratorPolicy>
+// senf::detail::ListParser_Iterator<ElementParser,IteratorPolicy>
template <class ElementParser, class IteratorPolicy>
-prefix_ senf::detail::Parse_List_Iterator<ElementParser,IteratorPolicy>::Parse_List_Iterator()
+prefix_ senf::detail::ListParser_Iterator<ElementParser,IteratorPolicy>::ListParser_Iterator()
{}
template <class ElementParser, class IteratorPolicy>
-prefix_ senf::detail::Parse_List_Iterator<ElementParser,IteratorPolicy>::
-Parse_List_Iterator(PacketParserBase::data_iterator i, PacketParserBase::state_type s, Begin_t)
+prefix_ senf::detail::ListParser_Iterator<ElementParser,IteratorPolicy>::
+ListParser_Iterator(PacketParserBase::data_iterator i, PacketParserBase::state_type s, Begin_t)
: IteratorPolicy(), i_(IteratorPolicy::setBegin(i,s)), s_(s)
{}
template <class ElementParser, class IteratorPolicy>
-prefix_ senf::detail::Parse_List_Iterator<ElementParser,IteratorPolicy>::
-Parse_List_Iterator(PacketParserBase::data_iterator i, PacketParserBase::state_type s, End_t)
+prefix_ senf::detail::ListParser_Iterator<ElementParser,IteratorPolicy>::
+ListParser_Iterator(PacketParserBase::data_iterator i, PacketParserBase::state_type s, End_t)
: IteratorPolicy(), i_(IteratorPolicy::setEnd(i,s)), s_(s)
{}
template <class ElementParser, class IteratorPolicy>
-prefix_ senf::detail::Parse_List_Iterator<ElementParser,IteratorPolicy>::
-Parse_List_Iterator(PacketParserBase::data_iterator i, PacketParserBase::state_type s,
+prefix_ senf::detail::ListParser_Iterator<ElementParser,IteratorPolicy>::
+ListParser_Iterator(PacketParserBase::data_iterator i, PacketParserBase::state_type s,
PacketParserBase::data_iterator p)
: IteratorPolicy(), i_(p), s_(s)
{
template <class ElementParser, class IteratorPolicy>
prefix_ senf::PacketParserBase::data_iterator
-senf::detail::Parse_List_Iterator<ElementParser,IteratorPolicy>::raw()
+senf::detail::ListParser_Iterator<ElementParser,IteratorPolicy>::raw()
const
{
return IteratorPolicy::raw(i_,s_);
template <class ElementParser, class IteratorPolicy>
prefix_ ElementParser
-senf::detail::Parse_List_Iterator<ElementParser,IteratorPolicy>::dereference()
+senf::detail::ListParser_Iterator<ElementParser,IteratorPolicy>::dereference()
const
{
return ElementParser(i_,s_);
}
template <class ElementParser, class IteratorPolicy>
-prefix_ bool senf::detail::Parse_List_Iterator<ElementParser,IteratorPolicy>::
-equal(Parse_List_Iterator const & other)
+prefix_ bool senf::detail::ListParser_Iterator<ElementParser,IteratorPolicy>::
+equal(ListParser_Iterator const & other)
const
{
return i_ == other.i_;
}
template <class ElementParser, class IteratorPolicy>
-prefix_ void senf::detail::Parse_List_Iterator<ElementParser,IteratorPolicy>::increment()
+prefix_ void senf::detail::ListParser_Iterator<ElementParser,IteratorPolicy>::increment()
{
i_ = IteratorPolicy::next(i_,s_);
}
///////////////////////////////////////////////////////////////////////////
-// senf::Parse_List_Container<ListPolicy>
+// senf::ListParser_Container<ListPolicy>
// Structors and default members
template <class ListPolicy>
-prefix_ senf::Parse_List_Container<ListPolicy>::
-Parse_List_Container(parser_type const & list)
+prefix_ senf::ListParser_Container<ListPolicy>::
+ListParser_Container(parser_type const & list)
: ListPolicy(list), state_(list.state()), i_(std::distance(data().begin(),list.i()))
{}
template <class ListPolicy>
-prefix_ senf::Parse_List_Container<ListPolicy>::~Parse_List_Container()
+prefix_ senf::ListParser_Container<ListPolicy>::~ListParser_Container()
{
ListPolicy::update(i(),state());
}
// Accessors
template <class ListPolicy>
-prefix_ typename senf::Parse_List_Container<ListPolicy>::size_type
-senf::Parse_List_Container<ListPolicy>::size()
+prefix_ typename senf::ListParser_Container<ListPolicy>::size_type
+senf::ListParser_Container<ListPolicy>::size()
const
{
ListPolicy::update(i(),state());
}
template <class ListPolicy>
-prefix_ bool senf::Parse_List_Container<ListPolicy>::empty()
+prefix_ bool senf::ListParser_Container<ListPolicy>::empty()
const
{
ListPolicy::update(i(),state());
}
template <class ListPolicy>
-prefix_ typename senf::Parse_List_Container<ListPolicy>::iterator
-senf::Parse_List_Container<ListPolicy>::begin()
+prefix_ typename senf::ListParser_Container<ListPolicy>::iterator
+senf::ListParser_Container<ListPolicy>::begin()
const
{
ListPolicy::update(i(),state());
}
template <class ListPolicy>
-prefix_ typename senf::Parse_List_Container<ListPolicy>::iterator
-senf::Parse_List_Container<ListPolicy>::end()
+prefix_ typename senf::ListParser_Container<ListPolicy>::iterator
+senf::ListParser_Container<ListPolicy>::end()
const
{
ListPolicy::update(i(),state());
}
template <class ListPolicy>
-prefix_ typename senf::Parse_List_Container<ListPolicy>::value_type
-senf::Parse_List_Container<ListPolicy>::front()
+prefix_ typename senf::ListParser_Container<ListPolicy>::value_type
+senf::ListParser_Container<ListPolicy>::front()
const
{
BOOST_ASSERT( ! empty() );
template <class ListPolicy>
template <class Value>
-prefix_ void senf::Parse_List_Container<ListPolicy>::insert(iterator pos,
+prefix_ void senf::ListParser_Container<ListPolicy>::insert(iterator pos,
Value const & t)
{
insert(pos,1,t);
}
template <class ListPolicy>
-prefix_ void senf::Parse_List_Container<ListPolicy>::erase(iterator f, iterator l)
+prefix_ void senf::ListParser_Container<ListPolicy>::erase(iterator f, iterator l)
{
erase(f,std::distance(f,l));
}
template <class ListPolicy>
template <class Value>
-prefix_ void senf::Parse_List_Container<ListPolicy>::push_back(Value value,
+prefix_ void senf::ListParser_Container<ListPolicy>::push_back(Value value,
size_type n)
{
insert(end(),n,value);
}
template <class ListPolicy>
-prefix_ void senf::Parse_List_Container<ListPolicy>::push_back_space(size_type n)
+prefix_ void senf::ListParser_Container<ListPolicy>::push_back_space(size_type n)
{
shift(end(),n);
}
template <class ListPolicy>
template <class Value>
-prefix_ void senf::Parse_List_Container<ListPolicy>::push_front(Value value,
+prefix_ void senf::ListParser_Container<ListPolicy>::push_front(Value value,
size_type n)
{
insert(begin(),n,value);
}
template <class ListPolicy>
-prefix_ void senf::Parse_List_Container<ListPolicy>::push_front_space(size_type n)
+prefix_ void senf::ListParser_Container<ListPolicy>::push_front_space(size_type n)
{
shift(begin(),n);
}
// Parser interface
template <class ListPolicy>
-prefix_ typename senf::Parse_List_Container<ListPolicy>::parser_type
-senf::Parse_List_Container<ListPolicy>::parser()
+prefix_ typename senf::ListParser_Container<ListPolicy>::parser_type
+senf::ListParser_Container<ListPolicy>::parser()
const
{
ListPolicy::update(i(),state());
}
template <class ListPolicy>
-prefix_ typename senf::Parse_List_Container<ListPolicy>::data_iterator
-senf::Parse_List_Container<ListPolicy>::i()
+prefix_ typename senf::ListParser_Container<ListPolicy>::data_iterator
+senf::ListParser_Container<ListPolicy>::i()
const
{
return boost::next(data().begin(),i_);
}
template <class ListPolicy>
-prefix_ typename senf::Parse_List_Container<ListPolicy>::state_type
-senf::Parse_List_Container<ListPolicy>::state()
+prefix_ typename senf::ListParser_Container<ListPolicy>::state_type
+senf::ListParser_Container<ListPolicy>::state()
const
{
return state_;
}
template <class ListPolicy>
-prefix_ senf::PacketData & senf::Parse_List_Container<ListPolicy>::data()
+prefix_ senf::PacketData & senf::ListParser_Container<ListPolicy>::data()
const
{
return *state_;
}
template <class ListPolicy>
-prefix_ typename senf::Parse_List_Container<ListPolicy>::size_type
-senf::Parse_List_Container<ListPolicy>::bytes()
+prefix_ typename senf::ListParser_Container<ListPolicy>::size_type
+senf::ListParser_Container<ListPolicy>::bytes()
const
{
ListPolicy::update(i(),state());
}
template <class ListPolicy>
-prefix_ void senf::Parse_List_Container<ListPolicy>::init()
+prefix_ void senf::ListParser_Container<ListPolicy>::init()
const
{
parser().init();
// 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 <boost/utility.hpp>
#include "PacketParser.hh"
-//#include "ParseList.mpp"
+//#include "ListParser.mpp"
///////////////////////////////hh.p////////////////////////////////////////
namespace senf {
namespace detail { template <class ElementParser, class IteratorPolicy>
- class Parse_List_Iterator; }
+ class ListParser_Iterator; }
template <class ListPolicy>
- class Parse_List_Container;
+ class ListParser_Container;
/** \brief Arbitrary sequential element collection
\ingroup parsecollection
*/
template <class ListPolicy>
- 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. */
// 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;
template <class Value> void resize (size_type n, Value value) const;
private:
- template <class Policy> friend class Parse_List_Container;
+ template <class Policy> 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
c.insert(c.begin(), ... );
\endcode
- \see Parse_List
+ \see ListParser
*/
template <class ListPolicy>
- class Parse_List_Container
+ class ListParser_Container
: private ListPolicy
{
public:
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;
// default destructor
// conversion constructors
- Parse_List_Container(parser_type const & list);
- ~Parse_List_Container();
+ ListParser_Container(parser_type const & list);
+ ~ListParser_Container();
///@}
///////////////////////////////////////////////////////////////////////////
///////////////////////////////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
\f
// 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 <boost/iterator/iterator_facade.hpp>
namespace senf {
namespace detail {
- /** \brief Internal: Iterator used by Parse_List
+ /** \brief Internal: Iterator used by ListParser
\internal
*/
template <class ElementParser, class IteratorPolicy>
- class Parse_List_Iterator
- : public boost::iterator_facade< Parse_List_Iterator<ElementParser,IteratorPolicy>,
+ class ListParser_Iterator
+ : public boost::iterator_facade< ListParser_Iterator<ElementParser,IteratorPolicy>,
ElementParser,
boost::forward_traversal_tag,
ElementParser >,
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;
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_;
// 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"
///////////////////////////////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_
//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);
};
\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,
* (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
(senf::DTCPIPv4AddressListParser) //IPv4
(senf::DTCPIPv6AddressListParser) ); //IPv6
- SENF_PARSER_FINALIZE(Parse_DTCPPacket);
+ SENF_PARSER_FINALIZE(DTCPPacketParser);
};
/** \brief DTCP packet
\ref DTCPPacket
\par Fields:
- \ref Parse_DTCPPacket
+ \ref DTCPPacketParser
\ingroup protocolbundle_mpegdvb
*/
{
typedef PacketTypeMixin<DTCPPacketType> mixin;
typedef ConcretePacket<DTCPPacketType> packet;
- typedef Parse_DTCPPacket parser;
+ typedef DTCPPacketParser parser;
using mixin::nextPacketRange;
using mixin::init;
*/
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_(); }
};
\ref GREPacket
\par Fields:
- \ref Parse_GREPacket
+ \ref GREPacketParser
\ingroup protocolbundle_mpegdvb
*/
{
typedef PacketTypeMixin<GREPacketType, EtherTypes> mixin;
typedef ConcretePacket<GREPacketType> packet;
- typedef Parse_GREPacket parser;
+ typedef GREPacketParser parser;
using mixin::nextPacketRange;
using mixin::nextPacketType;
-// $Id$
+// $Id:GREPacket.test.cc 560 2007-12-13 14:39:37Z tho $
//
// Copyright (C) 2007
// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
{
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 );
}
#define prefix_
///////////////////////////////cc.p////////////////////////////////////////
-//prefix_ boost::uint32_t senf::Parse_MPESection::calcCrc()
+//prefix_ boost::uint32_t senf::MPESectionParser::calcCrc()
// const
//{
// return std::for_each(
-// $Id$
+// $Id:MPESection.hh 560 2007-12-13 14:39:37Z tho $
//
// Copyright (C) 2007
// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
namespace senf {
- struct Parse_MPERealTimeParameters : public PacketParserBase
+ struct MPERealTimeParametersParser : public PacketParserBase
{
# include SENF_FIXED_PARSER()
SENF_PARSER_BITFIELD ( frame_boundary, 1, bool );
SENF_PARSER_BITFIELD ( address, 18, unsigned );
- SENF_PARSER_FINALIZE( Parse_MPERealTimeParameters );
+ SENF_PARSER_FINALIZE( MPERealTimeParametersParser );
};
\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 );
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 );
curr_next_indicator() = 1;
}
- Parse_UInt32 crc() const { return parse<Parse_UInt32>( data().size()-4 ); }
+ UInt32Parser crc() const { return parse<UInt32Parser>( data().size()-4 ); }
// typedef boost::crc_optimal<32, 0x04C11DB7, 0xFFFFFFFF, 0, false, false> crc32_t;
// boost::uint32_t calcCrc() const;
\ref MPESection
\par Fields:
- \ref Parse_MPESection
+ \ref MPESectionParser
\ingroup protocolbundle_mpegdvb
*/
{
typedef PacketTypeMixin<MPESectionType> mixin;
typedef ConcretePacket<MPESectionType> packet;
- typedef Parse_MPESection parser;
+ typedef MPESectionParser parser;
using mixin::nextPacketRange;
using mixin::init;
//}
-prefix_ boost::uint32_t senf::Parse_SNDUPacket::calcCrc()
+prefix_ boost::uint32_t senf::SNDUPacketParser::calcCrc()
const
{
return std::for_each(
\see SNDUPacketType
*/
- struct Parse_SNDUPacket : public PacketParserBase
+ struct SNDUPacketParser : public PacketParserBase
{
# include SENF_PARSER()
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
void withoutDestination() /// Set destination absent bit
{ destination_().init<1>(); }
- Parse_UInt32 crc()
- { return parse<Parse_UInt32>( data().size() - 4 ); }
+ UInt32Parser crc()
+ { return parse<UInt32Parser>( data().size() - 4 ); }
boost::uint32_t calcCrc() const;
};
\ref SNDUPacket
\par Fields:
- \ref Parse_SNDUPacket
+ \ref SNDUPacketParser
\ingroup protocolbundle_mpegdvb
*/
{
// typedef PacketTypeMixin<SNDUPacketType, ULEExtHeaderType> mixin;
typedef ConcretePacket<SNDUPacketType> packet;
- typedef Parse_SNDUPacket parser;
+ typedef SNDUPacketParser parser;
// using mixin::nextPacketRange;
// using mixin::nextPacketType;
#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<Parse_UInt8>( 1 ).value();
+ return parse<UInt8Parser>( 1 ).value();
case 3:
- return parse<Parse_UInt16>( 1 ).value();
+ return parse<UInt16Parser>( 1 ).value();
case 4:
- return parse<Parse_UInt24>( 1 ).value();
+ return parse<UInt24Parser>( 1 ).value();
case 5:
- return parse<Parse_UInt32>( 1 ).value();
+ return parse<UInt32Parser>( 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<Parse_TLVPacketLength> safeThis (*this);
+ SafePacketParserWrapper<TLVPacketLengthParser> safeThis (*this);
if (v < 128u) {
if (bytes() != 1) {
resize(1);
safeThis->extended_length_flag() = true;
safeThis->fixed_length_field() = 1;
}
- safeThis->parse<Parse_UInt8>(1) = v;
+ safeThis->parse<UInt8Parser>(1) = v;
return;
}
if (v < 65536u) {
safeThis->extended_length_flag() = true;
safeThis->fixed_length_field() = 2;
}
- safeThis->parse<Parse_UInt16>(1) = v;
+ safeThis->parse<UInt16Parser>(1) = v;
return;
}
if (v < 16777216u) {
safeThis->extended_length_flag() = true;
safeThis->fixed_length_field() = 3;
}
- safeThis->parse<Parse_UInt24>(1) = v;
+ safeThis->parse<UInt24Parser>(1) = v;
return;
}
if (v <= 4294967295u) {
safeThis->extended_length_flag() = true;
safeThis->fixed_length_field() = 4;
}
- safeThis->parse<Parse_UInt32>(1) = v;
+ safeThis->parse<UInt32Parser>(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();
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());
/** \brief xxx
\todo document me
*/
- class Parse_TLVPacketLength
- : public detail::packet::ParseIntOps<Parse_TLVPacketLength, boost::uint32_t>,
+ class TLVPacketLengthParser
+ : public detail::packet::IntParserOps<TLVPacketLengthParser, boost::uint32_t>,
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;
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<Parse_extended_length_flag>( 0 );
+ ExtendedLengthFlagParser extended_length_flag() const {
+ return parse<ExtendedLengthFlagParser>( 0 );
}
- Parse_fixed_length fixed_length_field() const {
- return parse<Parse_fixed_length>( 0 );
+ FixedLengthParser fixed_length_field() const {
+ return parse<FixedLengthParser>( 0 );
}
void resize(size_type size);
\see TLVPacketType
*/
template <class LengthParser>
- 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
{
#ifndef DOXYGEN
typedef ConcretePacket<TLVPacketType<LengthParser> > packet;
- typedef Parse_TLVPacket<LengthParser> parser;
+ typedef TLVPacketParser<LengthParser> parser;
#endif
static optional_range nextPacketRange(packet p);
static size_type initSize();
static void dump(packet p, std::ostream & os);
};
- typedef TLVPacketType<Parse_TLVPacketLength>::packet TLVPacket;
+ typedef TLVPacketType<TLVPacketLengthParser>::packet TLVPacket;
- typedef ConcretePacket<TLVPacketType<Parse_UInt8> > TLVFix8Packet;
- typedef ConcretePacket<TLVPacketType<Parse_UInt16> > TLVFix16Packet;
- typedef ConcretePacket<TLVPacketType<Parse_UInt24> > TLVFix24Packet;
- typedef ConcretePacket<TLVPacketType<Parse_UInt32> > TLVFix32Packet;
+ typedef ConcretePacket<TLVPacketType<UInt8Parser> > TLVFix8Packet;
+ typedef ConcretePacket<TLVPacketType<UInt16Parser> > TLVFix16Packet;
+ typedef ConcretePacket<TLVPacketType<UInt24Parser> > TLVFix24Packet;
+ typedef ConcretePacket<TLVPacketType<UInt32Parser> > TLVFix32Packet;
}
BOOST_AUTO_UNIT_TEST(TLVFixPacket_parse_packet)
{
- test_TLVFixPacket_parsing<TLVFix8Packet>( Parse_UInt8::fixed_bytes);
- test_TLVFixPacket_parsing<TLVFix16Packet>( Parse_UInt16::fixed_bytes);
- test_TLVFixPacket_parsing<TLVFix24Packet>( Parse_UInt24::fixed_bytes);
- test_TLVFixPacket_parsing<TLVFix32Packet>( Parse_UInt32::fixed_bytes);
+ test_TLVFixPacket_parsing<TLVFix8Packet>( UInt8Parser::fixed_bytes);
+ test_TLVFixPacket_parsing<TLVFix16Packet>( UInt16Parser::fixed_bytes);
+ test_TLVFixPacket_parsing<TLVFix24Packet>( UInt24Parser::fixed_bytes);
+ test_TLVFixPacket_parsing<TLVFix32Packet>( UInt32Parser::fixed_bytes);
}
BOOST_AUTO_UNIT_TEST(TLVFixPacket_create_invalid_packet)
{
- test_invalid_TLVFixPacket_creating<TLVFix8Packet> ( Parse_UInt8::max_value);
- test_invalid_TLVFixPacket_creating<TLVFix16Packet>( Parse_UInt16::max_value);
- test_invalid_TLVFixPacket_creating<TLVFix24Packet>( Parse_UInt24::max_value);
- //test_invalid_TLVFixPacket_creating<TLVFix32Packet>( Parse_UInt32::max_value);
+ test_invalid_TLVFixPacket_creating<TLVFix8Packet> ( UInt8Parser::max_value);
+ test_invalid_TLVFixPacket_creating<TLVFix16Packet>( UInt16Parser::max_value);
+ test_invalid_TLVFixPacket_creating<TLVFix24Packet>( UInt24Parser::max_value);
+ //test_invalid_TLVFixPacket_creating<TLVFix32Packet>( UInt32Parser::max_value);
}
-// $Id$
+// $Id:TransportPacket.hh 560 2007-12-13 14:39:37Z tho $
//
// Copyright (C) 2007
// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
\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 );
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_UInt8>( Parse_TransportPacket::fixed_bytes );
+// UInt8Parser payload_pointer() const {
+// return parse<UInt8Parser>( TransportPacketParser::fixed_bytes );
// }
};
<td>transport_packet() {</td> <td></td>
</tr>
<tr>
- <td style="padding-left:2em">\ref Parse_TransportPacket::sync_byte() "sync_byte"</td>
+ <td style="padding-left:2em">\ref TransportPacketParser::sync_byte() "sync_byte"</td>
<td>8</td></tr>
<tr>
- <td style="padding-left:2em">\ref Parse_TransportPacket::transport_error_indicator() "transport_error_indicator"</td>
+ <td style="padding-left:2em">\ref TransportPacketParser::transport_error_indicator() "transport_error_indicator"</td>
<td>1</td></tr>
<tr>
- <td style="padding-left:2em">\ref Parse_TransportPacket::pusi() "payload_uni_start_indicator"</td>
+ <td style="padding-left:2em">\ref TransportPacketParser::pusi() "payload_uni_start_indicator"</td>
<td>1</td></tr>
<tr>
- <td style="padding-left:2em">\ref Parse_TransportPacket::transport_priority() "transport_priority"</td>
+ <td style="padding-left:2em">\ref TransportPacketParser::transport_priority() "transport_priority"</td>
<td>1</td></tr>
<tr>
- <td style="padding-left:2em">\ref Parse_TransportPacket::pid() "PID"</td>
+ <td style="padding-left:2em">\ref TransportPacketParser::pid() "PID"</td>
<td>13</td></tr>
<tr>
- <td style="padding-left:2em">\ref Parse_TransportPacket::transport_scrmbl_ctrl() "transport_scrambling_control"</td>
+ <td style="padding-left:2em">\ref TransportPacketParser::transport_scrmbl_ctrl() "transport_scrambling_control"</td>
<td>2</td></tr>
<tr>
- <td style="padding-left:2em">\ref Parse_TransportPacket::adaptation_field_ctrl() "adaptation_field_control"</td>
+ <td style="padding-left:2em">\ref TransportPacketParser::adaptation_field_ctrl() "adaptation_field_control"</td>
<td>2</td></tr>
<tr>
- <td style="padding-left:2em">\ref Parse_TransportPacket::continuity_counter() "continuity_counter"</td>
+ <td style="padding-left:2em">\ref TransportPacketParser::continuity_counter() "continuity_counter"</td>
<td>4</td></tr>
<tr>
<td>}</td> <td></td></tr>
\ref TransportPacket
\par Fields:
- \ref Parse_TransportPacket
+ \ref TransportPacketParser
\ingroup protocolbundle_mpegdvb
*/
{
typedef PacketTypeMixin<TransportPacketType> mixin;
typedef ConcretePacket<TransportPacketType> packet;
- typedef Parse_TransportPacket parser;
+ typedef TransportPacketParser parser;
using mixin::nextPacketRange;
using mixin::init;
{
# 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);
};
{
PacketParserBase::size_type target_sz (bytes(target));
PacketParserBase::size_type source_sz (bytes(source));
- SafePacketParser<Parser> safe_target (target);
+ SafePacketParserWrapper<Parser> 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)
}
///////////////////////////////////////////////////////////////////////////
-// senf::SafePacketParser<Parser>
+// senf::SafePacketParserWrapper<Parser>
template <class Parser>
-prefix_ senf::SafePacketParser<Parser>::SafePacketParser()
+prefix_ senf::SafePacketParserWrapper<Parser>::SafePacketParserWrapper()
: parser_(), i_()
{}
template <class Parser>
-prefix_ senf::SafePacketParser<Parser>::SafePacketParser(Parser parser)
+prefix_ senf::SafePacketParserWrapper<Parser>::SafePacketParserWrapper(Parser parser)
: parser_(parser), i_(parser)
{}
template <class Parser>
-prefix_ senf::SafePacketParser<Parser> & senf::SafePacketParser<Parser>::operator=(Parser parser)
+prefix_ senf::SafePacketParserWrapper<Parser> & senf::SafePacketParserWrapper<Parser>::operator=(Parser parser)
{
parser_ = parser;
i_ = parser;
}
template <class Parser>
-prefix_ Parser senf::SafePacketParser<Parser>::operator*()
+prefix_ Parser senf::SafePacketParserWrapper<Parser>::operator*()
const
{
BOOST_ASSERT( i_ );
}
template <class Parser>
-prefix_ Parser const * senf::SafePacketParser<Parser>::operator->()
+prefix_ Parser const * senf::SafePacketParserWrapper<Parser>::operator->()
const
{
BOOST_ASSERT( i_ );
}
template <class Parser>
-prefix_ bool senf::SafePacketParser<Parser>::boolean_test()
+prefix_ bool senf::SafePacketParserWrapper<Parser>::boolean_test()
const
{
return i_;
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 <em>\ref parserimpl_value</em> provide the lowest level parsers (e.g. senf::Parse_UInt16 which
+ \li <em>\ref parserimpl_value</em> provide the lowest level parsers (e.g. senf::UInt16Parser which
returns an integer value).
\li <em>\ref parserimpl_collection</em> are parsers which model a collection of sub-elements like
- senf::Parse_List or senf::Parse_Vector.
+ senf::ListParser or senf::VectorParser.
\li <em>\ref parserimpl_composite</em> collect several fields of arbitrary type into a new
parser. Parsers defined using the \ref packetparsermacros fall under this category.
\li <em>\ref parserimpl_packet</em> are used to define a packet type.
\warning Parsers are like iterators: They are invalidated <em>whenever the size of the packet's
data is changed</em>. 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
\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
// 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<Parse_UInt16>( 0 ); }
- senf::Parse_UInt16 size() const { return parse<Parse_UInt16>( 2 ); }
+ senf::UInt16Parser type() const { return parse<UInt16Parser>( 0 ); }
+ senf::UInt16Parser size() const { return parse<UInt16Parser>( 2 ); }
};
\endcode
data_iterator i_;
PacketData * data_;
- template <class Parser> friend class SafePacketParser;
+ template <class Parser> friend class SafePacketParserWrapper;
};
/** \brief Return raw size parsed by the given parser object
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 Parser>
- class SafePacketParser
- : public safe_bool< SafePacketParser<Parser> >
+ class SafePacketParserWrapper
+ : public safe_bool< SafePacketParserWrapper<Parser> >
{
public:
///////////////////////////////////////////////////////////////////////////
// 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
///@}
///////////////////////////////////////////////////////////////////////////
{
# 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);
};
{
# 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);
};
// 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 );
BOOST_AUTO_UNIT_TEST(safePacketParser)
{
senf::PacketInterpreter<VoidPacket>::ptr pi (senf::PacketInterpreter<VoidPacket>::create(6u));
- senf::SafePacketParser<senf::Parse_UInt16> p;
+ senf::SafePacketParserWrapper<senf::UInt16Parser> 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;
namespace packet {
- /** \brief Internal: Tempalte typedef for used smart pointer
+ /** \brief Internal: Template typedef for used smart pointer
\internal
*/
the ethernet packet in <tt>DefaultBundle/EthernetPacket.hh</tt>)
\code
- struct Parse_EthVLan : public PacketParserBase
+ struct EthVLanPacketParser : public PacketParserBase
{
# include SENF_FIXED_PARSER()
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
{
# 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 );
};
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
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
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_t>( xyz_offset );
}
\endcode
/** \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
# ////////////////////////////////////////
# // SENF_PARSER_BITFIELD_I
#
-# define SENF_PARSER_BITFIELD_TYPE_signed(start, bits) senf::Parse_IntField<start, start+bits>
-# define SENF_PARSER_BITFIELD_TYPE_unsigned(start, bits) senf::Parse_UIntField<start, start+bits>
-# define SENF_PARSER_BITFIELD_TYPE_bool(start, bits) senf::Parse_Flag<start>
+# define SENF_PARSER_BITFIELD_TYPE_signed(start, bits) senf::IntFieldParser<start, start+bits>
+# define SENF_PARSER_BITFIELD_TYPE_unsigned(start, bits) senf::UIntFieldParser<start, start+bits>
+# define SENF_PARSER_BITFIELD_TYPE_bool(start, bits) senf::FlagParser<start>
#
# define SENF_PARSER_BITFIELD_I(name, bits, type, ofstype, rwtype, access) \
access: \
{
# 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<senf::Parse_UInt16>(customField_offset);
+ return parse<senf::UInt16Parser>(customField_offset);
}
SENF_PARSER_BITFIELD ( signedBitfield , 4, signed );
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();
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 );
{
# 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<senf::Parse_UInt16>(customField_offset());
+ return parse<senf::UInt16Parser>(customField_offset());
}
SENF_PARSER_BITFIELD ( signedBitfield , 4, signed );
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();
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 );
// 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 <algorithm>
template <class VariantPolicy, SENF_PARSE_VARIANT_TPL_ARGS(class P)>
template <unsigned N>
-prefix_ void senf::Parse_Variant<VariantPolicy,SENF_PARSE_VARIANT_TPL_ARGS(P)>::init()
+prefix_ void senf::VariantParser<VariantPolicy,SENF_PARSE_VARIANT_TPL_ARGS(P)>::init()
{
unsigned oldSize( bytes() );
typedef typename boost::mpl::at<parsers, boost::mpl::int_<N> >::type NewParser;
// 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 <boost/mpl/size.hpp>
///////////////////////////////cti.p///////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
-// senf::Parse_Variant<VariantPolicy,SENF_PARSE_VARIANT_TPL_ARGS(P)>
+// senf::VariantParser<VariantPolicy,SENF_PARSE_VARIANT_TPL_ARGS(P)>
template <class VariantPolicy, SENF_PARSE_VARIANT_TPL_ARGS(class P)>
-prefix_ senf::Parse_Variant<VariantPolicy,SENF_PARSE_VARIANT_TPL_ARGS(P)>::
-Parse_Variant(data_iterator i, state_type s)
+prefix_ senf::VariantParser<VariantPolicy,SENF_PARSE_VARIANT_TPL_ARGS(P)>::
+VariantParser(data_iterator i, state_type s)
: PacketParserBase(i,s)
{}
template <class VariantPolicy, SENF_PARSE_VARIANT_TPL_ARGS(class P)>
-prefix_ senf::Parse_Variant<VariantPolicy,SENF_PARSE_VARIANT_TPL_ARGS(P)>::
-Parse_Variant(VariantPolicy policy, data_iterator i, state_type s)
+prefix_ senf::VariantParser<VariantPolicy,SENF_PARSE_VARIANT_TPL_ARGS(P)>::
+VariantParser(VariantPolicy policy, data_iterator i, state_type s)
: PacketParserBase(i,s), VariantPolicy(policy)
{}
template <class VariantPolicy, SENF_PARSE_VARIANT_TPL_ARGS(class P)>
prefix_ senf::PacketParserBase::size_type
-senf::Parse_Variant<VariantPolicy,SENF_PARSE_VARIANT_TPL_ARGS(P)>::bytes()
+senf::VariantParser<VariantPolicy,SENF_PARSE_VARIANT_TPL_ARGS(P)>::bytes()
const
{
- return detail::VariantBytes< Parse_Variant, boost::mpl::size<parsers>::value - 1 >
+ return detail::VariantBytes< VariantParser, boost::mpl::size<parsers>::value - 1 >
::bytes(*this, variant()) + VariantPolicy::bytes(i(),state());
}
template <class VariantPolicy, SENF_PARSE_VARIANT_TPL_ARGS(class P)>
prefix_ void
-senf::Parse_Variant<VariantPolicy,SENF_PARSE_VARIANT_TPL_ARGS(P)>::init()
+senf::VariantParser<VariantPolicy,SENF_PARSE_VARIANT_TPL_ARGS(P)>::init()
{
VariantPolicy::variant(0,i(),state());
get<0>().init();
}
template <class VariantPolicy, SENF_PARSE_VARIANT_TPL_ARGS(class P)>
-prefix_ unsigned senf::Parse_Variant<VariantPolicy,SENF_PARSE_VARIANT_TPL_ARGS(P)>::variant()
+prefix_ unsigned senf::VariantParser<VariantPolicy,SENF_PARSE_VARIANT_TPL_ARGS(P)>::variant()
const
{
return VariantPolicy::variant(i(),state());
template <class VariantPolicy, SENF_PARSE_VARIANT_TPL_ARGS(class P)>
template <unsigned N>
prefix_ typename boost::mpl::at<
- typename senf::Parse_Variant<VariantPolicy,SENF_PARSE_VARIANT_TPL_ARGS(P)>::parsers,
+ typename senf::VariantParser<VariantPolicy,SENF_PARSE_VARIANT_TPL_ARGS(P)>::parsers,
boost::mpl::int_<N> >::type
-senf::Parse_Variant<VariantPolicy,SENF_PARSE_VARIANT_TPL_ARGS(P)>::get()
+senf::VariantParser<VariantPolicy,SENF_PARSE_VARIANT_TPL_ARGS(P)>::get()
const
{
BOOST_ASSERT( variant() == N );
// 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
#include <boost/preprocessor/seq/for_each.hpp>
#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
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
\ingroup parsecollection
*/
template <class VariantPolicy, SENF_PARSE_VARIANT_TPL_ARGS_DFL(class P)>
- class Parse_Variant
+ class VariantParser
: public PacketParserBase, private VariantPolicy
{
typedef boost::mpl::vector< SENF_PARSE_VARIANT_TPL_ARGS(P) > parsers;
///\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();
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
*/
template <class ChooserType, unsigned Distance, class Translator,
SENF_PARSE_VARIANT_TPL_ARGS_DFL(class P)>
- struct Parse_Variant_Direct
+ struct DirectVariantParser
{
- typedef Parse_Variant< detail::Parse_Variant_Direct<ChooserType, Distance, Translator>,
+ typedef VariantParser< detail::DirectVariantParser<ChooserType, Distance, Translator>,
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
{
# 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>(); }
\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.
\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
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
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:
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
///////////////////////////////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
\f
// 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"
# endif
- /** \brief Internal: Variant Policy used by senf::Parse_Variant_Direct */
+ /** \brief Internal: Variant Policy used by senf::DirectVariantParser */
template <class ChooserType, unsigned Distance, class Translator>
- struct Parse_Variant_Direct
+ struct DirectVariantParser
{
typedef PacketParserBase::data_iterator data_iterator;
typedef PacketParserBase::state_type state_type;
};
/** \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; }
};
# 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 \
// 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"
#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,
{
# 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);
};
}
-BOOST_AUTO_UNIT_TEST(parseVariantMacro)
+BOOST_AUTO_UNIT_TEST(VariantParserMacro)
{
senf::DataPacket p (senf::DataPacket::create(senf::init_bytes<TestParser>::value));
// 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
///////////////////////////////ct.p////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
-// senf::Parse_Vector<ElementParser,Sizer>
+// senf::VectorParser<ElementParser,Sizer>
template <class ElementParser, class Sizer>
-prefix_ void senf::Parse_Vector<ElementParser,Sizer>::init()
+prefix_ void senf::VectorParser<ElementParser,Sizer>::init()
const
{
sizer_.init(i(),state());
}
///////////////////////////////////////////////////////////////////////////
-// senf::Parse_Vector_Container<ElementParser,Sizer>
+// senf::VectorParser_Container<ElementParser,Sizer>
template <class ElementParser, class Sizer>
-prefix_ void senf::Parse_Vector_Container<ElementParser,Sizer>::init()
+prefix_ void senf::VectorParser_Container<ElementParser,Sizer>::init()
const
{
iterator i (begin());
// Mutators
template <class ElementParser, class Sizer>
-prefix_ typename senf::Parse_Vector_Container<ElementParser,Sizer>::iterator
-senf::Parse_Vector_Container<ElementParser,Sizer>::shift(iterator pos, size_type n)
+prefix_ typename senf::VectorParser_Container<ElementParser,Sizer>::iterator
+senf::VectorParser_Container<ElementParser,Sizer>::shift(iterator pos, size_type n)
{
size_type ix (std::distance(data().begin(),pos.raw()));
data().insert(pos.raw(),n*ElementParser::fixed_bytes,0);
template <class ElementParser, class Sizer>
template <class Value>
-prefix_ void senf::Parse_Vector_Container<ElementParser,Sizer>::insert(iterator pos,
+prefix_ void senf::VectorParser_Container<ElementParser,Sizer>::insert(iterator pos,
size_type n,
Value const & t)
{
#ifndef DOXYGEN
template <class ElementParser, class Sizer>
template <class ForwardIterator>
-prefix_ void senf::Parse_Vector_Container<ElementParser,Sizer>::
+prefix_ void senf::VectorParser_Container<ElementParser,Sizer>::
insert(iterator pos, ForwardIterator f, ForwardIterator l,
typename boost::disable_if< boost::is_convertible<ForwardIterator,size_type> >::type *)
{
#else
template <class ElementParser, class Sizer>
template <class ForwardIterator>
-prefix_ void senf::Parse_Vector_Container<ElementParser,Sizer>::
+prefix_ void senf::VectorParser_Container<ElementParser,Sizer>::
insert(iterator pos, ForwardIterator f, ForwardIterator l)
{}
#endif
template <class ElementParser, class Sizer>
-prefix_ void senf::Parse_Vector_Container<ElementParser,Sizer>::resize(size_type n)
+prefix_ void senf::VectorParser_Container<ElementParser,Sizer>::resize(size_type n)
{
if (size()>=n)
erase(boost::next(begin(),n),end());
template <class ElementParser, class Sizer>
template <class Value>
-prefix_ void senf::Parse_Vector_Container<ElementParser,Sizer>::resize(size_type n, Value value)
+prefix_ void senf::VectorParser_Container<ElementParser,Sizer>::resize(size_type n, Value value)
{
if (size()>=n)
erase(boost::next(begin(),n),end());
// 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
///////////////////////////////cti.p///////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
-// senf::Parse_Vector<ElementParser,Sizer>
+// senf::VectorParser<ElementParser,Sizer>
template <class ElementParser, class Sizer>
-prefix_ senf::Parse_Vector<ElementParser,Sizer>::Parse_Vector(data_iterator i, state_type s)
+prefix_ senf::VectorParser<ElementParser,Sizer>::VectorParser(data_iterator i, state_type s)
: PacketParserBase(i,s), sizer_()
{}
template <class ElementParser, class Sizer>
-prefix_ senf::Parse_Vector<ElementParser,Sizer>::Parse_Vector(Sizer sizer, data_iterator i,
+prefix_ senf::VectorParser<ElementParser,Sizer>::VectorParser(Sizer sizer, data_iterator i,
state_type s)
: PacketParserBase(i,s), sizer_(sizer)
{}
template <class ElementParser, class Sizer>
-prefix_ typename senf::Parse_Vector<ElementParser,Sizer>::size_type
-senf::Parse_Vector<ElementParser,Sizer>::bytes()
+prefix_ typename senf::VectorParser<ElementParser,Sizer>::size_type
+senf::VectorParser<ElementParser,Sizer>::bytes()
const
{
return size()*ElementParser::fixed_bytes + sizer_.bytes(i(),state());
// Container interface
template <class ElementParser, class Sizer>
-prefix_ typename senf::Parse_Vector<ElementParser,Sizer>::size_type
-senf::Parse_Vector<ElementParser,Sizer>::size()
+prefix_ typename senf::VectorParser<ElementParser,Sizer>::size_type
+senf::VectorParser<ElementParser,Sizer>::size()
const
{
return sizer_.size(i(),state());
}
template <class ElementParser, class Sizer>
-prefix_ bool senf::Parse_Vector<ElementParser,Sizer>::empty()
+prefix_ bool senf::VectorParser<ElementParser,Sizer>::empty()
const
{
return size()==0;
}
template <class ElementParser, class Sizer>
-prefix_ typename senf::Parse_Vector<ElementParser,Sizer>::iterator
-senf::Parse_Vector<ElementParser,Sizer>::begin()
+prefix_ typename senf::VectorParser<ElementParser,Sizer>::iterator
+senf::VectorParser<ElementParser,Sizer>::begin()
const
{
return iterator(sizer_.begin(i(),state()),state());
}
template <class ElementParser, class Sizer>
-prefix_ typename senf::Parse_Vector<ElementParser,Sizer>::iterator
-senf::Parse_Vector<ElementParser,Sizer>::end()
+prefix_ typename senf::VectorParser<ElementParser,Sizer>::iterator
+senf::VectorParser<ElementParser,Sizer>::end()
const
{
return boost::next(begin(),size());
}
template <class ElementParser, class Sizer>
-prefix_ typename senf::Parse_Vector<ElementParser,Sizer>::value_type
-senf::Parse_Vector<ElementParser,Sizer>::operator[](difference_type i)
+prefix_ typename senf::VectorParser<ElementParser,Sizer>::value_type
+senf::VectorParser<ElementParser,Sizer>::operator[](difference_type i)
const
{
return begin()[i];
}
template <class ElementParser, class Sizer>
-prefix_ typename senf::Parse_Vector<ElementParser,Sizer>::value_type
-senf::Parse_Vector<ElementParser,Sizer>::front()
+prefix_ typename senf::VectorParser<ElementParser,Sizer>::value_type
+senf::VectorParser<ElementParser,Sizer>::front()
const
{
return begin()[0];
}
template <class ElementParser, class Sizer>
-prefix_ typename senf::Parse_Vector<ElementParser,Sizer>::value_type
-senf::Parse_Vector<ElementParser,Sizer>::back()
+prefix_ typename senf::VectorParser<ElementParser,Sizer>::value_type
+senf::VectorParser<ElementParser,Sizer>::back()
const
{
return begin()[size()-1];
template <class ElementParser, class Sizer>
template <class Value>
-prefix_ void senf::Parse_Vector<ElementParser,Sizer>::push_back(Value value, size_type n)
+prefix_ void senf::VectorParser<ElementParser,Sizer>::push_back(Value value, size_type n)
const
{
container c (*this);
}
template <class ElementParser, class Sizer>
-prefix_ void senf::Parse_Vector<ElementParser,Sizer>::push_back_space(size_type n)
+prefix_ void senf::VectorParser<ElementParser,Sizer>::push_back_space(size_type n)
const
{
container c (*this);
template <class ElementParser, class Sizer>
template <class Value>
-prefix_ void senf::Parse_Vector<ElementParser,Sizer>::push_front(Value value, size_type n)
+prefix_ void senf::VectorParser<ElementParser,Sizer>::push_front(Value value, size_type n)
const
{
container c (*this);
}
template <class ElementParser, class Sizer>
-prefix_ void senf::Parse_Vector<ElementParser,Sizer>::push_front_space(size_type n)
+prefix_ void senf::VectorParser<ElementParser,Sizer>::push_front_space(size_type n)
const
{
container c (*this);
}
template <class ElementParser, class Sizer>
-prefix_ void senf::Parse_Vector<ElementParser,Sizer>::resize(size_type n)
+prefix_ void senf::VectorParser<ElementParser,Sizer>::resize(size_type n)
const
{
container c (*this);
template <class ElementParser, class Sizer>
template <class Value>
-prefix_ void senf::Parse_Vector<ElementParser,Sizer>::resize(size_type n, Value value)
+prefix_ void senf::VectorParser<ElementParser,Sizer>::resize(size_type n, Value value)
const
{
container c (*this);
// senf::SimpleSizeParser<SizeParser,offset>
template <class SizeParser, unsigned Distance>
-prefix_ typename senf::detail::Parse_VectorN_Sizer<SizeParser,Distance>::size_type
-senf::detail::Parse_VectorN_Sizer<SizeParser,Distance>::size(iterator i, state_type s)
+prefix_ typename senf::detail::VectorNParser_Sizer<SizeParser,Distance>::size_type
+senf::detail::VectorNParser_Sizer<SizeParser,Distance>::size(iterator i, state_type s)
const
{
return SizeParser(boost::prior(i, Distance), s).value();
}
template <class SizeParser, unsigned Distance>
-prefix_ void senf::detail::Parse_VectorN_Sizer<SizeParser,Distance>::size(iterator i,
+prefix_ void senf::detail::VectorNParser_Sizer<SizeParser,Distance>::size(iterator i,
state_type s,
size_type v)
const
}
template <class SizeParser, unsigned Distance>
-prefix_ typename senf::detail::Parse_VectorN_Sizer<SizeParser,Distance>::iterator
-senf::detail::Parse_VectorN_Sizer<SizeParser,Distance>::begin(iterator i, state_type s)
+prefix_ typename senf::detail::VectorNParser_Sizer<SizeParser,Distance>::iterator
+senf::detail::VectorNParser_Sizer<SizeParser,Distance>::begin(iterator i, state_type s)
const
{
return i;
}
template <class SizeParser, unsigned Distance>
-prefix_ typename senf::detail::Parse_VectorN_Sizer<SizeParser,Distance>::size_type
-senf::detail::Parse_VectorN_Sizer<SizeParser,Distance>::bytes(iterator i, state_type s)
+prefix_ typename senf::detail::VectorNParser_Sizer<SizeParser,Distance>::size_type
+senf::detail::VectorNParser_Sizer<SizeParser,Distance>::bytes(iterator i, state_type s)
const
{
return 0;
}
template <class SizeParser, unsigned Distance>
-prefix_ void senf::detail::Parse_VectorN_Sizer<SizeParser,Distance>::init(iterator i,
+prefix_ void senf::detail::VectorNParser_Sizer<SizeParser,Distance>::init(iterator i,
state_type s)
const
{}
///////////////////////////////////////////////////////////////////////////
-// senf::Parse_Vector_wrapper<Parser,SizeParser,Container>
+// senf::VectorParser_wrapper<Parser,SizeParser,Container>
// structors and default members
// instance. However, data() only depends on state_ which is initialized before the call. YOU MUST
// NOT CHANGE THE ORDERING OF THE DATA MEMBERS
template <class ElementParser, class Sizer>
-prefix_ senf::Parse_Vector_Container<ElementParser,Sizer>::
-Parse_Vector_Container(parser_type const & vector)
+prefix_ senf::VectorParser_Container<ElementParser,Sizer>::
+VectorParser_Container(parser_type const & vector)
: sizer_ (vector.sizer_), state_ (vector.state()),
i_ (std::distance(data().begin(),vector.i()))
{}
// accessors
template <class ElementParser, class Sizer>
-prefix_ typename senf::Parse_Vector_Container<ElementParser,Sizer>::size_type
-senf::Parse_Vector_Container<ElementParser,Sizer>::size()
+prefix_ typename senf::VectorParser_Container<ElementParser,Sizer>::size_type
+senf::VectorParser_Container<ElementParser,Sizer>::size()
const
{
return sizer_.size(i(),state());
}
template <class ElementParser, class Sizer>
-prefix_ bool senf::Parse_Vector_Container<ElementParser,Sizer>::empty()
+prefix_ bool senf::VectorParser_Container<ElementParser,Sizer>::empty()
const
{
return size() == 0;
}
template <class ElementParser, class Sizer>
-prefix_ typename senf::Parse_Vector_Container<ElementParser,Sizer>::iterator
-senf::Parse_Vector_Container<ElementParser,Sizer>::begin()
+prefix_ typename senf::VectorParser_Container<ElementParser,Sizer>::iterator
+senf::VectorParser_Container<ElementParser,Sizer>::begin()
const
{
return iterator(sizer_.begin(i(),state()),state());
}
template <class ElementParser, class Sizer>
-prefix_ typename senf::Parse_Vector_Container<ElementParser,Sizer>::iterator
-senf::Parse_Vector_Container<ElementParser,Sizer>::end()
+prefix_ typename senf::VectorParser_Container<ElementParser,Sizer>::iterator
+senf::VectorParser_Container<ElementParser,Sizer>::end()
const
{
return boost::next(begin(),size());
}
template <class ElementParser, class Sizer>
-prefix_ typename senf::Parse_Vector_Container<ElementParser,Sizer>::value_type
-senf::Parse_Vector_Container<ElementParser,Sizer>::operator[](difference_type i)
+prefix_ typename senf::VectorParser_Container<ElementParser,Sizer>::value_type
+senf::VectorParser_Container<ElementParser,Sizer>::operator[](difference_type i)
const
{
return begin()[i];
}
template <class ElementParser, class Sizer>
-prefix_ typename senf::Parse_Vector_Container<ElementParser,Sizer>::value_type
-senf::Parse_Vector_Container<ElementParser,Sizer>::front()
+prefix_ typename senf::VectorParser_Container<ElementParser,Sizer>::value_type
+senf::VectorParser_Container<ElementParser,Sizer>::front()
const
{
return begin()[0];
}
template <class ElementParser, class Sizer>
-prefix_ typename senf::Parse_Vector_Container<ElementParser,Sizer>::value_type
-senf::Parse_Vector_Container<ElementParser,Sizer>::back()
+prefix_ typename senf::VectorParser_Container<ElementParser,Sizer>::value_type
+senf::VectorParser_Container<ElementParser,Sizer>::back()
const
{
return begin()[size()-1];
template <class ElementParser, class Sizer>
template <class Value>
-prefix_ void senf::Parse_Vector_Container<ElementParser,Sizer>::insert(iterator pos,
+prefix_ void senf::VectorParser_Container<ElementParser,Sizer>::insert(iterator pos,
Value const & t)
{
*shift(pos) << t;
}
template <class ElementParser, class Sizer>
-prefix_ void senf::Parse_Vector_Container<ElementParser,Sizer>::erase(iterator pos, size_type n)
+prefix_ void senf::VectorParser_Container<ElementParser,Sizer>::erase(iterator pos, size_type n)
{
data().erase(pos.raw(),boost::next(pos.raw(),n*ElementParser::fixed_bytes));
setSize(size()-n);
}
template <class ElementParser, class Sizer>
-prefix_ void senf::Parse_Vector_Container<ElementParser,Sizer>::erase(iterator f, iterator l)
+prefix_ void senf::VectorParser_Container<ElementParser,Sizer>::erase(iterator f, iterator l)
{
erase(f,std::distance(f,l));
}
template <class ElementParser, class Sizer>
-prefix_ void senf::Parse_Vector_Container<ElementParser,Sizer>::clear()
+prefix_ void senf::VectorParser_Container<ElementParser,Sizer>::clear()
{
erase(begin(),end());
}
template <class ElementParser, class Sizer>
template <class Value>
-prefix_ void senf::Parse_Vector_Container<ElementParser,Sizer>::push_back(Value value,
+prefix_ void senf::VectorParser_Container<ElementParser,Sizer>::push_back(Value value,
size_type n)
{
insert(end(),n,value);
}
template <class ElementParser, class Sizer>
-prefix_ void senf::Parse_Vector_Container<ElementParser,Sizer>::push_back_space(size_type n)
+prefix_ void senf::VectorParser_Container<ElementParser,Sizer>::push_back_space(size_type n)
{
shift(end(),n);
}
template <class ElementParser, class Sizer>
template <class Value>
-prefix_ void senf::Parse_Vector_Container<ElementParser,Sizer>::push_front(Value value,
+prefix_ void senf::VectorParser_Container<ElementParser,Sizer>::push_front(Value value,
size_type n)
{
insert(begin(),n,value);
}
template <class ElementParser, class Sizer>
-prefix_ void senf::Parse_Vector_Container<ElementParser,Sizer>::push_front_space(size_type n)
+prefix_ void senf::VectorParser_Container<ElementParser,Sizer>::push_front_space(size_type n)
{
shift(begin(),n);
}
// Parser interface
template <class ElementParser, class Sizer>
-prefix_ typename senf::Parse_Vector_Container<ElementParser,Sizer>::parser_type
-senf::Parse_Vector_Container<ElementParser,Sizer>::parser()
+prefix_ typename senf::VectorParser_Container<ElementParser,Sizer>::parser_type
+senf::VectorParser_Container<ElementParser,Sizer>::parser()
const
{
return parser_type(i(),state());
}
template <class ElementParser, class Sizer>
-prefix_ typename senf::Parse_Vector_Container<ElementParser,Sizer>::data_iterator
-senf::Parse_Vector_Container<ElementParser,Sizer>::i()
+prefix_ typename senf::VectorParser_Container<ElementParser,Sizer>::data_iterator
+senf::VectorParser_Container<ElementParser,Sizer>::i()
const
{
return boost::next(data().begin(),i_);
}
template <class ElementParser, class Sizer>
-prefix_ typename senf::Parse_Vector_Container<ElementParser,Sizer>::state_type
-senf::Parse_Vector_Container<ElementParser,Sizer>::state()
+prefix_ typename senf::VectorParser_Container<ElementParser,Sizer>::state_type
+senf::VectorParser_Container<ElementParser,Sizer>::state()
const
{
return state_;
template <class ElementParser, class Sizer>
prefix_ senf::PacketData &
-senf::Parse_Vector_Container<ElementParser,Sizer>::data()
+senf::VectorParser_Container<ElementParser,Sizer>::data()
const
{
return *state_;
}
template <class ElementParser, class Sizer>
-prefix_ typename senf::Parse_Vector_Container<ElementParser,Sizer>::size_type
-senf::Parse_Vector_Container<ElementParser,Sizer>::bytes()
+prefix_ typename senf::VectorParser_Container<ElementParser,Sizer>::size_type
+senf::VectorParser_Container<ElementParser,Sizer>::bytes()
const
{
return size()*ElementParser::fixed_bytes + sizer_.bytes(i(),state());
// private members
template <class ElementParser, class Sizer>
-prefix_ void senf::Parse_Vector_Container<ElementParser,Sizer>::setSize(size_type value)
+prefix_ void senf::VectorParser_Container<ElementParser,Sizer>::setSize(size_type value)
{
sizer_.size(i(),state(),value);
}
// 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 <boost/iterator/iterator_facade.hpp>
#include <boost/range.hpp>
#include <boost/type_traits.hpp>
#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 ElementParser, class Sizer> class Parse_Vector_Container;
+ template <class ElementParser, class Sizer> class VectorParser_Container;
/** \brief Collection of fixed-size elements
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.
\ingroup parsecollection
*/
template <class ElementParser, class Sizer>
- 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. */
// Container interface
typedef ElementParser value_type;
- typedef detail::Parse_Array_iterator<value_type> iterator;
+ typedef detail::ArrayParser_iterator<value_type> iterator;
typedef iterator const_iterator;
- typedef Parse_Vector_Container<ElementParser,Sizer> container;
+ typedef VectorParser_Container<ElementParser,Sizer> container;
size_type size() const;
bool empty() const;
private:
Sizer sizer_;
- friend class Parse_Vector_Container<ElementParser,Sizer>;
+ friend class VectorParser_Container<ElementParser,Sizer>;
};
/** \brief Vector with prefix sizing
\code
// Define MyVector as a vector of 16bit unsigned elements with a directly preceding
// 8bit unsigned size field
- typedef senf::Parse_VectorN<senf::Parse_UInt16, senf::Parse_UInt8>::parser MyVector;
+ typedef senf::VectorNParser<senf::UInt16Parser, senf::UInt8Parser>::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 <class ElementParser, class SizeParser, unsigned Distance>
- struct Parse_VectorN
+ struct VectorNParser
{
- typedef Parse_Vector< ElementParser,
- detail::Parse_VectorN_Sizer<SizeParser, Distance> > parser;
+ typedef VectorParser< ElementParser,
+ detail::VectorNParser_Sizer<SizeParser, Distance> > 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
# 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
# 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
c.insert(c.begin(), ... );
\endcode
- \see Parse_Vector
+ \see VectorParser
*/
template <class ElementParser, class Sizer>
- class Parse_Vector_Container
+ class VectorParser_Container
{
public:
///////////////////////////////////////////////////////////////////////////
// Types
- typedef Parse_Vector<ElementParser,Sizer> parser_type;
+ typedef VectorParser<ElementParser,Sizer> 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<value_type> iterator;
+ typedef detail::ArrayParser_iterator<value_type> iterator;
typedef iterator const_iterator;
typedef PacketParserBase::state_type state_type;
// default destructor
// conversion constructors
- Parse_Vector_Container(parser_type const & vector);
+ VectorParser_Container(parser_type const & vector);
///@}
///////////////////////////////////////////////////////////////////////////
///////////////////////////////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
\f
// 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
\internal
- This is the sizer policy used by Parse_VectorN
+ This is the sizer policy used by VectorNParser
*/
template <class SizeParser, unsigned Distance>
- struct Parse_VectorN_Sizer
+ struct VectorNParser_Sizer
{
typedef PacketParserBase::size_type size_type;
typedef PacketParserBase::data_iterator iterator;
};
# 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) \
// Unit tests
-//#include "ParseVec.test.hh"
-//#include "ParseVec.test.ih"
+//#include "VectorParser.test.hh"
+//#include "VectorParser.test.ih"
// Custom includes
#include "Packets.hh"
{};
}
-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<VoidPacket>::create(data));
- typedef senf::Parse_Vector<
- senf::Parse_UInt16,
- senf::detail::Parse_VectorN_Sizer<senf::Parse_UInt8, 1u>
- > Parse_UInt16Vec;
+ typedef senf::VectorParser<
+ senf::UInt16Parser,
+ senf::detail::VectorNParser_Sizer<senf::UInt8Parser, 1u>
+ > 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 );
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
// 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 );
}
}
-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<VoidPacket>::create(data));
- typedef senf::Parse_Vector<
- senf::Parse_UInt16,
- senf::detail::Parse_VectorN_Sizer<senf::Parse_UInt8, 1u>
- > 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<senf::UInt8Parser, 1u>
+ > 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 );
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 );
{
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);
}