NetCDF4 C++ API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
NcType.h
Go to the documentation of this file.
1 
16 #ifndef INC_netcdf_NcType_h
17 #define INC_netcdf_NcType_h
18 
19 #include "NcConfig.h"
20 #include "NcException.h"
21 #include "stddef.h"
22 #include <string>
23 #include <vector>
24 
25 namespace netcdf {
26 
27 
28  class NcGroup;
29 
30  // some useful global types
31  typedef std::vector< signed char > TVecByte;
32  typedef std::vector< unsigned char > TVecUbyte;
33  typedef std::vector< char > TVecChar;
34  typedef std::vector< short > TVecShort;
35  typedef std::vector< unsigned short > TVecUshort;
36  typedef std::vector< int > TVecInt;
37  typedef std::vector< unsigned int > TVecUint;
38  typedef std::vector< float > TVecFloat;
39  typedef std::vector< double > TVecDouble;
40  typedef std::vector< long long > TVecInt64;
41  typedef std::vector< unsigned long long > TVecUint64;
42  typedef std::vector< std::string > TVecString;
43  typedef std::vector< std::size_t > TVecIndex;
44  typedef std::vector< ptrdiff_t > TVecStride;
45 
46 
47  class NcType
48  {
49 
50  public:
51 
56  enum ncType
57  {
58  nc_NAT = NC_NAT,
59  nc_BYTE = NC_BYTE,
60  nc_CHAR = NC_CHAR,
61  nc_SHORT = NC_SHORT,
62  nc_INT = NC_INT,
63  nc_FLOAT = NC_FLOAT,
64  nc_DOUBLE = NC_DOUBLE,
65  nc_UBYTE = NC_UBYTE,
66  nc_USHORT = NC_USHORT,
67  nc_UINT = NC_UINT,
68  nc_INT64 = NC_INT64,
69  nc_UINT64 = NC_UINT64,
70  nc_STRING = NC_STRING,
71  nc_VLEN = NC_VLEN,
72  nc_OPAQUE = NC_OPAQUE,
73  nc_ENUM = NC_ENUM,
74  nc_COMPOUND = NC_COMPOUND,
75  nc_Unknown // last one always!
76  };
77 
79  NcType ();
80 
88  NcType (
89  std::string const myClassName,
90  ncType const id);
91 
92  NcType (NcType const & rhs);
93 
94  virtual ~NcType() {}
95 
96  NcType& operator= (NcType const & rhs);
97  bool operator== (NcType const & rhs) const;
98  bool operator!= (NcType const & rhs) const { return !operator== (rhs); }
99  bool operator< (NcType const & rhs) const;
100 
101  ncType GetID() const { return myID; }
102 
121  virtual std::string GetName() const;
122 
129  virtual size_t Size() const;
130 
137  virtual ncType getTypeClass() const;
138  virtual ncType GetTypeClass() const;
139 
145  std::string const & getTypeClassName () const { return myName; }
146  std::string const & GetTypeClassName () const { return myName; }
147 
148  bool IsNull() const { return nullObject; }
149 
150  protected:
151 
152  static ncType const nullID = nc_NAT;
153 
155  std::string myName;
157 
158 
159  void ErrorDimsAreZero (std::string const & className);
160  void ErrorArrayNcSizeMismatch (std::string const & className);
161 
162  };
163 
164 
165 
166 class NcNullType : public NcType
167 {
168  public:
169 
171  : NcType ()
172  {
173  }
174 
175 };
176 
178 extern NcNullType nullType;
179 
180 
181 
182 } // namespace netcdf
183 
184 #endif // INC_netcdf_NcType_h
NcType()
Definition: NcType.cpp:27
ncType
Definition: NcType.h:56
void ErrorDimsAreZero(std::string const &className)
Definition: NcType.cpp:104
std::vector< unsigned int > TVecUint
Definition: NcType.h:37
signed 1 byte integer
Definition: NcType.h:59
NcType & operator=(NcType const &rhs)
Definition: NcType.cpp:49
std::vector< long long > TVecInt64
Definition: NcType.h:40
double precision floating point number
Definition: NcType.h:64
virtual std::string GetName() const
Definition: NcType.cpp:70
signed 4 byte integer
Definition: NcType.h:62
unsigned 2-byte int
Definition: NcType.h:66
Definition: NcType.h:166
virtual ncType GetTypeClass() const
Definition: NcType.cpp:98
std::vector< char > TVecChar
Definition: NcType.h:33
single precision floating point number
Definition: NcType.h:63
bool operator==(NcType const &rhs) const
Definition: NcType.cpp:57
std::vector< signed char > TVecByte
Definition: NcType.h:28
std::string const & getTypeClassName() const
Definition: NcType.h:145
Definition: NcType.h:75
string
Definition: NcType.h:70
signed 8-byte int
Definition: NcType.h:68
void ErrorArrayNcSizeMismatch(std::string const &className)
Definition: NcType.cpp:112
ncType GetID() const
Definition: NcType.h:101
&quot;NcEnum type&quot;
Definition: NcType.h:73
&quot;NcVlen type&quot;
Definition: NcType.h:71
signed 2 byte integer
Definition: NcType.h:61
unsigned 1 byte int
Definition: NcType.h:65
std::vector< unsigned long long > TVecUint64
Definition: NcType.h:41
std::vector< short > TVecShort
Definition: NcType.h:34
bool nullObject
Definition: NcType.h:154
unsigned 4-byte int
Definition: NcType.h:67
std::string const & GetTypeClassName() const
Definition: NcType.h:146
std::vector< std::size_t > TVecIndex
Definition: NcType.h:43
std::vector< unsigned char > TVecUbyte
Definition: NcType.h:32
static ncType const nullID
Definition: NcType.h:152
bool operator!=(NcType const &rhs) const
Definition: NcType.h:98
std::vector< std::string > TVecString
Definition: NcType.h:42
virtual size_t Size() const
Definition: NcType.cpp:82
ISO/ASCII character.
Definition: NcType.h:60
unsigned 8-byte int
Definition: NcType.h:69
ncType myID
enumerated type value
Definition: NcType.h:156
std::vector< ptrdiff_t > TVecStride
Definition: NcType.h:44
bool operator<(NcType const &rhs) const
Definition: NcType.cpp:65
NcNullType nullType
global null type
Definition: NcType.cpp:24
std::vector< float > TVecFloat
Definition: NcType.h:38
NcNullType()
Definition: NcType.h:170
std::vector< unsigned short > TVecUshort
Definition: NcType.h:35
std::string myName
enumerated type name
Definition: NcType.h:155
virtual ncType getTypeClass() const
Definition: NcType.cpp:91
bool IsNull() const
Definition: NcType.h:148
virtual ~NcType()
Definition: NcType.h:94
std::vector< int > TVecInt
Definition: NcType.h:36
Base class for all netCDF data types.
Definition: NcType.h:47
std::vector< double > TVecDouble
Definition: NcType.h:39
invalid type
Definition: NcType.h:58
&quot;NcCompound type&quot;
Definition: NcType.h:74
Represents a netCDF group.
Definition: NcGroup.h:36
&quot;NcOpaque type&quot;
Definition: NcType.h:72