aws-crt-cpp
C++ wrapper around the aws-c-* libraries. Provides Cross-Platform Transport Protocols and SSL/TLS implementations for C++.
XXHash.h
Go to the documentation of this file.
1 #pragma once
2 
6 #include <aws/crt/Exports.h>
7 #include <aws/crt/Types.h>
8 
9 struct aws_xxhash;
10 namespace Aws
11 {
12  namespace Crt
13  {
14  namespace Checksum
15  {
21  bool AWS_CRT_CPP_API ComputeXXHash64(const ByteCursor &input, ByteBuf &output, uint64_t seed = 0) noexcept;
22 
28  bool AWS_CRT_CPP_API
29  ComputeXXHash3_64(const ByteCursor &input, ByteBuf &output, uint64_t seed = 0) noexcept;
30 
36  bool AWS_CRT_CPP_API
37  ComputeXXHash3_128(const ByteCursor &input, ByteBuf &output, uint64_t seed = 0) noexcept;
38 
44  class AWS_CRT_CPP_API XXHash final
45  {
46  public:
47  XXHash(const XXHash &) = delete;
48  XXHash &operator=(const XXHash &) = delete;
49  XXHash(XXHash &&toMove) noexcept = default;
50  XXHash &operator=(XXHash &&toMove) noexcept = default;
51 
55  inline int LastError() const noexcept { return m_lastError; }
56 
60  static XXHash CreateXXHash64(uint64_t seed = 0, Allocator *allocator = ApiAllocator()) noexcept;
61 
65  static XXHash CreateXXHash3_64(uint64_t seed = 0, Allocator *allocator = ApiAllocator()) noexcept;
66 
70  static XXHash CreateXXHash3_128(uint64_t seed = 0, Allocator *allocator = ApiAllocator()) noexcept;
71 
76  bool Update(const ByteCursor &toHash) noexcept;
77 
83  bool Digest(ByteBuf &output) noexcept;
84 
85  private:
86  XXHash(aws_xxhash *hash) noexcept;
87  XXHash() = delete;
88 
89  ScopedResource<struct aws_xxhash> m_hash;
90  int m_lastError;
91  };
92  } // namespace Checksum
93  } // namespace Crt
94 } // namespace Aws
bool AWS_CRT_CPP_API ComputeXXHash3_128(const ByteCursor &input, ByteBuf &output, uint64_t seed=0) noexcept
Definition: XXHash.cpp:25
#define AWS_CRT_CPP_API
Definition: Exports.h:36
aws_byte_buf ByteBuf
Definition: Types.h:30
Definition: XXHash.h:44
aws_allocator Allocator
Definition: Allocator.h:14
aws_byte_cursor ByteCursor
Definition: Types.h:31
AWS_CRT_CPP_API Allocator * ApiAllocator() noexcept
Definition: Allocator.cpp:24
int LastError() const noexcept
Definition: XXHash.h:55
bool AWS_CRT_CPP_API ComputeXXHash64(const ByteCursor &input, ByteBuf &output, uint64_t seed=0) noexcept
Definition: XXHash.cpp:15
bool AWS_CRT_CPP_API ComputeXXHash3_64(const ByteCursor &input, ByteBuf &output, uint64_t seed=0) noexcept
Definition: XXHash.cpp:20
std::unique_ptr< T, std::function< void(T *)>> ScopedResource
Definition: Types.h:163
Definition: Allocator.h:10