Previous: Class NcVar, Up: NetCDF Classes


Class NcAtt

NcAtt is derived from NcTypedComponent, and represents a netCDF attribute. A netCDF attribute has a name and a type, and may be either a scalar attribute or a vector attribute. Scalar attributes have one value and vector attributes have multiple values. In addition, each attribute is attached to a specific netCDF variable or is global to an entire netCDF file. Because attributes are only associated with open netCDF files, there are no public constructors for this class. Use member functions of NcFile and NcVar to get netCDF attributes or add new attributes. Most of the useful member functions for NcAtt are inherited from class NcTypedComponent.

Public Member Functions

NcToken name( void ) const
Returns the name of the attribute.


NcType type( void ) const
Returns the type of the attribute. The type will be one of ncByte, ncChar, ncShort, ncInt, ncFloat, or ncDouble.


NcBool is_valid( void ) const
Returns TRUE if the attribute is valid, FALSE otherwise.


long num_vals( void ) const
Returns the number of values for an attribute. This is just 1 for a scalar attribute, the number of values for a vector-valued attribute, and the number of characters for a string-valued attribute.


NcBool rename( NcToken newname )
Renames the attribute.


NcValues* values( void ) const
Returns a pointer to the block of all values for the attribute. The caller is responsible for deleting this block of values when no longer needed.


ncbyte as_ncbyte( int n ) const
char as_char( int n ) const
short as_short( int n ) const
int as_int( int n ) const
nclong as_nclong( int n ) const // deprecated
long as_long( int n ) const
float as_float( int n ) const
double as_double( int n ) const
char* as_string( int n ) const
Get the n-th value of the attribute. These member functions provide conversions from the value type of the attribute to the specified type. If the value is out-of-range, the fill-value of the appropriate type is returned. The caller is responsible for eventually deleting memory allocated by the as_string method.


NcBool remove( void )
Deletes the attribute from the file and detaches it from the variable. Does not call the destructor. Subsequent calls to is_valid() will return FALSE.


~NcAtt( void )
Destructor.