aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/client.cpp107
-rw-r--r--src/client.h45
-rw-r--r--src/streamstack.cpp86
-rw-r--r--src/streamstack.h47
4 files changed, 250 insertions, 35 deletions
diff --git a/src/client.cpp b/src/client.cpp
index 095dd91..789cda4 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -125,62 +125,62 @@ bool Bu::Client::isOpen()
125 return pTopStream->isOpen(); 125 return pTopStream->isOpen();
126} 126}
127 127
128void Bu::Client::write( const Bu::FString &sData ) 128size_t Bu::Client::write( const Bu::FString &sData )
129{ 129{
130 qbWrite.write( sData.getStr(), sData.getSize() ); 130 return qbWrite.write( sData.getStr(), sData.getSize() );
131} 131}
132 132
133void Bu::Client::write( const void *pData, int nBytes ) 133size_t Bu::Client::write( const void *pData, size_t nBytes )
134{ 134{
135 qbWrite.write( pData, nBytes ); 135 return qbWrite.write( pData, nBytes );
136} 136}
137 137
138void Bu::Client::write( int8_t nData ) 138size_t Bu::Client::write( int8_t nData )
139{ 139{
140 qbWrite.write( (const char *)&nData, sizeof(nData) ); 140 return qbWrite.write( (const char *)&nData, sizeof(nData) );
141} 141}
142 142
143void Bu::Client::write( int16_t nData ) 143size_t Bu::Client::write( int16_t nData )
144{ 144{
145 qbWrite.write( (const char *)&nData, sizeof(nData) ); 145 return qbWrite.write( (const char *)&nData, sizeof(nData) );
146} 146}
147 147
148void Bu::Client::write( int32_t nData ) 148size_t Bu::Client::write( int32_t nData )
149{ 149{
150 qbWrite.write( (const char *)&nData, sizeof(nData) ); 150 return qbWrite.write( (const char *)&nData, sizeof(nData) );
151} 151}
152 152
153void Bu::Client::write( int64_t nData ) 153size_t Bu::Client::write( int64_t nData )
154{ 154{
155 qbWrite.write( (const char *)&nData, sizeof(nData) ); 155 return qbWrite.write( (const char *)&nData, sizeof(nData) );
156} 156}
157 157
158void Bu::Client::write( uint8_t nData ) 158size_t Bu::Client::write( uint8_t nData )
159{ 159{
160 qbWrite.write( (const char *)&nData, sizeof(nData) ); 160 return qbWrite.write( (const char *)&nData, sizeof(nData) );
161} 161}
162 162
163void Bu::Client::write( uint16_t nData ) 163size_t Bu::Client::write( uint16_t nData )
164{ 164{
165 qbWrite.write( (const char *)&nData, sizeof(nData) ); 165 return qbWrite.write( (const char *)&nData, sizeof(nData) );
166} 166}
167 167
168void Bu::Client::write( uint32_t nData ) 168size_t Bu::Client::write( uint32_t nData )
169{ 169{
170 qbWrite.write( (const char *)&nData, sizeof(nData) ); 170 return qbWrite.write( (const char *)&nData, sizeof(nData) );
171} 171}
172 172
173void Bu::Client::write( uint64_t nData ) 173size_t Bu::Client::write( uint64_t nData )
174{ 174{
175 qbWrite.write( (const char *)&nData, sizeof(nData) ); 175 return qbWrite.write( (const char *)&nData, sizeof(nData) );
176} 176}
177 177
178int Bu::Client::read( void *pData, int nBytes ) 178size_t Bu::Client::read( void *pData, size_t nBytes )
179{ 179{
180 return qbRead.read( pData, nBytes ); 180 return qbRead.read( pData, nBytes );
181} 181}
182 182
183int Bu::Client::peek( void *pData, int nBytes, int nOffset ) 183size_t Bu::Client::peek( void *pData, int nBytes, int nOffset )
184{ 184{
185 return qbRead.peek( pData, nBytes, nOffset ); 185 return qbRead.peek( pData, nBytes, nOffset );
186} 186}
@@ -237,3 +237,66 @@ void Bu::Client::tick()
237 pProto->onTick( this ); 237 pProto->onTick( this );
238} 238}
239 239
240long Bu::Client::tell()
241{
242}
243
244void Bu::Client::seek( long offset )
245{
246}
247
248void Bu::Client::setPos( long pos )
249{
250}
251
252void Bu::Client::setPosEnd( long pos )
253{
254}
255
256bool Bu::Client::isEos()
257{
258 return true;
259}
260
261void Bu::Client::flush()
262{
263}
264
265bool Bu::Client::canRead()
266{
267 return qbRead.getSize() > 0;
268}
269
270bool Bu::Client::canWrite()
271{
272 return true;
273}
274
275bool Bu::Client::isReadable()
276{
277 return true;
278}
279
280bool Bu::Client::isWritable()
281{
282 return true;
283}
284
285bool Bu::Client::isSeekable()
286{
287 return false;
288}
289
290bool Bu::Client::isBlocking()
291{
292 return false;
293}
294
295void Bu::Client::setBlocking( bool bBlocking )
296{
297}
298
299void Bu::Client::setSize( long iSize )
300{
301}
302
diff --git a/src/client.h b/src/client.h
index 5a933ca..105d48f 100644
--- a/src/client.h
+++ b/src/client.h
@@ -23,7 +23,7 @@ namespace Bu
23 /** 23 /**
24 *@ingroup Serving 24 *@ingroup Serving
25 */ 25 */
26 class Client 26 class Client : public Bu::Stream
27 { 27 {
28 public: 28 public:
29 Client( Bu::Socket *pSocket, Bu::ClientLinkFactory *pfLink ); 29 Client( Bu::Socket *pSocket, Bu::ClientLinkFactory *pfLink );
@@ -34,18 +34,18 @@ namespace Bu
34 34
35 //Bu::FString &getInput(); 35 //Bu::FString &getInput();
36 //Bu::FString &getOutput(); 36 //Bu::FString &getOutput();
37 void write( const Bu::FString &sData ); 37 size_t write( const Bu::FString &sData );
38 void write( const void *pData, int nBytes ); 38 size_t write( const void *pData, size_t nBytes );
39 void write( int8_t nData ); 39 size_t write( int8_t nData );
40 void write( int16_t nData ); 40 size_t write( int16_t nData );
41 void write( int32_t nData ); 41 size_t write( int32_t nData );
42 void write( int64_t nData ); 42 size_t write( int64_t nData );
43 void write( uint8_t nData ); 43 size_t write( uint8_t nData );
44 void write( uint16_t nData ); 44 size_t write( uint16_t nData );
45 void write( uint32_t nData ); 45 size_t write( uint32_t nData );
46 void write( uint64_t nData ); 46 size_t write( uint64_t nData );
47 int read( void *pData, int nBytes ); 47 size_t read( void *pData, size_t nBytes );
48 int peek( void *pData, int nBytes, int nOffset=0 ); 48 size_t peek( void *pData, int nBytes, int nOffset=0 );
49 void seek( int nBytes ); 49 void seek( int nBytes );
50 long getInputSize(); 50 long getInputSize();
51 long getOutputSize(); 51 long getOutputSize();
@@ -94,6 +94,25 @@ namespace Bu
94 lFilts.prepend( pFlt ); 94 lFilts.prepend( pFlt );
95 } 95 }
96 96
97 /*
98 * These are required to qualify as a stream, I dunno how many will
99 * be implemented.
100 */
101 virtual long tell();
102 virtual void seek( long offset );
103 virtual void setPos( long pos );
104 virtual void setPosEnd( long pos );
105 virtual bool isEos();
106 virtual void flush();
107 virtual bool canRead();
108 virtual bool canWrite();
109 virtual bool isReadable();
110 virtual bool isWritable();
111 virtual bool isSeekable();
112 virtual bool isBlocking();
113 virtual void setBlocking( bool bBlocking=true );
114 virtual void setSize( long iSize );
115
97 private: 116 private:
98 typedef Bu::List<Bu::Stream *> FilterList; 117 typedef Bu::List<Bu::Stream *> FilterList;
99 FilterList lFilts; 118 FilterList lFilts;
diff --git a/src/streamstack.cpp b/src/streamstack.cpp
new file mode 100644
index 0000000..9e45cc4
--- /dev/null
+++ b/src/streamstack.cpp
@@ -0,0 +1,86 @@
1#include "bu/streamstack.h"
2
3Bu::StreamStack::StreamStack()
4{
5}
6
7Bu::StreamStack::~StreamStack()
8{
9}
10
11void Bu::StreamStack::close()
12{
13}
14
15size_t Bu::StreamStack::read( void *pBuf, size_t nBytes )
16{
17}
18
19size_t Bu::StreamStack::write( const void *pBuf, size_t nBytes )
20{
21}
22
23size_t Bu::StreamStack::write( const Bu::FString &sBuf )
24{
25}
26
27long Bu::StreamStack::tell()
28{
29}
30
31void Bu::StreamStack::seek( long offset )
32{
33}
34
35void Bu::StreamStack::setPos( long pos )
36{
37}
38
39void Bu::StreamStack::setPosEnd( long pos )
40{
41}
42
43bool Bu::StreamStack::isEos()
44{
45}
46
47bool Bu::StreamStack::isOpen()
48{
49}
50
51void Bu::StreamStack::flush()
52{
53}
54
55bool Bu::StreamStack::canRead()
56{
57}
58
59bool Bu::StreamStack::canWrite()
60{
61}
62
63bool Bu::StreamStack::isReadable()
64{
65}
66
67bool Bu::StreamStack::isWritable()
68{
69}
70
71bool Bu::StreamStack::isSeekable()
72{
73}
74
75bool Bu::StreamStack::isBlocking()
76{
77}
78
79void Bu::StreamStack::setBlocking( bool bBlocking )
80{
81}
82
83void Bu::StreamStack::setSize( long iSize )
84{
85}
86
diff --git a/src/streamstack.h b/src/streamstack.h
new file mode 100644
index 0000000..03d8d8f
--- /dev/null
+++ b/src/streamstack.h
@@ -0,0 +1,47 @@
1#ifndef BU_STREAM_STACK_H
2#define BU_STREAM_STACK_H
3
4#include "bu/stream.h"
5
6namespace Bu
7{
8 class StreamStack : public Bu::Stream
9 {
10 public:
11 StreamStack();
12 virtual ~StreamStack();
13
14
15 //
16 // Everything below here merely passes on the call to the top of the
17 // stream stack.
18 //
19
20 virtual void close();
21 virtual size_t read( void *pBuf, size_t nBytes );
22 virtual size_t write( const void *pBuf, size_t nBytes );
23
24 virtual size_t write( const Bu::FString &sBuf );
25 virtual long tell();
26 virtual void seek( long offset );
27 virtual void setPos( long pos );
28 virtual void setPosEnd( long pos );
29 virtual bool isEos();
30 virtual bool isOpen();
31 virtual void flush();
32 virtual bool canRead();
33 virtual bool canWrite();
34 virtual bool isReadable();
35 virtual bool isWritable();
36 virtual bool isSeekable();
37 virtual bool isBlocking();
38 virtual void setBlocking( bool bBlocking=true );
39 virtual void setSize( long iSize );
40
41 private:
42 typedef Bu::List<Bu::Stream *> FilterList;
43 FilterList lFilts;
44 };
45};
46
47#endif