author | František Kučera <franta-hg@frantovo.cz> |
Sat, 27 Nov 2021 23:15:18 +0100 | |
branch | v_0 |
changeset 45 | b6f2740617e4 |
parent 35 | eafffeea6a3e |
permissions | -rw-r--r-- |
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 |
|
35
eafffeea6a3e
fix license version: GNU GPLv3
František Kučera <franta-hg@frantovo.cz>
parents:
33
diff
changeset
|
7 |
* the Free Software Foundation, version 3 of the License. |
0 | 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 <relpipe/writer/AttributeMetadata.h> |
|
20 |
#include <relpipe/writer/typedefs.h> |
|
21 |
||
22 |
namespace relpipe { |
|
23 |
namespace tr { |
|
24 |
namespace awk { |
|
25 |
||
8
513ea30d2fa3
more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
26 |
class DefinitionRecipe { |
513ea30d2fa3
more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
27 |
public: |
513ea30d2fa3
more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
28 |
|
513ea30d2fa3
more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
29 |
virtual ~DefinitionRecipe() { |
513ea30d2fa3
more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
30 |
} |
513ea30d2fa3
more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
31 |
|
513ea30d2fa3
more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
32 |
relpipe::writer::string_t name; |
513ea30d2fa3
more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
33 |
relpipe::writer::string_t type; |
513ea30d2fa3
more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
34 |
relpipe::writer::string_t value; |
513ea30d2fa3
more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
35 |
}; |
513ea30d2fa3
more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
36 |
|
513ea30d2fa3
more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
37 |
class RelationConfiguration { |
513ea30d2fa3
more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
38 |
public: |
513ea30d2fa3
more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
39 |
|
513ea30d2fa3
more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
40 |
virtual ~RelationConfiguration() { |
513ea30d2fa3
more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
41 |
} |
513ea30d2fa3
more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
42 |
|
513ea30d2fa3
more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
43 |
relpipe::writer::string_t relation; |
513ea30d2fa3
more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
44 |
relpipe::writer::string_t awkBeforeRecords; |
513ea30d2fa3
more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
45 |
relpipe::writer::string_t awkAfterRecords; |
513ea30d2fa3
more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
46 |
relpipe::writer::string_t awkForEach; |
513ea30d2fa3
more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
47 |
|
513ea30d2fa3
more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
48 |
/** |
26
cf57e8c78492
add option: --debug-variable-mapping
František Kučera <franta-hg@frantovo.cz>
parents:
19
diff
changeset
|
49 |
* If true, additional relation will be generated: mapping between relpipe attribute names and AWK variable names |
cf57e8c78492
add option: --debug-variable-mapping
František Kučera <franta-hg@frantovo.cz>
parents:
19
diff
changeset
|
50 |
*/ |
cf57e8c78492
add option: --debug-variable-mapping
František Kučera <franta-hg@frantovo.cz>
parents:
19
diff
changeset
|
51 |
bool debugVariableMapping = false; |
cf57e8c78492
add option: --debug-variable-mapping
František Kučera <franta-hg@frantovo.cz>
parents:
19
diff
changeset
|
52 |
|
cf57e8c78492
add option: --debug-variable-mapping
František Kučera <franta-hg@frantovo.cz>
parents:
19
diff
changeset
|
53 |
/** |
19
e4558df9ba2d
drop – run AWK code but generate no output for given relation
František Kučera <franta-hg@frantovo.cz>
parents:
8
diff
changeset
|
54 |
* If true, AWK code will be executed, but no output will be generated. |
e4558df9ba2d
drop – run AWK code but generate no output for given relation
František Kučera <franta-hg@frantovo.cz>
parents:
8
diff
changeset
|
55 |
*/ |
e4558df9ba2d
drop – run AWK code but generate no output for given relation
František Kučera <franta-hg@frantovo.cz>
parents:
8
diff
changeset
|
56 |
bool drop = false; |
e4558df9ba2d
drop – run AWK code but generate no output for given relation
František Kučera <franta-hg@frantovo.cz>
parents:
8
diff
changeset
|
57 |
|
e4558df9ba2d
drop – run AWK code but generate no output for given relation
František Kučera <franta-hg@frantovo.cz>
parents:
8
diff
changeset
|
58 |
/** |
8
513ea30d2fa3
more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
59 |
* Variable definitions for this relation. |
513ea30d2fa3
more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
60 |
* Can be used as a safe way for passing parameters from the outside environment. |
513ea30d2fa3
more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
61 |
* See also Configuration::definitions (can be overridden by relation's definitions) |
513ea30d2fa3
more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
62 |
*/ |
513ea30d2fa3
more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
63 |
std::vector<DefinitionRecipe> definitions; |
513ea30d2fa3
more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
64 |
|
513ea30d2fa3
more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
65 |
/** |
513ea30d2fa3
more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
66 |
* If empty, output relation will have same metadata as the input relation. |
513ea30d2fa3
more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
67 |
*/ |
513ea30d2fa3
more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
68 |
std::vector<relpipe::writer::AttributeMetadata> writerMetadata; |
513ea30d2fa3
more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
69 |
|
513ea30d2fa3
more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
70 |
/** |
513ea30d2fa3
more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
71 |
* Whether original attributes should be appended to those specified using --output-attribute |
513ea30d2fa3
more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
72 |
*/ |
513ea30d2fa3
more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
73 |
bool inputAttributesAppend = false; |
513ea30d2fa3
more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
74 |
|
513ea30d2fa3
more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
75 |
/** |
513ea30d2fa3
more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
76 |
* Whether original attributes should be prepended to those specified using --output-attribute |
513ea30d2fa3
more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
77 |
*/ |
513ea30d2fa3
more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
78 |
bool inputAttributesPrepend = false; |
513ea30d2fa3
more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
79 |
}; |
513ea30d2fa3
more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
80 |
|
0 | 81 |
class Configuration { |
82 |
public: |
|
83 |
||
33
5288af2e4921
namespace, formatting
František Kučera <franta-hg@frantovo.cz>
parents:
26
diff
changeset
|
84 |
std::vector<RelationConfiguration> relationConfigurations; |
8
513ea30d2fa3
more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
85 |
|
513ea30d2fa3
more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
86 |
/** |
513ea30d2fa3
more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
87 |
* Global definitions for all relations. |
513ea30d2fa3
more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
88 |
* Can be used as a safe way for passing parameters from the outside environment. |
513ea30d2fa3
more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
89 |
* See also RelationConfiguration::definitions |
513ea30d2fa3
more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
90 |
*/ |
513ea30d2fa3
more configuration/options
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
91 |
std::vector<DefinitionRecipe> definitions; |
0 | 92 |
|
93 |
virtual ~Configuration() { |
|
94 |
} |
|
95 |
}; |
|
96 |
||
97 |
} |
|
98 |
} |
|
99 |
} |