From 1300301a52bba102fed8b08bdcb668d246973af5 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Tue, 11 May 2010 13:27:30 +0000 Subject: Fixed an issue in the reader, it was tokenizing. --- src/cachestorefiles.h | 7 ++++-- src/formatter.cpp | 59 ++++++++++++++++++++++++++++++++++----------------- src/formatter.h | 11 +++++++--- 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 obtype *pOb = __cacheStoreFilesLoad( fIn, key ); return pOb; } - catch(...) + catch( std::exception &e ) { - throw Bu::HashException("File-key not found."); + throw Bu::HashException( e.what() ); } } @@ -158,6 +158,9 @@ namespace Bu Bu::Formatter f( mb ); try { + Fmt fm; + fm.tokenize( false ); + f << fm; f >> tmp; } 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 ) Bu::FString Bu::Formatter::readToken() { Bu::FString sRet; - for(;;) + if( fLast.bTokenize ) { - char buf; - int iRead = rStream.read( &buf, 1 ); - if( iRead == 0 ) - return sRet; - if( buf == ' ' || buf == '\t' || buf == '\n' || buf == '\r' ) - continue; - else + for(;;) { - sRet += buf; - break; + char buf; + int iRead = rStream.read( &buf, 1 ); + if( iRead == 0 ) + return sRet; + if( buf == ' ' || buf == '\t' || buf == '\n' || buf == '\r' ) + continue; + else + { + sRet += buf; + break; + } + } + for(;;) + { + char buf; + int iRead = rStream.read( &buf, 1 ); + if( iRead == 0 ) + return sRet; + if( buf == ' ' || buf == '\t' || buf == '\n' || buf == '\r' ) + return sRet; + else + sRet += buf; } } - for(;;) + else { - char buf; - int iRead = rStream.read( &buf, 1 ); - if( iRead == 0 ) - return sRet; - if( buf == ' ' || buf == '\t' || buf == '\n' || buf == '\r' ) - return sRet; - else - sRet += buf; + for(;;) + { + char buf; + int iRead = rStream.read( &buf, 1 ); + if( iRead == 0 ) + return sRet; + else + sRet += buf; + } } } @@ -228,6 +243,12 @@ Bu::Formatter::Fmt &Bu::Formatter::Fmt::caps( bool bCaps ) return *this; } +Bu::Formatter::Fmt &Bu::Formatter::Fmt::tokenize( bool bTokenize ) +{ + this->bTokenize = bTokenize; + return *this; +} + Bu::Formatter &Bu::operator<<( Bu::Formatter &f, const Bu::Formatter::Fmt &fmt ) { 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 uRadix( 10 ), uAlign( Right ), bPlus( false ), - bCaps( true ) + bCaps( true ), + bTokenize( true ) { } @@ -44,7 +45,8 @@ namespace Bu uRadix( uRadix ), uAlign( a ), bPlus( bPlus ), - bCaps( bCaps ) + bCaps( bCaps ), + bTokenize( true ) { } Fmt( unsigned int uMinWidth, Alignment a, @@ -55,7 +57,8 @@ namespace Bu uRadix( uRadix ), uAlign( a ), bPlus( bPlus ), - bCaps( bCaps ) + bCaps( bCaps ), + bTokenize( true ) { } @@ -85,6 +88,7 @@ namespace Bu Fmt &align( Alignment eAlign ); Fmt &plus( bool bPlus=true ); Fmt &caps( bool bCaps=true ); + Fmt &tokenize( bool bTokenize=true ); Fmt &left(); Fmt &right(); @@ -96,6 +100,7 @@ namespace Bu unsigned short uAlign : 2; unsigned short bPlus : 1; unsigned short bCaps : 1; + unsigned short bTokenize : 1; } Fmt; void write( const Bu::FString &sStr ); -- cgit v1.2.3