nlib
ZlibOutputStream.h
[詳解]
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
利用可能であればoverrideが定義されます。そうでない場合は空文字列です。
Definition: Config.h:244
errno_t Init() noexcept
デフォルト設定で初期化します。
#define NLIB_DISALLOW_COPY_AND_ASSIGN(TypeName)
TypeName で指定されたクラスのコピーコンストラクタと代入演算子を禁止します。
Definition: Config.h:179
constexpr ZlibOutputStream() noexcept
デフォルトコンストラクタです。
void * buf_out
z_stream::next_outに設定されるバッファです。
基本的なAPIがCリンケージで宣言されています。
void * buf_in
z_stream::next_inに設定されるバッファです。
#define NLIB_VIS_PUBLIC
関数やクラス等のシンボルをライブラリの外部に公開します。
Definition: Platform_unix.h:89
size_t buffer_size
ZlibOutputStreamSettings::buf_in, ZlibOutputStreamSettings::buf_outのバッファサイズです。 ...
ReallocFunc realloc_func
ZlibOutputStream内部で利用するrealloc又はreallocと同等の関数です。
内部でデータ変換を行うOutputStreamのように振る舞うクラスの基底です。
constexpr ZlibOutputStreamSettings() noexcept
デフォルトコンストラクタです。デフォルト値を設定します。
constexpr ZlibOutputStreamSettings(void *buf_in_, void *buf_out_, size_t buffer_size_, int level_) noexcept
それぞれのデータメンバを設定します。
#define NLIB_NOEXCEPT
環境に合わせてnoexcept 又は同等の定義がされます。
Definition: Config.h:105
#define NLIB_CEXPR
利用可能であればconstexprが定義されます。そうでない場合は空文字列です。
Definition: Config.h:107
void * nlib_realloc(void *ptr, size_t size)
C標準関数のrealloc()を呼び出すweak関数です。nlibはこの関数を経由してrealloc()を呼び出します。 ...
ZlibOutputStreamの各種設定が格納されている構造体です。コンストラクト時にはデフォルトの設定が格納され...
zlibを用いてデータを圧縮してストリームに書き込みます。
int level
zlibのdeflateInit2関数に渡す圧縮設定です。
#define NLIB_FINAL
利用可能であればfinalが定義されます。そうでない場合は空文字列です。
Definition: Config.h:245
constexpr ZlibOutputStreamSettings(void *buf_in_, void *buf_out_, size_t buffer_size_, int level_, ReallocFunc realloc_func_) noexcept
それぞれのデータメンバを設定します。
int errno_t
intのtypedefで、戻り値としてPOSIXのエラー値を返すことを示します。
Definition: NMalloc.h:37