#include <cstring>
#include <string>
+#include <msp/core/maputils.h>
#include <msp/strings/lexicalcast.h>
#include "protocol.h"
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