#include <xml_envelope_parser.h>
Inherits fipa::acl::EnvelopeParserImplementation.
Definition at line 13 of file xml_envelope_parser.h.
| bool fipa::acl::XMLEnvelopeParser::parseData |
( |
const std::string & |
storage, |
|
|
ACLEnvelope & |
envelope |
|
) |
| |
|
virtual |
Reimplemented from fipa::acl::EnvelopeParserImplementation.
Definition at line 11 of file xml_envelope_parser.cpp.
14 LOG_INFO_S <<
"XMLEnvelopeParser: starting to parse: " << storage;
16 std::string envelopeXML;
17 std::string payloadData;
20 std::string envelopeEndMarker =
"</envelope>";
21 size_t pos = storage.find(envelopeEndMarker);
22 if(pos == std::string::npos)
24 LOG_WARN_S <<
"XMLEnvelopeParser: this is not an XML envelope. Could not find </envelope>";
27 envelopeXML = storage.substr(0, pos + envelopeEndMarker.size());
29 size_t payloadPosition = pos + envelopeEndMarker.size();
30 if(payloadPosition < storage.length());
32 envelope.setPayload(storage.substr(payloadPosition));
37 const char* parseResult = doc.Parse(envelopeXML.c_str());
39 if(parseResult != NULL)
42 LOG_WARN_S <<
"Parsing envelope XML failed for (probably the payload): " << parseResult;
44 LOG_INFO_S <<
"XMLEnvelopeParser: basic XML parsing complete.";
47 const TiXmlElement* envelopeElem = doc.FirstChildElement();
49 if(envelopeElem == NULL)
51 LOG_WARN_S <<
"Parsing error: XML main node not found.";
55 if(envelopeElem->ValueStr() !=
"envelope")
57 LOG_WARN_S <<
"Parsing error: XML main node not named 'fipa-message' but " << envelopeElem->ValueStr();
62 const TiXmlElement* pChild = envelopeElem->FirstChildElement();
66 LOG_WARN_S <<
"Parsing error: XML first params node not found.";
75 envelope.setBaseEnvelope(parseParameters(pChild, paramsIndex++));
77 catch(std::exception& e)
79 LOG_WARN_S <<
"Parsing error base envelope: " << e.what();
84 for ( pChild = pChild->NextSiblingElement(); pChild != 0; pChild = pChild->NextSiblingElement())
88 envelope.addExtraEnvelope(parseParameters(pChild, paramsIndex++));
90 catch(std::exception& e)
92 LOG_WARN_S <<
"Parsing error extra envelope: " << e.what();
The documentation for this class was generated from the following files: