NetCDF-C++ 4.3.1
ncType.h
1#include <string>
2#include "netcdf.h"
3
4#ifndef NcTypeClass
5#define NcTypeClass
6
7
8namespace netCDF
9{
10
11 class NcGroup; // forward declaration to avoid cyclic reference.
12
14 class NcType
15 {
16
17 public:
18
25 enum ncType
26 {
27 nc_BYTE = NC_BYTE,
28 nc_CHAR = NC_CHAR,
29 nc_SHORT = NC_SHORT,
30 nc_INT = NC_INT,
31 nc_FLOAT = NC_FLOAT,
32 nc_DOUBLE = NC_DOUBLE,
33 nc_UBYTE = NC_UBYTE,
34 nc_USHORT = NC_USHORT,
35 nc_UINT = NC_UINT,
36 nc_INT64 = NC_INT64,
37 nc_UINT64 = NC_UINT64,
38 nc_STRING = NC_STRING,
39 nc_VLEN = NC_VLEN,
40 nc_OPAQUE = NC_OPAQUE,
41 nc_ENUM = NC_ENUM,
42 nc_COMPOUND = NC_COMPOUND
43 };
44
46 NcType();
47
55 NcType(const netCDF::NcGroup& grp, const std::string& name);
56
57
65 NcType(const netCDF::NcGroup& grp, nc_type id);
66
72 NcType(nc_type id);
73
75 NcType(const NcType& rhs);
76
78 virtual ~NcType() {}
79
81 bool operator==(const NcType&) const;
82
84 bool operator!=(const NcType &) const;
85
86 // accessors to private data.
88 nc_type getId() const {return myId;}
89
92
108 std::string getName() const;
109
116 size_t getSize() const;
117
123 ncType getTypeClass() const;
124
130 std::string getTypeClassName() const;
131
133 bool isNull() const {return nullObject;}
134
136 friend bool operator<(const NcType& lhs,const NcType& rhs);
137
139 friend bool operator>(const NcType& lhs,const NcType& rhs);
140
141 protected:
142
144 NcType& operator=(const NcType& rhs);
145
146 bool nullObject;
147
149 nc_type myId;
150
153
159
160 };
161
162}
163#endif
Class represents a netCDF group.
Definition: ncGroup.h:28
Base class inherited by NcOpaque, NcVlen, NcCompound and NcEnum classes.
Definition: ncType.h:15
int groupId
the group Id
Definition: ncType.h:152
ncType getTypeClass() const
The type class returned as enumeration type.
Definition: ncType.cpp:116
netCDF::NcGroup getParentGroup() const
Gets parent group.
Definition: ncType.cpp:89
friend bool operator>(const NcType &lhs, const NcType &rhs)
comparator operator
Definition: ncType.cpp:18
NcType()
Constructor generates a null object.
Definition: ncType.cpp:44
size_t getSize() const
The size in bytes.
Definition: ncType.cpp:108
friend bool operator<(const NcType &lhs, const NcType &rhs)
comparator operator
Definition: ncType.cpp:12
bool operator==(const NcType &) const
equivalence operator
Definition: ncType.cpp:74
nc_type myId
the type Id
Definition: ncType.h:149
std::string getTypeClassName() const
Return a string containing the name of the enumerated type.
Definition: ncType.cpp:144
NcType(const netCDF::NcGroup &grp, const std::string &name)
Constructor for a non-global type.
NcType & operator=(const NcType &rhs)
assignment operator
Definition: ncType.cpp:27
ncType
List of netCDF types that can be represented.
Definition: ncType.h:26
@ nc_DOUBLE
double precision floating point number
Definition: ncType.h:32
@ nc_UBYTE
unsigned 1 byte int
Definition: ncType.h:33
@ nc_OPAQUE
"NcOpaque type"
Definition: ncType.h:40
@ nc_CHAR
ISO/ASCII character.
Definition: ncType.h:28
@ nc_SHORT
signed 2 byte integer
Definition: ncType.h:29
@ nc_BYTE
signed 1 byte integer
Definition: ncType.h:27
@ nc_UINT64
unsigned 8-byte int
Definition: ncType.h:37
@ nc_VLEN
"NcVlen type"
Definition: ncType.h:39
@ nc_UINT
unsigned 4-byte int
Definition: ncType.h:35
@ nc_INT
signed 4 byte integer
Definition: ncType.h:30
@ nc_ENUM
"NcEnum type"
Definition: ncType.h:41
@ nc_STRING
string
Definition: ncType.h:38
@ nc_INT64
signed 8-byte int
Definition: ncType.h:36
@ nc_USHORT
unsigned 2-byte int
Definition: ncType.h:34
@ nc_FLOAT
single precision floating point number
Definition: ncType.h:31
@ nc_COMPOUND
"NcCompound type"
Definition: ncType.h:42
std::string getName() const
The name of this type.
Definition: ncType.cpp:94
bool isNull() const
Returns true if this object is null (i.e.
Definition: ncType.h:133
bool operator!=(const NcType &) const
!= operator
Definition: ncType.cpp:83
nc_type getId() const
The netCDF Id of this type.
Definition: ncType.h:88
virtual ~NcType()
destructor
Definition: ncType.h:78
int g_fileId
An ncid associated with a particular open file (returned from nc_open).
Definition: ncType.h:158
C++ API for netCDF4.
Definition: ncAtt.h:10

Return to the Main Unidata NetCDF page.
Generated on Wed Nov 10 2021 15:25:08 for NetCDF-C++. NetCDF is a Unidata library.