• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • KDevelop Utility Library
 

KDevelop Utility Library

Public Types | Static Public Member Functions | List of all members
DomUtil Class Reference

#include <domutil.h>

Public Types

typedef TQPair< TQString, TQString > Pair
 
typedef TQValueList< Pair > PairList
 

Static Public Member Functions

static void makeEmpty (TQDomElement &)
 
static TQString readEntry (const TQDomDocument &doc, const TQString &path, const TQString &defaultEntry=TQString())
 
static int readIntEntry (const TQDomDocument &doc, const TQString &path, int defaultEntry=0)
 
static bool readBoolEntry (const TQDomDocument &doc, const TQString &path, bool defaultEntry=false)
 
static TQStringList readListEntry (const TQDomDocument &doc, const TQString &path, const TQString &tag)
 
static PairList readPairListEntry (const TQDomDocument &doc, const TQString &path, const TQString &tag, const TQString &firstAttr, const TQString &secondAttr)
 
static TQMap< TQString, TQString > readMapEntry (const TQDomDocument &doc, const TQString &path)
 
static TQDomElement elementByPath (const TQDomDocument &doc, const TQString &path)
 
static TQDomElement createElementByPath (TQDomDocument &doc, const TQString &path)
 
static TQDomElement namedChildElement (TQDomElement &el, const TQString &name)
 
static void writeEntry (TQDomDocument &doc, const TQString &path, const TQString &value)
 
static void writeIntEntry (TQDomDocument &doc, const TQString &path, int value)
 
static void writeBoolEntry (TQDomDocument &doc, const TQString &path, bool value)
 
static void writeListEntry (TQDomDocument &doc, const TQString &path, const TQString &tag, const TQStringList &value)
 
static void writePairListEntry (TQDomDocument &doc, const TQString &path, const TQString &tag, const TQString &firstAttr, const TQString &secondAttr, const PairList &value)
 
static void writeMapEntry (TQDomDocument &doc, const TQString &path, const TQMap< TQString, TQString > &map)
 
static DomPath resolvPathStringExt (const TQString pathstring)
 
static TQDomElement elementByPathExt (TQDomDocument &doc, const TQString &pathstring)
 
static bool openDOMFile (TQDomDocument &doc, TQString filename)
 
static bool saveDOMFile (TQDomDocument &doc, TQString filename)
 
static bool removeTextNodes (TQDomDocument doc, TQString pathExt)
 
static bool appendText (TQDomDocument doc, TQString pathExt, TQString text)
 
static bool replaceText (TQDomDocument doc, TQString pathExt, TQString text)
 

Detailed Description

Utility class for conveniently accessing data in a DOM tree.

Definition at line 45 of file domutil.h.

Member Function Documentation

◆ appendText()

bool DomUtil::appendText ( TQDomDocument  doc,
TQString  pathExt,
TQString  text 
)
static

Add child text node to parent described in pathExt.

Definition at line 350 of file domutil.cpp.

◆ createElementByPath()

TQDomElement DomUtil::createElementByPath ( TQDomDocument &  doc,
const TQString &  path 
)
static

Retrieves an element by path, creating the necessary nodes.

Definition at line 145 of file domutil.cpp.

◆ elementByPath()

TQDomElement DomUtil::elementByPath ( const TQDomDocument &  doc,
const TQString &  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.

◆ elementByPathExt()

TQDomElement DomUtil::elementByPathExt ( TQDomDocument &  doc,
const TQString &  pathstring 
)
static

Retrieve an element specified with extended path examples:

  • 1: "widget|class=TQDialog/property|name=geometry" or "widget|class=TQDialog/property||1"
  • 2: "widget/property|name=caption/string" or "widget/property||2/string"
  <widget class=TQDIALOG_OBJECT_NAME_STRING>
    <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 259 of file domutil.cpp.

◆ makeEmpty()

void DomUtil::makeEmpty ( TQDomElement &  e)
static

Remove all child elements from a given element.

Definition at line 22 of file domutil.cpp.

◆ namedChildElement()

TQDomElement DomUtil::namedChildElement ( TQDomElement &  el,
const TQString &  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 134 of file domutil.cpp.

◆ openDOMFile()

bool DomUtil::openDOMFile ( TQDomDocument &  doc,
TQString  filename 
)
static

Open file - filename - and set setContents of doc.

Definition at line 313 of file domutil.cpp.

◆ readBoolEntry()

bool DomUtil::readBoolEntry ( const TQDomDocument &  doc,
const TQString &  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.

◆ readEntry()

TQString DomUtil::readEntry ( const TQDomDocument &  doc,
const TQString &  path,
const TQString &  defaultEntry = TQString() 
)
static

Reads a string entry.

Definition at line 43 of file domutil.cpp.

◆ readIntEntry()

int DomUtil::readIntEntry ( const TQDomDocument &  doc,
const TQString &  path,
int  defaultEntry = 0 
)
static

Reads a number entry.

Definition at line 65 of file domutil.cpp.

◆ readListEntry()

TQStringList DomUtil::readListEntry ( const TQDomDocument &  doc,
const TQString &  path,
const TQString &  tag 
)
static

Reads a list entry.

See writeListEntry().

Definition at line 85 of file domutil.cpp.

◆ readMapEntry()

TQMap< TQString, TQString > DomUtil::readMapEntry ( const TQDomDocument &  doc,
const TQString &  path 
)
static

Reads a string to string map.

See writeMapEntry()

Definition at line 120 of file domutil.cpp.

◆ readPairListEntry()

DomUtil::PairList DomUtil::readPairListEntry ( const TQDomDocument &  doc,
const TQString &  path,
const TQString &  tag,
const TQString &  firstAttr,
const TQString &  secondAttr 
)
static

Reads a list of string pairs.

See writePairListEntry().

Definition at line 101 of file domutil.cpp.

◆ removeTextNodes()

bool DomUtil::removeTextNodes ( TQDomDocument  doc,
TQString  pathExt 
)
static

Remove all child text nodes of parent described in pathExt.

Definition at line 337 of file domutil.cpp.

◆ replaceText()

bool DomUtil::replaceText ( TQDomDocument  doc,
TQString  pathExt,
TQString  text 
)
static

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

Definition at line 360 of file domutil.cpp.

◆ resolvPathStringExt()

DomPath DomUtil::resolvPathStringExt ( const TQString  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 221 of file domutil.cpp.

◆ saveDOMFile()

bool DomUtil::saveDOMFile ( TQDomDocument &  doc,
TQString  filename 
)
static

Store contents of doc in file - filename.

Existing file will be truncated!

Definition at line 326 of file domutil.cpp.

◆ writeBoolEntry()

void DomUtil::writeBoolEntry ( TQDomDocument &  doc,
const TQString &  path,
bool  value 
)
static

Writes a boolean entry.

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

Definition at line 186 of file domutil.cpp.

◆ writeEntry()

void DomUtil::writeEntry ( TQDomDocument &  doc,
const TQString &  path,
const TQString &  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 162 of file domutil.cpp.

◆ writeIntEntry()

void DomUtil::writeIntEntry ( TQDomDocument &  doc,
const TQString &  path,
int  value 
)
static

Writes a number entry.

Definition at line 180 of file domutil.cpp.

◆ writeListEntry()

void DomUtil::writeListEntry ( TQDomDocument &  doc,
const TQString &  path,
const TQString &  tag,
const TQStringList &  value 
)
static

Writes a string list element.

The list elements are separated by tag. For example,

  <code>
    TQStringList l; l << "one" << "two";
    writeListEntry(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 192 of file domutil.cpp.

◆ writeMapEntry()

void DomUtil::writeMapEntry ( TQDomDocument &  doc,
const TQString &  path,
const TQMap< TQString, TQString > &  map 
)
static

Writes a string to string map.

This map is stored in a way, that it can be read with readMapEntry() and readEntry()

Definition at line 168 of file domutil.cpp.

◆ writePairListEntry()

void DomUtil::writePairListEntry ( TQDomDocument &  doc,
const TQString &  path,
const TQString &  tag,
const TQString &  firstAttr,
const TQString &  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::PairList l;
    l << DomUtil::StringPair("one", "1");
    l << DomUtil::StringPair("two", "2");
    writePairListEntry(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 206 of file domutil.cpp.


The documentation for this class was generated from the following files:
  • domutil.h
  • domutil.cpp

KDevelop Utility Library

Skip menu "KDevelop Utility Library"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members

KDevelop Utility Library

Skip menu "KDevelop Utility Library"
  • buildtools
  •   lib
  •     base
  •     parsers
  •       autotools
  •       qmake
  •     widgets
  •   api
  • languages
  •   lib
  •     debugger
  •     designer_integration
  •     interfaces
  • lib
  •   catalog
  •   interfaces
  •     extensions
  •     external
  •     extras
  •   util
  •   widgets
  •     propeditor
  • parts
  •   documentation
  •     interfaces
  • src
  •   profileengine
  •     lib
Generated for KDevelop Utility Library by doxygen 1.8.13
This website is maintained by Timothy Pearson.