File: ncGroupAtt.cpp

package info (click to toggle)
netcdf-cxx 4.3.0%2Bds-3
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 3,016 kB
  • ctags: 1,015
  • sloc: sh: 11,553; cpp: 8,167; xml: 173; ansic: 134; makefile: 108
file content (65 lines) | stat: -rw-r--r-- 1,510 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include "ncGroupAtt.h"
#include "ncGroup.h"
#include "ncCheck.h"
#include <netcdf.h>
using namespace std;


namespace netCDF {
  //  Global comparator operator ==============
  // comparator operator 
  bool operator<(const NcGroupAtt& lhs,const NcGroupAtt& rhs)
  {
    return false;
  }
  
  // comparator operator 
  bool operator>(const NcGroupAtt& lhs,const NcGroupAtt& rhs)
  {
    return true;
  }
}


using namespace netCDF;

// assignment operator
NcGroupAtt& NcGroupAtt::operator=(const NcGroupAtt & rhs)
{
  NcAtt::operator=(rhs);    // assign base class parts
  return *this;
}

//! The copy constructor.
NcGroupAtt::NcGroupAtt(const NcGroupAtt& rhs): 
  NcAtt(rhs)   // invoke base class copy constructor
{}


// Constructor generates a null object.
NcGroupAtt::NcGroupAtt() : 
  NcAtt()  // invoke base class constructor
{}

// equivalence operator (doesn't bother compaing varid's of each object).
bool NcGroupAtt::operator==(const NcGroupAtt & rhs)
{
  if(nullObject) 
    return nullObject == rhs.isNull();
  else
    return myName == rhs.myName && groupId == rhs.groupId;
}  

// Constructor for an existing global attribute.
NcGroupAtt::NcGroupAtt(const NcGroup& grp, const int index):
  NcAtt(false)
{
  groupId =  grp.getId();
  varId = NC_GLOBAL;
  // get the name of this attribute
  char attName[NC_MAX_NAME+1];
  ncCheck(nc_inq_attname(groupId,varId, index, attName),__FILE__,__LINE__);
  ncCheck(nc_inq_attname(groupId,varId,index,attName),__FILE__,__LINE__);
  myName = attName;
}