1 : /******************************************************************************
2 : * $Id: vfkreaderp.h 25201 2012-11-04 11:11:31Z 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 : #ifdef HAVE_SQLITE
42 : #include "sqlite3.h"
43 : #endif
44 :
45 : class VFKReader;
46 :
47 : /************************************************************************/
48 : /* VFKReader */
49 : /************************************************************************/
50 : class VFKReader : public IVFKReader
51 : {
52 : private:
53 : bool m_bLatin2;
54 :
55 : FILE *m_poFD;
56 : char *ReadLine(bool = FALSE);
57 :
58 : /* metadata */
59 : std::map<std::string, std::string> poInfo;
60 :
61 : void AddInfo(const char *);
62 :
63 : protected:
64 : char *m_pszFilename;
65 : int m_nDataBlockCount;
66 : IVFKDataBlock **m_papoDataBlock;
67 :
68 : IVFKDataBlock *CreateDataBlock(const char *);
69 : void AddDataBlock(IVFKDataBlock *, const char *);
70 : void AddFeature(IVFKDataBlock *, VFKFeature *);
71 :
72 : public:
73 : VFKReader(const char *);
74 : virtual ~VFKReader();
75 :
76 1150 : bool IsLatin2() const { return m_bLatin2; }
77 : int ReadDataBlocks();
78 : int ReadDataRecords(IVFKDataBlock *);
79 : int LoadGeometry();
80 :
81 126 : int GetDataBlockCount() const { return m_nDataBlockCount; }
82 : IVFKDataBlock *GetDataBlock(int) const;
83 : IVFKDataBlock *GetDataBlock(const char *) const;
84 :
85 : const char *GetInfo(const char *);
86 : };
87 :
88 : #ifdef HAVE_SQLITE
89 : /************************************************************************/
90 : /* VFKReaderSQLite */
91 : /************************************************************************/
92 :
93 : class VFKReaderSQLite : public VFKReader
94 : {
95 : private:
96 : sqlite3 *m_poDB;
97 :
98 : IVFKDataBlock *CreateDataBlock(const char *);
99 : void AddDataBlock(IVFKDataBlock *, const char *);
100 : void AddFeature(IVFKDataBlock *, VFKFeature *);
101 :
102 : void CreateIndex(const char *, const char *, const char *);
103 :
104 : friend class VFKFeatureSQLite;
105 : public:
106 : VFKReaderSQLite(const char *);
107 : virtual ~VFKReaderSQLite();
108 :
109 : int ReadDataBlocks();
110 : int ReadDataRecords(IVFKDataBlock *);
111 :
112 : sqlite3_stmt *PrepareStatement(const char *);
113 : OGRErr ExecuteSQL(const char *);
114 : OGRErr ExecuteSQL(sqlite3_stmt *);
115 : };
116 : #endif // HAVE_SQLITE
117 :
118 : #endif // GDAL_OGR_VFK_VFKREADERP_H_INCLUDED
|