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