src/Configuration.h
author František Kučera <franta-hg@frantovo.cz>
Sat, 16 Jan 2021 16:36:39 +0100
branchv_0
changeset 0 ea26b3359fed
permissions -rw-r--r--
project skeleton
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     1
/**
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     2
 * Relational pipes
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     3
 * Copyright © 2021 František Kučera (Frantovo.cz, GlobalCode.info)
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     4
 *
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     5
 * This program is free software: you can redistribute it and/or modify
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License as published by
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     7
 * the Free Software Foundation, version 3 of the License.
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     8
 *
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    12
 * GNU General Public License for more details.
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    13
 *
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    15
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    16
 */
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    17
#pragma once
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    18
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    19
#include <vector>
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    20
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    21
#include <relpipe/writer/typedefs.h>
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    22
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    23
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    24
namespace relpipe {
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    25
namespace in {
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    26
namespace xmltable {
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    27
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    28
enum class Mode {
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    29
	STRING,
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    30
	BOOLEAN,
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    31
	// TODO: support also XML number, when we have a rational or decimal numbers in Relational pipes
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    32
	RAW_XML,
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    33
	LINE_NUMBER,
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    34
	XPATH
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    35
};
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    36
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    37
class XmlElementSkeleton {
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    38
public:
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    39
	relpipe::writer::string_t name;
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    40
	relpipe::writer::string_t uri;
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    41
	relpipe::writer::string_t prefix;
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    42
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    43
	XmlElementSkeleton() {
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    44
	}
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    45
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    46
	XmlElementSkeleton(relpipe::writer::string_t name, relpipe::writer::string_t uri = L"", relpipe::writer::string_t prefix = L"") : name(name), uri(uri), prefix(prefix) {
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    47
	}
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    48
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    49
	virtual ~XmlElementSkeleton() {
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    50
	}
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    51
};
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    52
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    53
class AttributeRecipe {
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    54
public:
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    55
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    56
	virtual ~AttributeRecipe() {
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    57
	}
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    58
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    59
	relpipe::writer::string_t name;
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    60
	relpipe::writer::TypeId type;
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    61
	relpipe::writer::string_t xpath;
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    62
	Mode mode = Mode::STRING;
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    63
	XmlElementSkeleton rawXmlNodeListWrapper;
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    64
	XmlElementSkeleton rawXmlAttributeWrapper;
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    65
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    66
};
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    67
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    68
class ParserOptionRecipe {
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    69
public:
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    70
	relpipe::writer::string_t uri;
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    71
	relpipe::writer::string_t value;
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    72
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    73
	ParserOptionRecipe(relpipe::writer::string_t uri, relpipe::writer::string_t value) : uri(uri), value(value) {
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    74
	}
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    75
};
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    76
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    77
class RelationConfiguration {
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    78
public:
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    79
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    80
	virtual ~RelationConfiguration() {
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    81
	}
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    82
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    83
	relpipe::writer::string_t relation;
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    84
	relpipe::writer::boolean_t nameIsXPath = false;
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    85
	relpipe::writer::string_t xpath;
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    86
	std::vector<AttributeRecipe> attributes;
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    87
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    88
	// Defaults/templates for AttributeRecipe:	
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    89
	Mode mode = Mode::STRING;
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    90
	XmlElementSkeleton rawXmlNodeListWrapper;
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    91
	XmlElementSkeleton rawXmlAttributeWrapper = {L"attribute"};
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    92
};
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    93
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    94
class Configuration {
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    95
public:
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    96
	std::vector<RelationConfiguration> relationConfigurations;
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    97
	std::vector<relpipe::writer::string_t> namespaceMappings;
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    98
	std::vector<ParserOptionRecipe> parserOptions;
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    99
	bool xinclude = false;
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   100
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   101
	virtual ~Configuration() {
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   102
	}
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   103
};
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   104
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   105
}
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   106
}
ea26b3359fed project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   107
}