author | František Kučera <franta-hg@frantovo.cz> |
Sun, 02 Dec 2018 18:25:43 +0100 | |
branch | v_0 |
changeset 2 | eb2066405f79 |
parent 0 | a1301a106504 |
child 3 | 8731263d44f1 |
permissions | -rw-r--r-- |
0 | 1 |
/** |
2 |
* Relational pipes |
|
3 |
* Copyright © 2018 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, either version 3 of the License, or |
|
8 |
* (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
17 |
*/ |
|
18 |
||
2
eb2066405f79
reader without any output
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
19 |
#include <cstdlib> |
eb2066405f79
reader without any output
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
20 |
#include <memory> |
eb2066405f79
reader without any output
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
21 |
|
0 | 22 |
#include <relpipe/cli/CLI.h> |
2
eb2066405f79
reader without any output
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
23 |
#include <relpipe/cli/RelpipeCLIException.h> |
eb2066405f79
reader without any output
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
24 |
|
eb2066405f79
reader without any output
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
25 |
#include <relpipe/reader/Factory.h> |
eb2066405f79
reader without any output
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
26 |
#include <relpipe/reader/RelationalReader.h> |
eb2066405f79
reader without any output
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
27 |
#include <relpipe/reader/RelpipeReaderException.h> |
eb2066405f79
reader without any output
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
28 |
|
eb2066405f79
reader without any output
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
29 |
#include <relpipe/writer/RelationalWriter.h> |
eb2066405f79
reader without any output
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
30 |
#include <relpipe/writer/RelpipeWriterException.h> |
eb2066405f79
reader without any output
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
31 |
#include <relpipe/writer/Factory.h> |
eb2066405f79
reader without any output
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
32 |
#include <relpipe/writer/TypeId.h> |
0 | 33 |
|
34 |
using namespace relpipe::cli; |
|
2
eb2066405f79
reader without any output
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
35 |
using namespace relpipe::reader; |
0 | 36 |
|
37 |
int main(int argc, char**argv) { |
|
38 |
CLI cli(argc, argv); |
|
2
eb2066405f79
reader without any output
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
39 |
|
eb2066405f79
reader without any output
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
40 |
int resultCode = CLI::EXIT_CODE_UNEXPECTED_ERROR; |
eb2066405f79
reader without any output
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
41 |
|
eb2066405f79
reader without any output
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
42 |
try { |
eb2066405f79
reader without any output
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
43 |
std::shared_ptr<RelationalReader> reader(Factory::create(std::cin)); |
eb2066405f79
reader without any output
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
44 |
//TabularPrefetchingHandler handler(std::cout); |
eb2066405f79
reader without any output
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
45 |
//reader->addHandler(&handler); |
eb2066405f79
reader without any output
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
46 |
reader->process(); |
eb2066405f79
reader without any output
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
47 |
|
eb2066405f79
reader without any output
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
48 |
resultCode = CLI::EXIT_CODE_SUCCESS; |
eb2066405f79
reader without any output
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
49 |
|
eb2066405f79
reader without any output
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
50 |
} catch (RelpipeCLIException e) { |
eb2066405f79
reader without any output
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
51 |
fwprintf(stderr, L"Caught CLI exception: %ls\n", e.getMessge().c_str()); |
eb2066405f79
reader without any output
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
52 |
fwprintf(stderr, L"Debug: Input stream: eof=%ls, lastRead=%d\n", (cin.eof() ? L"true" : L"false"), cin.gcount()); |
eb2066405f79
reader without any output
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
53 |
resultCode = e.getExitCode(); |
eb2066405f79
reader without any output
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
54 |
} catch (RelpipeReaderException e) { |
eb2066405f79
reader without any output
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
55 |
fwprintf(stderr, L"Caught Reader exception: %ls\n", e.getMessge().c_str()); |
eb2066405f79
reader without any output
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
56 |
fwprintf(stderr, L"Debug: Input stream: eof=%ls, lastRead=%d\n", (cin.eof() ? L"true" : L"false"), cin.gcount()); |
eb2066405f79
reader without any output
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
57 |
resultCode = CLI::EXIT_CODE_DATA_ERROR; |
eb2066405f79
reader without any output
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
58 |
} |
eb2066405f79
reader without any output
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
59 |
|
eb2066405f79
reader without any output
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
60 |
return resultCode; |
0 | 61 |
} |