1 : /******************************************************************************
2 : * $Id: ogr_xls.h 23694 2012-01-03 22:03:47Z rouault $
3 : *
4 : * Project: XLS Translator
5 : * Purpose: Definition of classes for OGR .xls driver.
6 : * Author: Even Rouault, even dot rouault at mines dash paris dot org
7 : *
8 : ******************************************************************************
9 : * Copyright (c) 2011, Even Rouault <even dot rouault at mines dash paris dot org>
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 _OGR_XLS_H_INCLUDED
31 : #define _OGR_XLS_H_INCLUDED
32 :
33 : #include "ogrsf_frmts.h"
34 :
35 : /************************************************************************/
36 : /* OGRXLSLayer */
37 : /************************************************************************/
38 :
39 : class OGRXLSDataSource;
40 :
41 : class OGRXLSLayer : public OGRLayer
42 : {
43 : OGRXLSDataSource* poDS;
44 : OGRFeatureDefn* poFeatureDefn;
45 :
46 : char *pszName;
47 : int iSheet;
48 : int bFirstLineIsHeaders;
49 : int nRows;
50 : unsigned short nCols;
51 :
52 : int nNextFID;
53 :
54 : OGRFeature * GetNextRawFeature();
55 :
56 : void DetectHeaderLine(const void* xlshandle);
57 : void DetectColumnTypes(const void* xlshandle,
58 : int* paeFieldTypes);
59 :
60 : public:
61 : OGRXLSLayer(OGRXLSDataSource* poDSIn,
62 : const char* pszSheetname,
63 : int iSheetIn,
64 : int nRowsIn,
65 : unsigned short nColsIn);
66 : ~OGRXLSLayer();
67 :
68 :
69 : virtual void ResetReading();
70 : virtual OGRFeature * GetNextFeature();
71 :
72 : virtual OGRFeatureDefn * GetLayerDefn();
73 : virtual int GetFeatureCount( int bForce = TRUE );
74 :
75 14 : virtual const char *GetName() { return pszName; }
76 2 : virtual OGRwkbGeometryType GetGeomType() { return wkbNone; }
77 :
78 : virtual int TestCapability( const char * );
79 :
80 2 : virtual OGRSpatialReference *GetSpatialRef() { return NULL; }
81 :
82 : };
83 :
84 : /************************************************************************/
85 : /* OGRXLSDataSource */
86 : /************************************************************************/
87 :
88 : class OGRXLSDataSource : public OGRDataSource
89 : {
90 : char* pszName;
91 :
92 : OGRLayer** papoLayers;
93 : int nLayers;
94 :
95 : const void* xlshandle;
96 :
97 : public:
98 : OGRXLSDataSource();
99 : ~OGRXLSDataSource();
100 :
101 : int Open( const char * pszFilename,
102 : int bUpdate );
103 :
104 4 : virtual const char* GetName() { return pszName; }
105 :
106 15 : virtual int GetLayerCount() { return nLayers; }
107 : virtual OGRLayer* GetLayer( int );
108 :
109 : virtual int TestCapability( const char * );
110 :
111 : const void *GetXLSHandle();
112 : };
113 :
114 : /************************************************************************/
115 : /* OGRXLSDriver */
116 : /************************************************************************/
117 :
118 : class OGRXLSDriver : public OGRSFDriver
119 226 : {
120 : public:
121 : ~OGRXLSDriver();
122 :
123 : virtual const char* GetName();
124 : virtual OGRDataSource* Open( const char *, int );
125 : virtual int TestCapability( const char * );
126 : };
127 :
128 :
129 : #endif /* ndef _OGR_XLS_H_INCLUDED */
|