[Scummvm-git-logs] scummvm master -> cd09481f6edf1e5a0b6c8647d7480798a019684e

sev- noreply at scummvm.org
Tue Feb 7 23:30:13 UTC 2023


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
cd09481f6e COMMON: Add ability to handle unknown xml keys


Commit: cd09481f6edf1e5a0b6c8647d7480798a019684e
    https://github.com/scummvm/scummvm/commit/cd09481f6edf1e5a0b6c8647d7480798a019684e
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2023-02-08T00:30:08+01:00

Commit Message:
COMMON: Add ability to handle unknown xml keys

Changed paths:
    common/formats/xmlparser.cpp
    common/formats/xmlparser.h


diff --git a/common/formats/xmlparser.cpp b/common/formats/xmlparser.cpp
index e834edfd8fa..66026a8f549 100644
--- a/common/formats/xmlparser.cpp
+++ b/common/formats/xmlparser.cpp
@@ -190,7 +190,9 @@ bool XMLParser::parseActiveKey(bool closed) {
 		}
 
 	} else {
-		return parserError("Unexpected key in the active scope ('" + key->name + "').");
+		if (!handleUnknownKey(key))
+			return parserError("Unexpected key in the active scope ('" + key->name + "').");
+		ignore = true;
 	}
 
 	// check if any of the parents must be ignored.
diff --git a/common/formats/xmlparser.h b/common/formats/xmlparser.h
index a896fcbdd46..49b4b5c8915 100644
--- a/common/formats/xmlparser.h
+++ b/common/formats/xmlparser.h
@@ -362,6 +362,15 @@ protected:
 	 */
 	virtual void cleanup() {}
 
+	/**
+	 * Overload if your parser wants to be notified of keys which haven't
+	 * been explicitly declared.
+	 *
+	 * The functions should return true if the key was handled and parsing should
+	 * continue, or false (default) to raise a parsing error.
+	 */
+	virtual bool handleUnknownKey(ParserNode *node) { return false; }
+
 	List<XMLKeyLayout *> _layoutList;
 
 private:




More information about the Scummvm-git-logs mailing list