From 7b565d9c7695ada727cb68714f30f289e8264411 Mon Sep 17 00:00:00 2001 From: Dan Paulat Date: Tue, 4 Oct 2022 23:09:36 -0500 Subject: [PATCH] Add stream support class for QIODevice to boost::iostreams::stream --- scwx-qt/scwx-qt.cmake | 3 ++- scwx-qt/source/scwx/qt/util/streams.hpp | 33 +++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 scwx-qt/source/scwx/qt/util/streams.hpp diff --git a/scwx-qt/scwx-qt.cmake b/scwx-qt/scwx-qt.cmake index 1c4a0366..5901935e 100644 --- a/scwx-qt/scwx-qt.cmake +++ b/scwx-qt/scwx-qt.cmake @@ -106,7 +106,8 @@ set(SRC_UI source/scwx/qt/ui/flow_layout.cpp source/scwx/qt/ui/level3_products_widget.cpp) set(HDR_UTIL source/scwx/qt/util/font.hpp source/scwx/qt/util/font_buffer.hpp - source/scwx/qt/util/json.hpp) + source/scwx/qt/util/json.hpp + source/scwx/qt/util/streams.hpp) set(SRC_UTIL source/scwx/qt/util/font.cpp source/scwx/qt/util/font_buffer.cpp source/scwx/qt/util/json.cpp) diff --git a/scwx-qt/source/scwx/qt/util/streams.hpp b/scwx-qt/source/scwx/qt/util/streams.hpp new file mode 100644 index 00000000..ca3a3d9c --- /dev/null +++ b/scwx-qt/source/scwx/qt/util/streams.hpp @@ -0,0 +1,33 @@ +#pragma once + +#include +#include + +namespace scwx +{ +namespace qt +{ +namespace util +{ + +class IoDeviceSource +{ +public: + typedef char char_type; + typedef boost::iostreams::source_tag category; + + IoDeviceSource(QIODevice& source) : source_ {source} {} + ~IoDeviceSource() {} + + std::streamsize read(char* buffer, std::streamsize n) + { + return source_.read(buffer, n); + } + +private: + QIODevice& source_; +}; + +} // namespace util +} // namespace qt +} // namespace scwx