NetCDF-C++
4.3.2
Toggle main menu visibility
Loading...
Searching...
No Matches
ncVlenType.cpp
1
#include "ncVlenType.h"
2
#include "ncGroup.h"
3
#include "ncCheck.h"
4
#include "ncException.h"
5
#include "ncByte.h"
6
#include "ncUbyte.h"
7
#include "ncChar.h"
8
#include "ncShort.h"
9
#include "ncUshort.h"
10
#include "ncInt.h"
11
#include "ncUint.h"
12
#include "ncInt64.h"
13
#include "ncUint64.h"
14
#include "ncFloat.h"
15
#include "ncDouble.h"
16
#include "ncString.h"
17
#include <netcdf.h>
18
using namespace
std;
19
using namespace
netCDF
;
20
using namespace
netCDF::exceptions
;
21
22
// Class represents a netCDF variable.
23
using namespace
netCDF
;
24
25
// assignment operator
26
NcVlenType
&
NcVlenType::operator=
(
const
NcVlenType
& rhs)
27
{
28
NcType::operator=
(rhs);
// assign base class parts
29
return
*
this
;
30
}
31
32
// assignment operator
33
NcVlenType
&
NcVlenType::operator=
(
const
NcType
& rhs)
34
{
35
if
(&rhs !=
this
) {
36
// check the rhs is the base of an Opaque type
37
if
(
getTypeClass
() != NC_VLEN)
throw
NcException
(
"The NcType object must be the base of an Vlen type."
,__FILE__,__LINE__);
38
// assign base class parts
39
NcType::operator=
(rhs);
40
}
41
return
*
this
;
42
}
43
44
// The copy constructor.
45
NcVlenType::NcVlenType
(
const
NcVlenType
& rhs):
46
NcType
(rhs)
47
{
48
}
49
50
51
// Constructor generates a null object.
52
NcVlenType::NcVlenType
() :
53
NcType
()
// invoke base class constructor
54
{}
55
56
// constructor
57
NcVlenType::NcVlenType
(
const
NcGroup
& grp,
const
string
& name) :
58
NcType
(grp,name)
59
{}
60
61
// constructor
62
NcVlenType::NcVlenType
(
const
NcType
&
ncType
):
63
NcType
(
ncType
)
64
{
65
// check the nctype object is the base of a Vlen type
66
if
(
getTypeClass
() != NC_VLEN)
throw
NcException
(
"The NcType object must be the base of a Vlen type."
,__FILE__,__LINE__);
67
}
68
69
// Returns the base type.
70
NcType
NcVlenType::getBaseType
()
const
71
{
72
char
charName[NC_MAX_NAME+1];
73
nc_type base_nc_typep;
74
size_t
datum_sizep;
75
ncCheck
(nc_inq_vlen(
groupId
,
myId
,charName,&datum_sizep,&base_nc_typep),__FILE__,__LINE__);
76
switch
(base_nc_typep) {
77
case
NC_BYTE :
return
ncByte
;
78
case
NC_UBYTE :
return
ncUbyte
;
79
case
NC_CHAR :
return
ncChar
;
80
case
NC_SHORT :
return
ncShort
;
81
case
NC_USHORT :
return
ncUshort;
82
case
NC_INT :
return
ncInt
;
83
case
NC_UINT :
return
ncUint
;
84
case
NC_INT64 :
return
ncInt64
;
85
case
NC_UINT64 :
return
ncUint64
;
86
case
NC_FLOAT :
return
ncFloat
;
87
case
NC_DOUBLE :
return
ncDouble
;
88
case
NC_STRING :
return
ncString
;
89
default
:
90
// this is a user defined type
91
return
NcType
(
getParentGroup
(),base_nc_typep);
92
}
93
}
netCDF::NcGroup
Class represents a netCDF group.
Definition
ncGroup.h:26
netCDF::NcType
Base class inherited by NcOpaque, NcVlen, NcCompound and NcEnum classes.
Definition
ncType.h:15
netCDF::NcType::groupId
int groupId
the group Id
Definition
ncType.h:155
netCDF::NcType::getTypeClass
ncType getTypeClass() const
The type class returned as enumeration type.
Definition
ncType.cpp:111
netCDF::NcType::getParentGroup
netCDF::NcGroup getParentGroup() const
Gets parent group.
Definition
ncType.cpp:88
netCDF::NcType::NcType
NcType()
Constructor generates a null object.
Definition
ncType.cpp:43
netCDF::NcType::myId
nc_type myId
the type Id
Definition
ncType.h:152
netCDF::NcType::operator=
NcType & operator=(const NcType &rhs)
assignment operator
Definition
ncType.cpp:26
netCDF::NcType::ncType
ncType
List of netCDF types that can be represented.
Definition
ncType.h:26
netCDF::NcVlenType::getBaseType
NcType getBaseType() const
Returns the base type.
Definition
ncVlenType.cpp:70
netCDF::NcVlenType::operator=
NcVlenType & operator=(const NcVlenType &rhs)
assignment operator
Definition
ncVlenType.cpp:26
netCDF::NcVlenType::NcVlenType
NcVlenType()
Constructor generates a null object.
Definition
ncVlenType.cpp:52
netCDF::exceptions::NcException
Base object is thrown if a netCDF exception is encountered.
Definition
ncException.h:24
netCDF::exceptions
Exception classes.
Definition
ncException.h:16
netCDF
C++ API for netCDF4.
Definition
ncAtt.h:10
netCDF::ncShort
NcShort ncShort
A global instance of the NcShort class within the netCDF namespace.
Definition
ncShort.cpp:7
netCDF::ncFloat
NcFloat ncFloat
A global instance of the NcFloat class within the netCDF namespace.
Definition
ncFloat.cpp:7
netCDF::ncInt64
NcInt64 ncInt64
A global instance of the NcInt64 class within the netCDF namespace.
Definition
ncInt64.cpp:7
netCDF::ncUint64
NcUint64 ncUint64
A global instance of the NcUint64 class within the netCDF namespace.
Definition
ncUint64.cpp:7
netCDF::ncUint
NcUint ncUint
A global instance of the NcUint class within the netCDF namespace.
Definition
ncUint.cpp:7
netCDF::ncString
NcString ncString
A global instance of the NcString class within the netCDF namespace.
Definition
ncString.cpp:7
netCDF::ncInt
NcInt ncInt
A global instance of the NcInt class within the netCDF namespace.
Definition
ncInt.cpp:7
netCDF::ncDouble
NcDouble ncDouble
A global instance of the NcDouble class within the netCDF namespace.
Definition
ncDouble.cpp:7
netCDF::ncCheck
void ncCheck(int retCode, const char *file, int line)
Function checks error code and if necessary throws an exception.
Definition
ncCheck.cpp:11
netCDF::ncUbyte
NcUbyte ncUbyte
A global instance of the NcUbyte class within the netCDF namespace.
Definition
ncUbyte.cpp:7
netCDF::ncChar
NcChar ncChar
A global instance of the NcChar class within the netCDF namespace.
Definition
ncChar.cpp:7
netCDF::ncByte
NcByte ncByte
A global instance of the NcByte class within the netCDF namespace.
Definition
ncByte.cpp:7
Return to the Main Unidata NetCDF page.
Generated on
for NetCDF-C++. NetCDF is a
Unidata
library.