Common Pipeline Library Reference Manual
5.3.1
|
Functions | |
const char * | cpl_type_get_name (cpl_type type) |
Get a string with the name of a type, e.g. "char", "int", "float". | |
size_t | cpl_type_get_sizeof (cpl_type type) |
Compute the size of a type. |
This module provides codes for the basic types (char
, int
, float
, etc.). These type codes may be used to indicate the type of a value stored in another object, the value of a property or the pixel of an image for instance. In addition, a utility function is provided to compute the size, which is required to store a value of the type indicated by a given type code.
CPL_TYPE_FLAG_ARRAY | Flag indicating whether a type is an array or a basic type. |
CPL_TYPE_INVALID | Invalid or undetermined type. |
CPL_TYPE_CHAR | Type code corresponding to type char . |
CPL_TYPE_UCHAR | Type code corresponding to type unsigned char. |
CPL_TYPE_BOOL | Type code corresponding to the boolean type. |
CPL_TYPE_INT | Type code corresponding to type int . |
CPL_TYPE_UINT | Type code corresponding to type unsigned int. |
CPL_TYPE_LONG | Type code corresponding to type long . |
CPL_TYPE_ULONG | Type code corresponding to type unsigned long. |
CPL_TYPE_FLOAT | Type code corresponding to type float . |
CPL_TYPE_DOUBLE | Type code corresponding to type double . |
CPL_TYPE_POINTER | Type code corresponding to a pointer type. |
CPL_TYPE_STRING | Type code corresponding to a character array. |
The module
#include <cpl_type.h>
const char* cpl_type_get_name | ( | cpl_type | type | ) |
Get a string with the name of a type, e.g. "char", "int", "float".
type | Type code to be evaluated. |
size_t cpl_type_get_sizeof | ( | cpl_type | type | ) |
Compute the size of a type.
type | Type code to be evaluated. |
The function computes the atomic size of the type type. The result for fundamental types like CPL_TYPE_FLOAT
is what you would expect from the C sizeof() operator. For arrays, i.e. types having the CPL_TYPE_FLAG_ARRAY
set the returned size is not the size of a pointer to CPL_TYPE_FLOAT
for instance, but the size of its fundamental type, i.e. the returned size is same as for the type CPL_TYPE_FLOAT
.
Especially for the type CPL_TYPE_STRING
, which is explicitly defined for convenience reasons, the size returned by this function is the size of CPL_TYPE_CHAR!