activemq-cpp-3.9.5
Deflater.h
Go to the documentation of this file.
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18#ifndef _DECAF_UTI_ZIP_DEFLATER_H_
19#define _DECAF_UTI_ZIP_DEFLATER_H_
20
21#include <decaf/util/Config.h>
22
27
28#include <vector>
29
30namespace decaf {
31namespace util {
32namespace zip {
33
34 class DeflaterData;
35
52 class DECAF_API Deflater {
53 public:
54
58 static const int BEST_SPEED;
59
63 static const int BEST_COMPRESSION;
64
68 static const int DEFAULT_COMPRESSION;
69
73 static const int DEFLATED;
74
78 static const int NO_COMPRESSION;
79
85 static const int FILTERED;
86
90 static const int HUFFMAN_ONLY;
91
95 static const int DEFAULT_STRATEGY;
96
97 private:
98
99 // Class internal data used during compression.
100 DeflaterData* data;
101
102 private:
103
104 Deflater(const Deflater&);
105 Deflater operator=(const Deflater&);
106
107 public:
108
119 Deflater(int level, bool nowrap = false);
120
126
127 virtual ~Deflater();
128
146 void setInput(const unsigned char* buffer, int size, int offset, int length);
147
162 void setInput(const std::vector<unsigned char>& buffer, int offset, int length);
163
173 void setInput(const std::vector<unsigned char>& buffer);
174
194 void setDictionary(const unsigned char* buffer, int size, int offset, int length);
195
212 void setDictionary(const std::vector<unsigned char>& buffer, int offset, int length);
213
225 void setDictionary(const std::vector<unsigned char>& buffer);
226
236 void setStrategy(int strategy);
237
247 void setLevel(int level);
248
253 bool needsInput() const;
254
259 void finish();
260
264 bool finished() const;
265
286 int deflate(unsigned char* buffer, int size, int offset, int length);
287
305 int deflate(std::vector<unsigned char>& buffer, int offset, int length);
306
319 int deflate(std::vector<unsigned char>& buffer);
320
326 long long getAdler() const;
327
333 long long getBytesRead() const;
334
340 long long getBytesWritten() const;
341
348 void reset();
349
355 void end();
356
357 };
358
359}}}
360
361#endif /* _DECAF_UTI_ZIP_DEFLATER_H_ */
void setInput(const std::vector< unsigned char > &buffer, int offset, int length)
Sets input data for compression.
static const int HUFFMAN_ONLY
Compression strategy for Huffman coding only.
Definition Deflater.h:90
static const int NO_COMPRESSION
Compression level for no compression.
Definition Deflater.h:78
int deflate(std::vector< unsigned char > &buffer, int offset, int length)
Fills specified buffer with compressed data.
void setDictionary(const unsigned char *buffer, int size, int offset, int length)
Sets preset dictionary for compression.
int deflate(std::vector< unsigned char > &buffer)
Fills specified buffer with compressed data.
static const int DEFAULT_STRATEGY
Default compression strategy.
Definition Deflater.h:95
void reset()
Resets deflater so that a new set of input data can be processed.
static const int BEST_SPEED
Compression level for fastest compression.
Definition Deflater.h:58
void setStrategy(int strategy)
Sets the compression strategy to the specified value.
static const int BEST_COMPRESSION
Compression level for best compression.
Definition Deflater.h:63
void setDictionary(const std::vector< unsigned char > &buffer, int offset, int length)
Sets preset dictionary for compression.
void end()
Closes the compressor and discards any unprocessed input.
Deflater(int level, bool nowrap=false)
Creates a new compressor using the specified compression level.
long long getBytesRead() const
static const int FILTERED
Compression strategy best used for data consisting mostly of small values with a somewhat random dist...
Definition Deflater.h:85
int deflate(unsigned char *buffer, int size, int offset, int length)
Fills specified buffer with compressed data.
void setInput(const std::vector< unsigned char > &buffer)
Sets input data for compression.
void setLevel(int level)
Sets the compression level to the specified value.
Deflater()
Creates a new compressor with the default compression level.
long long getAdler() const
void finish()
When called, indicates that compression should end with the current contents of the input buffer.
static const int DEFAULT_COMPRESSION
Default compression level.
Definition Deflater.h:68
void setDictionary(const std::vector< unsigned char > &buffer)
Sets preset dictionary for compression.
void setInput(const unsigned char *buffer, int size, int offset, int length)
Sets input data for compression.
long long getBytesWritten() const
static const int DEFLATED
Compression method for the deflate algorithm (the only one currently supported).
Definition Deflater.h:73
#define DECAF_API
Definition Config.h:29
Definition Adler32.h:26
Definition AbstractCollection.h:33
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.
Definition AprPool.h:25