/src/gdal/gcore/gdalmultidim_priv.h
Line | Count | Source |
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 | | |
18 | | //! @cond Doxygen_Suppress |
19 | | |
20 | | // For C API |
21 | | |
22 | | struct GDALExtendedDataTypeHS |
23 | | { |
24 | | std::unique_ptr<GDALExtendedDataType> m_poImpl; |
25 | | |
26 | 0 | explicit GDALExtendedDataTypeHS(GDALExtendedDataType *dt) : m_poImpl(dt) |
27 | 0 | { |
28 | 0 | } |
29 | | }; |
30 | | |
31 | | struct GDALEDTComponentHS |
32 | | { |
33 | | std::unique_ptr<GDALEDTComponent> m_poImpl; |
34 | | |
35 | | explicit GDALEDTComponentHS(const GDALEDTComponent &component) |
36 | 0 | : m_poImpl(new GDALEDTComponent(component)) |
37 | 0 | { |
38 | 0 | } |
39 | | }; |
40 | | |
41 | | struct GDALGroupHS |
42 | | { |
43 | | std::shared_ptr<GDALGroup> m_poImpl; |
44 | | |
45 | | explicit GDALGroupHS(const std::shared_ptr<GDALGroup> &poGroup) |
46 | 0 | : m_poImpl(poGroup) |
47 | 0 | { |
48 | 0 | } |
49 | | }; |
50 | | |
51 | | struct GDALMDArrayHS |
52 | | { |
53 | | std::shared_ptr<GDALMDArray> m_poImpl; |
54 | | |
55 | | explicit GDALMDArrayHS(const std::shared_ptr<GDALMDArray> &poArray) |
56 | 0 | : m_poImpl(poArray) |
57 | 0 | { |
58 | 0 | } |
59 | | }; |
60 | | |
61 | | struct GDALAttributeHS |
62 | | { |
63 | | std::shared_ptr<GDALAttribute> m_poImpl; |
64 | | |
65 | | explicit GDALAttributeHS(const std::shared_ptr<GDALAttribute> &poAttr) |
66 | 0 | : m_poImpl(poAttr) |
67 | 0 | { |
68 | 0 | } |
69 | | }; |
70 | | |
71 | | struct GDALDimensionHS |
72 | | { |
73 | | std::shared_ptr<GDALDimension> m_poImpl; |
74 | | |
75 | | explicit GDALDimensionHS(const std::shared_ptr<GDALDimension> &poDim) |
76 | 0 | : m_poImpl(poDim) |
77 | 0 | { |
78 | 0 | } |
79 | | }; |
80 | | |
81 | | class 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 | 0 | : GDALAbstractMDArray(std::string(), name), |
90 | 0 | GDALAttribute(std::string(), name), m_osValue(value) |
91 | 0 | { |
92 | 0 | } |
93 | | |
94 | | const std::vector<std::shared_ptr<GDALDimension>> & |
95 | | GetDimensions() const override; |
96 | | |
97 | | const GDALExtendedDataType &GetDataType() const override |
98 | 0 | { |
99 | 0 | return m_dt; |
100 | 0 | } |
101 | | |
102 | | bool IRead(const GUInt64 *, const size_t *, const GInt64 *, |
103 | | const GPtrDiff_t *, const GDALExtendedDataType &bufferDataType, |
104 | | void *pDstBuffer) const override |
105 | 0 | { |
106 | 0 | const char *pszStr = m_osValue.c_str(); |
107 | 0 | GDALExtendedDataType::CopyValue(&pszStr, m_dt, pDstBuffer, |
108 | 0 | bufferDataType); |
109 | 0 | return true; |
110 | 0 | } |
111 | | }; |
112 | | |
113 | | //! @endcond |
114 | | |
115 | | #endif // GDALMULTIDIM_PRIV_INCLUDED |