src/Configuration.h
branchv_0
changeset 0 2f783f0573fa
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/Configuration.h	Sat Feb 20 20:32:56 2021 +0100
@@ -0,0 +1,107 @@
+/**
+ * Relational pipes
+ * Copyright © 2019 František Kučera (Frantovo.cz, GlobalCode.info)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+#pragma once
+
+#include <vector>
+
+#include <relpipe/writer/typedefs.h>
+
+
+namespace relpipe {
+namespace in {
+namespace xmltable {
+
+enum class Mode {
+	STRING,
+	BOOLEAN,
+	// TODO: support also XML number, when we have a rational or decimal numbers in Relational pipes
+	RAW_XML,
+	LINE_NUMBER,
+	XPATH
+};
+
+class XmlElementSkeleton {
+public:
+	relpipe::writer::string_t name;
+	relpipe::writer::string_t uri;
+	relpipe::writer::string_t prefix;
+
+	XmlElementSkeleton() {
+	}
+
+	XmlElementSkeleton(relpipe::writer::string_t name, relpipe::writer::string_t uri = L"", relpipe::writer::string_t prefix = L"") : name(name), uri(uri), prefix(prefix) {
+	}
+
+	virtual ~XmlElementSkeleton() {
+	}
+};
+
+class AttributeRecipe {
+public:
+
+	virtual ~AttributeRecipe() {
+	}
+
+	relpipe::writer::string_t name;
+	relpipe::writer::TypeId type;
+	relpipe::writer::string_t xpath;
+	Mode mode = Mode::STRING;
+	XmlElementSkeleton rawXmlNodeListWrapper;
+	XmlElementSkeleton rawXmlAttributeWrapper;
+
+};
+
+class ParserOptionRecipe {
+public:
+	relpipe::writer::string_t uri;
+	relpipe::writer::string_t value;
+
+	ParserOptionRecipe(relpipe::writer::string_t uri, relpipe::writer::string_t value) : uri(uri), value(value) {
+	}
+};
+
+class RelationConfiguration {
+public:
+
+	virtual ~RelationConfiguration() {
+	}
+
+	relpipe::writer::string_t relation;
+	relpipe::writer::boolean_t nameIsXPath = false;
+	relpipe::writer::string_t xpath;
+	std::vector<AttributeRecipe> attributes;
+
+	// Defaults/templates for AttributeRecipe:	
+	Mode mode = Mode::STRING;
+	XmlElementSkeleton rawXmlNodeListWrapper;
+	XmlElementSkeleton rawXmlAttributeWrapper = {L"attribute"};
+};
+
+class Configuration {
+public:
+	std::vector<RelationConfiguration> relationConfigurations;
+	std::vector<relpipe::writer::string_t> namespaceMappings;
+	std::vector<ParserOptionRecipe> parserOptions;
+	bool xinclude = false;
+
+	virtual ~Configuration() {
+	}
+};
+
+}
+}
+}
\ No newline at end of file