author | František Kučera <franta-hg@frantovo.cz> |
Tue, 13 Dec 2022 02:07:00 +0100 | |
branch | v_0 |
changeset 3 | 202ce847990c |
parent 2 | 8a30971d285f |
permissions | -rw-r--r-- |
0
7727b4d5560d
new module: relpipe-out-sql
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
1 |
/** |
7727b4d5560d
new module: relpipe-out-sql
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
2 |
* Relational pipes |
7727b4d5560d
new module: relpipe-out-sql
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
3 |
* Copyright © 2022 František Kučera (Frantovo.cz, GlobalCode.info) |
7727b4d5560d
new module: relpipe-out-sql
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
4 |
* |
7727b4d5560d
new module: relpipe-out-sql
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
5 |
* This program is free software: you can redistribute it and/or modify |
7727b4d5560d
new module: relpipe-out-sql
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 |
7727b4d5560d
new module: relpipe-out-sql
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
7 |
* the Free Software Foundation, version 3 of the License. |
7727b4d5560d
new module: relpipe-out-sql
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
8 |
* |
7727b4d5560d
new module: relpipe-out-sql
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
9 |
* This program is distributed in the hope that it will be useful, |
7727b4d5560d
new module: relpipe-out-sql
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
7727b4d5560d
new module: relpipe-out-sql
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
7727b4d5560d
new module: relpipe-out-sql
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
12 |
* GNU General Public License for more details. |
7727b4d5560d
new module: relpipe-out-sql
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
13 |
* |
7727b4d5560d
new module: relpipe-out-sql
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
14 |
* You should have received a copy of the GNU General Public License |
7727b4d5560d
new module: relpipe-out-sql
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
15 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
7727b4d5560d
new module: relpipe-out-sql
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
16 |
*/ |
7727b4d5560d
new module: relpipe-out-sql
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
17 |
#pragma once |
7727b4d5560d
new module: relpipe-out-sql
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
18 |
|
7727b4d5560d
new module: relpipe-out-sql
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
19 |
#include <vector> |
7727b4d5560d
new module: relpipe-out-sql
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
20 |
#include <iostream> |
3
202ce847990c
configuration: --write-ddl, --write-dml, --write-column-names, --insert-mode, --type-cast
František Kučera <franta-hg@frantovo.cz>
parents:
2
diff
changeset
|
21 |
#include <regex> |
0
7727b4d5560d
new module: relpipe-out-sql
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
22 |
|
3
202ce847990c
configuration: --write-ddl, --write-dml, --write-column-names, --insert-mode, --type-cast
František Kučera <franta-hg@frantovo.cz>
parents:
2
diff
changeset
|
23 |
#include <relpipe/common/type/typedefs.h> |
0
7727b4d5560d
new module: relpipe-out-sql
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
24 |
#include <relpipe/reader/typedefs.h> |
7727b4d5560d
new module: relpipe-out-sql
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
25 |
|
7727b4d5560d
new module: relpipe-out-sql
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
26 |
|
7727b4d5560d
new module: relpipe-out-sql
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
27 |
namespace relpipe { |
7727b4d5560d
new module: relpipe-out-sql
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
28 |
namespace out { |
7727b4d5560d
new module: relpipe-out-sql
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
29 |
namespace sql { |
7727b4d5560d
new module: relpipe-out-sql
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
30 |
|
7727b4d5560d
new module: relpipe-out-sql
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
31 |
class Configuration { |
7727b4d5560d
new module: relpipe-out-sql
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
32 |
public: |
2
8a30971d285f
insert multiple records at once – first version
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
33 |
|
8a30971d285f
insert multiple records at once – first version
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
34 |
enum class InsertMode { |
3
202ce847990c
configuration: --write-ddl, --write-dml, --write-column-names, --insert-mode, --type-cast
František Kučera <franta-hg@frantovo.cz>
parents:
2
diff
changeset
|
35 |
DEFAULT, |
2
8a30971d285f
insert multiple records at once – first version
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
36 |
SINGLE, |
8a30971d285f
insert multiple records at once – first version
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
37 |
MULTI, |
8a30971d285f
insert multiple records at once – first version
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
38 |
}; |
8a30971d285f
insert multiple records at once – first version
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
39 |
|
3
202ce847990c
configuration: --write-ddl, --write-dml, --write-column-names, --insert-mode, --type-cast
František Kučera <franta-hg@frantovo.cz>
parents:
2
diff
changeset
|
40 |
class TypeCastRule { |
202ce847990c
configuration: --write-ddl, --write-dml, --write-column-names, --insert-mode, --type-cast
František Kučera <franta-hg@frantovo.cz>
parents:
2
diff
changeset
|
41 |
public: |
202ce847990c
configuration: --write-ddl, --write-dml, --write-column-names, --insert-mode, --type-cast
František Kučera <franta-hg@frantovo.cz>
parents:
2
diff
changeset
|
42 |
|
202ce847990c
configuration: --write-ddl, --write-dml, --write-column-names, --insert-mode, --type-cast
František Kučera <franta-hg@frantovo.cz>
parents:
2
diff
changeset
|
43 |
std::wregex attribute = std::wregex(L".*"); |
202ce847990c
configuration: --write-ddl, --write-dml, --write-column-names, --insert-mode, --type-cast
František Kučera <franta-hg@frantovo.cz>
parents:
2
diff
changeset
|
44 |
std::wregex type = std::wregex(L".*"); |
202ce847990c
configuration: --write-ddl, --write-dml, --write-column-names, --insert-mode, --type-cast
František Kučera <franta-hg@frantovo.cz>
parents:
2
diff
changeset
|
45 |
relpipe::common::type::StringX sqlType; |
202ce847990c
configuration: --write-ddl, --write-dml, --write-column-names, --insert-mode, --type-cast
František Kučera <franta-hg@frantovo.cz>
parents:
2
diff
changeset
|
46 |
}; |
202ce847990c
configuration: --write-ddl, --write-dml, --write-column-names, --insert-mode, --type-cast
František Kučera <franta-hg@frantovo.cz>
parents:
2
diff
changeset
|
47 |
|
202ce847990c
configuration: --write-ddl, --write-dml, --write-column-names, --insert-mode, --type-cast
František Kučera <franta-hg@frantovo.cz>
parents:
2
diff
changeset
|
48 |
class RelationConfiguration { |
202ce847990c
configuration: --write-ddl, --write-dml, --write-column-names, --insert-mode, --type-cast
František Kučera <franta-hg@frantovo.cz>
parents:
2
diff
changeset
|
49 |
public: |
202ce847990c
configuration: --write-ddl, --write-dml, --write-column-names, --insert-mode, --type-cast
František Kučera <franta-hg@frantovo.cz>
parents:
2
diff
changeset
|
50 |
relpipe::common::type::StringX relation; |
202ce847990c
configuration: --write-ddl, --write-dml, --write-column-names, --insert-mode, --type-cast
František Kučera <franta-hg@frantovo.cz>
parents:
2
diff
changeset
|
51 |
std::wregex relationPattern; |
202ce847990c
configuration: --write-ddl, --write-dml, --write-column-names, --insert-mode, --type-cast
František Kučera <franta-hg@frantovo.cz>
parents:
2
diff
changeset
|
52 |
relpipe::common::type::Boolean writeDDL = true; |
202ce847990c
configuration: --write-ddl, --write-dml, --write-column-names, --insert-mode, --type-cast
František Kučera <franta-hg@frantovo.cz>
parents:
2
diff
changeset
|
53 |
relpipe::common::type::Boolean writeDML = true; |
202ce847990c
configuration: --write-ddl, --write-dml, --write-column-names, --insert-mode, --type-cast
František Kučera <franta-hg@frantovo.cz>
parents:
2
diff
changeset
|
54 |
relpipe::common::type::Boolean writeColumnNames = true; |
202ce847990c
configuration: --write-ddl, --write-dml, --write-column-names, --insert-mode, --type-cast
František Kučera <franta-hg@frantovo.cz>
parents:
2
diff
changeset
|
55 |
std::vector<TypeCastRule> typeCastRules; |
202ce847990c
configuration: --write-ddl, --write-dml, --write-column-names, --insert-mode, --type-cast
František Kučera <franta-hg@frantovo.cz>
parents:
2
diff
changeset
|
56 |
InsertMode insertMode = InsertMode::DEFAULT; |
202ce847990c
configuration: --write-ddl, --write-dml, --write-column-names, --insert-mode, --type-cast
František Kučera <franta-hg@frantovo.cz>
parents:
2
diff
changeset
|
57 |
}; |
202ce847990c
configuration: --write-ddl, --write-dml, --write-column-names, --insert-mode, --type-cast
František Kučera <franta-hg@frantovo.cz>
parents:
2
diff
changeset
|
58 |
|
202ce847990c
configuration: --write-ddl, --write-dml, --write-column-names, --insert-mode, --type-cast
František Kučera <franta-hg@frantovo.cz>
parents:
2
diff
changeset
|
59 |
std::vector<RelationConfiguration> relationConfigurations; |
0
7727b4d5560d
new module: relpipe-out-sql
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
60 |
|
7727b4d5560d
new module: relpipe-out-sql
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
61 |
virtual ~Configuration() { |
7727b4d5560d
new module: relpipe-out-sql
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
62 |
} |
7727b4d5560d
new module: relpipe-out-sql
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
63 |
}; |
7727b4d5560d
new module: relpipe-out-sql
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
64 |
|
7727b4d5560d
new module: relpipe-out-sql
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
65 |
} |
7727b4d5560d
new module: relpipe-out-sql
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
66 |
} |
7727b4d5560d
new module: relpipe-out-sql
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
67 |
} |