1 : /******************************************************************************
2 : * $Id: ogr_rec.h 15583 2008-10-23 00:04:33Z warmerdam $
3 : *
4 : * Project: Epi .REC Translator
5 : * Purpose: Definition of classes for OGR .REC support.
6 : * Author: Frank Warmerdam, warmerdam@pobox.com
7 : *
8 : ******************************************************************************
9 : * Copyright (c) 2003, 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 _OGR_REC_H_INCLUDED
31 : #define _OGR_REC_H_INCLUDED
32 :
33 : #include "ogrsf_frmts.h"
34 :
35 : class OGRRECDataSource;
36 :
37 : CPL_C_START
38 : int CPL_DLL RECGetFieldCount( FILE *fp);
39 : int CPL_DLL RECGetFieldDefinition( FILE *fp, char *pszFieldName, int *pnType,
40 : int *pnWidth, int *pnPrecision );
41 : int CPL_DLL RECReadRecord( FILE *fp, char *pszRecBuf, int nRecordLength );
42 : const char CPL_DLL *RECGetField( const char *pszSrc, int nStart, int nWidth );
43 : CPL_C_END
44 :
45 :
46 : /************************************************************************/
47 : /* OGRRECLayer */
48 : /************************************************************************/
49 :
50 : class OGRRECLayer : public OGRLayer
51 : {
52 : OGRFeatureDefn *poFeatureDefn;
53 :
54 : FILE *fpREC;
55 : int nStartOfData;
56 : int bIsValid;
57 :
58 : int nFieldCount;
59 : int *panFieldOffset;
60 : int *panFieldWidth;
61 : int nRecordLength;
62 :
63 : int nNextFID;
64 :
65 : OGRFeature * GetNextUnfilteredFeature();
66 :
67 : public:
68 : OGRRECLayer( const char *pszName, FILE *fp,
69 : int nFieldCount );
70 : ~OGRRECLayer();
71 :
72 : void ResetReading();
73 : OGRFeature * GetNextFeature();
74 :
75 0 : OGRFeatureDefn * GetLayerDefn() { return poFeatureDefn; }
76 :
77 0 : void SetSpatialFilter( OGRGeometry * ) {}
78 :
79 : int TestCapability( const char * );
80 :
81 0 : int IsValid() { return bIsValid; }
82 :
83 : };
84 :
85 : /************************************************************************/
86 : /* OGRRECDataSource */
87 : /************************************************************************/
88 :
89 : class OGRRECDataSource : public OGRDataSource
90 : {
91 : char *pszName;
92 :
93 : OGRRECLayer *poLayer;
94 :
95 : public:
96 : OGRRECDataSource();
97 : ~OGRRECDataSource();
98 :
99 : int Open( const char * pszFilename );
100 :
101 0 : const char *GetName() { return pszName; }
102 0 : int GetLayerCount() { return 1; }
103 : OGRLayer *GetLayer( int );
104 : int TestCapability( const char * );
105 : };
106 :
107 : /************************************************************************/
108 : /* OGRRECDriver */
109 : /************************************************************************/
110 :
111 : class OGRRECDriver : public OGRSFDriver
112 64 : {
113 : public:
114 : ~OGRRECDriver();
115 :
116 : const char *GetName();
117 : OGRDataSource *Open( const char *, int );
118 : int TestCapability( const char * );
119 : };
120 :
121 :
122 : #endif /* ndef _OGR_REC_H_INCLUDED */
|