--- a/nbproject/configurations.xml Tue Dec 04 15:20:03 2018 +0100
+++ b/nbproject/configurations.xml Tue Dec 04 17:19:10 2018 +0100
@@ -80,7 +80,6 @@
<ccTool>
<incDir>
<pElem>../relpipe-lib-reader.cpp/include</pElem>
- <pElem>../relpipe-lib-writer.cpp/include</pElem>
<pElem>../relpipe-lib-cli.cpp/include</pElem>
<pElem>build/Debug/src</pElem>
</incDir>
--- a/nbproject/project.xml Tue Dec 04 15:20:03 2018 +0100
+++ b/nbproject/project.xml Tue Dec 04 17:19:10 2018 +0100
@@ -45,7 +45,7 @@
<name>relpipe-out-nullbyte.cpp</name>
<c-extensions/>
<cpp-extensions>cpp</cpp-extensions>
- <header-extensions/>
+ <header-extensions>h</header-extensions>
<sourceEncoding>UTF-8</sourceEncoding>
<sourceRootList>
<sourceRootElem>.</sourceRootElem>
--- a/src/CMakeLists.txt Tue Dec 04 15:20:03 2018 +0100
+++ b/src/CMakeLists.txt Tue Dec 04 17:19:10 2018 +0100
@@ -18,7 +18,7 @@
# Relpipe libraries:
INCLUDE(FindPkgConfig)
-pkg_check_modules (RELPIPE_LIBS relpipe-lib-reader.cpp relpipe-lib-writer.cpp relpipe-lib-cli.cpp)
+pkg_check_modules (RELPIPE_LIBS relpipe-lib-reader.cpp relpipe-lib-cli.cpp)
include_directories(${RELPIPE_LIBS_INCLUDE_DIRS})
link_directories(${RELPIPE_LIBS_LIBRARY_DIRS})
@@ -30,6 +30,7 @@
# Executable output:
add_executable(
${EXECUTABLE_FILE}
+ NullByteHandler.h
relpipe-out-nullbyte.cpp
)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/NullByteHandler.h Tue Dec 04 17:19:10 2018 +0100
@@ -0,0 +1,67 @@
+/**
+ * Relational pipes
+ * Copyright © 2018 František Kučera (Frantovo.cz, GlobalCode.info)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+#pragma once
+
+#include <memory>
+#include <string>
+#include <vector>
+#include <iostream>
+#include <sstream>
+#include <locale>
+#include <codecvt>
+
+#include <relpipe/reader/typedefs.h>
+#include <relpipe/reader/TypeId.h>
+#include <relpipe/reader/handlers/RelationalReaderStringHandler.h>
+#include <relpipe/reader/handlers/AttributeMetadata.h>
+
+namespace relpipe {
+namespace out {
+namespace nullbyte {
+
+using namespace relpipe;
+using namespace relpipe::reader;
+using namespace relpipe::reader::handlers;
+
+class NullByteHandler : public RelationalReaderStringHadler {
+private:
+ std::ostream& output;
+ std::wstring_convert<std::codecvt_utf8<wchar_t>> convertor; // TODO: support also other encodings.
+public:
+
+ NullByteHandler(std::ostream& output) : output(output) {
+ }
+
+ void startRelation(string_t name, std::vector<AttributeMetadata> attributes) override {
+
+ }
+
+ void attribute(const string_t& value) override {
+ output << convertor.to_bytes(value).c_str();
+ output.put(0);
+ }
+
+ void endOfPipe() {
+ output.flush();
+ }
+
+};
+
+}
+}
+}
--- a/src/relpipe-out-nullbyte.cpp Tue Dec 04 15:20:03 2018 +0100
+++ b/src/relpipe-out-nullbyte.cpp Tue Dec 04 17:19:10 2018 +0100
@@ -26,13 +26,11 @@
#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>
+#include "NullByteHandler.h"
using namespace relpipe::cli;
using namespace relpipe::reader;
+using namespace relpipe::out::nullbyte;
int main(int argc, char**argv) {
CLI cli(argc, argv);
@@ -41,8 +39,8 @@
try {
std::shared_ptr<RelationalReader> reader(Factory::create(std::cin));
- //TabularPrefetchingHandler handler(std::cout);
- //reader->addHandler(&handler);
+ NullByteHandler handler(std::cout);
+ reader->addHandler(&handler);
reader->process();
resultCode = CLI::EXIT_CODE_SUCCESS;