OPeNDAP Hyrax Back End Server (BES)  Updated for version 3.8.3
util_ff.cc File Reference
#include "config_ff.h"
#include <unistd.h>
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <cstdlib>
#include <BESDebug.h>
#include <BaseType.h>
#include <Byte.h>
#include <Int16.h>
#include <Int32.h>
#include <UInt16.h>
#include <UInt32.h>
#include <Float32.h>
#include <Float64.h>
#include <InternalErr.h>
#include <dods-limits.h>
#include <util.h>
#include <debug.h>
#include "FFRequestHandler.h"
#include "util_ff.h"
Include dependency graph for util_ff.cc:

Go to the source code of this file.

Functions

int ff_prec (Type dods_type)
 
const string ff_types (Type dods_type)
 
bool file_exist (const char *filename)
 
const string find_ancillary_rss_das (const string &dataset, const string &, const string &)
 Find the RSS (Remote Sensing Systems) format file using their naming convention. More...
 
const string find_ancillary_rss_formats (const string &dataset, const string &, const string &)
 Find the RSS (Remote Sensing Systems) format file using their naming convention. More...
 
const string & format_delimiter (const string &new_delimiter)
 Set or get the format file delimiter. More...
 
const string & format_extension (const string &new_extension)
 Set or get the format file extension. More...
 
void free_ff_char_vector (char **v, int len)
 Free a char ** vector that db_ask() allocates. More...
 
dods_float64 get_float_value (BaseType *var) throw (InternalErr)
 
dods_uint32 get_integer_value (BaseType *var) throw (InternalErr)
 Get the value of the BaseType Variable. More...
 
BOOLEAN is_a_warning (FF_ERROR_PTR error)
 
bool is_float_type (BaseType *btp)
 
bool is_integer_type (BaseType *btp)
 
const string make_output_format (const string &name, Type type, const int width)
 Make a FreeForm output format specification. More...
 
const string makeND_output_format (const string &name, Type type, const int width, int ndim, const long *start, const long *edge, const long *stride, string *dname)
 
FF_ERROR_PTR pull_error (void)
 
long read_ff (const char *dataset, const char *if_file, const char *o_format, char *o_buffer, unsigned long bsize)
 Read from a file/database using the FreeForm API. More...
 
long Records (const string &filename)
 Figure out how many records there are in the dataset. More...
 
int SetDodsDB (FF_STD_ARGS_PTR std_args, DATA_BIN_HANDLE dbin_h, char *Msgt)
 Given a set of standard arguments (input filenames), allocate a DATA-BIN_HANDLE and return an error code. More...
 

Function Documentation

int ff_prec ( Type  dods_type)
const string ff_types ( Type  dods_type)
bool file_exist ( const char *  filename)

Definition at line 532 of file util_ff.cc.

Referenced by ff_read_descriptors(), and read_attributes().

const string find_ancillary_rss_das ( const string &  dataset,
const string &  ,
const string &   
)

Find the RSS (Remote Sensing Systems) format file using their naming convention.

File naming convention: <data source>=""> + '_' + <date_string> + <version> + (optional)< _d3d > When <date_string> includes YYYYMMDDVV ('DD') the file contains 'daily' data. When <date_string> only includes YYYYMMVV ( no 'DD'), or includes ('DD') and optional '_d3d' then the file contains averaged data.

Different format files are required for 'daily' and 'averaged' data.

Returns
A const string object which contains the format file name.

Definition at line 607 of file util_ff.cc.

References FFRequestHandler::get_RSS_format_files().

Referenced by FFRequestHandler::ff_build_das().

Here is the call graph for this function:

const string find_ancillary_rss_formats ( const string &  dataset,
const string &  ,
const string &   
)

Find the RSS (Remote Sensing Systems) format file using their naming convention.

File naming convention: <data source>=""> + '_' + <date_string> + <version> + (optional)< _d3d > When <date_string> includes YYYYMMDDVV ('DD') the file contains 'daily' data. When <date_string> only includes YYYYMMVV ( no 'DD'), or includes ('DD') and optional '_d3d' then the file contains averaged data.

Different format files are required for 'daily' and 'averaged' data.

Returns
A const string object which contains the format file name.

Definition at line 550 of file util_ff.cc.

References FFRequestHandler::get_RSS_format_files().

Referenced by ff_read_descriptors(), and read_attributes().

Here is the call graph for this function:

const string& format_delimiter ( const string &  new_delimiter)

Set or get the format file delimiter.

If given no argument, return the format file basename delimiter. If given a string argument, set the format file basename delimiter to that string.

Returns
A reference to the delimiter string.

Definition at line 344 of file util_ff.cc.

const string& format_extension ( const string &  new_extension)

Set or get the format file extension.

If given no argument, return the format file extension. If given a string argument, set the format file extension to that string.

Returns
A reference to the format file extension.

Definition at line 360 of file util_ff.cc.

void free_ff_char_vector ( char **  v,
int  len 
)

Free a char ** vector that db_ask() allocates.

This code uses free() to do the delete.

Note
There maybe code in FreeForm to do this, but I can't find it.

Definition at line 232 of file util_ff.cc.

References free().

Here is the call graph for this function:

dods_float64 get_float_value ( BaseType *  var)
throw (InternalErr
)

Definition at line 735 of file util_ff.cc.

References get_integer_value().

Referenced by DODS_Time_Factory::get().

Here is the call graph for this function:

dods_uint32 get_integer_value ( BaseType *  var)
throw (InternalErr
)

Get the value of the BaseType Variable.

If it's not something that we can convert to an integer, throw InternalErr.

Parameters
varThe variable

Definition at line 708 of file util_ff.cc.

Referenced by DODS_Time_Factory::get(), DODS_Date_Factory::get(), and get_float_value().

BOOLEAN is_a_warning ( FF_ERROR_PTR  error)
bool is_float_type ( BaseType *  btp)

Definition at line 678 of file util_ff.cc.

Referenced by DODS_Time_Factory::DODS_Time_Factory().

bool is_integer_type ( BaseType *  btp)
const string make_output_format ( const string &  name,
Type  type,
const int  width 
)

Make a FreeForm output format specification.

For the current instance of FFArray, build a FreeForm output format specification.

Returns
The format string.

Definition at line 306 of file util_ff.cc.

References ff_prec(), and ff_types().

Here is the call graph for this function:

const string makeND_output_format ( const string &  name,
Type  type,
const int  width,
int  ndim,
const long *  start,
const long *  edge,
const long *  stride,
string *  dname 
)

Definition at line 319 of file util_ff.cc.

References ff_prec(), and ff_types().

Referenced by FFArray::read().

Here is the call graph for this function:

FF_ERROR_PTR pull_error ( void  )
long read_ff ( const char *  dataset,
const char *  if_file,
const char *  o_format,
char *  o_buffer,
unsigned long  bsize 
)

Read from a file/database using the FreeForm API.

Data values are read using an input file descriptor and written using an output format description.

Note
I moved this function from ff_read.c (C code) here so I could use exceptions to report errors found while using the FreeForm API. jhrg 9/11/12
Parameters
datasetThe name of the file/database to read from
if_fileThe input format descriptor
o_formatThe output format description
o_bufferValue-result parameter for the data
bsizeSize of the buffer in bytes

Definition at line 156 of file util_ff.cc.

References BES_SYNTAX_USER_ERROR, BESDEBUG, struct_ff_bufsize::buffer, struct_ff_bufsize::bytes_used, err_count(), struct_ff_std_args::error_prompt, FALSE, ff_create_bufsize(), ff_create_std_args(), ff_destroy_bufsize(), ff_destroy_std_args(), struct_ff_std_args::input_file, struct_ff_std_args::input_format_file, struct_ff_std_args::struct_std_args_user::is_stdin_redirected, struct_ff_std_args::log_file, newform(), NULL, struct_ff_std_args::output_bufsize, struct_ff_std_args::output_file, struct_ff_std_args::output_format_buffer, SCRATCH_QUANTA, struct_ff_bufsize::total_bytes, struct_ff_bufsize::usage, and struct_ff_std_args::user.

Referenced by FFArray::extract_array(), FFD4Sequence::read(), and FFSequence::read().

Here is the call graph for this function:

long Records ( const string &  filename)

Figure out how many records there are in the dataset.

Parameters
filename

set the structure values to create the FreeForm DB

Definition at line 487 of file util_ff.cc.

References db_ask(), db_destroy(), DBASK_PROCESS_INFO, dll_first(), ERR_WARNING_ONLY, ff_create_std_args(), ff_destroy_process_info_list(), ff_destroy_std_args(), FFF_DATA, FFF_INPUT, struct_ff_std_args::input_file, struct_ff_std_args::struct_std_args_user::is_stdin_redirected, NULL, struct_ff_std_args::output_file, PINFO_SUPER_ARRAY_ELS, SetDodsDB(), and struct_ff_std_args::user.

Referenced by FFD4Sequence::read(), and FFSequence::read().

Here is the call graph for this function:

int SetDodsDB ( FF_STD_ARGS_PTR  std_args,
DATA_BIN_HANDLE  dbin_h,
char *  Msgt 
)

Given a set of standard arguments (input filenames), allocate a DATA-BIN_HANDLE and return an error code.

Once called, the caller should free the std_args parameter.

Parameters
std_argsA pointer to a structure that holds a number of input and out file names.

Definition at line 402 of file util_ff.cc.

References assert, db_make(), db_set(), DBSET_CREATE_CONDUITS, DBSET_HEADER_FILE_NAMES, DBSET_HEADERS, DBSET_INIT_CONDUITS, DBSET_INPUT_FORMATS, DBSET_READ_EQV, dll_free_holdings(), ERR_API, ERR_MEM_LACK, FFF_DATA, FFF_INPUT, struct_ff_std_args::input_file, struct_ff_std_args::input_format_buffer, struct_ff_std_args::input_format_file, struct_ff_std_args::input_format_title, Msgt_size, NULL, struct_ff_std_args::output_file, struct_ff_std_args::records_to_read, and ROUTINE_NAME.

Referenced by ff_read_descriptors(), read_attributes(), and Records().

Here is the call graph for this function: