⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ifrowsetimpl.h

📁 GIS系统支持库Geospatial Data Abstraction Library代码.GDAL is a translator library for raster geospatial dat
💻 H
📖 第 1 页 / 共 2 页
字号:
/****************************************************************************** * $Id: IFRowsetImpl.h,v 1.2 2002/08/12 14:44:04 warmerda Exp $ * * Project:  OpenGIS Simple Features Reference Implementation * Purpose:  RowsetInterface implementation used for main features rowset. *           Only used by CSFRowsetImpl in SFRS.h. * Author:   Frank Warmerdam <warmerdam@pobox.com> * * This code is closely derived from the code in ATLDB.H for IRowsetImpl. * It basically modifies the CRowsetImpl to check overall status from * the row fetching mechanism (which comes from CVirtualArray).  This is * all based on the fact that we don't know the rowset size in advance, and * so must avoid calling CVirtualArray.GetSize(). * * Note: also contains some fixes mentioned in ICRRowsetImpl.h from which it * was directly derived. * ****************************************************************************** * Copyright (c) 2002, Frank Warmerdam * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. ****************************************************************************** * * $Log: IFRowsetImpl.h,v $ * Revision 1.2  2002/08/12 14:44:04  warmerda * cleanup * * Revision 1.1  2002/08/09 21:36:17  warmerda * New * * Revision 1.2  2002/02/05 20:42:46  warmerda * use CheckRows() in GetNextRows() to check availability * * Revision 1.1  2002/01/31 16:47:24  warmerda * New * */#ifndef _IFRowsetImpl_INCLUDED#define _IFRowsetImpl_INCLUDED// IFRowsetImpltemplate <class T, class RowsetInterface,	  class RowClass = CSimpleRow,	  class MapClass = CSimpleMap < RowClass::KeyType, RowClass* > >class ATL_NO_VTABLE IFRowsetImpl : public RowsetInterface{public:    typedef RowClass _HRowClass;    IFRowsetImpl()        {            m_iRowset = 0;            m_bCanScrollBack = false;            m_bCanFetchBack = false;            m_bReset = true;            m_bRemoveDeleted = true;            m_bIRowsetUpdate = false;        }    ~IFRowsetImpl()        {            for (int i = 0; i < m_rgRowHandles.GetSize(); i++)                delete (m_rgRowHandles.GetValueAt(i));        }    HRESULT RefRows(ULONG cRows, const HROW rghRows[], ULONG rgRefCounts[],                    DBROWSTATUS rgRowStatus[], BOOL bAdd)        {            ATLTRACE2(atlTraceDBProvider, 0, "IRowsetImpl::AddRefRows\n");            if (cRows == 0)                return S_OK;            if (rghRows == NULL)                return E_INVALIDARG;            T::ObjectLock cab((T*)this);            BOOL bSuccess1 = FALSE;            BOOL bFailed1 = FALSE;            DBROWSTATUS rs;            DWORD dwRef;            for (ULONG iRow = 0; iRow < cRows; iRow++)            {                HROW hRowCur = rghRows[iRow];                RowClass* pRow = m_rgRowHandles.Lookup((RowClass::KeyType)hRowCur);                if (pRow == NULL)                {                    ATLTRACE2(atlTraceDBProvider, 0, "Could not find HANDLE %x in list\n");                    rs = DBROWSTATUS_E_INVALID;                    dwRef = 0;                    bFailed1 = TRUE;                }                else                {                    if (bAdd)                        dwRef = pRow->AddRefRow();                    else                    {                        dwRef = pRow->ReleaseRow();                        if (dwRef == 0)                        {                            delete pRow;                            m_rgRowHandles.Remove((RowClass::KeyType)hRowCur);                        }                    }                    bSuccess1 = TRUE;                    rs = DBROWSTATUS_S_OK;                }                if (rgRefCounts)                    rgRefCounts[iRow] = dwRef;                if (rgRowStatus != NULL)                    rgRowStatus[iRow] = rs;            }            if (!bSuccess1 && !bFailed1)            {                ATLTRACE2(atlTraceDBProvider, 0, "IRowsetImpl::RefRows Unexpected state\n");                return E_FAIL;            }            HRESULT hr = S_OK;            if (bSuccess1 && bFailed1)                hr = DB_S_ERRORSOCCURRED;            if (!bSuccess1 && bFailed1)                hr = DB_E_ERRORSOCCURRED;            return hr;        }    STDMETHOD(AddRefRows)(ULONG cRows,                          const HROW rghRows[],                          ULONG rgRefCounts[],                          DBROWSTATUS rgRowStatus[])        {            ATLTRACE2(atlTraceDBProvider, 0, "IRowsetImpl::AddRefRows\n");            if (cRows == 0)                return S_OK;            return RefRows(cRows, rghRows, rgRefCounts, rgRowStatus, TRUE);        }    virtual DBSTATUS GetDBStatus(RowClass* poRC, ATLCOLUMNINFO*poColInfo,                                 void *pSrcData )        {            return DBSTATUS_S_OK;        }    OUT_OF_LINE HRESULT GetDataHelper(HACCESSOR hAccessor,                                      ATLCOLUMNINFO*& rpInfo,                                      void** ppBinding,                                      void*& rpSrcData,                                      ULONG& rcCols,                                      CComPtr<IDataConvert>& rspConvert,                                      RowClass* pRow)        {            HRESULT hr = S_OK;                    ATLASSERT(ppBinding != NULL);            T* pT = (T*) this;            *ppBinding = (void*)pT->m_rgBindings.Lookup((int)hAccessor);            if (*ppBinding == NULL)                return DB_E_BADACCESSORHANDLE;            rpSrcData = (void*)pT->m_rgRowData.GetRow(pRow->m_iRowset, hr);            if( rpSrcData == NULL )                return hr;            rpInfo = T::GetColumnInfo((T*)this, &rcCols);            rspConvert = pT->m_spConvert;            return S_OK;        }    STDMETHOD(GetData)(HROW hRow,                       HACCESSOR hAccessor,                       void *pDstData)        {            ATLTRACE2(atlTraceDBProvider, 0, "IRowsetImpl::GetData\n");            if (pDstData == NULL)                return E_INVALIDARG;            HRESULT hr = S_OK;            RowClass* pRow = (RowClass*)hRow;            if (hRow == NULL || (pRow = m_rgRowHandles.Lookup((RowClass::KeyType)hRow)) == NULL)                return DB_E_BADROWHANDLE;            T::_BindType* pBinding;            void* pSrcData;            ULONG cCols;            ATLCOLUMNINFO* pColInfo;            CComPtr<IDataConvert> spConvert;            hr = GetDataHelper(hAccessor, pColInfo, (void**)&pBinding, pSrcData, cCols, spConvert, pRow);            if (FAILED(hr) || hr != S_OK )                return hr;            for (ULONG iBind =0; iBind < pBinding->cBindings; iBind++)            {                DBBINDING* pBindCur = &(pBinding->pBindings[iBind]);                for (ULONG iColInfo = 0;                     iColInfo < cCols && pBindCur->iOrdinal != pColInfo[iColInfo].iOrdinal;                     iColInfo++);                if (iColInfo == cCols)                    return DB_E_BADORDINAL;                ATLCOLUMNINFO* pColCur = &(pColInfo[iColInfo]);                // Ordinal found at iColInfo                BOOL bProvOwn = pBindCur->dwMemOwner == DBMEMOWNER_PROVIDEROWNED;                bProvOwn;                DBSTATUS dbStat = GetDBStatus(pRow, pColCur, pSrcData);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -