summaryrefslogtreecommitdiff
path: root/libsql/osqlresult.cpp
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.cpp
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.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libsql/osqlresult.cpp127
1 files changed, 127 insertions, 0 deletions
diff --git a/libsql/osqlresult.cpp b/libsql/osqlresult.cpp
new file mode 100644
index 0000000..490fb45
--- a/dev/null
+++ b/libsql/osqlresult.cpp
@@ -0,0 +1,127 @@
1
2#include "osqlquery.h"
3#include "osqlresult.h"
4
5OSQLResultItem::OSQLResultItem( const TableString& string,
6 const TableInt& Int)
7 : m_string( string ), m_int( Int )
8{
9
10}
11OSQLResultItem::~OSQLResultItem() {
12}
13OSQLResultItem::OSQLResultItem( const OSQLResultItem& item) {
14 *this = item;
15}
16OSQLResultItem &OSQLResultItem::operator=( const OSQLResultItem& other) {
17 m_string = other.m_string;
18 m_int = other.m_int;
19 return *this;
20}
21OSQLResultItem::TableString OSQLResultItem::tableString()const{
22 return m_string;
23}
24OSQLResultItem::TableInt OSQLResultItem::tableInt()const {
25 return m_int;
26}
27QString OSQLResultItem::data( const QString& columnName, bool *ok ) {
28 TableString::Iterator it = m_string.find( columnName );
29
30 /* if found */
31 if ( it != m_string.end() ) {
32 if ( ok ) *ok = true;
33 return it.data();
34 }else{
35 if ( ok ) *ok = false;
36 return QString::null;
37 }
38
39}
40QString OSQLResultItem::data( int column, bool *ok ) {
41 TableInt::Iterator it = m_int.find( column );
42
43 /* if found */
44 if ( it != m_int.end() ) {
45 if ( ok ) *ok = true;
46 return it.data();
47 }else{
48 if ( ok ) *ok = false;
49 return QString::null;
50 }
51}
52/*
53 * DateFormat is 'YYYY-MM-DD'
54 */
55QDate OSQLResultItem::dataToDate( const QString& column, bool *ok ) {
56 QDate date = QDate::currentDate();
57 QString str = data( column, ok );
58 if (!str.isEmpty() ) {
59 ;// convert
60 }
61 return date;
62}
63QDate OSQLResultItem::dataToDate( int column, bool *ok ) {
64 QDate date = QDate::currentDate();
65 QString str = data( column, ok );
66 if (!str.isEmpty() ) {
67 ;// convert
68 }
69 return date;
70
71}
72QDateTime OSQLResultItem::dataToDateTime( const QString& column, bool *ok ) {
73 QDateTime time = QDateTime::currentDateTime();
74 return time;
75}
76QDateTime OSQLResultItem::dataToDateTime( int column, bool *ok ) {
77 QDateTime time = QDateTime::currentDateTime();
78 return time;
79}
80
81OSQLResult::OSQLResult( enum State state,
82 const OSQLResultItem::ValueList& list,
83 const OSQLError::ValueList& error )
84 : m_state( state ), m_list( list ), m_error( error )
85{
86
87}
88OSQLResult::~OSQLResult() {
89
90}
91OSQLResult::State OSQLResult::state()const {
92 return m_state;
93}
94void OSQLResult::setState( OSQLResult::State state ) {
95 m_state = state;
96}
97OSQLError::ValueList OSQLResult::errors()const {
98 return m_error;
99}
100void OSQLResult::setErrors( const OSQLError::ValueList& err ) {
101 m_error = err;
102}
103OSQLResultItem::ValueList OSQLResult::results()const {
104 return m_list;
105}
106void OSQLResult::setResults( const OSQLResultItem::ValueList& result ) {
107 m_list = result;
108}
109OSQLResultItem OSQLResult::first() {
110 it = m_list.begin();
111 return (*it);
112}
113OSQLResultItem OSQLResult::next(){
114 ++it;
115 return (*it);
116}
117bool OSQLResult::atEnd(){
118 if ( it == m_list.end() )
119 return true;
120
121 return false;
122}
123OSQLResultItem::ValueList::ConstIterator OSQLResult::iterator()const {
124 OSQLResultItem::ValueList::ConstIterator it;
125 it = m_list.begin();
126 return it;
127}