summaryrefslogtreecommitdiff
path: root/src/stable/substream.cpp
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2012-11-05 22:41:51 +0000
committerMike Buland <eichlan@xagasoft.com>2012-11-05 22:41:51 +0000
commitec05778d5718a7912e506764d443a78d6a6179e3 (patch)
tree78a9a01532180030c095acefc45763f07c14edb8 /src/stable/substream.cpp
parentb20414ac1fe80a71a90601f4cd1767fa7014a9ba (diff)
downloadlibbu++-ec05778d5718a7912e506764d443a78d6a6179e3.tar.gz
libbu++-ec05778d5718a7912e506764d443a78d6a6179e3.tar.bz2
libbu++-ec05778d5718a7912e506764d443a78d6a6179e3.tar.xz
libbu++-ec05778d5718a7912e506764d443a78d6a6179e3.zip
Converted tabs to spaces with tabconv.
Diffstat (limited to 'src/stable/substream.cpp')
-rw-r--r--src/stable/substream.cpp88
1 files changed, 44 insertions, 44 deletions
diff --git a/src/stable/substream.cpp b/src/stable/substream.cpp
index 7e3729b..c55dc04 100644
--- a/src/stable/substream.cpp
+++ b/src/stable/substream.cpp
@@ -8,12 +8,12 @@
8#include "bu/substream.h" 8#include "bu/substream.h"
9 9
10Bu::SubStream::SubStream( Bu::Stream &rNext, Bu::size iSize ) : 10Bu::SubStream::SubStream( Bu::Stream &rNext, Bu::size iSize ) :
11 Bu::Filter( rNext ), 11 Bu::Filter( rNext ),
12 iStart( 0 ), 12 iStart( 0 ),
13 iPos( 0 ), 13 iPos( 0 ),
14 iSize( iSize ) 14 iSize( iSize )
15{ 15{
16 iStart = rNext.tell(); 16 iStart = rNext.tell();
17} 17}
18 18
19Bu::SubStream::~SubStream() 19Bu::SubStream::~SubStream()
@@ -22,88 +22,88 @@ Bu::SubStream::~SubStream()
22 22
23Bu::size Bu::SubStream::read( void *pBuf, Bu::size nBytes ) 23Bu::size Bu::SubStream::read( void *pBuf, Bu::size nBytes )
24{ 24{
25 if( (Bu::size)nBytes > iSize-iPos ) 25 if( (Bu::size)nBytes > iSize-iPos )
26 nBytes = iSize-iPos; 26 nBytes = iSize-iPos;
27 nBytes = rNext.read( pBuf, nBytes ); 27 nBytes = rNext.read( pBuf, nBytes );
28 iPos += nBytes; 28 iPos += nBytes;
29 return nBytes; 29 return nBytes;
30} 30}
31 31
32Bu::size Bu::SubStream::write( const void *pBuf, Bu::size nBytes ) 32Bu::size Bu::SubStream::write( const void *pBuf, Bu::size nBytes )
33{ 33{
34 if( (Bu::size)nBytes > iSize-iPos ) 34 if( (Bu::size)nBytes > iSize-iPos )
35 nBytes = iSize-iPos; 35 nBytes = iSize-iPos;
36 nBytes = rNext.write( pBuf, nBytes ); 36 nBytes = rNext.write( pBuf, nBytes );
37 iPos += nBytes; 37 iPos += nBytes;
38 return nBytes; 38 return nBytes;
39} 39}
40 40
41void Bu::SubStream::start() 41void Bu::SubStream::start()
42{ 42{
43 // doesn't mean anything... 43 // doesn't mean anything...
44} 44}
45 45
46Bu::size Bu::SubStream::stop() 46Bu::size Bu::SubStream::stop()
47{ 47{
48 // doesn't mean anything... 48 // doesn't mean anything...
49 return 0; 49 return 0;
50} 50}
51 51
52void Bu::SubStream::close() 52void Bu::SubStream::close()
53{ 53{
54 // don't do anything? maybe... 54 // don't do anything? maybe...
55} 55}
56 56
57Bu::size Bu::SubStream::tell() 57Bu::size Bu::SubStream::tell()
58{ 58{
59 return iPos; 59 return iPos;
60} 60}
61 61
62void Bu::SubStream::seek( Bu::size offset ) 62void Bu::SubStream::seek( Bu::size offset )
63{ 63{
64 if( iPos+offset < 0 ) 64 if( iPos+offset < 0 )
65 offset = -iPos; 65 offset = -iPos;
66 else if( iPos+offset > iSize ) 66 else if( iPos+offset > iSize )
67 offset = iSize-iPos; 67 offset = iSize-iPos;
68 rNext.seek( offset ); 68 rNext.seek( offset );
69 iPos += offset; 69 iPos += offset;
70} 70}
71 71
72void Bu::SubStream::setPos( Bu::size pos ) 72void Bu::SubStream::setPos( Bu::size pos )
73{ 73{
74 if( pos < 0 ) 74 if( pos < 0 )
75 pos = 0; 75 pos = 0;
76 else if( pos > iSize ) 76 else if( pos > iSize )
77 pos = iSize; 77 pos = iSize;
78 iPos = pos; 78 iPos = pos;
79 pos += iStart; 79 pos += iStart;
80 rNext.setPos( pos ); 80 rNext.setPos( pos );
81} 81}
82 82
83void Bu::SubStream::setPosEnd( Bu::size pos ) 83void Bu::SubStream::setPosEnd( Bu::size pos )
84{ 84{
85 if( iSize-pos < 0 ) 85 if( iSize-pos < 0 )
86 pos = 0; 86 pos = 0;
87 else if( iSize-pos > iSize ) 87 else if( iSize-pos > iSize )
88 pos = iSize; 88 pos = iSize;
89 else 89 else
90 pos = iSize-pos; 90 pos = iSize-pos;
91 iPos = pos; 91 iPos = pos;
92 rNext.setPos( iStart+pos ); 92 rNext.setPos( iStart+pos );
93} 93}
94 94
95bool Bu::SubStream::isEos() 95bool Bu::SubStream::isEos()
96{ 96{
97 return rNext.isEos() || iPos == iSize; 97 return rNext.isEos() || iPos == iSize;
98} 98}
99 99
100bool Bu::SubStream::canRead() 100bool Bu::SubStream::canRead()
101{ 101{
102 return rNext.canRead() && (iPos < iSize); 102 return rNext.canRead() && (iPos < iSize);
103} 103}
104 104
105bool Bu::SubStream::canWrite() 105bool Bu::SubStream::canWrite()
106{ 106{
107 return rNext.canWrite() && (iPos < iSize); 107 return rNext.canWrite() && (iPos < iSize);
108} 108}
109 109