author | eilers <eilers> | 2004-08-29 12:42:03 (UTC) |
---|---|---|
committer | eilers <eilers> | 2004-08-29 12:42:03 (UTC) |
commit | dd159675e6e3c361bc20eaa6994265e73b6599ef (patch) (side-by-side diff) | |
tree | 70cf91b669307ae39e020ce4257b60b2de9acd42 /libopie2/opiedb | |
parent | 496157cb35b8f90e73770fc43c9a63534baebf33 (diff) | |
download | opie-dd159675e6e3c361bc20eaa6994265e73b6599ef.zip opie-dd159675e6e3c361bc20eaa6994265e73b6599ef.tar.gz opie-dd159675e6e3c361bc20eaa6994265e73b6599ef.tar.bz2 |
Minor but important changes in API. Improved SQL performance: contactsbackend now
supports look-ahead caching to speed up access.
Fixed and improved look-ahead cache in todo-backend.
Datebook backend will follow, soon !
-rw-r--r-- | libopie2/opiedb/osqlresult.cpp | 8 | ||||
-rw-r--r-- | libopie2/opiedb/osqlresult.h | 4 |
2 files changed, 6 insertions, 6 deletions
diff --git a/libopie2/opiedb/osqlresult.cpp b/libopie2/opiedb/osqlresult.cpp index bad7d8b..268ac8e 100644 --- a/libopie2/opiedb/osqlresult.cpp +++ b/libopie2/opiedb/osqlresult.cpp @@ -1,128 +1,128 @@ #include "osqlresult.h" using namespace Opie::DB; OSQLResultItem::OSQLResultItem( const TableString& string, const TableInt& Int) : m_string( string ), m_int( Int ) { } OSQLResultItem::~OSQLResultItem() { } OSQLResultItem::OSQLResultItem( const OSQLResultItem& item) { *this = item; } OSQLResultItem &OSQLResultItem::operator=( const OSQLResultItem& other) { m_string = other.m_string; m_int = other.m_int; return *this; } OSQLResultItem::TableString OSQLResultItem::tableString()const{ return m_string; } OSQLResultItem::TableInt OSQLResultItem::tableInt()const { return m_int; } -QString OSQLResultItem::data( const QString& columnName, bool *ok ) { - TableString::Iterator it = m_string.find( columnName ); +QString OSQLResultItem::data( const QString& columnName, bool *ok ) const { + TableString::ConstIterator it = m_string.find( columnName ); /* if found */ if ( it != m_string.end() ) { if ( ok ) *ok = true; return it.data(); }else{ if ( ok ) *ok = false; return QString::null; } } -QString OSQLResultItem::data( int column, bool *ok ) { - TableInt::Iterator it = m_int.find( column ); +QString OSQLResultItem::data( int column, bool *ok ) const { + TableInt::ConstIterator it = m_int.find( column ); /* if found */ if ( it != m_int.end() ) { if ( ok ) *ok = true; return it.data(); }else{ if ( ok ) *ok = false; return QString::null; } } /* * DateFormat is 'YYYY-MM-DD' */ QDate OSQLResultItem::dataToDate( const QString& column, bool *ok ) { QDate date = QDate::currentDate(); QString str = data( column, ok ); if (!str.isEmpty() ) { ;// convert } return date; } QDate OSQLResultItem::dataToDate( int column, bool *ok ) { QDate date = QDate::currentDate(); QString str = data( column, ok ); if (!str.isEmpty() ) { ;// convert } return date; } QDateTime OSQLResultItem::dataToDateTime( const QString& column, bool *ok ) { QDateTime time = QDateTime::currentDateTime(); return time; } QDateTime OSQLResultItem::dataToDateTime( int column, bool *ok ) { QDateTime time = QDateTime::currentDateTime(); return time; } OSQLResult::OSQLResult( enum State state, const OSQLResultItem::ValueList& list, const OSQLError::ValueList& error ) : m_state( state ), m_list( list ), m_error( error ) { } OSQLResult::~OSQLResult() { } OSQLResult::State OSQLResult::state()const { return m_state; } void OSQLResult::setState( OSQLResult::State state ) { m_state = state; } OSQLError::ValueList OSQLResult::errors()const { return m_error; } void OSQLResult::setErrors( const OSQLError::ValueList& err ) { m_error = err; } OSQLResultItem::ValueList OSQLResult::results()const { return m_list; } void OSQLResult::setResults( const OSQLResultItem::ValueList& result ) { m_list = result; } OSQLResultItem OSQLResult::first() { it = m_list.begin(); return (*it); } OSQLResultItem OSQLResult::next(){ ++it; return (*it); } bool OSQLResult::atEnd(){ if ( it == m_list.end() ) return true; return false; } OSQLResultItem::ValueList::ConstIterator OSQLResult::iterator()const { OSQLResultItem::ValueList::ConstIterator it; it = m_list.begin(); return it; } diff --git a/libopie2/opiedb/osqlresult.h b/libopie2/opiedb/osqlresult.h index fc6f01a..92b65a0 100644 --- a/libopie2/opiedb/osqlresult.h +++ b/libopie2/opiedb/osqlresult.h @@ -1,120 +1,120 @@ #ifndef OSQL_RESULT_H #define OSQL_RESULT_H #include <qdatetime.h> #include <qmap.h> #include <qvaluelist.h> #include "osqlerror.h" namespace Opie { namespace DB { /** * 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 data( const QString& columnName, bool *ok = 0) const; /** * QString for column number */ - QString data(int columnNumber, bool *ok = 0); + QString data(int columnNumber, bool *ok = 0) const; /** * 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; class Private; Private *d; }; } } #endif |