|
1 /** |
|
2 * Relational pipes |
|
3 * Copyright © 2021 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 <map> |
|
20 #include <regex> |
|
21 #include <locale> |
|
22 |
|
23 #include <relpipe/common/type/typedefs.h> |
|
24 |
|
25 |
|
26 namespace relpipe { |
|
27 namespace tr { |
|
28 namespace sed { |
|
29 |
|
30 enum class ENTITY { |
|
31 RELATION, |
|
32 ATTRIBUTE, |
|
33 VALUE |
|
34 }; |
|
35 |
|
36 class RewriteRule { |
|
37 public: |
|
38 |
|
39 RewriteRule(std::map<ENTITY, relpipe::common::type::Boolean> caseSensitive, std::map<ENTITY, relpipe::common::type::Boolean> invertMatch) : caseSensitive(caseSensitive), invertMatch(invertMatch) { |
|
40 } |
|
41 |
|
42 virtual ~RewriteRule() { |
|
43 } |
|
44 |
|
45 relpipe::common::type::StringX attribute; |
|
46 relpipe::common::type::StringX value; |
|
47 relpipe::common::type::StringX replacement; |
|
48 std::wregex attributePattern; |
|
49 std::wregex valuePattern; |
|
50 std::map<ENTITY, relpipe::common::type::Boolean> caseSensitive; |
|
51 std::map<ENTITY, relpipe::common::type::Boolean> invertMatch; |
|
52 }; |
|
53 |
|
54 class RelationConfiguration { |
|
55 public: |
|
56 |
|
57 RelationConfiguration() { |
|
58 caseSensitive[ENTITY::RELATION] = true; |
|
59 caseSensitive[ENTITY::ATTRIBUTE] = true; |
|
60 caseSensitive[ENTITY::VALUE] = true; |
|
61 invertMatch[ENTITY::RELATION] = false; |
|
62 invertMatch[ENTITY::ATTRIBUTE] = false; |
|
63 invertMatch[ENTITY::VALUE] = false; |
|
64 } |
|
65 |
|
66 virtual ~RelationConfiguration() { |
|
67 |
|
68 } |
|
69 |
|
70 relpipe::common::type::StringX relation; |
|
71 std::wregex relationPattern; |
|
72 std::vector<RewriteRule> rules; |
|
73 std::map<ENTITY, relpipe::common::type::Boolean> caseSensitive; |
|
74 std::map<ENTITY, relpipe::common::type::Boolean> invertMatch; |
|
75 }; |
|
76 |
|
77 class Configuration { |
|
78 public: |
|
79 std::vector<RelationConfiguration> relationConfigurations; |
|
80 |
|
81 virtual ~Configuration() { |
|
82 } |
|
83 }; |
|
84 |
|
85 } |
|
86 } |
|
87 } |