NetCDF-C++  4.3.1-developer
ncOpaqueType.cpp
1 #include "ncOpaqueType.h"
2 #include "ncGroup.h"
3 #include "ncCheck.h"
4 #include "ncException.h"
5 #include <netcdf.h>
6 using namespace std;
7 using namespace netCDF;
8 using namespace netCDF::exceptions;
9 
10 // Class represents a netCDF variable.
11 using namespace netCDF;
12 
13 // assignment operator
14 NcOpaqueType& NcOpaqueType::operator=(const NcOpaqueType& rhs)
15 {
16  // assign base class parts
17  NcType::operator=(rhs);
18  return *this;
19 }
20 
21 // assignment operator
22 NcOpaqueType& NcOpaqueType::operator=(const NcType& rhs)
23 {
24  if (&rhs != this) {
25  // check the rhs is the base of an Opaque type
26  if(getTypeClass() != NC_OPAQUE) throw NcException("The NcType object must be the base of an Opaque type.",__FILE__,__LINE__);
27  // assign base class parts
28  NcType::operator=(rhs);
29  }
30  return *this;
31 }
32 
33 // The copy constructor.
34 NcOpaqueType::NcOpaqueType(const NcOpaqueType& rhs):
35  NcType(rhs)
36 {
37 }
38 
39 
40 // Constructor generates a null object.
42  NcType() // invoke base class constructor
43 {}
44 
45 
46 // constructor
47 NcOpaqueType::NcOpaqueType(const NcGroup& grp, const string& name) :
48  NcType(grp,name)
49 {}
50 
51 
52 // constructor
54  NcType(ncType)
55 {
56  // check the nctype object is the base of a Opaque type
57  if(getTypeClass() != NC_OPAQUE) throw NcException("The NcType object must be the base of an Opaque type.",__FILE__,__LINE__);
58 }
59 
60 // Returns the size of the opaque type in bytes.
62 {
63  char* charName;
64  charName=NULL;
65  size_t sizep;
66  ncCheck(nc_inq_opaque(groupId,myId,charName,&sizep),__FILE__,__LINE__);
67  return sizep;
68 }
Base class inherited by NcOpaque, NcVlen, NcCompound and NcEnum classes.
Definition: ncType.h:14
int groupId
the group Id
Definition: ncType.h:152
C++ API for netCDF4.
Definition: ncAtt.h:9
NcOpaqueType()
Constructor generates a null object.
Class represents a netCDF group.
Definition: ncGroup.h:27
ncType
List of netCDF types that can be represented.
Definition: ncType.h:25
Exception classes.
Definition: ncException.h:15
nc_type myId
the type Id
Definition: ncType.h:149
Base object is thrown if a netCDF exception is encountered.
Definition: ncException.h:24
NcType()
Constructor generates a null object.
Definition: ncType.cpp:44
void ncCheck(int retCode, const char *file, int line)
Function checks error code and if necessary throws an exception.
Definition: ncCheck.cpp:11
size_t getTypeSize() const
Returns the size of the opaque type in bytes.
Class represents a netCDF opaque type.
Definition: ncOpaqueType.h:14
ncType getTypeClass() const
The type class returned as enumeration type.
Definition: ncType.cpp:116

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