X-Git-Url: http://git.tdb.fi/?p=libs%2Fnet.git;a=blobdiff_plain;f=source%2Fprotocol.cpp;h=3e7d479b52407f4bca47f3057fdeef7ed507fd96;hp=147077cc1253c3c60e7c9ab049951b0e3223445b;hb=f9cc7ff2e1e5af865220e9fbe16673619ecb78bd;hpb=12b93b4f1655bf9c26f73e67cf78b86eeb1eaa97 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