Ok, the long awaited config wizard is here (at least in a very basic state). There...
[quassel.git] / src / contrib / libqxt-2007-10-24 / src / sql / qxtsqlpackage.h
1 /****************************************************************************
2 **
3 ** Copyright (C) Qxt Foundation. Some rights reserved.
4 **
5 ** This file is part of the QxtSql module of the Qt eXTension library
6 **
7 ** This library is free software; you can redistribute it and/or modify it
8 ** under the terms of th Common Public License, version 1.0, as published by
9 ** IBM.
10 **
11 ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY
12 ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY
13 ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR
14 ** FITNESS FOR A PARTICULAR PURPOSE.
15 **
16 ** You should have received a copy of the CPL along with this file.
17 ** See the LICENSE file and the cpl1.0.txt file included with the source
18 ** distribution for more information. If you did not receive a copy of the
19 ** license, contact the Qxt Foundation.
20 **
21 ** <http://libqxt.sourceforge.net>  <foundation@libqxt.org>
22 **
23 ****************************************************************************/
24
25
26 /**
27 \class QxtSqlPackage QxtSqlPackage
28
29 \ingroup QxtSql
30
31 \brief full serialiseable QSqlQuery storage
32
33
34 Sometimes you want to set sql results over network or store them into files. QxtSqlPackage can provide you a storage that is still valid after the actual QSqlQuery has been destroyed
35 for confidence the interface is similiar to QSqlQuery.
36 */
37
38 #ifndef QXTSQLPACKAGE_H
39 #define QXTSQLPACKAGE_H
40 #include <QObject>
41 #include <QHash>
42 #include <QList>
43 #include <QtSql>
44 #include <qxtglobal.h>
45
46 class QXT_SQL_EXPORT QxtSqlPackage : public  QObject
47 {
48     Q_OBJECT
49
50 public:
51     QxtSqlPackage(QObject *parent = 0);
52     QxtSqlPackage(const QxtSqlPackage & other,QObject *parent = 0);
53
54     ///determinates if the package curently points to a valid row
55     bool isValid();
56
57     ///curent pointer position
58     int at();
59
60     /** \brief point to next entry
61
62     returns false if there is no next entry.\n
63     provided for easy porting from QSqlQuery.
64
65     \code       
66     while (query.next())
67         {
68         }
69     \endcode 
70     */
71     bool next();
72
73     ///point to last entry in storage
74     bool last();
75
76     ///point to first entry in storage
77     bool first();
78
79     /** \brief return a cloumn in curent row
80
81     in contrast to QSqlQuery you have to provide the name of the key.
82
83     the entry is returned as QString becouse in most cases you need QString anyway, and converting to needed data type is easy.
84     \code
85     QString name = query.value("name"); 
86     \endcode 
87     */
88     QString value(const QString& key);
89
90     /** \brief read from QSqlQuery
91
92     read out a QSqlQuery and store the result. you may close the query after reading, the data will stay.
93
94     \code
95     QxSqlPackage::insert(QSqlQuery::exec("select name,foo,bar from table;"));
96     \endcode 
97     */
98     void insert(QSqlQuery query);
99
100     ///Returns the number of rows stored
101     int count() const;
102
103     ///serialise Data
104     QByteArray data() const;
105
106     ///deserialise data
107     void setData(const QByteArray& data);
108
109     ///return a specific row as Hash
110     QHash<QString,QString> hash(int index);
111     ///return the curent row as Hash
112     QHash<QString,QString> hash();
113     QxtSqlPackage& operator= (const QxtSqlPackage& other);
114
115 private:
116     QList<QHash<QString,QString> > map;
117     int record;
118 };
119
120
121
122 #endif