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

NetCDF attribute attached to a group or variable. More...

#include <netcdfpp.h>

Public Member Functions

void copy_values (const Attribute &a)
 Copies the value and type metadata from another attribute.
 
template<typename T >
std::vector< T > get () const
 Reads the attribute as a vector of values.
 
std::string get_string () const
 Reads a classic NetCDF text attribute as a C++ string.
 
bool is_group_attribute () const
 Returns true when this attribute is attached to a group rather than a variable.
 
Maybe< Groupparent_group () const
 Returns the parent group for group attributes.
 
Maybe< Variableparent_variable () const
 Returns the parent variable for variable attributes.
 
void rename (std::string name)
 Renames the attribute in place.
 
template<typename T >
void set (const std::vector< T > &v)
 Writes a vector of atomic values to the attribute.
 
template<typename T >
void set (const std::vector< T > &v, const UserType &type)
 Writes a vector of values using a user-defined NetCDF type.
 
template<typename T >
void set (const T &v, const UserType &type)
 Writes one value using a user-defined NetCDF type.
 
template<typename T >
std::enable_if< std::is_same< std::string, T >::value, void >::type set (T v)
 Writes a string attribute.
 
template<typename T >
std::enable_if< std::is_same< constchar *, T >::value||std::is_same< char *, T >::value, void >::type set (T v)
 Writes a string attribute from a C string.
 
template<typename T >
std::enable_if<!std::is_same< std::string, T >::value &&!std::is_same< constchar *, T >::value &&!std::is_same< char *, T >::value, void >::type set (T v)
 Writes one atomic value to the attribute.
 
std::size_t size () const
 Returns the number of values stored in the attribute.
 
nc_type type () const
 Returns the NetCDF type id of the attribute.
 
std::string type_name () const
 Returns the NetCDF type name of the attribute.
 
Attribute require_type (const std::string &name) const
 Returns this attribute or throws if its NetCDF type name differs.
 
Maybe< UserTypeuser_type () const
 Returns the user-defined type for this attribute, if it has one.
 
template<>
std::vector< std::string > get () const
 
template<>
void set (const std::vector< std::string > &v)
 
template<>
void set (const std::vector< const char * > &v)
 
template<>
void set (const std::vector< char * > &v)
 
template<>
int set_internal (int ncid_p, int othid_p, const char *name_p, std::size_t len, const char *v)
 
- Public Member Functions inherited from netCDF::detail::Object
const std::string & name () const
 
int id () const
 

Friends

class Group
 
class Maybe< Attribute >
 
class Variable
 

Additional Inherited Members

- 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 attribute attached to a group or variable.

Member Function Documentation

◆ copy_values()

void netCDF::Attribute::copy_values ( const Attribute a)
inline

Copies the value and type metadata from another attribute.

◆ get() [1/2]

template<typename T >
std::vector< T > netCDF::Attribute::get ( ) const
inline

Reads the attribute as a vector of values.

Use get_string() for classic text attributes. Use get<std::string>() for NetCDF string attributes.

◆ get() [2/2]

template<>
std::vector< std::string > netCDF::Attribute::get ( ) const
inline

◆ get_string()

std::string netCDF::Attribute::get_string ( ) const
inline

Reads a classic NetCDF text attribute as a C++ string.

◆ is_group_attribute()

bool netCDF::Attribute::is_group_attribute ( ) const
inline

Returns true when this attribute is attached to a group rather than a variable.

◆ parent_group()

Maybe< Group > netCDF::Attribute::parent_group ( ) const
inline

Returns the parent group for group attributes.

◆ parent_variable()

Maybe< Variable > netCDF::Attribute::parent_variable ( ) const
inline

Returns the parent variable for variable attributes.

◆ rename()

void netCDF::Attribute::rename ( std::string  name)
inline

Renames the attribute in place.

◆ require_type()

Attribute netCDF::Attribute::require_type ( const std::string &  name) const
inline

Returns this attribute or throws if its NetCDF type name differs.

◆ set() [1/9]

template<>
void netCDF::Attribute::set ( const std::vector< char * > &  v)
inline

◆ set() [2/9]

template<>
void netCDF::Attribute::set ( const std::vector< const char * > &  v)
inline

◆ set() [3/9]

template<>
void netCDF::Attribute::set ( const std::vector< std::string > &  v)
inline

◆ set() [4/9]

template<typename T >
void netCDF::Attribute::set ( const std::vector< T > &  v)
inline

Writes a vector of atomic values to the attribute.

◆ set() [5/9]

template<typename T >
void netCDF::Attribute::set ( const std::vector< T > &  v,
const UserType type 
)
inline

Writes a vector of values using a user-defined NetCDF type.

◆ set() [6/9]

template<typename T >
void netCDF::Attribute::set ( const T &  v,
const UserType type 
)
inline

Writes one value using a user-defined NetCDF type.

◆ set() [7/9]

template<typename T >
std::enable_if< std::is_same< std::string, T >::value, void >::type netCDF::Attribute::set ( v)
inline

Writes a string attribute.

◆ set() [8/9]

template<typename T >
std::enable_if< std::is_same< constchar *, T >::value||std::is_same< char *, T >::value, void >::type netCDF::Attribute::set ( v)
inline

Writes a string attribute from a C string.

◆ set() [9/9]

template<typename T >
std::enable_if<!std::is_same< std::string, T >::value &&!std::is_same< constchar *, T >::value &&!std::is_same< char *, T >::value, void >::type netCDF::Attribute::set ( v)
inline

Writes one atomic value to the attribute.

◆ set_internal()

template<>
int netCDF::Attribute::set_internal ( int  ncid_p,
int  othid_p,
const char *  name_p,
std::size_t  len,
const char *  v 
)
inline

◆ size()

std::size_t netCDF::Attribute::size ( ) const
inline

Returns the number of values stored in the attribute.

◆ type()

nc_type netCDF::Attribute::type ( ) const
inline

Returns the NetCDF type id of the attribute.

◆ type_name()

std::string netCDF::Attribute::type_name ( ) const
inline

Returns the NetCDF type name of the attribute.

◆ user_type()

Maybe< UserType > netCDF::Attribute::user_type ( ) const
inline

Returns the user-defined type for this attribute, if it has one.

Friends And Related Symbol Documentation

◆ Group

friend class Group
friend

◆ Maybe< Attribute >

friend class Maybe< Attribute >
friend

◆ Variable

friend class Variable
friend

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