summaryrefslogtreecommitdiff
path: root/src/hash.h
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2007-10-14 22:27:51 +0000
committerMike Buland <eichlan@xagasoft.com>2007-10-14 22:27:51 +0000
commite72d6077b475bc6142afc3b5967db113922c76f5 (patch)
tree45bdb7b69ec4c1dbcfadc1fa568b1d6b341a6f0f /src/hash.h
parent44eac9521632f8da42f73085db945bdba45f8311 (diff)
downloadlibbu++-e72d6077b475bc6142afc3b5967db113922c76f5.tar.gz
libbu++-e72d6077b475bc6142afc3b5967db113922c76f5.tar.bz2
libbu++-e72d6077b475bc6142afc3b5967db113922c76f5.tar.xz
libbu++-e72d6077b475bc6142afc3b5967db113922c76f5.zip
Fixed an interesting ideosyncacy in Bu::Hash in a safe way, I should try to do
this with the Bu::Archive next. Basically, there's one generic template function that will convert anything that can safely cast to a uint32_t and that supports direct comparisson, and doesn't have it's own override already to be a Hash key, such as char, uint8_t, uint64_t, etc. The Telnet protocol handler does everything I need it too for now, next up for it is escape sequence handling, it would be nice to make this general too, by using the termcap database or something, but there is an ANSI/ISO standard now, I may just go ahead and use that. Also, it looks like it'd be pretty easy to make the canonical mode editing functions be pluggable to facilitate different types of editing, but that can be done down the road as well.
Diffstat (limited to 'src/hash.h')
-rw-r--r--src/hash.h14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/hash.h b/src/hash.h
index 62b19c9..be57786 100644
--- a/src/hash.h
+++ b/src/hash.h
@@ -1008,12 +1008,16 @@ namespace Bu
1008 challoc ca; 1008 challoc ca;
1009 sizecalc szCalc; 1009 sizecalc szCalc;
1010 }; 1010 };
1011
1012 template<typename T> uint32_t __calcHashCode( const T &k )
1013 {
1014 return static_cast<uint32_t>( k );
1015 }
1011 1016
1012 template<> uint32_t __calcHashCode<int>( const int &k ); 1017 template<typename T> bool __cmpHashKeys( const T &a, const T &b )
1013 template<> bool __cmpHashKeys<int>( const int &a, const int &b ); 1018 {
1014 1019 return (a == b);
1015 template<> uint32_t __calcHashCode<unsigned int>( const unsigned int &k ); 1020 }
1016 template<> bool __cmpHashKeys<unsigned int>( const unsigned int &a, const unsigned int &b );
1017 1021
1018 template<> uint32_t __calcHashCode<const char *>( const char * const &k ); 1022 template<> uint32_t __calcHashCode<const char *>( const char * const &k );
1019 template<> bool __cmpHashKeys<const char *>( const char * const &a, const char * const &b ); 1023 template<> bool __cmpHashKeys<const char *>( const char * const &a, const char * const &b );