X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=senf%2FPackets%2FGenericTLV.ct;h=fb59a100049c13e91d17ccbd55887e8133fa0797;hb=b490ccf2b17ccb29681e60b3e35aa5a949df3a10;hp=44b748d9c894322cae199cb20d7f11692a888397;hpb=9ffdaae4804503c4f36a53747c852a87ee626b9e;p=senf.git diff --git a/senf/Packets/GenericTLV.ct b/senf/Packets/GenericTLV.ct index 44b748d..fb59a10 100644 --- a/senf/Packets/GenericTLV.ct +++ b/senf/Packets/GenericTLV.ct @@ -52,6 +52,22 @@ prefix_ Parser senf::GenericTLVParserBase::init() } template +prefix_ void senf::GenericTLVParserBase::dump(std::ostream & os) + const +{ + if (Base::Registry::instance().isRegistered( *this)) { + Base::Registry::instance().dump( *this, os); + } else { + boost::io::ios_all_saver ias(os); + os << " GenericTLVParser<" << prettyName(typeid(Base)) << ">\n" + << " type: " << senf::format::dumpint(this->type()) << "\n" + << " length: " << senf::format::dumpint(this->length()) << "\n" + << " value:\n"; + hexdump(value().begin(), value().end(), os); + } +} + +template prefix_ senf::PacketInterpreterBase::range senf::GenericTLVParserBase::value() const { @@ -74,32 +90,35 @@ prefix_ void senf::GenericTLVParserBase::value_(ForwardReadableRange const /////////////////////////////////////////////////////////////////////////// -// senf::GenericTLVParserRegistry +// senf::GenericTLVParserRegistry -template +template template -prefix_ void senf::GenericTLVParserRegistry::registerParser() +prefix_ void senf::GenericTLVParserRegistry::registerParser() { - typename BaseParser::type_t::value_type key (Parser::typeId+0); + Keytype key (Parser::typeId+0); typename Map::iterator i (map_.find( key )); if (i == map_.end() ) map_.insert(key, new detail::GenericTLVParserRegistry_Entry() ); } -template -prefix_ void senf::GenericTLVParserRegistry::dump( +template +prefix_ void senf::GenericTLVParserRegistry::dump( GenericTLVParserBase const & parser, std::ostream & os) + const { - typename Map::iterator i (map_.find( parser.type())); - if (i == map_.end()) { - boost::io::ios_all_saver ias(os); - os << " GenericTLVParser<" << prettyName(typeid(BaseParser)) << ">\n" - << " type: " << senf::format::dumpint(parser.type()) << "\n" - << " length: " << senf::format::dumpint(parser.length()) << "\n" - << " value:\n"; - hexdump(parser.value().begin(), parser.value().end(), os); - } - else + typename Map::const_iterator i (map_.find( parser.type())); + if (i != map_.end()) + (i->second)->dump(parser, os); +} + +template +prefix_ void senf::GenericTLVParserRegistry::dump( + GenericTLVParserBase const & parser, Keytype const & key, std::ostream & os) + const +{ + typename Map::const_iterator i (map_.find( key)); + if (i != map_.end()) (i->second)->dump(parser, os); }