X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=senf%2FPackets%2FGenericTLV.ct;h=e405ce70b4461d1cd4eea4ab539235eed97a2430;hb=a1c37005ec4c281f6a76c07070a943cd1e36b6af;hp=fb59a100049c13e91d17ccbd55887e8133fa0797;hpb=bea7cfcf3d02688ece159d76890acfe2d0051d71;p=senf.git diff --git a/senf/Packets/GenericTLV.ct b/senf/Packets/GenericTLV.ct index fb59a10..e405ce7 100644 --- a/senf/Packets/GenericTLV.ct +++ b/senf/Packets/GenericTLV.ct @@ -40,7 +40,7 @@ template template prefix_ Parser senf::GenericTLVParserBase::init() -{ +{ senf::PacketParserBase::size_type oldSize (bytes() ); senf::PacketParserBase::size_type newParserSize ( senf::init_bytes::value ); this->resize( oldSize, newParserSize); @@ -53,7 +53,7 @@ prefix_ Parser senf::GenericTLVParserBase::init() template prefix_ void senf::GenericTLVParserBase::dump(std::ostream & os) - const + const { if (Base::Registry::instance().isRegistered( *this)) { Base::Registry::instance().dump( *this, os); @@ -68,8 +68,8 @@ prefix_ void senf::GenericTLVParserBase::dump(std::ostream & os) } template -prefix_ senf::PacketInterpreterBase::range senf::GenericTLVParserBase::value() - const +prefix_ senf::PacketInterpreterBase::range senf::GenericTLVParserBase::value() + const { senf::PacketData::iterator begin ( boost::next(this->i(), senf::bytes( self())) ); return PacketInterpreterBase::range(begin, boost::next( begin, this->length()) ); @@ -104,7 +104,7 @@ prefix_ void senf::GenericTLVParserRegistry::registerParser( template prefix_ void senf::GenericTLVParserRegistry::dump( - GenericTLVParserBase const & parser, std::ostream & os) + GenericTLVParser const & parser, std::ostream & os) const { typename Map::const_iterator i (map_.find( parser.type())); @@ -114,7 +114,7 @@ prefix_ void senf::GenericTLVParserRegistry::dump( template prefix_ void senf::GenericTLVParserRegistry::dump( - GenericTLVParserBase const & parser, Keytype const & key, std::ostream & os) + GenericTLVParser const & parser, Keytype const & key, std::ostream & os) const { typename Map::const_iterator i (map_.find( key)); @@ -122,6 +122,32 @@ prefix_ void senf::GenericTLVParserRegistry::dump( (i->second)->dump(parser, os); } +template +prefix_ senf::PacketParserBase::size_type senf::GenericTLVParserRegistry::bytes( + GenericTLVParser const & parser) + const +{ + typename Map::const_iterator i (map_.find( parser.type())); + if (i != map_.end()) + return (i->second)->bytes(parser); + else + throw TLVParserNotRegisteredException(); +} + +template +prefix_ senf::PacketParserBase::size_type senf::GenericTLVParserRegistry::bytes( + GenericTLVParser const & parser, Keytype const & key) + const +{ + typename Map::const_iterator i (map_.find( key)); + if (i != map_.end()) + return (i->second)->bytes(parser); + else + throw TLVParserNotRegisteredException(); +} + + + ///////////////////////////////ct.e//////////////////////////////////////// #undef prefix_