GDAL
gdalmultidim_priv.h
1/******************************************************************************
2 * Name: gdalmultidim_priv.h
3 * Project: GDAL Core
4 * Purpose: GDAL private header for multidimensional support
5 * Author: Even Rouault <even.rouault at spatialys.com>
6 *
7 ******************************************************************************
8 * Copyright (c) 2023, Even Rouault <even.rouault at spatialys.com>
9 *
10 * SPDX-License-Identifier: MIT
11 ****************************************************************************/
12
13#ifndef GDALMULTIDIM_PRIV_INCLUDED
14#define GDALMULTIDIM_PRIV_INCLUDED
15
16#include "gdal_priv.h"
17
19
20// For C API
21
22struct GDALExtendedDataTypeHS
23{
24 std::unique_ptr<GDALExtendedDataType> m_poImpl;
25
26 explicit GDALExtendedDataTypeHS(GDALExtendedDataType *dt) : m_poImpl(dt)
27 {
28 }
29};
30
31struct GDALEDTComponentHS
32{
33 std::unique_ptr<GDALEDTComponent> m_poImpl;
34
35 explicit GDALEDTComponentHS(const GDALEDTComponent &component)
36 : m_poImpl(new GDALEDTComponent(component))
37 {
38 }
39};
40
41struct GDALGroupHS
42{
43 std::shared_ptr<GDALGroup> m_poImpl;
44
45 explicit GDALGroupHS(const std::shared_ptr<GDALGroup> &poGroup)
46 : m_poImpl(poGroup)
47 {
48 }
49};
50
51struct GDALMDArrayHS
52{
53 std::shared_ptr<GDALMDArray> m_poImpl;
54
55 explicit GDALMDArrayHS(const std::shared_ptr<GDALMDArray> &poArray)
56 : m_poImpl(poArray)
57 {
58 }
59};
60
61struct GDALAttributeHS
62{
63 std::shared_ptr<GDALAttribute> m_poImpl;
64
65 explicit GDALAttributeHS(const std::shared_ptr<GDALAttribute> &poAttr)
66 : m_poImpl(poAttr)
67 {
68 }
69};
70
71struct GDALDimensionHS
72{
73 std::shared_ptr<GDALDimension> m_poImpl;
74
75 explicit GDALDimensionHS(const std::shared_ptr<GDALDimension> &poDim)
76 : m_poImpl(poDim)
77 {
78 }
79};
80
81class GDALMDIAsAttribute final : public GDALAttribute
82{
83 std::vector<std::shared_ptr<GDALDimension>> m_dims{};
84 const GDALExtendedDataType m_dt = GDALExtendedDataType::CreateString();
85 std::string m_osValue;
86
87 public:
88 GDALMDIAsAttribute(const std::string &name, const std::string &value)
89 : GDALAbstractMDArray(std::string(), name),
90 GDALAttribute(std::string(), name), m_osValue(value)
91 {
92 }
93
94 const std::vector<std::shared_ptr<GDALDimension>> &
95 GetDimensions() const override;
96
97 const GDALExtendedDataType &GetDataType() const override
98 {
99 return m_dt;
100 }
101
102 bool IRead(const GUInt64 *, const size_t *, const GInt64 *,
103 const GPtrDiff_t *, const GDALExtendedDataType &bufferDataType,
104 void *pDstBuffer) const override
105 {
106 const char *pszStr = m_osValue.c_str();
107 GDALExtendedDataType::CopyValue(&pszStr, m_dt, pDstBuffer,
108 bufferDataType);
109 return true;
110 }
111};
112
114
115#endif // GDALMULTIDIM_PRIV_INCLUDED
virtual const std::vector< std::shared_ptr< GDALDimension > > & GetDimensions() const =0
Return the dimensions of an attribute/array.
virtual const GDALExtendedDataType & GetDataType() const =0
Return the data type of an attribute/array.
Class modeling an attribute that has a name, a value and a type, and is typically used to describe a ...
Definition gdal_multidim.h:729
static bool CopyValue(const void *pSrc, const GDALExtendedDataType &srcType, void *pDst, const GDALExtendedDataType &dstType)
Convert a value from a source type to a destination type.
Definition gdalmultidim.cpp:1721
static GDALExtendedDataType CreateString(size_t nMaxStringLength=0, GDALExtendedDataTypeSubType eSubType=GEDTST_NONE)
Return a new GDALExtendedDataType of class GEDTC_STRING.
Definition gdalmultidim.cpp:10768
int GPtrDiff_t
Integer type large enough to hold the difference between 2 addresses.
Definition cpl_port.h:246
GIntBig GInt64
Signed 64 bit integer type.
Definition cpl_port.h:226
GUIntBig GUInt64
Unsigned 64 bit integer type.
Definition cpl_port.h:228
This file is legacy since GDAL 3.12, but will be kept at least in the whole GDAL 3....