nlib
Types.h
Go to the documentation of this file.
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_
Reads from and writes to a byte-aligned EXI stream.
Definition: Types.h:45
Set of options that preserve the binary XML to read or write.
Definition: Types.h:47
bool pis
Sets whether processing instructions are preserved.
Definition: Types.h:49
constexpr Preserve(bool comments_, bool pis_, bool prefixes_) noexcept
Sets values to data members and initializes.
Definition: Types.h:55
Use binary XML.
Definition: Types.h:62
#define NLIB_VIS_PUBLIC
Symbols for functions and classes are made available outside of the library.
Definition: Platform_unix.h:89
constexpr Preserve() noexcept
Instantiates the object with default parameters (default constructor). Sets all data members to false...
Definition: Types.h:54
Use text-based XML.
Definition: Types.h:62
Unicode-related functionality is implemented.
Alignment
Specifies the alignment of the binary XML to read or write.
Definition: Types.h:45
bool comments
Sets whether XML comments are preserved.
Definition: Types.h:48
XmlProcessor
Option that specifies which XML processor to use.
Definition: Types.h:62
#define NLIB_NOEXCEPT
Defines noexcept geared to the environment, or the equivalent.
Definition: Config.h:105
#define NLIB_CEXPR
Defines constexpr if it is available for use. If not, holds an empty string.
Definition: Config.h:107
A file that contains the configuration information for each development environment.
Wraps functions like strlen and strcpy so they can be safely used.
bool prefixes
Sets whether XML prefix names are preserved.
Definition: Types.h:50
Reads from and writes to a bit-packed EXI stream (default).
Definition: Types.h:45
char nlib_utf8_t
Defines char with a typedef. Indicates that it is a UTF-8 string.
Definition: Platform.h:308
nlib_utf8_t ExiChar
A string-type typedef used internally by the XML parser.
Definition: Types.h:40