forked from egorFiNE/node-compress-buffer
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
strdup for *string; length() method instead of strlen(); throwexcepti…
…on(); z_stream wrapper;
- Loading branch information
Showing
2 changed files
with
87 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#ifndef _CZSTREAM_H_ | ||
#define _CZSTREAM_H_ | ||
|
||
#include <zlib.h> | ||
|
||
namespace zstream | ||
{ | ||
|
||
enum {compression = Z_DEFAULT_COMPRESSION}; | ||
enum {algorithm = Z_DEFLATED}; | ||
enum {strategy = Z_DEFAULT_STRATEGY}; | ||
enum {wbits = 16 + MAX_WBITS}; | ||
enum {memlevel = 8L}; | ||
|
||
template<typename Stream> | ||
class CZStream | ||
{ | ||
public: | ||
CZStream() | ||
{ | ||
stream_.zalloc = Z_NULL; | ||
stream_.zfree = Z_NULL; | ||
stream_.opaque = Z_NULL; | ||
} | ||
|
||
~CZStream() | ||
{ | ||
} | ||
|
||
operator Stream*() const { return const_cast<Stream*>(&stream_); } | ||
|
||
private: | ||
Stream stream_; | ||
}; | ||
|
||
} //namespace zstream | ||
|
||
#endif //_CZSTREAM_H_ | ||
|