nlib
WcharInputStream.h
Go to the documentation of this file.
1 
2 #pragma once
3 #ifndef INCLUDE_NN_NLIB_WCHARINPUTSTREAM_H_
4 #define INCLUDE_NN_NLIB_WCHARINPUTSTREAM_H_
5 
7 
8 NLIB_NAMESPACE_BEGIN
9 
10 class InputStream;
11 
12 namespace detail {
13 
14 class NLIB_VIS_PUBLIC UtfInputTransform : public InputTransform {
15  public:
16  typedef errno_t (*Func)(InputStream* istr, char (&utf8)[4], int* n);
17 
18  explicit UtfInputTransform(Func func) NLIB_NOEXCEPT;
19  virtual errno_t Transform(InputStream* is, void* p, size_t size,
20  size_t* nBytes) NLIB_NOEXCEPT NLIB_OVERRIDE;
21  virtual void* GetWorkBuffer(size_t* n) NLIB_NOEXCEPT NLIB_OVERRIDE;
22  virtual errno_t OnSetStream(InputStream* is) NLIB_NOEXCEPT NLIB_OVERRIDE;
23  virtual errno_t OnClose() NLIB_NOEXCEPT NLIB_OVERRIDE;
24 
25  private:
26  Func m_Func;
27  unsigned char m_NumUtf8;
28  char m_Utf8[3];
29  unsigned char m_Buf[128];
30 
31  NLIB_DISALLOW_COPY_AND_ASSIGN(UtfInputTransform);
32 };
33 
34 class NLIB_VIS_PUBLIC Utf32InputTransform NLIB_FINAL : public UtfInputTransform {
35  public:
36  Utf32InputTransform() NLIB_NOEXCEPT;
37 };
38 
39 class NLIB_VIS_PUBLIC Utf16InputTransform NLIB_FINAL : public UtfInputTransform {
40  public:
41  Utf16InputTransform() NLIB_NOEXCEPT;
42 };
43 
44 } // namespace detail
45 
46 #ifndef NLIB_DOXYGEN
47 typedef InputConverterStreamTempl<detail::Utf32InputTransform> Utf32InputStream;
48 typedef InputConverterStreamTempl<detail::Utf16InputTransform> Utf16InputStream;
49 #if NLIB_WCHAR_SIZE == 4
50 typedef Utf32InputStream WcharInputStream;
51 #else
52 typedef Utf16InputStream WcharInputStream;
53 #endif
54 #else
55 // Do not typedef for doxygen
56 class Utf32InputStream :
57  public InputConverterStreamTempl<detail::Utf32InputTransform> {
58  public:
59 };
60 
61 class Utf16InputStream :
62  public InputConverterStreamTempl<detail::Utf16InputTransform> {
63  public:
64 };
65 
66 #if NLIB_WCHAR_SIZE == 4
67 class WcharInputStream NLIB_FINAL : public Utf32InputStream {
68  public:
69 };
70 #else
71 class WcharInputStream NLIB_FINAL : public Utf16InputStream {
72  public:
73 };
74 #endif
75 #endif
76 
77 NLIB_NAMESPACE_END
78 
79 #endif // INCLUDE_NN_NLIB_WCHARINPUTSTREAM_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
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.
#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