GDALExtendedDataType C++ API

GDALExtendedDataType class

class GDALExtendedDataType

Class used to represent potentially complex data types.

Several classes of data types are supported: numeric (based on GDALDataType), compound or string.

Since

GDAL 3.1

Public Functions

GDALExtendedDataType(const GDALExtendedDataType &other)

Copy constructor.

GDALExtendedDataType &operator=(GDALExtendedDataType &&other)

Move assignment.

bool operator==(const GDALExtendedDataType &other) const

Equality operator.

This is the same as the C function GDALExtendedDataTypeEquals().

bool operator!=(const GDALExtendedDataType &other) const

Non-equality operator.

const std::string &GetName() const

Return type name.

This is the same as the C funtion GDALExtendedDataTypeGetName()

GDALExtendedDataTypeClass GetClass() const

Return type class.

This is the same as the C funtion GDALExtendedDataTypeGetClass()

GDALDataType GetNumericDataType() const

Return numeric data type (only valid when GetClass() == GEDTC_NUMERIC)

This is the same as the C funtion GDALExtendedDataTypeGetNumericDataType()

const std::vector<std::unique_ptr<GDALEDTComponent>> &GetComponents() const

Return the components of the data type (only valid when GetClass() == GEDTC_COMPOUND)

This is the same as the C funtion GDALExtendedDataTypeGetComponents()

size_t GetSize() const

Return data type size in bytes.

For a string, this will be size of a char* pointer.

This is the same as the C funtion GDALExtendedDataTypeGetSize()

size_t GetMaxStringLength() const

Return the maximum length of a string in bytes.

0 indicates unknown/unlimited string.

bool CanConvertTo(const GDALExtendedDataType &other) const

Return whether this data type can be converted to the other one.

This is the same as the C function GDALExtendedDataTypeCanConvertTo().

Parameters
  • other: Target data type for the conversion being considered.

bool NeedsFreeDynamicMemory() const

Return whether the data type holds dynamically allocated memory, that needs to be freed with FreeDynamicMemory().

void FreeDynamicMemory(void *pBuffer) const

Release the dynamic memory (strings typically) from a raw value.

This is the same as the C function GDALExtendedDataTypeFreeDynamicMemory().

Parameters
  • pBuffer: Raw buffer of a single element of an attribute or array value.

Public Static Functions

GDALExtendedDataType Create(GDALDataType eType)

Return a new GDALExtendedDataType of class GEDTC_NUMERIC.

This is the same as the C function GDALExtendedDataTypeCreate()

Parameters
  • eType: Numeric data type.

GDALExtendedDataType Create(const std::string &osName, size_t nTotalSize, std::vector<std::unique_ptr<GDALEDTComponent>> &&components)

Return a new GDALExtendedDataType of class GEDTC_COMPOUND.

This is the same as the C function GDALExtendedDataTypeCreateCompound()

Parameters
  • osName: Type name.

  • nTotalSize: Total size of the type in bytes. Should be large enough to store all components.

  • components: Components of the compound type.

GDALExtendedDataType CreateString(size_t nMaxStringLength = 0)

Return a new GDALExtendedDataType of class GEDTC_STRING.

This is the same as the C function GDALExtendedDataTypeCreateString().

Parameters
  • nMaxStringLength: maximum length of a string in bytes. 0 if unknown/unlimited

bool CopyValue(const void *pSrc, const GDALExtendedDataType &srcType, void *pDst, const GDALExtendedDataType &dstType)

Convert a value from a source type to a destination type.

If dstType is GEDTC_STRING, the written value will be a pointer to a char*, that must be freed with CPLFree().

GDALEDTComponent class

class GDALEDTComponent

Class for a component of a compound extended data type.

Since

GDAL 3.1

Public Functions

GDALEDTComponent(const std::string &name, size_t offset, const GDALExtendedDataType &type)

constructor of a GDALEDTComponent

This is the same as the C function GDALEDTComponendCreate()

Parameters
  • name: Component name

  • offset: Offset in byte of the component in the compound data type. In case of nesting of compound data type, this should be the offset to the immediate belonging data type, not to the higher level one.

  • type: Component data type.

GDALEDTComponent(const GDALEDTComponent&)

Copy constructor.

bool operator==(const GDALEDTComponent &other) const

Equality operator.

const std::string &GetName() const

Return the name.

This is the same as the C function GDALEDTComponentGetName().

size_t GetOffset() const

Return the offset (in bytes) of the component in the compound data type.

This is the same as the C function GDALEDTComponentGetOffset().

const GDALExtendedDataType &GetType() const

Return the data type of the component.

This is the same as the C function GDALEDTComponentGetType().