root/spike/sfcom_oledb/client/oledb_sup.h
| Revision 12207, 4.9 kB (checked in by warmerdam, 1 year ago) | |
|---|---|
| |
| Line | |
|---|---|
| 1 | /****************************************************************************** |
| 2 | * $Id$ |
| 3 | * |
| 4 | * Project: OpenGIS Simple Features Reference Implementation |
| 5 | * Purpose: OLE DB support functions. |
| 6 | * Author: Frank Warmerdam, warmerdam@pobox.com |
| 7 | * |
| 8 | ****************************************************************************** |
| 9 | * Copyright (c) 1999, Frank Warmerdam |
| 10 | * |
| 11 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 12 | * copy of this software and associated documentation files (the "Software"), |
| 13 | * to deal in the Software without restriction, including without limitation |
| 14 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 15 | * and/or sell copies of the Software, and to permit persons to whom the |
| 16 | * Software is furnished to do so, subject to the following conditions: |
| 17 | * |
| 18 | * The above copyright notice and this permission notice shall be included |
| 19 | * in all copies or substantial portions of the Software. |
| 20 | * |
| 21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| 22 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 23 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 24 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 25 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 26 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| 27 | * DEALINGS IN THE SOFTWARE. |
| 28 | ****************************************************************************/ |
| 29 | |
| 30 | #ifndef OLEDB_SUP_H_INCLUDED |
| 31 | #define OLEDB_SUP_H_INCLUDED |
| 32 | |
| 33 | #define WIN32_LEAN_AND_MEAN // avoid the world |
| 34 | #define INC_OLE2 // tell windows.h to always include ole2.h |
| 35 | |
| 36 | #include <windows.h> // |
| 37 | #include <ole2ver.h> // OLE2.0 build version |
| 38 | #include <cguid.h> // GUID_NULL |
| 39 | #include <stdio.h> // vsnprintf, etc. |
| 40 | #include <stddef.h> // offsetof |
| 41 | #include <stdarg.h> // va_arg |
| 42 | #include <assert.h> // assert |
| 43 | |
| 44 | // OLE DB headers |
| 45 | #include <oledb.h> |
| 46 | #include <oledberr.h> |
| 47 | |
| 48 | /* -------------------------------------------------------------------- */ |
| 49 | /* General error reporting. */ |
| 50 | /* -------------------------------------------------------------------- */ |
| 51 | void DumpErrorMsg( const char * ); |
| 52 | HRESULT DumpErrorHResult( HRESULT, const char *, ... ); |
| 53 | |
| 54 | HRESULT AnsiToUnicode(LPCSTR pszA, LPOLESTR* ppszW); |
| 55 | HRESULT UnicodeToAnsi(LPCOLESTR ppszW, LPSTR *pszA ); |
| 56 | HRESULT AnsiToBSTR( const char *, BSTR * ); |
| 57 | |
| 58 | extern "C" { |
| 59 | const char *VARIANTToString( VARIANT * ); |
| 60 | } |
| 61 | |
| 62 | /* -------------------------------------------------------------------- */ |
| 63 | /* Ole helper functions. */ |
| 64 | /* -------------------------------------------------------------------- */ |
| 65 | int OleSupInitialize(); |
| 66 | int OleSupUninitialize(); |
| 67 | |
| 68 | void OledbSupWriteColumnInfo( FILE *, DBCOLUMNINFO * ); |
| 69 | void OledbSupDumpRow( FILE *, DBCOLUMNINFO *, int, DBBINDING *, |
| 70 | ULONG, ULONG, BYTE * ); |
| 71 | |
| 72 | /* -------------------------------------------------------------------- */ |
| 73 | /* Constants from sampclnt. */ |
| 74 | /* -------------------------------------------------------------------- */ |
| 75 | |
| 76 | // Alignment for placement of each column within memory. |
| 77 | // Rule of thumb is "natural" boundary, i.e. 4-byte member should be |
| 78 | // aligned on address that is multiple of 4. |
| 79 | // Worst case is double or __int64 (8 bytes). |
| 80 | #define COLUMN_ALIGNVAL 8 |
| 81 | |
| 82 | #define MAX_GUID_STRING 42 // size of a GUID, in characters |
| 83 | #define MAX_NAME_STRING 60 // size of DBCOLOD name or propid string |
| 84 | #define MAX_BINDINGS 100 // size of binding array |
| 85 | #define NUMROWS_CHUNK 20 // number of rows to grab at a time |
| 86 | #define DEFAULT_CBMAXLENGTH 40 // cbMaxLength for binding |
| 87 | |
| 88 | //----------------------------------- |
| 89 | // macros |
| 90 | //------------------------------------ |
| 91 | |
| 92 | // Rounding amount is always a power of two. |
| 93 | #define ROUND_UP( Size, Amount ) (((DWORD)(Size) + ((Amount) - 1)) & ~((Amount) - 1)) |
| 94 | |
| 95 | #ifndef NUMELEM |
| 96 | # define NUMELEM(p) (sizeof(p)/sizeof(*p)) |
| 97 | #endif |
| 98 | |
| 99 | //----------------------------------- |
| 100 | // type and structure definitions |
| 101 | //------------------------------------ |
| 102 | |
| 103 | // How to lay out each column in memory. |
| 104 | // Issue? we depend on the dwLength field being first in memory (see assert) |
| 105 | // is there another way to handle this? |
| 106 | struct COLUMNDATA |
| 107 | { |
| 108 | DWORD dwLength; // length of data (not space allocated) |
| 109 | DWORD dwStatus; // status of column |
| 110 | BYTE bData[1]; // data here and beyond |
| 111 | }; |
| 112 | |
| 113 | |
| 114 | // Lists of value/string pairs. |
| 115 | typedef struct { |
| 116 | DWORD dwFlag; |
| 117 | char *szText; |
| 118 | } Note; |
| 119 | |
| 120 | char * GetNoteString( Note *, int, DWORD ); |
| 121 | |
| 122 | #define NOTE(s) { (DWORD) s, #s } |
| 123 | |
| 124 | #endif /* ndef OLEDB_SUP_H_INCLUDED */ |
Note: See TracBrowser for help on using the browser.
