X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fxml%2Feasyxml.hxx;h=7f0c916e2e20642a8988dd8ec22d3c5e979c4f5f;hb=819833a56030570718b9cc2aa1a52daa34631e18;hp=6356901bd53b00abd1d58acab11f6fbde2692258;hpb=848965e7f07c0da4bb5f15674c9501fcfa37cd18;p=simgear.git diff --git a/simgear/xml/easyxml.hxx b/simgear/xml/easyxml.hxx index 6356901b..7f0c916e 100644 --- a/simgear/xml/easyxml.hxx +++ b/simgear/xml/easyxml.hxx @@ -15,10 +15,7 @@ #include #include -using std::istream; -using std::string; -using std::vector; - +typedef struct XML_ParserStruct* XML_Parser; /** * Interface for XML attributes. @@ -220,7 +217,7 @@ public: virtual void setValue (const char * name, const char * value); private: - vector _atts; + std::vector _atts; }; //////////////////////////////////////////////////////////////////////// @@ -256,6 +253,8 @@ private: class XMLVisitor { public: + /// Constructor + XMLVisitor() : parser(0), line(-1), column(-1) {} /** * Virtual destructor. @@ -372,6 +371,81 @@ public: * the warning. */ virtual void warning (const char * message, int line, int column) {} + + /** Set the path to the file that is parsed. + * + * This method will be called to store the path to the parsed file. Note that + * the XML parser makes no use of this copy of the path. The intent is + * to be capable of refering to the path to the parsed file if needed. + * + * @param _path The path to the parsed file. + * @see #getPath + */ + void setPath(const std::string& _path) { path = _path; } + + /** Get the path to the parsed file. + * + * This method will be called if the application needs to access the path to + * the parsed file. This information is typically needed if an error is found + * so the file where it occurred can be retrieved to help the user locate the + * error. + * + * @return the path to the parsed file. + * @see #setPath + */ + const std::string& getPath(void) const { return path; } + + /** Save the current position in the parsed file. + * + * This method will be called to save the position at which the file is + * currently parsed. Note that the XML parser makes no use of that + * information. The intent is to be capable of refering to the position in + * the parsed file if needed. + * + * @see #getColumn + * @see #getLine + */ + void savePosition(void); + + /** Get the saved column number in the parsed file. + * + * This method will be called if the application needs to get the column + * number that has been saved during the last call to savePosition(). This + * information is typically needed if an error is found so the position at + * which it occurred can be retrieved to help the user locate the error. + * + * @return the save column number. + * @see #savePosition + */ + int getColumn(void) const { return column; } + + /** Get the saved line number in the parsed file. + * + * This method will be called if the application needs to get the line + * number that has been saved during the last call to savePosition(). This + * information is typically needed if an error is found so the position at + * which it occurred can be retrieved to help the user locate the error. + * + * @return the save line number. + * @see #savePosition + */ + int getLine(void) const { return line; } + + /** Set the XML parser. + * + * This method will be called so the #XMLVisitor instance can internally use + * the XML parser for its housekeeping. The intent is that #XMLVisitor will + * only call the reporting functions of the XML parser and will not interfer + * with the XML parser current state. Doing otherwise will result in an + * unpredictable behavior of the XML parser. + * + * @param _parser the XML parser + */ + void setParser(XML_Parser _parser) { parser = _parser; } +private: + XML_Parser parser; + std::string path; + int line, column; }; @@ -394,8 +468,8 @@ public: * is a problem reading the file. * @see XMLVisitor */ -extern void readXML (istream &input, XMLVisitor &visitor, - const string &path=""); +extern void readXML (std::istream &input, XMLVisitor &visitor, + const std::string &path=""); /** @@ -416,7 +490,7 @@ extern void readXML (istream &input, XMLVisitor &visitor, * is a problem reading the file. * @see XMLVisitor */ -extern void readXML (const string &path, XMLVisitor &visitor); +extern void readXML (const std::string &path, XMLVisitor &visitor); /**