Modified:
MYSQLCC/MYSQLCCLib/MDescriptor.cpp
MYSQLCC/MYSQLCCLib/MDescriptorAPD.h
MYSQLCC/MYSQLCCLib/MDescriptorARD.h
MYSQLCC/MYSQLCCLib/MDescriptorIPD.h
MYSQLCC/MYSQLCCLib/MDescriptorIRD.h
MYSQLCC/MYSQLCCLib/MDescriptorRecord.cpp
MYSQLCC/include/MDescriptor.h
Log:
Modified: MYSQLCC/MYSQLCCLib/MDescriptor.cpp
===================================================================
--- MYSQLCC/MYSQLCCLib/MDescriptor.cpp 2006-04-26 22:45:13 UTC (rev 134)
+++ MYSQLCC/MYSQLCCLib/MDescriptor.cpp 2006-04-27 19:36:51 UTC (rev 135)
@@ -230,6 +230,8 @@
MDescriptor &MDescriptor::operator=( MDescriptor &descriptor )
{
+ MYODBCDbgEnter();
+
descriptor.doClear();
descriptor.nArraySize = nArraySize;
descriptor.nBindType = nBindType;
@@ -237,11 +239,16 @@
descriptor.pnBindOffsetPtr = pnBindOffsetPtr;
descriptor.pnRowsProcessedPtr = pnRowsProcessedPtr;
- QVectorIterator<MDescriptorRecord*> i( vectorRecords );
- while ( i.hasNext() )
+ QObjectList listChildren = children();
+ QList<QObject>::iterator i;
+ for ( i = listChildren.begin(); i != listChildren.end(); ++i )
{
- MDescriptorRecord *pDescriptorRecord = i.next();
- descriptor.doAppend( pDescriptorRecord );
+// We assume, for the sake of performance, that all children are MDescriptorRecord based.
+// if ( i->inherits( "MDescriptorRecord" ) )
+ {
+ MDescriptorRecord *pDescriptorRecord = descriptor.doAppend();
+ *pDescriptorRecord = *((MDescriptorRecord*)pObject);
+ }
}
MYODBCDbgReturn3( "%p", *this );
@@ -322,14 +329,15 @@
/* truncate */
{
- QMutableVectorIterator<MDescriptorRecord*> i( vectorRecords );
+ QList<MDescriptorRecord*> listRecords =
findChildren<MDescriptorRecord*>();
+ QMutableListIterator<MDescriptorRecord*> i( listRecords );
i.toBack();
while ( getCount() > nCount && i.hasPrevious() )
{
MDescriptorRecord *pDescriptorRecord = i.previous();
- /* do not delete bound records */
- if ( pDescriptorRecord->getDataPtr() && !bUnbind )
+ /* do not delete bound records? */
+ if ( pDescriptorRecord->isBound() && !bUnbind )
break;
i.remove();
@@ -396,7 +404,11 @@
0 is returned if only the bookmark record exists (this makes the bookmark
record something of a hidden record).
*/
- MYODBCDbgReturn3( "%d", (vectorRecords.count() - 1) );
+
+// We assume, for the sake of performance, that all children are MDescriptorRecord based.
+// QList<MDescriptorRecord*> listRecords =
findChildren<MDescriptorRecord*>();
+
+ MYODBCDbgReturn3( "%d", (children.count() - 1) );
}
SQLUINTEGER *MDescriptor::getRowsProcessedPtr()
@@ -406,55 +418,42 @@
MYODBCDbgReturn3( "%p", pnRowsProcessedPtr );
}
-MYODBCDesRec *MDescriptor::getRec( unsigned int nRec )
-{
- MYODBCDbgEnter();
+/*!
+ \brief Create, and return, a new descriptor record.
- Q_ASSERT( nRec >= vectorRecords.count() );
+ The descriptor record is created as a child of <B>this<\B>. So it
+ has a parent and the parent will manage its existence including
+ deleting it when parent is deleted.
- MYODBCDbgReturn3( "%p", vectorRecords[nRec] );
-}
-
-SQLHANDLE MDescriptor::getOwner()
+ Classes derived from MDescriptor will want to replace this method
+ so as to create the type of child record it needs. Some
+ methods in MDescriptor rely on this.
+*/
+MDescriptorRecord * MDescriptor::doAppend()
{
MYODBCDbgEnter();
- MYODBCDbgReturn3( "%p", hOwner );
-}
+ MDescriptorRecord *pDescriptorRecord = new MDescriptorRecord( this );
-MYODBCDia *MDescriptor::getDia()
-{
- MYODBCDbgEnter();
-
- MYODBCDbgReturn3( "%p", pdia );
+ MYODBCDbgReturn3( "%p", pnRowsProcessedPtr );
}
-SQLRETURN MDescriptor::doAppend( SQLSMALLINT nConciseType, const QString &stringName,
SQLSMALLINT nNullable, SQLSMALLINT nUnsigned )
-{
- MYODBCDbgEnter();
-
- MYODBCDesRec * pdesrec = doAppend();
- SQLRETURN nReturn = pdesrec->setDefault( nConciseType );
-
- pdesrec->setName( stringName );
- pdesrec->setNullable( nNullable );
- pdesrec->setUnsigned( nUnsigned );
-
- MYODBCDbgReturn( nReturn );
-}
-
void MDescriptor::doClear()
{
MYODBCDbgEnter();
/* delete records */
- QMutableVectorIterator<MYODBCDesRec*> i( vectorRecords );
+ /*! \todo double check that this is deleting objects not just removing from list */
+ children().clear();
+/*
+ QMutableVectorIterator<MDescriptorRecord*> i( children() );
while ( i.hasNext() )
{
- MYODBCDesRec *pdesrec = i.next();
+ MDescriptorRecord *pdesrec = i.next();
delete pdesrec;
i.remove();
}
+*/
/* reinit header fields */
doInit();
@@ -463,31 +462,6 @@
MYODBCDbgReturn2();
}
-int MDescriptor::doTruncateUnboundRecords()
-{
- MYODBCDbgEnter();
-
- int nRecordsDeleted = 0;
-
- /* process from eof to bof, delete records which are unbound, stop at first bound
record */
- QMutableVectorIterator<MYODBCDesRec*> i( vectorRecords );
- i.toBack();
- while ( i.hasPrevious() )
- {
- MYODBCDesRec *pdesrec = i.previous();
-
- /* do not delete bound records */
- if ( pdesrec->isBound() )
- break;
-
- i.remove();
- delete pdesrec;
- nRecordsDeleted++;
- }
-
- MYODBCDbgReturn3( "%d", nRecordsDeleted );
-}
-
void MDescriptor::doAppendBookmark()
{
MYODBCDbgEnter();
@@ -502,25 +476,14 @@
or by an ODBC 2.x application working with an ODBC 3.x
driver.)
*/
- MYODBCDesRec *pdesrec = doAppend();
- pdesrec->setConciseType( SQL_BINARY );
- pdesrec->setType( SQL_BINARY );
- pdesrec->setDatetimeIntervalCode( 0 );
+ MDescriptorRecord *pDescriptorRecord = doAppend();
+ pDescriptorRecord->setConciseType( SQL_BINARY );
+ pDescriptorRecord->setType( SQL_BINARY );
+ pDescriptorRecord->setDatetimeIntervalCode( 0 );
MYODBCDbgReturn2();
}
-void MDescriptor::doAppend( MYODBCDesRec *pdesrec )
-{
- MYODBCDbgEnter();
-
- MYODBCDesRec *p = doAppend();
-
- *p = *pdesrec;
-
- MYODBCDbgReturn2();
-}
-
void MDescriptor::doInit()
{
nArraySize = 1;
Modified: MYSQLCC/MYSQLCCLib/MDescriptorAPD.h
===================================================================
--- MYSQLCC/MYSQLCCLib/MDescriptorAPD.h 2006-04-26 22:45:13 UTC (rev 134)
+++ MYSQLCC/MYSQLCCLib/MDescriptorAPD.h 2006-04-27 19:36:51 UTC (rev 135)
@@ -29,7 +29,8 @@
/* getters */
- /* do'ers */
+ /* doers */
+ MDescriptorRecord * doAppend();
};
#endif
Modified: MYSQLCC/MYSQLCCLib/MDescriptorARD.h
===================================================================
--- MYSQLCC/MYSQLCCLib/MDescriptorARD.h 2006-04-26 22:45:13 UTC (rev 134)
+++ MYSQLCC/MYSQLCCLib/MDescriptorARD.h 2006-04-27 19:36:51 UTC (rev 135)
@@ -23,7 +23,8 @@
/* getters */
- /* do'ers */
+ /* doers */
+ MDescriptorRecord * doAppend();
};
#endif
Modified: MYSQLCC/MYSQLCCLib/MDescriptorIPD.h
===================================================================
--- MYSQLCC/MYSQLCCLib/MDescriptorIPD.h 2006-04-26 22:45:13 UTC (rev 134)
+++ MYSQLCC/MYSQLCCLib/MDescriptorIPD.h 2006-04-27 19:36:51 UTC (rev 135)
@@ -22,7 +22,8 @@
/* getters */
- /* do'ers */
+ /* doers */
+ MDescriptorRecord * doAppend();
};
#endif
Modified: MYSQLCC/MYSQLCCLib/MDescriptorIRD.h
===================================================================
--- MYSQLCC/MYSQLCCLib/MDescriptorIRD.h 2006-04-26 22:45:13 UTC (rev 134)
+++ MYSQLCC/MYSQLCCLib/MDescriptorIRD.h 2006-04-27 19:36:51 UTC (rev 135)
@@ -22,7 +22,8 @@
/* getters */
- /* do'ers */
+ /* doers */
+ MDescriptorRecord * doAppend();
};
#endif
Modified: MYSQLCC/MYSQLCCLib/MDescriptorRecord.cpp
===================================================================
--- MYSQLCC/MYSQLCCLib/MDescriptorRecord.cpp 2006-04-26 22:45:13 UTC (rev 134)
+++ MYSQLCC/MYSQLCCLib/MDescriptorRecord.cpp 2006-04-27 19:36:51 UTC (rev 135)
@@ -975,43 +975,45 @@
MYODBCDbgReturn3( "%d", ( pDataPtr ? true : false ) );
}
-MYODBCDesRec &MYODBCDesRec::operator=( MYODBCDesRec &desrec )
+MDescriptorRecord &MDescriptorRecord::operator=( MDescriptorRecord
&descriptorrecord )
{
- desrec.nAutoUniqueValue = nAutoUniqueValue;
- desrec.nCaseSensitive = nCaseSensitive;
- desrec.nConciseType = nConciseType;
- desrec.nDatetimeIntervalCode = nDatetimeIntervalCode;
- desrec.nDatetimeIntervalPrecision = nDatetimeIntervalPrecision;
- desrec.nDisplaySize = nDisplaySize;
- desrec.nFixedPrecScale = nFixedPrecScale;
- desrec.nLength = nLength;
- desrec.nNullable = nNullable;
- desrec.nNumPrecRadix = nNumPrecRadix;
- desrec.nOctetLength = nOctetLength;
- desrec.nParamterType = nParamterType;
- desrec.nPrecision = nPrecision;
- desrec.nRowver = nRowver;
- desrec.nScale = nScale;
- desrec.nSearchable = nSearchable;
- desrec.nType = nType;
- desrec.nUnnamed = nUnnamed;
- desrec.nUnsigned = nUnsigned;
- desrec.nUpdatable = nUpdatable;
- desrec.pDataPtr = pDataPtr;
- desrec.pnIndicatorPtr = pnIndicatorPtr;
- desrec.pnOctetLengthPtr = pnOctetLengthPtr;
- desrec.stringBaseColumnName = stringBaseColumnName;
- desrec.stringBaseTableName = stringBaseTableName;
- desrec.stringCatalogName = stringCatalogName;
- desrec.stringLabel = stringLabel;
- desrec.stringLiteralPrefix = stringLiteralPrefix;
- desrec.stringLiteralSuffix = stringLiteralSuffix;
- desrec.stringLocalTypeName = stringLocalTypeName;
- desrec.stringName = stringName;
- desrec.stringSchemaName = stringSchemaName;
- desrec.stringTableName = stringTableName;
- desrec.stringTypeName = stringTypeName;
+ MYODBCDbgEnter();
+ descriptorrecord.nAutoUniqueValue = nAutoUniqueValue;
+ descriptorrecord.nCaseSensitive = nCaseSensitive;
+ descriptorrecord.nConciseType = nConciseType;
+ descriptorrecord.nDatetimeIntervalCode = nDatetimeIntervalCode;
+ descriptorrecord.nDatetimeIntervalPrecision = nDatetimeIntervalPrecision;
+ descriptorrecord.nDisplaySize = nDisplaySize;
+ descriptorrecord.nFixedPrecScale = nFixedPrecScale;
+ descriptorrecord.nLength = nLength;
+ descriptorrecord.nNullable = nNullable;
+ descriptorrecord.nNumPrecRadix = nNumPrecRadix;
+ descriptorrecord.nOctetLength = nOctetLength;
+ descriptorrecord.nParamterType = nParamterType;
+ descriptorrecord.nPrecision = nPrecision;
+ descriptorrecord.nRowver = nRowver;
+ descriptorrecord.nScale = nScale;
+ descriptorrecord.nSearchable = nSearchable;
+ descriptorrecord.nType = nType;
+ descriptorrecord.nUnnamed = nUnnamed;
+ descriptorrecord.nUnsigned = nUnsigned;
+ descriptorrecord.nUpdatable = nUpdatable;
+ descriptorrecord.pDataPtr = pDataPtr;
+ descriptorrecord.pnIndicatorPtr = pnIndicatorPtr;
+ descriptorrecord.pnOctetLengthPtr = pnOctetLengthPtr;
+ descriptorrecord.stringBaseColumnName = stringBaseColumnName;
+ descriptorrecord.stringBaseTableName = stringBaseTableName;
+ descriptorrecord.stringCatalogName = stringCatalogName;
+ descriptorrecord.stringLabel = stringLabel;
+ descriptorrecord.stringLiteralPrefix = stringLiteralPrefix;
+ descriptorrecord.stringLiteralSuffix = stringLiteralSuffix;
+ descriptorrecord.stringLocalTypeName = stringLocalTypeName;
+ descriptorrecord.stringName = stringName;
+ descriptorrecord.stringSchemaName = stringSchemaName;
+ descriptorrecord.stringTableName = stringTableName;
+ descriptorrecord.stringTypeName = stringTypeName;
+
MYODBCDbgReturn3( "%p", *this );
}
Modified: MYSQLCC/include/MDescriptor.h
===================================================================
--- MYSQLCC/include/MDescriptor.h 2006-04-26 22:45:13 UTC (rev 134)
+++ MYSQLCC/include/MDescriptor.h 2006-04-27 19:36:51 UTC (rev 135)
@@ -25,6 +25,12 @@
downgraded when no longer associated with a MStatement
(\sa SQLSetStmtAttr).
+ A descriptor has 0-n descriptor records (\sa MDescriptorRecord).
+ Descriptor records are maintained as child objects of the descriptor.
+
+ It is <B>imperative<\B> that *all* child objects are (or are
derived from)
+ MDescriptorRecord.
+
\sa MDescriptor
*/
class MDescriptor : public QObject
@@ -48,7 +54,7 @@
virtual SQLRETURN getDiagRec( SQLSMALLINT nRecNumber, SQLWCHAR *psSQLState,
SQLINTEGER *pnNativeErrorPtr, SQLWCHAR *psMessageText, SQLSMALLINT nBufferLength,
SQLSMALLINT *pnTextLengthPtr );
/* operators */
- virtual MDescriptor &operator=( MDescriptor &des );
+ virtual MDescriptor &operator=( MDescriptor &descriptor );
protected:
@@ -69,6 +75,9 @@
virtual SQLSMALLINT getCount();
virtual SQLUINTEGER * getRowsProcessedPtr();
+ /* doers */
+ MDescriptorRecord * doAppend();
+
private:
MDiagnostic diagnostic; /*!< our diagnostic information */
| Thread |
|---|
| • Connector/ODBC 5 commit: r135 - in MYSQLCC: MYSQLCCLib include | pharvey | 27 Apr |