summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2009-04-02 14:33:55 +0000
committerMike Buland <eichlan@xagasoft.com>2009-04-02 14:33:55 +0000
commite9e5da32b2e154698482b7ec6b7ab2098cd849c8 (patch)
tree1e9d2168a27b3979398285909dd10c362c03545a /src
parentb4ab27db8a97f0a56a61bd56480cfbe08a1f3399 (diff)
downloadlibbu++-e9e5da32b2e154698482b7ec6b7ab2098cd849c8.tar.gz
libbu++-e9e5da32b2e154698482b7ec6b7ab2098cd849c8.tar.bz2
libbu++-e9e5da32b2e154698482b7ec6b7ab2098cd849c8.tar.xz
libbu++-e9e5da32b2e154698482b7ec6b7ab2098cd849c8.zip
Removed some uses of printf in libbu++, I would like to get rid of all of them
some day, but I'm not in much of a rush, I just wanted to do a quick survey. Also added the Formatter::flush special stream value, so now you can do a: sio << "hello" << sio.flush; and it'll flush output immediately. I also tweaked a few things in the cachestore and cache so that they actually throw exceptions and the like instead of just printing out some garbage.
Diffstat (limited to 'src')
-rw-r--r--src/archive.cpp2
-rw-r--r--src/cache.h6
-rw-r--r--src/cachestorenids.h2
-rw-r--r--src/filter.cpp10
-rw-r--r--src/formatter.cpp14
-rw-r--r--src/formatter.h8
6 files changed, 21 insertions, 21 deletions
diff --git a/src/archive.cpp b/src/archive.cpp
index c1c89cc..0efa145 100644
--- a/src/archive.cpp
+++ b/src/archive.cpp
@@ -459,14 +459,12 @@ Bu::Archive &Bu::operator>>(Bu::Archive &s, Bu::Archival &p)
459 459
460Bu::Archive &Bu::operator<<(Bu::Archive &ar, class Bu::Archival *p ) 460Bu::Archive &Bu::operator<<(Bu::Archive &ar, class Bu::Archival *p )
461{ 461{
462 printf("Writing a pointer to an archive...\n");
463 ar << *p; 462 ar << *p;
464 return ar; 463 return ar;
465} 464}
466 465
467Bu::Archive &Bu::operator>>(Bu::Archive &ar, class Bu::Archival *p ) 466Bu::Archive &Bu::operator>>(Bu::Archive &ar, class Bu::Archival *p )
468{ 467{
469 printf("Reading a pointer to an archive...\n");
470 ar >> *p; 468 ar >> *p;
471 return ar; 469 return ar;
472} 470}
diff --git a/src/cache.h b/src/cache.h
index 4ae1aa8..f36c29b 100644
--- a/src/cache.h
+++ b/src/cache.h
@@ -165,9 +165,9 @@ namespace Bu
165 { 165 {
166 if( i.getValue().iRefs > 0 ) 166 if( i.getValue().iRefs > 0 )
167 { 167 {
168 printf("Error? iRefs=%d for key ", i.getValue().iRefs ); 168 // TODO: Throw an error in this case? iRefs != 0 for an
169 __tracer_format( i.getKey() ); 169 // object when the Cache is destroyed.
170 printf("!\n"); 170 throw Bu::ExceptionBase("iRefs not zero.");
171 } 171 }
172 pCalc->onUnload( 172 pCalc->onUnload(
173 i.getValue().pData, 173 i.getValue().pData,
diff --git a/src/cachestorenids.h b/src/cachestorenids.h
index c6a00ce..0f7c72c 100644
--- a/src/cachestorenids.h
+++ b/src/cachestorenids.h
@@ -57,7 +57,7 @@ namespace Bu
57 nStore.initialize( iBlockSize, iPreAllocate ); 57 nStore.initialize( iBlockSize, iPreAllocate );
58 int iStream = nStore.createStream(); 58 int iStream = nStore.createStream();
59 if( iStream != 0 ) 59 if( iStream != 0 )
60 printf("That's...horrible...id = %d.\n\n", iStream ); 60 throw Bu::ExceptionBase("That's...horrible...id = %d.\n\n", iStream );
61 NidsStream ns = nStore.openStream( 0 ); 61 NidsStream ns = nStore.openStream( 0 );
62 Bu::Archive ar( ns, Bu::Archive::save ); 62 Bu::Archive ar( ns, Bu::Archive::save );
63 ar << hId; 63 ar << hId;
diff --git a/src/filter.cpp b/src/filter.cpp
index 9f10026..771cf0d 100644
--- a/src/filter.cpp
+++ b/src/filter.cpp
@@ -14,17 +14,7 @@ Bu::Filter::Filter( Bu::Stream &rNext ) :
14 14
15Bu::Filter::~Filter() 15Bu::Filter::~Filter()
16{ 16{
17 //printf("-> Bu::Filter::~Filter()\n");
18} 17}
19/*
20void Bu::Filter::start()
21{
22 printf("-> Bu::Filter::start()\n");
23}
24
25void Bu::Filter::stop()
26{
27}*/
28 18
29void Bu::Filter::close() 19void Bu::Filter::close()
30{ 20{
diff --git a/src/formatter.cpp b/src/formatter.cpp
index 2fadd96..8c06bde 100644
--- a/src/formatter.cpp
+++ b/src/formatter.cpp
@@ -176,10 +176,16 @@ Bu::Formatter &Bu::operator<<( Bu::Formatter &rOut, Bu::Formatter::Special s )
176 switch( s ) 176 switch( s )
177 { 177 {
178 case Formatter::nl: 178 case Formatter::nl:
179 rOut.write("\n", 1 ); 179 {
180 char ci = rOut.getIndentChar(); 180 rOut.write("\n", 1 );
181 for( int j = 0; j < rOut.getIndent(); j++ ) 181 char ci = rOut.getIndentChar();
182 rOut.write( &ci, 1 ); 182 for( int j = 0; j < rOut.getIndent(); j++ )
183 rOut.write( &ci, 1 );
184 }
185 break;
186
187 case Formatter::flush:
188 rOut.doFlush();
183 break; 189 break;
184 } 190 }
185 return rOut; 191 return rOut;
diff --git a/src/formatter.h b/src/formatter.h
index 5dd7622..30ecf42 100644
--- a/src/formatter.h
+++ b/src/formatter.h
@@ -179,9 +179,15 @@ namespace Bu
179 179
180 enum Special 180 enum Special
181 { 181 {
182 nl 182 nl,
183 flush
183 }; 184 };
184 185
186 void doFlush()
187 {
188 rOut.flush();
189 }
190
185 private: 191 private:
186 Stream &rOut; 192 Stream &rOut;
187 Fmt fLast; 193 Fmt fLast;