diff options
author | Mike Buland <eichlan@xagasoft.com> | 2012-11-05 22:41:51 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2012-11-05 22:41:51 +0000 |
commit | ec05778d5718a7912e506764d443a78d6a6179e3 (patch) | |
tree | 78a9a01532180030c095acefc45763f07c14edb8 /src/stable/substream.cpp | |
parent | b20414ac1fe80a71a90601f4cd1767fa7014a9ba (diff) | |
download | libbu++-ec05778d5718a7912e506764d443a78d6a6179e3.tar.gz libbu++-ec05778d5718a7912e506764d443a78d6a6179e3.tar.bz2 libbu++-ec05778d5718a7912e506764d443a78d6a6179e3.tar.xz libbu++-ec05778d5718a7912e506764d443a78d6a6179e3.zip |
Converted tabs to spaces with tabconv.
Diffstat (limited to '')
-rw-r--r-- | src/stable/substream.cpp | 88 |
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 | ||
10 | Bu::SubStream::SubStream( Bu::Stream &rNext, Bu::size iSize ) : | 10 | Bu::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 | ||
19 | Bu::SubStream::~SubStream() | 19 | Bu::SubStream::~SubStream() |
@@ -22,88 +22,88 @@ Bu::SubStream::~SubStream() | |||
22 | 22 | ||
23 | Bu::size Bu::SubStream::read( void *pBuf, Bu::size nBytes ) | 23 | Bu::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 | ||
32 | Bu::size Bu::SubStream::write( const void *pBuf, Bu::size nBytes ) | 32 | Bu::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 | ||
41 | void Bu::SubStream::start() | 41 | void Bu::SubStream::start() |
42 | { | 42 | { |
43 | // doesn't mean anything... | 43 | // doesn't mean anything... |
44 | } | 44 | } |
45 | 45 | ||
46 | Bu::size Bu::SubStream::stop() | 46 | Bu::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 | ||
52 | void Bu::SubStream::close() | 52 | void Bu::SubStream::close() |
53 | { | 53 | { |
54 | // don't do anything? maybe... | 54 | // don't do anything? maybe... |
55 | } | 55 | } |
56 | 56 | ||
57 | Bu::size Bu::SubStream::tell() | 57 | Bu::size Bu::SubStream::tell() |
58 | { | 58 | { |
59 | return iPos; | 59 | return iPos; |
60 | } | 60 | } |
61 | 61 | ||
62 | void Bu::SubStream::seek( Bu::size offset ) | 62 | void 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 | ||
72 | void Bu::SubStream::setPos( Bu::size pos ) | 72 | void 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 | ||
83 | void Bu::SubStream::setPosEnd( Bu::size pos ) | 83 | void 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 | ||
95 | bool Bu::SubStream::isEos() | 95 | bool Bu::SubStream::isEos() |
96 | { | 96 | { |
97 | return rNext.isEos() || iPos == iSize; | 97 | return rNext.isEos() || iPos == iSize; |
98 | } | 98 | } |
99 | 99 | ||
100 | bool Bu::SubStream::canRead() | 100 | bool Bu::SubStream::canRead() |
101 | { | 101 | { |
102 | return rNext.canRead() && (iPos < iSize); | 102 | return rNext.canRead() && (iPos < iSize); |
103 | } | 103 | } |
104 | 104 | ||
105 | bool Bu::SubStream::canWrite() | 105 | bool Bu::SubStream::canWrite() |
106 | { | 106 | { |
107 | return rNext.canWrite() && (iPos < iSize); | 107 | return rNext.canWrite() && (iPos < iSize); |
108 | } | 108 | } |
109 | 109 | ||