NorMIT-nav  2023.01.05-dev+develop.0da12
An IGT application
cx::XmlOptionFile Class Reference

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...
 
static void printDocument (QDomDocument document)
 
static void printElement (QDomElement element)
 

Detailed Description

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 78 of file cxXmlOptionItem.h.

Constructor & Destructor Documentation

◆ XmlOptionFile() [1/2]

cx::XmlOptionFile::XmlOptionFile ( QString  filename)
explicit

create from filename, create trivial document of type name and root node if no file exists.

Definition at line 234 of file cxXmlOptionItem.cpp.

◆ XmlOptionFile() [2/2]

cx::XmlOptionFile::XmlOptionFile ( )

Definition at line 228 of file cxXmlOptionItem.cpp.

◆ ~XmlOptionFile()

cx::XmlOptionFile::~XmlOptionFile ( )

Definition at line 248 of file cxXmlOptionItem.cpp.

Member Function Documentation

◆ ascend()

XmlOptionFile cx::XmlOptionFile::ascend ( ) const

step one level up in the xml tree

Definition at line 312 of file cxXmlOptionItem.cpp.

◆ createNull()

XmlOptionFile cx::XmlOptionFile::createNull ( )
static

create an empty document

----------------------------------------------------—


Definition at line 220 of file cxXmlOptionItem.cpp.

◆ deleteNode()

void cx::XmlOptionFile::deleteNode ( )

Delete the current node.

Definition at line 389 of file cxXmlOptionItem.cpp.

◆ descend() [1/2]

XmlOptionFile cx::XmlOptionFile::descend ( QString  element) const

step one level down in the xml tree

Definition at line 271 of file cxXmlOptionItem.cpp.

◆ descend() [2/2]

XmlOptionFile cx::XmlOptionFile::descend ( QString  element,
QString  attributeName,
QString  attributeValue 
) const

Definition at line 278 of file cxXmlOptionItem.cpp.

◆ getDocument()

QDomDocument cx::XmlOptionFile::getDocument ( )

returns the document

Definition at line 360 of file cxXmlOptionItem.cpp.

◆ getElement() [1/3]

QDomElement cx::XmlOptionFile::getElement ( )

return the current element

Definition at line 365 of file cxXmlOptionItem.cpp.

◆ getElement() [2/3]

QDomElement cx::XmlOptionFile::getElement ( QString  level1)

return a element below the current element. Guaranteed to exist.

Definition at line 370 of file cxXmlOptionItem.cpp.

◆ getElement() [3/3]

QDomElement cx::XmlOptionFile::getElement ( QString  level1,
QString  level2 
)

return a element two levels below the current element. Guaranteed to exist.

Definition at line 376 of file cxXmlOptionItem.cpp.

◆ getFileName()

QString cx::XmlOptionFile::getFileName ( )

Definition at line 252 of file cxXmlOptionItem.cpp.

◆ isNull()

bool cx::XmlOptionFile::isNull ( ) const

checks if this is null

Definition at line 257 of file cxXmlOptionItem.cpp.

◆ printDocument() [1/2]

void cx::XmlOptionFile::printDocument ( )

print the entire document

Definition at line 336 of file cxXmlOptionItem.cpp.

◆ printDocument() [2/2]

void cx::XmlOptionFile::printDocument ( QDomDocument  document)
static

Definition at line 346 of file cxXmlOptionItem.cpp.

◆ printElement() [1/2]

void cx::XmlOptionFile::printElement ( )

print just the current element

Definition at line 341 of file cxXmlOptionItem.cpp.

◆ printElement() [2/2]

void cx::XmlOptionFile::printElement ( QDomElement  element)
static

Definition at line 352 of file cxXmlOptionItem.cpp.

◆ removeChildren()

void cx::XmlOptionFile::removeChildren ( )

remove all child nodes of the current element.

Definition at line 383 of file cxXmlOptionItem.cpp.

◆ root()

XmlOptionFile cx::XmlOptionFile::root ( ) const

set the current element to root

Definition at line 264 of file cxXmlOptionItem.cpp.

◆ safeGetElement()

QDomElement cx::XmlOptionFile::safeGetElement ( QDomElement  parent,
QString  childName 
)

return an element child of parent. Create if not existing.

Definition at line 323 of file cxXmlOptionItem.cpp.

◆ save()

void cx::XmlOptionFile::save ( )

save entire document.

Definition at line 396 of file cxXmlOptionItem.cpp.

◆ tryDescend()

XmlOptionFile cx::XmlOptionFile::tryDescend ( QString  element,
QString  attributeName,
QString  attributeValue 
) const

Definition at line 293 of file cxXmlOptionItem.cpp.


The documentation for this class was generated from the following files: