mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 21:30:05 +00:00
Add stream support class for QIODevice to boost::iostreams::stream
This commit is contained in:
parent
5ae098daff
commit
7b565d9c76
2 changed files with 35 additions and 1 deletions
33
scwx-qt/source/scwx/qt/util/streams.hpp
Normal file
33
scwx-qt/source/scwx/qt/util/streams.hpp
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
#pragma once
|
||||
|
||||
#include <boost/iostreams/categories.hpp>
|
||||
#include <QIODevice>
|
||||
|
||||
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
|
||||
Loading…
Add table
Add a link
Reference in a new issue