netcdfpp
Header-only NetCDF C++ wrapper
Loading...
Searching...
No Matches
Public Member Functions | List of all members
netCDF::File Class Referencefinal

NetCDF file handle and root group. More...

#include <netcdfpp.h>

Public Member Functions

 File ()
 Creates a closed file handle.
 
 File (std::string filename, char mode)
 Opens or creates a file.
 
 File (const char *filename, char mode)
 Opens or creates a file.
 
 ~File ()
 Closes the file if it is open.
 
void open (std::string filename, char mode)
 Opens or creates a file, closing any currently open file first.
 
void close ()
 Closes the file if it is open.
 
bool is_open () const
 Returns true when this object owns an open NetCDF file id.
 
void sync () const
 Flushes buffered changes to disk.
 
- Public Member Functions inherited from netCDF::Group
Attribute add_attribute (std::string name)
 Defines an attribute handle. The attribute is created when a value is written.
 
Attribute add_attribute (const Attribute &a)
 Copies an attribute into this group.
 
Dimension add_dimension (std::string name)
 Defines an unlimited dimension.
 
Dimension add_dimension (std::string name, std::size_t len)
 Defines a fixed-size dimension.
 
Dimension add_dimension (const Dimension &d)
 Copies a dimension into this group.
 
template<typename T >
Variable add_dimension_variable (std::string name)
 Defines an unlimited dimension and a variable with the same name.
 
template<typename T >
Variable add_dimension_variable (std::string name, std::size_t len)
 Defines a fixed-size dimension and a variable with the same name.
 
template<typename T >
Variable add_dimension_variable (const Dimension &d)
 Defines a variable with the same name and extent as an existing dimension.
 
Group add_group (std::string name)
 Defines a child group.
 
Group add_group (const Group &g, bool variable_values=false)
 Copies a group into this group.
 
UserType add_type_compound (std::string name, std::size_t bytes_size)
 Defines a compound user type with an explicit byte size.
 
template<typename T >
UserType add_type_compound (std::string name)
 Defines a compound user type with sizeof(T).
 
UserType add_type_enum (std::string name, nc_type basetype)
 Defines an enum user type with an explicit NetCDF base type.
 
template<typename T >
UserType add_type_enum (std::string name)
 Defines an enum user type using the C++ enum underlying type.
 
UserType add_type_vlen (std::string name, nc_type basetype)
 Defines a variable-length user type with an explicit NetCDF base type.
 
template<typename T >
UserType add_type_vlen (std::string name)
 Defines a variable-length user type using the mapped NetCDF type of T.
 
UserType add_type_opaque (std::string name, std::size_t bytes_size)
 Defines an opaque user type.
 
UserType add_user_type (const UserType &t)
 Copies a user-defined type into this group.
 
Variable add_variable (std::string name, const UserType &type, const std::vector< int > &dims)
 Defines a variable using a user-defined type and dimension ids.
 
Variable add_variable (std::string name, const UserType &type, const std::vector< Dimension > &dims)
 Defines a variable using a user-defined type and dimension objects.
 
Variable add_variable (std::string name, const UserType &type, const std::vector< std::string > &dims)
 Defines a variable using a user-defined type and dimension names.
 
Variable add_variable (std::string name, nc_type type, const std::vector< int > &dims)
 Defines a variable using a NetCDF type id and dimension ids.
 
Variable add_variable (std::string name, nc_type type, const std::vector< Dimension > &dims)
 Defines a variable using a NetCDF type id and dimension objects.
 
Variable add_variable (std::string name, nc_type type, const std::vector< std::string > &dims)
 Defines a variable using a NetCDF type id and dimension names.
 
template<typename T >
Variable add_variable (std::string name, const std::vector< int > &dims)
 Defines a variable using the mapped NetCDF type of T and dimension ids.
 
template<typename T >
Variable add_variable (std::string name, const std::vector< Dimension > &dims)
 Defines a variable using the mapped NetCDF type of T and dimension objects.
 
template<typename T >
Variable add_variable (std::string name, const std::vector< std::string > &dims)
 Defines a variable using the mapped NetCDF type of T and dimension names.
 
Variable add_variable (const Variable &v, bool with_values=false)
 Copies a variable definition into this group.
 
Maybe< Attributeattribute (std::string name) const
 Looks up a group attribute by name.
 
std::vector< Attributeattributes () const
 Returns all group attributes.
 
void copy_attributes (const Group &g)
 Copies all group attributes from another group.
 
void copy_dimensions (const Group &g)
 Copies all dimensions from another group.
 
void copy_from (const Group &g, bool variable_values=false)
 Copies attributes, dimensions, user types, variables, and child groups.
 
void copy_groups (const Group &g, bool variable_values=false)
 Copies child groups from another group.
 
void copy_user_types (const Group &g)
 Copies user-defined types from another group.
 
void copy_variables (const Group &g, bool variable_values=false)
 Copies variables from another group.
 
Maybe< Dimensiondimension (std::string name) const
 Looks up a dimension by name.
 
std::vector< Dimensiondimensions () const
 Returns all dimensions visible in this group.
 
Maybe< Groupgroup (std::string name) const
 Looks up a child group by name.
 
std::vector< Groupgroups () const
 Returns all direct child groups.
 
void rename (std::string name)
 Renames the group in place.
 
Maybe< Groupparent () const
 Returns the parent group, if this is not the root group.
 
Maybe< UserTypeuser_type (std::string name) const
 Looks up a user-defined type by name.
 
std::vector< UserTypeuser_types () const
 Returns all user-defined types in this group.
 
Maybe< Variablevariable (std::string name) const
 Looks up a variable by name.
 
std::vector< Variablevariables () const
 Returns all variables in this group.
 
- Public Member Functions inherited from netCDF::detail::Object
const std::string & name () const
 
int id () const
 

Additional Inherited Members

- Protected Member Functions inherited from netCDF::Group
 Group (std::shared_ptr< detail::Path > path_p)
 
- Protected Member Functions inherited from netCDF::detail::Object
 Object (std::shared_ptr< Path > path_p)
 
void raise_error (int ret) const
 
void check (int ret) const
 
- Static Protected Member Functions inherited from netCDF::detail::Object
static std::string get_error_message (int ret)
 
- Protected Attributes inherited from netCDF::detail::Object
std::shared_ptr< Pathpath
 

Detailed Description

NetCDF file handle and root group.

File owns the NetCDF file id and closes it in the destructor.

Constructor & Destructor Documentation

◆ File() [1/3]

netCDF::File::File ( )
inline

Creates a closed file handle.

◆ File() [2/3]

netCDF::File::File ( std::string  filename,
char  mode 
)
inline

Opens or creates a file.

Modes are ‘'r’for read-only,'a'for read-write append, and'w'` for creating a NetCDF4 file with clobber semantics.

◆ File() [3/3]

netCDF::File::File ( const char *  filename,
char  mode 
)
inline

Opens or creates a file.

◆ ~File()

netCDF::File::~File ( )
inline

Closes the file if it is open.

Member Function Documentation

◆ close()

void netCDF::File::close ( )
inline

Closes the file if it is open.

◆ is_open()

bool netCDF::File::is_open ( ) const
inline

Returns true when this object owns an open NetCDF file id.

◆ open()

void netCDF::File::open ( std::string  filename,
char  mode 
)
inline

Opens or creates a file, closing any currently open file first.

◆ sync()

void netCDF::File::sync ( ) const
inline

Flushes buffered changes to disk.


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