author | František Kučera <franta-hg@frantovo.cz> |
Sat, 15 May 2021 18:18:10 +0200 | |
branch | v_0 |
changeset 25 | 0cfbaf5c57a6 |
child 26 | 576d4965434f |
permissions | -rw-r--r-- |
25
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
1 |
/** |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
2 |
* Relational pipes |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
3 |
* Copyright © 2021 František Kučera (Frantovo.cz, GlobalCode.info) |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
4 |
* |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
5 |
* This program is free software: you can redistribute it and/or modify |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
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 |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
7 |
* the Free Software Foundation, version 3 of the License. |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
8 |
* |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
9 |
* This program is distributed in the hope that it will be useful, |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
12 |
* GNU General Public License for more details. |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
13 |
* |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
14 |
* You should have received a copy of the GNU General Public License |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
15 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
16 |
*/ |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
17 |
#pragma once |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
18 |
|
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
19 |
#include <map> |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
20 |
#include <regex> |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
21 |
#include <locale> |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
22 |
|
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
23 |
#include <relpipe/common/type/typedefs.h> |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
24 |
|
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
25 |
|
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
26 |
namespace relpipe { |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
27 |
namespace tr { |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
28 |
namespace sed { |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
29 |
|
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
30 |
enum class ENTITY { |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
31 |
RELATION, |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
32 |
ATTRIBUTE, |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
33 |
VALUE |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
34 |
}; |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
35 |
|
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
36 |
class RewriteRule { |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
37 |
public: |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
38 |
|
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
39 |
RewriteRule(std::map<ENTITY, relpipe::common::type::Boolean> caseSensitive, std::map<ENTITY, relpipe::common::type::Boolean> invertMatch) : caseSensitive(caseSensitive), invertMatch(invertMatch) { |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
40 |
} |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
41 |
|
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
42 |
virtual ~RewriteRule() { |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
43 |
} |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
44 |
|
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
45 |
relpipe::common::type::StringX attribute; |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
46 |
relpipe::common::type::StringX value; |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
47 |
relpipe::common::type::StringX replacement; |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
48 |
std::wregex attributePattern; |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
49 |
std::wregex valuePattern; |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
50 |
std::map<ENTITY, relpipe::common::type::Boolean> caseSensitive; |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
51 |
std::map<ENTITY, relpipe::common::type::Boolean> invertMatch; |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
52 |
}; |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
53 |
|
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
54 |
class RelationConfiguration { |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
55 |
public: |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
56 |
|
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
57 |
RelationConfiguration() { |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
58 |
caseSensitive[ENTITY::RELATION] = true; |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
59 |
caseSensitive[ENTITY::ATTRIBUTE] = true; |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
60 |
caseSensitive[ENTITY::VALUE] = true; |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
61 |
invertMatch[ENTITY::RELATION] = false; |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
62 |
invertMatch[ENTITY::ATTRIBUTE] = false; |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
63 |
invertMatch[ENTITY::VALUE] = false; |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
64 |
} |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
65 |
|
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
66 |
virtual ~RelationConfiguration() { |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
67 |
|
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
68 |
} |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
69 |
|
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
70 |
relpipe::common::type::StringX relation; |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
71 |
std::wregex relationPattern; |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
72 |
std::vector<RewriteRule> rules; |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
73 |
std::map<ENTITY, relpipe::common::type::Boolean> caseSensitive; |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
74 |
std::map<ENTITY, relpipe::common::type::Boolean> invertMatch; |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
75 |
}; |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
76 |
|
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
77 |
class Configuration { |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
78 |
public: |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
79 |
std::vector<RelationConfiguration> relationConfigurations; |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
80 |
|
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
81 |
virtual ~Configuration() { |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
82 |
} |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
83 |
}; |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
84 |
|
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
85 |
} |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
86 |
} |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
87 |
} |