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