author | František Kučera <franta-hg@frantovo.cz> |
Fri, 11 Jan 2019 00:29:32 +0100 | |
branch | v_0 |
changeset 2 | 3ab78bf63467 |
parent 0 | 751260846c40 |
child 4 | 1363ec0879ca |
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 |
#include <cstdlib> |
|
19 |
#include <fstream> |
|
20 |
#include <memory> |
|
21 |
#include <regex> |
|
22 |
#include <algorithm> |
|
23 |
#include <unistd.h> |
|
24 |
||
25 |
#include <relpipe/writer/RelationalWriter.h> |
|
26 |
#include <relpipe/writer/RelpipeWriterException.h> |
|
27 |
#include <relpipe/writer/Factory.h> |
|
28 |
#include <relpipe/writer/TypeId.h> |
|
29 |
||
30 |
#include <relpipe/cli/CLI.h> |
|
31 |
||
32 |
#include "XMLCommand.h" |
|
33 |
||
34 |
using namespace relpipe::cli; |
|
35 |
using namespace relpipe::writer; |
|
36 |
using namespace relpipe::in::xml; |
|
37 |
||
38 |
int main(int argc, char** argv) { |
|
39 |
setlocale(LC_ALL, ""); |
|
40 |
CLI::untieStdIO(); |
|
41 |
CLI cli(argc, argv); |
|
42 |
||
43 |
int resultCode = CLI::EXIT_CODE_UNEXPECTED_ERROR; |
|
44 |
||
45 |
try { |
|
46 |
XMLCommand command; |
|
47 |
command.process(cin, cout); |
|
48 |
resultCode = CLI::EXIT_CODE_SUCCESS; |
|
2
3ab78bf63467
read XML from istream using Xerces (just parse/validate, no processing yet)
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
49 |
} catch (RelpipeWriterException& e) { |
0 | 50 |
fwprintf(stderr, L"Caught Writer exception: %ls\n", e.getMessge().c_str()); |
51 |
fwprintf(stderr, L"Debug: Input stream: eof=%ls, lastRead=%d\n", (cin.eof() ? L"true" : L"false"), cin.gcount()); |
|
52 |
resultCode = CLI::EXIT_CODE_DATA_ERROR; |
|
2
3ab78bf63467
read XML from istream using Xerces (just parse/validate, no processing yet)
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
53 |
} catch (const xercesc::XMLException& e) { |
3ab78bf63467
read XML from istream using Xerces (just parse/validate, no processing yet)
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
54 |
// TODO: print message |
3ab78bf63467
read XML from istream using Xerces (just parse/validate, no processing yet)
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
55 |
// char* message = xercesc::XMLString::transcode(e.getMessage()); |
3ab78bf63467
read XML from istream using Xerces (just parse/validate, no processing yet)
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
56 |
fwprintf(stderr, L"Caught xercesc::XMLException\n"); |
3ab78bf63467
read XML from istream using Xerces (just parse/validate, no processing yet)
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
57 |
fwprintf(stderr, L"Debug: Input stream: eof=%ls, lastRead=%d\n", (cin.eof() ? L"true" : L"false"), cin.gcount()); |
3ab78bf63467
read XML from istream using Xerces (just parse/validate, no processing yet)
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
58 |
resultCode = CLI::EXIT_CODE_UNEXPECTED_ERROR; |
0 | 59 |
} |
60 |
||
61 |
return resultCode; |
|
62 |
} |