src/relpipe-tr-awk.cpp
branchv_0
changeset 13 b74001992ec3
parent 0 644fd2ce2580
child 28 4fdbe30d8c58
equal deleted inserted replaced
12:8844ebce8fb4 13:b74001992ec3
    17  */
    17  */
    18 
    18 
    19 #include <cstdio>
    19 #include <cstdio>
    20 #include <cstdlib>
    20 #include <cstdlib>
    21 #include <memory>
    21 #include <memory>
       
    22 #include <functional>
    22 
    23 
    23 #include <relpipe/cli/CLI.h>
    24 #include <relpipe/cli/CLI.h>
    24 #include <relpipe/cli/RelpipeCLIException.h>
    25 #include <relpipe/cli/RelpipeCLIException.h>
    25 
    26 
    26 #include <relpipe/reader/Factory.h>
    27 #include <relpipe/reader/Factory.h>
    50 	try {
    51 	try {
    51 		CLIParser cliParser;
    52 		CLIParser cliParser;
    52 		Configuration configuration = cliParser.parse(cli.arguments());
    53 		Configuration configuration = cliParser.parse(cli.arguments());
    53 		std::shared_ptr<reader::RelationalReader> reader(reader::Factory::create(std::cin));
    54 		std::shared_ptr<reader::RelationalReader> reader(reader::Factory::create(std::cin));
    54 		std::shared_ptr<writer::RelationalWriter> writer(writer::Factory::create(std::cout));
    55 		std::shared_ptr<writer::RelationalWriter> writer(writer::Factory::create(std::cout));
    55 		AwkHandler handler(writer.get(), configuration);
    56 		AwkHandler handler(writer.get(), std::bind(fflush, stdout), configuration); // std::bind(fflush, XXX) writer::Factory::create(XXX) must be the same stream XXX
    56 		reader->addHandler(&handler);
    57 		reader->addHandler(&handler);
    57 		reader->process();
    58 		reader->process();
    58 		
    59 
    59 		resultCode = CLI::EXIT_CODE_SUCCESS;
    60 		resultCode = CLI::EXIT_CODE_SUCCESS;
    60 
    61 
    61 	} catch (RelpipeCLIException& e) {
    62 	} catch (RelpipeCLIException& e) {
    62 		fwprintf(stderr, L"Caught CLI exception: %ls\n", e.getMessge().c_str());
    63 		fwprintf(stderr, L"Caught CLI exception: %ls\n", e.getMessge().c_str());
    63 		fwprintf(stderr, L"Debug: Input stream: eof=%ls, lastRead=%d\n", (cin.eof() ? L"true" : L"false"), cin.gcount());
    64 		fwprintf(stderr, L"Debug: Input stream: eof=%ls, lastRead=%d\n", (cin.eof() ? L"true" : L"false"), cin.gcount());