netcdf-C++
Public Types | Public Member Functions | List of all members
netCDF::NcFile Class Reference

#include <ncFile.h>

Inheritance diagram for netCDF::NcFile:
Inheritance graph
[legend]

Public Types

enum  FileFormat { classic, classic64, nc4, nc4classic }
 
enum  FileMode { read, write, replace, newFile }
 
- Public Types inherited from netCDF::NcGroup
enum  GroupLocation {
  ChildrenGrps, ParentsGrps, ChildrenOfChildrenGrps, AllChildrenGrps,
  ParentsAndCurrentGrps, AllGrps
}
 
enum  Location {
  Current, Parents, Children, ParentsAndCurrent,
  ChildrenAndCurrent, All
}
 

Public Member Functions

void close ()
 Close a file before destructor call.
 
void create (const std::string &filePath, int ncFileFlags)
 
void enddef ()
 Leave define mode, used for classic model.
 
 NcFile ()
 
 NcFile (const std::string &filePath, FileMode fMode)
 
 NcFile (const std::string &filePath, FileMode fMode, FileFormat fFormat)
 
 NcFile (const std::string &filePath, int ncFileFlags)
 
void open (const std::string &filePath, FileMode fMode)
 
void open (const std::string &filePath, FileMode fMode, FileFormat fFormat)
 
void open (const std::string &filePath, int ncFileFlags)
 
void redef ()
 Redefine variable.
 
void set_Fill (int fillmode, int *old_modep)
 Elect a fill parameter different that the one currently being used.
 
void sync ()
 Synchronize an open netcdf dataset to disk.
 
virtual ~NcFile ()
 
- Public Member Functions inherited from netCDF::NcGroup
NcCompoundType addCompoundType (const std::string &name, size_t size) const
 
NcDim addDim (const std::string &name) const
 
NcDim addDim (const std::string &name, size_t dimSize) const
 
NcEnumType addEnumType (const std::string &name, NcEnumType::ncEnumType basetype) const
 
NcGroup addGroup (const std::string &name) const
 
NcOpaqueType addOpaqueType (const std::string &name, size_t size) const
 
NcVar addVar (const std::string &name, const NcType &ncType) const
 
NcVar addVar (const std::string &name, const NcType &ncType, const NcDim &ncDim) const
 
NcVar addVar (const std::string &name, const NcType &ncType, const std::vector< NcDim > &ncDimVector) const
 
NcVar addVar (const std::string &name, const std::string &typeName, const std::string &dimName) const
 
NcVar addVar (const std::string &name, const std::string &typeName, const std::vector< std::string > &dimNames) const
 
NcVlenType addVlenType (const std::string &name, NcType &basetype) const
 
NcGroupAtt getAtt (const std::string &name, NcGroup::Location location=Current) const
 
int getAttCount (NcGroup::Location location=Current) const
 
std::set< NcGroupAttgetAtts (const std::string &name, NcGroup::Location location=Current) const
 
std::multimap< std::string, NcGroupAttgetAtts (NcGroup::Location location=Current) const
 
void getCoordVar (std::string &coordVarName, NcDim &ncDim, NcVar &ncVar, NcGroup::Location location=Current) const
 
std::map< std::string, NcGroupgetCoordVars (NcGroup::Location location=Current) const
 
NcDim getDim (const std::string &name, NcGroup::Location location=Current) const
 
int getDimCount (NcGroup::Location location=Current) const
 
std::set< NcDimgetDims (const std::string &name, NcGroup::Location location=Current) const
 
std::multimap< std::string, NcDimgetDims (NcGroup::Location location=Current) const
 
NcGroup getGroup (const std::string &name, NcGroup::GroupLocation location=ChildrenGrps) const
 
int getGroupCount (NcGroup::GroupLocation location=ChildrenGrps) const
 
std::set< NcGroupgetGroups (const std::string &name, NcGroup::GroupLocation location=ChildrenGrps) const
 
std::multimap< std::string, NcGroupgetGroups (NcGroup::GroupLocation location=ChildrenGrps) const
 
int getId () const
 
std::string getName (bool fullName=false) const
 
NcGroup getParentGroup () const
 
NcType getType (const std::string &name, NcGroup::Location location=Current) const
 
int getTypeCount (NcGroup::Location location=Current) const
 
int getTypeCount (NcType::ncType enumType, NcGroup::Location location=Current) const
 
std::set< NcTypegetTypes (const std::string &name, NcGroup::Location location=Current) const
 
std::set< NcTypegetTypes (const std::string &name, NcType::ncType enumType, NcGroup::Location location=Current) const
 
std::multimap< std::string, NcTypegetTypes (NcGroup::Location location=Current) const
 
std::set< NcTypegetTypes (NcType::ncType enumType, NcGroup::Location location=Current) const
 
NcVar getVar (const std::string &name, NcGroup::Location location=Current) const
 
int getVarCount (NcGroup::Location location=Current) const
 
std::set< NcVargetVars (const std::string &name, NcGroup::Location location=Current) const
 
std::multimap< std::string, NcVargetVars (NcGroup::Location location=Current) const
 
bool isNull () const
 
bool isRootGroup () const
 
 NcGroup ()
 
 NcGroup (const NcGroup &rhs)
 
bool operator!= (const NcGroup &rhs) const
 
NcGroupoperator= (const NcGroup &rhs)
 
bool operator== (const NcGroup &rhs) const
 
NcGroupAtt putAtt (const std::string &name, const NcType &type, double datumValue) const
 
NcGroupAtt putAtt (const std::string &name, const NcType &type, float datumValue) const
 
NcGroupAtt putAtt (const std::string &name, const NcType &type, int datumValue) const
 
NcGroupAtt putAtt (const std::string &name, const NcType &type, long datumValue) const
 
NcGroupAtt putAtt (const std::string &name, const NcType &type, long long datumValue) const
 
NcGroupAtt putAtt (const std::string &name, const NcType &type, short datumValue) const
 
NcGroupAtt putAtt (const std::string &name, const NcType &type, size_t len, const double *dataValues) const
 
NcGroupAtt putAtt (const std::string &name, const NcType &type, size_t len, const float *dataValues) const
 
NcGroupAtt putAtt (const std::string &name, const NcType &type, size_t len, const int *dataValues) const
 
NcGroupAtt putAtt (const std::string &name, const NcType &type, size_t len, const long *dataValues) const
 
NcGroupAtt putAtt (const std::string &name, const NcType &type, size_t len, const long long *dataValues) const
 
NcGroupAtt putAtt (const std::string &name, const NcType &type, size_t len, const short *dataValues) const
 
NcGroupAtt putAtt (const std::string &name, const NcType &type, size_t len, const signed char *dataValues) const
 
NcGroupAtt putAtt (const std::string &name, const NcType &type, size_t len, const unsigned char *dataValues) const
 
NcGroupAtt putAtt (const std::string &name, const NcType &type, size_t len, const unsigned int *dataValues) const
 
NcGroupAtt putAtt (const std::string &name, const NcType &type, size_t len, const unsigned long long *dataValues) const
 
NcGroupAtt putAtt (const std::string &name, const NcType &type, size_t len, const unsigned short *dataValues) const
 
NcGroupAtt putAtt (const std::string &name, const NcType &type, size_t len, const void *dataValues) const
 
NcGroupAtt putAtt (const std::string &name, const NcType &type, unsigned int datumValue) const
 
NcGroupAtt putAtt (const std::string &name, const NcType &type, unsigned long long datumValue) const
 
NcGroupAtt putAtt (const std::string &name, const NcType &type, unsigned short datumValue) const
 
NcGroupAtt putAtt (const std::string &name, const std::string &dataValues) const
 
NcGroupAtt putAtt (const std::string &name, size_t len, const char **dataValues) const
 
virtual ~NcGroup ()
 

Additional Inherited Members

- Protected Attributes inherited from netCDF::NcGroup
bool nullObject
 

Detailed Description

Class represents a netCDF root group. The Ncfile class is the same as the NcGroup class with the additional functionality for opening and closing files.

Member Enumeration Documentation

◆ FileFormat

Enumerator
classic 

Classic format, classic data model.

classic64 

64-bit offset format, classic data model

nc4 

(default) netCDF-4/HDF5 format, enhanced data model

nc4classic 

netCDF-4/HDF5 format, classic data model

◆ FileMode

Enumerator
read 

File exists, open read-only.

write 

File exists, open for writing.

replace 

Create new file, even if already exists.

newFile 

Create new file, fail if already exists.

Constructor & Destructor Documentation

◆ NcFile() [1/4]

NcFile::NcFile ( )

Constructor generates a null object.

◆ NcFile() [2/4]

netCDF::NcFile::NcFile ( const std::string &  filePath,
int  ncFileFlags 
)

Opens a netCDF file.

Parameters
filePathName of netCDF optional path. \aram ncFileFlags File flags from netcdf.h

◆ NcFile() [3/4]

netCDF::NcFile::NcFile ( const std::string &  filePath,
FileMode  fMode 
)

Opens a netCDF file.

Parameters
filePathName of netCDF optional path.
fModeThe file mode:
  • 'read' File exists, open for read-only.
  • 'write' File exists, open for writing.
  • 'replace' Create new file, even it already exists.
  • 'newFile' Create new file, fail it exists already.

◆ NcFile() [4/4]

netCDF::NcFile::NcFile ( const std::string &  filePath,
FileMode  fMode,
FileFormat  fFormat 
)

Creates a netCDF file of a specified format.

Parameters
filePathName of netCDF optional path.
fModeThe file mode:
  • 'replace' Create new file, even it already exists.
  • 'newFile' Create new file, fail it exists already.

◆ ~NcFile()

NcFile::~NcFile ( )
virtual

destructor

Member Function Documentation

◆ create()

void NcFile::create ( const std::string &  filePath,
int  ncFileFlags 
)

Create a netCDF file.

Parameters
filePathName of netCDF optional path.
ncFileFlagsFile flags from netcdf.h

Allow for the explicit creation of a file using a path and NC_ file flags from netcdf.h

Author
wfisher

◆ open() [1/3]

void netCDF::NcFile::open ( const std::string &  filePath,
FileMode  fMode 
)

Opens a netCDF file.

Parameters
filePathName of netCDF optional path.
fModeThe file mode:
  • 'read' File exists, open for read-only.
  • 'write' File exists, open for writing.
  • 'replace' Create new file, even it already exists.
  • 'newFile' Create new file, fail it exists already.

◆ open() [2/3]

void netCDF::NcFile::open ( const std::string &  filePath,
FileMode  fMode,
FileFormat  fFormat 
)

Creates a netCDF file of a specified format.

Parameters
filePathName of netCDF optional path.
fModeThe file mode:
  • 'replace' Create new file, even it already exists.
  • 'newFile' Create new file, fail it exists already.

◆ open() [3/3]

void netCDF::NcFile::open ( const std::string &  filePath,
int  ncFileFlags 
)

Opens a netCDF file.

Parameters
filePathName of netCDF optional path.
ncFileFlagsFile flags from netcdf.h

The documentation for this class was generated from the following files: