30using std::ostringstream;
34#include <libdap/Error.h>
35#include <libdap/debug.h>
38#include "FFD4Sequence.h"
46static long Records(
const string &filename)
49 DATA_BIN_PTR dbin = NULL;
50 FF_STD_ARGS_PTR SetUps = NULL;
51 PROCESS_INFO_LIST pinfo_list = NULL;
52 PROCESS_INFO_PTR pinfo = NULL;
53 static char Msgt[255];
55 SetUps = ff_create_std_args();
61 SetUps->user.is_stdin_redirected = 0;
62 SetUps->input_file =
const_cast<char*
>(filename.c_str());
64 SetUps->output_file = NULL;
66 error = SetDodsDB(SetUps, &dbin, Msgt);
67 if (error && error < ERR_WARNING_ONLY) {
72 ff_destroy_std_args(SetUps);
74 error = db_ask(dbin, DBASK_PROCESS_INFO, FFF_INPUT | FFF_DATA,
79 pinfo_list = dll_first(pinfo_list);
81 pinfo = ((PROCESS_INFO_PTR) (pinfo_list)->data.u.pi);
83 long num_records = PINFO_SUPER_ARRAY_ELS(pinfo);
85 ff_destroy_process_info_list(pinfo_list);
102 DBG(cerr <<
"Entering FFD4Sequence::read..." << endl);
107 if ((BufPtr >= BufSiz) && (BufSiz != 0))
116 o_fmt <<
"binary_output_data \"DODS binary output data\"" << endl;
117 for (Vars_iter p = var_begin(); p != var_end(); ++p) {
118 if ((*p)->synthesized_p())
120 if ((*p)->type() == dods_str_c)
121 endbyte +=
static_cast<FFStr&
>(**p).size();
123 endbyte += (*p)->width();
125 o_fmt << (*p)->name() <<
" " << stbyte <<
" " << endbyte <<
" " << ff_types((*p)->type()) <<
" "
126 << ff_prec((*p)->type()) << endl;
127 stbyte = endbyte + 1;
130 DBG(cerr << o_fmt.str());
133 long num_rec = Records(dataset());
138 BufSiz = num_rec * (stbyte - 1);
139 BufVal =
new char[BufSiz];
141 long bytes = read_ff(dataset().c_str(), d_input_format_file.c_str(), o_fmt.str().c_str(), BufVal, BufSiz);
144 throw Error(
"Could not read requested data from the dataset.");
147 for (Vars_iter p = var_begin(); p != var_end(); ++p)
155void FFD4Sequence::transfer_attributes(AttrTable *at)
158 Vars_iter var = var_begin();
159 while (var != var_end()) {
160 (*var)->transfer_attributes(at);