PACK WOC  $VERSION$
domquery.h
Go to the documentation of this file.
1 // Copyright (C) 2009-2011 by Konrad Rosenbaum <konrad@silmor.de>
2 // protected under the GNU GPL version 3 or at your option any newer.
3 // See COPYING.GPL file that comes with this distribution.
4 //
5 
6 #ifndef MAGICSMOKE_DOMQUERY_H
7 #define MAGICSMOKE_DOMQUERY_H
8 
9 
10 #include <QDomElement>
11 #include <QList>
12 #include <QStringList>
13 
15 class MDomNodeList:public QList<QDomNode>
16 {
17  public:
19  MDomNodeList(const MDomNodeList&l):QList<QDomNode>(l){}
20  MDomNodeList(const QList<QDomNode>&l):QList<QDomNode>(l){}
21  MDomNodeList(const QDomNodeList&l){for(int i=0;i<l.size();i++)append(l.at(i));}
22  MDomNodeList(const QDomNamedNodeMap&l){for(int i=0;i<l.size();i++)append(l.item(i));}
23 
24  MDomNodeList& operator+=(const QDomNodeList&l)
25  {for(int i=0;i<l.size();i++)append(l.at(i));return *this;}
26 
27  MDomNodeList& operator+=(const QDomNamedNodeMap&l)
28  {for(int i=0;i<l.size();i++)append(l.item(i));return *this;}
29 };
30 
31 
55 class MDomQuery
56 {
57  public:
59  MDomQuery(const QDomElement&start,QString path);
60 
62  MDomQuery(const QDomDocument&start,QString path);
63 
65  QString toString()const;
67  QStringList toStringList()const;
70 
72  operator QString()const{return toString();}
74  operator QStringList()const{return toStringList();}
76  operator MDomNodeList()const{return m_result;}
77  private:
79 
80  //helper for constructor
81  void construct(const QDomElement&start,QString path);
82 };
83 
84 #endif
void construct(const QDomElement &start, QString path)
Definition: domquery.cpp:19
MDomNodeList & operator+=(const QDomNamedNodeMap &l)
Definition: domquery.h:27
MDomNodeList(const QDomNamedNodeMap &l)
Definition: domquery.h:22
MDomNodeList(const MDomNodeList &l)
Definition: domquery.h:19
QString toString() const
returns the search result as a single string, if there were multiple matches, they are separated by s...
Definition: domquery.cpp:116
QStringList toStringList() const
returns the search result as a list of strings, one string element per match
Definition: domquery.cpp:129
MDomNodeList()
Definition: domquery.h:18
MDomNodeList toNodeList() const
returns the result as a list of DOM nodes
Definition: domquery.h:69
MDomNodeList m_result
Definition: domquery.h:78
Helper class: more flexible version of QDomNodeList.
Definition: domquery.h:15
MDomNodeList & operator+=(const QDomNodeList &l)
Definition: domquery.h:24
DOM Query Class.
Definition: domquery.h:55
MDomQuery(const QDomElement &start, QString path)
creates the query object and executes the query
Definition: domquery.cpp:14
MDomNodeList(const QDomNodeList &l)
Definition: domquery.h:21
MDomNodeList(const QList< QDomNode > &l)
Definition: domquery.h:20