From 509d136e9adb60c56369565b9545e613cac3678e Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Thu, 12 Nov 2009 17:05:30 +0000 Subject: I've started my campaign to clean up all of the header files in libbu++ as far as includes go. This required a little bit of reworking as far as archive goes, but I've been planning on changing it aronud for a bit anyway. The final result here is that you may need to add some more includes in your own code, libbu++ doesn't include as many random things you didn't ask for anymore, most of these seem to be bu/hash.h, unistd.h, and time.h. Also, any Archive functions and operators should use ArchiveBase when they can instead of Archive, archivebase.h is a much lighterweight include that will be used everywhere in core that it can be, there are a few classes that actually want a specific archiver to be used, they will use it (such as the nids storage class). So far, except for adding header files, nothing has changed in functionality, and no other code changes should be required, although the above mentioned archive changeover is reccomended. --- src/hash.h | 56 +++++++++++++++++++------------------------------------- 1 file changed, 19 insertions(+), 37 deletions(-) (limited to 'src/hash.h') diff --git a/src/hash.h b/src/hash.h index 10c661f..09025ba 100644 --- a/src/hash.h +++ b/src/hash.h @@ -8,17 +8,11 @@ #ifndef BU_HASH_H #define BU_HASH_H -#include -#include #include -#include -#include -#include #include "bu/exceptionbase.h" #include "bu/list.h" #include "bu/util.h" -//#include "archival.h" -//#include "archive.h" +#include "archivebase.h" #define bitsToBytes( n ) (n/32+(n%32>0 ? 1 : 0)) @@ -373,6 +367,11 @@ namespace Bu return nFilled-nDeleted; } + bool isEmpty() const + { + return (nFilled-nDeleted) == 0; + } + /** * Get the number of items which have been deleted, but not yet * cleaned up. @@ -1171,9 +1170,6 @@ namespace Bu template<> uint32_t __calcHashCode( char * const &k ); template<> bool __cmpHashKeys( char * const &a, char * const &b ); - template<> uint32_t __calcHashCode( const std::string &k ); - template<> bool __cmpHashKeys( const std::string &a, const std::string &b ); - class Formatter; Formatter &operator<<( Formatter &rOut, char *sStr ); Formatter &operator<<( Formatter &rOut, signed char c ); @@ -1190,30 +1186,30 @@ namespace Bu f << '}'; return f; - } + } - /* - template - Archive &operator<<( Archive &ar, Hash &h ) + template + ArchiveBase &operator<<( ArchiveBase &ar, const Hash &h ) { - ar << h.size(); - for( typename Hash::iterator i = h.begin(); i != h.end(); i++ ) + ar << h.getSize(); + for( typename Hash::const_iterator i = h.begin(); i != h.end(); i++ ) { - std::pair p = *i; - ar << p.first << p.second; + ar << (i.getKey()) << (i.getValue()); } return ar; } - template - Archive &operator>>( Archive &ar, Hash &h ) + template + ArchiveBase &operator>>( ArchiveBase &ar, Hash &h ) { h.clear(); - uint32_t nSize; + long nSize; ar >> nSize; - for( uint32_t j = 0; j < nSize; j++ ) + for( long j = 0; j < nSize; j++ ) { key k; value v; ar >> k >> v; @@ -1221,21 +1217,7 @@ namespace Bu } return ar; - }*/ - - /* - template - Serializer &operator&&( Serializer &ar, Hash &h ) - { - if( ar.isLoading() ) - { - return ar >> h; - } - else - { - return ar << h; - } - }*/ + } } #endif -- cgit v1.2.3