author | František Kučera <franta-hg@frantovo.cz> |
Sun, 14 May 2023 02:13:46 +0200 | |
branch | v_0 |
changeset 1 | e82aaf24b0fe |
parent 0 | 71b902e1c5ee |
permissions | -rw-r--r-- |
0
71b902e1c5ee
project skeleton (taken from relpipe-in-xmltable)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
1 |
/** |
71b902e1c5ee
project skeleton (taken from relpipe-in-xmltable)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
2 |
* Relational pipes |
1
e82aaf24b0fe
first version, prototype, works sometimes
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
3 |
* Copyright © 2023 František Kučera (Frantovo.cz, GlobalCode.info) |
0
71b902e1c5ee
project skeleton (taken from relpipe-in-xmltable)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
4 |
* |
71b902e1c5ee
project skeleton (taken from relpipe-in-xmltable)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
5 |
* This program is free software: you can redistribute it and/or modify |
71b902e1c5ee
project skeleton (taken from relpipe-in-xmltable)
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 |
71b902e1c5ee
project skeleton (taken from relpipe-in-xmltable)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
7 |
* the Free Software Foundation, version 3 of the License. |
71b902e1c5ee
project skeleton (taken from relpipe-in-xmltable)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
8 |
* |
71b902e1c5ee
project skeleton (taken from relpipe-in-xmltable)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
9 |
* This program is distributed in the hope that it will be useful, |
71b902e1c5ee
project skeleton (taken from relpipe-in-xmltable)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
71b902e1c5ee
project skeleton (taken from relpipe-in-xmltable)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
71b902e1c5ee
project skeleton (taken from relpipe-in-xmltable)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
12 |
* GNU General Public License for more details. |
71b902e1c5ee
project skeleton (taken from relpipe-in-xmltable)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
13 |
* |
71b902e1c5ee
project skeleton (taken from relpipe-in-xmltable)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
14 |
* You should have received a copy of the GNU General Public License |
71b902e1c5ee
project skeleton (taken from relpipe-in-xmltable)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
15 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
71b902e1c5ee
project skeleton (taken from relpipe-in-xmltable)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
16 |
*/ |
71b902e1c5ee
project skeleton (taken from relpipe-in-xmltable)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
17 |
#include <cstdlib> |
71b902e1c5ee
project skeleton (taken from relpipe-in-xmltable)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
18 |
#include <fstream> |
71b902e1c5ee
project skeleton (taken from relpipe-in-xmltable)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
19 |
#include <memory> |
71b902e1c5ee
project skeleton (taken from relpipe-in-xmltable)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
20 |
#include <regex> |
71b902e1c5ee
project skeleton (taken from relpipe-in-xmltable)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
21 |
#include <algorithm> |
71b902e1c5ee
project skeleton (taken from relpipe-in-xmltable)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
22 |
#include <unistd.h> |
71b902e1c5ee
project skeleton (taken from relpipe-in-xmltable)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
23 |
|
71b902e1c5ee
project skeleton (taken from relpipe-in-xmltable)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
24 |
#include <relpipe/writer/RelationalWriter.h> |
71b902e1c5ee
project skeleton (taken from relpipe-in-xmltable)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
25 |
#include <relpipe/writer/RelpipeWriterException.h> |
71b902e1c5ee
project skeleton (taken from relpipe-in-xmltable)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
26 |
#include <relpipe/writer/Factory.h> |
71b902e1c5ee
project skeleton (taken from relpipe-in-xmltable)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
27 |
#include <relpipe/writer/TypeId.h> |
71b902e1c5ee
project skeleton (taken from relpipe-in-xmltable)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
28 |
|
71b902e1c5ee
project skeleton (taken from relpipe-in-xmltable)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
29 |
#include <relpipe/cli/CLI.h> |
71b902e1c5ee
project skeleton (taken from relpipe-in-xmltable)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
30 |
|
1
e82aaf24b0fe
first version, prototype, works sometimes
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
31 |
#include "ODSCommand.h" |
0
71b902e1c5ee
project skeleton (taken from relpipe-in-xmltable)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
32 |
|
71b902e1c5ee
project skeleton (taken from relpipe-in-xmltable)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
33 |
using namespace relpipe::cli; |
71b902e1c5ee
project skeleton (taken from relpipe-in-xmltable)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
34 |
using namespace relpipe::writer; |
1
e82aaf24b0fe
first version, prototype, works sometimes
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
35 |
using namespace relpipe::in::ods; |
0
71b902e1c5ee
project skeleton (taken from relpipe-in-xmltable)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
36 |
|
71b902e1c5ee
project skeleton (taken from relpipe-in-xmltable)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
37 |
int main(int argc, char** argv) { |
71b902e1c5ee
project skeleton (taken from relpipe-in-xmltable)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
38 |
setlocale(LC_ALL, ""); |
71b902e1c5ee
project skeleton (taken from relpipe-in-xmltable)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
39 |
CLI::untieStdIO(); |
71b902e1c5ee
project skeleton (taken from relpipe-in-xmltable)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
40 |
CLI cli(argc, argv); |
71b902e1c5ee
project skeleton (taken from relpipe-in-xmltable)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
41 |
|
71b902e1c5ee
project skeleton (taken from relpipe-in-xmltable)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
42 |
int resultCode = CLI::EXIT_CODE_UNEXPECTED_ERROR; |
71b902e1c5ee
project skeleton (taken from relpipe-in-xmltable)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
43 |
|
71b902e1c5ee
project skeleton (taken from relpipe-in-xmltable)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
44 |
try { |
1
e82aaf24b0fe
first version, prototype, works sometimes
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
45 |
std::shared_ptr<RelationalWriter> writer(Factory::create(cout)); |
e82aaf24b0fe
first version, prototype, works sometimes
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
46 |
ODSCommand command(writer); |
e82aaf24b0fe
first version, prototype, works sometimes
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
47 |
command.process(cin); |
0
71b902e1c5ee
project skeleton (taken from relpipe-in-xmltable)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
48 |
resultCode = CLI::EXIT_CODE_SUCCESS; |
71b902e1c5ee
project skeleton (taken from relpipe-in-xmltable)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
49 |
} catch (RelpipeWriterException& e) { |
71b902e1c5ee
project skeleton (taken from relpipe-in-xmltable)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
50 |
fwprintf(stderr, L"Caught Writer exception: %ls\n", e.getMessage().c_str()); |
71b902e1c5ee
project skeleton (taken from relpipe-in-xmltable)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
51 |
fwprintf(stderr, L"Debug: Input stream: eof=%ls, lastRead=%d\n", (cin.eof() ? L"true" : L"false"), cin.gcount()); |
71b902e1c5ee
project skeleton (taken from relpipe-in-xmltable)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
52 |
resultCode = CLI::EXIT_CODE_DATA_ERROR; |
71b902e1c5ee
project skeleton (taken from relpipe-in-xmltable)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
53 |
} // TODO: catch xmlpp::exception |
71b902e1c5ee
project skeleton (taken from relpipe-in-xmltable)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
54 |
|
71b902e1c5ee
project skeleton (taken from relpipe-in-xmltable)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
55 |
return resultCode; |
71b902e1c5ee
project skeleton (taken from relpipe-in-xmltable)
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
56 |
} |