util.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2014-2020, The University of Memphis
4  *
5  * This file is part of PSync.
6  * See AUTHORS.md for complete list of PSync authors and contributors.
7  *
8  * PSync is free software: you can redistribute it and/or modify it under the terms
9  * of the GNU Lesser General Public License as published by the Free Software Foundation,
10  * either version 3 of the License, or (at your option) any later version.
11  *
12  * PSync is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
13  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14  * PURPOSE. See the GNU Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License along with
17  * PSync, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef PSYNC_DETAIL_UTIL_HPP
21 #define PSYNC_DETAIL_UTIL_HPP
22 
23 #include "PSync/common.hpp"
24 
25 #include <ndn-cxx/encoding/buffer.hpp>
26 
27 #include <string>
28 
29 namespace psync {
30 namespace detail {
31 
32 uint32_t
33 murmurHash3(const void* key, size_t len, uint32_t seed);
34 
35 inline uint32_t
36 murmurHash3(uint32_t seed, const std::string& str)
37 {
38  return murmurHash3(str.data(), str.size(), seed);
39 }
40 
41 inline uint32_t
42 murmurHash3(uint32_t seed, uint32_t value)
43 {
44  return murmurHash3(&value, sizeof(value), seed);
45 }
46 
47 std::shared_ptr<ndn::Buffer>
48 compress(CompressionScheme scheme, const uint8_t* buffer, size_t bufferSize);
49 
50 std::shared_ptr<ndn::Buffer>
51 decompress(CompressionScheme scheme, const uint8_t* buffer, size_t bufferSize);
52 
53 } // namespace detail
54 } // namespace psync
55 
56 #endif // PSYNC_DETAIL_UTIL_HPP
Definition: common.hpp:33
std::shared_ptr< ndn::Buffer > decompress(CompressionScheme scheme, const uint8_t *buffer, size_t bufferSize)
Definition: util.cpp:176
CompressionScheme
Definition: common.hpp:35
std::shared_ptr< ndn::Buffer > compress(CompressionScheme scheme, const uint8_t *buffer, size_t bufferSize)
Definition: util.cpp:120
uint32_t murmurHash3(const void *key, size_t len, uint32_t seed)
Definition: util.cpp:61