just from a specified file name.
}
+/**
+ * Read properties from an in-memory buffer.
+ *
+ * @param buf A character buffer containing the xml data.
+ * @param size The size/length of the buffer in bytes
+ * @param start_node The root node for reading properties.
+ * @return true if the read succeeded, false otherwise.
+ */
+void readProperties (const char *buf, const int size,
+ SGPropertyNode * start_node)
+{
+ PropsVisitor visitor(start_node, "");
+ readXML(buf, size, visitor);
+ if (visitor.hasException())
+ throw visitor.getException();
+}
+
\f
////////////////////////////////////////////////////////////////////////
// Property list writer.
void readProperties (const string &file, SGPropertyNode * start_node);
+/**
+ * Read properties from an in-memory buffer.
+ */
+void readProperties (const char *buf, const int size,
+ SGPropertyNode * start_node);
+
+
/**
* Write properties to an XML output stream.
*/
input.close();
}
+void
+readXML (const char *buf, const int size, XMLVisitor &visitor)
+{
+ XML_Parser parser = XML_ParserCreate(0);
+ XML_SetUserData(parser, &visitor);
+ XML_SetElementHandler(parser, start_element, end_element);
+ XML_SetCharacterDataHandler(parser, character_data);
+ XML_SetProcessingInstructionHandler(parser, processing_instruction);
+
+ visitor.startXML();
+
+ if (!XML_Parse(parser, buf, size, false)) {
+ XML_ParserFree(parser);
+ throw sg_io_exception(XML_ErrorString(XML_GetErrorCode(parser)),
+ sg_location("In-memory XML buffer",
+ XML_GetCurrentLineNumber(parser),
+ XML_GetCurrentColumnNumber(parser)),
+ "SimGear XML Parser");
+ }
+
+ XML_ParserFree(parser);
+}
+
// end of easyxml.cxx
extern void readXML (const string &path, XMLVisitor &visitor);
+/**
+ * @relates XMLVisitor
+ * Read an XML document.
+ *
+ * This function reads an XML document from the buffer provided,
+ * and invokes the callback methods in the visitor object to pass the
+ * parsing events back to the application. When this function
+ * returns, the parser will have reported all of the data in the XML
+ * document to the application through the visitor callback methods,
+ * and XML processing will be complete.
+ *
+ * @param buf The xml data buffer.
+ * @param size The size of the data buffer in bytes
+ * @param visitor An object that contains callbacks for XML parsing
+ * events.
+ * @exception Throws sg_io_exception or sg_xml_exception if there
+ * is a problem reading the file.
+ * @see XMLVisitor
+ */
+extern void readXML (const char *buf, const int size, XMLVisitor &visitor);
+
+
#endif // __EASYXML_HXX