nlib
ZlibInputStream.h
Go to the documentation of this file.
1 
2 /*--------------------------------------------------------------------------------*
3  Project: CrossRoad
4  Copyright (C)Nintendo All rights reserved.
5 
6  These coded instructions, statements, and computer programs contain proprietary
7  information of Nintendo and/or its licensed developers and are protected by
8  national and international copyright laws. They may not be disclosed to third
9  parties or copied or duplicated in any form, in whole or in part, without the
10  prior written consent of Nintendo.
11 
12  The content herein is highly confidential and should be handled accordingly.
13  *--------------------------------------------------------------------------------*/
14 
15 #pragma once
16 #ifndef INCLUDE_NN_NLIB_ZLIBINPUTSTREAM_H_
17 #define INCLUDE_NN_NLIB_ZLIBINPUTSTREAM_H_
18 
19 #include "nn/nlib/Platform.h"
20 #ifdef NLIB_HAS_ZLIB
21 
22 #include "nn/nlib/InputStream.h"
24 
25 NLIB_NAMESPACE_BEGIN
26 
28  typedef void* (*ReallocFunc)(void* p, size_t n) NLIB_NOEXCEPT_FUNCPTR;
29  void* buf_in;
30  void* buf_out;
31  size_t buffer_size;
32  ReallocFunc realloc_func;
33 
34  public:
36  buf_out(NULL),
37  buffer_size(64 * 1024),
38  realloc_func(::nlib_realloc) {}
39  NLIB_CEXPR ZlibInputStreamSettings(void* buf_in_, void* buf_out_,
40  size_t buffer_size_) NLIB_NOEXCEPT
41  : buf_in(buf_in_),
42  buf_out(buf_out_),
43  buffer_size(buffer_size_),
44  realloc_func(::nlib_realloc) {}
45  NLIB_CEXPR ZlibInputStreamSettings(void* buf_in_, void* buf_out_, size_t buffer_size_,
46  ReallocFunc realloc_func_) NLIB_NOEXCEPT
47  : buf_in(buf_in_),
48  buf_out(buf_out_),
49  buffer_size(buffer_size_),
50  realloc_func(realloc_func_) {}
51 };
52 
54  : public InputConverterStream {
55  public:
56  ZlibInputStream() NLIB_NOEXCEPT : prv_(NULL) {}
60  return this->Init(settings);
61  }
62  errno_t Init(const ZlibInputStreamSettings& settings) NLIB_NOEXCEPT;
63 
64  private:
65  struct ZlibInputStreamPrivate;
66  ZlibInputStreamPrivate* prv_;
68 };
69 
70 NLIB_NAMESPACE_END
71 
72 #endif
73 #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:228
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:163
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.
Basic APIs are declared with a C linkage.
#define NLIB_VIS_PUBLIC
Symbols for functions and classes are made available outside of the library.
Definition: Platform_unix.h:89
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:99
#define NLIB_CEXPR
Defines constexpr if it is available for use. If not, holds an empty string.
Definition: Config.h:93
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:229
int errno_t
Indicates with an int-type typedef that a POSIX error value is returned as the return value...
Definition: NMalloc.h:37