1 /****************************************************************************
3 ** Copyright (C) Qxt Foundation. Some rights reserved.
5 ** This file is part of the QxtSql module of the Qt eXTension library
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
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.
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.
21 ** <http://libqxt.sourceforge.net> <foundation@libqxt.org>
23 ****************************************************************************/
27 \class QxtSqlPackage QxtSqlPackage
31 \brief full serialiseable QSqlQuery storage
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.
38 #ifndef QXTSQLPACKAGE_H
39 #define QXTSQLPACKAGE_H
44 #include <qxtglobal.h>
46 class QXT_SQL_EXPORT QxtSqlPackage : public QObject
51 QxtSqlPackage(QObject *parent = 0);
52 QxtSqlPackage(const QxtSqlPackage & other,QObject *parent = 0);
54 ///determinates if the package curently points to a valid row
57 ///curent pointer position
60 /** \brief point to next entry
62 returns false if there is no next entry.\n
63 provided for easy porting from QSqlQuery.
73 ///point to last entry in storage
76 ///point to first entry in storage
79 /** \brief return a cloumn in curent row
81 in contrast to QSqlQuery you have to provide the name of the key.
83 the entry is returned as QString becouse in most cases you need QString anyway, and converting to needed data type is easy.
85 QString name = query.value("name");
88 QString value(const QString& key);
90 /** \brief read from QSqlQuery
92 read out a QSqlQuery and store the result. you may close the query after reading, the data will stay.
95 QxSqlPackage::insert(QSqlQuery::exec("select name,foo,bar from table;"));
98 void insert(QSqlQuery query);
100 ///Returns the number of rows stored
104 QByteArray data() const;
107 void setData(const QByteArray& data);
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);
116 QList<QHash<QString,QString> > map;