#define HH_SENF_PPI_Joins_ 1
// Custom includes
-#include <boost/ptr_container/ptr_vector.hpp>
-#include "predecl.hh"
#include "Connectors.hh"
#include "Module.hh"
#include "MultiConnectorMixin.hh"
}
prefix_ senf::RadiotapPacketType::optional_range
-senf::RadiotapPacketType::nextPacketRange(packet p)
+senf::RadiotapPacketType::nextPacketRange(packet const & p)
{
parser rtParser (p.parser());
size_type h (senf::bytes(rtParser));
static void init(packet p);
static void dump(packet p, std::ostream & os);
static factory_t nextPacketType(packet p);
- static optional_range nextPacketRange(packet p);
+ static optional_range nextPacketRange(packet const & p);
};
typedef ConcretePacket<RadiotapPacketType> RadiotapPacket;
#define prefix_
//-/////////////////////////////////////////////////////////////////////////////////////////////////
-prefix_ senf::Packet senf::Packet::getNext()
+prefix_ senf::Packet senf::Packet::getNext(PacketInterpreterBase::optional_range const & range)
const
{
factory_t factory (ptr()->nextPacketType());
if (factory)
- return parseNextAs(factory);
+ return parseNextAs(factory, range);
else
return parseNextAs<DataPacket>();
}
PacketInterpreterBase::ptr p (ptr()->next());
if (p) return Packet(p);
PacketInterpreterBase::optional_range r (ptr()->nextPacketRange());
- return (r && ! r->empty()) ? getNext() : Packet();
+ return (r && ! r->empty()) ? getNext(r) : Packet();
}
prefix_ senf::Packet senf::Packet::next()
prefix_ senf::Packet senf::Packet::parseNextAs(factory_t factory)
const
{
- return Packet(ptr()->parseNextAs(factory));
+ return Packet(ptr()->parseNextAs(factory, ptr()->nextPacketRange()));
+}
+
+prefix_ senf::Packet senf::Packet::parseNextAs(factory_t factory, PacketInterpreterBase::optional_range const & range)
+ const
+{
+ return Packet(ptr()->parseNextAs(factory, range));
}
prefix_ senf::Packet senf::Packet::append(Packet const & packet)
return ParserProxy(parser());
}
+template <class PacketType>
+prefix_ senf::Packet senf::ConcretePacket<PacketType>::next(NoThrow_t)
+ const
+{
+ PacketInterpreterBase::ptr p (Packet::ptr()->next());
+ if (p) return Packet(p);
+ PacketInterpreterBase::optional_range r (type::nextPacketRange(*this));
+ return (r && ! r->empty()) ? getNext(r) : Packet();
+}
+
// private members
template <class PacketType>
PacketInterpreterBase::ptr const & ptr() const;
- private:
- Packet getNext() const;
+ Packet parseNextAs(factory_t factory, PacketInterpreterBase::optional_range const & range) const;
+ Packet getNext(PacketInterpreterBase::optional_range const & range) const;
Packet getLast() const;
+ private:
PacketInterpreterBase::ptr packet_;
template <class PacketType>
itself, only it's members.
\see \ref packetparser for the %parser interface */
- protected:
+#ifndef DOXYGEN
+ using Packet::next;
+
+ Packet next(NoThrow_t) const;
+#endif
private:
typedef PacketInterpreter<PacketType> interpreter;
}
prefix_ senf::PacketInterpreterBase::ptr
-senf::PacketInterpreterBase::parseNextAs(factory_t factory)
+senf::PacketInterpreterBase::parseNextAs(factory_t factory, PacketInterpreterBase::optional_range const & range)
{
- return factory->parseNext(ptr(this));
+ return factory->parseNext(ptr(this), range);
}
// Data access
template <class PacketType>
prefix_ typename senf::PacketInterpreterBase::ptr
-senf::PacketInterpreter<PacketType>::FactoryImpl::parseNext(PacketInterpreterBase::ptr packet)
+senf::PacketInterpreter<PacketType>::FactoryImpl::parseNext(PacketInterpreterBase::ptr packet, PacketInterpreterBase::optional_range const & range)
const
{
- optional_range r (packet->nextPacketRange());
- if (!r)
+ if (!range)
throw InvalidPacketChainException();
if (packet->next())
packet->impl().truncateInterpreters(packet->next().get());
- return senf::PacketInterpreter<PacketType>::create(&packet->impl(),r->begin(),r->end(),Append);
+ return senf::PacketInterpreter<PacketType>::create(&packet->impl(),range->begin(),range->end(),Append);
}
template <class PacketType>
typedef senf::detail::packet::byte byte;
typedef boost::iterator_range<iterator> range;
- typedef boost::optional< boost::iterator_range<iterator> > optional_range;
+ typedef boost::optional<range> optional_range;
typedef optional_range no_range;
enum Append_t { Append };
// Parse next packet in chain
- virtual ptr parseNext(ptr packet) const = 0;
+ virtual ptr parseNext(ptr packet, PacketInterpreterBase::optional_range const & range) const = 0;
};
typedef Factory const * factory_t;
ptr last();
template <class Type> typename PacketInterpreter<Type>::ptr parseNextAs();
- ptr parseNextAs(factory_t factory);
+ ptr parseNextAs(factory_t factory, PacketInterpreterBase::optional_range const & range);
template <class Type> bool is();
template <class Type> typename PacketInterpreter<Type>::ptr as();
// Parse next packet in chain
- virtual PacketInterpreterBase::ptr parseNext(PacketInterpreterBase::ptr packet)
+ virtual PacketInterpreterBase::ptr parseNext(PacketInterpreterBase::ptr packet, PacketInterpreterBase::optional_range const & range)
const;
};
BOOST_CHECK( ! pi1->prev() );
BOOST_CHECK( pi2->is<VoidPacket>() );
BOOST_CHECK( pi2->as<VoidPacket>() == pi2 );
- BOOST_CHECK( pi2->parseNextAs(senf::PacketInterpreter<VoidPacket>::factory()) );
+ BOOST_CHECK( pi2->parseNextAs(senf::PacketInterpreter<VoidPacket>::factory(), pi2->nextPacketRange()) );
BOOST_CHECK( pi2->typeId() == pi1->typeId() );
pi1->data().insert(pi1->data().begin(),2,0x01u);
senf::PacketInterpreter<VoidPacket>::ptr p
(senf::PacketInterpreter<VoidPacket>::create(size_type(12u)));
- senf::PacketInterpreterBase::ptr p2 (p->parseNextAs(factory));
+ senf::PacketInterpreterBase::ptr p2 (p->parseNextAs(factory, p->nextPacketRange()));
BOOST_CHECK( p2->is<OtherPacket>() );
BOOST_CHECK( ! p2->is<VoidPacket>() );
BOOST_CHECK_EQUAL( unsigned(boost::size(*p2->nextPacketRange())), 4u );