nlib
Lz4InputStream.h
Go to the documentation of this file.
1 
2 #pragma once
3 #ifndef INCLUDE_NN_NLIB_OSS_LZ4OUTPUTSTREAM_H_
4 #define INCLUDE_NN_NLIB_OSS_LZ4OUTPUTSTREAM_H_
5 
6 #include "nn/nlib/Config.h"
7 #include "nn/nlib/InputStream.h"
9 
10 #if defined(_MSC_VER) && defined(nx_oss_lz4_EXPORTS)
11 #undef NLIB_VIS_PUBLIC
12 #define NLIB_VIS_PUBLIC NLIB_WINEXPORT
13 #endif
14 
15 NLIB_NAMESPACE_BEGIN
16 namespace oss {
17 
19  public:
21 };
22 
23 namespace detail {
24 
25 class NLIB_VIS_PUBLIC Lz4InputTransform NLIB_FINAL : public InputTransform {
26  public:
27  Lz4InputTransform() NLIB_NOEXCEPT;
28  virtual ~Lz4InputTransform() NLIB_NOEXCEPT NLIB_OVERRIDE;
29  errno_t Init(const Lz4InputStreamSettings& settings) NLIB_NOEXCEPT;
30  virtual errno_t Transform(InputStream* is, void* p, size_t nBytes,
31  size_t* written) NLIB_NOEXCEPT NLIB_OVERRIDE;
32  virtual void* GetWorkBuffer(size_t* n) NLIB_NOEXCEPT NLIB_OVERRIDE;
33  virtual errno_t OnSetStream(InputStream* is) NLIB_NOEXCEPT NLIB_OVERRIDE;
34  virtual errno_t OnClose() NLIB_NOEXCEPT NLIB_OVERRIDE;
35 
36  private:
37  LZ4F_decompressionContext_t m_Ctx;
38  unsigned char* m_BufIn;
39  size_t m_BufInCur;
40  size_t m_BufInDataSize;
41  unsigned char m_BaseBuf[256];
42 
43  NLIB_DISALLOW_COPY_AND_ASSIGN(Lz4InputTransform);
44 };
45 
46 } // namespace detail
47 
49  : public InputConverterStreamTempl<detail::Lz4InputTransform> {
50  public:
52  virtual ~Lz4InputStream() NLIB_NOEXCEPT NLIB_OVERRIDE;
53  errno_t Init() NLIB_NOEXCEPT {
55  return this->Init(settings);
56  }
57  errno_t Init(const Lz4InputStreamSettings& settings) NLIB_NOEXCEPT {
58  return m_Transform.Init(settings);
59  }
60 
61  private:
63 };
64 
65 } // namespace oss
66 NLIB_NAMESPACE_END
67 
68 #if defined(_MSC_VER) && defined(nx_oss_lz4_EXPORTS)
69 #undef NLIB_VIS_PUBLIC
70 #define NLIB_VIS_PUBLIC NLIB_WINIMPORT
71 #endif
72 
73 #endif // INCLUDE_NN_NLIB_OSS_LZ4OUTPUTSTREAM_H_
#define NLIB_NOEXCEPT
Defines noexcept geared to the environment, or the equivalent.
Definition: Platform.h:2151
#define NLIB_FINAL
Defines final if it is available for use. If not, holds an empty string.
#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:126
Defines the base class for input streams.
The class for holding the InputTransform derived class.
#define NLIB_OVERRIDE
Defines override if it is available for use. If not, holds an empty string.
The stream class to read data according to the LZ4 frame format.
#define NLIB_CEXPR
Defines constexpr if it is available for use. If not, holds an empty string.
The base class for input streams. This class cannot be instantiated.
Definition: InputStream.h:15
errno_t Init() noexcept
Initializes the stream with the default settings.
A file that contains the configuration information for each development environment.
errno_t Init(const Lz4InputStreamSettings &settings) noexcept
Initializes a stream.
The class to obtain and configure the Lz4InputStream settings. As of now this class is empty...
#define NLIB_VIS_PUBLIC
Symbols for functions and classes are made available outside of the library.
Definition: Platform_unix.h:51
int errno_t
Indicates with an int-type typedef that a POSIX error value is returned as the return value...
Definition: NMalloc.h:24