3 #include <fipa_acl/message_generator/message_format.h> 4 #include <base-logging/Logging.hpp> 6 #include <boost/foreach.hpp> 16 const char* parseResult = doc.Parse(storage.c_str());
18 if(parseResult != NULL)
21 LOG_WARN_S <<
"Parsing message XML failed for: " << parseResult;
25 const TiXmlElement* messageElem = doc.FirstChildElement();
27 if(messageElem->ValueStr() !=
"fipa-message")
29 LOG_WARN_S <<
"Parsing error: XML main node not named 'fipa-message' but " << messageElem->ValueStr();
38 catch(
const std::exception& e)
41 LOG_WARN_S <<
"Parsing error performative: " << e.what();
46 const std::string* convID = messageElem->Attribute(std::string(
"conversation-id"));
53 const TiXmlElement * pChild;
54 for ( pChild = messageElem->FirstChildElement(); pChild != 0; pChild = pChild->NextSiblingElement())
56 if(!parseParameter(msg, pChild))
65 bool XMLMessageParser::parseParameter(
ACLMessage& aclMsg,
const TiXmlElement* elem)
const 67 using namespace MessageField;
68 const std::string& name = elem->ValueStr();
78 BOOST_FOREACH(
AgentID aid, aidl)
83 catch(std::exception& e)
85 LOG_WARN_S <<
"Parsing error receivers: " << e.what();
92 const TiXmlElement* aid = elem->FirstChildElement();
95 LOG_WARN_S <<
"Parsing error: sender has no first child";
104 catch(std::exception& e)
106 LOG_WARN_S <<
"Parsing error sender: " << e.what();
115 LOG_WARN_S <<
"Parsing error: content is set but invalid";
126 LOG_WARN_S <<
"Parsing error: language is set but invalid";
137 LOG_WARN_S <<
"Parsing error: encoding is set but invalid";
148 LOG_WARN_S <<
"Parsing error: ontology is set but invalid";
159 LOG_WARN_S <<
"Parsing error: protocol is set but invalid";
170 LOG_WARN_S <<
"Parsing error: reply_with is set but invalid";
181 LOG_WARN_S <<
"Parsing error: in_reply_to is set but invalid";
190 const char* value = elem->Attribute(
"time");
193 LOG_WARN_S <<
"Parsing error: reply_by is set but invalid";
200 catch(std::exception& e)
202 LOG_WARN_S <<
"Parsing error reply_by: " << e.what();
213 catch(std::exception& e)
215 LOG_WARN_S <<
"Parsing error reply_to: " << e.what();
225 LOG_WARN_S <<
"Parsing error: conversation_id is set but invalid";
231 else if(name ==
"user-defined")
238 catch(std::exception& e)
240 LOG_WARN_S <<
"Parsing error user_def_param: " << e.what();
246 LOG_WARN_S <<
"Parsing error: unknown node: " << name;
void setReplyWith(const std::string &str)
void setConversationID(const std::string &str)
void setLanguage(const std::string &str)
bool parseData(const std::string &storage, ACLMessage &msg)
std::map< MessageField::Type, std::string > MessageFieldTxt
void setInReplyTo(const std::string &str)
std::vector< AgentID > AgentIDList
static const AgentIDList parseAgentIDSequence(const TiXmlElement *aidlElem)
static const base::Time strToDate(const std::string &dateStr)
void setContent(const std::string &content)
void setSender(const AgentID &sender)
static const UserdefParam parseUserdefinedParameter(const TiXmlElement *paramElem)
void addUserdefParam(const UserdefParam &p)
static const AgentID parseAgentID(const TiXmlElement *aidElem)
void setAllReplyTo(const AgentIDList &replyTo)
static const char * extractContentOrAttribute(const TiXmlElement *elem, const char *identifier="href")
This class provides a representation of a message conforming to the FIPA specification SC00061...
void setReplyBy(const base::Time &time)
void addReceiver(const AgentID &aid)
void setPerformative(Performative perf)
Set performative.
Implements the general AgentID functionality, which is present throughout the fipa specifications(FIP...
Foundation of Physical Intelligent Agents.
void setEncoding(const std::string &str)
void setProtocol(const std::string &str)
the method checks whether the passed protocol string is a word or not(according to the fipa spec) ...
void setOntology(const std::string &str)