aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVicent Marti2008-07-04 23:51:23 +0000
committerVicent Marti2008-07-04 23:51:23 +0000
commit40bf717d3ba7974d95414bf8c8cf1abe34de288d (patch)
tree6e7e2c157de3f79b862a5e0b61e40ce34d2421d6
parent96f2d9ca18eea27eaffda76fbce2168cddebbfb1 (diff)
downloadscummvm-rg350-40bf717d3ba7974d95414bf8c8cf1abe34de288d.tar.gz
scummvm-rg350-40bf717d3ba7974d95414bf8c8cf1abe34de288d.tar.bz2
scummvm-rg350-40bf717d3ba7974d95414bf8c8cf1abe34de288d.zip
closedKeyCallback on XMLParser (as asked by Kenny)
svn-id: r32909
-rw-r--r--common/xmlparser.cpp5
-rw-r--r--common/xmlparser.h14
2 files changed, 19 insertions, 0 deletions
diff --git a/common/xmlparser.cpp b/common/xmlparser.cpp
index d5c8535932..d0c89a9d3e 100644
--- a/common/xmlparser.cpp
+++ b/common/xmlparser.cpp
@@ -194,6 +194,11 @@ bool XMLParser::parse() {
case kParserNeedPropertyName:
if (activeClosure) {
+ if (!closedKeyCallback(_activeKey.top()->name)) {
+ parserError("Missing data when closing key '%s'.", _activeKey.top()->name.c_str());
+ break;
+ }
+
activeClosure = false;
delete _activeKey.pop();
diff --git a/common/xmlparser.h b/common/xmlparser.h
index 3738b69b7b..4c77696482 100644
--- a/common/xmlparser.h
+++ b/common/xmlparser.h
@@ -204,6 +204,20 @@ protected:
}
/**
+ * The closed key callback function must be overloaded by inheriting classes to
+ * implement parser-specific functions.
+ *
+ * The closedKeyCallback is issued once a key has been finished parsing, to let
+ * the parser verify that all the required subkeys, etc, were included.
+ *
+ * Returns true if the key was properly closed, false otherwise.
+ * By default, all keys are properly closed.
+ */
+ virtual bool closedKeyCallback(Common::String keyName) {
+ return true;
+ }
+
+ /**
* Parses the value of a given key. There's no reason to overload this.
*/
virtual bool parseKeyValue(Common::String keyName);