--- a/src/relpipe-tr-validator.cpp Sun Dec 02 18:17:52 2018 +0100
+++ b/src/relpipe-tr-validator.cpp Sun Dec 02 18:25:43 2018 +0100
@@ -16,11 +16,46 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <cstdlib>
+#include <memory>
+
#include <relpipe/cli/CLI.h>
+#include <relpipe/cli/RelpipeCLIException.h>
+
+#include <relpipe/reader/Factory.h>
+#include <relpipe/reader/RelationalReader.h>
+#include <relpipe/reader/RelpipeReaderException.h>
+
+#include <relpipe/writer/RelationalWriter.h>
+#include <relpipe/writer/RelpipeWriterException.h>
+#include <relpipe/writer/Factory.h>
+#include <relpipe/writer/TypeId.h>
using namespace relpipe::cli;
+using namespace relpipe::reader;
int main(int argc, char**argv) {
CLI cli(argc, argv);
- return 1;
+
+ int resultCode = CLI::EXIT_CODE_UNEXPECTED_ERROR;
+
+ try {
+ std::shared_ptr<RelationalReader> reader(Factory::create(std::cin));
+ //TabularPrefetchingHandler handler(std::cout);
+ //reader->addHandler(&handler);
+ reader->process();
+
+ resultCode = CLI::EXIT_CODE_SUCCESS;
+
+ } catch (RelpipeCLIException e) {
+ fwprintf(stderr, L"Caught CLI exception: %ls\n", e.getMessge().c_str());
+ fwprintf(stderr, L"Debug: Input stream: eof=%ls, lastRead=%d\n", (cin.eof() ? L"true" : L"false"), cin.gcount());
+ resultCode = e.getExitCode();
+ } catch (RelpipeReaderException e) {
+ fwprintf(stderr, L"Caught Reader exception: %ls\n", e.getMessge().c_str());
+ fwprintf(stderr, L"Debug: Input stream: eof=%ls, lastRead=%d\n", (cin.eof() ? L"true" : L"false"), cin.gcount());
+ resultCode = CLI::EXIT_CODE_DATA_ERROR;
+ }
+
+ return resultCode;
}