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