ci: bsds: rebuild packages after reconfiguration
[m6w6/libmemcached] / include / libhashkit-1.0 / hashkit.hpp
1 /*
2 +--------------------------------------------------------------------+
3 | libmemcached - C/C++ Client Library for memcached |
4 +--------------------------------------------------------------------+
5 | Redistribution and use in source and binary forms, with or without |
6 | modification, are permitted under the terms of the BSD license. |
7 | You should have received a copy of the license in a bundled file |
8 | named LICENSE; in case you did not receive a copy you can review |
9 | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
10 +--------------------------------------------------------------------+
11 | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
12 | Copyright (c) 2020 Michael Wallner <mike@php.net> |
13 +--------------------------------------------------------------------+
14 */
15
16 #pragma once
17
18 #include <libhashkit-1.0/hashkit.h>
19 #include <string>
20
21 class Hashkit {
22 public:
23 Hashkit() { hashkit_create(&self); }
24
25 Hashkit(const Hashkit &source) { hashkit_clone(&self, &source.self); }
26
27 Hashkit &operator=(const Hashkit &source) {
28 hashkit_free(&self);
29 hashkit_clone(&self, &source.self);
30
31 return *this;
32 }
33
34 friend bool operator==(const Hashkit &left, const Hashkit &right) {
35 return hashkit_compare(&left.self, &right.self);
36 }
37
38 uint32_t digest(std::string &str) { return hashkit_digest(&self, str.c_str(), str.length()); }
39
40 uint32_t digest(const char *key, size_t key_length) {
41 return hashkit_digest(&self, key, key_length);
42 }
43
44 hashkit_return_t set_function(hashkit_hash_algorithm_t hash_algorithm) {
45 return hashkit_set_function(&self, hash_algorithm);
46 }
47
48 hashkit_return_t set_distribution_function(hashkit_hash_algorithm_t hash_algorithm) {
49 return hashkit_set_distribution_function(&self, hash_algorithm);
50 }
51
52 ~Hashkit() { hashkit_free(&self); }
53
54 private:
55 hashkit_st self;
56 };