join 1.0
lightweight network framework library
Loading...
Searching...
No Matches
streambuf.hpp
Go to the documentation of this file.
1
25#ifndef __JOIN_STREAMBUF_HPP__
26#define __JOIN_STREAMBUF_HPP__
27
28// C++.
29#include <iostream>
30#include <memory>
31
32namespace join
33{
37 class StreambufDecorator : public std::streambuf
38 {
39 public:
45 StreambufDecorator (std::streambuf* streambuf, bool own = false)
46 : _innerbuf (streambuf),
47 _own (own)
48 {
49 }
50
55 StreambufDecorator (const StreambufDecorator& other) = delete;
56
63
69 : std::streambuf (std::move (other)),
70 _innerbuf (other._innerbuf),
71 _own (other._own)
72 {
73 other._innerbuf = nullptr;
74 other._own = false;
75 }
76
83 {
84 std::streambuf::operator= (std::move (other));
85 _innerbuf = other._innerbuf;
86 _own = other._own;
87 other._innerbuf = nullptr;
88 other._own = false;
89 return *this;
90 }
91
96 {
97 if (_own && _innerbuf)
98 {
99 delete (_innerbuf);
100 }
101 }
102
103 protected:
105 std::streambuf* _innerbuf;
106
108 bool _own = false;
109 };
110}
111
112#endif
stream buffer decorator.
Definition streambuf.hpp:38
virtual ~StreambufDecorator()
destroy the stream buffer decorator instance.
Definition streambuf.hpp:95
StreambufDecorator(StreambufDecorator &&other)
move constructor.
Definition streambuf.hpp:68
bool _own
own inner stream buffer.
Definition streambuf.hpp:108
std::streambuf * _innerbuf
concrete stream buffer.
Definition streambuf.hpp:105
StreambufDecorator(const StreambufDecorator &other)=delete
copy constructor.
StreambufDecorator & operator=(const StreambufDecorator &other)=delete
copy assignment operator.
StreambufDecorator(std::streambuf *streambuf, bool own=false)
create the stream buffer decorator instance.
Definition streambuf.hpp:45
Definition acceptor.hpp:32
Definition error.hpp:106