KDevelop API Documentation

DomUtil Class Reference

Utility class for conveniently accessing data in a DOM tree. More...

#include <domutil.h>

List of all members.

Public Types

typedef QPair< QString, QStringPair
typedef QValueList< PairPairList

Static Public Member Functions

void makeEmpty (QDomElement &)
 Remove all child elements from a given element.

QString readEntry (const QDomDocument &doc, const QString &path, const QString &defaultEntry=QString::null)
 Reads a string entry.

int readIntEntry (const QDomDocument &doc, const QString &path, int defaultEntry=0)
 Reads a number entry.

bool readBoolEntry (const QDomDocument &doc, const QString &path, bool defaultEntry=false)
 Reads a boolean entry.

QStringList readListEntry (const QDomDocument &doc, const QString &path, const QString &tag)
 Reads a list entry.

PairList readPairListEntry (const QDomDocument &doc, const QString &path, const QString &tag, const QString &firstAttr, const QString &secondAttr)
 Reads a list of string pairs.

QDomElement elementByPath (const QDomDocument &doc, const QString &path)
 Retrieves an element by path, return null if any item along the path does not exist.

QDomElement createElementByPath (QDomDocument &doc, const QString &path)
 Retrieves an element by path, creating the necessary nodes.

QDomElement namedChildElement (QDomElement &el, const QString &name)
 Retrieves a child element, creating it if it does not exist.

void writeEntry (QDomDocument &doc, const QString &path, const QString &value)
 Writes a string entry.

void writeIntEntry (QDomDocument &doc, const QString &path, int value)
 Writes a number entry.

void writeBoolEntry (QDomDocument &doc, const QString &path, bool value)
 Writes a boolean entry.

void writeListEntry (QDomDocument &doc, const QString &path, const QString &tag, const QStringList &value)
 Writes a string list element.

void writePairListEntry (QDomDocument &doc, const QString &path, const QString &tag, const QString &firstAttr, const QString &secondAttr, const PairList &value)
 Writes a list of string pairs.

DomPath resolvPathStringExt (const QString pathstring)
 Resolves an extended path Extended path format: pathpart: tag[|attr1=value[;attr2=value;..][|matchNumber]] where matchNumber is zero-based path: pathpart[/pathpart/..].

QDomElement elementByPathExt (QDomDocument &doc, const QString &pathstring)
 Retrieve an element specified with extended path examples:.

bool openDOMFile (QDomDocument &doc, QString filename)
 Open file - filename - and set setContents of doc.

bool saveDOMFile (QDomDocument &doc, QString filename)
 Store contents of doc in file - filename.

bool removeTextNodes (QDomDocument doc, QString pathExt)
 Remove all child text nodes of parent described in pathExt.

bool appendText (QDomDocument doc, QString pathExt, QString text)
 Add child text node to parent described in pathExt.

bool replaceText (QDomDocument doc, QString pathExt, QString text)
 Replace all chilt text nodes of parent described in pathExt with one new.


Static Private Member Functions

QString readEntryAux (const QDomDocument &doc, const QString &path)


Detailed Description

Utility class for conveniently accessing data in a DOM tree.

Definition at line 40 of file domutil.h.


Member Typedef Documentation

typedef QPair<QString, QString> DomUtil::Pair
 

Definition at line 43 of file domutil.h.

Referenced by SubclassesDlg::accept(), EnvironmentVariablesWidget::accept(), readPairListEntry(), AutoProjectPart::setWantautotools(), AutoDetailsView::slotDetailsContextMenu(), TrollProjectWidget::slotExecuteTarget(), and FileGroupsConfigWidget::storeConfig().

typedef QValueList<Pair> DomUtil::PairList
 

Definition at line 44 of file domutil.h.

Referenced by TrollProjectPart::makeEnvironment(), FileGroupsConfigWidget::readConfig(), EnvironmentVariablesWidget::readEnvironment(), readPairListEntry(), FileGroupsWidget::refresh(), ScriptProjectPart::runEnvironmentVars(), PascalProjectPart::runEnvironmentVars(), HaskellProjectPart::runEnvironmentVars(), GenericProjectPart::runEnvironmentVars(), CustomProjectPart::runEnvironmentVars(), AutoProjectPart::runEnvironmentVars(), AntProjectPart::runEnvironmentVars(), AdaProjectPart::runEnvironmentVars(), GDBDebugger::GDBController::slotStart(), GDBDebugger::DebuggerPart::startDebugger(), and SubclassesDlg::SubclassesDlg().


Member Function Documentation

bool DomUtil::appendText QDomDocument  doc,
QString  pathExt,
QString  text
[static]
 

Add child text node to parent described in pathExt.

Definition at line 326 of file domutil.cpp.

References appendText(), elementByPathExt(), and text().

Referenced by appendText(), and replaceText().

QDomElement DomUtil::createElementByPath QDomDocument doc,
const QString path
[static]
 

Retrieves an element by path, creating the necessary nodes.

Definition at line 132 of file domutil.cpp.

References createElementByPath(), and namedChildElement().

Referenced by createElementByPath(), writeEntry(), writeListEntry(), and writePairListEntry().

QDomElement DomUtil::elementByPath const QDomDocument doc,
const QString path
[static]
 

Retrieves an element by path, return null if any item along the path does not exist.

Definition at line 28 of file domutil.cpp.

References elementByPath().

Referenced by elementByPath(), readEntry(), readEntryAux(), readListEntry(), and readPairListEntry().

QDomElement DomUtil::elementByPathExt QDomDocument doc,
const QString pathstring
[static]
 

Retrieve an element specified with extended path examples:.

  • 1: "widget|class=QDialog/property|name=geometry" or "widget|class=QDialog/property||1"
  • 2: "widget/property|name=caption/string" or "widget/property||2/string"
<widget class="QDialog"> <property name="name"> <cstring>KdevFormName</cstring> </property> <property name="geometry"> <-- 1. reaches this node <rect> <x>0</x> <y>0</y> <width>600</width> <height>480</height> </rect> </property> <property name="caption"> <string>KdevFormCaption</string> <-- 2. reaches this node </property> </widget>

Definition at line 235 of file domutil.cpp.

References DomPathElement::attribute, elementByPathExt(), DomPathElement::matchNumber, DomAttribute::name, resolvPathStringExt(), rightchild, DomPathElement::tagName, and DomAttribute::value.

Referenced by appendText(), elementByPathExt(), and removeTextNodes().

void DomUtil::makeEmpty QDomElement  )  [static]
 

Remove all child elements from a given element.

Definition at line 22 of file domutil.cpp.

References makeEmpty().

Referenced by makeEmpty().

QDomElement DomUtil::namedChildElement QDomElement el,
const QString name
[static]
 

Retrieves a child element, creating it if it does not exist.

The return value is guaranteed to be non isNull()

Definition at line 121 of file domutil.cpp.

References namedChildElement().

Referenced by createElementByPath(), and namedChildElement().

bool DomUtil::openDOMFile QDomDocument doc,
QString  filename
[static]
 

Open file - filename - and set setContents of doc.

Definition at line 289 of file domutil.cpp.

References file, and openDOMFile().

Referenced by openDOMFile().

bool DomUtil::readBoolEntry const QDomDocument doc,
const QString path,
bool  defaultEntry = false
[static]
 

Reads a boolean entry.

The strings "true" and "TRUE" are interpreted as true, all other as false.

Definition at line 75 of file domutil.cpp.

References readBoolEntry(), and readEntryAux().

Referenced by readBoolEntry().

QString DomUtil::readEntry const QDomDocument doc,
const QString path,
const QString defaultEntry = QString::null
[static]
 

Reads a string entry.

Definition at line 43 of file domutil.cpp.

References elementByPath(), and readEntry().

Referenced by readEntry().

QString DomUtil::readEntryAux const QDomDocument doc,
const QString path
[static, private]
 

Todo:
consider whether it's okay to accept empty string == default value if not use the below type typedef pair<bool,QString> EltInfo;

Definition at line 56 of file domutil.cpp.

References elementByPath(), and readEntryAux().

Referenced by readBoolEntry(), readEntryAux(), and readIntEntry().

int DomUtil::readIntEntry const QDomDocument doc,
const QString path,
int  defaultEntry = 0
[static]
 

Reads a number entry.

Definition at line 65 of file domutil.cpp.

References readEntryAux(), and readIntEntry().

Referenced by readIntEntry().

QStringList DomUtil::readListEntry const QDomDocument doc,
const QString path,
const QString tag
[static]
 

Reads a list entry.

See writeListEntry().

Definition at line 85 of file domutil.cpp.

References elementByPath(), and readListEntry().

Referenced by readListEntry().

DomUtil::PairList DomUtil::readPairListEntry const QDomDocument doc,
const QString path,
const QString tag,
const QString firstAttr,
const QString secondAttr
[static]
 

Reads a list of string pairs.

See writePairListEntry().

Definition at line 101 of file domutil.cpp.

References elementByPath(), first(), Pair, PairList, and readPairListEntry().

Referenced by readPairListEntry().

bool DomUtil::removeTextNodes QDomDocument  doc,
QString  pathExt
[static]
 

Remove all child text nodes of parent described in pathExt.

Definition at line 313 of file domutil.cpp.

References elementByPathExt(), and removeTextNodes().

Referenced by removeTextNodes(), and replaceText().

bool DomUtil::replaceText QDomDocument  doc,
QString  pathExt,
QString  text
[static]
 

Replace all chilt text nodes of parent described in pathExt with one new.

Definition at line 336 of file domutil.cpp.

References appendText(), removeTextNodes(), replaceText(), and text().

Referenced by replaceText().

DomPath DomUtil::resolvPathStringExt const QString  pathstring  )  [static]
 

Resolves an extended path Extended path format: pathpart: tag[|attr1=value[;attr2=value;..][|matchNumber]] where matchNumber is zero-based path: pathpart[/pathpart/..].

Definition at line 197 of file domutil.cpp.

References DomPathElement::attribute, DomPath, DomPathElement::matchNumber, DomAttribute::name, resolvPathStringExt(), DomPathElement::tagName, and DomAttribute::value.

Referenced by elementByPathExt(), and resolvPathStringExt().

bool DomUtil::saveDOMFile QDomDocument doc,
QString  filename
[static]
 

Store contents of doc in file - filename.

Existing file will be truncated!

Definition at line 302 of file domutil.cpp.

References file, and saveDOMFile().

Referenced by saveDOMFile().

void DomUtil::writeBoolEntry QDomDocument doc,
const QString path,
bool  value
[static]
 

Writes a boolean entry.

Booleans are stored as "true", "false" resp.

Definition at line 162 of file domutil.cpp.

References writeBoolEntry(), and writeEntry().

Referenced by writeBoolEntry().

void DomUtil::writeEntry QDomDocument doc,
const QString path,
const QString value
[static]
 

Writes a string entry.

For example,

<code> writeEntry(doc, "/general/special", "foo"); </code>
creates the DOM fragment:
<code> <general><special>foo</special></general> </code>

Definition at line 149 of file domutil.cpp.

References createElementByPath(), and writeEntry().

Referenced by writeBoolEntry(), writeEntry(), and writeIntEntry().

void DomUtil::writeIntEntry QDomDocument doc,
const QString path,
int  value
[static]
 

Writes a number entry.

Definition at line 156 of file domutil.cpp.

References writeEntry(), and writeIntEntry().

Referenced by writeIntEntry().

void DomUtil::writeListEntry QDomDocument doc,
const QString path,
const QString tag,
const QStringList value
[static]
 

Writes a string list element.

The list elements are separated by tag. For example,

<code> QStringList l; l << "one" << "two"; writeEntry(doc, "/general/special", "el", l); </code>
creates the DOM fragment:
<code> <general><special><el>one</el><el>two</el></special></general> </code>

Definition at line 168 of file domutil.cpp.

References createElementByPath(), and writeListEntry().

Referenced by writeListEntry().

void DomUtil::writePairListEntry QDomDocument doc,
const QString path,
const QString tag,
const QString firstAttr,
const QString secondAttr,
const PairList value
[static]
 

Writes a list of string pairs.

The list elements are stored in the attributes firstAttr and secondAttr of elements named tag. For example,

<code> DomUtil::StringPairList l; l << DomUtil::StringPair("one", "1"); l << DomUtil::StringPair("two", "2"); writeEntry(doc, "/general/special", "el", "first", "second", l); </code>
creates the DOM fragment:
<code> <general><special> <el first="one" second="1"/> <el first="two" second="2"/> </special></general> </code>

Definition at line 182 of file domutil.cpp.

References createElementByPath(), and writePairListEntry().

Referenced by writePairListEntry().


The documentation for this class was generated from the following files:
KDE Logo
This file is part of the documentation for KDevelop Version 3.0.4.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Oct 6 17:39:24 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003