fipa_acl  1.4
message_parser.cpp
Go to the documentation of this file.
3 #include "xml_message_parser.h"
4 
5 #include <boost/assign/list_of.hpp>
6 
7 
8 namespace fipa {
9 namespace acl {
10 
11 std::map<representation::Type, MessageParserImplementationPtr > MessageParser::msParsers = boost::assign::map_list_of
12  (representation::BITEFFICIENT, boost::shared_ptr<MessageParserImplementation>(new BitefficientMessageParser()) )
13  (representation::XML, boost::shared_ptr<MessageParserImplementation>(new XMLMessageParser()))
14  (representation::STRING_REP, boost::shared_ptr<MessageParserImplementation>(new StringMessageParser()) );
15 
16 
17 bool MessageParser::parseData(const std::string& storage, ACLMessage &msg, fipa::acl::representation::Type representation)
18 {
19  MessageParserImplementationPtr messageParser = msParsers[representation];
20  if(messageParser)
21  {
22  return messageParser->parseData(storage, msg);
23  } else {
24  std::string msg = "MessageParser: there is no parser registered for " + representation::TypeTxt[representation];
25  throw std::runtime_error(msg);
26  }
27 }
28 
29 } // end namespace acl
30 } // end namespace fipa
static bool parseData(const std::string &storage, ACLMessage &msg, fipa::acl::representation::Type representation=fipa::acl::representation::BITEFFICIENT)
parses a correctly encoded message according to grammar_bitefficient.h and creates a Message object f...
boost::shared_ptr< MessageParserImplementation > MessageParserImplementationPtr
rebuilds an ACLMessage from a parsed bit-efficient encoded received message
const std::string TypeTxt[]
Definition: types.h:28
This class provides a representation of a message conforming to the FIPA specification SC00061...
Definition: acl_message.h:55
Foundation of Physical Intelligent Agents.
Definition: conversation.cpp:6