1 | /*! \file |
---|
2 | Functions for User-Defined Types |
---|
3 | |
---|
4 | Copyright 2011 University Corporation for Atmospheric |
---|
5 | Research/Unidata. See \ref copyright file for more info. */ |
---|
6 | |
---|
7 | #include "ncdispatch.h" |
---|
8 | |
---|
9 | /** \internal |
---|
10 | \ingroup user_types |
---|
11 | Learn if two types are equal |
---|
12 | |
---|
13 | \param ncid1 \ref ncid of first typeid. |
---|
14 | \param typeid1 First typeid. |
---|
15 | \param ncid2 \ref ncid of second typeid. |
---|
16 | \param typeid2 Second typeid. |
---|
17 | \param equal Pointer to int. A non-zero value will be copied here if |
---|
18 | the two types are equal, a zero if they are not equal. |
---|
19 | |
---|
20 | \returns ::NC_NOERR No error. |
---|
21 | \returns ::NC_EBADID Bad \ref ncid. |
---|
22 | \returns ::NC_EBADTYPE Bad type id. |
---|
23 | \returns ::NC_ENOTNC4 Not an netCDF-4 file, or classic model enabled. |
---|
24 | \returns ::NC_EHDFERR An error was reported by the HDF5 layer. |
---|
25 | */ |
---|
26 | int |
---|
27 | nc_inq_type_equal(int ncid1, nc_type typeid1, int ncid2, |
---|
28 | nc_type typeid2, int *equal) |
---|
29 | { |
---|
30 | NC* ncp1; |
---|
31 | int stat = NC_check_id(ncid1,&ncp1); |
---|
32 | if(stat != NC_NOERR) return stat; |
---|
33 | return ncp1->dispatch->inq_type_equal(ncid1,typeid1,ncid2,typeid2,equal); |
---|
34 | } |
---|
35 | |
---|
36 | /** \name Learning about User-Defined Types |
---|
37 | |
---|
38 | Functions to learn about any kind of user-defined type. */ |
---|
39 | /*! \{ */ /* All these functions are part of this named group... */ |
---|
40 | |
---|
41 | /** \ingroup user_types |
---|
42 | |
---|
43 | Find a type by name. Given a group ID and a type name, find the ID of |
---|
44 | the type. If the type is not found in the group, then the parents are |
---|
45 | searched. If still not found, the entire file is searched. |
---|
46 | |
---|
47 | \param ncid \ref ncid |
---|
48 | \param name \ref object_name of type to search for. |
---|
49 | \param typeidp Typeid of named type will be copied here, if it is |
---|
50 | found. |
---|
51 | |
---|
52 | \returns ::NC_NOERR No error. |
---|
53 | \returns ::NC_EBADID Bad \ref ncid. |
---|
54 | \returns ::NC_EBADTYPE Bad type id. |
---|
55 | \returns ::NC_ENOTNC4 Not an netCDF-4 file, or classic model enabled. |
---|
56 | \returns ::NC_EHDFERR An error was reported by the HDF5 layer. |
---|
57 | */ |
---|
58 | int |
---|
59 | nc_inq_typeid(int ncid, const char *name, nc_type *typeidp) |
---|
60 | { |
---|
61 | NC* ncp; |
---|
62 | int stat = NC_check_id(ncid,&ncp); |
---|
63 | if(stat != NC_NOERR) return stat; |
---|
64 | return ncp->dispatch->inq_typeid(ncid,name,typeidp); |
---|
65 | } |
---|
66 | |
---|
67 | /** \ingroup user_types |
---|
68 | Learn about a user defined type. |
---|
69 | |
---|
70 | Given an ncid and a typeid, get the information about a user defined |
---|
71 | type. This function will work on any user defined type, whether |
---|
72 | compound, opaque, enumeration, or variable length array. |
---|
73 | |
---|
74 | \param ncid \ref ncid |
---|
75 | |
---|
76 | \param xtype The typeid |
---|
77 | |
---|
78 | \param name The \ref object_name will be copied here. \ref |
---|
79 | ignored_if_null. |
---|
80 | |
---|
81 | \param size the (in-memory) size of the type in bytes will be copied |
---|
82 | here. VLEN type size is the size of nc_vlen_t. String size is returned |
---|
83 | as the size of a character pointer. The size may be used to malloc |
---|
84 | space for the data, no matter what the type. \ref ignored_if_null. |
---|
85 | |
---|
86 | \param base_nc_typep The base type will be copied here for enum and |
---|
87 | VLEN types. \ref ignored_if_null. |
---|
88 | |
---|
89 | \param nfieldsp The number of fields will be copied here for enum and |
---|
90 | compound types. \ref ignored_if_null. |
---|
91 | |
---|
92 | \param classp Return the class of the user defined type, ::NC_VLEN, |
---|
93 | ::NC_OPAQUE, ::NC_ENUM, or ::NC_COMPOUND. \ref ignored_if_null. |
---|
94 | |
---|
95 | \returns ::NC_NOERR No error. |
---|
96 | \returns ::NC_EBADID Bad \ref ncid. |
---|
97 | \returns ::NC_EBADTYPE Bad type id. |
---|
98 | \returns ::NC_ENOTNC4 Not an netCDF-4 file, or classic model enabled. |
---|
99 | \returns ::NC_EHDFERR An error was reported by the HDF5 layer. |
---|
100 | */ |
---|
101 | int |
---|
102 | nc_inq_user_type(int ncid, nc_type xtype, char *name, size_t *size, |
---|
103 | nc_type *base_nc_typep, size_t *nfieldsp, int *classp) |
---|
104 | { |
---|
105 | NC *ncp; |
---|
106 | int stat = NC_check_id(ncid,&ncp); |
---|
107 | if(stat != NC_NOERR) return stat; |
---|
108 | return ncp->dispatch->inq_user_type(ncid, xtype, name, size, |
---|
109 | base_nc_typep, nfieldsp, classp); |
---|
110 | } |
---|
111 | /*! \} */ /* End of named group ...*/ |
---|