X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libhashkit%2Fhashkit.h;h=451333075f225c83641647dcd93065db946935f1;hb=3430cb015fb0add207ff733f484dbb4a9fed3655;hp=fe6c148d97f1a1ef4e1909922f605d9646f86503;hpb=dac48f2dbe34915755f8f4f7f88419f47dc9e27f;p=m6w6%2Flibmemcached diff --git a/libhashkit/hashkit.h b/libhashkit/hashkit.h index fe6c148d..45133307 100644 --- a/libhashkit/hashkit.h +++ b/libhashkit/hashkit.h @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -45,6 +46,10 @@ void hashkit_free(hashkit_st *hash); #define hashkit_is_allocated(__object) ((__object)->options.is_allocated) #define hashkit_is_initialized(__object) ((__object)->options.is_initialized) +#ifdef __cplusplus +} // extern "C" +#endif + struct hashkit_st { struct hashkit_function_st { @@ -59,35 +64,32 @@ struct hashkit_st struct { bool is_allocated:1; } options; +}; #ifdef __cplusplus +class Hashkit : private hashkit_st { + +public: - hashkit_st() : - base_hash(), - distribution_hash(), - flags(), - options() + Hashkit() { hashkit_create(this); } - hashkit_st(const hashkit_st& source) : - base_hash(), - distribution_hash(), - flags(), - options() + Hashkit(const Hashkit& source) { hashkit_clone(this, &source); } - hashkit_st& operator=(const hashkit_st& source) - { + Hashkit& operator=(const Hashkit& source) + { + hashkit_free(this); hashkit_clone(this, &source); return *this; } - friend bool operator==(const hashkit_st &left, const hashkit_st &right) + friend bool operator==(const Hashkit &left, const Hashkit &right) { return hashkit_compare(&left, &right); } @@ -112,15 +114,11 @@ struct hashkit_st return hashkit_set_function(this, hash_algorithm); } - ~hashkit_st() + ~Hashkit() { hashkit_free(this); } -#endif }; - -#ifdef __cplusplus -} // extern "C" #endif