From: Mikko Rasa Date: Thu, 4 Aug 2011 22:44:12 +0000 (+0300) Subject: Use maputils X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;ds=sidebyside;h=f9cc7ff2e1e5af865220e9fbe16673619ecb78bd;hp=12b93b4f1655bf9c26f73e67cf78b86eeb1eaa97;p=libs%2Fnet.git Use maputils --- diff --git a/source/protocol.cpp b/source/protocol.cpp index 147077c..3e7d479 100644 --- a/source/protocol.cpp +++ b/source/protocol.cpp @@ -1,5 +1,6 @@ #include #include +#include #include #include "protocol.h" @@ -123,18 +124,12 @@ void Protocol::add_packet(PacketDefBase &pdef) const Protocol::PacketDefBase &Protocol::get_packet_by_class(unsigned id) const { - PacketMap::const_iterator i = packet_class_defs.find(id); - if(i==packet_class_defs.end()) - throw KeyError("Unknown packet class", lexical_cast(id)); - return *i->second; + return *get_item(packet_class_defs, id); } const Protocol::PacketDefBase &Protocol::get_packet_by_id(unsigned id) const { - PacketMap::const_iterator i = packet_id_defs.find(id); - if(i==packet_id_defs.end()) - throw KeyError("Unknown packet ID", lexical_cast(id)); - return *i->second; + return *get_item(packet_id_defs, id); } unsigned Protocol::disassemble(ReceiverBase &rcv, const char *data, unsigned size) const