bes  Updated for version 3.20.6
FONcUtils Class Reference

Utilities used to help in the return of an OPeNDAP DataDDS object as a netcdf file. More...

#include <FONcUtils.h>

Collaboration diagram for FONcUtils:
Collaboration graph

Static Public Member Functions

static FONcBaseTypeconvert (BaseType *v)
 Creates a FONc object for the given DAP object. More...
 
static string gen_name (const vector< string > &embed, const string &name, string &original)
 generate a new name for the embedded variable More...
 
static nc_type get_nc_type (BaseType *element)
 translate the OPeNDAP data type to a netcdf data type More...
 
static void handle_error (int stax, const string &err, const string &file, int line)
 handle any netcdf errors More...
 
static string id2netcdf (string in)
 convert the provided string to a netcdf allowed identifier. More...
 
static void reset ()
 Resets the FONc transformation for a new input and out file. More...
 

Static Public Attributes

static string name_prefix = ""
 If a variable name, dimension name, or attribute name begins with a character that is not supported by netcdf, then use this prefix to prepend to the name. More...
 

Detailed Description

Utilities used to help in the return of an OPeNDAP DataDDS object as a netcdf file.

This class includes static functions to help with the conversion of an OPeNDAP DataDDS object into a netcdf file.

Definition at line 54 of file FONcUtils.h.

Member Function Documentation

◆ convert()

FONcBaseType * FONcUtils::convert ( BaseType *  v)
static

Creates a FONc object for the given DAP object.

This is a simple factory for FONcBaseType objects that maps the DAP2 data types into netCDF3 and netCDF4 types (actually instances of FONcBaseType's specializations).

Parameters
vThe DAP object to convert
Returns
The FONc object created via the DAP object
Exceptions
BESInternalErrorif the DAP object is not an expected type

Definition at line 182 of file FONcUtils.cc.

◆ gen_name()

string FONcUtils::gen_name ( const vector< string > &  embed,
const string &  name,
string &  original 
)
static

generate a new name for the embedded variable

This function takes the name of a variable as it exists in a data file, and generates a new name given that netcdf does not have structures or grids. Variables within structures and grids are considered embedded variables, so a new name needs to be generated.

The new name is then passed top id2netcdf to remove any characters that are not allowed by netcdf.

Parameters
embedA list of names for parent structures
nameThe name of the variable to use for the new name
originalThe variable name before calling id2netcdf
Returns
the newly generated name with embedded names preceeding it, and converted using id2netcdf

Definition at line 148 of file FONcUtils.cc.

◆ get_nc_type()

nc_type FONcUtils::get_nc_type ( BaseType *  element)
static

translate the OPeNDAP data type to a netcdf data type

Parameters
elementThe OPeNDAP element to translate
Returns
the netcdf data type

Definition at line 102 of file FONcUtils.cc.

◆ handle_error()

void FONcUtils::handle_error ( int  stax,
const string &  err,
const string &  file,
int  line 
)
static

handle any netcdf errors

Looks up the netcdf error message associated with the provided netcdf return value and throws an exception with that information appended to the provided error message.

Note
Modified: This used to test the value of stax and return without doing anything if stax == NC_NOERR. This should not be called if there is no error.
Parameters
staxA netcdf return value. Should be any value other than NC_NOERR
errA provided error message to begin the error message with
fileThe source code file name where the error was generated
lineThe source code line number where the error was generated
Returns
Never returns
Exceptions
BESErrorif the return value represents a netcdf error

Definition at line 245 of file FONcUtils.cc.

◆ id2netcdf()

string FONcUtils::id2netcdf ( string  in)
static

convert the provided string to a netcdf allowed identifier.

The function makes a copy of the incoming parameter to use and returns the new string.

Parameters
inidentifier to convert
Returns
new netcdf compliant identifier

Definition at line 75 of file FONcUtils.cc.

◆ reset()

void FONcUtils::reset ( )
static

Resets the FONc transformation for a new input and out file.

Definition at line 59 of file FONcUtils.cc.

Member Data Documentation

◆ name_prefix

string FONcUtils::name_prefix = ""
static

If a variable name, dimension name, or attribute name begins with a character that is not supported by netcdf, then use this prefix to prepend to the name.

Definition at line 56 of file FONcUtils.h.


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