Documentation for OpenFLUID
2.2.0
GDALCompatibility.hpp
Go to the documentation of this file.
1
/*
2
3
This file is part of OpenFLUID software
4
Copyright(c) 2007, INRA - Montpellier SupAgro
5
6
7
== GNU General Public License Usage ==
8
9
OpenFLUID is free software: you can redistribute it and/or modify
10
it under the terms of the GNU General Public License as published by
11
the Free Software Foundation, either version 3 of the License, or
12
(at your option) any later version.
13
14
OpenFLUID is distributed in the hope that it will be useful,
15
but WITHOUT ANY WARRANTY; without even the implied warranty of
16
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
GNU General Public License for more details.
18
19
You should have received a copy of the GNU General Public License
20
along with OpenFLUID. If not, see <http://www.gnu.org/licenses/>.
21
22
23
== Other Usage ==
24
25
Other Usage means a use of OpenFLUID that is inconsistent with the GPL
26
license, and requires a written agreement between You and INRA.
27
Licensees for Other Usage of OpenFLUID may use this file in accordance
28
with the terms contained in the written agreement between You and INRA.
29
30
*/
31
32
/**
33
@file GDALCompatibility.hpp
34
35
@author Jean-Christophe FABRE <jean-christophe.fabre@inra.fr>
36
37
This file contains macros to help ensuring compatibility
38
between GDAL version 1.xx and 2.xx of this library.
39
These macros mainly apply to vector part (OGR) of the library
40
*/
41
42
43
#ifndef __OPENFLUID_UTILS_GDALCOMPATIBILITY_HPP__
44
#define __OPENFLUID_UTILS_GDALCOMPATIBILITY_HPP__
45
46
47
#include <gdal.h>
48
49
50
#if !defined(GDAL_VERSION_MAJOR)
51
#error "GDAL_VERSION_MAJOR not defined"
52
#endif
53
54
55
#if (GDAL_VERSION_MAJOR < 2)
56
#error "GDAL version 2 or higher is required"
57
#endif
58
59
60
/**
61
Macro for compatibility of vector drivers registering
62
*/
63
#define GDALAllRegister_COMPAT() GDALAllRegister()
64
65
66
/**
67
Macro for compatibility of vector data source type
68
*/
69
#define GDALDataset_COMPAT GDALDataset
70
71
72
/**
73
Macro for compatibility of vector driver type
74
*/
75
#define GDALDriver_COMPAT GDALDriver
76
77
78
/**
79
Macro for compatibility of vector data opening (in read-write mode)
80
@param _M_path Path to the file(s) to open
81
@return a pointer to a GDALDataset_COMPAT data source
82
*/
83
#define GDALOpenRW_COMPAT(_M_path) \
84
static_cast<GDALDataset_COMPAT*>(GDALOpenEx(_M_path,GDAL_OF_VECTOR | GDAL_OF_UPDATE,nullptr,nullptr,nullptr));
85
86
87
/**
88
Macro for compatibility of vector data opening (in read only mode)
89
@param _M_path Path to the file(s) to open
90
@return a pointer to a GDALDataset_COMPAT data source
91
*/
92
#define GDALOpenRO_COMPAT(_M_path) \
93
static_cast<GDALDataset_COMPAT*>(GDALOpenEx(_M_path,GDAL_OF_VECTOR | GDAL_OF_READONLY,nullptr,nullptr,nullptr));
94
95
96
/**
97
Macro for compatibility of syncing/flushing a dataset to disk
98
@param _M_dataset The dataset
99
*/
100
#define GDALFlush_COMPAT(_M_dataset) _M_dataset->FlushCache()
101
102
103
/**
104
Macro for compatibility of vector data copy
105
@param _M_driver Driver to use for the copy
106
@param _M_srcptr Data source to copy
107
@param _M_destpath Path to the copied file(s)
108
@return a pointer to a GDALDataset_COMPAT data source for the newly copied files
109
*/
110
#define GDALCopy_COMPAT(_M_driver,_M_srcptr,_M_destpath) \
111
_M_driver->CreateCopy(_M_destpath,_M_srcptr,false,nullptr,nullptr,nullptr)
112
113
114
/**
115
Macro for compatibility of vector data creation
116
@param _M_driver Driver to use for the creation
117
@param _M_path Path to the file(s) to create
118
@return a pointer to a GDALDataset_COMPAT data source for the newly created files
119
*/
120
#define GDALCreate_COMPAT(_M_driver,_M_path) \
121
_M_driver->Create(_M_path,0,0,0,GDT_Unknown,nullptr)
122
123
124
/**
125
Macro for compatibility of data source closing
126
@param _M_ptr Pointer to the data source to close
127
*/
128
#define GDALClose_COMPAT(_M_ptr) GDALClose(_M_ptr);
129
130
131
/**
132
Macro for compatibility of physical deletion of vector data
133
@param _M_driver Driver to use for the deletion
134
@param _M_path Path to the file(s) to delete
135
*/
136
#define GDALDelete_COMPAT(_M_driver,_M_path) _M_driver->Delete(_M_path)
137
138
139
/**
140
Macro for compatibility of getting a driver by its name
141
@param _M_name Name of the driver
142
@return a pointer to a GDALDriver_COMPAT driver, NULL if not found
143
*/
144
#define GDALGetDriverByName_COMPAT(_M_name) GetGDALDriverManager()->GetDriverByName(_M_name)
145
146
147
/**
148
Macro for compatibility of getting a the name of the driver from a driver object
149
@param _M_driver The driver object
150
@return the name of the driver
151
*/
152
#define GDALGetDriverName_COMPAT(_M_driver) _M_driver->GetDescription()
153
154
155
/**
156
Macro for compatibility of Integer64 and Integer64List type
157
*/
158
#define GDALOFTInteger64_COMPAT OFTInteger64
159
#define GDALOFTIntegerList64_COMPAT OFTIntegerList64
160
161
162
#endif
/* __OPENFLUID_UTILS_GDALCOMPATIBILITY_HPP__ */
utils
GDALCompatibility.hpp
Generated by
1.9.1