src/relpipe-tr-validator.cpp
branchv_0
changeset 3 0161ea43ce2a
parent 2 eb2066405f79
child 4 12ffbdbb3574
equal deleted inserted replaced
2:eb2066405f79 3:0161ea43ce2a
     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 
       
    19 #include <cstdlib>
       
    20 #include <memory>
       
    21 
       
    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>
       
    33 
       
    34 using namespace relpipe::cli;
       
    35 using namespace relpipe::reader;
       
    36 
       
    37 int main(int argc, char**argv) {
       
    38 	CLI cli(argc, argv);
       
    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;
       
    61 }