src/XMLDocumentConstructor.h
branchv_0
changeset 26 84ff7c97bfdc
parent 25 0e8a58946c48
child 29 cc601886f0a7
--- a/src/XMLDocumentConstructor.h	Sat Nov 28 23:52:01 2020 +0100
+++ b/src/XMLDocumentConstructor.h	Sat Dec 05 20:17:27 2020 +0100
@@ -42,6 +42,7 @@
 		MAP_KEY
 	};
 
+	std::string rootName = "yaml";
 	xmlpp::Element* current;
 	std::vector<Mode> mode;
 
@@ -51,7 +52,7 @@
 		*length = input->gcount();
 		return (input->good() || input->eof()) ? 1 : 0;
 	}
-	
+
 	/**
 	 * Both YAML and XML strings are in UTF-8.
 	 */
@@ -77,12 +78,14 @@
 	virtual ~XMLDocumentConstructor() {
 		yaml_parser_delete(&yamlParser);
 	}
-	
+
 	void setOption(const std::string& uri, const std::string& value) {
+		if (uri == "root-name") rootName = value;
+		else throw std::invalid_argument(std::string("Invalid parser option: „") + uri + "“ with value: „" + value + "“");
 	}
 
 	void process() {
-		current = parser->get_document()->create_root_node("yaml");
+		current = parser->get_document()->create_root_node(rootName);
 		mode.push_back(Mode::ROOT);
 		std::string itemName;