"Fossies" - the Fresh Open Source Software Archive

Member "netcdf-cxx4-4.3.1/cxx4/ncVlenType.cpp" (11 Sep 2019, 2410 Bytes) of package /linux/misc/netcdf-cxx4-4.3.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "ncVlenType.cpp" see the Fossies "Dox" file reference documentation.

    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 }