Ocean
Compression.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) Meta Platforms, Inc. and affiliates.
3  *
4  * This source code is licensed under the MIT license found in the
5  * LICENSE file in the root directory of this source tree.
6  */
7 
8 #ifndef META_OCEAN_IO_COMPRESSION_H
9 #define META_OCEAN_IO_COMPRESSION_H
10 
11 #include "ocean/io/IO.h"
12 
13 #include <vector>
14 
15 namespace Ocean
16 {
17 
18 namespace IO
19 {
20 
21 /**
22  * This class implements individual compression algorithms.
23  * @ingroup io
24  */
25 class OCEAN_IO_EXPORT Compression
26 {
27  public:
28 
29  /**
30  * Definition of a vector holding bytes.
31  */
32  typedef std::vector<uint8_t> Buffer;
33 
34  public:
35 
36  /**
37  * Compresses a buffer with gzip
38  * @param buffer The buffer to compress
39  * @param bufferSize The size of the buffer, in bytes
40  * @param compressedBuffer The compressed buffer
41  * @return True, if succeeded
42  */
43  static bool gzipCompress(const void* buffer, const size_t bufferSize, Buffer& compressedBuffer);
44 
45  /**
46  * Decompresses a buffer which has been compressed with gzip
47  * @param compressedBuffer The compressed buffer
48  * @param compressedBufferSize The size of the uncompressed buffer, in bytes
49  * @param uncompressedBuffer The uncompressed buffer
50  * @return True, if succeeded
51  */
52  static bool gzipDecompress(const void* compressedBuffer, const size_t compressedBufferSize, Buffer& uncompressedBuffer);
53 };
54 
55 }
56 
57 }
58 
59 #endif // META_OCEAN_IO_COMPRESSION_H
This class implements individual compression algorithms.
Definition: Compression.h:26
static bool gzipDecompress(const void *compressedBuffer, const size_t compressedBufferSize, Buffer &uncompressedBuffer)
Decompresses a buffer which has been compressed with gzip.
std::vector< uint8_t > Buffer
Definition of a vector holding bytes.
Definition: Compression.h:32
static bool gzipCompress(const void *buffer, const size_t bufferSize, Buffer &compressedBuffer)
Compresses a buffer with gzip.
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15