List:Commits« Previous MessageNext Message »
From:pharvey Date:January 15 2006 4:55pm
Subject:Connector/ODBC 5 commit: r39 - in MYODBCRes: MYODBCResLib include
View as plain text  
Added:
   MYODBCRes/MYODBCResLib/MYODBCRes.cpp
   MYODBCRes/MYODBCResLib/MYODBCResDriver.cpp
   MYODBCRes/include/MYODBCResDriver.h
Log:
UNICODE:
- some new files for previous commit

Added: MYODBCRes/MYODBCResLib/MYODBCRes.cpp
===================================================================
--- MYODBCRes/MYODBCResLib/MYODBCRes.cpp	2006-01-15 16:51:23 UTC (rev 38)
+++ MYODBCRes/MYODBCResLib/MYODBCRes.cpp	2006-01-15 16:55:50 UTC (rev 39)
@@ -0,0 +1,97 @@
+
+/*!
+    \brief  Result handle.
+
+            The result set may be internally generated or generated on 
+            the server. The result may reside on the client side or the
+            server side. Results which reside on the client side may be 
+            managed by the mysql client library or by myodbc.
+
+            All of the above is hidden by MYODBC_RES_HANDLE.
+            However; one can assume certian things - for example;
+
+            A) Calling most info and catalog functions in myodbc will have
+            the effect of creating a result which is generated and managed
+            in myodbc. 
+
+            B) Calls to SQLExecute and SQLExecDirect will have the server
+            create the result. Where the result is managed (mysql client 
+            or server) is dictated by; DSN options, env/dbc/stm attributes.
+*/    
+
+#include "MYODBCResInternal.h"
+
+/*! 
+    \internal
+    \brief  Allocates, initializes and returns a new MYODBC_RES_HANDLE. 
+
+            The current position will be EOR.
+            
+    \param  hDia        Diagnostic handle to use for errors and warnings.
+                        This is likely to just be the diagnostic handle
+                        associated with an ODBC statement.
+    \param  pDesIRD     Descriptor describing the result set. This is
+                        likely to be the IRD of a statement.                            
+    \param  pMySQL      The current MySQL (connection) handle. This should
+                        be null if nMethod is MYODBC_RES_METHOD_INTERNAL.
+    \param  phRes       Pointer to a place where we can store the new handle.
+
+    \return SQLRETURN
+
+    \retval SQL_SUCCESS
+    \retval SQL_ERROR  
+
+    \sa     MYODBCResFree
+*/
+MYODBCRes::MYODBCRes( MYODBCDia *pdia, MYODBCDes *pdesIRD, MYSQL *pmysql )
+{
+    MYODBCDbgEnter();
+
+    Q_ASSERT( !pdia );
+    Q_ASSERT( !pdesIRD );
+
+    this->pdia      = pdia;
+    this->pdesIRD   = pdesIRD;
+    this->pmysql    = pmysql;
+
+    MYODBCDbgReturn2();
+}
+
+MYODBCRes::~MYODBCRes()
+{
+    MYODBCDbgEnter();
+
+    MYODBCDbgReturn2();
+}
+
+MYODBCDes * MYODBCRes::getDesIRD()
+{
+    MYODBCDbgEnter();
+
+    MYODBCDbgReturn3( "%p", pdesIRD );
+}
+
+bool MYODBCRes::isValidColumn( uint nColumn )
+{
+    bool b;
+
+    MYODBCDbgEnter();
+
+    b = ( nColumn <= (uint)pdesIRD->getCount() );
+
+    MYODBCDbgReturn3( "%d", b );
+}
+
+bool MYODBCRes::isValidRow()
+{
+    bool b;
+
+    MYODBCDbgEnter();
+
+    b = !isBOS() && !isEOS();
+
+    MYODBCDbgReturn3( "%d", b );
+}
+
+
+

Added: MYODBCRes/MYODBCResLib/MYODBCResDriver.cpp
===================================================================
--- MYODBCRes/MYODBCResLib/MYODBCResDriver.cpp	2006-01-15 16:51:23 UTC (rev 38)
+++ MYODBCRes/MYODBCResLib/MYODBCResDriver.cpp	2006-01-15 16:55:50 UTC (rev 39)
@@ -0,0 +1,256 @@
+#include "MYODBCResInternal.h"
+
+MYODBCResDriver::MYODBCResDriver( MYODBCDia *pdia, MYODBCDes *pdesIRD, MYSQL *pmysql )
+    : MYODBCRes( pdia, pdesIRD, pmysql )
+{
+    MYODBCDbgEnter();
+
+    nRow = 0;
+
+    MYODBCDbgReturn2();
+}
+
+MYODBCResDriver::~MYODBCResDriver()
+{
+    MYODBCDbgEnter();
+
+    MYODBCDbgReturn2();
+}
+
+SQLRETURN MYODBCResDriver::setData( uint nColumn, const QVariant &variantData )
+{
+    MYODBCDbgEnter();
+
+    Q_ASSERT( !isValidRow() );
+    Q_ASSERT( !isValidColumn( nColumn ) );
+
+    listResults[ nRow - 1 ][ nColumn ] = variantData;
+
+    MYODBCDbgReturn( SQL_SUCCESS );
+}
+
+SQLRETURN MYODBCResDriver::setRow( my_ulonglong nRow )
+{
+    MYODBCDbgEnter();
+
+    Q_ASSERT( !isValidRow( nRow ) );
+
+    this->nRow = nRow;
+
+    MYODBCDbgReturn( SQL_SUCCESS );
+}
+
+SQLRETURN MYODBCResDriver::getColumns( uint *pnColumns )
+{
+    MYODBCDbgEnter();
+
+    Q_ASSERT( !pnColumns );
+
+    *pnColumns = pdesIRD->getCount();
+
+    MYODBCDbgReturn( SQL_SUCCESS );
+}
+
+SQLRETURN MYODBCResDriver::getData( uint nColumn, QVariant &variantData )
+{
+    MYODBCDbgEnter();
+
+    Q_ASSERT( !isValidRow() );
+    Q_ASSERT( !isValidColumn( nColumn ) );
+
+    variantData = listResults.at( nRow - 1 ).at( nColumn );
+
+    MYODBCDbgReturn( SQL_SUCCESS );
+}
+
+SQLRETURN MYODBCResDriver::getRow( my_ulonglong *pnRow )
+{
+    MYODBCDbgEnter();
+
+    Q_ASSERT( !pnRow );
+
+    *pnRow = nRow;
+
+    MYODBCDbgReturn( SQL_SUCCESS );
+}
+
+SQLRETURN MYODBCResDriver::getRows( my_ulonglong *pnRows )
+{
+    MYODBCDbgEnter();
+
+    Q_ASSERT( !pnRow );
+
+    *pnRows = listResults.count();
+
+    MYODBCDbgReturn( SQL_SUCCESS );
+}
+
+SQLRETURN MYODBCResDriver::doAppend()
+{
+    MYODBCDbgEnter();
+
+    listResults.append( QVector<QVariant>( pdesIRD->getCount() ) );
+
+    MYODBCDbgReturn( SQL_SUCCESS );
+}
+
+SQLRETURN MYODBCResDriver::doClear()
+{
+    MYODBCDbgEnter();
+
+    listResults.clear();
+
+    MYODBCDbgReturn( SQL_SUCCESS );
+}
+
+SQLRETURN MYODBCResDriver::doDelete()
+{
+    MYODBCDbgEnter();
+
+    Q_ASSERT( !isValidRow() );
+
+    nRow--;
+    listResults.removeAt( nRow );
+
+    MYODBCDbgReturn( SQL_SUCCESS );
+}
+
+SQLRETURN MYODBCResDriver::doFirst()
+{
+    MYODBCDbgEnter();
+
+    if ( !listResults.count() )
+    {
+        nRow = 0;
+        MYODBCDbgReturn( SQL_NO_DATA );
+    }
+    nRow = 1;
+
+    MYODBCDbgReturn( SQL_SUCCESS );
+}
+
+SQLRETURN MYODBCResDriver::doInsert()
+{
+    MYODBCDbgEnter();
+
+    listResults.insert( nRow, QVector<QVariant>( pdesIRD->getCount() ) );
+
+    MYODBCDbgReturn( SQL_SUCCESS );
+}
+
+SQLRETURN MYODBCResDriver::doLast()
+{
+    MYODBCDbgEnter();
+
+    nRow = listResults.count();
+
+    MYODBCDbgReturn( SQL_SUCCESS );
+}
+
+SQLRETURN MYODBCResDriver::doNext()
+{
+    MYODBCDbgEnter();
+
+    /* wrap to beginning */
+    if ( isEOS() )
+        doBOS();
+
+    /* next */
+    nRow++;
+
+    if ( isEOS() )
+        MYODBCDbgReturn( SQL_NO_DATA );
+
+    MYODBCDbgReturn( SQL_SUCCESS );
+}
+
+SQLRETURN MYODBCResDriver::doPrev()
+{
+    MYODBCDbgEnter();
+
+    /* wrap to end */
+    if ( isBOS() )
+        doEOS();
+
+    /* prev */
+    nRow--;
+
+    if ( isBOS() )
+        MYODBCDbgReturn( SQL_NO_DATA );
+
+    MYODBCDbgReturn( SQL_SUCCESS );
+}
+
+SQLRETURN MYODBCResDriver::doSkip( my_ulonglong nRows )
+{
+    MYODBCDbgEnter();
+
+    Q_ASSERT( nRows == 0 );
+
+    if ( !isValidRow( nRow + nRows ) )
+    {
+        if ( nRows > 0 )
+            doEOS();
+        else
+            doBOS();
+        MYODBCDbgReturn( SQL_NO_DATA );
+    }
+
+    nRow += nRows;
+
+    MYODBCDbgReturn( SQL_SUCCESS );
+}
+
+bool MYODBCResDriver::isValidRow( my_ulonglong nRow )
+{
+    bool b;
+
+    MYODBCDbgEnter();
+
+    b = ( nRow > 0 && nRow <= listResults.count() );
+
+    MYODBCDbgReturn3( "%d", b );
+}
+
+bool MYODBCResDriver::isBOS()
+{
+    bool b;
+
+    MYODBCDbgEnter();
+
+    b = ( nRow < 1  );
+
+    MYODBCDbgReturn3( "%d", b );
+}
+
+bool MYODBCResDriver::isEOS()
+{
+    bool b;
+
+    MYODBCDbgEnter();
+
+    b = ( nRow > listResults.count() );
+
+    MYODBCDbgReturn3( "%d", b );
+}
+
+
+void MYODBCResDriver::doBOS()
+{
+    MYODBCDbgEnter();
+
+    nRow = 0;
+
+    MYODBCDbgReturn2();
+}
+
+void MYODBCResDriver::doEOS()
+{
+    MYODBCDbgEnter();
+
+    nRow = listResults.count() + 1;
+
+    MYODBCDbgReturn2();
+}
+
+

Added: MYODBCRes/include/MYODBCResDriver.h
===================================================================
--- MYODBCRes/include/MYODBCResDriver.h	2006-01-15 16:51:23 UTC (rev 38)
+++ MYODBCRes/include/MYODBCResDriver.h	2006-01-15 16:55:50 UTC (rev 39)
@@ -0,0 +1,44 @@
+#ifndef MYODBC_RES_DRIVER_H
+#define MYODBC_RES_DRIVER_H
+
+#include "MYODBCRes.h"
+
+class MYODBCResDriver : public MYODBCRes
+{
+public:
+    MYODBCResDriver( MYODBCDia *pdia, MYODBCDes *pdesIRD, MYSQL *pmysql );
+    virtual ~MYODBCResDriver();
+
+    virtual SQLRETURN setData( uint nColumn, const QVariant &variantData );
+    virtual SQLRETURN setRow( my_ulonglong nRow );
+
+    virtual SQLRETURN getColumns( uint *pnColumns );
+    virtual SQLRETURN getData( uint nColumn, QVariant &variantData );
+    virtual SQLRETURN getRow( my_ulonglong *pnRow );
+    virtual SQLRETURN getRows( my_ulonglong *pnRows );
+
+    virtual SQLRETURN doAppend();
+    virtual SQLRETURN doClear();
+    virtual SQLRETURN doDelete();
+    virtual SQLRETURN doFirst();
+    virtual SQLRETURN doInsert();
+    virtual SQLRETURN doLast();
+    virtual SQLRETURN doNext();
+    virtual SQLRETURN doPrev();
+    virtual SQLRETURN doSkip( my_ulonglong nRows );
+
+    virtual bool isValidRow( my_ulonglong nRow );
+    virtual bool isBOS();
+    virtual bool isEOS();
+
+protected:
+    void doBOS();
+    void doEOS();
+
+    /* Our result set is a list of rows. Each row is a vector of column data. Column data
is a QVariant. */
+    QList<QVector<QVariant>> listResults;
+    my_ulonglong nRow; /* 1 -based (0 as BOS) */
+};
+
+#endif
+

Thread
Connector/ODBC 5 commit: r39 - in MYODBCRes: MYODBCResLib includepharvey15 Jan