oledb_sup.h

00001 /******************************************************************************
00002  * $Id: oledb_sup.h,v 1.11 2001/11/09 19:09:03 warmerda Exp $
00003  *
00004  * Project:  OpenGIS Simple Features Reference Implementation
00005  * Purpose:  OLE DB support functions. 
00006  * Author:   Frank Warmerdam, warmerda@home.com
00007  *
00008  ******************************************************************************
00009  * Copyright (c) 1999, Frank Warmerdam
00010  *
00011  * Permission is hereby granted, free of charge, to any person obtaining a
00012  * copy of this software and associated documentation files (the "Software"),
00013  * to deal in the Software without restriction, including without limitation
00014  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
00015  * and/or sell copies of the Software, and to permit persons to whom the
00016  * Software is furnished to do so, subject to the following conditions:
00017  *
00018  * The above copyright notice and this permission notice shall be included
00019  * in all copies or substantial portions of the Software.
00020  *
00021  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00022  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00023  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
00024  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00025  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
00026  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
00027  * DEALINGS IN THE SOFTWARE.
00028  ******************************************************************************
00029  *
00030  * $Log: oledb_sup.h,v $
00031  * Revision 1.11  2001/11/09 19:09:03  warmerda
00032  * added VARIANTToString... does not appear to work
00033  *
00034  * Revision 1.10  1999/11/18 19:02:20  warmerda
00035  * expanded tabs
00036  *
00037  * Revision 1.9  1999/09/07 12:05:59  warmerda
00038  * trimmed out some old oledbsup related stuff
00039  *
00040  * Revision 1.8  1999/06/09 21:03:58  warmerda
00041  * Removed OledbSupRowset documentation ... this class will be decommisioned
00042  * soon.
00043  *
00044  * Revision 1.7  1999/06/02 16:28:17  warmerda
00045  * added docs
00046  *
00047  * Revision 1.6  1999/05/21 02:38:32  warmerda
00048  * added AnsiToBSTR()
00049  *
00050  * Revision 1.5  1999/04/07 11:54:16  warmerda
00051  * Added dumping stuff.
00052  *
00053  * Revision 1.4  1999/04/01 20:49:41  warmerda
00054  * make class internals protected so OledbSFTable can have access
00055  *
00056  * Revision 1.3  1999/04/01 17:53:46  warmerda
00057  * added getnumcolumns, and oledbsupWritecolumninfo
00058  *
00059  * Revision 1.2  1999/03/31 15:11:16  warmerda
00060  * Use char * instead of LPWSTR, better multi-provider support
00061  *
00062  * Revision 1.1  1999/03/30 19:07:59  warmerda
00063  * New
00064  *
00065  */
00066 
00067 #ifndef OLEDB_SUP_H_INCLUDED
00068 #define OLEDB_SUP_H_INCLUDED
00069 
00070 #define WIN32_LEAN_AND_MEAN             // avoid the world
00071 #define INC_OLE2                                // tell windows.h to always include ole2.h
00072 
00073 #include <windows.h>                    // 
00074 #include <ole2ver.h>                    // OLE2.0 build version
00075 #include <cguid.h>                              // GUID_NULL
00076 #include <stdio.h>                              // vsnprintf, etc.
00077 #include <stddef.h>                             // offsetof
00078 #include <stdarg.h>                             // va_arg
00079 #include <assert.h>                             // assert
00080 
00081 //      OLE DB headers
00082 #include <oledb.h>
00083 #include <oledberr.h>
00084 
00085 /* -------------------------------------------------------------------- */
00086 /*      General error reporting.                                        */
00087 /* -------------------------------------------------------------------- */
00088 void DumpErrorMsg( const char * );
00089 HRESULT DumpErrorHResult( HRESULT, const char *, ... );
00090 
00091 HRESULT AnsiToUnicode(LPCSTR pszA, LPOLESTR* ppszW);
00092 HRESULT UnicodeToAnsi(LPCOLESTR ppszW, LPSTR *pszA );
00093 HRESULT AnsiToBSTR( const char *, BSTR * );
00094 
00095 extern "C" {
00096 const char *VARIANTToString( VARIANT * );
00097 }
00098 
00099 /* -------------------------------------------------------------------- */
00100 /*      Ole helper functions.                                           */
00101 /* -------------------------------------------------------------------- */
00102 int OleSupInitialize();
00103 int OleSupUninitialize();
00104 
00105 void OledbSupWriteColumnInfo( FILE *, DBCOLUMNINFO * );
00106 void OledbSupDumpRow( FILE *, DBCOLUMNINFO *, int, DBBINDING *,
00107                       ULONG, ULONG, BYTE * );
00108 
00109 /* -------------------------------------------------------------------- */
00110 /*                       Constants from sampclnt.                       */
00111 /* -------------------------------------------------------------------- */
00112 
00113 // Alignment for placement of each column within memory.
00114 // Rule of thumb is "natural" boundary, i.e. 4-byte member should be
00115 // aligned on address that is multiple of 4.
00116 // Worst case is double or __int64 (8 bytes).
00117 #define COLUMN_ALIGNVAL 8
00118 
00119 #define MAX_GUID_STRING     42  // size of a GUID, in characters
00120 #define MAX_NAME_STRING     60  // size of DBCOLOD name or propid string
00121 #define MAX_BINDINGS       100  // size of binding array
00122 #define NUMROWS_CHUNK       20  // number of rows to grab at a time
00123 #define DEFAULT_CBMAXLENGTH 40  // cbMaxLength for binding
00124 
00125 //-----------------------------------
00126 //      macros 
00127 //------------------------------------
00128 
00129 // Rounding amount is always a power of two.
00130 #define ROUND_UP(   Size, Amount ) (((DWORD)(Size) +  ((Amount) - 1)) & ~((Amount) - 1))
00131 
00132 #ifndef  NUMELEM
00133 # define NUMELEM(p) (sizeof(p)/sizeof(*p))
00134 #endif
00135 
00136 //-----------------------------------
00137 //      type and structure definitions 
00138 //------------------------------------
00139 
00140 // How to lay out each column in memory.
00141 // Issue? we depend on the dwLength field being first in memory (see assert)
00142 // is there another way to handle this?
00143 struct COLUMNDATA 
00144         {
00145         DWORD           dwLength;       // length of data (not space allocated)
00146         DWORD           dwStatus;       // status of column
00147         BYTE            bData[1];       // data here and beyond
00148         };
00149 
00150 
00151 // Lists of value/string pairs.
00152 typedef struct {
00153         DWORD dwFlag;
00154         char *szText;
00155 } Note;
00156 
00157 char * GetNoteString( Note *, int, DWORD );
00158 
00159 #define NOTE(s) { (DWORD) s, #s }
00160 
00161 #endif /* ndef OLEDB_SUP_H_INCLUDED */

Generated on Mon Jan 9 18:03:31 2006 for OGR by  doxygen 1.4.6