|
NEP 4.3.0
NetCDF Expansion Pack
|
nxCDF user-defined types and NC_STRING support. More...
#include "nxcdf/nxcdf.h"#include "config.h"#include <stdlib.h>#include <string.h>#include <assert.h>#include "nxcdf_internal.h"Macros | |
| #define | NXCDF_ENUM_BASE_OK(t) |
Functions | |
| int | NXCDF_get_type_size (nc_type xtype, size_t *sizep) |
| Return the in-memory size of an atomic type — a thin public wrapper over NXCDF_type_size(). | |
| static int | check_type_write (NXCDF_FILE_INFO_T *file, NC_GRP_INFO_T *grp) |
| Check that the file may have a user-defined type defined now. | |
| static int | get_grp_and_file (int ncid, NC_FILE_INFO_T **h5, NC_GRP_INFO_T **grp, NXCDF_FILE_INFO_T **filep) |
| Resolve file state and the group an ncid refers to. | |
| int | nxcdf_find_type (NC_GRP_INFO_T *grp, nc_type xtype, NC_TYPE_INFO_T **typep) |
| Find the user-defined type record an nc_type id refers to. | |
| int | nxcdf_type_size (NC_GRP_INFO_T *grp, nc_type xtype, size_t *sizep) |
| Resolve the in-memory element size of any supported type. | |
| int | nxcdf_file_type (NC_GRP_INFO_T *grp, nc_type xtype, hid_t *typep) |
| Produce an owned HDF5 datatype with the type's file layout. | |
| static int | user_mem_type (NC_GRP_INFO_T *grp, NC_TYPE_INFO_T *type, hid_t *typep) |
| Build an owned HDF5 memory datatype for a user-defined type. | |
| int | nxcdf_memory_type (NC_GRP_INFO_T *grp, nc_type xtype, hid_t *typep) |
| Produce an owned HDF5 memory datatype for any supported type. | |
| int | nxcdf_hdf_type_match (NC_GRP_INFO_T *grp, hid_t htype, NC_TYPE_INFO_T **typep) |
| Resolve an HDF5 datatype to a registered committed user type by object identity. | |
| static hid_t | base_hdf_type (nc_type xtype) |
| Map an atomic nc_type to a fresh HDF5 datatype hid_t. | |
| void | nxcdf_free_type_info (NC_TYPE_INFO_T *type) |
| Release a type's nxCDF-private record and its HDF5 datatype handle, if any. | |
| static int | attach_hdf_type (NC_TYPE_INFO_T *type, hid_t hdf) |
| Record a built HDF5 datatype on a type, still uncommitted. | |
| static int | commit_hdf_type (NC_GRP_INFO_T *grp, NC_TYPE_INFO_T *type, hid_t hdf) |
| Commit (name and store) an HDF5 datatype into a group. | |
| int | NXCDF_def_compound (int ncid, size_t size, const char *name, nc_type *typeidp) |
| Define a compound type — the nc_def_compound() dispatch entry. | |
| static int | type_graph_contains (NC_FILE_INFO_T *h5, NC_TYPE_INFO_T *t, NC_TYPE_INFO_T *target, NClist *seen) |
Check whether target appears anywhere in t's member graph — the cycle check for compound insertion and vlen bases. | |
| static int | type_graph_has_forbidden (NC_FILE_INFO_T *h5, NC_TYPE_INFO_T *t, NClist *seen) |
Check whether t's type graph contains a reference member. | |
| static int | check_graph_clean (NC_FILE_INFO_T *h5, NC_TYPE_INFO_T *t) |
| Reject a type graph containing references. | |
| static int | member_type_ok (NXCDF_FILE_INFO_T *file, NC_GRP_INFO_T *grp, nc_type xtype, NC_TYPE_INFO_T *container) |
| Validate a compound member's element type. | |
| static int | field_hdf_type (NC_GRP_INFO_T *grp, const NC_FIELD_INFO_T *f, hid_t *typep, int *ownedp) |
| Build the HDF5 datatype for one compound field. | |
| int | NXCDF_insert_compound (int ncid, nc_type typeid, const char *name, size_t offset, nc_type xtype) |
| Insert a scalar field into a compound type — the nc_insert_compound() dispatch entry. | |
| int | NXCDF_insert_array_compound (int ncid, nc_type typeid, const char *name, size_t offset, nc_type xtype, int ndims, const int *dim_sizesp) |
| Insert a scalar or fixed-size array field into a compound type — the nc_insert_array_compound() dispatch entry. | |
| int | NXCDF_inq_compound_field (int ncid, nc_type typeid, int fieldid, char *name, size_t *offsetp, nc_type *fieldtypep, int *ndimsp, int *dim_sizesp) |
| Inquire a field of a compound type — the nc_inq_compound_field() dispatch entry. | |
| int | NXCDF_inq_compound_fieldindex (int ncid, nc_type typeid, const char *name, int *fieldidxp) |
| Get a compound field's index by name — the nc_inq_compound_fieldindex() dispatch entry. | |
| int | NXCDF_def_vlen (int ncid, const char *name, nc_type base_typeid, nc_type *typeidp) |
| Define a variable-length type — the nc_def_vlen() dispatch entry. | |
| static int | find_vlen_type (int ncid, nc_type typeid, NC_FILE_INFO_T **h5p, NC_TYPE_INFO_T **typep) |
| Resolve a vlen type record from a typeid — shared prologue for the vlen element helpers. | |
| int | NXCDF_put_vlen_element (int ncid, int typeid, void *vlen_element, size_t len, const void *data) |
| Write a vlen element value — the nc_put_vlen_element() dispatch entry. | |
| int | NXCDF_get_vlen_element (int ncid, int typeid, const void *vlen_element, size_t *lenp, void *data) |
| Read a vlen element value — the nc_get_vlen_element() dispatch entry. | |
| int | NXCDF_def_enum (int ncid, nc_type base_typeid, const char *name, nc_type *typeidp) |
| Define an enum type — the nc_def_enum() dispatch entry. | |
| int | NXCDF_insert_enum (int ncid, nc_type typeid, const char *name, const void *value) |
| Insert a member into an enum type — the nc_insert_enum() dispatch entry. | |
| int | NXCDF_inq_enum_member (int ncid, nc_type typeid, int idx, char *name, void *value) |
| Inquire an enum member by index — the nc_inq_enum_member() dispatch entry. | |
| int | NXCDF_inq_enum_ident (int ncid, nc_type typeid, long long value, char *identifier) |
| Get an enum member name by value — the nc_inq_enum_ident() dispatch entry. | |
| int | NXCDF_def_opaque (int ncid, size_t size, const char *name, nc_type *typeidp) |
| Define an opaque type — the nc_def_opaque() dispatch entry. | |
| static int | commit_one_type (NC_GRP_INFO_T *grp, NC_TYPE_INFO_T *type) |
| Commit one previously-attached-but-uncommitted type. | |
| static int | rebuild_compound_transient (NC_GRP_INFO_T *grp, NC_TYPE_INFO_T *type) |
| Rebuild a compound's transient HDF5 datatype from its field metadata. | |
| static NC_GRP_INFO_T * | find_type_owner (NC_GRP_INFO_T *grp, NC_TYPE_INFO_T *type) |
| Find the group whose type index owns a record. | |
| static int | rebuild_vlen_transient (NC_GRP_INFO_T *grp, NC_TYPE_INFO_T *type) |
| Rebuild a vlen's transient HDF5 datatype around its committed base. | |
| static int | commit_type_tree (NC_FILE_INFO_T *h5, NC_GRP_INFO_T *grp, NC_TYPE_INFO_T *type) |
| Commit one type after its dependencies. | |
| static int | commit_types_in_grp (NC_FILE_INFO_T *h5, NC_GRP_INFO_T *grp) |
| Recursively commit all uncommitted types in a group tree. | |
| int | NXCDF_write_types (NC_FILE_INFO_T *h5) |
| Commit every pending user-defined type — called by NXCDF__enddef() before the metadata writer runs, so committed datatypes exist when variable datasets are created. | |
| int | NXCDF_inq_user_type (int ncid, nc_type typeid, char *name, size_t *sizep, nc_type *base_typep, size_t *nfieldsp, int *classp) |
| Inquire a user-defined type — the nc_inq_user_type() dispatch entry. | |
| int | NXCDF_inq_typeid (int ncid, const char *name, nc_type *typeidp) |
| Get a type's id by name — the nc_inq_typeid() dispatch entry. | |
| static int | types_equal (NC_FILE_INFO_T *h5_1, NC_TYPE_INFO_T *t1, NC_FILE_INFO_T *h5_2, NC_TYPE_INFO_T *t2) |
| Structural comparison for nc_inq_type_equal(). | |
| int | NXCDF_inq_type_equal (int ncid1, nc_type typeid1, int ncid2, nc_type typeid2, int *equalp) |
| Compare two types for equality — the nc_inq_type_equal() dispatch entry. | |
| int | NXCDF_inq_typeids (int ncid, int *ntypes, int *typeids) |
| Get the type ids of the user-defined types in a group — the nc_inq_typeids() dispatch entry. | |
| int | nxcdf_storage_memory_type (hid_t memory, hid_t storage, hid_t *typep) |
| Preserve storage string character sets in a native memory layout. | |
| int | nxcdf_copy_data (NC *nc, nc_type xtype, const void *src, size_t count, void *dst) |
| Deep-copy values with initialized, reclaim-safe partial results. | |
nxCDF user-defined types and NC_STRING support.
| #define NXCDF_ENUM_BASE_OK | ( | t | ) |
|
static |
Record a built HDF5 datatype on a type, still uncommitted.
HDF5 distinguishes a "transient" datatype (exists only in memory) from a "committed" one (named and stored in the file). Types being defined stay transient so members can still be inserted; they are committed later at _enddef by NXCDF_write_types() (or immediately for vlen/opaque, which have no members).
| type | In-memory type record. |
| hdf | HDF5 datatype identifier to attach (ownership stays with the record). |
|
static |
Map an atomic nc_type to a fresh HDF5 datatype hid_t.
Convenience wrapper over NXCDF_map_hdf_type() returning -1 instead of an error code. The caller owns the returned datatype.
| xtype | NetCDF atomic type. |
|
static |
Reject a type graph containing references.
| h5 | NetCDF-4 file state. |
| t | Type record to inspect. |
|
static |
Check that the file may have a user-defined type defined now.
User-defined types (compound, vlen, enum, opaque) require define mode and write access. They are an enhanced-model feature, so NC_CLASSIC_MODEL files reject them; NC_NETCDF4_MODEL files permit the standard enhanced-model types because upstream netcdf-c files can represent them.
| file | nxCDF file state. |
| grp | Group (currently unused). |
|
static |
Commit (name and store) an HDF5 datatype into a group.
Committed datatypes are named objects in the file, like variables — this is what makes a user-defined type persistent. Falls back to the root group when the group's own HDF5 handle isn't open yet.
| grp | Group. |
| type | In-memory type record. |
| hdf | HDF5 datatype to commit. |
|
static |
Commit one previously-attached-but-uncommitted type.
Used at _enddef for compounds and enums, whose HDF5 datatypes were built transient so members could be inserted during define mode.
| grp | Group the type belongs to. |
| type | In-memory type record. |
|
static |
Commit one type after its dependencies.
For compounds, every uncommitted user-defined member type is committed first (in its own group), then the container's transient datatype is rebuilt so stored members are shared references to the committed datatypes. A vlen whose base is a user type gets the same treatment: commit the base first, then rebuild the vlen around it. Cycles cannot form — insertion rejects them — so plain recursion is sufficient.
| h5 | NetCDF-4 file state. |
| grp | Group the type belongs to. |
| type | Type record. |
|
static |
Recursively commit all uncommitted types in a group tree.
| h5 | NetCDF-4 file state. |
| grp | Group. |
|
static |
Build the HDF5 datatype for one compound field.
Resolves the element type (atomic via NXCDF_map_hdf_type, or a user-defined type's own HDF5 datatype) and wraps it in H5Tarray_create2 when the field is an array. The returned id is owned by the caller only when *ownedp is nonzero; a borrowed committed member datatype stays owned by its type record.
| grp | Group resolving member type ids. |
| f | Field record. |
| typep | Destination for the HDF5 datatype. |
| ownedp | Destination for the ownership flag. |
|
static |
Find the group whose type index owns a record.
| grp | Group to walk recursively. |
| type | Type record to locate. |
|
static |
Resolve a vlen type record from a typeid — shared prologue for the vlen element helpers.
| ncid | NetCDF file identifier. |
| typeid | Type id (must name a NC_VLEN user type). |
| h5p | Destination for the NetCDF-4 file state. |
| typep | Destination for the borrowed type record. |
|
static |
Resolve file state and the group an ncid refers to.
Shared prologue for the def_* functions: NXCDF_get_file() maps the ncid to file state, nc4_find_nc4_grp finds the in-memory group (types are defined per-group in the enhanced model).
| ncid | NetCDF file identifier. |
| h5 | Destination for the NetCDF-4 file state. |
| grp | Destination for the group. |
| filep | Destination for the nxCDF file state; may be NULL. |
|
static |
Validate a compound member's element type.
Atomic members use the file's compatibility rules, excluding NC_STD_REF. Compounds, enums, opaques and vlens all nest, including string leaves, but their member graph must contain no references and must not contain the container itself.
| file | nxCDF file state. |
| grp | Group the container type lives in (visibility scope). |
| xtype | Candidate member element type. |
| container | Compound record receiving the member. |
| int nxcdf_copy_data | ( | NC * | nc, |
| nc_type | xtype, | ||
| const void * | src, | ||
| size_t | count, | ||
| void * | dst ) |
Deep-copy values with initialized, reclaim-safe partial results.
| nc | File controller owning user-type metadata. |
| xtype | Atomic or user-defined type. |
| src | Borrowed source element buffer. |
| count | Number of elements. |
| dst | Uninitialized destination element buffer. |
| int NXCDF_def_compound | ( | int | ncid, |
| size_t | size, | ||
| const char * | name, | ||
| nc_type * | typeidp ) |
Define a compound type — the nc_def_compound() dispatch entry.
A compound type is a C-struct-like record of named fields at byte offsets. Creates an empty transient H5T_COMPOUND, registers the NC_TYPE_INFO_T, and attaches the datatype uncommitted — fields are added by NXCDF_insert_compound() and the type is committed at _enddef.
| ncid | NetCDF file identifier. |
| size | Size of the compound type in bytes. |
| name | Type name. |
| typeidp | Destination for the new type id. |
| int NXCDF_def_enum | ( | int | ncid, |
| nc_type | base_typeid, | ||
| const char * | name, | ||
| nc_type * | typeidp ) |
Define an enum type — the nc_def_enum() dispatch entry.
An enum is named constants over an integer base type. Creates a transient H5Tenum_create datatype and attaches it uncommitted; members are added by NXCDF_insert_enum() and the type is committed at _enddef.
| ncid | NetCDF file identifier. |
| base_typeid | Integer base type id. |
| name | Type name. |
| typeidp | Destination for the new type id. |
| int NXCDF_def_opaque | ( | int | ncid, |
| size_t | size, | ||
| const char * | name, | ||
| nc_type * | typeidp ) |
Define an opaque type — the nc_def_opaque() dispatch entry.
An opaque type is a fixed-size blob the library does not interpret. Like vlens it has no members, so the H5T_OPAQUE datatype is committed immediately.
| ncid | NetCDF file identifier. |
| size | Size of the opaque data in bytes. |
| name | Type name. |
| typeidp | Destination for the new type id. |
| int NXCDF_def_vlen | ( | int | ncid, |
| const char * | name, | ||
| nc_type | base_typeid, | ||
| nc_type * | typeidp ) |
Define a variable-length type — the nc_def_vlen() dispatch entry.
A vlen variable stores a different number of elements per datum (nc_vlen_t handles in memory, heap-allocated on disk). The base type may be any supported atomic type except NC_STD_REF, or a visible user-defined type — compounds, enums, opaques and other vlens all nest.
When the base is still uncommitted (a compound whose fields may still grow), the vlen's datatype stays transient and commit is deferred to _enddef, where commit_type_tree() commits the base first and rebuilds the vlen around it; vlens over committed bases commit immediately, like opaques.
The public nc_vlen_t descriptor and HDF5's hvl_t must have the same layout — I/O moves descriptors verbatim.
| ncid | NetCDF file identifier. |
| name | Type name. |
| base_typeid | Base type of the vlen elements. |
| typeidp | Destination for the new type id. |
| int nxcdf_file_type | ( | NC_GRP_INFO_T * | grp, |
| nc_type | xtype, | ||
| hid_t * | typep ) |
Produce an owned HDF5 datatype with the type's file layout.
Atomic types map through NXCDF_map_hdf_type(); user-defined types copy the record's committed (or still-transient) HDF5 datatype so the dataset or attribute links to the named type. The caller owns the returned handle and must H5Tclose it.
| grp | Group the type is being used from. |
| xtype | Type id. |
| typep | Destination for an owned HDF5 datatype. |
| int nxcdf_find_type | ( | NC_GRP_INFO_T * | grp, |
| nc_type | xtype, | ||
| NC_TYPE_INFO_T ** | typep ) |
Find the user-defined type record an nc_type id refers to.
Type visibility flows downward in the enhanced model: a type defined in a group is usable in that group and its descendants, never in siblings or ancestors. The search therefore walks the group and its ancestors only; the returned record is borrowed — the caller must not free it or alter its reference count.
| grp | Group the type is being used from. |
| xtype | Type id (must be NC_FIRSTUSERTYPEID or above). |
| typep | Destination for the borrowed record. |
| void nxcdf_free_type_info | ( | NC_TYPE_INFO_T * | type | ) |
Release a type's nxCDF-private record and its HDF5 datatype handle, if any.
nc4_type_free() knows nothing about format_type_info, so every definition failure path and the file-close walk must dispose of it separately. Safe on a type with no private record.
| type | In-memory type record. |
| int NXCDF_get_type_size | ( | nc_type | xtype, |
| size_t * | sizep ) |
Return the in-memory size of an atomic type — a thin public wrapper over NXCDF_type_size().
| xtype | NetCDF atomic type. |
| sizep | Destination for the size. |
| int NXCDF_get_vlen_element | ( | int | ncid, |
| int | typeid, | ||
| const void * | vlen_element, | ||
| size_t * | lenp, | ||
| void * | data ) |
Read a vlen element value — the nc_get_vlen_element() dispatch entry.
Reports the descriptor's element count and copies the payload into the caller's buffer using the base type's real in-memory size. The copy is shallow: for a vlen whose base is itself dynamic (a nested vlen, or a compound containing vlen members) the copied descriptors still alias the source element's inner payloads. Those aliases must not be reclaimed independently — callers wanting an owned deep copy use nc_copy_data().
| ncid | NetCDF file identifier. |
| typeid | Vlen type id. |
| vlen_element | Source nc_vlen_t descriptor. |
| lenp | Destination for the element count (required). |
| data | Destination for the element data (required when the descriptor is non-empty). |
| int nxcdf_hdf_type_match | ( | NC_GRP_INFO_T * | grp, |
| hid_t | htype, | ||
| NC_TYPE_INFO_T ** | typep ) |
Resolve an HDF5 datatype to a registered committed user type by object identity.
Datasets and attributes created from a committed datatype keep a reference to that named object; comparing the HDF5 object token of htype against every committed type visible from grp (the group and its ancestors) recovers the exact NC_TYPE_INFO_T — matching on H5Tequal alone would conflate distinct named types with equal shapes.
| grp | Group the datatype is being used from. |
| htype | HDF5 datatype (need not be committed itself). |
| typep | Destination for the borrowed type record. |
| int NXCDF_inq_compound_field | ( | int | ncid, |
| nc_type | typeid, | ||
| int | fieldid, | ||
| char * | name, | ||
| size_t * | offsetp, | ||
| nc_type * | fieldtypep, | ||
| int * | ndimsp, | ||
| int * | dim_sizesp ) |
Inquire a field of a compound type — the nc_inq_compound_field() dispatch entry.
| ncid | NetCDF file identifier. |
| typeid | Compound type id. |
| fieldid | Field index. |
| name | Destination for the field name. |
| offsetp | Destination for the field offset. |
| fieldtypep | Destination for the field type. |
| ndimsp | Destination for the field rank. |
| dim_sizesp | Destination for the field dimension sizes. |
| int NXCDF_inq_compound_fieldindex | ( | int | ncid, |
| nc_type | typeid, | ||
| const char * | name, | ||
| int * | fieldidxp ) |
Get a compound field's index by name — the nc_inq_compound_fieldindex() dispatch entry.
| ncid | NetCDF file identifier. |
| typeid | Compound type id. |
| name | Field name. |
| fieldidxp | Destination for the field index. |
| int NXCDF_inq_enum_ident | ( | int | ncid, |
| nc_type | typeid, | ||
| long long | value, | ||
| char * | identifier ) |
Get an enum member name by value — the nc_inq_enum_ident() dispatch entry.
| ncid | NetCDF file identifier. |
| typeid | Enum type id. |
| value | Member value. |
| identifier | Destination for the member name. |
| int NXCDF_inq_enum_member | ( | int | ncid, |
| nc_type | typeid, | ||
| int | idx, | ||
| char * | name, | ||
| void * | value ) |
Inquire an enum member by index — the nc_inq_enum_member() dispatch entry.
| ncid | NetCDF file identifier. |
| typeid | Enum type id. |
| idx | Member index. |
| name | Destination for the member name. |
| value | Destination for the member value. |
| int NXCDF_inq_type_equal | ( | int | ncid1, |
| nc_type | typeid1, | ||
| int | ncid2, | ||
| nc_type | typeid2, | ||
| int * | equalp ) |
Compare two types for equality — the nc_inq_type_equal() dispatch entry.
Two types count as equal when they are the same in-memory record or structurally equal: same class, size and member layout/base/member values, recursively for nested members.
| ncid1 | NetCDF file identifier of the first type. |
| typeid1 | First type id. |
| ncid2 | NetCDF file identifier of the second type. |
| typeid2 | Second type id. |
| equalp | Destination for the nonzero-if-equal flag. |
| int NXCDF_inq_typeid | ( | int | ncid, |
| const char * | name, | ||
| nc_type * | typeidp ) |
Get a type's id by name — the nc_inq_typeid() dispatch entry.
Type names are visible file-wide in netCDF semantics; the lookup recurses through the group tree via netcdf-c's nc4_rec_find_named_type.
| ncid | NetCDF file identifier. |
| name | Type name. |
| typeidp | Destination for the type id. |
| int NXCDF_inq_typeids | ( | int | ncid, |
| int * | ntypes, | ||
| int * | typeids ) |
Get the type ids of the user-defined types in a group — the nc_inq_typeids() dispatch entry.
| ncid | NetCDF file identifier. |
| ntypes | Destination for the number of types. |
| typeids | Destination for the type ids. |
| int NXCDF_inq_user_type | ( | int | ncid, |
| nc_type | typeid, | ||
| char * | name, | ||
| size_t * | sizep, | ||
| nc_type * | base_typep, | ||
| size_t * | nfieldsp, | ||
| int * | classp ) |
Inquire a user-defined type — the nc_inq_user_type() dispatch entry.
| ncid | NetCDF file identifier. |
| typeid | Type id. |
| name | Destination for the type name. |
| sizep | Destination for the type size. |
| base_typep | Destination for the base type id. |
| nfieldsp | Destination for the number of fields/members. |
| classp | Destination for the type class. |
| int NXCDF_insert_array_compound | ( | int | ncid, |
| nc_type | typeid, | ||
| const char * | name, | ||
| size_t | offset, | ||
| nc_type | xtype, | ||
| int | ndims, | ||
| const int * | dim_sizesp ) |
Insert a scalar or fixed-size array field into a compound type — the nc_insert_array_compound() dispatch entry.
Members may be supported atomic types (excluding NC_STD_REF) or visible user-defined types, including strings and dynamic nesting. Validation happens entirely before H5Tinsert and the metadata update, so a rejected call changes nothing.
| ncid | NetCDF file identifier. |
| typeid | Compound type id. |
| name | Field name. |
| offset | Field offset in bytes. |
| xtype | NetCDF type of the field elements. |
| ndims | Number of array dimensions; 0 inserts a scalar. |
| dim_sizesp | Array dimension sizes (required when ndims>0). |
| int NXCDF_insert_compound | ( | int | ncid, |
| nc_type | typeid, | ||
| const char * | name, | ||
| size_t | offset, | ||
| nc_type | xtype ) |
Insert a scalar field into a compound type — the nc_insert_compound() dispatch entry.
Thin wrapper over NXCDF_insert_array_compound() with rank zero, matching upstream's delegation.
| ncid | NetCDF file identifier. |
| typeid | Compound type id. |
| name | Field name. |
| offset | Field offset in bytes. |
| xtype | NetCDF type of the field. |
| int NXCDF_insert_enum | ( | int | ncid, |
| nc_type | typeid, | ||
| const char * | name, | ||
| const void * | value ) |
Insert a member into an enum type — the nc_insert_enum() dispatch entry.
The member value arrives as raw bytes in the enum's base type; it is widened to long long for H5Tenum_insert and stored byte-for-byte in the in-memory record.
| ncid | NetCDF file identifier. |
| typeid | Enum type id. |
| name | Member name. |
| value | Member value. |
| int nxcdf_memory_type | ( | NC_GRP_INFO_T * | grp, |
| nc_type | xtype, | ||
| hid_t * | typep ) |
Produce an owned HDF5 memory datatype for any supported type.
Atomic types delegate to NXCDF_memory_type(); ids at or above NC_FIRSTUSERTYPEID resolve through nxcdf_find_type() and build the memory layout described by user_mem_type(). The caller owns the returned handle and must H5Tclose it.
| grp | Group the type is being used from. |
| xtype | Type id. |
| typep | Destination for an owned HDF5 datatype. |
| int NXCDF_put_vlen_element | ( | int | ncid, |
| int | typeid, | ||
| void * | vlen_element, | ||
| size_t | len, | ||
| const void * | data ) |
Write a vlen element value — the nc_put_vlen_element() dispatch entry.
Fills the caller's nc_vlen_t descriptor with the element count and a borrowed pointer to data — nothing is copied and no ownership is taken. The payload must stay valid until the write it feeds (typically nc_put_vara) has completed.
| ncid | NetCDF file identifier. |
| typeid | Vlen type id. |
| vlen_element | Destination nc_vlen_t descriptor. |
| len | Number of elements. |
| data | Element data (required when len is nonzero). |
| int nxcdf_storage_memory_type | ( | hid_t | memory, |
| hid_t | storage, | ||
| hid_t * | typep ) |
Preserve storage string character sets in a native memory layout.
| memory | Borrowed datatype describing the caller's layout. |
| storage | Borrowed stored datatype with matching members. |
| typep | Owned result, closed by the caller. |
| int nxcdf_type_size | ( | NC_GRP_INFO_T * | grp, |
| nc_type | xtype, | ||
| size_t * | sizep ) |
Resolve the in-memory element size of any supported type.
Atomic ids delegate to NXCDF_type_size(); ids at or above NC_FIRSTUSERTYPEID resolve through nxcdf_find_type() and return the type record's size.
| grp | Group the type is being used from. |
| xtype | Type id. |
| sizep | Destination for the size in bytes. |
| int NXCDF_write_types | ( | NC_FILE_INFO_T * | h5 | ) |
Commit every pending user-defined type — called by NXCDF__enddef() before the metadata writer runs, so committed datatypes exist when variable datasets are created.
| h5 | NetCDF-4 file state. |
|
static |
Rebuild a compound's transient HDF5 datatype from its field metadata.
Called at commit time, after the compound's dependency member types have themselves been committed: building members from the now- committed HDF5 datatypes makes the stored members shared datatype references (as upstream netcdf-c writes), rather than anonymous copies of what were transient ids at insert time.
| grp | Group the type belongs to (visibility scope). |
| type | Compound type record. |
|
static |
Rebuild a vlen's transient HDF5 datatype around its committed base.
Called at commit time when the vlen's base is a user-defined type: building the vlen from the now-committed base datatype makes the stored base a shared datatype reference (as upstream netcdf-c writes), rather than an anonymous copy of the transient id the base had when nc_def_vlen ran.
| grp | Group the type belongs to (visibility scope). |
| type | Vlen type record. |
|
static |
Check whether target appears anywhere in t's member graph — the cycle check for compound insertion and vlen bases.
Member types form a DAG by construction (every insert runs this check), so a depth-first walk through user-typed fields and vlen bases is enough; seen bounds the recursion on a malformed graph.
| h5 | NetCDF-4 file state used to resolve member type ids. |
| t | Type record whose member graph is walked. |
| target | Type record being searched for. |
| seen | Scratch list of already-visited records (may be NULL; allocated lazily by the caller). |
target is reachable from t's members.
|
static |
Check whether t's type graph contains a reference member.
NC_STD_REF tokens cannot legally nest inside compounds or vlens. String members and bases are supported. The walk covers compound fields, array elements and vlen bases recursively; seen bounds the recursion on a malformed graph.
| h5 | NetCDF-4 file state used to resolve member type ids. |
| t | Type record whose member graph is walked. |
| seen | Scratch list of already-visited records. |
t.
|
static |
Structural comparison for nc_inq_type_equal().
Compares class, size and contents recursively — member type ids are file-local, so user-defined members compare by structure through each side's own type list, never by numeric id or by name.
| h5_1 | File state of the first type. |
| t1 | First type record. |
| h5_2 | File state of the second type. |
| t2 | Second type record. |
|
static |
Build an owned HDF5 memory datatype for a user-defined type.
The memory layout uses native-endian atomic components so HDF5 converts between buffer and file representations: compounds are rebuilt field-by-field at the offsets nc_inq_compound_field reports (array fields wrapped in H5Tarray_create), enums are rebuilt over the native integer base with the recorded member values, opaques are plain H5T_OPAQUE, and vlens wrap the memory base.
| grp | Group the type is being used from. |
| type | In-memory user-type record. |
| typep | Destination for an owned HDF5 datatype. |