NetCDF-C++ 4.3.1
ncGroupAtt.cpp
1#include "ncGroupAtt.h"
2#include "ncGroup.h"
3#include "ncCheck.h"
4#include <netcdf.h>
5using namespace std;
6
7
8namespace netCDF {
9 // Global comparator operator ==============
10 // comparator operator
11 bool operator<(const NcGroupAtt& lhs,const NcGroupAtt& rhs)
12 {
13 return false;
14 }
15
16 // comparator operator
17 bool operator>(const NcGroupAtt& lhs,const NcGroupAtt& rhs)
18 {
19 return true;
20 }
21}
22
23
24using namespace netCDF;
25
26// assignment operator
27NcGroupAtt& NcGroupAtt::operator=(const NcGroupAtt & rhs)
28{
29 NcAtt::operator=(rhs); // assign base class parts
30 return *this;
31}
32
35 NcAtt(rhs) // invoke base class copy constructor
36{}
37
38
39// Constructor generates a null object.
41 NcAtt() // invoke base class constructor
42{}
43
44// equivalence operator (doesn't bother compaing varid's of each object).
46{
47 if(nullObject)
48 return nullObject == rhs.isNull();
49 else
50 return myName == rhs.myName && groupId == rhs.groupId;
51}
52
53// Constructor for an existing global attribute.
54NcGroupAtt::NcGroupAtt(const NcGroup& grp, const int index):
55 NcAtt(false)
56{
57 groupId = grp.getId();
58 varId = NC_GLOBAL;
59 // get the name of this attribute
60 char attName[NC_MAX_NAME+1];
61 ncCheck(nc_inq_attname(groupId,varId, index, attName),__FILE__,__LINE__);
62 ncCheck(nc_inq_attname(groupId,varId,index,attName),__FILE__,__LINE__);
63 myName = attName;
64}
65
Abstract base class represents inherited by ncVarAtt and ncGroupAtt.
Definition: ncAtt.h:14
NcAtt & operator=(const NcAtt &rhs)
assignment operator
Definition: ncAtt.cpp:14
bool isNull() const
Returns true if this object is null (i.e.
Definition: ncAtt.h:103
Class represents a netCDF group attribute.
Definition: ncGroupAtt.h:13
bool operator==(const NcGroupAtt &rhs)
equivalence operator
Definition: ncGroupAtt.cpp:45
NcGroupAtt()
Constructor generates a null object.
Definition: ncGroupAtt.cpp:40
Class represents a netCDF group.
Definition: ncGroup.h:28
int getId() const
Gets the group id.
Definition: ncGroup.cpp:141
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.