24 #include <relpipe/reader/Factory.h> |
24 #include <relpipe/reader/Factory.h> |
25 #include <relpipe/reader/RelationalReader.h> |
25 #include <relpipe/reader/RelationalReader.h> |
26 #include <relpipe/reader/RelpipeReaderException.h> |
26 #include <relpipe/reader/RelpipeReaderException.h> |
27 |
27 |
28 #include "PosixMQHandler.h" |
28 #include "PosixMQHandler.h" |
|
29 #include "CLIParser.h" |
|
30 #include "Configuration.h" |
29 |
31 |
30 using namespace relpipe::cli; |
32 using namespace relpipe::cli; |
31 using namespace relpipe::reader; |
33 using namespace relpipe::reader; |
32 using namespace relpipe::out::posixmq; |
34 using namespace relpipe::out::posixmq; |
33 |
35 |
34 int main(int argc, char**argv) { |
36 int main(int argc, char**argv) { |
|
37 setlocale(LC_ALL, ""); |
|
38 CLI::untieStdIO(); |
35 CLI cli(argc, argv); |
39 CLI cli(argc, argv); |
36 CLI::untieStdIO(); |
40 |
37 |
|
38 int resultCode = CLI::EXIT_CODE_UNEXPECTED_ERROR; |
41 int resultCode = CLI::EXIT_CODE_UNEXPECTED_ERROR; |
39 |
42 |
40 try { |
43 try { |
|
44 CLIParser cliParser; |
|
45 Configuration configuration = cliParser.parse(cli.arguments()); |
41 std::shared_ptr<RelationalReader> reader(Factory::create(std::cin)); |
46 std::shared_ptr<RelationalReader> reader(Factory::create(std::cin)); |
42 PosixMQHandler handler(std::cout); |
47 PosixMQHandler handler(configuration); |
43 reader->addHandler(&handler); |
48 reader->addHandler(&handler); |
44 reader->process(); |
49 reader->process(); |
45 |
|
46 resultCode = CLI::EXIT_CODE_SUCCESS; |
50 resultCode = CLI::EXIT_CODE_SUCCESS; |
47 |
|
48 } catch (RelpipeCLIException e) { |
51 } catch (RelpipeCLIException e) { |
49 fwprintf(stderr, L"Caught CLI exception: %ls\n", e.getMessage().c_str()); |
52 fwprintf(stderr, L"Caught CLI exception: %ls\n", e.getMessage().c_str()); |
50 fwprintf(stderr, L"Debug: Input stream: eof=%ls, lastRead=%d\n", (cin.eof() ? L"true" : L"false"), cin.gcount()); |
53 fwprintf(stderr, L"Debug: Input stream: eof=%ls, lastRead=%d\n", (cin.eof() ? L"true" : L"false"), cin.gcount()); |
51 resultCode = e.getExitCode(); |
54 resultCode = e.getExitCode(); |
52 } catch (RelpipeReaderException e) { |
55 } catch (RelpipeReaderException e) { |