NetCDF 4.8.0
Loading...
Searching...
No Matches
nc4type.c File Reference
#include "nc4internal.h"
#include "nc4dispatch.h"

Go to the source code of this file.

Macros

#define NC_BYTE_LEN   1
 
#define NC_CHAR_LEN   sizeof(char)
 
#define NC_DOUBLE_LEN   8
 
#define NC_FLOAT_LEN   4
 
#define NC_INT64_LEN   8
 
#define NC_INT_LEN   4
 
#define NC_SHORT_LEN   2
 
#define NC_STRING_LEN   sizeof(char *)
 

Functions

int nc4_get_typeclass (const NC_FILE_INFO_T *h5, nc_type xtype, int *type_class)
 
int NC4_inq_atomic_type (nc_type typeid1, char *name, size_t *size)
 
int NC4_inq_compound_field (int ncid, nc_type typeid1, int fieldid, char *name, size_t *offsetp, nc_type *field_typeidp, int *ndimsp, int *dim_sizesp)
 
int NC4_inq_compound_fieldindex (int ncid, nc_type typeid1, const char *name, int *fieldidp)
 
int NC4_inq_enum_ident (int ncid, nc_type xtype, long long value, char *identifier)
 
int NC4_inq_enum_member (int ncid, nc_type typeid1, int idx, char *identifier, void *value)
 
int NC4_inq_type (int ncid, nc_type typeid1, char *name, size_t *size)
 
EXTERNL int NC4_inq_typeid (int ncid, const char *name, nc_type *typeidp)
 
int NC4_inq_typeids (int ncid, int *ntypes, int *typeids)
 
int NC4_inq_user_type (int ncid, nc_type typeid1, char *name, size_t *size, nc_type *base_nc_typep, size_t *nfieldsp, int *classp)
 
int NC4_lookup_atomic_type (const char *name, nc_type *idp, size_t *sizep)
 

Variables

const char * nc4_atomic_name [NUM_ATOMIC_TYPES]
 
static const int nc4_atomic_size [NUM_ATOMIC_TYPES]
 

Detailed Description

This file is part of netcdf-4, a netCDF-like interface for HDF5, or a HDF5 backend for netCDF, depending on your point of view.

This file handles the nc4 user-defined type functions (i.e. compound and opaque types).

Author
Ed Hartnett

Definition in file nc4type.c.

Macro Definition Documentation

◆ NC_BYTE_LEN

#define NC_BYTE_LEN   1

Size of byte.

Definition at line 21 of file nc4type.c.

◆ NC_CHAR_LEN

#define NC_CHAR_LEN   sizeof(char)

Size of char.

Definition at line 19 of file nc4type.c.

◆ NC_DOUBLE_LEN

#define NC_DOUBLE_LEN   8

Size of double.

Definition at line 25 of file nc4type.c.

◆ NC_FLOAT_LEN

#define NC_FLOAT_LEN   4

Size of float.

Definition at line 24 of file nc4type.c.

◆ NC_INT64_LEN

#define NC_INT64_LEN   8

Size of int64.

Definition at line 26 of file nc4type.c.

◆ NC_INT_LEN

#define NC_INT_LEN   4

Size of int.

Definition at line 23 of file nc4type.c.

◆ NC_SHORT_LEN

#define NC_SHORT_LEN   2

Size of short.

Definition at line 22 of file nc4type.c.

◆ NC_STRING_LEN

#define NC_STRING_LEN   sizeof(char *)

Size of char *.

Definition at line 20 of file nc4type.c.

Function Documentation

◆ nc4_get_typeclass()

int nc4_get_typeclass ( const NC_FILE_INFO_T * h5,
nc_type xtype,
int * type_class )

Get the class of a type

Parameters
h5Pointer to the HDF5 file info struct.
xtypeNetCDF type ID.
type_classPointer that gets class of type, NC_INT, NC_FLOAT, NC_CHAR, or NC_STRING, NC_ENUM, NC_VLEN, NC_COMPOUND, or NC_OPAQUE.
Returns
NC_NOERR No error.
Author
Ed Hartnett

Definition at line 627 of file nc4type.c.

◆ NC4_inq_atomic_type()

int NC4_inq_atomic_type ( nc_type typeid1,
char * name,
size_t * size )

Get the name and size of an atomic type. For strings, 1 is returned.

Parameters
typeid1Type ID.
nameGets the name of the type.
sizeGets the size of one element of the type in bytes.
Returns
NC_NOERR No error.
NC_EBADID Bad ncid.
NC_EBADTYPE Type not found.
Author
Dennis Heimbigner

Definition at line 101 of file nc4type.c.

◆ NC4_inq_compound_field()

int NC4_inq_compound_field ( int ncid,
nc_type typeid1,
int fieldid,
char * name,
size_t * offsetp,
nc_type * field_typeidp,
int * ndimsp,
int * dim_sizesp )

Given the ncid, typeid and fieldid, get info about the field.

Parameters
ncidFile and group ID.
typeid1Type ID.
fieldidField ID.
nameGets name of field.
offsetpGets offset of field.
field_typeidpGets field type ID.
ndimspGets number of dims for this field.
dim_sizespGets the dim sizes for this field.
Returns
NC_NOERR No error.
NC_EBADID Bad ncid.
Author
Ed Hartnett

Definition at line 298 of file nc4type.c.

◆ NC4_inq_compound_fieldindex()

int NC4_inq_compound_fieldindex ( int ncid,
nc_type typeid1,
const char * name,
int * fieldidp )

Given the typeid and the name, get the fieldid.

Parameters
ncidFile and group ID.
typeid1Type ID.
nameName of field.
fieldidpPointer that gets new field ID.
Returns
NC_NOERR No error.
NC_EBADID Bad ncid.
NC_EBADTYPE Type not found.
NC_EBADFIELD Field not found.
Author
Ed Hartnett

Definition at line 349 of file nc4type.c.

◆ NC4_inq_enum_ident()

int NC4_inq_enum_ident ( int ncid,
nc_type xtype,
long long value,
char * identifier )

Get enum name from enum value. Name size will be <= NC_MAX_NAME.

Parameters
ncidFile and group ID.
xtypeType ID.
valueValue of enum.
identifierGets the identifier for this enum value.
Returns
NC_NOERR No error.
NC_EBADID Bad ncid.
NC_EBADTYPE Type not found.
NC_EINVAL Invalid type data.
Author
Ed Hartnett

Definition at line 411 of file nc4type.c.

◆ NC4_inq_enum_member()

int NC4_inq_enum_member ( int ncid,
nc_type typeid1,
int idx,
char * identifier,
void * value )

Get information about an enum member: an identifier and value. Identifier size will be <= NC_MAX_NAME.

Parameters
ncidFile and group ID.
typeid1Type ID.
idxEnum member index.
identifierGets the identifier.
valueGets the enum value.
Returns
NC_NOERR No error.
NC_EBADID Bad ncid.
NC_EBADTYPE Type not found.
NC_EINVAL Bad idx.
Author
Ed Hartnett

Definition at line 501 of file nc4type.c.

◆ NC4_inq_type()

int NC4_inq_type ( int ncid,
nc_type typeid1,
char * name,
size_t * size )

Get the name and size of a type. For VLEN the base type len is returned.

Parameters
ncidFile and group ID.
typeid1Type ID.
nameGets the name of the type.
sizeGets the size of one element of the type in bytes.
Returns
NC_NOERR No error.
NC_EBADID Bad ncid.
NC_EBADTYPE Type not found.
Author
Ed Hartnett

Definition at line 159 of file nc4type.c.

◆ NC4_inq_typeid()

EXTERNL int NC4_inq_typeid ( int ncid,
const char * name,
nc_type * typeidp )

Get the id of a type from the name.

Parameters
ncidFile and group ID.
nameName of type.
typeidpPointer that will get the type ID.
Returns
NC_NOERR No error.
NC_ENOMEM Out of memory.
NC_EINVAL Bad size.
NC_ENOTNC4 User types in netCDF-4 files only.
NC_EBADTYPE Type not found.
Author
Ed Hartnett

Definition at line 551 of file nc4type.c.

◆ NC4_inq_typeids()

int NC4_inq_typeids ( int ncid,
int * ntypes,
int * typeids )

Find all user-defined types for a location. This finds all user-defined types in a group.

Parameters
ncidFile and group ID.
ntypesPointer that gets the number of user-defined types. Ignored if NULL
typeidsArray that gets the typeids. Ignored if NULL.
Returns
NC_NOERR No error.
NC_EBADID Bad ncid.
Author
Ed Hartnett

Definition at line 53 of file nc4type.c.

◆ NC4_inq_user_type()

int NC4_inq_user_type ( int ncid,
nc_type typeid1,
char * name,
size_t * size,
nc_type * base_nc_typep,
size_t * nfieldsp,
int * classp )

Find info about any user defined type.

Parameters
ncidFile and group ID.
typeid1Type ID.
nameGets name of the type.
sizeGets size in bytes of one element of type.
base_nc_typepGets the base nc_type.
nfieldspGets the number of fields.
classpGets the type class (NC_COMPOUND, NC_ENUM, NC_VLEN).
Returns
NC_NOERR No error.
NC_EBADID Bad ncid.
NC_EBADTYPE Type not found.
Author
Ed Hartnett

Definition at line 219 of file nc4type.c.

◆ NC4_lookup_atomic_type()

int NC4_lookup_atomic_type ( const char * name,
nc_type * idp,
size_t * sizep )

Get the id and size of an atomic type by name.

Parameters
name[in] the name of the type.
size[out] the size of one element of the type in bytes.
Returns
NC_NOERR No error.
NC_EBADID Bad ncid.
NC_EBADTYPE Type not found.
Author
Dennis Heimbigner

Definition at line 126 of file nc4type.c.

Variable Documentation

◆ nc4_atomic_name

const char* nc4_atomic_name[NUM_ATOMIC_TYPES]
Initial value:
= {"none", "byte", "char",
"short", "int", "float",
"double", "ubyte",
"ushort", "uint",
"int64", "uint64", "string"}

Names of atomic types.

Definition at line 29 of file nc4type.c.

◆ nc4_atomic_size

const int nc4_atomic_size[NUM_ATOMIC_TYPES]
static
Initial value:
#define NC_INT_LEN
Definition nc4type.c:23
#define NC_FLOAT_LEN
Definition nc4type.c:24
#define NC_BYTE_LEN
Definition nc4type.c:21
#define NC_INT64_LEN
Definition nc4type.c:26
#define NC_DOUBLE_LEN
Definition nc4type.c:25
#define NC_STRING_LEN
Definition nc4type.c:20
#define NC_SHORT_LEN
Definition nc4type.c:22
#define NC_CHAR_LEN
Definition nc4type.c:19

Definition at line 34 of file nc4type.c.