prefix_ bool senf::Packet::is()
const
{
- return valid() && ptr()->is<typename OtherPacket::type>();
+ // ensure that the template class is included in the corresponding object file when linking:
+ { static typename PacketInterpreter<typename OtherPacket::type>::factory_t _ (
+ PacketInterpreter<typename OtherPacket::type>::factory()); (void) _;}
+ return valid() && typeId() == typeIdValue<OtherPacket>();
}
template <class OtherPacket>
// Interpreter chain access
template <class Type>
-prefix_ bool senf::PacketInterpreterBase::is()
-{
- // ensure that the template argument is included in the corresponding object file when linking:
- { static typename PacketInterpreter<Type>::factory_t _ (PacketInterpreter<Type>::factory()); (void) _;}
- return dynamic_cast< PacketInterpreter<Type>* >(this);
-}
-
-template <class Type>
prefix_ typename senf::PacketInterpreter<Type>::ptr senf::PacketInterpreterBase::as()
{
// ensure that the template argument is included in the corresponding object file when linking:
template <class Type> typename PacketInterpreter<Type>::ptr parseNextAs();
ptr parseNextAs(factory_t factory, PacketInterpreterBase::optional_range const & range);
- template <class Type> bool is();
template <class Type> typename PacketInterpreter<Type>::ptr as();
ptr append(ptr packet);
BOOST_CHECK( pi2 == pi3->prev() );
BOOST_CHECK( pi1 == pi2->prev() );
BOOST_CHECK( ! pi1->prev() );
- BOOST_CHECK( pi2->is<VoidPacket>() );
BOOST_CHECK( pi2->as<VoidPacket>() == pi2 );
BOOST_CHECK( pi2->parseNextAs(senf::PacketInterpreter<VoidPacket>::factory(), pi2->nextPacketRange()) );
BOOST_CHECK( pi2->typeId() == pi1->typeId() );
BOOST_CHECK( ! senf::PacketInterpreterBase::no_factory() );
BOOST_REQUIRE( factory );
- BOOST_CHECK( factory->create()->is<OtherPacket>() );
BOOST_CHECK_EQUAL( factory->create()->data().size(), 8u );
BOOST_CHECK_EQUAL( factory->create(senf::noinit)->data().size(), 0u );
BOOST_CHECK_EQUAL( factory->create(size_type(12u))->data().size(), 12u );
(senf::PacketInterpreter<VoidPacket>::create());
BOOST_CHECK_EQUAL( p->data().size(), 0u);
- BOOST_CHECK( factory->createAfter(p)->is<OtherPacket>() );
BOOST_REQUIRE( p->next() );
BOOST_CHECK( ! p->next()->next() );
(senf::PacketInterpreter<VoidPacket>::create(size_type(12u)));
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 );
}