2 * Copyright (C) 2009-2010 Brian Aker
5 * Use and distribution licensed under the BSD license. See
6 * the COPYING file in the parent directory for full text.
13 #if !defined(__cplusplus)
17 #include <sys/types.h>
18 #include <libhashkit/visibility.h>
19 #include <libhashkit/configure.h>
20 #include <libhashkit/types.h>
21 #include <libhashkit/algorithm.h>
22 #include <libhashkit/behavior.h>
23 #include <libhashkit/digest.h>
24 #include <libhashkit/function.h>
25 #include <libhashkit/strerror.h>
35 hashkit_st
*hashkit_create(hashkit_st
*hash
);
38 hashkit_st
*hashkit_clone(hashkit_st
*destination
, const hashkit_st
*ptr
);
41 bool hashkit_compare(const hashkit_st
*first
, const hashkit_st
*second
);
44 void hashkit_free(hashkit_st
*hash
);
46 #define hashkit_is_allocated(__object) ((__object)->options.is_allocated)
47 #define hashkit_is_initialized(__object) ((__object)->options.is_initialized)
55 struct hashkit_function_st
{
56 hashkit_hash_fn function
;
58 } base_hash
, distribution_hash
;
61 bool is_base_same_distributed
:1;
70 class Hashkit
: private hashkit_st
{
79 Hashkit(const Hashkit
& source
)
81 hashkit_clone(this, &source
);
84 Hashkit
& operator=(const Hashkit
& source
)
87 hashkit_clone(this, &source
);
92 friend bool operator==(const Hashkit
&left
, const Hashkit
&right
)
94 return hashkit_compare(&left
, &right
);
97 uint32_t digest(std::string
& str
)
99 return hashkit_digest(this, str
.c_str(), str
.length());
102 uint32_t digest(const char *key
, size_t key_length
)
104 return hashkit_digest(this, key
, key_length
);
107 hashkit_return_t
set_function(hashkit_hash_algorithm_t hash_algorithm
)
109 return hashkit_set_function(this, hash_algorithm
);
112 hashkit_return_t
set_distribution_function(hashkit_hash_algorithm_t hash_algorithm
)
114 return hashkit_set_function(this, hash_algorithm
);
125 #endif /* HASHKIT_H */