src/Configuration.h
author František Kučera <franta-hg@frantovo.cz>
Sun, 05 Jan 2020 01:01:12 +0100
branchv_0
changeset 8 8730e2d0db0e
parent 7 ff69af3c67a3
child 15 917b8fbd29b9
permissions -rw-r--r--
suport multiple modes of reading from XML: string, boolean, raw-xml, line-number, xpath
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
7d6ac51c0d48 configuration and CLI parser
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     1
/**
7d6ac51c0d48 configuration and CLI parser
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     2
 * Relational pipes
7d6ac51c0d48 configuration and CLI parser
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     3
 * Copyright © 2019 František Kučera (Frantovo.cz, GlobalCode.info)
7d6ac51c0d48 configuration and CLI parser
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     4
 *
7d6ac51c0d48 configuration and CLI parser
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     5
 * This program is free software: you can redistribute it and/or modify
7d6ac51c0d48 configuration and CLI parser
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
4
a0689654b3c2 fix license version: GNU GPLv3
František Kučera <franta-hg@frantovo.cz>
parents: 2
diff changeset
     7
 * the Free Software Foundation, version 3 of the License.
1
7d6ac51c0d48 configuration and CLI parser
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     8
 *
7d6ac51c0d48 configuration and CLI parser
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
7d6ac51c0d48 configuration and CLI parser
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
7d6ac51c0d48 configuration and CLI parser
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7d6ac51c0d48 configuration and CLI parser
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    12
 * GNU General Public License for more details.
7d6ac51c0d48 configuration and CLI parser
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    13
 *
7d6ac51c0d48 configuration and CLI parser
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
7d6ac51c0d48 configuration and CLI parser
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    15
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
7d6ac51c0d48 configuration and CLI parser
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    16
 */
7d6ac51c0d48 configuration and CLI parser
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    17
#pragma once
7d6ac51c0d48 configuration and CLI parser
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    18
7d6ac51c0d48 configuration and CLI parser
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    19
#include <vector>
7d6ac51c0d48 configuration and CLI parser
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    20
7d6ac51c0d48 configuration and CLI parser
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    21
#include <relpipe/writer/typedefs.h>
7d6ac51c0d48 configuration and CLI parser
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    22
7d6ac51c0d48 configuration and CLI parser
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    23
7d6ac51c0d48 configuration and CLI parser
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    24
namespace relpipe {
7d6ac51c0d48 configuration and CLI parser
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    25
namespace in {
7d6ac51c0d48 configuration and CLI parser
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    26
namespace xmltable {
7d6ac51c0d48 configuration and CLI parser
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    27
8
8730e2d0db0e suport multiple modes of reading from XML: string, boolean, raw-xml, line-number, xpath
František Kučera <franta-hg@frantovo.cz>
parents: 7
diff changeset
    28
enum class Mode {
8730e2d0db0e suport multiple modes of reading from XML: string, boolean, raw-xml, line-number, xpath
František Kučera <franta-hg@frantovo.cz>
parents: 7
diff changeset
    29
	STRING,
8730e2d0db0e suport multiple modes of reading from XML: string, boolean, raw-xml, line-number, xpath
František Kučera <franta-hg@frantovo.cz>
parents: 7
diff changeset
    30
	BOOLEAN,
8730e2d0db0e suport multiple modes of reading from XML: string, boolean, raw-xml, line-number, xpath
František Kučera <franta-hg@frantovo.cz>
parents: 7
diff changeset
    31
	// TODO: support also XML number, when we have a rational or decimal numbers in Relational pipes
8730e2d0db0e suport multiple modes of reading from XML: string, boolean, raw-xml, line-number, xpath
František Kučera <franta-hg@frantovo.cz>
parents: 7
diff changeset
    32
	RAW_XML,
8730e2d0db0e suport multiple modes of reading from XML: string, boolean, raw-xml, line-number, xpath
František Kučera <franta-hg@frantovo.cz>
parents: 7
diff changeset
    33
	LINE_NUMBER,
8730e2d0db0e suport multiple modes of reading from XML: string, boolean, raw-xml, line-number, xpath
František Kučera <franta-hg@frantovo.cz>
parents: 7
diff changeset
    34
	XPATH
8730e2d0db0e suport multiple modes of reading from XML: string, boolean, raw-xml, line-number, xpath
František Kučera <franta-hg@frantovo.cz>
parents: 7
diff changeset
    35
};
8730e2d0db0e suport multiple modes of reading from XML: string, boolean, raw-xml, line-number, xpath
František Kučera <franta-hg@frantovo.cz>
parents: 7
diff changeset
    36
8730e2d0db0e suport multiple modes of reading from XML: string, boolean, raw-xml, line-number, xpath
František Kučera <franta-hg@frantovo.cz>
parents: 7
diff changeset
    37
class XmlElementSkeleton {
8730e2d0db0e suport multiple modes of reading from XML: string, boolean, raw-xml, line-number, xpath
František Kučera <franta-hg@frantovo.cz>
parents: 7
diff changeset
    38
public:
8730e2d0db0e suport multiple modes of reading from XML: string, boolean, raw-xml, line-number, xpath
František Kučera <franta-hg@frantovo.cz>
parents: 7
diff changeset
    39
	relpipe::writer::string_t name;
8730e2d0db0e suport multiple modes of reading from XML: string, boolean, raw-xml, line-number, xpath
František Kučera <franta-hg@frantovo.cz>
parents: 7
diff changeset
    40
	relpipe::writer::string_t uri;
8730e2d0db0e suport multiple modes of reading from XML: string, boolean, raw-xml, line-number, xpath
František Kučera <franta-hg@frantovo.cz>
parents: 7
diff changeset
    41
	relpipe::writer::string_t prefix;
8730e2d0db0e suport multiple modes of reading from XML: string, boolean, raw-xml, line-number, xpath
František Kučera <franta-hg@frantovo.cz>
parents: 7
diff changeset
    42
8730e2d0db0e suport multiple modes of reading from XML: string, boolean, raw-xml, line-number, xpath
František Kučera <franta-hg@frantovo.cz>
parents: 7
diff changeset
    43
	XmlElementSkeleton() {
8730e2d0db0e suport multiple modes of reading from XML: string, boolean, raw-xml, line-number, xpath
František Kučera <franta-hg@frantovo.cz>
parents: 7
diff changeset
    44
	}
8730e2d0db0e suport multiple modes of reading from XML: string, boolean, raw-xml, line-number, xpath
František Kučera <franta-hg@frantovo.cz>
parents: 7
diff changeset
    45
8730e2d0db0e suport multiple modes of reading from XML: string, boolean, raw-xml, line-number, xpath
František Kučera <franta-hg@frantovo.cz>
parents: 7
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) {
8730e2d0db0e suport multiple modes of reading from XML: string, boolean, raw-xml, line-number, xpath
František Kučera <franta-hg@frantovo.cz>
parents: 7
diff changeset
    47
	}
8730e2d0db0e suport multiple modes of reading from XML: string, boolean, raw-xml, line-number, xpath
František Kučera <franta-hg@frantovo.cz>
parents: 7
diff changeset
    48
8730e2d0db0e suport multiple modes of reading from XML: string, boolean, raw-xml, line-number, xpath
František Kučera <franta-hg@frantovo.cz>
parents: 7
diff changeset
    49
	virtual ~XmlElementSkeleton() {
8730e2d0db0e suport multiple modes of reading from XML: string, boolean, raw-xml, line-number, xpath
František Kučera <franta-hg@frantovo.cz>
parents: 7
diff changeset
    50
	}
8730e2d0db0e suport multiple modes of reading from XML: string, boolean, raw-xml, line-number, xpath
František Kučera <franta-hg@frantovo.cz>
parents: 7
diff changeset
    51
};
8730e2d0db0e suport multiple modes of reading from XML: string, boolean, raw-xml, line-number, xpath
František Kučera <franta-hg@frantovo.cz>
parents: 7
diff changeset
    52
1
7d6ac51c0d48 configuration and CLI parser
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    53
class AttributeRecipe {
7d6ac51c0d48 configuration and CLI parser
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    54
public:
7d6ac51c0d48 configuration and CLI parser
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    55
7d6ac51c0d48 configuration and CLI parser
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    56
	virtual ~AttributeRecipe() {
7d6ac51c0d48 configuration and CLI parser
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    57
	}
7d6ac51c0d48 configuration and CLI parser
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    58
7d6ac51c0d48 configuration and CLI parser
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    59
	relpipe::writer::string_t name;
7d6ac51c0d48 configuration and CLI parser
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    60
	relpipe::writer::TypeId type;
7d6ac51c0d48 configuration and CLI parser
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    61
	relpipe::writer::string_t xpath;
8
8730e2d0db0e suport multiple modes of reading from XML: string, boolean, raw-xml, line-number, xpath
František Kučera <franta-hg@frantovo.cz>
parents: 7
diff changeset
    62
	Mode mode = Mode::STRING;
8730e2d0db0e suport multiple modes of reading from XML: string, boolean, raw-xml, line-number, xpath
František Kučera <franta-hg@frantovo.cz>
parents: 7
diff changeset
    63
	XmlElementSkeleton rawXmlNodeListWrapper;
8730e2d0db0e suport multiple modes of reading from XML: string, boolean, raw-xml, line-number, xpath
František Kučera <franta-hg@frantovo.cz>
parents: 7
diff changeset
    64
	XmlElementSkeleton rawXmlAttributeWrapper;
8730e2d0db0e suport multiple modes of reading from XML: string, boolean, raw-xml, line-number, xpath
František Kučera <franta-hg@frantovo.cz>
parents: 7
diff changeset
    65
1
7d6ac51c0d48 configuration and CLI parser
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    66
};
7d6ac51c0d48 configuration and CLI parser
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    67
7d6ac51c0d48 configuration and CLI parser
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    68
class RelationConfiguration {
7d6ac51c0d48 configuration and CLI parser
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    69
public:
7d6ac51c0d48 configuration and CLI parser
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    70
7d6ac51c0d48 configuration and CLI parser
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    71
	virtual ~RelationConfiguration() {
7d6ac51c0d48 configuration and CLI parser
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    72
	}
7d6ac51c0d48 configuration and CLI parser
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    73
7d6ac51c0d48 configuration and CLI parser
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    74
	relpipe::writer::string_t relation;
2
0d3eb5129582 convert arbitrary XML to one or more relations
František Kučera <franta-hg@frantovo.cz>
parents: 1
diff changeset
    75
	relpipe::writer::boolean_t nameIsXPath = false;
1
7d6ac51c0d48 configuration and CLI parser
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    76
	relpipe::writer::string_t xpath;
7d6ac51c0d48 configuration and CLI parser
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    77
	std::vector<AttributeRecipe> attributes;
8
8730e2d0db0e suport multiple modes of reading from XML: string, boolean, raw-xml, line-number, xpath
František Kučera <franta-hg@frantovo.cz>
parents: 7
diff changeset
    78
8730e2d0db0e suport multiple modes of reading from XML: string, boolean, raw-xml, line-number, xpath
František Kučera <franta-hg@frantovo.cz>
parents: 7
diff changeset
    79
	// Defaults/templates for AttributeRecipe:	
8730e2d0db0e suport multiple modes of reading from XML: string, boolean, raw-xml, line-number, xpath
František Kučera <franta-hg@frantovo.cz>
parents: 7
diff changeset
    80
	Mode mode = Mode::STRING;
8730e2d0db0e suport multiple modes of reading from XML: string, boolean, raw-xml, line-number, xpath
František Kučera <franta-hg@frantovo.cz>
parents: 7
diff changeset
    81
	XmlElementSkeleton rawXmlNodeListWrapper;
8730e2d0db0e suport multiple modes of reading from XML: string, boolean, raw-xml, line-number, xpath
František Kučera <franta-hg@frantovo.cz>
parents: 7
diff changeset
    82
	XmlElementSkeleton rawXmlAttributeWrapper = {L"attribute"};
1
7d6ac51c0d48 configuration and CLI parser
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    83
};
7d6ac51c0d48 configuration and CLI parser
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    84
7d6ac51c0d48 configuration and CLI parser
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    85
class Configuration {
7d6ac51c0d48 configuration and CLI parser
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    86
public:
7d6ac51c0d48 configuration and CLI parser
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    87
	std::vector<RelationConfiguration> relationConfigurations;
7d6ac51c0d48 configuration and CLI parser
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    88
	std::vector<relpipe::writer::string_t> namespaceMappings;
7
ff69af3c67a3 XInclude support – option: --xinclude true
František Kučera <franta-hg@frantovo.cz>
parents: 4
diff changeset
    89
	bool xinclude = false;
1
7d6ac51c0d48 configuration and CLI parser
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    90
7d6ac51c0d48 configuration and CLI parser
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    91
	virtual ~Configuration() {
7d6ac51c0d48 configuration and CLI parser
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    92
	}
7d6ac51c0d48 configuration and CLI parser
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    93
};
7d6ac51c0d48 configuration and CLI parser
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    94
7d6ac51c0d48 configuration and CLI parser
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    95
}
7d6ac51c0d48 configuration and CLI parser
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    96
}
7d6ac51c0d48 configuration and CLI parser
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    97
}