src/Configuration.h
author František Kučera <franta-hg@frantovo.cz>
Fri, 20 Nov 2020 11:59:15 +0100
branchv_0
changeset 23 b25404ff2b2b
parent 8 8730e2d0db0e
child 25 0e8a58946c48
permissions -rw-r--r--
XML name escaping: documentation, refactoring

/**
 * 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 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;
	bool xinclude = false;

	virtual ~Configuration() {
	}
};

}
}
}