|
1 /** |
|
2 * Relational pipes |
|
3 * Copyright © 2019 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 #include <cstdlib> |
|
19 #include <fstream> |
|
20 #include <memory> |
|
21 #include <regex> |
|
22 #include <algorithm> |
|
23 #include <unistd.h> |
|
24 |
|
25 #include <libxml++-2.6/libxml++/libxml++.h> |
|
26 |
|
27 #include <relpipe/writer/RelationalWriter.h> |
|
28 #include <relpipe/writer/RelpipeWriterException.h> |
|
29 #include <relpipe/writer/Factory.h> |
|
30 #include <relpipe/writer/TypeId.h> |
|
31 |
|
32 #include <relpipe/cli/CLI.h> |
|
33 |
|
34 #include "XMLTableCommand.h" |
|
35 |
|
36 using namespace relpipe::cli; |
|
37 using namespace relpipe::writer; |
|
38 using namespace relpipe::in::xmltable; |
|
39 |
|
40 int main(int argc, char** argv) { |
|
41 setlocale(LC_ALL, ""); |
|
42 CLI::untieStdIO(); |
|
43 CLI cli(argc, argv); |
|
44 |
|
45 int resultCode = CLI::EXIT_CODE_UNEXPECTED_ERROR; |
|
46 |
|
47 try { |
|
48 XMLCommand command; |
|
49 command.process(cin, cout); |
|
50 resultCode = CLI::EXIT_CODE_SUCCESS; |
|
51 } catch (RelpipeWriterException& e) { |
|
52 fwprintf(stderr, L"Caught Writer exception: %ls\n", e.getMessge().c_str()); |
|
53 fwprintf(stderr, L"Debug: Input stream: eof=%ls, lastRead=%d\n", (cin.eof() ? L"true" : L"false"), cin.gcount()); |
|
54 resultCode = CLI::EXIT_CODE_DATA_ERROR; |
|
55 } // TODO: catch xmlpp::exception |
|
56 |
|
57 return resultCode; |
|
58 } |