nlib
Types.h
[詳解]
1 
2 #pragma once
3 #ifndef INCLUDE_NN_NLIB_EXI_TYPES_H_
4 #define INCLUDE_NN_NLIB_EXI_TYPES_H_
5 
6 #include "nn/nlib/Config.h"
7 #include "nn/nlib/Cstring.h"
9 
10 #if defined(_MSC_VER) || defined(CAFE) || (defined(__GNUC__) && !defined(__clang__))
11 #define NLIB_EXI_WCHAR_INTERFACE
12 #endif
13 
14 #if defined(_MSC_VER) && defined(nx_exi_EXPORTS)
15 #undef NLIB_VIS_PUBLIC
16 #define NLIB_VIS_PUBLIC NLIB_WINEXPORT
17 #endif
18 
19 NLIB_NAMESPACE_BEGIN
20 namespace exi {
21 
22 #ifdef NLIB_EXI_WCHAR_INTERFACE
23 typedef wchar_t ExiChar;
24 #define NLIB_EXI_ESTR L""
25 #define NLIB_EXI_STR(x) L##x
26 #else
27 typedef char ExiChar;
28 #define NLIB_EXI_ESTR ""
29 #define NLIB_EXI_STR(x) x
30 #endif
31 
33 
35  bool comments;
36  bool pis;
37  bool prefixes;
38  char _;
39 
40  public:
41  NLIB_CEXPR Preserve() NLIB_NOEXCEPT : comments(false), pis(false), prefixes(false), _(0) {}
42  NLIB_CEXPR Preserve(bool comments_, bool pis_, bool prefixes_) NLIB_NOEXCEPT
43  : comments(comments_),
44  pis(pis_),
45  prefixes(prefixes_),
46  _(0) {}
47 };
48 
50 
51 namespace core {
52 
53 enum EventType {
54  NEXI_START_DOCUMENT = 0,
55  NEXI_ATTRIBUTE,
56  NEXI_ATTRIBUTE_UNDECLARED,
57  NEXI_START_ELEMENT,
58  NEXI_START_ELEMENT_UNDECLARED,
59  NEXI_START_ELEMENT_UNDECLARED_DOCCONTENT,
60  NEXI_CHARACTERS,
61  NEXI_CHARACTERS_UNDECLARED,
62  NEXI_END_ELEMENT,
63  NEXI_END_ELEMENT_UNDECLARED,
64  NEXI_COMMENT,
65  NEXI_PROCESSING_INSTRUCTION,
66  NEXI_NAMESPACE,
67  NEXI_END_DOCUMENT,
68  NEXI_INVALID_EVENT
69 };
70 
71 struct NBitUint {
72  int nb; // # of bits needed for encoding
73  int value; // the value encoded
74 };
75 
76 struct EventCode {
77  NBitUint ec1;
78  NBitUint ec2;
79  NBitUint ec3;
80 };
81 } // namespace core
82 
83 #ifdef _MSC_VER
84 
85 #ifdef NLIB_EXI_WCHAR_INTERFACE
86 #define NLIB_EXI_LITERAL(x) NLIB_EXI_STR(x)
87 #define NLIB_EXI_UTF8(x) ::nlib_ns::unicode::ToUtf8Obj(x).c_str()
88 #define NLIB_EXI_STRING(x) ::nlib_ns::unicode::ToWideObj(x).c_str()
89 #else
90 #define NLIB_EXI_LITERAL(x) ::nlib_ns::unicode::ToUtf8Obj(L##x).c_str()
91 #define NLIB_EXI_UTF8(x) x
92 #define NLIB_EXI_STRING(x) ::nlib_ns::unicode::ToUtf8Obj(x).c_str()
93 #endif
94 
95 #else
96 
97 #define NLIB_EXI_LITERAL(x) NLIB_EXI_STR(x)
98 #ifdef NLIB_EXI_WCHAR_INTERFACE
99 #define NLIB_EXI_UTF8(x) ::nlib_ns::unicode::ToUtf8Obj(x).c_str()
100 #define NLIB_EXI_STRING(x) ::nlib_ns::unicode::ToWideObj(x).c_str()
101 #else
102 #define NLIB_EXI_UTF8(x) x
103 #define NLIB_EXI_STRING(x) ::nlib_ns::unicode::ToUtf8Obj(x).c_str()
104 #endif
105 
106 #endif
107 
108 } // namespace exi
109 NLIB_NAMESPACE_END
110 
111 #if defined(_MSC_VER) && defined(nx_exi_EXPORTS)
112 #undef NLIB_VIS_PUBLIC
113 #define NLIB_VIS_PUBLIC NLIB_WINIMPORT
114 #endif
115 
116 #endif // INCLUDE_NN_NLIB_EXI_TYPES_H_
バイトアラインされたEXIストリームを読み書きします。
Definition: Types.h:32
読み書きするバイナリXMLのデータ保持オプションです。
Definition: Types.h:34
bool pis
Processing Instructionを保持するかどうか設定します。
Definition: Types.h:36
constexpr Preserve(bool comments_, bool pis_, bool prefixes_) noexcept
データメンバに値を設定して初期化します。
Definition: Types.h:42
バイナリXMLの利用
Definition: Types.h:49
#define NLIB_VIS_PUBLIC
関数やクラス等のシンボルをライブラリの外部に公開します。
Definition: Platform_unix.h:61
constexpr Preserve() noexcept
デフォルトコンストラクタです。全てのデータメンバにfalseを設定します。
Definition: Types.h:41
テキストXMLの利用
Definition: Types.h:49
ユニコード関連の関数が実装されています。
Alignment
読み書きするバイナリXMLのアライメントを指定します。
Definition: Types.h:32
bool comments
XMLコメントを保持するかどうか設定します。
Definition: Types.h:35
XmlProcessor
利用するXmlプロセッサの指定オプションです。
Definition: Types.h:49
#define NLIB_NOEXCEPT
環境に合わせてnoexcept 又は同等の定義がされます。
Definition: Config.h:86
#define NLIB_CEXPR
利用可能であればconstexprが定義されます。そうでない場合は空文字列です。
Definition: Config.h:80
開発環境別の設定が書かれるファイルです。
strlen, strcpy等を安全に使えるようにラップしています。
bool prefixes
XMLのプレフィックス名を保持するかどうか設定します。
Definition: Types.h:37
ビット単位にデータが詰められたEXIストリームを読み書きします(デフォルト)。
Definition: Types.h:32
wchar_t ExiChar
XMLパーサーの内部文字列型のtypedefです。
Definition: Types.h:23