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