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) (side-by-side diff)
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 @@
+#ifndef OSQL_RESULT_H
+#define OSQL_RESULT_H
+
+#include <qdatetime.h>
+#include <qmap.h>
+#include <qvaluelist.h>
+
+
+#include "osqlerror.h"
+/**
+ * ResultItem represents one row of the resulting answer
+ */
+class OSQLResultItem {
+public:
+ typedef QValueList<OSQLResultItem> ValueList;
+ /**
+ * TableString is used to establish the relations
+ * between the column name and the real item
+ */
+ typedef QMap<QString, QString> TableString;
+
+ /**
+ * TableInt is used to establish a relation between a
+ * position of a column and the row value
+ */
+ typedef QMap<int, QString> TableInt;
+
+ /**
+ * Default c'tor. It has a TableString and a TableInt
+ */
+ OSQLResultItem(const TableString& = TableString(),
+ const TableInt& = TableInt() );
+ OSQLResultItem( const OSQLResultItem& );
+ ~OSQLResultItem();
+ OSQLResultItem &operator=( const OSQLResultItem& );
+ /**
+ * returns the TableString
+ */
+ TableString tableString()const;
+
+ /**
+ * returns the TableInt
+ */
+ TableInt tableInt() const;
+
+ /**
+ * retrieves the Data from columnName
+ *
+ */
+ QString data( const QString& columnName, bool *ok = 0);
+
+ /**
+ * QString for column number
+ */
+ QString data(int columnNumber, bool *ok = 0);
+
+ /**
+ * Date conversion from columnName
+ */
+ QDate dataToDate( const QString& columnName, bool *ok = 0 );
+
+ /**
+ * Date conversion from column-number
+ */
+ QDate dataToDate( int columnNumber, bool *ok = 0 );
+
+ QDateTime dataToDateTime( const QString& columName, bool *ok = 0 );
+ QDateTime dataToDateTime( int columnNumber, bool *ok = 0 );
+private:
+ TableString m_string;
+ TableInt m_int;
+};
+
+/**
+ * the OSQLResult
+ * either a SQL statement failed or succeeded
+ */
+class OSQLResult {
+public:
+ /** The State of a Result */
+ enum State{ Success = 0, Failure,Undefined };
+
+ /**
+ * default c'tor
+ * @param state The State of the Result
+ * @param r ResultItems
+ * @prarm errors the Errors a OSQLResult created
+ */
+ OSQLResult( enum State state = Undefined,
+ const OSQLResultItem::ValueList& r= OSQLResultItem::ValueList(),
+ const OSQLError::ValueList& errors = OSQLError::ValueList() );
+ ~OSQLResult();
+ State state()const;
+ OSQLError::ValueList errors()const;
+ OSQLResultItem::ValueList results()const;
+
+ void setState( enum State state );
+ void setErrors( const OSQLError::ValueList& error );
+ void setResults( const OSQLResultItem::ValueList& result );
+
+ OSQLResultItem first();
+ OSQLResultItem next();
+ bool atEnd();
+ OSQLResultItem::ValueList::ConstIterator iterator()const;
+private:
+ enum State m_state;
+ OSQLResultItem::ValueList m_list;
+ OSQLError::ValueList m_error;
+ OSQLResultItem::ValueList::Iterator it;
+};
+
+#endif