author | František Kučera <franta-hg@frantovo.cz> |
Sat, 05 Dec 2020 19:32:05 +0100 | |
branch | v_0 |
changeset 4 | c176766462c5 |
parent 1 | 8d2d8f4077af |
child 10 | 15a151aa93b1 |
permissions | -rw-r--r-- |
0 | 1 |
/** |
2 |
* Relational pipes |
|
1
8d2d8f4077af
OOP wrapper for yaml.h + list event types
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
3 |
* Copyright © 2020 František Kučera (Frantovo.cz, GlobalCode.info) |
0 | 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 |
#include <cstdlib> |
|
18 |
#include <fstream> |
|
19 |
#include <memory> |
|
20 |
||
21 |
#include <relpipe/writer/RelationalWriter.h> |
|
22 |
#include <relpipe/writer/RelpipeWriterException.h> |
|
23 |
#include <relpipe/writer/Factory.h> |
|
24 |
#include <relpipe/writer/TypeId.h> |
|
25 |
||
26 |
#include <relpipe/cli/CLI.h> |
|
27 |
||
28 |
#include "YAMLCommand.h" |
|
29 |
||
30 |
using namespace relpipe::cli; |
|
31 |
using namespace relpipe::writer; |
|
32 |
using namespace relpipe::in::yaml; |
|
33 |
||
34 |
int main(int argc, char** argv) { |
|
35 |
setlocale(LC_ALL, ""); |
|
36 |
CLI::untieStdIO(); |
|
37 |
CLI cli(argc, argv); |
|
38 |
||
39 |
int resultCode = CLI::EXIT_CODE_UNEXPECTED_ERROR; |
|
40 |
||
41 |
try { |
|
42 |
YAMLCommand command; |
|
43 |
std::shared_ptr<RelationalWriter> writer(Factory::create(std::cout)); |
|
44 |
command.process(cin, writer); |
|
45 |
resultCode = CLI::EXIT_CODE_SUCCESS; |
|
46 |
} catch (RelpipeWriterException& e) { |
|
47 |
fwprintf(stderr, L"Caught Writer exception: %ls\n", e.getMessge().c_str()); |
|
48 |
fwprintf(stderr, L"Debug: Input stream: eof=%ls, lastRead=%d\n", (cin.eof() ? L"true" : L"false"), cin.gcount()); |
|
49 |
resultCode = CLI::EXIT_CODE_DATA_ERROR; |
|
50 |
} |
|
51 |
||
52 |
return resultCode; |
|
53 |
} |