src/CLIParser.h
branchv_0
changeset 8 8730e2d0db0e
parent 7 ff69af3c67a3
child 15 917b8fbd29b9
--- a/src/CLIParser.h	Thu Jan 02 23:31:44 2020 +0100
+++ b/src/CLIParser.h	Sun Jan 05 01:01:12 2020 +0100
@@ -68,6 +68,9 @@
 	static const string_t OPTION_RECORDS;
 	static const string_t OPTION_ATTRIBUTE;
 	static const string_t OPTION_XINCLUDE;
+	static const string_t OPTION_MODE;
+	static const string_t OPTION_RAW_XML_NODELIST_WRAPPER;
+	static const string_t OPTION_RAW_XML_ATTRIBUTE_WRAPPER;
 
 	Configuration parse(const std::vector<string_t>& arguments) {
 		Configuration c;
@@ -90,10 +93,32 @@
 				currentRelation.xpath = readNext(arguments, i);
 			} else if (option == OPTION_ATTRIBUTE) {
 				AttributeRecipe attribute;
+				attribute.mode = currentRelation.mode;
+				attribute.rawXmlNodeListWrapper = currentRelation.rawXmlNodeListWrapper;
+				attribute.rawXmlAttributeWrapper = currentRelation.rawXmlAttributeWrapper;
 				attribute.name = readNext(arguments, i);
 				attribute.type = parseTypeId(readNext(arguments, i));
 				attribute.xpath = readNext(arguments, i);
 				currentRelation.attributes.push_back(attribute);
+			} else if (option == OPTION_MODE) {
+				string_t modeName = readNext(arguments, i);
+				Mode mode;
+				if (modeName == L"string") mode = Mode::STRING;
+				else if (modeName == L"boolean") mode = Mode::BOOLEAN;
+				else if (modeName == L"raw-xml") mode = Mode::RAW_XML;
+				else if (modeName == L"line-number") mode = Mode::LINE_NUMBER;
+				else if (modeName == L"xpath") mode = Mode::XPATH;
+				else throw relpipe::cli::RelpipeCLIException(L"Unsupported mode: " + modeName, relpipe::cli::CLI::EXIT_CODE_BAD_CLI_ARGUMENTS);
+				if (currentRelation.attributes.size()) currentRelation.attributes.back().mode = mode;
+				else currentRelation.mode = mode;
+			} else if (option == OPTION_RAW_XML_NODELIST_WRAPPER) {
+				XmlElementSkeleton w = {readNext(arguments, i), readNext(arguments, i), readNext(arguments, i)};
+				if (currentRelation.attributes.size()) currentRelation.attributes.back().rawXmlNodeListWrapper = w;
+				else currentRelation.rawXmlNodeListWrapper = w;
+			} else if (option == OPTION_RAW_XML_ATTRIBUTE_WRAPPER) {
+				XmlElementSkeleton w = {readNext(arguments, i), readNext(arguments, i), readNext(arguments, i)};
+				if (currentRelation.attributes.size()) currentRelation.attributes.back().rawXmlAttributeWrapper = w;
+				else currentRelation.rawXmlAttributeWrapper = w;
 			} else throw relpipe::cli::RelpipeCLIException(L"Unsupported CLI option: " + option, relpipe::cli::CLI::EXIT_CODE_BAD_CLI_ARGUMENTS);
 		}
 		addRelation(c, currentRelation); // last relation
@@ -111,6 +136,9 @@
 const string_t CLIParser::OPTION_RECORDS = L"--records";
 const string_t CLIParser::OPTION_ATTRIBUTE = L"--attribute";
 const string_t CLIParser::OPTION_XINCLUDE = L"--xinclude";
+const string_t CLIParser::OPTION_MODE = L"--mode";
+const string_t CLIParser::OPTION_RAW_XML_NODELIST_WRAPPER = L"--raw-xml-nodelist-wrapper";
+const string_t CLIParser::OPTION_RAW_XML_ATTRIBUTE_WRAPPER = L"--raw-xml-attribute-wrapper";
 
 }
 }