From c10c9ef627c7e79fde6170fe334238bbcb5d66e5 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Fri, 27 Aug 2010 21:53:54 +0000 Subject: Added formatter handlers for debugging, works really well. Also added a bunch more helpers to make it as easy to use as possible. --- src/dictionary.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/dictionary.cpp') diff --git a/src/dictionary.cpp b/src/dictionary.cpp index 1a9549f..b789bbf 100644 --- a/src/dictionary.cpp +++ b/src/dictionary.cpp @@ -6,6 +6,8 @@ #include "gats/string.h" #include "gats/list.h" +#include + template<> uint32_t Bu::__calcHashCode( const Gats::String &s ) { @@ -156,3 +158,24 @@ Gats::Dictionary *Gats::Dictionary::getDict( const Bu::FString &sKey ) return pOb; } +Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::Dictionary &d ) +{ + f << "(dict) {"; + f.incIndent(); + int iMax = 0; + for( Gats::Dictionary::const_iterator i = d.begin(); i; i++ ) + { + if( i.getKey().getSize() > iMax ) + iMax = i.getKey().getSize(); + } + iMax += 2; + for( Gats::Dictionary::const_iterator i = d.begin(); i; i++ ) + { + f << f.nl << Bu::Fmt( iMax ) << i.getKey() + ": " << *i.getValue(); + } + f.decIndent(); + f << f.nl << "}"; + + return f; +} + -- cgit v1.2.3