NetCDF-C++  4.3.1-developer
ncType.h
1 #include <string>
2 #include "netcdf.h"
3 
4 #ifndef NcTypeClass
5 #define NcTypeClass
6 
7 
8 namespace 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 
152  int groupId;
153 
158  int g_fileId;
159 
160  };
161 
162 }
163 #endif
signed 2 byte integer
Definition: ncType.h:29
unsigned 8-byte int
Definition: ncType.h:37
Base class inherited by NcOpaque, NcVlen, NcCompound and NcEnum classes.
Definition: ncType.h:14
int groupId
the group Id
Definition: ncType.h:152
ISO/ASCII character.
Definition: ncType.h:28
"NcOpaque type"
Definition: ncType.h:40
C++ API for netCDF4.
Definition: ncAtt.h:9
unsigned 4-byte int
Definition: ncType.h:35
unsigned 2-byte int
Definition: ncType.h:34
signed 1 byte integer
Definition: ncType.h:27
friend bool operator<(const NcType &lhs, const NcType &rhs)
comparator operator
Definition: ncType.cpp:12
int g_fileId
An ncid associated with a particular open file (returned from nc_open).
Definition: ncType.h:158
"NcCompound type"
Definition: ncType.h:42
bool operator==(const NcType &) const
equivalence operator
Definition: ncType.cpp:74
"NcVlen type"
Definition: ncType.h:39
Class represents a netCDF group.
Definition: ncGroup.h:27
ncType
List of netCDF types that can be represented.
Definition: ncType.h:25
single precision floating point number
Definition: ncType.h:31
std::string getTypeClassName() const
Return a string containing the name of the enumerated type.
Definition: ncType.cpp:144
bool isNull() const
Returns true if this object is null (i.e.
Definition: ncType.h:133
std::string getName() const
The name of this type.
Definition: ncType.cpp:94
unsigned 1 byte int
Definition: ncType.h:33
nc_type myId
the type Id
Definition: ncType.h:149
nc_type getId() const
The netCDF Id of this type.
Definition: ncType.h:88
virtual ~NcType()
destructor
Definition: ncType.h:78
NcType()
Constructor generates a null object.
Definition: ncType.cpp:44
friend bool operator>(const NcType &lhs, const NcType &rhs)
comparator operator
Definition: ncType.cpp:18
signed 8-byte int
Definition: ncType.h:36
bool operator!=(const NcType &) const
!= operator
Definition: ncType.cpp:83
"NcEnum type"
Definition: ncType.h:41
netCDF::NcGroup getParentGroup() const
Gets parent group.
Definition: ncType.cpp:89
signed 4 byte integer
Definition: ncType.h:30
size_t getSize() const
The size in bytes.
Definition: ncType.cpp:108
ncType getTypeClass() const
The type class returned as enumeration type.
Definition: ncType.cpp:116
double precision floating point number
Definition: ncType.h:32
NcType & operator=(const NcType &rhs)
assignment operator
Definition: ncType.cpp:27

Return to the Main Unidata NetCDF page.
Generated on Fri Nov 11 2016 15:28:29 for NetCDF-C++. NetCDF is a Unidata library.