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