aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2009-08-03 21:33:33 +0000
committerMike Buland <eichlan@xagasoft.com>2009-08-03 21:33:33 +0000
commit6e6402825bcd6021d62fd2eb8a0669641fe9c266 (patch)
tree6942e99b440849046482e99eef7590014c06120d
parentfbb30d35cfa10bf36d4ecb2d0eb5971c24aab26a (diff)
downloadlibbu++-6e6402825bcd6021d62fd2eb8a0669641fe9c266.tar.gz
libbu++-6e6402825bcd6021d62fd2eb8a0669641fe9c266.tar.bz2
libbu++-6e6402825bcd6021d62fd2eb8a0669641fe9c266.tar.xz
libbu++-6e6402825bcd6021d62fd2eb8a0669641fe9c266.zip
Hey, buffer has some good tweaks, added some stuff and fixed stuff in formatter
and base64 no longer accidentally complains about properly formatted streams, as much...
-rw-r--r--src/base64.cpp9
-rw-r--r--src/buffer.cpp18
-rw-r--r--src/formatter.h9
3 files changed, 23 insertions, 13 deletions
diff --git a/src/base64.cpp b/src/base64.cpp
index ccf9077..55df550 100644
--- a/src/base64.cpp
+++ b/src/base64.cpp
@@ -118,9 +118,14 @@ size_t Bu::Base64::read( void *pBuf, size_t nBytes )
118 { 118 {
119 if( rNext.isEos() ) 119 if( rNext.isEos() )
120 { 120 {
121 iChars = 0;
122 bEosIn = true; 121 bEosIn = true;
123 throw Base64Exception("Premature end of stream detected while decoding Base64 data."); 122 if( j != 0 )
123 {
124 throw Base64Exception(
125 "Premature end of stream detected while "
126 "decoding Base64 data."
127 );
128 }
124 } 129 }
125 return sIn; 130 return sIn;
126 } 131 }
diff --git a/src/buffer.cpp b/src/buffer.cpp
index 5e7fb9a..d4eb8a6 100644
--- a/src/buffer.cpp
+++ b/src/buffer.cpp
@@ -40,12 +40,12 @@ void Bu::Buffer::fillReadBuf()
40{ 40{
41 if( iReadBufFill+iReadPos < iBufSize ) 41 if( iReadBufFill+iReadPos < iBufSize )
42 { 42 {
43 printf("Buffer: Attempting to read %db.\n", iBufSize-iReadBufFill-iReadPos ); 43 //printf("Buffer: Attempting to read %db.\n", iBufSize-iReadBufFill-iReadPos );
44 iReadBufFill += rNext.read( 44 iReadBufFill += rNext.read(
45 sReadBuf+iReadPos+iReadBufFill, 45 sReadBuf+iReadPos+iReadBufFill,
46 iBufSize-iReadBufFill-iReadPos 46 iBufSize-iReadBufFill-iReadPos
47 ); 47 );
48 printf("Buffer: Read from stream, %db now in buffer.\n", iReadBufFill ); 48 //printf("Buffer: Read from stream, %db now in buffer.\n", iReadBufFill );
49 } 49 }
50} 50}
51 51
@@ -82,7 +82,7 @@ size_t Bu::Buffer::read( void *pBuf, size_t nBytes )
82 } 82 }
83 while( nTotRead < nBytes && iReadBufFill > 0 ); 83 while( nTotRead < nBytes && iReadBufFill > 0 );
84 84
85 printf("Buffer: %db returned, %db remain in buffer.\n", nTotRead, iReadBufFill ); 85 //printf("Buffer: %db returned, %db remain in buffer.\n", nTotRead, iReadBufFill );
86 86
87 return nTotRead; 87 return nTotRead;
88} 88}
@@ -107,14 +107,14 @@ size_t Bu::Buffer::write( const void *pBuf, size_t nBytes )
107 ); 107 );
108 nTotWrote += iAmnt; 108 nTotWrote += iAmnt;
109 iWriteBufFill += iAmnt; 109 iWriteBufFill += iAmnt;
110 printf("Buffer: Moved %db to write buffer, %db filled now.\n", 110 //printf("Buffer: Moved %db to write buffer, %db filled now.\n",
111 iAmnt, iWriteBufFill ); 111 //iAmnt, iWriteBufFill );
112 } 112 }
113 while( iWritePos+iWriteBufFill == iBufSize ) 113 while( iWritePos+iWriteBufFill == iBufSize )
114 { 114 {
115 printf("iWritePos = %d\n", iWritePos ); 115 //printf("iWritePos = %d\n", iWritePos );
116 int iWr = rNext.write( sWriteBuf+iWritePos, iWriteBufFill ); 116 int iWr = rNext.write( sWriteBuf+iWritePos, iWriteBufFill );
117 printf("Buffer: Wrote %db from buffer to stream, %db filled now.\n", iWr, iWriteBufFill-iWr ); 117 //printf("Buffer: Wrote %db from buffer to stream, %db filled now.\n", iWr, iWriteBufFill-iWr );
118 if( iWr == 0 ) 118 if( iWr == 0 )
119 { 119 {
120 return nTotWrote; 120 return nTotWrote;
@@ -139,12 +139,12 @@ void Bu::Buffer::flush()
139{ 139{
140 if( iWriteBufFill > 0 ) 140 if( iWriteBufFill > 0 )
141 { 141 {
142 printf("Buffer: Flushing remaining data, %db.\n", iWriteBufFill ); 142 //printf("Buffer: Flushing remaining data, %db.\n", iWriteBufFill );
143 int iWr = 0; 143 int iWr = 0;
144 do 144 do
145 { 145 {
146 iWr = rNext.write( sWriteBuf+iWritePos, iWriteBufFill ); 146 iWr = rNext.write( sWriteBuf+iWritePos, iWriteBufFill );
147 printf("Buffer: %db written to stream.\n", iWr ); 147 //printf("Buffer: %db written to stream.\n", iWr );
148 iWritePos += iWr; 148 iWritePos += iWr;
149 iWriteBufFill -= iWr; 149 iWriteBufFill -= iWr;
150 } while( iWriteBufFill > 0 && iWr > 0 ); 150 } while( iWriteBufFill > 0 && iWr > 0 );
diff --git a/src/formatter.h b/src/formatter.h
index aacf893..8bb8e08 100644
--- a/src/formatter.h
+++ b/src/formatter.h
@@ -64,9 +64,14 @@ namespace Bu
64 return Fmt( uWidth, 16, Right, false, bCaps, '0' ); 64 return Fmt( uWidth, 16, Right, false, bCaps, '0' );
65 } 65 }
66 66
67 static Fmt oct( unsigned int uWidth=0, bool bCaps=true ) 67 static Fmt oct( unsigned int uWidth=0 )
68 { 68 {
69 return Fmt( uWidth, 8, Right, false, bCaps, '0' ); 69 return Fmt( uWidth, 8, Right, false, false, '0' );
70 }
71
72 static Fmt bin( unsigned int uWidth=0 )
73 {
74 return Fmt( uWidth, 1, Right, false, false, '0' );
70 } 75 }
71 76
72 static Fmt ptr( bool bCaps=true ) 77 static Fmt ptr( bool bCaps=true )