summaryrefslogtreecommitdiff
path: root/libsql/osqlresult.h
authorzecke <zecke>2002-08-27 20:17:50 (UTC)
committer zecke <zecke>2002-08-27 20:17:50 (UTC)
commit86352e32f449ecf00de254674b7dcac72bc34a14 (patch) (unidiff)
treeb5803b69ca00dceea1e2a76a5eee390f0748f27e /libsql/osqlresult.h
parent1398b50ffc193bc9ab69ebe198aeda847c39516e (diff)
downloadopie-86352e32f449ecf00de254674b7dcac72bc34a14.zip
opie-86352e32f449ecf00de254674b7dcac72bc34a14.tar.gz
opie-86352e32f449ecf00de254674b7dcac72bc34a14.tar.bz2
Initial check in of the light wrapper library
around normal SQL The first driver implementation is a SQLite version
Diffstat (limited to 'libsql/osqlresult.h') (more/less context) (ignore whitespace changes)
-rw-r--r--libsql/osqlresult.h112
1 files changed, 112 insertions, 0 deletions
diff --git a/libsql/osqlresult.h b/libsql/osqlresult.h
new file mode 100644
index 0000000..9c9efa2
--- a/dev/null
+++ b/libsql/osqlresult.h
@@ -0,0 +1,112 @@
1#ifndef OSQL_RESULT_H
2#define OSQL_RESULT_H
3
4#include <qdatetime.h>
5#include <qmap.h>
6#include <qvaluelist.h>
7
8
9#include "osqlerror.h"
10/**
11 * ResultItem represents one row of the resulting answer
12 */
13class OSQLResultItem {
14public:
15 typedef QValueList<OSQLResultItem> ValueList;
16 /**
17 * TableString is used to establish the relations
18 * between the column name and the real item
19 */
20 typedef QMap<QString, QString> TableString;
21
22 /**
23 * TableInt is used to establish a relation between a
24 * position of a column and the row value
25 */
26 typedef QMap<int, QString> TableInt;
27
28 /**
29 * Default c'tor. It has a TableString and a TableInt
30 */
31 OSQLResultItem(const TableString& = TableString(),
32 const TableInt& = TableInt() );
33 OSQLResultItem( const OSQLResultItem& );
34 ~OSQLResultItem();
35 OSQLResultItem &operator=( const OSQLResultItem& );
36 /**
37 * returns the TableString
38 */
39 TableString tableString()const;
40
41 /**
42 * returns the TableInt
43 */
44 TableInt tableInt() const;
45
46 /**
47 * retrieves the Data from columnName
48 *
49 */
50 QString data( const QString& columnName, bool *ok = 0);
51
52 /**
53 * QString for column number
54 */
55 QString data(int columnNumber, bool *ok = 0);
56
57 /**
58 * Date conversion from columnName
59 */
60 QDate dataToDate( const QString& columnName, bool *ok = 0 );
61
62 /**
63 * Date conversion from column-number
64 */
65 QDate dataToDate( int columnNumber, bool *ok = 0 );
66
67 QDateTime dataToDateTime( const QString& columName, bool *ok = 0 );
68 QDateTime dataToDateTime( int columnNumber, bool *ok = 0 );
69private:
70 TableString m_string;
71 TableInt m_int;
72};
73
74/**
75 * the OSQLResult
76 * either a SQL statement failed or succeeded
77 */
78class OSQLResult {
79public:
80 /** The State of a Result */
81 enum State{ Success = 0, Failure,Undefined };
82
83 /**
84 * default c'tor
85 * @param state The State of the Result
86 * @param r ResultItems
87 * @prarm errors the Errors a OSQLResult created
88 */
89 OSQLResult( enum State state = Undefined,
90 const OSQLResultItem::ValueList& r= OSQLResultItem::ValueList(),
91 const OSQLError::ValueList& errors = OSQLError::ValueList() );
92 ~OSQLResult();
93 State state()const;
94 OSQLError::ValueList errors()const;
95 OSQLResultItem::ValueList results()const;
96
97 void setState( enum State state );
98 void setErrors( const OSQLError::ValueList& error );
99 void setResults( const OSQLResultItem::ValueList& result );
100
101 OSQLResultItem first();
102 OSQLResultItem next();
103 bool atEnd();
104 OSQLResultItem::ValueList::ConstIterator iterator()const;
105private:
106 enum State m_state;
107 OSQLResultItem::ValueList m_list;
108 OSQLError::ValueList m_error;
109 OSQLResultItem::ValueList::Iterator it;
110};
111
112#endif