diff options
| author | Mike Buland <eichlan@xagasoft.com> | 2010-08-27 21:53:54 +0000 |
|---|---|---|
| committer | Mike Buland <eichlan@xagasoft.com> | 2010-08-27 21:53:54 +0000 |
| commit | c10c9ef627c7e79fde6170fe334238bbcb5d66e5 (patch) | |
| tree | 4a0971d81e666e91866ddeaf9b58b952ce2fdd0a /src/dictionary.cpp | |
| parent | 2a72923397d866f33221b9d32a3f9653d1a960e7 (diff) | |
| download | libgats-c10c9ef627c7e79fde6170fe334238bbcb5d66e5.tar.gz libgats-c10c9ef627c7e79fde6170fe334238bbcb5d66e5.tar.bz2 libgats-c10c9ef627c7e79fde6170fe334238bbcb5d66e5.tar.xz libgats-c10c9ef627c7e79fde6170fe334238bbcb5d66e5.zip | |
Added formatter handlers for debugging, works really well. Also added a bunch
more helpers to make it as easy to use as possible.
Diffstat (limited to 'src/dictionary.cpp')
| -rw-r--r-- | src/dictionary.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
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 @@ | |||
| 6 | #include "gats/string.h" | 6 | #include "gats/string.h" |
| 7 | #include "gats/list.h" | 7 | #include "gats/list.h" |
| 8 | 8 | ||
| 9 | #include <bu/formatter.h> | ||
| 10 | |||
| 9 | template<> | 11 | template<> |
| 10 | uint32_t Bu::__calcHashCode<Gats::String>( const Gats::String &s ) | 12 | uint32_t Bu::__calcHashCode<Gats::String>( const Gats::String &s ) |
| 11 | { | 13 | { |
| @@ -156,3 +158,24 @@ Gats::Dictionary *Gats::Dictionary::getDict( const Bu::FString &sKey ) | |||
| 156 | return pOb; | 158 | return pOb; |
| 157 | } | 159 | } |
| 158 | 160 | ||
| 161 | Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::Dictionary &d ) | ||
| 162 | { | ||
| 163 | f << "(dict) {"; | ||
| 164 | f.incIndent(); | ||
| 165 | int iMax = 0; | ||
| 166 | for( Gats::Dictionary::const_iterator i = d.begin(); i; i++ ) | ||
| 167 | { | ||
| 168 | if( i.getKey().getSize() > iMax ) | ||
| 169 | iMax = i.getKey().getSize(); | ||
| 170 | } | ||
| 171 | iMax += 2; | ||
| 172 | for( Gats::Dictionary::const_iterator i = d.begin(); i; i++ ) | ||
| 173 | { | ||
| 174 | f << f.nl << Bu::Fmt( iMax ) << i.getKey() + ": " << *i.getValue(); | ||
| 175 | } | ||
| 176 | f.decIndent(); | ||
| 177 | f << f.nl << "}"; | ||
| 178 | |||
| 179 | return f; | ||
| 180 | } | ||
| 181 | |||
