FILEIO.H
//-------------------------------------------------------------------- 
// Microsoft OLE DB Sample Provider 
// (C) Copyright 1994 - 1996 Microsoft Corporation.  All Rights Reserved. 
// 
// @doc 
// 
// @module FILEIO.H | Class Definitions for CFileIO Class 
// 
// 
#ifndef _FILEIO_H_ 
#define _FILEIO_H_ 
 
#include <fstream.h> 
#include "fileidx.h" 
#include "hashtbl.h" 
 
#define MAX_INPUT_BUFFER 2048 
#define MAX_COLUMNS129// 128 columns supported, but 1 extra 
// is needed since 1 based. 
 
//-------------------------------------------------------------------- 
// @class CFileIO | Opens and manipulates a given CSV file.  Allows  
// deletions, reads, and updates. 
//  
// @hungarian  
// 
class CFileIO : public fstream//@base public | fstream 
{ 
private: //@access private 
//@cmember Count of rows in the table  
ULONGm_cRows; 
//@cmember Count of columns in the table 
DWORDm_dwColumns; 
//@cmember Pointer to Column Names buffer 
LPTSTRm_pColNames; 
//@cmember Array of pointers into the Column Names buffer 
LPTSTRm_rgpColNames[MAX_COLUMNS]; 
//@cmember Array of Column Data Types 
SWORDm_rgswColType[MAX_COLUMNS]; 
//@cmember Array of Precision values for columns 
UDWORDm_rgudwColSize[MAX_COLUMNS]; 
//@cmember True if columns contains signed values 
BOOLm_rgfSigned[MAX_COLUMNS]; 
//@cmember Array of pointers to Data 
PCOLUMNDATA m_rgpColumnData[MAX_COLUMNS]; 
//@cmember Array of Lengths for the data 
SDWORDm_rgsdwMaxLen[MAX_COLUMNS]; 
//@cmember Input buffer of size MAX_INPUT_BUFFER 
LPTSTRm_pvInput; 
//@cmember Offset into file for DataTypes 
ULONGm_ulDataTypeOffset; 
//@cmember Index Class declaration 
CFileIdxm_FileIdx; 
 
private: //@access private 
//@cmember Break a stream into column names 
HRESULT ParseColumnNames(LPTSTR ptstrInput); 
//@cmember Break a stream into MetaData information 
HRESULT ParseDataTypes(); 
//@cmember Control procedure to Read and parse intitial 
//information from the file 
HRESULT GenerateFileInfo(); 
//@cmember Fill the COLUMNDATA structure 
HRESULT CFileIO::FillBinding(DWORD dwColumn, LPTSTR pvCopy); 
 
 
public: //@access public 
//@cmember Constructor 
CFileIO(void); 
//@cmember Destructor 
~CFileIO(void); 
//@cmember Initialization routine 
HRESULT fInit(LPTSTR pstrFileName); 
//@cmember Return the number of columns in the file 
inline DWORD GetColumnCnt() { return m_dwColumns; }; 
//@cmember Return the number of rows in the file 
inline DWORD GetRowCnt() { return m_cRows; }; 
//@cmember Retrieve pointers to the columns names 
HRESULT GetColumnName(DWORD dwCol, LPTSTR* pptstrName = NULL); 
//@cmember Retrieve the metadata for a particular column 
HRESULT GetDataTypes(DWORD dwCol, SWORD* pswType, UDWORD* pudwColDef, BOOL* pfSigned); 
//@cmember Set the Binding Areas. 
HRESULT SetColumnBind(DWORD dwcol, PCOLUMNDATA pColumn, SDWORD sdwMaxLen); 
//@cmember Extract the data from a stream 
HRESULT ParseRowValues(); 
//@cmember Fetch A single rows data values 
HRESULT Fetch(ULONG ulRow); 
//@cmember Update the current rows values 
HRESULT UpdateRow(ULONG ulRow, ULONG* ulOffset, BYTE* pbProvRow); 
//@cmember Remove the specified row from the file 
HRESULT DeleteRow(ULONG ulRow); 
//@cmember Determines if the row has already been deleted 
HRESULT IsDeleted(ULONG ulRow); 
}; 
 
typedef CFileIO FAR * PCFILEIO; 
 
#endif