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 (m_IsLocalAl) ExiAllocator::Swap(m_Al);
62 ExiAllocatorSwapper swapper(m_Al);
66 ExiAllocatorSwapper swapper(m_Al);
70 ExiAllocatorSwapper swapper(m_Al);
76 void WriteAttribute(
const ExiChar* prefix,
const ExiChar* namespace_uri,
79 if (NEXI_IS_ERROR)
return;
80 ExiAllocatorSwapper swapper(m_Al);
84 if (NEXI_IS_ERROR)
return;
85 ExiAllocatorSwapper swapper(m_Al);
91 if (NEXI_IS_ERROR)
return;
92 ExiAllocatorSwapper swapper(m_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(m_Al);
108 this->WriteStartDocument_();
113 if (NEXI_IS_ERROR)
return;
114 ExiAllocatorSwapper swapper(m_Al);
115 this->WriteEndDocument_();
118 if (NEXI_IS_ERROR)
return;
119 ExiAllocatorSwapper swapper(m_Al);
120 this->WriteEndElement_();
126 void WriteStartElement(
const ExiChar* prefix,
const ExiChar* namespace_uri,
128 bool IsError() const NLIB_NOEXCEPT {
return !m_ErrorStatus->IsOk(); }
129 bool IsOk() const NLIB_NOEXCEPT {
return m_ErrorStatus->IsOk(); }
131 return m_ErrorStatus->GetErrorValue();
137 virtual
void Close_() NLIB_NOEXCEPT = 0;
138 virtual
void Flush_() NLIB_NOEXCEPT = 0;
139 virtual const
ExiChar* GetPrefix_(const
ExiChar* uri) NLIB_NOEXCEPT = 0;
140 virtual
void WriteAttribute_(const
ExiChar* prefix, const
ExiChar* namespace_uri,
141 const
ExiChar* local_name, const
ExiChar* value) NLIB_NOEXCEPT = 0;
142 virtual
void WriteCData_(const
ExiChar* data) NLIB_NOEXCEPT = 0;
143 virtual
void WriteCharacters_(const
ExiChar* text) NLIB_NOEXCEPT = 0;
144 virtual
void WriteComment_(const
ExiChar* data) NLIB_NOEXCEPT = 0;
145 virtual
void WriteProcessingInstruction_(const
ExiChar* target,
146 const
ExiChar* data) NLIB_NOEXCEPT = 0;
147 virtual
void WriteStartElement_(const
ExiChar* prefix, const
ExiChar* namespace_uri,
148 const
ExiChar* local_name) NLIB_NOEXCEPT = 0;
149 virtual
void WriteEmptyElement_(const
ExiChar* prefix, const
ExiChar* namespace_uri,
150 const
ExiChar* local_name) NLIB_NOEXCEPT {
151 this->WriteStartElement_(prefix, namespace_uri, local_name);
152 this->WriteEndElement();
154 virtual void WriteNamespace_(
const ExiChar* prefix,
155 const ExiChar* namespace_uri) NLIB_NOEXCEPT = 0;
156 virtual void WriteStartDocument_() NLIB_NOEXCEPT = 0;
157 virtual
void WriteEndDocument_() NLIB_NOEXCEPT = 0;
158 virtual
void WriteEndElement_() NLIB_NOEXCEPT = 0;
161 static
bool IsNullOrEmptyString(const
ExiChar* p) NLIB_NOEXCEPT {
return (!p) || (*p ==
'\0'); }
162 void SetExiErrorStatus(ExiErrorStatus* p) NLIB_NOEXCEPT { m_ErrorStatus = p; }
163 ExiErrorStatus* GetExiErrorStatus() const NLIB_NOEXCEPT {
return m_ErrorStatus; }
164 explicit XmlStreamWriter(
const ExiAllocatorEx& al) NLIB_NOEXCEPT : m_ErrorStatus(NULL),
169 ExiErrorStatus* m_ErrorStatus;
180 #if defined(_MSC_VER) && defined(nx_exi_EXPORTS)
181 #undef NLIB_VIS_PUBLIC
182 #define NLIB_VIS_PUBLIC NLIB_WINIMPORT
185 #endif // INCLUDE_NN_NLIB_EXI_XMLSTREAMWRITER_H_
#define NLIB_NOEXCEPT
環境に合わせてnoexcept 又は同等の定義がされます。
bool encodeCookie
データの先頭に識別用の文字列を書きこむかを設定します。
void WriteDefaultNamespace(const ExiChar *namespace_uri) noexcept
デフォルト名前空間を宣言します。
bool IsError() const noexcept
エラーが発生している場合はtrueを返します。
void WriteStartElement(const ExiChar *local_name) noexcept
名前空間なしの要素で開始タグを書き込みます。
文字列型のtypedefやユーティリティマクロ等が定義されています。
#define NLIB_DISALLOW_COPY_AND_ASSIGN(TypeName)
TypeName で指定されたクラスのコピーコンストラクタと代入演算子を禁止します。
void WriteNamespace(const ExiChar *prefix, const ExiChar *namespace_uri) noexcept
XML名前空間を宣言します。
#define NLIB_SAFE_BOOL(class_name, exp)
クラス内に安全なoperator bool()を定義します。 可能であればC++11のexplicit boolを利用します。 ...
XmlProcessor processor
バイナリXMLを書きだすかテキストXMLを書きだすか指定します。
bool IsOk() const noexcept
エラーが発生していない場合はtrueを返します。
読み書きするバイナリXMLのデータ保持オプションです。
int version
バイナリXMLに記録されるバージョン番号を指定します。
void WriteEndElement() noexcept
終了タグを書き込みます。
ExiErrorStatus::ErrorValue GetError() const noexcept
エラー値を取得します。
void WriteEmptyElement(const ExiChar *local_name) noexcept
名前空間なしの要素で開始タグと終了タグをを書き込みます。
constexpr XmlStreamWriterSettings() noexcept
デフォルト設定がセットされます。
bool encodeOptions
設定の自動認識のための情報を書き込むかを設定します。
#define NLIB_CEXPR
利用可能であればconstexprが定義されます。そうでない場合は空文字列です。
void WriteEndDocument() noexcept
開いている任意の要素を全て閉じ、XMLライタをクローズします。
Alignment
読み書きするバイナリXMLのアライメントを指定します。
XmlStreamReader, XmlStreamWriter の各インスタンス毎に設定できるアロケータです。
ExiErrorStatus * GetErrorStatus() const noexcept
エラー状態オブジェクトを取得します。
#define NLIB_EXI_ESTR
空文字列が定義されています。""又はL""です。
XmlProcessor
利用するXmlプロセッサの指定オプションです。
Alignment alignment
バイナリXMLのアライメントを設定します。
bool fragment
複数のルートノードを持つXML(XMLフラグメント)の書き込みをサポートします。デフォルトはfalseです。 ...
static XmlStreamWriter * Create(OutputStream *stream) noexcept
XmlStreamWriterSettingsをデフォルト設定でXmlStreamReaderのインスタンスを作成します。 ...
Preserve preserve
各種フィデリティオプションを設定します。
static XmlStreamWriter * Create(OutputStream *stream, const XmlStreamWriterSettings &settings) noexcept
XmlStreamWriterのインスタンスを作成します。
XmlStreamWriter の初期化オプションとなる構造体です。
void WriteAttribute(const ExiChar *local_name, const ExiChar *value) noexcept
名前空間なしの属性と値を書き込みます。
void WriteCData(const ExiChar *data) noexcept
引数で指定したテキストを書き込みます。
static XmlStreamWriter * Create(OutputStream *stream, const ExiAllocatorEx &al) noexcept
オブジェクト単位のアロケータを指定してXmlStreamWriterのインスタンスを作成します。 ...
void Flush() noexcept
XMLライタをフラッシュします。
XMLのストリームへの書き出しを行う抽象クラスです。
void WriteCharacters(const ExiChar *text) noexcept
引数で指定したテキストを書き込みます。
void Close() noexcept
XmlStreamWriterをクローズします。基となるストリームは切り離されるだけでクローズされません。 ...
const ExiChar * GetPrefix(const ExiChar *uri) noexcept
名前空間URIに対応するプレフィックスを取得します。
ビット単位にデータが詰められたEXIストリームを読み書きします(デフォルト)。
出力ストリームの基底クラスです。このクラスを実体化することはできません。
void WriteStartDocument() noexcept
XMLドキュメントの開始を宣言し、XML宣言等を書き込みます。
wchar_t ExiChar
XMLパーサーの内部文字列型のtypedefです。