X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libhashkit%2Fhashkit.h;h=2d8ad3a2d38aafdaa66737a29921227b96deedc7;hb=6e9731947eace4be83d553a242a44b36b3adcf22;hp=e3d5862e905f6f5867bde504e83a9136f87009c1;hpb=e36367e4c27fc5537d437c4a4ea741f57426b37d;p=m6w6%2Flibmemcached diff --git a/libhashkit/hashkit.h b/libhashkit/hashkit.h index e3d5862e..2d8ad3a2 100644 --- a/libhashkit/hashkit.h +++ b/libhashkit/hashkit.h @@ -22,12 +22,10 @@ #include #include #include +#include #include #ifdef __cplusplus - -#include - extern "C" { #endif @@ -58,66 +56,72 @@ struct hashkit_st } base_hash, distribution_hash; struct { - bool is_base_same_distributed HASHKIT_BITFIELD; + bool is_base_same_distributed:1; } flags; struct { - bool is_allocated HASHKIT_BITFIELD; + bool is_allocated:1; } options; }; #ifdef __cplusplus -class Hashkit : private hashkit_st { + +#include + +class Hashkit { public: Hashkit() { - hashkit_create(this); + hashkit_create(&self); } Hashkit(const Hashkit& source) { - hashkit_clone(this, &source); + hashkit_clone(&self, &source.self); } Hashkit& operator=(const Hashkit& source) { - hashkit_free(this); - hashkit_clone(this, &source); + hashkit_free(&self); + hashkit_clone(&self, &source.self); return *this; } friend bool operator==(const Hashkit &left, const Hashkit &right) { - return hashkit_compare(&left, &right); + return hashkit_compare(&left.self, &right.self); } uint32_t digest(std::string& str) { - return hashkit_digest(this, str.c_str(), str.length()); + return hashkit_digest(&self, str.c_str(), str.length()); } uint32_t digest(const char *key, size_t key_length) { - return hashkit_digest(this, key, key_length); + return hashkit_digest(&self, key, key_length); } hashkit_return_t set_function(hashkit_hash_algorithm_t hash_algorithm) { - return hashkit_set_function(this, hash_algorithm); + return hashkit_set_function(&self, hash_algorithm); } hashkit_return_t set_distribution_function(hashkit_hash_algorithm_t hash_algorithm) { - return hashkit_set_function(this, hash_algorithm); + return hashkit_set_function(&self, hash_algorithm); } ~Hashkit() { - hashkit_free(this); + hashkit_free(&self); } +private: + + hashkit_st self; }; #endif