NetCDF4 C++ API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
NcAtt.h
Go to the documentation of this file.
1 
16 #ifndef INC_netcdf_NcAtt_h
17 #define INC_netcdf_NcAtt_h
18 
19 #include "NcType.h"
20 #include "NcItem.h"
21 #include "NcUtil.h"
22 #include "NcException.h"
23 #include <map>
24 
25 namespace netcdf {
26 
27  class NcAtt : public NcItem
28  {
29 
30  public:
31 
32  typedef std::multimap<std::string, NcType> NcTypeMap;
33 
34  virtual ~NcAtt() {}
35 
37  NcAtt ();
38 
40  NcAtt (bool const isNullObject);
41 
42  NcAtt (
43  int const useFileID,
44  int const useID,
45  std::string const attName,
46  int const useGroupID = nullID,
47  int const useVarID = NcItem::idGlobal);
48 
50  NcAtt (NcAtt const & rhs);
51 
53  NcAtt (
54  int const useID,
55  NcAtt const & rhs);
56 
58  NcAtt& operator= (NcAtt const & rhs);
59 
60  int Size() const;
61  NcType GetType() const;
62  NcGroup GetParentGroup() const;
63  int const GetVarID () const { return varID; }
64 
65  bool operator== (NcAtt const & rhs) const;
66  bool operator!= (NcAtt const & rhs) const
67  { return !operator==(rhs); }
68  bool operator< (NcAtt const & rhs) const;
69 
70  // get into vector
71  void Get (TVecUbyte & data) const;
72  void Get (TVecByte & data) const;
73  void Get (TVecChar & data) const;
74  void Get (TVecShort & data) const;
75  void Get (TVecUshort & data) const;
76  void Get (TVecInt & data) const;
77  void Get (TVecUint & data) const;
78  void Get (TVecFloat & data) const;
79  void Get (TVecDouble & data) const;
80  void Get (TVecInt64 & data) const;
81  void Get (TVecUint64 & data) const;
82  void Get (TVecString & data) const;
83 
84  // get 1 value
85  void Get (unsigned char & data) const;
86  void Get (signed char & data) const;
87  void Get (char & data) const;
88  void Get (short & data) const;
89  void Get (unsigned short & data) const;
90  void Get (int & data) const;
91  void Get (long & data) const;
92  void Get (unsigned int & data) const;
93  void Get (unsigned long & data) const;
94  void Get (float & data) const;
95  void Get (double & data) const;
96  void Get (long long & data) const;
97  void Get (unsigned long long & data) const;
98 
99  // get into C array (caller allocates array)
100  void Get (unsigned char* const data) const;
101  void Get (signed char* const data) const;
102  void Get (char* const data) const;
103  void Get (short* const data) const;
104  void Get (unsigned short* const data) const;
105  void Get (int* const data) const;
106  void Get (long* const data) const;
107  void Get (unsigned int* const data) const;
108  void Get (float* const data) const;
109  void Get (double* const data) const;
110  void Get (long long* const data) const;
111  void Get (unsigned long long* const data) const;
112  void Get (char** const data) const;
113  void Get (std::string& data) const;
114 
123  void Get (void* data) const;
124  virtual void Rename( std::string const & newname );
125 
126  private:
127 
128  int mutable varID;
129 
130  inline void CheckType ( NcType::ncType const typeWanted ) const
131  {
132  if ( GetType().getTypeClass() != typeWanted )
133  NcEXCEPTION( "attribute type != function type" );
134  }
135 
136  inline void CheckLength ( int const maxLengthWanted ) const
137  {
138  if ( Size() > maxLengthWanted )
139  NcEXCEPTION( "attribute data length > length of variable" );
140  }
141 
142  // functions not allowed
143 
144  };
145 
146 
147 } // namespace netcdf
148 
149 #endif // INC_netcdf_NcAtt_h
ncType
Definition: NcType.h:56
std::vector< unsigned int > TVecUint
Definition: NcType.h:37
virtual ~NcAtt()
Definition: NcAtt.h:34
std::vector< long long > TVecInt64
Definition: NcType.h:40
bool operator!=(NcAtt const &rhs) const
Definition: NcAtt.h:66
int Size() const
number of elements
Definition: NcAtt.cpp:144
std::vector< char > TVecChar
Definition: NcType.h:33
std::vector< signed char > TVecByte
Definition: NcType.h:28
Definition: NcItem.h:26
std::multimap< std::string, NcType > NcTypeMap
Definition: NcAtt.h:32
NcAtt()
Definition: NcAtt.cpp:38
virtual void Rename(std::string const &newname)
Definition: NcAtt.cpp:88
std::vector< unsigned long long > TVecUint64
Definition: NcType.h:41
std::vector< short > TVecShort
Definition: NcType.h:34
std::vector< unsigned char > TVecUbyte
Definition: NcType.h:32
#define NcEXCEPTION(a_)
Definition: NcException.h:67
Represents a netCDF attribute.
Definition: NcAtt.h:27
bool operator<(NcAtt const &rhs) const
Definition: NcAtt.cpp:102
static int const nullID
Definition: NcItem.h:27
std::vector< std::string > TVecString
Definition: NcType.h:42
NcGroup GetParentGroup() const
Definition: NcAtt.cpp:110
NcAtt & operator=(NcAtt const &rhs)
Copy attribute to this variable.
Definition: NcAtt.cpp:80
NcType GetType() const
Definition: NcAtt.cpp:117
void Get(TVecUbyte &data) const
get NcUbyte vector
Definition: NcAtt.cpp:155
std::vector< float > TVecFloat
Definition: NcType.h:38
std::vector< unsigned short > TVecUshort
Definition: NcType.h:35
int const GetVarID() const
Definition: NcAtt.h:63
std::vector< int > TVecInt
Definition: NcType.h:36
Base class for NcAtt, NcVar, NcDim, NcGroup.
Definition: NcItem.h:22
Base class for all netCDF data types.
Definition: NcType.h:47
std::vector< double > TVecDouble
Definition: NcType.h:39
bool operator==(NcAtt const &rhs) const
Definition: NcAtt.cpp:94
Represents a netCDF group.
Definition: NcGroup.h:36