40 #include "NptStrings.h" 41 #include "NptStreams.h" 46 const int NPT_ERROR_XML_INVALID_NESTING = NPT_ERROR_BASE_XML - 0;
47 const int NPT_ERROR_XML_TAG_MISMATCH = NPT_ERROR_BASE_XML - 1;
48 const int NPT_ERROR_XML_NO_ROOT = NPT_ERROR_BASE_XML - 2;
49 const int NPT_ERROR_XML_MULTIPLE_ROOTS = NPT_ERROR_BASE_XML - 3;
51 #define NPT_XML_ANY_NAMESPACE "*" 52 #define NPT_XML_NO_NAMESPACE NULL 68 m_Prefix(prefix), m_Name(name), m_Value(value) {}
69 const NPT_String& GetPrefix()
const {
return m_Prefix; }
70 const NPT_String& GetName()
const {
return m_Name; }
71 const NPT_String& GetValue()
const {
return m_Value; }
72 void SetValue(
const char* value) { m_Value = value; }
81 m_Prefix(attribute.m_Prefix),
82 m_Name(attribute.m_Name),
83 m_Value(attribute.m_Value) {}
101 NPT_Result SetNamespaceUri(
const char* prefix,
const char* uri);
102 const NPT_String* GetNamespaceUri(
const char* prefix);
103 const NPT_String* GetNamespacePrefix(
const char* uri);
110 Entry(
const char* prefix,
const char* uri) :
111 m_Prefix(prefix), m_Uri(uri) {}
143 NPT_XmlNode(Type type) : m_Type(type), m_Parent(NULL) {}
145 Type GetType()
const {
return m_Type; }
146 NPT_XmlNode* GetParent()
const {
return m_Parent; }
156 virtual void SetParent(
NPT_XmlNode* parent) { m_Parent = parent; }
163 friend class NPT_XmlNodeFinder;
181 GetChildren()
const {
return m_Children; }
183 const char* namespc = NPT_XML_NO_NAMESPACE,
184 NPT_Ordinal n=0)
const;
186 NPT_Result SetAttribute(
const char* prefix,
189 NPT_Result SetAttribute(
const char* name,
191 NPT_Result AddText(
const char* text);
193 GetAttributes() {
return m_Attributes; }
195 GetAttributes()
const {
return m_Attributes; }
196 const NPT_String* GetAttribute(
const char* name,
197 const char* namespc = NPT_XML_NO_NAMESPACE)
const;
198 const NPT_String& GetPrefix()
const {
return m_Prefix; }
199 const NPT_String& GetTag()
const {
return m_Tag; }
200 const NPT_String* GetText(NPT_Ordinal n=0)
const;
205 NPT_Result MakeStandalone();
209 NPT_Result SetNamespaceUri(
const char* prefix,
const char* uri);
210 const NPT_String* GetNamespaceUri(
const char* prefix)
const;
211 const NPT_String* GetNamespacePrefix(
const char* uri)
const;
221 void RelinkNamespaceMaps();
223 NPT_Result AddAttribute(
const char* name,
const char* value);
253 IGNORABLE_WHITESPACE,
263 const NPT_String& GetString()
const {
return m_Text; }
264 TokenType GetTokenType()
const {
return m_TokenType; }
272 TokenType m_TokenType;
285 virtual NPT_Result Parse(
const char* xml,
287 bool incremental=
false);
288 virtual NPT_Result Parse(
const char* xml,
291 bool incremental=
false);
294 bool incremental=
false);
298 bool incremental=
false);
302 NPT_Result OnStartElement(
const char* name);
303 NPT_Result OnElementAttribute(
const char* name,
const char* value);
304 NPT_Result OnEndElement(
const char* name);
305 NPT_Result OnCharacterData(
const char* data, NPT_Size size);
306 void RemoveIgnorableWhitespace();
312 bool m_KeepWhitespace;
329 NPT_Cardinal indentation = 0,
330 bool shrink_empty_elements =
true,
331 bool add_xml_decl =
false);
333 virtual NPT_Result StartDocument();
334 virtual NPT_Result EndDocument();
335 virtual NPT_Result StartElement(
const char* prefix,
const char* name);
336 virtual NPT_Result EndElement(
const char* prefix,
const char* name);
337 virtual NPT_Result Attribute(
const char* prefix,
const char* name,
const char* value);
338 virtual NPT_Result Text(
const char* text);
339 virtual NPT_Result CdataSection(
const char* data);
340 virtual NPT_Result Comment(
const char* comment);
344 void EscapeChar(
unsigned char c,
char* text);
345 NPT_Result ProcessPending();
346 NPT_Result OutputEscapedString(
const char* text,
bool attribute);
347 void OutputIndentation(
bool start);
351 bool m_ElementPending;
352 NPT_Cardinal m_Depth;
353 NPT_Cardinal m_Indentation;
355 bool m_ElementHasText;
356 bool m_ShrinkEmptyElements;
367 explicit NPT_XmlWriter(NPT_Cardinal indentation = 0) : m_Indentation(indentation) {}
372 bool add_xml_decl =
false);
376 NPT_Cardinal m_Indentation;
388 bool add_xml_decl =
false);
391 #endif // _NPT_XML_H_
Definition: NptXml.cpp:116
Definition: NptXml.cpp:2062
Definition: NptXml.cpp:2016
Definition: NptXml.cpp:186
Definition: NptXml.cpp:1096
Definition: NptStreams.h:92
Definition: NptXml.cpp:69
Definition: NptXml.cpp:134
Definition: NptStrings.h:57