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-2022, 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 #include <ndn-cxx/util/span.hpp>
27 
28 namespace psync::detail {
29 
30 uint32_t
31 murmurHash3(const void* key, size_t len, uint32_t seed);
32 
36 uint32_t
37 murmurHash3(uint32_t seed, const ndn::Name& name);
38 
39 inline uint32_t
40 murmurHash3(uint32_t seed, uint32_t value)
41 {
42  return murmurHash3(&value, sizeof(value), seed);
43 }
44 
45 std::shared_ptr<ndn::Buffer>
46 compress(CompressionScheme scheme, ndn::span<const uint8_t> buffer);
47 
48 std::shared_ptr<ndn::Buffer>
49 decompress(CompressionScheme scheme, ndn::span<const uint8_t> buffer);
50 
51 } // namespace psync::detail
52 
53 #endif // PSYNC_DETAIL_UTIL_HPP
uint32_t murmurHash3(const void *key, size_t len, uint32_t seed)
Definition: util.cpp:58
std::shared_ptr< ndn::Buffer > compress(CompressionScheme scheme, ndn::span< const uint8_t > buffer)
Definition: util.cpp:124
std::shared_ptr< ndn::Buffer > decompress(CompressionScheme scheme, ndn::span< const uint8_t > buffer)
Definition: util.cpp:183
CompressionScheme
Definition: common.hpp:43