fipa_acl  1.4
envelope_parser.cpp
Go to the documentation of this file.
1 #include "envelope_parser.h"
3 #include "xml_envelope_parser.h"
4 
5 #include <boost/assign/list_of.hpp>
6 
7 namespace fipa {
8 namespace acl {
9 
10 std::map<representation::Type, EnvelopeParserImplementationPtr > EnvelopeParser::msParsers = boost::assign::map_list_of
11  (representation::BITEFFICIENT, boost::shared_ptr<EnvelopeParserImplementation>(new BitefficientEnvelopeParser()) )
12  (representation::XML, boost::shared_ptr<EnvelopeParserImplementation>(new XMLEnvelopeParser()) );
13 
14 
15 bool EnvelopeParser::parseData(const std::string& storage, ACLEnvelope& envelope, representation::Type type)
16 {
17  EnvelopeParserImplementationPtr messageParser = msParsers[type];
18  if(messageParser)
19  {
20  return messageParser->parseData(storage, envelope);
21  } else {
22  std::string msg = "EnvelopeParser: there is no parser registered for " + representation::TypeTxt[type];
23  throw std::runtime_error(msg);
24  }
25 }
26 
27 } // end namespace acl
28 } // end namespace fipa
ACLMessage envelope (also typed as fipa::acl::Letter) includes the base envelope and updated fields...
Definition: acl_envelope.h:349
static bool parseData(const std::string &storage, ACLEnvelope &envelope, representation::Type type=fipa::acl::representation::BITEFFICIENT)
boost::shared_ptr< EnvelopeParserImplementation > EnvelopeParserImplementationPtr
const std::string TypeTxt[]
Definition: types.h:28