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/types.h>
20 #include <libhashkit/algorithm.h>
21 #include <libhashkit/behavior.h>
22 #include <libhashkit/digest.h>
23 #include <libhashkit/function.h>
24 #include <libhashkit/strerror.h>
34 hashkit_st
*hashkit_create(hashkit_st
*hash
);
37 hashkit_st
*hashkit_clone(hashkit_st
*destination
, const hashkit_st
*ptr
);
40 bool hashkit_compare(const hashkit_st
*first
, const hashkit_st
*second
);
43 void hashkit_free(hashkit_st
*hash
);
45 #define hashkit_is_allocated(__object) ((__object)->options.is_allocated)
46 #define hashkit_is_initialized(__object) ((__object)->options.is_initialized)
54 struct hashkit_function_st
{
55 hashkit_hash_fn function
;
57 } base_hash
, distribution_hash
;
60 bool is_base_same_distributed
:1;
69 class Hashkit
: private hashkit_st
{
78 Hashkit(const Hashkit
& source
)
80 hashkit_clone(this, &source
);
83 Hashkit
& operator=(const Hashkit
& source
)
86 hashkit_clone(this, &source
);
91 friend bool operator==(const Hashkit
&left
, const Hashkit
&right
)
93 return hashkit_compare(&left
, &right
);
96 uint32_t digest(std::string
& str
)
98 return hashkit_digest(this, str
.c_str(), str
.length());
101 uint32_t digest(const char *key
, size_t key_length
)
103 return hashkit_digest(this, key
, key_length
);
106 hashkit_return_t
set_function(hashkit_hash_algorithm_t hash_algorithm
)
108 return hashkit_set_function(this, hash_algorithm
);
111 hashkit_return_t
set_distribution_function(hashkit_hash_algorithm_t hash_algorithm
)
113 return hashkit_set_function(this, hash_algorithm
);
124 #endif /* HASHKIT_H */