Skip to content
Snippets Groups Projects
Commit 10d215bc authored by Ruud Overeem's avatar Ruud Overeem
Browse files

Task #7342; Fixed bug in XML parser.

parent 7cca2ac3
No related branches found
No related tags found
No related merge requests found
...@@ -69,8 +69,6 @@ Message::Message(const std::string &from, ...@@ -69,8 +69,6 @@ Message::Message(const std::string &from,
itsQpidMsg.setContent(formatString(LOFAR_MSG_TEMPLATE.c_str(), protocol.c_str(), protocolVersion.c_str(), itsQpidMsg.setContent(formatString(LOFAR_MSG_TEMPLATE.c_str(), protocol.c_str(), protocolVersion.c_str(),
from.c_str(), forUser.c_str(), "", "", summary.c_str(), from.c_str(), forUser.c_str(), "", "", summary.c_str(),
momid.c_str(), sasid.c_str(), "%s")); momid.c_str(), sasid.c_str(), "%s"));
cout << itsQpidMsg.getContent() << endl;
} }
// Read a message from disk (header + payload) // Read a message from disk (header + payload)
...@@ -84,12 +82,12 @@ Message::~Message() ...@@ -84,12 +82,12 @@ Message::~Message()
void Message::setXMLPayload (const std::string &payload) void Message::setXMLPayload (const std::string &payload)
{ {
itsQpidMsg.setContent(formatString(itsQpidMsg.getContent().c_str(), payload.c_str())); itsQpidMsg.setContent(formatlString(itsQpidMsg.getContent().c_str(), payload.c_str()));
} }
void Message::setTXTPayload (const std::string &payload) void Message::setTXTPayload (const std::string &payload)
{ {
itsQpidMsg.setContent(formatString(itsQpidMsg.getContent().c_str(), payload.c_str())); itsQpidMsg.setContent(formatlString(itsQpidMsg.getContent().c_str(), payload.c_str()));
} }
void Message::setMapPayload (const qpid::types::Variant::Map &payload) void Message::setMapPayload (const qpid::types::Variant::Map &payload)
...@@ -135,21 +133,23 @@ string Message::getXMLvalue(const string& key) const ...@@ -135,21 +133,23 @@ string Message::getXMLvalue(const string& key) const
string::size_type offset = 0; string::size_type offset = 0;
string::size_type begin; string::size_type begin;
string::size_type end; string::size_type end;
string startTag;
for (size_t i = 0; i < labels.size(); ++i) { for (size_t i = 0; i < labels.size(); ++i) {
// define tags to find // define tags to find
string startTag("<"+labels[i]+">"); startTag = string("<"+labels[i]+">");
string stopTag ("</"+labels[i]+">");
// search begin tag // search begin tag
begin = content.find(startTag, offset); begin = content.find(startTag, offset);
if (begin == string::npos) { if (begin == string::npos) {
return ("???"); return ("???");
} }
// search end tag offset = begin;
begin+=startTag.size(); }
end = content.find(stopTag, begin); // search end tag
if (end == string::npos) { string stopTag ("</"+labels[labels.size()-1]+">");
return ("???"); begin+=startTag.size();
} end = content.find(stopTag, begin);
if (end == string::npos) {
return ("???");
} }
return (content.substr(begin, end - begin)); return (content.substr(begin, end - begin));
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment