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

KDevelop Utility Library

  • lib
  • util
domutil.h
Go to the documentation of this file.
1/***************************************************************************
2 * Copyright (C) 2001 by Bernd Gehrmann *
3 * bernd@kdevelop.org *
4 * jakob@simon-gaarde.dk *
5 * *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
10 * *
11 ***************************************************************************/
12
13#ifndef _DOMUTIL_H_
14#define _DOMUTIL_H_
15
16#include <tqdom.h>
17#include <tqpair.h>
18#include <tqstringlist.h>
19#include <tqvaluelist.h>
20#include <tqmap.h>
21
27struct DomAttribute
28{
29 TQString name;
30 TQString value;
31};
32
33struct DomPathElement
34{
35 TQString tagName;
36 TQValueList<DomAttribute> attribute;
37 int matchNumber; // for use when more than one element matches the path
38};
39
40typedef TQValueList<DomPathElement> DomPath;
41
45class DomUtil
46{
47public:
48 typedef TQPair<TQString, TQString> Pair;
49 typedef TQValueList<Pair> PairList;
53 static void makeEmpty( TQDomElement& );
57 static TQString readEntry(const TQDomDocument &doc, const TQString &path, const TQString &defaultEntry = TQString());
61 static int readIntEntry(const TQDomDocument &doc, const TQString &path, int defaultEntry = 0);
66 static bool readBoolEntry(const TQDomDocument &doc, const TQString &path, bool defaultEntry = false);
70 static TQStringList readListEntry(const TQDomDocument &doc, const TQString &path, const TQString &tag);
74 static PairList readPairListEntry(const TQDomDocument &doc, const TQString &path, const TQString &tag,
75 const TQString &firstAttr, const TQString &secondAttr);
79 static TQMap<TQString, TQString> readMapEntry(const TQDomDocument &doc, const TQString &path);
84 static TQDomElement elementByPath( const TQDomDocument& doc, const TQString& path );
88 static TQDomElement createElementByPath( TQDomDocument& doc, const TQString& path );
93 static TQDomElement namedChildElement( TQDomElement& el, const TQString& name );
106 static void writeEntry(TQDomDocument &doc, const TQString &path, const TQString &value);
110 static void writeIntEntry(TQDomDocument &doc, const TQString &path, int value);
114 static void writeBoolEntry(TQDomDocument &doc, const TQString &path, bool value);
128 static void writeListEntry(TQDomDocument &doc, const TQString &path, const TQString &tag,
129 const TQStringList &value);
149 static void writePairListEntry(TQDomDocument &doc, const TQString &path, const TQString &tag,
150 const TQString &firstAttr, const TQString &secondAttr,
151 const PairList &value);
156 static void writeMapEntry(TQDomDocument &doc, const TQString& path, const TQMap<TQString,TQString> &map);
157
165 static DomPath resolvPathStringExt(const TQString pathstring);
166
195 static TQDomElement elementByPathExt(TQDomDocument &doc, const TQString &pathstring);
196
200 static bool openDOMFile(TQDomDocument &doc, TQString filename);
201
205 static bool saveDOMFile(TQDomDocument &doc, TQString filename);
206
210 static bool removeTextNodes(TQDomDocument doc,TQString pathExt);
211
215 static bool appendText(TQDomDocument doc, TQString pathExt, TQString text);
216
220 static bool replaceText(TQDomDocument doc, TQString pathExt, TQString text);
221
222private:
223 static TQString readEntryAux(const TQDomDocument &doc, const TQString &path);
224};
225
226#endif
DomUtil
Utility class for conveniently accessing data in a DOM tree.
Definition domutil.h:46
DomUtil::replaceText
static bool replaceText(TQDomDocument doc, TQString pathExt, TQString text)
Replace all chilt text nodes of parent described in pathExt with one new.
Definition domutil.cpp:360
DomUtil::readMapEntry
static TQMap< TQString, TQString > readMapEntry(const TQDomDocument &doc, const TQString &path)
Reads a string to string map.
Definition domutil.cpp:120
DomUtil::writeBoolEntry
static void writeBoolEntry(TQDomDocument &doc, const TQString &path, bool value)
Writes a boolean entry.
Definition domutil.cpp:186
DomUtil::elementByPathExt
static TQDomElement elementByPathExt(TQDomDocument &doc, const TQString &pathstring)
Retrieve an element specified with extended path examples:
Definition domutil.cpp:259
DomUtil::appendText
static bool appendText(TQDomDocument doc, TQString pathExt, TQString text)
Add child text node to parent described in pathExt.
Definition domutil.cpp:350
DomUtil::saveDOMFile
static bool saveDOMFile(TQDomDocument &doc, TQString filename)
Store contents of doc in file - filename.
Definition domutil.cpp:326
DomUtil::createElementByPath
static TQDomElement createElementByPath(TQDomDocument &doc, const TQString &path)
Retrieves an element by path, creating the necessary nodes.
Definition domutil.cpp:145
DomUtil::removeTextNodes
static bool removeTextNodes(TQDomDocument doc, TQString pathExt)
Remove all child text nodes of parent described in pathExt.
Definition domutil.cpp:337
DomUtil::readEntry
static TQString readEntry(const TQDomDocument &doc, const TQString &path, const TQString &defaultEntry=TQString())
Reads a string entry.
Definition domutil.cpp:43
DomUtil::openDOMFile
static bool openDOMFile(TQDomDocument &doc, TQString filename)
Open file - filename - and set setContents of doc.
Definition domutil.cpp:313
DomUtil::namedChildElement
static TQDomElement namedChildElement(TQDomElement &el, const TQString &name)
Retrieves a child element, creating it if it does not exist.
Definition domutil.cpp:134
DomUtil::writeEntry
static void writeEntry(TQDomDocument &doc, const TQString &path, const TQString &value)
Writes a string entry.
Definition domutil.cpp:162
DomUtil::writePairListEntry
static void writePairListEntry(TQDomDocument &doc, const TQString &path, const TQString &tag, const TQString &firstAttr, const TQString &secondAttr, const PairList &value)
Writes a list of string pairs.
Definition domutil.cpp:206
DomUtil::writeMapEntry
static void writeMapEntry(TQDomDocument &doc, const TQString &path, const TQMap< TQString, TQString > &map)
Writes a string to string map.
Definition domutil.cpp:168
DomUtil::readPairListEntry
static PairList readPairListEntry(const TQDomDocument &doc, const TQString &path, const TQString &tag, const TQString &firstAttr, const TQString &secondAttr)
Reads a list of string pairs.
Definition domutil.cpp:101
DomUtil::readIntEntry
static int readIntEntry(const TQDomDocument &doc, const TQString &path, int defaultEntry=0)
Reads a number entry.
Definition domutil.cpp:65
DomUtil::makeEmpty
static void makeEmpty(TQDomElement &)
Remove all child elements from a given element.
Definition domutil.cpp:22
DomUtil::elementByPath
static TQDomElement elementByPath(const TQDomDocument &doc, const TQString &path)
Retrieves an element by path, return null if any item along the path does not exist.
Definition domutil.cpp:28
DomUtil::resolvPathStringExt
static DomPath resolvPathStringExt(const TQString pathstring)
Resolves an extended path Extended path format: pathpart: tag[|attr1=value[;attr2=value;....
Definition domutil.cpp:221
DomUtil::writeIntEntry
static void writeIntEntry(TQDomDocument &doc, const TQString &path, int value)
Writes a number entry.
Definition domutil.cpp:180
DomUtil::readListEntry
static TQStringList readListEntry(const TQDomDocument &doc, const TQString &path, const TQString &tag)
Reads a list entry.
Definition domutil.cpp:85
DomUtil::readBoolEntry
static bool readBoolEntry(const TQDomDocument &doc, const TQString &path, bool defaultEntry=false)
Reads a boolean entry.
Definition domutil.cpp:75
DomUtil::writeListEntry
static void writeListEntry(TQDomDocument &doc, const TQString &path, const TQString &tag, const TQStringList &value)
Writes a string list element.
Definition domutil.cpp:192

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.9.8
This website is maintained by Timothy Pearson.