nlib
ZlibOutputStream.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_ZLIBOUTPUTSTREAM_H_
17 #define INCLUDE_NN_NLIB_ZLIBOUTPUTSTREAM_H_
18 
19 #include "nn/nlib/Platform.h"
20 #ifdef NLIB_HAS_ZLIB
21 
23 
24 NLIB_NAMESPACE_BEGIN
25 
26 class OutputStream;
27 
29  typedef void* (*ReallocFunc)(void* p, size_t n) NLIB_NOEXCEPT_FUNCPTR;
30  void* buf_in;
31  void* buf_out;
32  size_t buffer_size;
33  int level;
34  ReallocFunc realloc_func;
35 
36  public:
38  buf_out(nullptr),
39  buffer_size(64 * 1024),
40  level(-1),
41  realloc_func(::nlib_realloc) {}
42  NLIB_CEXPR ZlibOutputStreamSettings(void* buf_in_, void* buf_out_, size_t buffer_size_,
43  int level_) NLIB_NOEXCEPT : buf_in(buf_in_),
44  buf_out(buf_out_),
45  buffer_size(buffer_size_),
46  level(level_),
47  realloc_func(::nlib_realloc) {}
48  NLIB_CEXPR ZlibOutputStreamSettings(void* buf_in_, void* buf_out_, size_t buffer_size_,
49  int level_, ReallocFunc realloc_func_) NLIB_NOEXCEPT
50  : buf_in(buf_in_),
51  buf_out(buf_out_),
52  buffer_size(buffer_size_),
53  level(level_),
54  realloc_func(realloc_func_) {}
55 };
56 
58  public:
63  return this->Init(settings);
64  }
65  errno_t Init(const ZlibOutputStreamSettings& settings) NLIB_NOEXCEPT;
66 
67  private:
68  struct ZlibOutputStreamPrivate;
69  ZlibOutputStreamPrivate* prv_;
71 };
72 
73 NLIB_NAMESPACE_END
74 
75 #endif
76 #endif // INCLUDE_NN_NLIB_ZLIBOUTPUTSTREAM_H_
#define NLIB_OVERRIDE
Defines override if it is available for use. If not, holds an empty string.
Definition: Config.h:244
errno_t Init() noexcept
Initializes using the default settings.
#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:179
constexpr ZlibOutputStream() noexcept
Instantiates the object with default parameters (default constructor).
void * buf_out
The buffer set for z_stream::next_out.
Basic APIs are declared with a C linkage.
void * buf_in
The buffer set for z_stream::next_in.
#define NLIB_VIS_PUBLIC
Symbols for functions and classes are made available outside of the library.
Definition: Platform_unix.h:89
size_t buffer_size
The size of ZlibOutputStreamSettings::buf_in and ZlibOutputStreamSettings::buf_out.
ReallocFunc realloc_func
The realloc function or its equivalent that ZlibOutputStream uses internally.
The base class for classes that act internally like OutputStream to convert data. ...
constexpr ZlibOutputStreamSettings() noexcept
Instantiates the object with default parameters (default constructor). Sets the default values...
constexpr ZlibOutputStreamSettings(void *buf_in_, void *buf_out_, size_t buffer_size_, int level_) noexcept
Sets the individual data members.
#define NLIB_NOEXCEPT
Defines noexcept geared to the environment, or the equivalent.
Definition: Config.h:105
#define NLIB_CEXPR
Defines constexpr if it is available for use. If not, holds an empty string.
Definition: Config.h:107
void * nlib_realloc(void *ptr, size_t size)
A weak function that calls the C standard function realloc. nlib calls realloc via this function...
The structure that stores the various ZlibOutputStream settings. At construction time, the default settings are stored.
The class that uses zlib to decompress data and write the data to a stream.
int level
The compression setting to pass to the deflateInit2 function of zlib.
#define NLIB_FINAL
Defines final if it is available for use. If not, holds an empty string.
Definition: Config.h:245
constexpr ZlibOutputStreamSettings(void *buf_in_, void *buf_out_, size_t buffer_size_, int level_, ReallocFunc realloc_func_) noexcept
Sets the individual data members.
int errno_t
Indicates with an int-type typedef that a POSIX error value is returned as the return value...
Definition: NMalloc.h:37