diff options
author | Mike Buland <eichlan@xagasoft.com> | 2011-01-20 18:09:04 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2011-01-20 18:09:04 +0000 |
commit | 393f1b414746a7f1977971dd7659dd2b47092b11 (patch) | |
tree | 81d0ca1ee70ab86a7d79c1991abe5c387b655fb2 /src/queuebuf.cpp | |
parent | c259f95bd0e58b247940a339bb9b4b401b4e9438 (diff) | |
parent | 7e25a863325dc3e9762397e700030969e093b087 (diff) | |
download | libbu++-393f1b414746a7f1977971dd7659dd2b47092b11.tar.gz libbu++-393f1b414746a7f1977971dd7659dd2b47092b11.tar.bz2 libbu++-393f1b414746a7f1977971dd7659dd2b47092b11.tar.xz libbu++-393f1b414746a7f1977971dd7659dd2b47092b11.zip |
Wow! Merged the branch, streams are updated, and there's no more FString, run
the fixstrings.sh script in the support directory to (hopefully) automatically
update your projects.
Diffstat (limited to 'src/queuebuf.cpp')
-rw-r--r-- | src/queuebuf.cpp | 51 |
1 files changed, 33 insertions, 18 deletions
diff --git a/src/queuebuf.cpp b/src/queuebuf.cpp index e8eb2ed..69abf4b 100644 --- a/src/queuebuf.cpp +++ b/src/queuebuf.cpp | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2007-2010 Xagasoft, All rights reserved. | 2 | * Copyright (C) 2007-2011 Xagasoft, All rights reserved. |
3 | * | 3 | * |
4 | * This file is part of the libbu++ library and is released under the | 4 | * This file is part of the libbu++ library and is released under the |
5 | * terms of the license contained in the file LICENSE. | 5 | * terms of the license contained in the file LICENSE. |
@@ -37,7 +37,7 @@ void Bu::QueueBuf::close() | |||
37 | iReadOffset = iWriteOffset = iTotalSize = 0; | 37 | iReadOffset = iWriteOffset = iTotalSize = 0; |
38 | } | 38 | } |
39 | 39 | ||
40 | size_t Bu::QueueBuf::read( void *pRawBuf, size_t nBytes ) | 40 | Bu::size Bu::QueueBuf::read( void *pRawBuf, Bu::size nBytes ) |
41 | { | 41 | { |
42 | if( nBytes <= 0 ) | 42 | if( nBytes <= 0 ) |
43 | return 0; | 43 | return 0; |
@@ -45,7 +45,7 @@ size_t Bu::QueueBuf::read( void *pRawBuf, size_t nBytes ) | |||
45 | if( lBlocks.isEmpty() ) | 45 | if( lBlocks.isEmpty() ) |
46 | return 0; | 46 | return 0; |
47 | 47 | ||
48 | size_t iLeft = nBytes; | 48 | Bu::size iLeft = nBytes; |
49 | char *pBuf = (char *)pRawBuf; | 49 | char *pBuf = (char *)pRawBuf; |
50 | 50 | ||
51 | while( iLeft > 0 && iTotalSize > 0 ) | 51 | while( iLeft > 0 && iTotalSize > 0 ) |
@@ -60,7 +60,7 @@ size_t Bu::QueueBuf::read( void *pRawBuf, size_t nBytes ) | |||
60 | iReadOffset = 0; | 60 | iReadOffset = 0; |
61 | } | 61 | } |
62 | char *pBlock = lBlocks.first(); | 62 | char *pBlock = lBlocks.first(); |
63 | size_t iCopy = iBlockSize-iReadOffset; | 63 | Bu::size iCopy = iBlockSize-iReadOffset; |
64 | if( iLeft < iCopy ) | 64 | if( iLeft < iCopy ) |
65 | iCopy = iLeft; | 65 | iCopy = iLeft; |
66 | if( iTotalSize < iCopy ) | 66 | if( iTotalSize < iCopy ) |
@@ -76,12 +76,12 @@ size_t Bu::QueueBuf::read( void *pRawBuf, size_t nBytes ) | |||
76 | return nBytes - iLeft; | 76 | return nBytes - iLeft; |
77 | } | 77 | } |
78 | 78 | ||
79 | size_t Bu::QueueBuf::peek( void *pBuf, size_t nBytes ) | 79 | Bu::size Bu::QueueBuf::peek( void *pBuf, Bu::size nBytes ) |
80 | { | 80 | { |
81 | return peek( pBuf, nBytes, 0 ); | 81 | return peek( pBuf, nBytes, 0 ); |
82 | } | 82 | } |
83 | 83 | ||
84 | size_t Bu::QueueBuf::peek( void *pRawBuf, size_t nBytes, size_t nSkip ) | 84 | Bu::size Bu::QueueBuf::peek( void *pRawBuf, Bu::size nBytes, Bu::size nSkip ) |
85 | { | 85 | { |
86 | if( nBytes <= 0 ) | 86 | if( nBytes <= 0 ) |
87 | return 0; | 87 | return 0; |
@@ -89,11 +89,11 @@ size_t Bu::QueueBuf::peek( void *pRawBuf, size_t nBytes, size_t nSkip ) | |||
89 | if( lBlocks.isEmpty() ) | 89 | if( lBlocks.isEmpty() ) |
90 | return 0; | 90 | return 0; |
91 | 91 | ||
92 | size_t iLeft = nBytes; | 92 | Bu::size iLeft = nBytes; |
93 | char *pBuf = (char *)pRawBuf; | 93 | char *pBuf = (char *)pRawBuf; |
94 | 94 | ||
95 | int iTmpReadOffset = iReadOffset + nSkip; | 95 | int iTmpReadOffset = iReadOffset + nSkip; |
96 | size_t iTmpRemSize = iTotalSize; | 96 | Bu::size iTmpRemSize = iTotalSize; |
97 | BlockList::iterator iBlock = lBlocks.begin(); | 97 | BlockList::iterator iBlock = lBlocks.begin(); |
98 | while( iTmpReadOffset > iBlockSize ) | 98 | while( iTmpReadOffset > iBlockSize ) |
99 | { | 99 | { |
@@ -112,7 +112,7 @@ size_t Bu::QueueBuf::peek( void *pRawBuf, size_t nBytes, size_t nSkip ) | |||
112 | iTmpReadOffset = 0; | 112 | iTmpReadOffset = 0; |
113 | } | 113 | } |
114 | char *pBlock = *iBlock; | 114 | char *pBlock = *iBlock; |
115 | size_t iCopy = iBlockSize-iTmpReadOffset; | 115 | Bu::size iCopy = iBlockSize-iTmpReadOffset; |
116 | if( iLeft < iCopy ) | 116 | if( iLeft < iCopy ) |
117 | iCopy = iLeft; | 117 | iCopy = iLeft; |
118 | if( iTmpRemSize < iCopy ) | 118 | if( iTmpRemSize < iCopy ) |
@@ -129,7 +129,7 @@ size_t Bu::QueueBuf::peek( void *pRawBuf, size_t nBytes, size_t nSkip ) | |||
129 | return nBytes - iLeft; | 129 | return nBytes - iLeft; |
130 | } | 130 | } |
131 | 131 | ||
132 | size_t Bu::QueueBuf::write( const void *pRawBuf, size_t nBytes ) | 132 | Bu::size Bu::QueueBuf::write( const void *pRawBuf, Bu::size nBytes ) |
133 | { | 133 | { |
134 | if( nBytes <= 0 ) | 134 | if( nBytes <= 0 ) |
135 | return 0; | 135 | return 0; |
@@ -139,7 +139,7 @@ size_t Bu::QueueBuf::write( const void *pRawBuf, size_t nBytes ) | |||
139 | addBlock(); | 139 | addBlock(); |
140 | iWriteOffset = 0; | 140 | iWriteOffset = 0; |
141 | } | 141 | } |
142 | size_t iLeft = nBytes; | 142 | Bu::size iLeft = nBytes; |
143 | const char *pBuf = (const char *)pRawBuf; | 143 | const char *pBuf = (const char *)pRawBuf; |
144 | 144 | ||
145 | while( iLeft > 0 ) | 145 | while( iLeft > 0 ) |
@@ -150,7 +150,7 @@ size_t Bu::QueueBuf::write( const void *pRawBuf, size_t nBytes ) | |||
150 | iWriteOffset = 0; | 150 | iWriteOffset = 0; |
151 | } | 151 | } |
152 | char *pBlock = lBlocks.last(); | 152 | char *pBlock = lBlocks.last(); |
153 | size_t iCopy = iBlockSize-iWriteOffset; | 153 | Bu::size iCopy = iBlockSize-iWriteOffset; |
154 | if( iLeft < iCopy ) | 154 | if( iLeft < iCopy ) |
155 | iCopy = iLeft; | 155 | iCopy = iLeft; |
156 | memcpy( pBlock+iWriteOffset, pBuf, iCopy ); | 156 | memcpy( pBlock+iWriteOffset, pBuf, iCopy ); |
@@ -165,17 +165,17 @@ size_t Bu::QueueBuf::write( const void *pRawBuf, size_t nBytes ) | |||
165 | return nBytes; | 165 | return nBytes; |
166 | } | 166 | } |
167 | 167 | ||
168 | long Bu::QueueBuf::tell() | 168 | Bu::size Bu::QueueBuf::tell() |
169 | { | 169 | { |
170 | return -1; | 170 | return -1; |
171 | } | 171 | } |
172 | 172 | ||
173 | void Bu::QueueBuf::seek( long iAmnt ) | 173 | void Bu::QueueBuf::seek( Bu::size iAmnt ) |
174 | { | 174 | { |
175 | if( iAmnt <= 0 ) | 175 | if( iAmnt <= 0 ) |
176 | return; | 176 | return; |
177 | 177 | ||
178 | if( (size_t)iAmnt >= iTotalSize ) | 178 | if( (Bu::size)iAmnt >= iTotalSize ) |
179 | { | 179 | { |
180 | // sio << "seek: clear all data (" << iAmnt << ">=" << iTotalSize | 180 | // sio << "seek: clear all data (" << iAmnt << ">=" << iTotalSize |
181 | // << ")." << sio.nl; | 181 | // << ")." << sio.nl; |
@@ -193,11 +193,11 @@ void Bu::QueueBuf::seek( long iAmnt ) | |||
193 | } | 193 | } |
194 | } | 194 | } |
195 | 195 | ||
196 | void Bu::QueueBuf::setPos( long ) | 196 | void Bu::QueueBuf::setPos( Bu::size ) |
197 | { | 197 | { |
198 | } | 198 | } |
199 | 199 | ||
200 | void Bu::QueueBuf::setPosEnd( long ) | 200 | void Bu::QueueBuf::setPosEnd( Bu::size ) |
201 | { | 201 | { |
202 | } | 202 | } |
203 | 203 | ||
@@ -249,10 +249,25 @@ void Bu::QueueBuf::setBlocking( bool ) | |||
249 | { | 249 | { |
250 | } | 250 | } |
251 | 251 | ||
252 | void Bu::QueueBuf::setSize( long ) | 252 | void Bu::QueueBuf::setSize( Bu::size ) |
253 | { | 253 | { |
254 | } | 254 | } |
255 | 255 | ||
256 | Bu::size Bu::QueueBuf::getSize() const | ||
257 | { | ||
258 | return iTotalSize; | ||
259 | } | ||
260 | |||
261 | Bu::size Bu::QueueBuf::getBlockSize() const | ||
262 | { | ||
263 | return iBlockSize; | ||
264 | } | ||
265 | |||
266 | Bu::String Bu::QueueBuf::getLocation() const | ||
267 | { | ||
268 | return ""; | ||
269 | } | ||
270 | |||
256 | void Bu::QueueBuf::addBlock() | 271 | void Bu::QueueBuf::addBlock() |
257 | { | 272 | { |
258 | lBlocks.append( new char[iBlockSize] ); | 273 | lBlocks.append( new char[iBlockSize] ); |