DumontEXE 0.0.1
cmcCursor.cpp
00001 /* ***************************************************************************
00002 **
00003 ** Copyright (C) 2007 Lorimark Solutions, LLC. All rights reserved.
00004 **
00005 ** This file is part of the DumontEXE Scripting Extension Kit
00006 **
00007 ** This file may be used under the terms of the GNU General Public
00008 ** License version 2.0 as published by the Free Software Foundation
00009 ** and appearing in the file LICENSE.GPL included in the packaging of
00010 ** this file.  Please review the following information to ensure GNU
00011 ** General Public Licensing requirements will be met:
00012 ** http://dumont.showoff-db.org/opensource.html
00013 **
00014 ** If you are unsure which license is appropriate for your use, please
00015 ** review the following information:
00016 ** http://dumont.showoff-db.org/licensing.html 
00017 ** or contact the sales department at sales@lorimarksolutions.com.
00018 **
00019 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00020 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00021 **
00022 ** author: Mark Petryk ~ Lorimark Solutions, LLC
00023 ** **************************************************************************/
00024 
00025 #include <QDate>
00026 
00027 #include "cmcApplication.h"
00028 #include "cmcCursor.h"
00029 #include "cmcRowSet.h"
00030 
00031 namespace cmcDatabaseApi {
00032 
00033 cmcCursor::cmcCursor( const cmcCursor & copy ):
00034   cmcApi( copy )
00035 {
00036 }
00037 
00038 cmcCursor::cmcCursor
00039 (
00040   const long             i_mode,
00041   const QString        & i_name,
00042   const long             i_flags,
00043         IDispatch      * i_dispatch,
00044         cmcApplication * i_application,
00045         QObject        * i_parent
00046 ):
00047   cmcApi( i_name, i_dispatch, i_application, i_parent ),
00048   m_mode(i_mode), 
00049   m_flags(i_flags)
00050 {
00051 //  TRACE_FUNCTION
00052 
00053   if( app() && 
00054       app()-> db() && 
00055       app()-> db()-> cursors()
00056     )
00057     app()-> db()-> cursors()-> add( this );
00058 
00059 }
00060 
00061 cmcCursor::~cmcCursor()
00062 {
00063 //  TRACE_FUNCTION
00064 }
00065 
00066 long cmcCursor::flags()
00067 {
00068   return( m_flags );
00069 }
00070 
00071 long cmcCursor::mode()
00072 {
00073   return( m_mode );
00074 }
00075 
00076 bool cmcCursor::useThids()
00077 {
00078   return( (flags() & 0x100) == 256 );
00079 }
00080 
00081 long cmcCursor::rowCount()
00082 {
00083   return( GetServerLong("RowCount") );
00084 }
00085 
00086 long cmcCursor::columnCount()
00087 {
00088   return( GetServerLong("ColumnCount") );
00089 }
00090 
00091 long cmcCursor::colCount()
00092 {
00093   return( columnCount() );
00094 }
00095 
00096 void cmcCursor::clearFilter( long filterNumber )
00097 {
00098   if( filterNumber == -1 )
00099   {
00100     for( int i=1; i<9; i++ )
00101     {
00102       clearFilter(i);
00103     }
00104      m_filterCache.clear();
00105      return;
00106   }
00107 
00108   setFilter( QString("[ViewFilter(%1,Clear)]").arg(filterNumber) );
00109 
00110 }
00111 
00112 bool cmcCursor::setFilter( const QString & filter, long flags )
00113 {
00114   QString filterString = filter;
00115 
00116   if( !filter.contains("ViewFilter", Qt::CaseInsensitive ) )
00117   {
00118     filterString = "[ViewFilter(" + filter + ")]";
00119   }
00120 
00121   bool retVal = SetServerString( "SetFilter", filterString, flags );
00122 
00123   if( !retVal )
00124   {
00125     err.set
00126     (
00127       1,
00128       QString("cursor('%1'): unable to set Filter: %2")
00129       .arg(categoryName())
00130       .arg(filterString)
00131     );
00132   }
00133   else
00134   {
00135     m_filterCache.append(filterString);
00136   }
00137 
00138 //  TRACE_MESSAGE( qPrintable("filter: " + filter) );
00139 
00140   return( retVal );
00141 
00142 }
00143 
00144 bool cmcCursor::filter
00145 (
00146   const QString & filterString,
00147   long flags
00148 )
00149 {
00150   return( setFilter( filterString, flags ) );
00151 }
00152 
00153 
00154 QString cmcCursor::filters( const QString & delimiter )
00155 {
00156   return( m_filterCache.join(delimiter) );
00157 }
00158 
00159 bool cmcCursor::setSort( const QString & sort, long flags )
00160 {
00161   VARIANTARG varg[2];
00162   ::VariantInit(&varg[0]);     // Initialize the VARIANT.
00163   ::VariantInit(&varg[1]);
00164 
00165   QString sortString = sort;
00166   if( !sortString.contains("ViewSort") )
00167        sortString = "[ViewSort(" + sort + ")]";
00168 
00169   BSTR bstrIn = ::SysAllocString((OLECHAR*)sortString.utf16());
00170 
00171   // load the variant
00172   varg[1].vt = VT_BSTR; varg[1].bstrVal = bstrIn;
00173   varg[0].vt = VT_I4;   varg[0].lVal    = flags;
00174 
00175   // Fill in the DISPPARAMS structure.
00176   DISPPARAMS param;
00177   param.cArgs             = 2;     // Number of arguments
00178   param.rgvarg            = varg;  // Arguments
00179   param.cNamedArgs        = 0;     // Number of named args
00180   param.rgdispidNamedArgs = NULL;  // Named arguments
00181 
00182   // Allocate a variant for the returned parameter.
00183   VARIANT varResult;
00184   ::VariantInit(&varResult);
00185 
00186   // Invoke the function.
00187   HRESULT hr = Invoke
00188   (
00189     "SetSort",
00190     IID_NULL,
00191     GetUserDefaultLCID(),
00192     DISPATCH_METHOD,
00193     &param,
00194     &varResult,
00195     NULL,
00196     NULL
00197   );
00198 
00199   ::SysFreeString(bstrIn);
00200 
00201   if( FAILED(hr) )
00202   {
00203 //    TROF( "csr::set failed hr=" + QString::number(hr,16) );
00204     return false;
00205   }
00206 
00207   // Display the returned string.
00208   if( varResult.vt == VT_BOOL )
00209   {
00210 //    TROF( "csr::set OK" );
00211     return varResult.boolVal;
00212   }
00213 
00214 //  TROF( "csr::set bad var type=" + QString::number(varResult.vt) );
00215   return false;
00216 
00217 }
00218 
00219 bool cmcCursor::setColumn( long column, const QString & fieldName, long flags )
00220 {
00221   /*
00222   ** Check the range of the column number provided.  If it's
00223   **  out of sequence then we can error with a message.  According
00224   **  to the Commence documentation you are suppose to set the
00225   **  columns in numerical order, and not skip a sequence or
00226   **  duplicate the same column.
00227   **
00228   */
00229   if( m_columnLabelCache.count() != column )
00230   {
00231     err.set
00232     (
00233       2,
00234       QString("cursor('%1'): you have added columns out of sequence.  column not added:")
00235       .arg(categoryName())
00236     );
00237     return( false );
00238   }
00239 
00240   /*
00241   ** Make sure this column name does not already exist in the cache
00242   **  of column names.
00243   **
00244   */
00245   if( int x = m_columnLabelCache.indexOf(fieldName) != -1 )
00246   {
00247     err.set
00248     (
00249       3,
00250       QString("cursor('%1').setColumn(%1,'%2') already defined on %3")
00251       .arg(categoryName())
00252       .arg(column)
00253       .arg(fieldName)
00254       .arg(x)
00255     );
00256     return( false );
00257   }
00258 
00259   VARIANTARG varg[3];
00260   ::VariantInit(&varg[0]);     // Initialize the VARIANT.
00261   ::VariantInit(&varg[1]);
00262   ::VariantInit(&varg[2]);
00263 
00264   // Convert the wide-character string to a BSTR.
00265   BSTR bstrIn = ::SysAllocString((OLECHAR*)fieldName.utf16());
00266 
00267   // load the variant
00268   varg[2].vt = VT_I4;   varg[2].lVal    = column;
00269   varg[1].vt = VT_BSTR; varg[1].bstrVal = bstrIn;
00270   varg[0].vt = VT_I4;   varg[0].lVal    = flags;
00271 
00272   // Fill in the DISPPARAMS structure.
00273   DISPPARAMS param;
00274   param.cArgs             = 3;     // Number of arguments
00275   param.rgvarg            = varg;  // Arguments
00276   param.cNamedArgs        = 0;     // Number of named args
00277   param.rgdispidNamedArgs = NULL;  // Named arguments
00278 
00279   // Allocate a variant for the returned parameter.
00280   VARIANT varResult;
00281   ::VariantInit(&varResult);
00282 
00283   // Invoke the function.
00284   HRESULT hr = Invoke
00285   (
00286     GetIDofName("SetColumn"),
00287     IID_NULL,
00288     GetUserDefaultLCID(),
00289     DISPATCH_METHOD,
00290     &param,
00291     &varResult,
00292     NULL,
00293     NULL
00294   );
00295 
00296   ::SysFreeString(bstrIn) ;
00297 
00298   if( FAILED(hr) )
00299   {
00300     err.set
00301     (
00302       4,
00303       QString("cursor('%1').setColumn(%1,'%2') failed hr=%3")
00304       .arg(categoryName())
00305       .arg(column)
00306       .arg(fieldName)
00307       .arg(hr)
00308     );
00309     return false;
00310   }
00311 
00312   // Display the returned string.
00313   if( varResult.vt == VT_BOOL )
00314   {
00315     if( varResult.boolVal ) 
00316     {
00317       m_columnLabelCache.append(fieldName);
00318     }
00319 //    TROF( "setColumn: OK" );
00320     return varResult.boolVal;
00321   }
00322 
00323   err.set
00324   (
00325     5,
00326     QString("cursor('%1').setColumn(%1,'%2') could not set label")
00327     .arg(categoryName())
00328     .arg(column)
00329     .arg(fieldName)
00330   );
00331 
00332 //  TROF( "setColumn: bad var type" );
00333   return false;
00334 }
00335 
00336 long cmcCursor::setColumn( const QString & fieldName, long flags )
00337 {
00338   /*
00339   ** Check to make sure this column doesn't already exist.  If it
00340   **  does then we'll just return that index value.  This prevents
00341   **  accidental duplicate-column references from occurring.  But
00342   **  it also does this without generating an error message.
00343   **
00344   */
00345   long retVal = m_columnLabelCache.indexOf(fieldName);
00346 
00347   /*
00348   ** A negative index value means the column does not exist.
00349   **
00350   */
00351   if( retVal < 0 )
00352   {
00353     /*
00354     ** Try to set the column label using the cache column count value
00355     **  and the name provided.  If successful, return the new column
00356     **  index position.
00357     **
00358     */
00359     if( setColumn( m_columnLabelCache.count(), fieldName, flags ) )
00360       retVal = m_columnLabelCache.indexOf(fieldName);
00361   }
00362 
00363   /*
00364   ** A -1 return value indicates we could not set the column
00365   **
00366   */
00367   return( retVal );
00368 
00369 } // endlong cmcCursor::setColumn( const QString & name, long flags )
00370 
00371 
00372 
00373 bool cmcCursor::setRelatedColumn
00374 (
00375   long column,
00376   const QString & connectionName,
00377   const QString & _categoryName,
00378   const QString & fieldName,
00379   long flags
00380 )
00381 {
00382   /*
00383   ** Check the range of the column number provided.  If it's
00384   **  out of sequence then we can error with a message.  According
00385   **  to the Commence documentation you are suppose to set the
00386   **  columns in numerical order, and not skip a sequence or
00387   **  duplicate the same column.
00388   **
00389   */
00390   if( m_columnLabelCache.count() != column )
00391   {
00392     err.set
00393     (
00394       6,
00395       QString("cursor('%1'): you have added columns out of sequence.  column not added:")
00396       .arg(categoryName())
00397     );
00398     return( false );
00399   }
00400 
00401   /*
00402   ** Assemble a name that looks just like a field name
00403   **
00404   */
00405   QString name = connectionName + " " + _categoryName + " " + fieldName;
00406 
00407   /*
00408   ** Make sure this column name does not already exist in the cache
00409   **  of column names.
00410   **
00411   */
00412   if( int x = m_columnLabelCache.indexOf(name) != -1 )
00413   {
00414     err.set
00415     (
00416       7,
00417       QString("cursor('%1').setColumn(%1,'%2') already defined on %3")
00418       .arg(categoryName())
00419       .arg(column)
00420       .arg(name)
00421       .arg(x)
00422     );
00423     return( false );
00424   }
00425 
00426   VARIANTARG varg[5];
00427   for( int i=0; i<5; i++ )
00428   ::VariantInit(&varg[i]);     // Initialize the VARIANT.
00429 
00430   BSTR bstrConName = ::SysAllocString((OLECHAR*)connectionName.utf16());
00431   BSTR bstrCatName = ::SysAllocString((OLECHAR*)_categoryName.utf16());
00432   BSTR bstrName    = ::SysAllocString((OLECHAR*)fieldName.utf16());
00433 
00434   // load the variant
00435   varg[4].vt = VT_I4;   varg[4].lVal    = column;
00436   varg[3].vt = VT_BSTR; varg[3].bstrVal = bstrConName;
00437   varg[2].vt = VT_BSTR; varg[2].bstrVal = bstrCatName;
00438   varg[1].vt = VT_BSTR; varg[1].bstrVal = bstrName;
00439   varg[0].vt = VT_I4;   varg[0].lVal    = flags;
00440 
00441   // Fill in the DISPPARAMS structure.
00442   DISPPARAMS param;
00443   param.cArgs             = 5;     // Number of arguments
00444   param.rgvarg            = varg;  // Arguments
00445   param.cNamedArgs        = 0;     // Number of named args
00446   param.rgdispidNamedArgs = NULL;  // Named arguments
00447 
00448   // Allocate a variant for the returned parameter.
00449   VARIANT varResult;
00450   ::VariantInit(&varResult);
00451 
00452   // Invoke the function.
00453   HRESULT hr = Invoke
00454   (
00455     GetIDofName("SetRelatedColumn"),
00456     IID_NULL,
00457     GetUserDefaultLCID(),
00458     DISPATCH_METHOD,
00459     &param,
00460     &varResult,
00461     NULL,
00462     NULL
00463   );
00464 
00465   ::SysFreeString(bstrConName);
00466   ::SysFreeString(bstrCatName);
00467   ::SysFreeString(bstrName);
00468 
00469   if( FAILED(hr) )
00470   {
00471     TRACE_MESSAGE( qPrintable("error setting related column '" + name + "'") )
00472 
00473     return false;
00474   }
00475 
00476   // Display the returned string.
00477   if( varResult.vt == VT_BOOL )
00478   {
00479     m_columnLabelCache.append(name);
00480 
00481     return varResult.boolVal;
00482   }
00483 
00484   TRACE_MESSAGE( qPrintable("could not set related column '" + name + "'") )
00485 
00486   return false;
00487 
00488 }
00489 
00490 bool cmcCursor::setColumn
00491 (
00492   long column,
00493   const QString & connectionName,
00494   const QString & targetCategoryName,
00495   const QString & fieldName,
00496   long flags
00497 )
00498 {
00499   if( fieldName == "" )
00500     return( setColumn( column, connectionName + " " + targetCategoryName, flags ) );
00501 
00502   return( setRelatedColumn( column, connectionName, targetCategoryName, fieldName, flags ) );
00503 }
00504 
00505 
00506 long cmcCursor::setRelatedColumn
00507 (
00508   const QString & connectionName,
00509   const QString & targetCategoryName,
00510   const QString & fieldName,
00511   long flags
00512 )
00513 {
00514   /*
00515   ** Try to set the column label using the cache column count value
00516   **  and the name provided.  If successful, return the new column
00517   **  count (minus 1 since this is a zero based index)
00518   **
00519   */
00520   if( setRelatedColumn( m_columnLabelCache.count(), connectionName, targetCategoryName, fieldName, flags ) )
00521     return( m_columnLabelCache.count()-1 );
00522 
00523   /*
00524   ** A -1 return value indicates we could not set the column
00525   **
00526   */
00527   return( -1 );
00528 
00529 }
00530 
00531 long cmcCursor::setColumn
00532 (
00533   const QString & connectionName,
00534   const QString & targetCategoryName,
00535   const QString & fieldName,
00536   long flags
00537 )
00538 {
00539   if( fieldName == "" )
00540     return( setColumn( connectionName + " " + targetCategoryName, flags ) );
00541 
00542   return( setRelatedColumn( connectionName, targetCategoryName, fieldName, flags ) );
00543 }
00544 
00545 long cmcCursor::getColumnIndex( const QString columnName, long flags )
00546 {
00547   return( m_columnLabelCache.indexOf(columnName) );
00548 }
00549 
00550 QString cmcCursor::getColumnLabel( long index, long flags )
00551 {
00552   return( m_columnLabelCache.value(index) );
00553 }
00554 
00555 QString cmcCursor::category()
00556 {
00557   return( GetServerString("Category") );
00558 }
00559 
00560 QString cmcCursor::categoryName()
00561 {
00562   return( category() );
00563 }
00564 
00565 cmcCategoryDef * cmcCursor::categoryDef()
00566 {
00567   if( !m_categoryDef )
00568        m_categoryDef = app()-> categoryDef( categoryName() );
00569 
00570   return( m_categoryDef );
00571 }
00572 bool cmcCursor::shared()
00573 {
00574   return( GetServerBool("Shared", DISPATCH_PROPERTYGET ) );
00575 }
00576 
00577 bool cmcCursor::setLogic( QString const & logic, long flags )
00578 {
00579   return( SetServerString( "SetLogic", logic, flags ) );
00580 }
00581 
00582 long cmcCursor::seekRow( long origin, long rows )
00583 {
00584   return( 0 );
00585 }
00586 
00587 long cmcCursor::seekRowApprox( long numerator, long denominator )
00588 {
00589   return( 0 );
00590 }
00591 bool cmcCursor::setActiveItem( const QString & categoryName, const QString & rowID, long flags )
00592 {
00593   return( false );
00594 }
00595 
00596 bool cmcCursor::setActiveDate( const QDate & date, long flags )
00597 {
00598   return( SetServerString( "SetActiveDate", date.toString("MM/dd/yy"), flags ) );
00599 }
00600 
00601 bool cmcCursor::setActiveDateRange( const QDate & startDate, const QDate & endDate, long flags )
00602 {
00603   return( false );
00604 }
00605 
00606 long cmcCursor::maxFieldSize()
00607 {
00608   return( GetServerLong("MaxFieldSize") );
00609 }
00610 
00611 long cmcCursor::maxRows()
00612 {
00613   return( GetServerLong("MaxRows") );
00614 }
00615 
00616 cmcCursor * cmcCursor::getRelatedCursor( const QString & connectionName, const QString parentKey )
00617 {
00618   return( NULL );
00619 }
00620 
00621 IDispatch * cmcCursor::getRowSet
00622 (
00623   const QString & rowSetType,
00624   long rows,
00625   long flags
00626 )
00627 {
00628   VARIANTARG varg[2];
00629   ::VariantInit(&varg[0]);     // Initialize the VARIANT.
00630   ::VariantInit(&varg[1]);
00631 
00632   // load the variant
00633   varg[1].vt = VT_I4; varg[1].lVal = rows;
00634   varg[0].vt = VT_I4; varg[0].lVal = flags;
00635 
00636   // Fill in the DISPPARAMS structure.
00637   DISPPARAMS param;
00638   param.cArgs             = 2;     // Number of arguments
00639   param.rgvarg            = varg;  // Arguments
00640   param.cNamedArgs        = 0;     // Number of named args
00641   param.rgdispidNamedArgs = NULL;  // Named arguments
00642 
00643   // Allocate a variant for the returned parameter.
00644   VARIANT varResult;
00645   ::VariantInit(&varResult);
00646 
00647   // Invoke the function.
00648   HRESULT hr = Invoke
00649   (
00650     GetIDofName(qPrintable(rowSetType)),
00651     IID_NULL,
00652     GetUserDefaultLCID(),
00653     DISPATCH_METHOD,
00654     &param,
00655     &varResult,
00656     NULL,
00657     NULL
00658   );
00659 
00660   if( FAILED(hr) )
00661   {
00662     qDebug( "failed(%lx)::cmcCursor::getRowSet %s %ld %ld", hr, qPrintable(rowSetType), rows, flags );
00663     return( NULL );
00664   }
00665 
00666   // Display the returned string.
00667   if( varResult.vt == VT_DISPATCH )
00668   {
00669     return( (IDispatch*) varResult.punkVal );
00670   }
00671 
00672   return( NULL );
00673 
00674 } // endIDispatch * cmcCursor::getRowSet( const QString & rowSetType, long rowCount, long flags )
00675 
00676 IDispatch * cmcCursor::getRowSet
00677 (
00678   const QString & rowSetType,
00679   const QString & id,
00680   long flags
00681 )
00682 {
00683   VARIANTARG varg[2];
00684   ::VariantInit(&varg[0]);     // Initialize the VARIANT.
00685   ::VariantInit(&varg[1]);
00686 
00687   BSTR bstrIn = ::SysAllocString((OLECHAR*)id.utf16());
00688 
00689   // load the variant
00690   varg[1].vt = VT_BSTR; varg[1].bstrVal = bstrIn;
00691   varg[0].vt = VT_I4;   varg[0].lVal    = flags;
00692 
00693   // Fill in the DISPPARAMS structure.
00694   DISPPARAMS param;
00695   param.cArgs             = 2;     // Number of arguments
00696   param.rgvarg            = varg;  // Arguments
00697   param.cNamedArgs        = 0;     // Number of named args
00698   param.rgdispidNamedArgs = NULL;  // Named arguments
00699 
00700   // Allocate a variant for the returned parameter.
00701   VARIANT varResult;
00702   ::VariantInit(&varResult);
00703 
00704   // Invoke the function.
00705   HRESULT hr = Invoke
00706   (
00707     GetIDofName(qPrintable(rowSetType)),
00708     IID_NULL,
00709     GetUserDefaultLCID(),
00710     DISPATCH_METHOD,
00711     &param,
00712     &varResult,
00713     NULL,
00714     NULL
00715   );
00716 
00717   if( FAILED(hr) )
00718   {
00719 
00720     return( NULL );
00721   }
00722 
00723   // Display the returned string.
00724   if( varResult.vt == VT_DISPATCH )
00725   {
00726     return( (IDispatch*) varResult.punkVal );
00727   }
00728 
00729   return( NULL );
00730 
00731 } // endIDispatch * cmcCursor::getRowSet( const QString & rowSetType, long rowCount, long flags )
00732 
00733 
00734 cmcRowSet * cmcCursor::getRowSet
00735 (
00736   long type,
00737   long rows,
00738   const QString & name,
00739   long flags
00740 )
00741 {
00742   cmcRowSet * retVal = NULL;
00743 
00744   /*
00745   ** If the rowCount is nothing then reset it to equal
00746   **  the number of rows in the cursor.  Also, if the
00747   **  caller has requested too many rows, then reset
00748   **  the rowCount to equal the number of rows in
00749   **  the cursor.
00750   **
00751   ** Note that requesting zero rows is valid.
00752   **
00753   */
00754   if( type != cmcRowSet::RowSetAdd )
00755   {
00756     if( rows < 0 ||
00757         rows > rowCount() )
00758         rows = rowCount();
00759   }
00760 
00761   /*
00762   ** See if we're able to acquire a dispatch pointer
00763   **
00764   */
00765   IDispatch * dispatch = getRowSet( "Get" + cmcRowSet::typeName(type) + "RowSet", rows, flags );
00766 
00767   /*
00768   ** If we got a dispatch pointer then we'll manufacture the rowset.
00769   **
00770   */
00771   if( dispatch )
00772   {
00773     /*
00774     ** If the name is also blank then reset it to equal
00775     **  the name of the category.
00776     **
00777     */
00778     QString rowSetName = name;
00779     if( rowSetName == "" )
00780         rowSetName = categoryName();
00781 
00782     /*
00783     ** Make the row set and link it up to everything.
00784     **
00785     */
00786     retVal = new cmcRowSet( rows, flags, rowSetName, type, this, dispatch );
00787 
00788     /*
00789     ** Copy the trace level
00790     **
00791     */
00792     retVal-> trace( trace() );
00793 
00794     /*
00795     ** Release the original dispatch pointer.
00796     **
00797     */
00798     dispatch-> Release();
00799 
00800   } // endif( dispatch )
00801 
00802   /*
00803   ** Return the wrapped pointer (assuming we got one).
00804   **
00805   */
00806   return( retVal );
00807 
00808 }
00809 
00810 cmcRowSet * cmcCursor::getRowSet
00811 (
00812   long type,
00813   const QString & id,
00814   const QString & name,
00815   long flags
00816 )
00817 {
00818   cmcRowSet * retVal = NULL;
00819 
00820   /*
00821   ** See if we're able to acquire a dispatch pointer
00822   **
00823   */
00824   IDispatch * dispatch = getRowSet( "Get" + cmcRowSet::typeName(type) + "RowSetByID", id, flags );
00825 
00826   /*
00827   ** If we got a dispatch pointer then we'll manufacture the rowset.
00828   **
00829   */
00830   if( dispatch )
00831   {
00832     /*
00833     ** If the name is also blank then reset it to equal
00834     **  the name of the category.
00835     **
00836     */
00837     QString rowSetName = name;
00838     if( rowSetName == "" )
00839         rowSetName = categoryName();
00840 
00841     /*
00842     ** Make the row set and link it up to everything.
00843     **
00844     */
00845     retVal = new cmcRowSet( 1, flags, rowSetName, type, this, dispatch );
00846 
00847     /*
00848     ** Copy the trace level
00849     **
00850     */
00851     retVal-> trace( trace() );
00852 
00853     /*
00854     ** Release the original dispatch pointer.
00855     **
00856     */
00857     dispatch-> Release();
00858 
00859   } // endif( dispatch )
00860 
00861   /*
00862   ** Return the wrapped pointer (assuming we got one).
00863   **
00864   */
00865   return( retVal );
00866 
00867 }
00868 
00869 
00870 cmcRowSet * cmcCursor::getQueryRowSet( long rowCount, long flags )
00871 {
00872   return( getRowSet( cmcRowSet::RowSetQuery, rowCount, name(), flags ) );
00873 }
00874 
00875 cmcRowSet * cmcCursor::getQueryRowSetByID( QString const & id, long flags )
00876 {
00877   return( getRowSet( cmcRowSet::RowSetQuery, id, name(), flags ) );
00878 }
00879 
00880 cmcRowSet * cmcCursor::getAddRowSet( long rowCount, long flags )
00881 {
00882   return( getRowSet( cmcRowSet::RowSetAdd, rowCount, name(), flags ) );
00883 }
00884 
00885 cmcRowSet * cmcCursor::getEditRowSet( long rowCount, long flags )
00886 {
00887   return( getRowSet( cmcRowSet::RowSetEdit, rowCount, name(), flags ) );
00888 }
00889 
00890 cmcRowSet * cmcCursor::getEditRowSetByID( QString const & id, long flags )
00891 {
00892   return( getRowSet( cmcRowSet::RowSetEdit, id, name(), flags ) );
00893 }
00894 
00895 cmcRowSet * cmcCursor::getDeleteRowSet( long rowCount, long flags )
00896 {
00897   return( getRowSet( cmcRowSet::RowSetDelete, rowCount, name(), flags ) );
00898 }
00899 
00900 cmcRowSet * cmcCursor::getDeleteRowSetByID( QString const & id, long flags )
00901 {
00902   return( getRowSet( cmcRowSet::RowSetDelete, id, name(), flags ) );
00903 }
00904 
00905 } // endnamespace cmcDatabaseApi
00906 
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties




~ ~ ~ ~ ~ ~
Source Code without Comments is like a Cranberry Garland
without the berries. Comment your Code!
 
Commence Database User Support Group Forum
http://newsgroup.showoff-db.org/
~ ~ ~ ~ ~ ~
Author: Mark Petryk
Lorimark Solutions, LLC
mark@lorimarksolutions.com