KDevelop API Documentation

domutil.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2001 by Bernd Gehrmann                                  *
00003  *   bernd@kdevelop.org                                                    *
00004  *   jakob@simon-gaarde.dk                                                 *
00005  *                                                                         *
00006  *   This program is free software; you can redistribute it and/or modify  *
00007  *   it under the terms of the GNU General Public License as published by  *
00008  *   the Free Software Foundation; either version 2 of the License, or     *
00009  *   (at your option) any later version.                                   *
00010  *                                                                         *
00011  ***************************************************************************/
00012 
00013 #ifndef _DOMUTIL_H_
00014 #define _DOMUTIL_H_
00015 
00016 #include <qdom.h>
00017 #include <qpair.h>
00018 #include <qstringlist.h>
00019 #include <qvaluelist.h>
00020 #include <qmap.h>
00021 
00022 struct DomAttribute
00023 {
00024   QString name;
00025   QString value;
00026 };
00027 
00028 struct DomPathElement
00029 {
00030   QString tagName;
00031   QValueList<DomAttribute> attribute;
00032   int matchNumber;  // for use when more than one element matches the path
00033 };
00034 
00035 typedef QValueList<DomPathElement> DomPath;
00036 
00040 class DomUtil
00041 {
00042 public:
00043     typedef QPair<QString, QString> Pair;
00044     typedef QValueList<Pair> PairList;
00048     static void makeEmpty( QDomElement& );
00052     static QString readEntry(const QDomDocument &doc, const QString &path, const QString &defaultEntry = QString::null);
00056     static int readIntEntry(const QDomDocument &doc, const QString &path, int defaultEntry = 0);
00061     static bool readBoolEntry(const QDomDocument &doc, const QString &path, bool defaultEntry = false);
00065     static QStringList readListEntry(const QDomDocument &doc, const QString &path, const QString &tag);
00069     static PairList readPairListEntry(const QDomDocument &doc, const QString &path, const QString &tag,
00070                                       const QString &firstAttr, const QString &secondAttr);
00074     static QMap<QString, QString> readMapEntry(const QDomDocument &doc, const QString &path);
00079     static QDomElement elementByPath( const QDomDocument& doc, const QString& path );
00083     static QDomElement createElementByPath( QDomDocument& doc, const QString& path );
00088     static QDomElement namedChildElement( QDomElement& el, const QString& name );
00101     static void writeEntry(QDomDocument &doc, const QString &path, const QString &value);
00105     static void writeIntEntry(QDomDocument &doc, const QString &path, int value);
00109     static void writeBoolEntry(QDomDocument &doc, const QString &path, bool value);
00123     static void writeListEntry(QDomDocument &doc, const QString &path, const QString &tag,
00124                                const QStringList &value);
00144     static void writePairListEntry(QDomDocument &doc, const QString &path, const QString &tag,
00145                                    const QString &firstAttr, const QString &secondAttr,
00146                                    const PairList &value);
00151     static void writeMapEntry(QDomDocument &doc, const QString& path, const QMap<QString,QString> &map);
00152 
00160     static DomPath resolvPathStringExt(const QString pathstring);
00161 
00190     static QDomElement elementByPathExt(QDomDocument &doc, const QString &pathstring);
00191 
00195     static bool openDOMFile(QDomDocument &doc, QString filename);
00196 
00200     static bool saveDOMFile(QDomDocument &doc, QString filename);
00201 
00205     static bool removeTextNodes(QDomDocument doc,QString pathExt);
00206 
00210     static bool appendText(QDomDocument doc, QString pathExt, QString text);
00211 
00215     static bool replaceText(QDomDocument doc, QString pathExt, QString text);
00216 
00217 private:
00218     static QString readEntryAux(const QDomDocument &doc, const QString &path);
00219 };
00220 
00221 #endif
KDE Logo
This file is part of the documentation for KDevelop Version 3.1.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Mar 23 00:03:52 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003