aboutsummaryrefslogtreecommitdiff
path: root/src/queuebuf.cpp
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2011-01-20 05:30:43 +0000
committerMike Buland <eichlan@xagasoft.com>2011-01-20 05:30:43 +0000
commit7c6c9538b03c9eae24e38fbeb30dd76a16aff1d2 (patch)
treee2d4bfccd81070adf7294ee54db2399df0c7171f /src/queuebuf.cpp
parentf5aca1a1b402bd7ebc944dc6e6fe65828d863365 (diff)
downloadlibbu++-7c6c9538b03c9eae24e38fbeb30dd76a16aff1d2.tar.gz
libbu++-7c6c9538b03c9eae24e38fbeb30dd76a16aff1d2.tar.bz2
libbu++-7c6c9538b03c9eae24e38fbeb30dd76a16aff1d2.tar.xz
libbu++-7c6c9538b03c9eae24e38fbeb30dd76a16aff1d2.zip
Wow, got the Stream changes propegated, all tests build with string instead of
fstring, and updated the copyright notice to extend to 2011
Diffstat (limited to 'src/queuebuf.cpp')
-rw-r--r--src/queuebuf.cpp51
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
40size_t Bu::QueueBuf::read( void *pRawBuf, size_t nBytes ) 40Bu::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
79size_t Bu::QueueBuf::peek( void *pBuf, size_t nBytes ) 79Bu::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
84size_t Bu::QueueBuf::peek( void *pRawBuf, size_t nBytes, size_t nSkip ) 84Bu::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
132size_t Bu::QueueBuf::write( const void *pRawBuf, size_t nBytes ) 132Bu::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
168long Bu::QueueBuf::tell() 168Bu::size Bu::QueueBuf::tell()
169{ 169{
170 return -1; 170 return -1;
171} 171}
172 172
173void Bu::QueueBuf::seek( long iAmnt ) 173void 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
196void Bu::QueueBuf::setPos( long ) 196void Bu::QueueBuf::setPos( Bu::size )
197{ 197{
198} 198}
199 199
200void Bu::QueueBuf::setPosEnd( long ) 200void 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
252void Bu::QueueBuf::setSize( long ) 252void Bu::QueueBuf::setSize( Bu::size )
253{ 253{
254} 254}
255 255
256Bu::size Bu::QueueBuf::getSize() const
257{
258 return iTotalSize;
259}
260
261Bu::size Bu::QueueBuf::getBlockSize() const
262{
263 return iBlockSize;
264}
265
266Bu::String Bu::QueueBuf::getLocation() const
267{
268 return "";
269}
270
256void Bu::QueueBuf::addBlock() 271void Bu::QueueBuf::addBlock()
257{ 272{
258 lBlocks.append( new char[iBlockSize] ); 273 lBlocks.append( new char[iBlockSize] );