14 * |
14 * |
15 * You should have received a copy of the GNU General Public License |
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/>. |
16 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 */ |
17 */ |
18 |
18 |
|
19 #include <cstdlib> |
|
20 #include <memory> |
|
21 |
19 #include <relpipe/cli/CLI.h> |
22 #include <relpipe/cli/CLI.h> |
|
23 #include <relpipe/cli/RelpipeCLIException.h> |
|
24 |
|
25 #include <relpipe/reader/Factory.h> |
|
26 #include <relpipe/reader/RelationalReader.h> |
|
27 #include <relpipe/reader/RelpipeReaderException.h> |
|
28 |
|
29 #include <relpipe/writer/RelationalWriter.h> |
|
30 #include <relpipe/writer/RelpipeWriterException.h> |
|
31 #include <relpipe/writer/Factory.h> |
|
32 #include <relpipe/writer/TypeId.h> |
20 |
33 |
21 using namespace relpipe::cli; |
34 using namespace relpipe::cli; |
|
35 using namespace relpipe::reader; |
22 |
36 |
23 int main(int argc, char**argv) { |
37 int main(int argc, char**argv) { |
24 CLI cli(argc, argv); |
38 CLI cli(argc, argv); |
25 return 1; |
39 |
|
40 int resultCode = CLI::EXIT_CODE_UNEXPECTED_ERROR; |
|
41 |
|
42 try { |
|
43 std::shared_ptr<RelationalReader> reader(Factory::create(std::cin)); |
|
44 //TabularPrefetchingHandler handler(std::cout); |
|
45 //reader->addHandler(&handler); |
|
46 reader->process(); |
|
47 |
|
48 resultCode = CLI::EXIT_CODE_SUCCESS; |
|
49 |
|
50 } catch (RelpipeCLIException e) { |
|
51 fwprintf(stderr, L"Caught CLI exception: %ls\n", e.getMessge().c_str()); |
|
52 fwprintf(stderr, L"Debug: Input stream: eof=%ls, lastRead=%d\n", (cin.eof() ? L"true" : L"false"), cin.gcount()); |
|
53 resultCode = e.getExitCode(); |
|
54 } catch (RelpipeReaderException e) { |
|
55 fwprintf(stderr, L"Caught Reader exception: %ls\n", e.getMessge().c_str()); |
|
56 fwprintf(stderr, L"Debug: Input stream: eof=%ls, lastRead=%d\n", (cin.eof() ? L"true" : L"false"), cin.gcount()); |
|
57 resultCode = CLI::EXIT_CODE_DATA_ERROR; |
|
58 } |
|
59 |
|
60 return resultCode; |
26 } |
61 } |