nlib
ZlibInputStream.h
Go to the documentation of this file.
1 
2 #pragma once
3 #ifndef INCLUDE_NN_NLIB_ZLIBINPUTSTREAM_H_
4 #define INCLUDE_NN_NLIB_ZLIBINPUTSTREAM_H_
5 
6 #include "nn/nlib/Platform.h"
7 #ifdef NLIB_HAS_ZLIB
8 
9 #include "nn/nlib/InputStream.h"
11 
12 NLIB_NAMESPACE_BEGIN
13 
15  typedef void* (*ReallocFunc)(void* p, size_t n);
16  void* buf_in;
17  void* buf_out;
18  size_t buffer_size;
19  ReallocFunc realloc_func;
20 
21  public:
23  buf_out(NULL),
24  buffer_size(64 * 1024),
25  realloc_func(::nlib_realloc) {}
26  NLIB_CEXPR ZlibInputStreamSettings(void* buf_in_, void* buf_out_,
27  size_t buffer_size_) NLIB_NOEXCEPT
28  : buf_in(buf_in_),
29  buf_out(buf_out_),
30  buffer_size(buffer_size_),
31  realloc_func(::nlib_realloc) {}
32  NLIB_CEXPR ZlibInputStreamSettings(void* buf_in_, void* buf_out_, size_t buffer_size_,
33  ReallocFunc realloc_func_) NLIB_NOEXCEPT
34  : buf_in(buf_in_),
35  buf_out(buf_out_),
36  buffer_size(buffer_size_),
37  realloc_func(realloc_func_) {}
38 };
39 
41  : public InputConverterStream {
42  public:
43  ZlibInputStream() NLIB_NOEXCEPT : prv_(NULL) {}
47  return this->Init(settings);
48  }
49  errno_t Init(const ZlibInputStreamSettings& settings) NLIB_NOEXCEPT;
50 
51  private:
52  struct ZlibInputStreamPrivate;
53  ZlibInputStreamPrivate* prv_;
55 };
56 
57 NLIB_NAMESPACE_END
58 
59 #endif
60 #endif // INCLUDE_NN_NLIB_ZLIBINPUTSTREAM_H_
#define NLIB_OVERRIDE
Defines override if it is available for use. If not, holds an empty string.
Definition: Config.h:210
The base class for classes that act internally like InputStream to convert data.
#define NLIB_DISALLOW_COPY_AND_ASSIGN(TypeName)
Prohibits use of the copy constructor and assignment operator for the class specified by TypeName...
Definition: Config.h:145
Defines the base class for input streams.
The structure that stores the various ZlibInputStream settings. At construction time, the default settings are stored.
ZlibInputStream() noexcept
Instantiates the object with default parameters (default constructor).
ReallocFunc realloc_func
The realloc function or its equivalent that ZlibInputStream uses internally.
size_t buffer_size
The size of ZlibInputStreamSettings::buf_in and ZlibInputStreamSettings::buf_out. ...
constexpr ZlibInputStreamSettings(void *buf_in_, void *buf_out_, size_t buffer_size_) noexcept
Sets the individual data members.
C-based declaration of the basic API.
#define NLIB_VIS_PUBLIC
Symbols for functions and classes are made available outside of the library.
Definition: Platform_unix.h:61
constexpr ZlibInputStreamSettings() noexcept
Instantiates the object with default parameters (default constructor). Sets the default values...
void * buf_in
The buffer set for z_stream::next_in.
errno_t Init() noexcept
Initializes using the default settings.
constexpr ZlibInputStreamSettings(void *buf_in_, void *buf_out_, size_t buffer_size_, ReallocFunc realloc_func_) noexcept
Sets the individual data members.
The stream class for reading compressed data using zlib.
#define NLIB_NOEXCEPT
Defines noexcept geared to the environment, or the equivalent.
Definition: Config.h:86
#define NLIB_CEXPR
Defines constexpr if it is available for use. If not, holds an empty string.
Definition: Config.h:80
NLIB_CHECK_RESULT void * nlib_realloc(void *ptr, size_t size)
A weak function that calls the C standard function realloc. nlib calls realloc via this function...
void * buf_out
The buffer set for z_stream::next_out.
#define NLIB_FINAL
Defines final if it is available for use. If not, holds an empty string.
Definition: Config.h:211
int errno_t
Indicates with an int-type typedef that a POSIX error value is returned as the return value...
Definition: NMalloc.h:24