join 1.0
lightweight network framework library
Loading...
Searching...
No Matches
chunk_stream.hpp
Go to the documentation of this file.
1
25#ifndef JOIN_SERVICES_CHUNK_STREAM_HPP
26#define JOIN_SERVICES_CHUNK_STREAM_HPP
27
28// libjoin.
29#include <join/streambuf.hpp>
30
31// C++.
32#include <iostream>
33#include <memory>
34
35namespace join
36{
41 {
42 public:
48 Chunkstreambuf (std::streambuf* streambuf, bool own = false);
49
56 Chunkstreambuf (std::streambuf* streambuf, std::streamsize chunksize, bool own = false);
57
62 Chunkstreambuf (const Chunkstreambuf& other) = delete;
63
69 Chunkstreambuf& operator= (const Chunkstreambuf& other) = delete;
70
76
83
87 virtual ~Chunkstreambuf ();
88
89 protected:
94 virtual int_type underflow () override;
95
101 virtual int_type overflow (int_type c = traits_type::eof ()) override;
102
107 virtual int_type sync () override;
108
110 std::streamsize _chunksize = 16384;
111
113 std::unique_ptr<char[]> _buf;
114 };
115
119 class Chunkstream : public std::iostream
120 {
121 public:
126 Chunkstream (std::iostream& stream);
127
133 Chunkstream (std::iostream& stream, std::streamsize chunksize);
134
139 Chunkstream (const Chunkstream& other) = delete;
140
146 Chunkstream& operator= (const Chunkstream& other) = delete;
147
152 Chunkstream (Chunkstream&& other);
153
160
164 virtual ~Chunkstream () = default;
165
166 protected:
169 };
170}
171
172#endif
chunk stream.
Definition chunk_stream.hpp:120
Chunkstreambuf _chunkbuf
chunkstream buffer.
Definition chunk_stream.hpp:168
Chunkstream(std::iostream &stream)
create the chunk stream instance.
Definition chunk_stream.cpp:223
Chunkstream & operator=(const Chunkstream &other)=delete
copy assignment operator.
Chunkstream(const Chunkstream &other)=delete
copy constructor.
virtual ~Chunkstream()=default
destroy the chunk stream instance.
chunk stream buffer.
Definition chunk_stream.hpp:41
Chunkstreambuf & operator=(const Chunkstreambuf &other)=delete
copy assignment operator.
virtual int_type overflow(int_type c=traits_type::eof()) override
writes characters to the associated output sequence from the put area.
Definition chunk_stream.cpp:165
Chunkstreambuf(std::streambuf *streambuf, bool own=false)
create the chunk stream buffer instance.
Definition chunk_stream.cpp:39
virtual int_type underflow() override
reads characters from the associated input sequence to the get area.
Definition chunk_stream.cpp:95
std::streamsize _chunksize
chunk size.
Definition chunk_stream.hpp:110
Chunkstreambuf(const Chunkstreambuf &other)=delete
copy constructor.
virtual int_type sync() override
synchronizes the buffers with the associated character sequence.
Definition chunk_stream.cpp:210
std::unique_ptr< char[]> _buf
internal buffer.
Definition chunk_stream.hpp:113
virtual ~Chunkstreambuf()
destroy the chunk stream buffer instance.
Definition chunk_stream.cpp:83
stream buffer decorator.
Definition streambuf.hpp:38
Definition acceptor.hpp:32