34#include <libdap/BaseType.h>
35#include <libdap/Byte.h>
36#include <libdap/Int16.h>
37#include <libdap/Int32.h>
38#include <libdap/UInt16.h>
39#include <libdap/UInt32.h>
40#include <libdap/Float32.h>
41#include <libdap/Float64.h>
42#include <libdap/Str.h>
43#include <libdap/Url.h>
45#include <libdap/DDS.h>
46#include <libdap/ConstraintEvaluator.h>
47#include <libdap/Marshaller.h>
49#include <libdap/debug.h>
52#include "CachedSequence.h"
59void CachedSequence::load_prototypes_with_values(BaseTypeRow &btr,
bool safe)
65 Vars_iter i = d_vars.begin(), e = d_vars.end();
66 for (BaseTypeRow::iterator vi = btr.begin(), ve = btr.end(); vi != ve; ++vi) {
68 if (safe && (i == e || ((*i)->type() != (*vi)->type())))
69 throw InternalErr(__FILE__, __LINE__,
"Expected number and types to match when loading values.");
72 switch ((*i)->type()) {
74 static_cast<Byte*
>(*i++)->set_value(
static_cast<Byte*
>(*vi)->value());
77 static_cast<Int16*
>(*i++)->set_value(
static_cast<Int16*
>((*vi))->value());
80 static_cast<Int32*
>(*i++)->set_value(
static_cast<Int32*
>((*vi))->value());
83 static_cast<UInt16*
>(*i++)->set_value(
static_cast<UInt16*
>((*vi))->value());
86 static_cast<UInt32*
>(*i++)->set_value(
static_cast<UInt32*
>((*vi))->value());
89 static_cast<Float32*
>(*i++)->set_value(
static_cast<Float32*
>((*vi))->value());
92 static_cast<Float64*
>(*i++)->set_value(
static_cast<Float64*
>((*vi))->value());
95 static_cast<Str*
>(*i++)->set_value(
static_cast<Str*
>((*vi))->value());
98 static_cast<Url*
>(*i++)->set_value(
static_cast<Url*
>((*vi))->value());
101 case dods_sequence_c:
103 throw InternalErr(__FILE__, __LINE__,
"Expected nested sequence to be the last variable.");
107 throw InternalErr(__FILE__, __LINE__,
"Expected a scalar (or nested sequence) when loading values.");
144 DBGN(cerr << __PRETTY_FUNCTION__ <<
" name: " << name() <<
", row number " << row <<
", current row " << get_row_number() << endl);
153 assert(row > get_row_number());
155 while (row > get_row_number()) {
160 BaseTypeRow *btr_ptr = row_value(d_value_index++);
166 if (!btr_ptr)
return false;
170 load_prototypes_with_values(*btr_ptr,
false);
172 load_prototypes_with_values(*btr_ptr,
true);
175 increment_row_number(1);
178 else if (ce_eval && eval.eval_selection(dds, dataset())) {
179 increment_row_number(1);
204 return Sequence::serialize(eval, dds, m, ce_eval);
220 Sequence::intern_data(eval, dds);
234 strm << BESIndent::LMarg <<
"CachedSequence::dump - (" << (
void *)
this <<
")" << endl ;
235 BESIndent::Indent() ;
236 Sequence::dump(strm) ;
237 BESIndent::UnIndent() ;
virtual void intern_data(libdap::ConstraintEvaluator &eval, libdap::DDS &dds)
Specialization that resets CachedSequence's 'value index' state variable.
virtual void dump(ostream &strm) const
dumps information about this object
virtual bool read_row(int row, libdap::DDS &dds, libdap::ConstraintEvaluator &eval, bool ce_eval)
Read row number row of the Sequence.
virtual bool serialize(libdap::ConstraintEvaluator &eval, libdap::DDS &dds, libdap::Marshaller &m, bool ce_eval=true)
Specialization that resets CachedSequence's 'value index' state variable.