blob: ed1506a1a2168368f78d1f5bb9f363003d9a694d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
/**
* StreamBuf.h
*
* PHP output stream buffer which is used by the Php::out object to
* have an output stream just like the regular std::ostream buffers,
* but that sends all output to PHP output
*
* @author Emiel Bruijntjes <emiel.bruijntjes@copernica.com>
* @copyright 2014 Copernica BV
*/
/**
* Set up namespace
*/
namespace Php {
/**
* Class definition
*/
class StreamBuf : public std::streambuf
{
public:
/**
* Constructor
* @param error the error type, or 0 for regular output
*/
StreamBuf(int error);
/**
* No copying or moving
* @param that
*/
StreamBuf(const StreamBuf &that) = delete;
StreamBuf(StreamBuf &&that) = delete;
/**
* Destructor
*/
virtual ~StreamBuf() {}
/**
* No copying or moving
* @param that
*/
StreamBuf &operator=(const StreamBuf &that) = delete;
StreamBuf &operator=(StreamBuf &&that) = delete;
protected:
/**
* Method that is called when the internal buffer overflows
* @param c
* @return int
*/
virtual int overflow(int c = EOF) override;
/**
* Called when the internal buffer should be synchronized
* @return int
*/
virtual int sync() override;
private:
/**
* The error type, or 0 for regular output
* @var int
*/
int _error;
/**
* The internal buffer
* @var char[]
*/
char _buffer[1024];
};
/**
* End namespace
*/
}
|