reader without any output v_0
authorFrantišek Kučera <franta-hg@frantovo.cz>
Sun, 02 Dec 2018 18:25:43 +0100
branchv_0
changeset 2 eb2066405f79
parent 1 b2b20519ab23
child 3 8731263d44f1
reader without any output
src/relpipe-tr-validator.cpp
--- 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;
 }