aboutsummaryrefslogtreecommitdiff
path: root/src/streamstack.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/streamstack.cpp120
1 files changed, 120 insertions, 0 deletions
diff --git a/src/streamstack.cpp b/src/streamstack.cpp
index 9e45cc4..c7f8af5 100644
--- a/src/streamstack.cpp
+++ b/src/streamstack.cpp
@@ -4,83 +4,203 @@ Bu::StreamStack::StreamStack()
4{ 4{
5} 5}
6 6
7Bu::StreamStack::StreamStack( Bu::Stream *pStream )
8{
9 lFilts.prepend( pStream );
10}
11
7Bu::StreamStack::~StreamStack() 12Bu::StreamStack::~StreamStack()
8{ 13{
14 clearStack();
15}
16
17bool Bu::StreamStack::isEmpty()
18{
19 return lFilts.isEmpty();
20}
21
22bool Bu::StreamStack::hasStream()
23{
24 return !lFilts.isEmpty();
25}
26
27void Bu::StreamStack::setStream( Bu::Stream *pStream )
28{
29 if( !lFilts.isEmpty() )
30 throw Bu::ExceptionBase("There is already a stream set.");
31
32 lFilts.prepend( pStream );
33}
34
35void Bu::StreamStack::clearStack()
36{
37 for( FilterList::iterator i = lFilts.begin(); i; i++ )
38 {
39 delete *i;
40 }
41
42 lFilts.clear();
43}
44
45void Bu::StreamStack::popFilter()
46{
47 if( lFilts.isEmpty() )
48 return;
49
50 delete lFilts.first();
51 lFilts.erase( lFilts.begin() );
52}
53
54Bu::Stream *Bu::StreamStack::getTop()
55{
56 checkStack();
57
58 return lFilts.first();
59}
60
61Bu::Stream *Bu::StreamStack::getStream()
62{
63 checkStack();
64
65 return lFilts.last();
9} 66}
10 67
11void Bu::StreamStack::close() 68void Bu::StreamStack::close()
12{ 69{
70 checkStack();
71
72 lFilts.first()->close();
13} 73}
14 74
15size_t Bu::StreamStack::read( void *pBuf, size_t nBytes ) 75size_t Bu::StreamStack::read( void *pBuf, size_t nBytes )
16{ 76{
77 checkStack();
78
79 return lFilts.first()->read( pBuf, nBytes );
17} 80}
18 81
19size_t Bu::StreamStack::write( const void *pBuf, size_t nBytes ) 82size_t Bu::StreamStack::write( const void *pBuf, size_t nBytes )
20{ 83{
84 checkStack();
85
86 return lFilts.first()->write( pBuf, nBytes );
21} 87}
22 88
23size_t Bu::StreamStack::write( const Bu::FString &sBuf ) 89size_t Bu::StreamStack::write( const Bu::FString &sBuf )
24{ 90{
91 checkStack();
92
93 return lFilts.first()->write( sBuf );
25} 94}
26 95
27long Bu::StreamStack::tell() 96long Bu::StreamStack::tell()
28{ 97{
98 checkStack();
99
100 return lFilts.first()->tell();
29} 101}
30 102
31void Bu::StreamStack::seek( long offset ) 103void Bu::StreamStack::seek( long offset )
32{ 104{
105 checkStack();
106
107 lFilts.first()->seek( offset );
33} 108}
34 109
35void Bu::StreamStack::setPos( long pos ) 110void Bu::StreamStack::setPos( long pos )
36{ 111{
112 checkStack();
113
114 lFilts.first()->setPos( pos );
37} 115}
38 116
39void Bu::StreamStack::setPosEnd( long pos ) 117void Bu::StreamStack::setPosEnd( long pos )
40{ 118{
119 checkStack();
120
121 lFilts.first()->setPosEnd( pos );
41} 122}
42 123
43bool Bu::StreamStack::isEos() 124bool Bu::StreamStack::isEos()
44{ 125{
126 checkStack();
127
128 return lFilts.first()->isEos();
45} 129}
46 130
47bool Bu::StreamStack::isOpen() 131bool Bu::StreamStack::isOpen()
48{ 132{
133 checkStack();
134
135 return lFilts.first()->isOpen();
49} 136}
50 137
51void Bu::StreamStack::flush() 138void Bu::StreamStack::flush()
52{ 139{
140 checkStack();
141
142 lFilts.first()->flush();
53} 143}
54 144
55bool Bu::StreamStack::canRead() 145bool Bu::StreamStack::canRead()
56{ 146{
147 checkStack();
148
149 return lFilts.first()->canRead();
57} 150}
58 151
59bool Bu::StreamStack::canWrite() 152bool Bu::StreamStack::canWrite()
60{ 153{
154 checkStack();
155
156 return lFilts.first()->canWrite();
61} 157}
62 158
63bool Bu::StreamStack::isReadable() 159bool Bu::StreamStack::isReadable()
64{ 160{
161 checkStack();
162
163 return lFilts.first()->isReadable();
65} 164}
66 165
67bool Bu::StreamStack::isWritable() 166bool Bu::StreamStack::isWritable()
68{ 167{
168 checkStack();
169
170 return lFilts.first()->isWritable();
69} 171}
70 172
71bool Bu::StreamStack::isSeekable() 173bool Bu::StreamStack::isSeekable()
72{ 174{
175 checkStack();
176
177 return lFilts.first()->isSeekable();
73} 178}
74 179
75bool Bu::StreamStack::isBlocking() 180bool Bu::StreamStack::isBlocking()
76{ 181{
182 checkStack();
183
184 return lFilts.first()->isBlocking();
77} 185}
78 186
79void Bu::StreamStack::setBlocking( bool bBlocking ) 187void Bu::StreamStack::setBlocking( bool bBlocking )
80{ 188{
189 checkStack();
190
191 lFilts.first()->setBlocking( bBlocking );
81} 192}
82 193
83void Bu::StreamStack::setSize( long iSize ) 194void Bu::StreamStack::setSize( long iSize )
84{ 195{
196 checkStack();
197
198 lFilts.first()->setSize( iSize );
199}
200
201inline void Bu::StreamStack::checkStack()
202{
203 if( lFilts.isEmpty() )
204 throw Bu::ExceptionBase("StreamStack is empty.");
85} 205}
86 206