3 #ifndef INCLUDE_NN_NLIB_EXI_XMLSTREAMWRITER_H_ 4 #define INCLUDE_NN_NLIB_EXI_XMLSTREAMWRITER_H_ 9 #if defined(_MSC_VER) && defined(nx_exi_EXPORTS) 10 #undef NLIB_VIS_PUBLIC 11 #define NLIB_VIS_PUBLIC NLIB_WINEXPORT 48 return Create(stream, settings, al);
52 return Create(stream, settings);
56 return Create(stream, settings, al);
59 if (is_local_al_) ExiAllocator::Swap(al_);
62 ExiAllocatorSwapper swapper(al_);
66 ExiAllocatorSwapper swapper(al_);
70 ExiAllocatorSwapper swapper(al_);
76 void WriteAttribute(
const ExiChar* prefix,
const ExiChar* namespace_uri,
79 if (NEXI_IS_ERROR)
return;
80 ExiAllocatorSwapper swapper(al_);
84 if (NEXI_IS_ERROR)
return;
85 ExiAllocatorSwapper swapper(al_);
91 if (NEXI_IS_ERROR)
return;
92 ExiAllocatorSwapper swapper(al_);
94 namespace_uri ? namespace_uri : NLIB_EXI_ESTR);
103 void WriteEmptyElement(
const ExiChar* prefix,
const ExiChar* namespace_uri,
106 if (NEXI_IS_ERROR)
return;
107 ExiAllocatorSwapper swapper(al_);
108 this->WriteStartDocument_();
113 if (NEXI_IS_ERROR)
return;
114 ExiAllocatorSwapper swapper(al_);
115 this->WriteEndDocument_();
118 if (NEXI_IS_ERROR)
return;
119 ExiAllocatorSwapper swapper(al_);
120 this->WriteEndElement_();
126 void WriteStartElement(
const ExiChar* prefix,
const ExiChar* namespace_uri,
129 return error_status_->GetError();
135 virtual void Close_() NLIB_NOEXCEPT = 0;
136 virtual void Flush_() NLIB_NOEXCEPT = 0;
137 virtual const ExiChar* GetPrefix_(
const ExiChar* uri) NLIB_NOEXCEPT = 0;
138 virtual void WriteAttribute_(
const ExiChar* prefix,
const ExiChar* namespace_uri,
139 const ExiChar* local_name,
const ExiChar* value) NLIB_NOEXCEPT = 0;
140 virtual void WriteCData_(
const ExiChar* data) NLIB_NOEXCEPT = 0;
141 virtual void WriteCharacters_(
const ExiChar* text) NLIB_NOEXCEPT = 0;
142 virtual void WriteComment_(
const ExiChar* data) NLIB_NOEXCEPT = 0;
143 virtual void WriteProcessingInstruction_(
const ExiChar* target,
144 const ExiChar* data) NLIB_NOEXCEPT = 0;
145 virtual void WriteStartElement_(
const ExiChar* prefix,
const ExiChar* namespace_uri,
146 const ExiChar* local_name) NLIB_NOEXCEPT = 0;
147 virtual void WriteEmptyElement_(
const ExiChar* prefix,
const ExiChar* namespace_uri,
148 const ExiChar* local_name) NLIB_NOEXCEPT {
149 this->WriteStartElement_(prefix, namespace_uri, local_name);
150 this->WriteEndElement();
152 virtual void WriteNamespace_(
const ExiChar* prefix,
153 const ExiChar* namespace_uri) NLIB_NOEXCEPT = 0;
154 virtual void WriteStartDocument_() NLIB_NOEXCEPT = 0;
155 virtual void WriteEndDocument_() NLIB_NOEXCEPT = 0;
156 virtual void WriteEndElement_() NLIB_NOEXCEPT = 0;
159 static bool IsNullOrEmptyString(
const ExiChar* p) NLIB_NOEXCEPT {
return (!p) || (*p ==
'\0'); }
160 void SetExiErrorStatus(
ExiErrorStatus* p) NLIB_NOEXCEPT { error_status_ = p; }
161 ExiErrorStatus* GetExiErrorStatus()
const NLIB_NOEXCEPT {
return error_status_; }
178 #if defined(_MSC_VER) && defined(nx_exi_EXPORTS) 179 #undef NLIB_VIS_PUBLIC 180 #define NLIB_VIS_PUBLIC NLIB_WINIMPORT 183 #endif // INCLUDE_NN_NLIB_EXI_XMLSTREAMWRITER_H_ bool encodeCookie
Sets whether to write identification strings at the beginning of the data.
void WriteDefaultNamespace(const ExiChar *namespace_uri) noexcept
Declares the default namespace.
void WriteStartElement(const ExiChar *local_name) noexcept
Writes an opening tag of an element without a namespace.
Defines constructs such as string-type typedef statements and utility macros.
#define NLIB_DISALLOW_COPY_AND_ASSIGN(TypeName)
Prohibits use of the copy constructor and assignment operator for the class specified by TypeName...
void WriteNamespace(const ExiChar *prefix, const ExiChar *namespace_uri) noexcept
Declares the XML namespace.
#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...
XmlProcessor processor
Specifies whether to write binary XML or text-based XML.
ExiErrorStatus::ErrorValue GetError() const noexcept
Gets the error value.
Set of options that preserve the binary XML to read or write.
int version
Specifies the version number to record in the binary XML.
void WriteEndElement() noexcept
Writes a closing tag.
void WriteEmptyElement(const ExiChar *local_name) noexcept
Writes opening tags and closing tags for elements without a namespace.
Sets and stores the error status of the XML parser.
ExiErrorStatus * GetErrorStatus() const noexcept
Gets an error status object.
constexpr XmlStreamWriterSettings() noexcept
Configures the default settings.
bool encodeOptions
Sets whether to write information used to automatically recognize the settings.
void WriteEndDocument() noexcept
Closes all open elements and closes the XML writer.
Alignment
Specifies the alignment of the binary XML to read or write.
Allocator that can be set for each instance of XmlStreamReader and XmlStreamWriter.
#define NLIB_EXI_ESTR
Defines an empty string. "" or L"".
XmlProcessor
Option that specifies which XML processor to use.
ErrorValue
Enumerates error statuses.
#define NLIB_NOEXCEPT
Defines noexcept geared to the environment, or the equivalent.
Alignment alignment
Sets the alignment of the binary XML.
#define NLIB_CEXPR
Defines constexpr if it is available for use. If not, holds an empty string.
bool fragment
Supports writing binary XML that has multiple root nodes (aka XML fragments). The default is false...
static XmlStreamWriter * Create(OutputStream *stream) noexcept
Creates an XmlStreamWriter instance using default settings for XmlStreamWriterSettings.
Preserve preserve
Sets the fidelity options.
Defines the errors returned by the XML parser.
static XmlStreamWriter * Create(OutputStream *stream, const XmlStreamWriterSettings &settings) noexcept
Creates an instance of XmlStreamWriter.
Structure used as the initialization options for XmlStreamWriter.
void WriteAttribute(const ExiChar *local_name, const ExiChar *value) noexcept
Writes an attribute and value without a namespace.
void WriteCData(const ExiChar *data) noexcept
Writes the text specified as an argument.
static XmlStreamWriter * Create(OutputStream *stream, const ExiAllocatorEx &al) noexcept
Creates an XmlStreamWriter instance by specifying an objectwise allocator.
void Flush() noexcept
Flushes the XML writer cache.
Abstract class that writes to an XML stream.
void WriteCharacters(const ExiChar *text) noexcept
Writes the text specified as an argument.
void Close() noexcept
Closes an XmlStreamWriter. The original stream is not actually closed; it merely is detached...
const ExiChar * GetPrefix(const ExiChar *uri) noexcept
Gets the prefix corresponding to the namespace URI.
Reads from and writes to a bit-packed EXI stream (default).
The base class for output streams. This class cannot be instantiated.
void WriteStartDocument() noexcept
Declares the start of an XML document and writes data including the XML declaration.
wchar_t ExiChar
A string-type typedef used internally by the XML parser.