# HG changeset patch # User František Kučera # Date 1536011074 -7200 # Node ID 9a4062b12fc9e199b335de6604974ad03bab7666 # Parent 31ef97e63eb08fdbc05c3de70888bc9f94022e6e DemoHandler (not an actual tabular handler) diff -r 31ef97e63eb0 -r 9a4062b12fc9 nbproject/Makefile-Debug.mk --- a/nbproject/Makefile-Debug.mk Sat Aug 25 12:29:03 2018 +0200 +++ b/nbproject/Makefile-Debug.mk Mon Sep 03 23:44:34 2018 +0200 @@ -34,7 +34,8 @@ OBJECTDIR=${CND_BUILDDIR}/${CND_CONF}/${CND_PLATFORM} # Object Files -OBJECTFILES= +OBJECTFILES= \ + ${OBJECTDIR}/relpipe-out-tabular.o # C Compiler Flags @@ -59,7 +60,12 @@ ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/relpipe-out-tabular.cpp: ${OBJECTFILES} ${MKDIR} -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM} - ${LINK.c} -o ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/relpipe-out-tabular.cpp ${OBJECTFILES} ${LDLIBSOPTIONS} + ${LINK.cc} -o ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/relpipe-out-tabular.cpp ${OBJECTFILES} ${LDLIBSOPTIONS} + +${OBJECTDIR}/relpipe-out-tabular.o: relpipe-out-tabular.cpp + ${MKDIR} -p ${OBJECTDIR} + ${RM} "$@.d" + $(COMPILE.cc) -g `pkg-config --cflags relpipe-lib-cli.cpp` `pkg-config --cflags relpipe-lib-reader.cpp` -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/relpipe-out-tabular.o relpipe-out-tabular.cpp # Subprojects .build-subprojects: diff -r 31ef97e63eb0 -r 9a4062b12fc9 nbproject/Makefile-Release.mk --- a/nbproject/Makefile-Release.mk Sat Aug 25 12:29:03 2018 +0200 +++ b/nbproject/Makefile-Release.mk Mon Sep 03 23:44:34 2018 +0200 @@ -34,7 +34,8 @@ OBJECTDIR=${CND_BUILDDIR}/${CND_CONF}/${CND_PLATFORM} # Object Files -OBJECTFILES= +OBJECTFILES= \ + ${OBJECTDIR}/relpipe-out-tabular.o # C Compiler Flags @@ -59,7 +60,12 @@ ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/relpipe-out-tabular.cpp: ${OBJECTFILES} ${MKDIR} -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM} - ${LINK.c} -o ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/relpipe-out-tabular.cpp ${OBJECTFILES} ${LDLIBSOPTIONS} + ${LINK.cc} -o ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/relpipe-out-tabular.cpp ${OBJECTFILES} ${LDLIBSOPTIONS} + +${OBJECTDIR}/relpipe-out-tabular.o: relpipe-out-tabular.cpp + ${MKDIR} -p ${OBJECTDIR} + ${RM} "$@.d" + $(COMPILE.cc) -O2 `pkg-config --cflags relpipe-lib-cli.cpp` `pkg-config --cflags relpipe-lib-reader.cpp` -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/relpipe-out-tabular.o relpipe-out-tabular.cpp # Subprojects .build-subprojects: diff -r 31ef97e63eb0 -r 9a4062b12fc9 nbproject/configurations.xml --- a/nbproject/configurations.xml Sat Aug 25 12:29:03 2018 +0200 +++ b/nbproject/configurations.xml Mon Sep 03 23:44:34 2018 +0200 @@ -12,6 +12,7 @@ + relpipe-out-tabular.cpp + + @@ -71,6 +74,8 @@ + + diff -r 31ef97e63eb0 -r 9a4062b12fc9 nbproject/project.xml --- a/nbproject/project.xml Sat Aug 25 12:29:03 2018 +0200 +++ b/nbproject/project.xml Mon Sep 03 23:44:34 2018 +0200 @@ -5,7 +5,7 @@ relpipe-out-tabular.cpp - + cpp UTF-8 diff -r 31ef97e63eb0 -r 9a4062b12fc9 relpipe-out-tabular.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/relpipe-out-tabular.cpp Mon Sep 03 23:44:34 2018 +0200 @@ -0,0 +1,65 @@ +#include +#include + +#include +#include +#include +#include +#include + + +using namespace relpipe::cli; +using namespace relpipe::reader; + +class DemoHandler : public handlers::RelationalReaderStringHadler { + + void startRelation(string_t name, std::vector > attributes) override { + std::wcout << L"start relation: " << name << std::endl << std::flush; + for (int i = 0; i < attributes.size(); i++) { + std::wcout << L"\tcolumn: " << attributes[i].first << L" / " << (int) attributes[i].second << std::endl << std::flush; + } + } + + void attribute(const string_t& value) override { + std::wcout << L"attribute: " << value << std::endl << std::flush; + } + + +}; + +int main(int argc, char** argv) { + CLI cli(argc, argv); + + int resultCode = CLI::EXIT_CODE_UNEXPECTED_ERROR; + + try { + // if (cli.arguments().size() > 0) { + + // const wstring commandName = cli.arguments()[0]; + // vector arguments(cli.arguments().size() - 1); + // for (int i = 1; i < cli.arguments().size(); i++) { + // arguments[i - 1] = cli.arguments()[i]; + // } + + std::shared_ptr reader(Factory::create(std::cin)); + DemoHandler handler; + reader->addHandler(&handler); + reader->process(); + + resultCode = CLI::EXIT_CODE_SUCCESS; + + // } else { + // throw RelpipeCLIException(L"Missing command…", CLI::EXIT_CODE_BAD_SYNTAX); + // } + } 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; +}