- Main Page
- Classes
- Files
- Directories
- Related Pages

- File List
- File Members

# oledb_sup.h

    00001 /******************************************************************************
    00002  * $Id: oledb_sup.h 10645 2007-01-18 02:22:39Z warmerdam $
    00003  *
    00004  * Project:  OpenGIS Simple Features Reference Implementation
    00005  * Purpose:  OLE DB support functions.
    00006  * Author:   Frank Warmerdam, warmerdam@pobox.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 #ifndef OLEDB_SUP_H_INCLUDED
    00031 #define OLEDB_SUP_H_INCLUDED
    00032
    00033 #define WIN32_LEAN_AND_MEAN             // avoid the world
    00034 #define INC_OLE2                                // tell windows.h to always include ole2.h
    00035
    00036 #include <windows.h>                    //
    00037 #include <ole2ver.h>                    // OLE2.0 build version
    00038 #include <cguid.h>                              // GUID_NULL
    00039 #include <stdio.h>                              // vsnprintf, etc.
    00040 #include <stddef.h>                             // offsetof
    00041 #include <stdarg.h>                             // va_arg
    00042 #include <assert.h>                             // assert
    00043
    00044 //      OLE DB headers
    00045 #include <oledb.h>
    00046 #include <oledberr.h>
    00047
    00048 /* -------------------------------------------------------------------- */
    00049 /*      General error reporting.                                        */
    00050 /* -------------------------------------------------------------------- */
    00051 void DumpErrorMsg( const char * );
    00052 HRESULT DumpErrorHResult( HRESULT, const char *, ... );
    00053
    00054 HRESULT AnsiToUnicode(LPCSTR pszA, LPOLESTR* ppszW);
    00055 HRESULT UnicodeToAnsi(LPCOLESTR ppszW, LPSTR *pszA );
    00056 HRESULT AnsiToBSTR( const char *, BSTR * );
    00057
    00058 extern "C" {
    00059 const char *VARIANTToString( VARIANT * );
    00060 }
    00061
    00062 /* -------------------------------------------------------------------- */
    00063 /*      Ole helper functions.                                           */
    00064 /* -------------------------------------------------------------------- */
    00065 int OleSupInitialize();
    00066 int OleSupUninitialize();
    00067
    00068 void OledbSupWriteColumnInfo( FILE *, DBCOLUMNINFO * );
    00069 void OledbSupDumpRow( FILE *, DBCOLUMNINFO *, int, DBBINDING *,
    00070                       ULONG, ULONG, BYTE * );
    00071
    00072 /* -------------------------------------------------------------------- */
    00073 /*                       Constants from sampclnt.                       */
    00074 /* -------------------------------------------------------------------- */
    00075
    00076 // Alignment for placement of each column within memory.
    00077 // Rule of thumb is "natural" boundary, i.e. 4-byte member should be
    00078 // aligned on address that is multiple of 4.
    00079 // Worst case is double or __int64 (8 bytes).
    00080 #define COLUMN_ALIGNVAL 8
    00081
    00082 #define MAX_GUID_STRING     42  // size of a GUID, in characters
    00083 #define MAX_NAME_STRING     60  // size of DBCOLOD name or propid string
    00084 #define MAX_BINDINGS       100  // size of binding array
    00085 #define NUMROWS_CHUNK       20  // number of rows to grab at a time
    00086 #define DEFAULT_CBMAXLENGTH 40  // cbMaxLength for binding
    00087
    00088 //-----------------------------------
    00089 //      macros
    00090 //------------------------------------
    00091
    00092 // Rounding amount is always a power of two.
    00093 #define ROUND_UP(   Size, Amount ) (((DWORD)(Size) +  ((Amount) - 1)) & ~((Amount) - 1))
    00094
    00095 #ifndef  NUMELEM
    00096 # define NUMELEM(p) (sizeof(p)/sizeof(*p))
    00097 #endif
    00098
    00099 //-----------------------------------
    00100 //      type and structure definitions
    00101 //------------------------------------
    00102
    00103 // How to lay out each column in memory.
    00104 // Issue? we depend on the dwLength field being first in memory (see assert)
    00105 // is there another way to handle this?
    00106 struct COLUMNDATA
    00107         {
    00108         DWORD           dwLength;       // length of data (not space allocated)
    00109         DWORD           dwStatus;       // status of column
    00110         BYTE            bData[1];       // data here and beyond
    00111         };
    00112
    00113
    00114 // Lists of value/string pairs.
    00115 typedef struct {
    00116         DWORD dwFlag;
    00117         char *szText;
    00118 } Note;
    00119
    00120 char * GetNoteString( Note *, int, DWORD );
    00121
    00122 #define NOTE(s) { (DWORD) s, #s }
    00123
    00124 #endif /* ndef OLEDB_SUP_H_INCLUDED */

Generated for GDAL by 1.5.1.