3 #ifndef INCLUDE_NN_NLIB_EXI_XMLSTREAMREADER_H_
4 #define INCLUDE_NN_NLIB_EXI_XMLSTREAMREADER_H_
9 #if defined(_MSC_VER) && defined(nx_exi_EXPORTS)
10 #undef NLIB_VIS_PUBLIC
11 #define NLIB_VIS_PUBLIC NLIB_WINEXPORT
34 isVersionIgnored(false),
36 tempStringMaxLength(1023) {}
40 class ExiStringAllocator;
49 PROCESSING_INSTRUCTION = 3,
68 return Create(stream, settings, al);
72 return Create(stream, settings);
76 return Create(stream, settings, al);
81 if (m_IsLocalAl) ExiAllocator::Swap(m_Al);
84 ExiAllocatorSwapper swapper(m_Al);
88 ExiAllocatorSwapper swapper(m_Al);
89 return this->GetAttributeCountV();
92 ExiAllocatorSwapper swapper(m_Al);
93 return this->GetAttributeLocalNameV(index);
96 ExiAllocatorSwapper swapper(m_Al);
97 return this->GetAttributeNamespaceUriV(index);
100 ExiAllocatorSwapper swapper(m_Al);
101 return this->GetAttributePrefixV(index);
103 const ExiChar* GetAttributeType(
size_t index) NLIB_NOEXCEPT {
104 ExiAllocatorSwapper swapper(m_Al);
105 return this->GetAttributeTypeV(index);
108 ExiAllocatorSwapper swapper(m_Al);
109 return this->GetAttributeValueV(index);
112 const ExiChar* local_name) NLIB_NOEXCEPT {
113 ExiAllocatorSwapper swapper(m_Al);
114 return this->GetAttributeValueV(namespace_uri, local_name);
117 ExiAllocatorSwapper swapper(m_Al);
118 return this->GetNamespaceCountV();
121 ExiAllocatorSwapper swapper(m_Al);
122 return this->GetNamespacePrefixV(index);
125 ExiAllocatorSwapper swapper(m_Al);
126 return this->GetNamespaceUriV(index);
129 ExiAllocatorSwapper swapper(m_Al);
130 return this->GetElementTextV();
133 ExiAllocatorSwapper swapper(m_Al);
134 return this->GetLocalNameV();
137 ExiAllocatorSwapper swapper(m_Al);
138 return this->GetNamespaceUriV();
141 ExiAllocatorSwapper swapper(m_Al);
142 return this->GetPrefixV();
145 ExiAllocatorSwapper swapper(m_Al);
146 return this->GetTextV();
148 int GetLineNo() const NLIB_NOEXCEPT {
return this->GetLineNoV(); }
149 int GetColumnNo() const NLIB_NOEXCEPT {
return this->GetColumnNoV(); }
151 ExiAllocatorSwapper swapper(m_Al);
152 return this->NextV();
158 return m_State == START_ELEMENT || m_State == END_ELEMENT ||
159 m_State == PROCESSING_INSTRUCTION;
161 bool HasNext() const NLIB_NOEXCEPT {
return m_State != END_DOCUMENT && m_State != NONE; }
163 return m_State == CHARACTERS || m_State == CDATA || m_State == COMMENT ||
164 m_State == PROCESSING_INSTRUCTION;
166 bool IsCharacters() const NLIB_NOEXCEPT {
return m_State == CHARACTERS || m_State == CDATA; }
167 bool IsEndElement() const NLIB_NOEXCEPT {
return m_State == END_ELEMENT; }
169 bool IsError() const NLIB_NOEXCEPT {
return !m_ErrorStatus->
IsOk(); }
170 bool IsOk() const NLIB_NOEXCEPT {
return m_ErrorStatus->
IsOk(); }
172 return m_ErrorStatus->GetErrorValue();
181 m_State(START_DOCUMENT) {}
183 void SetExiErrorStatus(ExiErrorStatus* p) NLIB_NOEXCEPT { m_ErrorStatus = p; }
184 ExiErrorStatus* GetExiErrorStatus() const NLIB_NOEXCEPT {
return m_ErrorStatus; }
187 template <
class DECODER>
189 template <
class DECODER>
191 template <
class DECODER>
193 template <
class DECODER>
195 template <
class DECODER>
197 template <
class DECODER>
198 const ExiChar* GetAttributeValue_(DECODER* decoder,
const ExiChar* namespace_uri,
200 template <
class DECODER>
202 template <
class DECODER>
204 template <
class DECODER>
207 template <
class DECODER>
209 template <
class DECODER>
211 template <
class DECODER>
213 template <
class DECODER>
218 virtual void CloseV() NLIB_NOEXCEPT = 0;
219 virtual
size_t GetAttributeCountV() NLIB_NOEXCEPT = 0;
220 virtual const
ExiChar* GetAttributeLocalNameV(
size_t index) NLIB_NOEXCEPT = 0;
221 virtual const
ExiChar* GetAttributeNamespaceUriV(
size_t index) NLIB_NOEXCEPT = 0;
222 virtual const
ExiChar* GetAttributePrefixV(
size_t index) NLIB_NOEXCEPT = 0;
223 virtual const
ExiChar* GetAttributeTypeV(
size_t index) NLIB_NOEXCEPT = 0;
224 virtual const
ExiChar* GetAttributeValueV(
size_t index) NLIB_NOEXCEPT = 0;
225 virtual const
ExiChar* GetAttributeValueV(const
ExiChar* namespace_uri,
226 const
ExiChar* local_name) NLIB_NOEXCEPT = 0;
227 virtual
size_t GetNamespaceCountV() NLIB_NOEXCEPT = 0;
228 virtual const
ExiChar* GetNamespacePrefixV(
size_t index) NLIB_NOEXCEPT = 0;
229 virtual const
ExiChar* GetNamespaceUriV(
size_t index) NLIB_NOEXCEPT = 0;
230 virtual const
ExiChar* GetElementTextV() NLIB_NOEXCEPT = 0;
231 virtual const
ExiChar* GetLocalNameV() NLIB_NOEXCEPT = 0;
232 virtual const
ExiChar* GetNamespaceUriV() NLIB_NOEXCEPT = 0;
233 virtual const
ExiChar* GetPrefixV() NLIB_NOEXCEPT = 0;
234 virtual const
ExiChar* GetTextV() NLIB_NOEXCEPT = 0;
235 virtual
int GetLineNoV() const NLIB_NOEXCEPT {
return 0; }
236 virtual int GetColumnNoV() const NLIB_NOEXCEPT {
return 0; }
237 virtual XmlStreamConstants NextV() NLIB_NOEXCEPT = 0;
240 ExiErrorStatus* m_ErrorStatus;
252 #if defined(_MSC_VER) && defined(nx_exi_EXPORTS)
253 #undef NLIB_VIS_PUBLIC
254 #define NLIB_VIS_PUBLIC NLIB_WINIMPORT
257 #endif // INCLUDE_NN_NLIB_EXI_XMLSTREAMREADER_H_
XmlStreamConstants Next() noexcept
Reads the next XML stream event from the stream.
#define NLIB_NOEXCEPT
Defines noexcept geared to the environment, or the equivalent.
static XmlStreamReader * Create(InputStream *stream, const ExiAllocatorEx &al) noexcept
Creates an XmlStreamReader instance by specifying an objectwise allocator.
size_t GetAttributeCount() noexcept
Gets the number of attributes.
bool IsError() const noexcept
Returns true if an error has occurred.
Defines constructs such as string-type typedef statements and utility macros.
bool IsCharacters() const noexcept
Gets whether the data that was read is a text node.
static XmlStreamReader * Create(InputStream *stream, const XmlStreamReaderSettings &settings) noexcept
Creates an instance of XmlStreamReader.
bool IsStartElement() const noexcept
Gets whether the data that was read is an opening tag.
#define NLIB_DISALLOW_COPY_AND_ASSIGN(TypeName)
Prohibits use of the copy constructor and assignment operator for the class specified by TypeName...
const ExiChar * GetNamespacePrefix(size_t index) noexcept
Gets the prefix of a namespace declaration.
const ExiChar * GetLocalName() noexcept
Gets the local name.
#define NLIB_SAFE_BOOL(class_name, exp)
Defines a safe operator bool function in the class. Uses the C++11 explicit bool if it is available f...
XmlStreamConstants GetEventType() const noexcept
Returns the value for the most recent XML stream event.
const ExiChar * GetAttributePrefix(size_t index) noexcept
Gets the prefix of an attribute.
int GetColumnNo() const noexcept
Gets the column number indicated by the XmlStreamReader.
Set of options that preserve the binary XML to read or write.
const ExiChar * GetAttributeValue(const ExiChar *namespace_uri, const ExiChar *local_name) noexcept
Gets the value of the attribute based on a particular namespace URI and local name.
bool HasText() const noexcept
Returns whether text is ready to be obtained using GetText().
int GetLineNo() const noexcept
Gets the line number indicated by the XmlStreamReader.
const ExiChar * GetAttributeLocalName(size_t index) noexcept
Gets the local name of an attribute.
const ExiChar * GetNamespaceUri(size_t index) noexcept
Gets the namespace URI of a namespace declaration.
const ExiChar * GetPrefix() noexcept
Gets the namespace prefix of the XML.
bool IsEndElement() const noexcept
Gets whether the data that was read is a closing tag.
const ExiChar * GetAttributeValue(size_t index) noexcept
Gets the value of an attribute.
constexpr XmlStreamReaderSettings() noexcept
Configures the default settings.
static XmlStreamReader * Create(InputStream *stream) noexcept
Creates an XmlStreamReader instance using default settings for XmlStreamReaderSettings.
virtual ~XmlStreamReader() noexcept
Destructor.
const ExiChar * GetText() noexcept
Gets text data.
Sets and stores the error status of the XML parser.
const ExiChar * GetElementText() noexcept
Reads a series of text events and returns a single text element.
#define NLIB_CEXPR
Defines constexpr if it is available for use. If not, holds an empty string.
ExiErrorStatus * GetErrorStatus() const noexcept
Gets an error status object.
bool HasName() const noexcept
Returns whether data like a local name can be obtained.
Preserve preserve
Sets the fidelity options.
ExiErrorStatus::ErrorValue GetError() const noexcept
Gets the error value.
const ExiChar * GetNamespaceUri() noexcept
Gets the URI of the XML namespace.
Abstract class that reads from an XML stream.
Alignment
Specifies the alignment of the binary XML to read or write.
const ExiChar * GetAttributeNamespaceUri(size_t index) noexcept
Gets the namespace URI of an attribute.
Allocator that can be set for each instance of XmlStreamReader and XmlStreamWriter.
size_t GetNamespaceCount() noexcept
Gets the number of newly defined namespaces.
XmlProcessor
Option that specifies which XML processor to use.
size_t tempStringMaxLength
Specifies the length of the string that stores the temporary buffer used when reading XML comments an...
ErrorValue
Enumerates error statuses.
XmlProcessor processor
Specifies whether to read binary XML or text-based XML.
Alignment alignment
Specifies the alignment of the binary XML to read.
Defines the errors returned by the XML parser.
bool isVersionIgnored
By setting this option to true during read operations, you can ignore the version check when reading ...
XmlStreamConstants
Values of XML stream events that occurred while reading an XML stream.
bool HasNext() const noexcept
Returns whether the next XML stream event can be obtained.
bool IsOk() const noexcept
Returns true if an error has not occurred.
void Close() noexcept
Closes an XmlStreamReader. The original stream is not actually closed; it merely stops being referenc...
bool fragment
Reads binary XML that supports multiple root nodes (aka XML fragments).
Reads from and writes to a bit-packed EXI stream (default).
wchar_t ExiChar
A string-type typedef used internally by the XML parser.
Structure used as the initialization options for XmlStreamReader.