Tag: cws_src680_sqlite User: aklitzing Date: 2006/08/18 11:54:27 Modified: dba/connectivity/source/drivers/sqlite3/sqQueryPrepared.cpp dba/connectivity/source/drivers/sqlite3/sqQueryPrepared.h
Log: * Some bugs fixed * Cursor-Functions added * this->free() removed File Changes: Directory: /dba/connectivity/source/drivers/sqlite3/ ==================================================== File [changed]: sqQueryPrepared.cpp Url: http://dba.openoffice.org/source/browse/dba/connectivity/source/drivers/sqlite3/sqQueryPrepared.cpp?r1=1.1.2.1&r2=1.1.2.2 Delta lines: +34 -14 --------------------- --- sqQueryPrepared.cpp 16 Aug 2006 14:57:12 -0000 1.1.2.1 +++ sqQueryPrepared.cpp 18 Aug 2006 18:54:24 -0000 1.1.2.2 @@ -4,9 +4,9 @@ * * $RCSfile: sqQueryPrepared.cpp,v $ * - * $Revision: 1.1.2.1 $ + * $Revision: 1.1.2.2 $ * - * last change: $Author: aklitzing $ $Date: 2006/08/16 14:57:12 $ + * last change: $Author: aklitzing $ $Date: 2006/08/18 18:54:24 $ * * Original contributor: André Klitzing * @@ -46,8 +46,8 @@ sqQueryPrepared::sqQueryPrepared(int returnNo, const char* unusedStmt, sqlite3_stmt* stmt, sqDB* parent) : sqQuery(returnNo) , m_unusedStmt(unusedStmt) - , m_parent(parent) , m_stmt(stmt) + , m_parent(parent) , m_currentRow(-1) , m_done(false) , m_executed(false) @@ -75,19 +75,29 @@ return m_parent; } -// Only use sqDB->free(sqQuery) or this->free() to destroy this object. DO NOT use 'delete' yourself! -void sqQueryPrepared::free() -{ - m_parent->free(this); -} - -// ----------------------------------- CURSOR-Functions +// CURSOR-Functions +bool sqQueryPrepared::isBeforeFirst() +{ + return m_currentRow == -1; +} +bool sqQueryPrepared::isAfterLast() +{ + return m_done; +} +bool sqQueryPrepared::isFirst() +{ + return m_currentRow == 0; +} +bool sqQueryPrepared::isLast() +{ + return false; //!< \todo Needs to be implemented +} @@ -98,9 +108,18 @@ m_executed = true; if(!m_done) { - ++m_currentRow; + int ret = sqlite3_step(m_stmt); - m_done = (ret == SQLITE_DONE) ? true : false; + switch(ret) + { + case SQLITE_DONE: + m_done = true; + + case SQLITE_ROW: + ++m_currentRow; + break; + } + return ret; } return SQLITE_DONE; @@ -141,7 +160,7 @@ // reset the query - so you can iterator it again void sqQueryPrepared::reset() { - m_currentRow=0; + m_currentRow=-1; m_done=false; sqlite3_reset(m_stmt); } @@ -156,6 +175,7 @@ { return sqlite3_column_name(m_stmt, column); } + const char* sqQueryPrepared::getOriginName(int column) const { return sqlite3_column_origin_name(m_stmt, column); File [changed]: sqQueryPrepared.h Url: http://dba.openoffice.org/source/browse/dba/connectivity/source/drivers/sqlite3/sqQueryPrepared.h?r1=1.1.2.1&r2=1.1.2.2 Delta lines: +33 -13 --------------------- --- sqQueryPrepared.h 16 Aug 2006 14:57:12 -0000 1.1.2.1 +++ sqQueryPrepared.h 18 Aug 2006 18:54:24 -0000 1.1.2.2 @@ -4,9 +4,9 @@ * * $RCSfile: sqQueryPrepared.h,v $ * - * $Revision: 1.1.2.1 $ + * $Revision: 1.1.2.2 $ * - * last change: $Author: aklitzing $ $Date: 2006/08/16 14:57:12 $ + * last change: $Author: aklitzing $ $Date: 2006/08/18 18:54:24 $ * * Original contributor: André Klitzing * @@ -35,8 +35,8 @@ * ************************************************************************/ -#ifndef __SQLITE3s_SQQUERYPREPARE_H -#define __SQLITE3s_SQQUERYPREPARE_H +#ifndef __SQLITE3s_SQQUERYPREPARED_H +#define __SQLITE3s_SQQUERYPREPARED_H #include "sqQuery.h" class sqDB; // do not include sqDB.h - your compiler won't like recursive includes even with include-flags ;-) @@ -52,13 +52,15 @@ const char* m_unusedStmt; //!< if a part of the given statement of getQuery() wasn't used you can see it there, otherwise NULL sqlite3_stmt* m_stmt; //!< returned result table of this query sqDB* m_parent; //!< the parent-database of this query - long m_currentRow; //!< the current row of this query. reset() will set it to 0 and nextRow() will increment it - bool m_done; //!< true if there is no nextRow(), otherwise false - bool m_executed; //!< true if the query was executed, otherwise false sqQueryPrepared(const sqQueryPrepared &cpy); //!< Do NOT copy that object! sqQueryPrepared& operator= (const sqQueryPrepared &assign); //!< Do NOT assign that object! +protected: + long m_currentRow; //!< the current row of this query. reset() will set it to 0 and nextRow() will increment it + bool m_done; //!< true if there is no nextRow(), otherwise false + bool m_executed; //!< true if the query was executed, otherwise false + public: //! \fn sqQueryPrepared(int returnNo, const char* errorMsg, const char* unusedStmt, sqlite3_stmt* stmt) //! \brief constructor - initializes this object @@ -87,13 +89,30 @@ //! \return read-only pointer to sqDB-parent const sqDB* getParentDB() const; - //! \fn void free() - //! \brief deletes the object and will free every memory. It's just a wrapper to sqDB->free(sqQuery) - DO NOT use your pointer after this function. The object will be destroyed!! - //! \return nothing - void free(); + // CURSOR-Functions + //! \fn bool isBeforeFirst() + //! \brief check if the cursor is before the first row + //! \return true if the cursor is there, otherwise false + bool isBeforeFirst(); + + //! \fn bool isAfterLast() + //! \brief check if the cursor is after the last row + //! \return true if the cursor is there, otherwise false + bool isAfterLast(); + + //! \fn bool isFirst() + //! \brief check if the cursor is on the first row + //! \return true if the cursor is there, otherwise false + bool isFirst(); + + //! \fn bool isLast() + //! \brief check if the cursor is on the last row + //! \return true if the cursor is there, otherwise false + //! \todo this function isn't implemented at the moment. It will always return FALSE + bool isLast(); @@ -208,6 +227,7 @@ char const** out_DataType, char const** out_CollSeq, int* out_isNotNull, int* out_isPK, int* out_isAutoInc) const; + // CONTENT-Functions //! \fn const char* getText(int column) const @@ -241,4 +261,4 @@ bool isNull(int column) const; }; -#endif //__SQLITE3s_SQQUERYPREPARE_H +#endif //__SQLITE3s_SQQUERYPREPARED_H --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
