1 : /******************************************************************************
2 : * $Id: vfkreaderp.h 24216 2012-04-09 11:26:40Z 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();
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 : 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 : #ifdef HAVE_SQLITE
88 : /************************************************************************/
89 : /* VFKReaderSQLite */
90 : /************************************************************************/
91 :
92 : class VFKReaderSQLite : public VFKReader
93 : {
94 : private:
95 : sqlite3 *m_poDB;
96 :
97 : IVFKDataBlock *CreateDataBlock(const char *);
98 : void AddDataBlock(IVFKDataBlock *, const char *);
99 : void AddFeature(IVFKDataBlock *, VFKFeature *);
100 :
101 : friend class VFKFeatureSQLite;
102 : public:
103 : VFKReaderSQLite(const char *);
104 : virtual ~VFKReaderSQLite();
105 :
106 : int ReadDataBlocks();
107 : int ReadDataRecords(IVFKDataBlock *);
108 :
109 : sqlite3_stmt *PrepareStatement(const char *);
110 : OGRErr ExecuteSQL(const char *);
111 : OGRErr ExecuteSQL(sqlite3_stmt *);
112 : };
113 : #endif // HAVE_SQLITE
114 :
115 : #endif // GDAL_OGR_VFK_VFKREADERP_H_INCLUDED
|