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