1 : /******************************************************************************
2 : * $Id: vfkreaderp.h 25703 2013-03-07 18:23:48Z martinl $
3 : *
4 : * Project: VFK Reader
5 : * Purpose: Private Declarations for OGR free VFK Reader code.
6 : * Author: Martin Landa, landa.martin gmail.com
7 : *
8 : ******************************************************************************
9 : * Copyright (c) 2009-2010, 2012, Martin Landa <landa.martin gmail.com>
10 : *
11 : * Permission is hereby granted, free of charge, to any person
12 : * obtaining a copy of this software and associated documentation
13 : * files (the "Software"), to deal in the Software without
14 : * restriction, including without limitation the rights to use, copy,
15 : * modify, merge, publish, distribute, sublicense, and/or sell copies
16 : * of the Software, and to permit persons to whom the Software is
17 : * furnished to do so, subject to the following conditions:
18 : *
19 : * The above copyright notice and this permission notice shall be
20 : * included in all copies or substantial portions of the Software.
21 : *
22 : * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 : * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 : * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 : * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
26 : * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
27 : * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
28 : * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29 : * SOFTWARE.
30 : ****************************************************************************/
31 :
32 : #ifndef GDAL_OGR_VFK_VFKREADERP_H_INCLUDED
33 : #define GDAL_OGR_VFK_VFKREADERP_H_INCLUDED
34 :
35 : #include <map>
36 : #include <string>
37 :
38 : #include "vfkreader.h"
39 : #include "ogr_api.h"
40 :
41 : #include "sqlite3.h"
42 :
43 : class VFKReader;
44 :
45 : /************************************************************************/
46 : /* VFKReader */
47 : /************************************************************************/
48 : class VFKReader : public IVFKReader
49 : {
50 : private:
51 : bool m_bLatin2;
52 :
53 : FILE *m_poFD;
54 : char *ReadLine(bool = FALSE);
55 :
56 : /* metadata */
57 : std::map<CPLString, CPLString> poInfo;
58 :
59 : void AddInfo(const char *);
60 :
61 : protected:
62 : char *m_pszFilename;
63 : int m_nDataBlockCount;
64 : IVFKDataBlock **m_papoDataBlock;
65 :
66 : IVFKDataBlock *CreateDataBlock(const char *);
67 : void AddDataBlock(IVFKDataBlock *, const char *);
68 : OGRErr AddFeature(IVFKDataBlock *, VFKFeature *);
69 :
70 : public:
71 : VFKReader(const char *);
72 : virtual ~VFKReader();
73 :
74 1150 : bool IsLatin2() const { return m_bLatin2; }
75 0 : bool IsSpatial() const { return FALSE; }
76 : int ReadDataBlocks();
77 : int ReadDataRecords(IVFKDataBlock *);
78 : int LoadGeometry();
79 :
80 126 : int GetDataBlockCount() const { return m_nDataBlockCount; }
81 : IVFKDataBlock *GetDataBlock(int) const;
82 : IVFKDataBlock *GetDataBlock(const char *) const;
83 :
84 : const char *GetInfo(const char *);
85 : };
86 :
87 : /************************************************************************/
88 : /* VFKReaderSQLite */
89 : /************************************************************************/
90 :
91 : class VFKReaderSQLite : public VFKReader
92 : {
93 : private:
94 : sqlite3 *m_poDB;
95 : bool m_bSpatial;
96 :
97 : IVFKDataBlock *CreateDataBlock(const char *);
98 : void AddDataBlock(IVFKDataBlock *, const char *);
99 : OGRErr AddFeature(IVFKDataBlock *, VFKFeature *);
100 :
101 : void CreateIndex(const char *, const char *, const char *, bool = TRUE);
102 :
103 : friend class VFKFeatureSQLite;
104 : public:
105 : VFKReaderSQLite(const char *);
106 : virtual ~VFKReaderSQLite();
107 :
108 58 : bool IsSpatial() const { return m_bSpatial; }
109 : int ReadDataBlocks();
110 : int ReadDataRecords(IVFKDataBlock *);
111 :
112 : sqlite3_stmt *PrepareStatement(const char *);
113 : OGRErr ExecuteSQL(const char *, bool = FALSE);
114 : OGRErr ExecuteSQL(sqlite3_stmt *);
115 : };
116 :
117 : #endif // GDAL_OGR_VFK_VFKREADERP_H_INCLUDED
|