aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2010-05-11 13:27:30 +0000
committerMike Buland <eichlan@xagasoft.com>2010-05-11 13:27:30 +0000
commit1300301a52bba102fed8b08bdcb668d246973af5 (patch)
treebd64c93b000b5637cb185d704714ac6a634603a2 /src
parent70be76029b39d9d909ce9c069c1564d5d476fc22 (diff)
downloadlibbu++-1300301a52bba102fed8b08bdcb668d246973af5.tar.gz
libbu++-1300301a52bba102fed8b08bdcb668d246973af5.tar.bz2
libbu++-1300301a52bba102fed8b08bdcb668d246973af5.tar.xz
libbu++-1300301a52bba102fed8b08bdcb668d246973af5.zip
Fixed an issue in the reader, it was tokenizing.
Diffstat (limited to '')
-rw-r--r--src/cachestorefiles.h7
-rw-r--r--src/formatter.cpp59
-rw-r--r--src/formatter.h11
3 files changed, 53 insertions, 24 deletions
diff --git a/src/cachestorefiles.h b/src/cachestorefiles.h
index 0416f8b..6a80765 100644
--- a/src/cachestorefiles.h
+++ b/src/cachestorefiles.h
@@ -77,9 +77,9 @@ namespace Bu
77 obtype *pOb = __cacheStoreFilesLoad<keytype, obtype>( fIn, key ); 77 obtype *pOb = __cacheStoreFilesLoad<keytype, obtype>( fIn, key );
78 return pOb; 78 return pOb;
79 } 79 }
80 catch(...) 80 catch( std::exception &e )
81 { 81 {
82 throw Bu::HashException("File-key not found."); 82 throw Bu::HashException( e.what() );
83 } 83 }
84 } 84 }
85 85
@@ -158,6 +158,9 @@ namespace Bu
158 Bu::Formatter f( mb ); 158 Bu::Formatter f( mb );
159 try 159 try
160 { 160 {
161 Fmt fm;
162 fm.tokenize( false );
163 f << fm;
161 f >> tmp; 164 f >> tmp;
162 } 165 }
163 catch( Bu::ExceptionBase &e ) 166 catch( Bu::ExceptionBase &e )
diff --git a/src/formatter.cpp b/src/formatter.cpp
index ce92caa..7eaa1e2 100644
--- a/src/formatter.cpp
+++ b/src/formatter.cpp
@@ -120,30 +120,45 @@ void Bu::Formatter::read( void *sStr, int iLen )
120Bu::FString Bu::Formatter::readToken() 120Bu::FString Bu::Formatter::readToken()
121{ 121{
122 Bu::FString sRet; 122 Bu::FString sRet;
123 for(;;) 123 if( fLast.bTokenize )
124 { 124 {
125 char buf; 125 for(;;)
126 int iRead = rStream.read( &buf, 1 );
127 if( iRead == 0 )
128 return sRet;
129 if( buf == ' ' || buf == '\t' || buf == '\n' || buf == '\r' )
130 continue;
131 else
132 { 126 {
133 sRet += buf; 127 char buf;
134 break; 128 int iRead = rStream.read( &buf, 1 );
129 if( iRead == 0 )
130 return sRet;
131 if( buf == ' ' || buf == '\t' || buf == '\n' || buf == '\r' )
132 continue;
133 else
134 {
135 sRet += buf;
136 break;
137 }
138 }
139 for(;;)
140 {
141 char buf;
142 int iRead = rStream.read( &buf, 1 );
143 if( iRead == 0 )
144 return sRet;
145 if( buf == ' ' || buf == '\t' || buf == '\n' || buf == '\r' )
146 return sRet;
147 else
148 sRet += buf;
135 } 149 }
136 } 150 }
137 for(;;) 151 else
138 { 152 {
139 char buf; 153 for(;;)
140 int iRead = rStream.read( &buf, 1 ); 154 {
141 if( iRead == 0 ) 155 char buf;
142 return sRet; 156 int iRead = rStream.read( &buf, 1 );
143 if( buf == ' ' || buf == '\t' || buf == '\n' || buf == '\r' ) 157 if( iRead == 0 )
144 return sRet; 158 return sRet;
145 else 159 else
146 sRet += buf; 160 sRet += buf;
161 }
147 } 162 }
148} 163}
149 164
@@ -228,6 +243,12 @@ Bu::Formatter::Fmt &Bu::Formatter::Fmt::caps( bool bCaps )
228 return *this; 243 return *this;
229} 244}
230 245
246Bu::Formatter::Fmt &Bu::Formatter::Fmt::tokenize( bool bTokenize )
247{
248 this->bTokenize = bTokenize;
249 return *this;
250}
251
231Bu::Formatter &Bu::operator<<( Bu::Formatter &f, const Bu::Formatter::Fmt &fmt ) 252Bu::Formatter &Bu::operator<<( Bu::Formatter &f, const Bu::Formatter::Fmt &fmt )
232{ 253{
233 f.setTempFormat( fmt ); 254 f.setTempFormat( fmt );
diff --git a/src/formatter.h b/src/formatter.h
index 47592ad..7e0c54b 100644
--- a/src/formatter.h
+++ b/src/formatter.h
@@ -32,7 +32,8 @@ namespace Bu
32 uRadix( 10 ), 32 uRadix( 10 ),
33 uAlign( Right ), 33 uAlign( Right ),
34 bPlus( false ), 34 bPlus( false ),
35 bCaps( true ) 35 bCaps( true ),
36 bTokenize( true )
36 { 37 {
37 } 38 }
38 39
@@ -44,7 +45,8 @@ namespace Bu
44 uRadix( uRadix ), 45 uRadix( uRadix ),
45 uAlign( a ), 46 uAlign( a ),
46 bPlus( bPlus ), 47 bPlus( bPlus ),
47 bCaps( bCaps ) 48 bCaps( bCaps ),
49 bTokenize( true )
48 { 50 {
49 } 51 }
50 Fmt( unsigned int uMinWidth, Alignment a, 52 Fmt( unsigned int uMinWidth, Alignment a,
@@ -55,7 +57,8 @@ namespace Bu
55 uRadix( uRadix ), 57 uRadix( uRadix ),
56 uAlign( a ), 58 uAlign( a ),
57 bPlus( bPlus ), 59 bPlus( bPlus ),
58 bCaps( bCaps ) 60 bCaps( bCaps ),
61 bTokenize( true )
59 { 62 {
60 } 63 }
61 64
@@ -85,6 +88,7 @@ namespace Bu
85 Fmt &align( Alignment eAlign ); 88 Fmt &align( Alignment eAlign );
86 Fmt &plus( bool bPlus=true ); 89 Fmt &plus( bool bPlus=true );
87 Fmt &caps( bool bCaps=true ); 90 Fmt &caps( bool bCaps=true );
91 Fmt &tokenize( bool bTokenize=true );
88 92
89 Fmt &left(); 93 Fmt &left();
90 Fmt &right(); 94 Fmt &right();
@@ -96,6 +100,7 @@ namespace Bu
96 unsigned short uAlign : 2; 100 unsigned short uAlign : 2;
97 unsigned short bPlus : 1; 101 unsigned short bPlus : 1;
98 unsigned short bCaps : 1; 102 unsigned short bCaps : 1;
103 unsigned short bTokenize : 1;
99 } Fmt; 104 } Fmt;
100 105
101 void write( const Bu::FString &sStr ); 106 void write( const Bu::FString &sStr );