NIST Biometric Evaluation Framework
Software components for biometric technology evaluations
be_io_gzip.h
Go to the documentation of this file.
1/*
2 * This software was developed at the National Institute of Standards and
3 * Technology (NIST) by employees of the Federal Government in the course
4 * of their official duties. Pursuant to title 17 Section 105 of the
5 * United States Code, this software is not subject to copyright protection
6 * and is in the public domain. NIST assumes no responsibility whatsoever for
7 * its use by other parties, and makes no guarantees, expressed or implied,
8 * about its quality, reliability, or any other characteristic.
9 */
10
11#ifndef __BE_IO_GZIP__
12#define __BE_IO_GZIP__
13
14#include <string>
15#include <zlib.h>
16
17#include <be_error_exception.h>
18#include <be_io_compressor.h>
19#include <be_io_properties.h>
20#include <be_memory_autoarray.h>
21
22namespace BiometricEvaluation
23{
24 namespace IO
25 {
30 class GZip : public Compressor
31 {
32 public:
33 /*
34 * zlib compressor property keys.
35 */
37 static const std::string COMPRESSION_LEVEL;
39 static const std::string COMPRESSION_STRATEGY;
41 static const std::string COMPRESSION_METHOD;
43 static const std::string INPUT_DATA_TYPE;
45 static const std::string WINDOW_BITS;
47 static const std::string MEMORY_LEVEL;
49 static const std::string CHUNK_SIZE;
50
52
55 const uint8_t *const uncompressedData,
56 uint64_t uncompressedDataSize)
57 const;
58
61 const Memory::uint8Array &uncompressedData)
62 const;
63
64 void
66 const uint8_t *const uncompressedData,
67 uint64_t uncompressedDataSize,
68 const std::string &outputFile) const;
69
70 void
72 const Memory::uint8Array &uncompressedData,
73 const std::string &outputFile) const;
74
77 const std::string &inputFile)
78 const;
79
80 void
82 const std::string &inputFile,
83 const std::string &outputFile) const;
84
87 const uint8_t *const compressedData,
88 uint64_t compressedDataSize)
89 const;
90
93 const Memory::uint8Array &compressedData)
94 const;
95
98 const std::string &input)
99 const;
100
101 void
103 const std::string &inputFile,
104 const std::string &outputFile) const;
105
106 void
108 const uint8_t *const compressedData,
109 const uint64_t compressedDataSize,
110 const std::string &outputFile) const;
111
112 void
114 const Memory::uint8Array &compressedData,
115 const std::string &outputFile) const;
116
118
130 const GZip &other) = delete;
131
145 GZip&
147 const GZip& other) = delete;
148
149 private:
157 z_stream
158 initCompressionStream()
159 const;
160
185 int32_t
186 compressChunk(
187 uint8_t flush,
188 uint64_t chunkSize,
189 uint64_t &totalCompressedBytes,
190 Memory::uint8Array &compressedBuf,
191 bool compressedBufIsChunk,
192 z_stream &strm) const;
193
201 z_stream
202 initDecompressionStream()
203 const;
204
227 int32_t
228 decompressChunk(
229 uint64_t chunkSize,
230 uint64_t &totalUncompressedBytes,
231 Memory::uint8Array &uncompressedBuf,
232 bool uncompressedBufIsChunk,
233 z_stream &strm) const;
234
236 static const uint8_t GZIP_WBITS_MAGIC = 16;
237 };
238 }
239}
240
241#endif /* __BE_IO_GZIP__ */
Common interface for classes providing compressing and decompressing functionality.
An IO::Compressor for gzip compression from zlib.
Definition: be_io_gzip.h:31
static const std::string INPUT_DATA_TYPE
The type of data being compressed.
Definition: be_io_gzip.h:43
Memory::uint8Array compress(const Memory::uint8Array &uncompressedData) const
Compress a buffer.
static const std::string COMPRESSION_LEVEL
How thorough the compression should be.
Definition: be_io_gzip.h:37
Memory::uint8Array decompress(const Memory::uint8Array &compressedData) const
Decompress a compressed buffer.
Memory::uint8Array decompress(const std::string &input) const
Decompress a compressed buffer into a file.
void compress(const uint8_t *const uncompressedData, uint64_t uncompressedDataSize, const std::string &outputFile) const
Compress a buffer.
static const std::string COMPRESSION_METHOD
Which underlying method in the compressor.
Definition: be_io_gzip.h:41
void compress(const std::string &inputFile, const std::string &outputFile) const
Compress a file.
Memory::uint8Array decompress(const uint8_t *const compressedData, uint64_t compressedDataSize) const
Decompress a compressed buffer.
static const std::string CHUNK_SIZE
How many bytes to work at a time.
Definition: be_io_gzip.h:49
GZip & operator=(const GZip &other)=delete
Assignment overload (disabled).
Memory::uint8Array compress(const uint8_t *const uncompressedData, uint64_t uncompressedDataSize) const
Compress a buffer.
GZip(const GZip &other)=delete
Copy constructor (disabled).
static const std::string COMPRESSION_STRATEGY
Which underlying algorithm to use.
Definition: be_io_gzip.h:39
static const std::string MEMORY_LEVEL
How much memory for internal compression state.
Definition: be_io_gzip.h:47
void decompress(const Memory::uint8Array &compressedData, const std::string &outputFile) const
Decompress a file.
void decompress(const std::string &inputFile, const std::string &outputFile) const
Decompress a file.
Memory::uint8Array compress(const std::string &inputFile) const
Compress a file.
void decompress(const uint8_t *const compressedData, const uint64_t compressedDataSize, const std::string &outputFile) const
Decompress a file.
static const std::string WINDOW_BITS
Window size.
Definition: be_io_gzip.h:45
void compress(const Memory::uint8Array &uncompressedData, const std::string &outputFile) const
Compress a buffer.
This software was developed at the National Institute of Standards and Technology (NIST) by employees...