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