//--------------------------------------------------------------------
// Microsoft OLE DB Sample Provider
// (C) Copyright 1994 - 1996 Microsoft Corporation. All Rights Reserved.
//
// @doc
//
// @module ROWSET.H | CRowset base object and contained interface
// definitions
//
//
#ifndef _ROWSET_H_
#define _ROWSET_H_
#include "fileio.h"
#include "bitarray.h"
#include "extbuff.h"
#include "hashtbl.h"
#include "dbsess.h"
// Forward declarations ------------------------------------------------------
class CImpIRowset;
class CImpIRowsetChange;
class CImpIColumnsInfo;
class CImpIAccessor;
class CImpIRowsetInfo;
typedef CImpIRowset*PIMPIROWSET;
typedef CImpIRowsetChange*PIMPIROWSETCHANGE;
typedef CImpIColumnsInfo*PIMPICOLUMNSINFO;
typedef CImpIAccessor *PIMPIACCESSOR;
typedef CImpIRowsetInfo*PIMPIROWSETINFO;
// General Helper Function
HRESULT GetInternalTypeFromCSVType(SWORD swDataType, BOOL fIsSigned, DWORD* pdwdbType);
// Classes -------------------------------------------------------------------
//----------------------------------------------------------------------------
// @class CRowset | Rowset object. Containing class for all interfaces on the Rowset
// Object
//
class CRowset : public IUnknown//@base public | IUnknown
{
//Contained interfaces are friends
friend class CImpIColumnsInfo;
friend class CImpIRowset;
friend class CImpIRowsetChange;
friend class CImpIAccessor;
friend class CImpIRowsetInfo;
private: //@access private
//@cmember Builds DBCOLINFO structures
HRESULT GatherColumnInfo(void);
//@cmember Creates Helper Classes
HRESULT CreateHelperFunctions(void);
//@cmember Returns the Buffer Pointer for the specified row
ROWBUFF* GetRowBuff(ULONG iRow);
//@cmember Establishes the data area bindings
HRESULT Rebind(BYTE* pBase);
protected: //@access protected
//@cmember File Manipulation Class
CFileIO*m_pFileio;
//@cmember Count of Columns in Result Set
ULONGm_cCols;
//@cmember Pointer to Info Array Heap (heap of column name strings)
BYTE*m_pbHeap;
//@cmember ColumnInfo array
DBCOLUMNINFO*m_rgdbcolinfo;
//@cmember how many bytes of the column names heap is in use
ULONG m_cbHeapUsed;
//@cmember column offsets in SampProv's buffer
ULONG*m_rgdwDataOffsets;
//@cmember if type is signed
BOOL*m_rgfIsSigned;
//@cmember length of buffer slots for column data
SDWORD*m_rgcbLen;
//@cmember array of accessor ptrs
LPEXTBUFFER m_pextbufferAccessor;
//@cmember internal buffer structure
PLSTSLOT m_pIBuffer;
//@cmember bit array to mark active rows
LPBITARRAYm_prowbitsIBuffer;
//@cmember size of row in the buffer
ULONG m_cbRowSize;
//@cmember points to the first buffered row
BYTE*m_rgbRowData;
//@cmember index of the first available rowbuffer
ULONG m_irowMin;
//@cmember current # of rows in the buffer
ULONG m_cRows;
//@cmember position in the resultset
ULONG m_irowFilePos;
//@cmember Start of the rowset
ULONGm_irowLastFilePos;
//@cmember status word for the entire cursor
UDWORD m_dwStatus;
//@cmember remember last binding location
BYTE*m_pLastBindBase;
//@cmember RefCount of all outstanding row handles
ULONG m_ulRowRefCount;
//@member Utility object to manage properties
PCUTILPROP m_pUtilProp;
// Interface and OLE Variables
//@cmember Reference count
ULONGm_cRef;
//@cmember Controlling IUnknown
LPUNKNOWNm_pUnkOuter;
//@cmember Contained IColumnsInfo
PIMPICOLUMNSINFOm_pIColumnsInfo;
//@cmember Contained IRowset
PIMPIROWSETm_pIRowset;
//@cmember Contained IRowsetChange
PIMPIROWSETCHANGEm_pIRowsetChange;
//@cmember Contained IAccessor
PIMPIACCESSORm_pIAccessor;
//@cmember Contained IRowsetInfo
PIMPIROWSETINFOm_pIRowsetInfo;
public: //@access public
//@cmember Constructor
CRowset(LPUNKNOWN);
//@cmember Destructor
~CRowset(void);
//@cmember Intitialization Routine
BOOL FInit(CFileIO*);
//Object's base IUnknown
//@cmember Request an Interface
STDMETHODIMPQueryInterface(REFIID, LPVOID *);
//@cmember Increments the Reference count
STDMETHODIMP_(ULONG)AddRef(void);
//@cmember Decrements the Reference count
STDMETHODIMP_(ULONG)Release(void);
//Back pointer to a creator object. Used in IRowssetInfo::GetSpecification
PCDBSESSION m_pCreator;
};
typedef CRowset *PCROWSET;
//----------------------------------------------------------------------------
// @class CImpIRowset | Contained IRowset class
//
class CImpIRowset : public IRowset//@base public | IRowset
{
private: //@access private
DEFINE_DEFAULT_IUNKNOWN_MEMBER_DATA(CRowset)
public: //@access public
DEFINE_DEFAULT_IUNKNOWN_CTOR_DTOR(CRowset, CImpIRowset);
DEFINE_DEFAULT_IUNKNOWN_ADDREF_RELEASE
//IRowset members
//@cmember GetData Method
STDMETHODIMPGetData(HROW, HACCESSOR, void*);
//@cmember GetNextRows Method
STDMETHODIMPGetNextRows(HCHAPTER, LONG, LONG, ULONG*, HROW**);
//cmember ReleaseRows method
STDMETHODIMPReleaseRows(ULONG, const HROW[], DBROWOPTIONS[], ULONG[], DBROWSTATUS[]);
//@cmember RestartPosition method
STDMETHODIMPRestartPosition(HCHAPTER);
//@cmember AddRefRows method
STDMETHODIMP AddRefRows(ULONG, const HROW[], ULONG[], DBROWSTATUS[]);
};
//----------------------------------------------------------------------------
// @class CImpIRowsetChange | Contained IRowsetChange class
//
class CImpIRowsetChange : public IRowsetChange//@base public | IRowsetChange
{
private: //@access private
DEFINE_DEFAULT_IUNKNOWN_MEMBER_DATA(CRowset)
public: //@access public
DEFINE_DEFAULT_IUNKNOWN_CTOR_DTOR(CRowset, CImpIRowsetChange);
DEFINE_DEFAULT_IUNKNOWN_ADDREF_RELEASE
//IRowsetChange members
//@cmember SetData Method
STDMETHODIMPSetData(HROW, HACCESSOR, void*);
STDMETHODIMPDeleteRows(HCHAPTER, ULONG, const HROW[], DBROWSTATUS[]);
STDMETHODIMP InsertRow
(
HCHAPTERhReserved,
HACCESSORhAccessor,
void*pData,
HROW*phRow
);
};
//----------------------------------------------------------------------------
// @class CImpIColumnsInfo | Contained IColumnsInfo class
//
class CImpIColumnsInfo : public IColumnsInfo //@base public | IColumnsInfo
{
private: //@access private
DEFINE_DEFAULT_IUNKNOWN_MEMBER_DATA(CRowset)
public: //@access public
DEFINE_DEFAULT_IUNKNOWN_CTOR_DTOR(CRowset, CImpIColumnsInfo);
DEFINE_DEFAULT_IUNKNOWN_ADDREF_RELEASE
//IColumnsInfo members
//@cmember GetColumnInfo method
STDMETHODIMPGetColumnInfo(ULONG*, DBCOLUMNINFO**, WCHAR**);
//@cmember MapColumnIDs
STDMETHODIMPMapColumnIDs(ULONG, const DBID[], ULONG[]);
};
//----------------------------------------------------------------------------
// @class CImpIAccessor | Contained IAccessor class
//
class CImpIAccessor : public IAccessor //@base public | IAccessor
{
private: //@access private
DEFINE_DEFAULT_IUNKNOWN_MEMBER_DATA(CRowset)
public: //@access public
DEFINE_DEFAULT_IUNKNOWN_CTOR_DTOR(CRowset, CImpIAccessor);
DEFINE_DEFAULT_IUNKNOWN_ADDREF_RELEASE
//@cmember Increment Reference count on accessor
STDMETHODIMPAddRefAccessor(HACCESSOR hAccessor, ULONG* pcRefCounts);
//@cmember CreateAccessor Method
STDMETHODIMPCreateAccessor(DBACCESSORFLAGS, ULONG, const DBBINDING[], ULONG, HACCESSOR*, DBBINDSTATUS[]);
//@cmember GetBindings Method
STDMETHODIMPGetBindings(HACCESSOR, DBACCESSORFLAGS*, ULONG*, DBBINDING**);
//@cmember ReleaseAccessor Method
STDMETHODIMPReleaseAccessor(HACCESSOR, ULONG*);
};
//----------------------------------------------------------------------------
// @class CImpIRowsetInfo | Contained IRowsetInfo class
//
class CImpIRowsetInfo : public IRowsetInfo //@base public | IAccessor
{
private: //@access private
DEFINE_DEFAULT_IUNKNOWN_MEMBER_DATA(CRowset)
public: //@access public
DEFINE_DEFAULT_IUNKNOWN_CTOR_DTOR(CRowset, CImpIRowsetInfo);
DEFINE_DEFAULT_IUNKNOWN_ADDREF_RELEASE
//@cmember GetReferencedRowset
STDMETHODIMPGetReferencedRowset
(
ULONGiOrdinal,
REFIIDrrid,
IUnknown**ppReferencedRowset
);
//@cmember GetProperties
STDMETHODIMPGetProperties
(
const ULONGcPropertySets,
const DBPROPIDSETrgPropertySets[],
ULONG* pcProperties,
DBPROPSET**prgProperties
);
//@cmember GetSpecification Method
STDMETHODIMPGetSpecification(REFIID, IUnknown**);
};
#endif