libcrn
3.9.5
A document image processing library
|
XML document. More...
#include <CRNXml.h>
Public Member Functions | |
Document (const StringUTF8 &encoding="UTF-8", const StringUTF8 &version="1.0", bool char_conversion_throws=true) | |
Constructor. More... | |
Document (const Path &fname, bool char_conversion_throws=true) | |
Constructor from file. More... | |
Document (const char *content, bool char_conversion_throws=true) | |
Constructor from buffer. More... | |
Document (const Document &)=delete | |
Document (Document &&) | |
Document & | operator= (const Document &)=delete |
Document & | operator= (Document &&) |
virtual | ~Document () |
Destructor. More... | |
operator bool () const noexcept | |
Checks if the document is open. More... | |
bool | operator! () const noexcept |
Checks if the document is not open. More... | |
void | Save (const Path &fname) |
Saves to file. More... | |
void | Save () |
Saves to file. More... | |
const Path & | GetFilename () const noexcept |
Gets the filename if the document exists on the disk. More... | |
const StringUTF8 & | GetEncoding () const noexcept |
Gets the character encoding of the file. More... | |
const StringUTF8 & | GetVersion () const noexcept |
Gets the XML version of the file. More... | |
Element | GetRoot () |
Gets the first element. More... | |
Node | GetFirstNode () |
Gets the first child node. More... | |
Node | GetLastNode () |
Gets the last child node. More... | |
Node | BeginNode () |
Gets the first child node. More... | |
Node | EndNode () |
Gets a null node. More... | |
Element | GetFirstElement (const StringUTF8 &name="") |
Gets the first child element. More... | |
Element | GetLastElement (const StringUTF8 &name="") |
Gets the last child element. More... | |
Element | BeginElement () |
Gets the first child element. More... | |
Element | EndElement () |
Gets a null node. More... | |
Element | PushBackElement (const StringUTF8 &name) |
Adds an element at the end of the children list. More... | |
Element | InsertElement (Node &n, const StringUTF8 &name) |
Inserts an element after a node. More... | |
Comment | PushBackComment (const StringUTF8 &text) |
Adds a comment at the end of the children list. More... | |
Comment | InsertComment (Node &n, const StringUTF8 &text) |
Inserts a comment after a node. More... | |
Node | PushBackClone (Node &n, bool recursive=false) |
Adds a copy of a node at the end of the children list. More... | |
StringUTF8 | AsString () |
Exports the document to a string. More... | |
crn::xml::Document::Document | ( | const StringUTF8 & | encoding = "UTF-8" , |
const StringUTF8 & | version = "1.0" , |
||
bool | char_conversion_throws = true |
||
) |
Constructor.
Constructor from file.
crn::xml::Document::Document | ( | const char * | content, |
bool | char_conversion_throws = true |
||
) |
Constructor from buffer.
|
delete |
crn::xml::Document::Document | ( | Document && | ) |
|
virtual |
Destructor.
StringUTF8 Document::AsString | ( | ) |
Exports the document to a string.
Exports the document to a string
Definition at line 1218 of file CRNXml.cpp.
|
inline |
|
inline |
|
inline |
|
inline |
|
inlinenoexcept |
|
inlinenoexcept |
Element Document::GetFirstElement | ( | const StringUTF8 & | name = "" | ) |
Gets the first child element.
Gets the first element
CharsetConverter::ExceptionInvalidCharacter | invalid character |
CharsetConverter::ExceptionIncompleteCode | incomplete multibyte character |
[in] | name | the name of the element or empty string for any element |
Definition at line 1064 of file CRNXml.cpp.
Node Document::GetFirstNode | ( | ) |
Gets the first child node.
Gets the first node
Definition at line 1045 of file CRNXml.cpp.
Element Document::GetLastElement | ( | const StringUTF8 & | name = "" | ) |
Gets the last child element.
Gets the last element
CharsetConverter::ExceptionInvalidCharacter | invalid character |
CharsetConverter::ExceptionIncompleteCode | incomplete multibyte character |
[in] | name | the name of the element or empty string for any element |
Definition at line 1075 of file CRNXml.cpp.
Node Document::GetLastNode | ( | ) |
Gets the last child node.
Gets the last node
Definition at line 1053 of file CRNXml.cpp.
Element Document::GetRoot | ( | ) |
Gets the first element.
Gets the first element
ExceptionNotFound | no element in the xml |
Definition at line 1034 of file CRNXml.cpp.
|
inlinenoexcept |
Comment Document::InsertComment | ( | Node & | n, |
const StringUTF8 & | text | ||
) |
Inserts a comment after a node.
Inserts a comment after a node
ExceptionNotFound | node not found |
CharsetConverter::ExceptionInvalidCharacter | invalid character |
CharsetConverter::ExceptionIncompleteCode | incomplete multibyte character |
[in] | n | the node after which the new comment will be inserted |
[in] | text | the content of the comment |
Definition at line 1141 of file CRNXml.cpp.
Element Document::InsertElement | ( | Node & | n, |
const StringUTF8 & | name | ||
) |
Inserts an element after a node.
Inserts an element after a node
ExceptionInvalidArgument | null node or empty element name |
ExceptionNotFound | node not found |
CharsetConverter::ExceptionInvalidCharacter | invalid character |
CharsetConverter::ExceptionIncompleteCode | incomplete multibyte character |
[in] | n | the node after which the new element will be inserted |
[in] | name | the name of the element |
Definition at line 1105 of file CRNXml.cpp.
|
inlinenoexcept |
|
inlinenoexcept |
Adds a copy of a node at the end of the children list.
Adds a copy of a node at the end of the children list
ExceptionInvalidArgument | null or invalid node |
[in] | n | the node to copy |
[in] | recursive | shall the subelements be copied too? (only if n is an Element) |
Definition at line 1160 of file CRNXml.cpp.
Comment Document::PushBackComment | ( | const StringUTF8 & | text | ) |
Adds a comment at the end of the children list.
Adds a comment at the end of the document
CharsetConverter::ExceptionInvalidCharacter | invalid character |
CharsetConverter::ExceptionIncompleteCode | incomplete multibyte character |
[in] | text | the content of the comment |
Definition at line 1126 of file CRNXml.cpp.
Element Document::PushBackElement | ( | const StringUTF8 & | name | ) |
Adds an element at the end of the children list.
Adds an element at the end of the document
ExceptionInvalidArgument | empty element name |
CharsetConverter::ExceptionInvalidCharacter | invalid character |
CharsetConverter::ExceptionIncompleteCode | incomplete multibyte character |
[in] | name | the name of the element |
Definition at line 1087 of file CRNXml.cpp.
void Document::Save | ( | const Path & | fname | ) |
Saves to file.
Saves the XML to a file
ExceptionNotFound | file not found |
ExceptionIO | cannot open file |
ExceptionRuntime | error creating the file |
[in] | fname | the xml file name |
Definition at line 1009 of file CRNXml.cpp.
void Document::Save | ( | ) |
Saves to file.
Saves the XML to a file
ExceptionUninitialized | emtpy filename |
ExceptionNotFound | file not found |
ExceptionIO | cannot open file |
ExceptionRuntime | error creating the file |
Definition at line 1022 of file CRNXml.cpp.