45 #include <ConstraintEvaluator.h>
46 #include <Marshaller.h>
47 #include <UnMarshaller.h>
59 static const unsigned char end_of_sequence = 0xA5;
60 static const unsigned char start_of_instance = 0x5A;
63 write_end_of_sequence(Marshaller &m)
65 m.put_opaque( (
char *)&end_of_sequence, 1 ) ;
69 write_start_of_instance(Marshaller &m)
71 m.put_opaque( (
char *)&start_of_instance, 1 ) ;
74 void TabularSequence::load_prototypes_with_values(BaseTypeRow &btr,
bool safe)
80 Vars_iter i = d_vars.begin(), e = d_vars.end();
81 for (BaseTypeRow::iterator vi = btr.begin(), ve = btr.end(); vi != ve; ++vi) {
83 if (safe && (i == e || ((*i)->type() != (*vi)->var()->type())))
84 throw InternalErr(__FILE__, __LINE__,
"Expected number and types to match when loading values for selection expression evaluation.");
87 switch ((*i)->type()) {
89 static_cast<Byte*
>(*i++)->set_value(static_cast<Byte*>(*vi)->value());
92 static_cast<Int16*
>(*i++)->set_value(static_cast<Int16*>((*vi))->value());
95 static_cast<Int32*
>(*i++)->set_value(static_cast<Int32*>((*vi))->value());
98 static_cast<UInt16*
>(*i++)->set_value(static_cast<UInt16*>((*vi))->value());
101 static_cast<UInt32*
>(*i++)->set_value(static_cast<UInt32*>((*vi))->value());
104 static_cast<Float32*
>(*i++)->set_value(static_cast<Float32*>((*vi))->value());
107 static_cast<Float64*
>(*i++)->set_value(static_cast<Float64*>((*vi))->value());
110 static_cast<Str*
>(*i++)->set_value(static_cast<Str*>((*vi))->value());
113 static_cast<Url*
>(*i++)->set_value(static_cast<Url*>((*vi))->value());
116 throw InternalErr(__FILE__, __LINE__,
"Expected a scalar type when loading values for selection expression evaluation.");
131 TabularSequence::TabularSequence(
const string &n) : Sequence(n)
172 dynamic_cast<Sequence &
>(*this) = rhs;
197 DBG(cerr <<
"Entering TabularSequence::serialize for " << name() << endl);
199 SequenceValues values = value();
202 for (SequenceValues::iterator i = values.begin(), e = values.end(); i != e; ++i) {
204 BaseTypeRow &btr = **i;
212 for (BaseTypeRow::iterator vi = btr.begin(), ve = btr.end(); vi != ve; ++vi) {
214 (*vi)->buf2val(&val);
215 d_vars.at(j++)->val2buf(val);
219 if (ce_eval && !eval.eval_selection(dds, dataset()))
223 write_start_of_instance(m);
226 for (BaseTypeRow::iterator vi = btr.begin(), ve = btr.end(); vi != ve; ++vi) {
227 if ((*vi)->send_p()) {
228 (*vi)->serialize(eval, dds, m,
false);
233 write_end_of_sequence(m);
249 DBG(cerr <<
"Entering TabularSequence::intern_data" << endl);
257 SequenceValues result;
258 SequenceValues &values = value_ref();
260 for (SequenceValues::iterator i = values.begin(), e = values.end(); i != e; ++i) {
262 BaseTypeRow &btr = **i;
269 for (BaseTypeRow::iterator vi = btr.begin(), ve = btr.end(); vi != ve; ++vi) {
272 (*vi)->buf2val(&val);
273 d_vars.at(j++)->val2buf(val);
277 if (!eval.eval_selection(dds, dataset()))
280 BaseTypeRow *result_row =
new BaseTypeRow();
282 for (BaseTypeRow::iterator vi = btr.begin(), ve = btr.end(); vi != ve; ++vi) {
283 if ((*vi)->send_p()) {
284 result_row->push_back(*vi);
288 result.push_back(result_row);
294 DBG(cerr <<
"Leaving TabularSequence::intern_data" << endl);
308 strm << DapIndent::LMarg <<
"TabularSequence::dump - (" << (
void *)
this <<
")" << endl ;
309 DapIndent::Indent() ;
310 Sequence::dump(strm) ;
311 DapIndent::UnIndent() ;
TabularSequence(const string &n)
virtual bool serialize(ConstraintEvaluator &eval, DDS &dds, Marshaller &m, bool ce_eval=true)
Specialized version of Sequence::serialize() for tables that already hold their data.
virtual BaseType * ptr_duplicate()
virtual void dump(ostream &strm) const
dumps information about this object
virtual ~TabularSequence()
static class NCMLUtil overview
TabularSequence & operator=(const TabularSequence &rhs)
virtual void intern_data(ConstraintEvaluator &eval, DDS &dds)
Specialized intern_data().
void load_prototypes_with_values(BaseTypeRow &btr, bool safe=true)