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/str_algorithm.h>
26 #include <libhashkit/strerror.h>
33 hashkit_st
*hashkit_create(hashkit_st
*hash
);
36 hashkit_st
*hashkit_clone(hashkit_st
*destination
, const hashkit_st
*ptr
);
39 bool hashkit_compare(const hashkit_st
*first
, const hashkit_st
*second
);
42 void hashkit_free(hashkit_st
*hash
);
44 #define hashkit_is_allocated(__object) ((__object)->options.is_allocated)
45 #define hashkit_is_initialized(__object) ((__object)->options.is_initialized)
53 struct hashkit_function_st
{
54 hashkit_hash_fn function
;
56 } base_hash
, distribution_hash
;
59 bool is_base_same_distributed
:1;
77 hashkit_create(&self
);
80 Hashkit(const Hashkit
& source
)
82 hashkit_clone(&self
, &source
.self
);
85 Hashkit
& operator=(const Hashkit
& source
)
88 hashkit_clone(&self
, &source
.self
);
93 friend bool operator==(const Hashkit
&left
, const Hashkit
&right
)
95 return hashkit_compare(&left
.self
, &right
.self
);
98 uint32_t digest(std::string
& str
)
100 return hashkit_digest(&self
, str
.c_str(), str
.length());
103 uint32_t digest(const char *key
, size_t key_length
)
105 return hashkit_digest(&self
, key
, key_length
);
108 hashkit_return_t
set_function(hashkit_hash_algorithm_t hash_algorithm
)
110 return hashkit_set_function(&self
, hash_algorithm
);
113 hashkit_return_t
set_distribution_function(hashkit_hash_algorithm_t hash_algorithm
)
115 return hashkit_set_function(&self
, hash_algorithm
);
129 #endif /* HASHKIT_H */