Skip to content

Commit 20d1070

Browse files
committed
Add gdal_raster_cpp.h, gdal_vector_cpp.h and gdal_multidim_cpp.h
1 parent 25f941a commit 20d1070

12 files changed

+175
-21
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
.. _gdal_multidim_cpp:
2+
3+
================================================================================
4+
Entry point for C++ Multi-dimensional Array API
5+
================================================================================
6+
7+
Since GDAL 3.12, :source_file:`gcore/gdal_multidim_cpp.h` is the include file
8+
for all headers related to the C++ Multi-dimensional Array API.
9+
10+
In earlier versions (and still available in the GDAL 3.x series), :file:`gdal_priv.h`
11+
is the equivalent include file.
12+
13+
Note that the C++ API is also used by GDAL internals and may be subject from
14+
time to time to backwards incompatible changes.

doc/source/api/gdal_raster_cpp.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
.. _gdal_raster_cpp:
2+
3+
================================================================================
4+
Entry point for C++ Raster API
5+
================================================================================
6+
7+
Since GDAL 3.12, :source_file:`gcore/gdal_raster_cpp.h` is the include file
8+
for all headers related to the C++ Raster API.
9+
10+
In earlier versions (and still available in the GDAL 3.x series), :file:`gdal_priv.h`
11+
is the equivalent include file.
12+
13+
Note that the C++ API is also used by GDAL internals and may be subject from
14+
time to time to backwards incompatible changes.

doc/source/api/gdal_vector_cpp.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
.. _gdal_vector_cpp:
2+
3+
================================================================================
4+
Entry point for C++ Vector API
5+
================================================================================
6+
7+
Since GDAL 3.12, :source_file:`gcore/gdal_vector_cpp.h` is the include file
8+
for all headers related to the C++ Vector API.
9+
10+
In earlier versions, the equivalent is to include :file:`gdal_priv.h`,
11+
:file:`ogrsf_frmts.h`, :file:`ogr_feature.h` and :file:`ogr_geometry.h`
12+
13+
Note that the C++ API is also used by GDAL internals and may be subject from
14+
time to time to backwards incompatible changes.

doc/source/api/index.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ API
3232
.. toctree::
3333
:maxdepth: 1
3434

35+
gdal_raster_cpp
3536
gdalmajorobject_cpp
3637
gdaldriver_cpp
3738
gdaldataset_cpp
@@ -46,6 +47,7 @@ API
4647
.. toctree::
4748
:maxdepth: 1
4849

50+
gdal_vector_cpp
4951
ogrfeature_cpp
5052
ogrfeaturestyle_cpp
5153
ogrgeometry_cpp
@@ -66,6 +68,7 @@ API
6668
.. toctree::
6769
:maxdepth: 1
6870

71+
gdal_multidim_cpp
6972
gdalgroup_cpp
7073
gdaldimension_cpp
7174
gdalabstractmdarray_cpp

doc/source/tutorials/multidimensional_api_tut.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ Read the content of an array
1111

1212
.. code-tab:: c++
1313

14+
// Note: since GDAL >= 3.12, "gdal_multidim_cpp.h" can alo be used.
1415
#include "gdal_priv.h"
16+
1517
int main()
1618
{
1719
GDALAllRegister();

doc/source/tutorials/raster_api_tut.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ Once the drivers are registered, the application should call the free standing :
1515

1616
.. code-tab:: c++
1717

18+
// Note: since GDAL >= 3.12, "gdal_raster_cpp.h" can alo be used
19+
// or finer grained include files such as "gdal_drivermanager.h",
20+
// "gdal_dataset.h" and "gdal_rasterband.h".
1821
#include "gdal_priv.h"
1922

2023
#include <errno.h>

doc/source/tutorials/vector_api_tut.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ all format drivers built into GDAL/OGR.
2626

2727
.. code-tab:: c++
2828

29+
// Note: since GDAL >= 3.12, "gdal_vector_cpp.h" can alo be used.
2930
#include "ogrsf_frmts.h"
3031

3132
int main()
@@ -186,11 +187,11 @@ and fetch and report the attributes based on their type.
186187

187188
OGRFeatureDefnH hFDefn = OGR_L_GetLayerDefn(hLayer);
188189
int iField;
189-
190+
190191
for( iField = 0; iField < OGR_FD_GetFieldCount(hFDefn); iField++ )
191192
{
192193
OGRFieldDefnH hFieldDefn = OGR_FD_GetFieldDefn( hFDefn, iField );
193-
194+
194195
if( !OGR_F_IsFieldSet(hFeature, iField) )
195196
{
196197
printf("(unset),");
@@ -328,7 +329,7 @@ Several geometry fields can be associated to a feature.
328329
#else
329330
OGRPoint *poPoint = (OGRPoint *) poGeometry;
330331
#endif
331-
332+
332333
printf( "%.3f,%3.f\n", poPoint->getX(), poPoint->getY() );
333334
}
334335
else

gcore/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,9 @@ target_public_header(
218218
HEADERS
219219
${CMAKE_CURRENT_BINARY_DIR}/gdal_version_full/gdal_version.h
220220
gdal.h
221+
gdal_raster_cpp.h
222+
gdal_multidim_cpp.h
223+
gdal_vector_cpp.h
221224
gdal_multidomainmetadata.h
222225
gdal_majorobject.h
223226
gdal_defaultoverviews.h

gcore/gdal_multidim_cpp.h

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/******************************************************************************
2+
*
3+
* Name: gdal_multidim_cpp.h
4+
* Project: GDAL Core
5+
* Purpose: GDAL Core Multidimensional C++ declarations.
6+
* Author: Even Rouault, <even dot rouault at spatialys.com>
7+
*
8+
******************************************************************************
9+
* Copyright (c) 2025 Even Rouault <even dot rouault at spatialys.com>
10+
*
11+
* SPDX-License-Identifier: MIT
12+
****************************************************************************/
13+
14+
#ifndef GDAL_MULTIDIM_CPP_H_INCLUDED
15+
#define GDAL_MULTIDIM_CPP_H_INCLUDED
16+
17+
/**
18+
* \file gdal_multidim_cpp.h
19+
*
20+
* C++ GDAL multidimensional API entry points.
21+
*
22+
* Before GDAL 3.12, the equivalent file to include is gdal_priv.h (which still
23+
* exits in the GDAL 3.x series)
24+
*
25+
* \since GDAL 3.12
26+
*/
27+
28+
#include "gdal_dataset.h"
29+
#include "gdal_drivermanager.h"
30+
#include "gdal_multidim.h"
31+
#include "gdal_pam_multidim.h"
32+
33+
#endif

gcore/gdal_priv.h

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,12 @@
1818
/**
1919
* \file gdal_priv.h
2020
*
21-
* C++ GDAL entry points.
21+
* This file is legacy since GDAL 3.12, but will be kept at least in the whole
22+
* GDAL 3.x series. Applications using the C++ API and that target only
23+
* GDAL >= 3.12 should rather use the new gdal_cpp.h header, or the finer
24+
* grain headers it includes.
25+
*
26+
* C++ GDAL entry points (legacy).
2227
*/
2328

2429
/* -------------------------------------------------------------------- */
@@ -58,22 +63,7 @@
5863
#include <vector>
5964
#endif
6065

61-
#include "gdal_multidomainmetadata.h"
62-
#include "gdal_majorobject.h"
63-
#include "gdal_defaultoverviews.h"
64-
#include "gdal_openinfo.h"
65-
#include "gdal_gcp.h"
66-
#include "gdal_geotransform.h"
67-
#include "gdal_dataset.h"
68-
#include "gdal_rasterblock.h"
69-
#include "gdal_colortable.h"
70-
#include "gdal_rasterband.h"
71-
#include "gdal_maskbands.h"
72-
#include "gdal_driver.h"
73-
#include "gdal_drivermanager.h"
74-
#include "gdal_asyncreader.h"
75-
#include "gdal_multidim.h"
76-
#include "gdal_relationship.h"
77-
#include "gdal_cpp_functions.h"
66+
#include "gdal_raster_cpp.h"
67+
#include "gdal_multidim_cpp.h"
7868

7969
#endif /* ndef GDAL_PRIV_H_INCLUDED */

0 commit comments

Comments
 (0)