loadXML is renamed to loadXMLFile to be more explicit.
Added loadXMLString to load an xml representation.
This will allow to interpret directly json values as base64 xml
encodings.
*/
void loadXML(const std::string &xmlPathFile) throw(anna::RuntimeException);
+ /**
+ * Interpret a xml string in order to create a diameter message
+ * You could apply this multiple times over the same object. A basic cleanup is done respecting the codec engine.
+ *
+ * @see functions::messageXmlDocumentFromXmlString
+ * @see fromXML
+ *
+ * @param xmlString xml representation of the diameter message
+ */
+ void loadXMLString(const std::string &xmlString) throw(anna::RuntimeException);
+
// getters
For example, you could load the document to be decoded over a codec Message by mean #Message::fromXML (using
the xml document #getRootNode) during document lifetime. After that, it could be destroyed.
*/
- static void messageXmlDocumentFromXmlString(anna::xml::DocumentFile &xmlDocument, const std::string &xmlString) throw(anna::RuntimeException);
+ static void messageXmlDocumentFromXmlString(anna::xml::DocumentMemory &xmlDocument, const std::string &xmlString) throw(anna::RuntimeException);
};
fromXML(xmlDocument.getRootNode());
}
+//------------------------------------------------------------------------------
+//----------------------------------------------------- Message::loadXMLString()
+//------------------------------------------------------------------------------
+void Message::loadXMLString(const std::string &xmlString) throw(anna::RuntimeException) {
+
+ anna::xml::DocumentMemory xmlDocument;
+ anna::diameter::codec::functions::messageXmlDocumentFromXmlString(xmlDocument, xmlString);
+ fromXML(xmlDocument.getRootNode());
+}
+
//------------------------------------------------------------------------------
//----------------------------------------------------------- Message::fromXML()
//------------------------------------------------------------------------------
);
}
-void anna::diameter::codec::functions::messageXmlDocumentFromXmlString(anna::xml::DocumentFile &xmlDocument, const std::string &xmlString) throw(anna::RuntimeException) {
+void anna::diameter::codec::functions::messageXmlDocumentFromXmlString(anna::xml::DocumentMemory &xmlDocument, const std::string &xmlString) throw(anna::RuntimeException) {
LOGDEBUG(anna::Logger::debug("Parsing diameter message from xml string representation into xml document", ANNA_FILE_LOCATION));
xmlDocument.initialize(xmlString.c_str());
- xmlDocument.parse(MessageDTDMemory); // Parsing: fail here if xml violates dtd
- LOGDEBUG(anna::Logger::debug("Parsing OK from XML string representation", ANNA_FILE_LOCATION));
+ const anna::xml::Node *rootNode = xmlDocument.parse(MessageDTDMemory); // Parsing: fail here if xml violates dtd
+ LOGDEBUG(
+ std::string trace = "Parsing OK from XML string representation '";
+ trace += xmlString;
+ trace += "':\n";
+ trace += anna::xml::Compiler().apply(rootNode);
+ anna::Logger::debug(trace, ANNA_FILE_LOCATION);
+ );
}