![]() |
CustusX
15.4.0-beta
An IGT application
|
Helper class for xml files used to store ssc/cx data. More...
#include <cxXmlOptionItem.h>
Public Member Functions | |
XmlOptionFile (QString filename) | |
create from filename, create trivial document of type name and root node if no file exists. More... | |
XmlOptionFile () | |
~XmlOptionFile () | |
QString | getFileName () |
bool | isNull () const |
checks if this is null More... | |
XmlOptionFile | root () const |
set the current element to root More... | |
XmlOptionFile | descend (QString element) const |
step one level down in the xml tree More... | |
XmlOptionFile | descend (QString element, QString attributeName, QString attributeValue) const |
XmlOptionFile | ascend () const |
step one level up in the xml tree More... | |
XmlOptionFile | tryDescend (QString element, QString attributeName, QString attributeValue) const |
QDomDocument | getDocument () |
returns the document More... | |
QDomElement | getElement () |
return the current element More... | |
QDomElement | getElement (QString level1) |
return a element below the current element. Guaranteed to exist. More... | |
QDomElement | getElement (QString level1, QString level2) |
return a element two levels below the current element. Guaranteed to exist. More... | |
void | save () |
save entire document. More... | |
void | removeChildren () |
remove all child nodes of the current element. More... | |
void | deleteNode () |
Delete the current node. More... | |
QDomElement | safeGetElement (QDomElement parent, QString childName) |
void | printDocument () |
print the entire document More... | |
void | printElement () |
print just the current element More... | |
Static Public Member Functions | |
static XmlOptionFile | createNull () |
create an empty document More... | |
Helper class for xml files used to store ssc/cx data.
Both the xml document and filename are stored, and save/load are provided.
Several instances of the same file points to the same internal object, in the same way as QSettings. This means that they share the QDomDocument, and is NOT threadsafe.
The object has a current element, which is used to ease work at a specified level in the hierarchy. Use descend/ascend to change the current element.
The getElement() methods are used to retrieve QDomElements relative to the current element.
Definition at line 99 of file cxXmlOptionItem.h.
|
explicit |
create from filename, create trivial document of type name and root node if no file exists.
Definition at line 254 of file cxXmlOptionItem.cpp.
cx::XmlOptionFile::XmlOptionFile | ( | ) |
Definition at line 248 of file cxXmlOptionItem.cpp.
cx::XmlOptionFile::~XmlOptionFile | ( | ) |
Definition at line 268 of file cxXmlOptionItem.cpp.
XmlOptionFile cx::XmlOptionFile::ascend | ( | ) | const |
step one level up in the xml tree
Definition at line 332 of file cxXmlOptionItem.cpp.
|
static |
create an empty document
Definition at line 240 of file cxXmlOptionItem.cpp.
void cx::XmlOptionFile::deleteNode | ( | ) |
Delete the current node.
Definition at line 399 of file cxXmlOptionItem.cpp.
XmlOptionFile cx::XmlOptionFile::descend | ( | QString | element | ) | const |
step one level down in the xml tree
Definition at line 291 of file cxXmlOptionItem.cpp.
XmlOptionFile cx::XmlOptionFile::descend | ( | QString | element, |
QString | attributeName, | ||
QString | attributeValue | ||
) | const |
Definition at line 298 of file cxXmlOptionItem.cpp.
QDomDocument cx::XmlOptionFile::getDocument | ( | ) |
returns the document
Definition at line 370 of file cxXmlOptionItem.cpp.
QDomElement cx::XmlOptionFile::getElement | ( | ) |
return the current element
Definition at line 375 of file cxXmlOptionItem.cpp.
QDomElement cx::XmlOptionFile::getElement | ( | QString | level1 | ) |
return a element below the current element. Guaranteed to exist.
Definition at line 380 of file cxXmlOptionItem.cpp.
QDomElement cx::XmlOptionFile::getElement | ( | QString | level1, |
QString | level2 | ||
) |
return a element two levels below the current element. Guaranteed to exist.
Definition at line 386 of file cxXmlOptionItem.cpp.
QString cx::XmlOptionFile::getFileName | ( | ) |
Definition at line 272 of file cxXmlOptionItem.cpp.
bool cx::XmlOptionFile::isNull | ( | ) | const |
checks if this is null
Definition at line 277 of file cxXmlOptionItem.cpp.
void cx::XmlOptionFile::printDocument | ( | ) |
print the entire document
Definition at line 356 of file cxXmlOptionItem.cpp.
void cx::XmlOptionFile::printElement | ( | ) |
print just the current element
Definition at line 362 of file cxXmlOptionItem.cpp.
void cx::XmlOptionFile::removeChildren | ( | ) |
remove all child nodes of the current element.
Definition at line 393 of file cxXmlOptionItem.cpp.
XmlOptionFile cx::XmlOptionFile::root | ( | ) | const |
set the current element to root
Definition at line 284 of file cxXmlOptionItem.cpp.
QDomElement cx::XmlOptionFile::safeGetElement | ( | QDomElement | parent, |
QString | childName | ||
) |
return an element child of parent. Create if not existing.
Definition at line 343 of file cxXmlOptionItem.cpp.
void cx::XmlOptionFile::save | ( | ) |
save entire document.
Definition at line 406 of file cxXmlOptionItem.cpp.
XmlOptionFile cx::XmlOptionFile::tryDescend | ( | QString | element, |
QString | attributeName, | ||
QString | attributeValue | ||
) | const |
Definition at line 313 of file cxXmlOptionItem.cpp.