summaryrefslogtreecommitdiff
path: root/src/membuf.cpp
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2011-01-19 23:02:44 +0000
committerMike Buland <eichlan@xagasoft.com>2011-01-19 23:02:44 +0000
commit10c557562e1d67c55314c212371ea9cb7f802863 (patch)
tree5834f4060874de33df5d0f9ebe115059d2541189 /src/membuf.cpp
parentdfb29c814b9c3327df3ab90e333b43504768e6d6 (diff)
downloadlibbu++-10c557562e1d67c55314c212371ea9cb7f802863.tar.gz
libbu++-10c557562e1d67c55314c212371ea9cb7f802863.tar.bz2
libbu++-10c557562e1d67c55314c212371ea9cb7f802863.tar.xz
libbu++-10c557562e1d67c55314c212371ea9cb7f802863.zip
Started work adding more functions to stream, and changing to a new size type.
Diffstat (limited to 'src/membuf.cpp')
-rw-r--r--src/membuf.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/membuf.cpp b/src/membuf.cpp
index b822641..1a6bf9a 100644
--- a/src/membuf.cpp
+++ b/src/membuf.cpp
@@ -28,9 +28,9 @@ void Bu::MemBuf::close()
28{ 28{
29} 29}
30 30
31size_t Bu::MemBuf::read( void *pBuf, size_t nBytes ) 31size Bu::MemBuf::read( void *pBuf, size nBytes )
32{ 32{
33 if( (size_t)sBuf.getSize()-(size_t)nPos < nBytes ) 33 if( (size)sBuf.getSize()-(size)nPos < nBytes )
34 nBytes = sBuf.getSize()-nPos; 34 nBytes = sBuf.getSize()-nPos;
35 35
36 memcpy( pBuf, sBuf.getStr()+nPos, nBytes ); 36 memcpy( pBuf, sBuf.getStr()+nPos, nBytes );
@@ -39,7 +39,7 @@ size_t Bu::MemBuf::read( void *pBuf, size_t nBytes )
39 return nBytes; 39 return nBytes;
40} 40}
41 41
42size_t Bu::MemBuf::write( const void *pBuf, size_t nBytes ) 42size Bu::MemBuf::write( const void *pBuf, size nBytes )
43{ 43{
44 if( nPos == sBuf.getSize() ) 44 if( nPos == sBuf.getSize() )
45 { 45 {
@@ -52,7 +52,7 @@ size_t Bu::MemBuf::write( const void *pBuf, size_t nBytes )
52 { 52 {
53 // Trickier, we must do this in two parts, overwrite, then append 53 // Trickier, we must do this in two parts, overwrite, then append
54 // Frist, overwrite. 54 // Frist, overwrite.
55 size_t iOver = sBuf.getSize() - nPos; 55 size iOver = sBuf.getSize() - nPos;
56 if( iOver > nBytes ) 56 if( iOver > nBytes )
57 iOver = nBytes; 57 iOver = nBytes;
58 memcpy( sBuf.getStr()+nPos, pBuf, iOver ); 58 memcpy( sBuf.getStr()+nPos, pBuf, iOver );
@@ -66,26 +66,26 @@ size_t Bu::MemBuf::write( const void *pBuf, size_t nBytes )
66 } 66 }
67} 67}
68 68
69long Bu::MemBuf::tell() 69size Bu::MemBuf::tell()
70{ 70{
71 return nPos; 71 return nPos;
72} 72}
73 73
74void Bu::MemBuf::seek( long offset ) 74void Bu::MemBuf::seek( size offset )
75{ 75{
76 nPos += offset; 76 nPos += offset;
77 if( nPos < 0 ) nPos = 0; 77 if( nPos < 0 ) nPos = 0;
78 else if( nPos > sBuf.getSize() ) nPos = sBuf.getSize(); 78 else if( nPos > sBuf.getSize() ) nPos = sBuf.getSize();
79} 79}
80 80
81void Bu::MemBuf::setPos( long pos ) 81void Bu::MemBuf::setPos( size pos )
82{ 82{
83 nPos = pos; 83 nPos = pos;
84 if( nPos < 0 ) nPos = 0; 84 if( nPos < 0 ) nPos = 0;
85 else if( nPos > sBuf.getSize() ) nPos = sBuf.getSize(); 85 else if( nPos > sBuf.getSize() ) nPos = sBuf.getSize();
86} 86}
87 87
88void Bu::MemBuf::setPosEnd( long pos ) 88void Bu::MemBuf::setPosEnd( size pos )
89{ 89{
90 nPos = sBuf.getSize()-pos; 90 nPos = sBuf.getSize()-pos;
91 if( nPos < 0 ) nPos = 0; 91 if( nPos < 0 ) nPos = 0;
@@ -140,7 +140,7 @@ void Bu::MemBuf::setBlocking( bool )
140{ 140{
141} 141}
142 142
143void Bu::MemBuf::setSize( long iSize ) 143void Bu::MemBuf::setSize( size iSize )
144{ 144{
145 if( iSize < 0 ) 145 if( iSize < 0 )
146 iSize = 0; 146 iSize = 0;