src/Configuration.h
author František Kučera <franta-hg@frantovo.cz>
Sat, 20 Feb 2021 20:32:56 +0100
branchv_0
changeset 0 2f783f0573fa
permissions -rw-r--r--
project skeleton
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     1
/**
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     2
 * Relational pipes
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     3
 * Copyright © 2019 František Kučera (Frantovo.cz, GlobalCode.info)
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     4
 *
2f783f0573fa 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
2f783f0573fa 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
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     7
 * the Free Software Foundation, version 3 of the License.
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     8
 *
2f783f0573fa 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,
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    12
 * GNU General Public License for more details.
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    13
 *
2f783f0573fa 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
2f783f0573fa 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/>.
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    16
 */
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    17
#pragma once
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    18
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    19
#include <vector>
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    20
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    21
#include <relpipe/writer/typedefs.h>
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    22
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    23
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    24
namespace relpipe {
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    25
namespace in {
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    26
namespace xmltable {
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    27
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    28
enum class Mode {
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    29
	STRING,
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    30
	BOOLEAN,
2f783f0573fa 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
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    32
	RAW_XML,
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    33
	LINE_NUMBER,
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    34
	XPATH
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    35
};
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    36
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    37
class XmlElementSkeleton {
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    38
public:
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    39
	relpipe::writer::string_t name;
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    40
	relpipe::writer::string_t uri;
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    41
	relpipe::writer::string_t prefix;
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    42
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    43
	XmlElementSkeleton() {
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    44
	}
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    45
2f783f0573fa 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) {
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    47
	}
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    48
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    49
	virtual ~XmlElementSkeleton() {
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    50
	}
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    51
};
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    52
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    53
class AttributeRecipe {
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    54
public:
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    55
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    56
	virtual ~AttributeRecipe() {
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    57
	}
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    58
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    59
	relpipe::writer::string_t name;
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    60
	relpipe::writer::TypeId type;
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    61
	relpipe::writer::string_t xpath;
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    62
	Mode mode = Mode::STRING;
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    63
	XmlElementSkeleton rawXmlNodeListWrapper;
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    64
	XmlElementSkeleton rawXmlAttributeWrapper;
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    65
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    66
};
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    67
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    68
class ParserOptionRecipe {
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    69
public:
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    70
	relpipe::writer::string_t uri;
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    71
	relpipe::writer::string_t value;
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    72
2f783f0573fa 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) {
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    74
	}
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    75
};
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    76
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    77
class RelationConfiguration {
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    78
public:
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    79
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    80
	virtual ~RelationConfiguration() {
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    81
	}
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    82
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    83
	relpipe::writer::string_t relation;
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    84
	relpipe::writer::boolean_t nameIsXPath = false;
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    85
	relpipe::writer::string_t xpath;
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    86
	std::vector<AttributeRecipe> attributes;
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    87
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    88
	// Defaults/templates for AttributeRecipe:	
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    89
	Mode mode = Mode::STRING;
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    90
	XmlElementSkeleton rawXmlNodeListWrapper;
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    91
	XmlElementSkeleton rawXmlAttributeWrapper = {L"attribute"};
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    92
};
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    93
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    94
class Configuration {
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    95
public:
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    96
	std::vector<RelationConfiguration> relationConfigurations;
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    97
	std::vector<relpipe::writer::string_t> namespaceMappings;
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    98
	std::vector<ParserOptionRecipe> parserOptions;
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    99
	bool xinclude = false;
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   100
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   101
	virtual ~Configuration() {
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   102
	}
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   103
};
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   104
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   105
}
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   106
}
2f783f0573fa project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   107
}