NetCDF-C++ 4.3.1
ncVarAtt.cpp
1#include "ncVar.h"
2#include "ncVarAtt.h"
3#include "ncGroup.h"
4#include "ncCheck.h"
5#include <netcdf.h>
6using namespace std;
7
8
9namespace netCDF {
10 // Global comparator operator ==============
11 // comparator operator
12 bool operator<(const NcVarAtt& lhs,const NcVarAtt& rhs)
13 {
14 return false;
15 }
16
17 // comparator operator
18 bool operator>(const NcVarAtt& lhs,const NcVarAtt& rhs)
19 {
20 return true;
21 }
22}
23
24
25using namespace netCDF;
26
27
28// assignment operator
29NcVarAtt& NcVarAtt::operator=(const NcVarAtt & rhs)
30{
31 NcAtt::operator=(rhs); // assign base class parts
32 return *this;
33}
34
37 NcAtt(rhs) // invoke base class copy constructor
38{}
39
40
41// Constructor generates a null object.
43 NcAtt() // invoke base class constructor
44{}
45
46
47// Constructor for an existing local attribute.
48NcVarAtt::NcVarAtt(const NcGroup& grp, const NcVar& ncVar, const int index):
49 NcAtt(false)
50{
51 groupId = grp.getId();
52 varId = ncVar.getId();
53 // get the name of this attribute
54 char attName[NC_MAX_NAME+1];
55 ncCheck(nc_inq_attname(groupId,varId, index, attName),__FILE__,__LINE__);
56 ncCheck(nc_inq_attname(groupId,varId,index,attName),__FILE__,__LINE__);
57 myName = attName;
58}
59
60// Query a variable attribute type
61void NcVarAtt::inq_atttype(const char *name, nc_type *xtypep)
62{
63 ncCheck(nc_inq_atttype(groupId, varId, name, xtypep),__FILE__,__LINE__);
64}
65
66
67// Returns the NcVar parent object.
69 return NcVar(groupId,varId);
70}
Abstract base class represents inherited by ncVarAtt and ncGroupAtt.
Definition: ncAtt.h:14
NcAtt & operator=(const NcAtt &rhs)
assignment operator
Definition: ncAtt.cpp:14
Class represents a netCDF group.
Definition: ncGroup.h:28
int getId() const
Gets the group id.
Definition: ncGroup.cpp:141
Class represents a netCDF attribute local to a netCDF variable.
Definition: ncVarAtt.h:14
NcVarAtt()
Constructor generates a null object.
Definition: ncVarAtt.cpp:42
void inq_atttype(const char *name, nc_type *xtypep)
Query a variable attribute type.
Definition: ncVarAtt.cpp:61
NcVar getParentVar() const
Returns the NcVar parent object.
Definition: ncVarAtt.cpp:68
Class represents a netCDF variable.
Definition: ncVar.h:34
int getId() const
Get the variable id.
Definition: ncVar.cpp:86
C++ API for netCDF4.
Definition: ncAtt.h:10
void ncCheck(int retCode, const char *file, int line)
Function checks error code and if necessary throws an exception.
Definition: ncCheck.cpp:11

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