From f9cc7ff2e1e5af865220e9fbe16673619ecb78bd Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Fri, 5 Aug 2011 01:44:12 +0300 Subject: [PATCH] Use maputils --- source/protocol.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) 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 -- 2.43.0