62#include "dods-datatypes.h"
66#undef CLEAR_LOCAL_DATA
73void Vector::m_duplicate(
const Vector &v) {
74 d_length = v.d_length;
75 d_length_ll = v.d_length_ll;
83 d_proto = v.d_proto->ptr_duplicate();
84 d_proto->set_parent(
this);
93 if (v.d_compound_buf.empty()) {
94 d_compound_buf = v.d_compound_buf;
98 d_compound_buf.resize(d_length);
99 for (
int i = 0; i < d_length; ++i) {
104 d_compound_buf[i] = v.d_compound_buf[i]->ptr_duplicate();
116 d_capacity = v.d_capacity;
117 d_capacity_ll = v.d_capacity_ll;
124bool Vector::m_is_cardinal_type()
const {
130 switch (d_proto->type()) {
161 assert(
"Vector::var: Unrecognized type");
178int64_t Vector::m_create_cardinal_data_buffer_for_type(int64_t num_elements) {
181 throw InternalErr(__FILE__, __LINE__,
"create_cardinal_data_buffer_for_type: Logic error: _var is null!");
185 if (!m_is_cardinal_type()) {
186 throw InternalErr(__FILE__, __LINE__,
187 "create_cardinal_data_buffer_for_type: incorrectly used on Vector whose type was not a "
188 "cardinal (simple data types).");
192 if (num_elements == 0)
195 m_delete_cardinal_data_buffer();
199 unsigned int bytesPerElt = d_proto->width();
200 unsigned int bytesNeeded = bytesPerElt * numEltsOfType;
202 int64_t bytesNeeded = d_proto->width_ll() * num_elements;
203 d_buf =
new char[bytesNeeded];
206 d_capacity = (
unsigned long long)num_elements;
213void Vector::m_delete_cardinal_data_buffer() {
223template <
class CardType>
void Vector::m_set_cardinal_values_internal(
const CardType *fromArray, int64_t numElts) {
225 throw InternalErr(__FILE__, __LINE__,
226 "Logic error: Vector::set_cardinal_values_internal() called with negative numElts!");
229 throw InternalErr(__FILE__, __LINE__,
230 "Logic error: Vector::set_cardinal_values_internal() called with null fromArray!");
233 m_create_cardinal_data_buffer_for_type(numElts);
235 memcpy(d_buf, fromArray, numElts *
sizeof(CardType));
259 DBG2(cerr <<
"Entering Vector ctor for object: " <<
this << endl);
261 d_proto->set_parent(
this);
287 DBG2(cerr <<
"Entering Vector ctor for object: " <<
this << endl);
289 d_proto->set_parent(
this);
297 DBG2(cerr <<
"Entering Vector const ctor for object: " <<
this << endl);
298 DBG2(cerr <<
"RHS: " << &rhs << endl);
310 }
catch (
const std::exception &) {
328 d_proto->set_name(
name);
336 return d_proto->element_count(leaves);
354 d_proto->set_send_p(state);
363 switch (d_proto->type()) {
367 if (d_compound_buf.size() > 0) {
368 for (
unsigned long long i = 0; i < (unsigned)d_length; ++i) {
369 if (d_compound_buf[i])
370 d_compound_buf[i]->set_send_p(state);
391 d_proto->set_read_p(state);
394 switch (d_proto->type()) {
398 if (d_compound_buf.size() > 0) {
399 for (
unsigned long long i = 0; i < (unsigned)d_length; ++i) {
400 if (d_compound_buf[i])
401 d_compound_buf[i]->set_read_p(state);
438 d_too_big_for_dap2 =
true;
445 d_capacity = (
unsigned int)l;
448 d_too_big_for_dap2 =
true;
471 DBG2(cerr <<
"Vector::var: Looking for " <<
name << endl);
473 if (
name.empty() || d_proto->name() ==
name) {
482 if (d_proto->is_constructor_type()) {
505 if (d_proto->is_constructor_type())
506 return d_proto->var(
name, s);
527 switch (d_proto->
type()) {
557 return d_compound_buf[i];
560 throw Error (
"Vector::var: Unrecognized type");
568 switch (d_proto->type()) {
585 d_proto->val2buf(d_buf + (i * (uint64_t)d_proto->width_ll()));
590 d_proto->val2buf(&d_str[i]);
598 return d_compound_buf[i];
601 throw Error(
"Vector::var: Unrecognized type");
615 if (m_is_cardinal_type())
616 throw InternalErr(__FILE__, __LINE__,
"Vector::vec_resize() is applicable to compound types only");
621 d_compound_buf.resize(l, 0);
623 d_capacity = d_compound_buf.size();
630 if (m_is_cardinal_type())
631 throw InternalErr(__FILE__, __LINE__,
"Vector::vec_resize() is applicable to compound types only");
636 d_compound_buf.resize(l,
nullptr);
638 d_capacity = d_compound_buf.size();
659 DBG(cerr <<
"Vector::intern_data: " <<
name() << endl);
661 throw Error(
string(
"A method usable only with DAP2 variables was called on a DAP4 variable (")
672 switch (d_proto->type()) {
692 throw InternalErr(__FILE__, __LINE__,
"Array of Array not supported.");
697 DBG(cerr <<
"Vector::intern_data: found ctor" << endl);
703 if (d_compound_buf.capacity() < (
unsigned)num)
704 throw InternalErr(__FILE__, __LINE__,
"The capacity of this Vector is less than the number of elements.");
706 for (
int i = 0; i < num; ++i)
712 throw InternalErr(__FILE__, __LINE__,
"Unknown datatype.");
730 throw Error(
string(
"A method usable only with DAP2 variables was called on a DAP4 variable (")
735 if (d_too_big_for_dap2)
736 throw Error(
"Trying to send a variable that is too large for DAP2.", __FILE__, __LINE__);
756 switch (d_proto->type()) {
768 assert((
int)d_proto->width_ll() == d_proto->width_ll());
769 m.
put_vector(d_buf, num, (
int)d_proto->width_ll(), *
this);
776 if (d_str.capacity() == 0)
777 throw InternalErr(__FILE__, __LINE__,
"The capacity of the string vector is 0");
781 for (
int i = 0; i < num; ++i)
793 if (d_compound_buf.capacity() == 0)
794 throw InternalErr(__FILE__, __LINE__,
"The capacity of *this* vector is 0.");
798 for (
int i = 0; i < num && status; ++i)
799 status = status && d_compound_buf[i]->
serialize(eval, dds, m,
false);
804 throw InternalErr(__FILE__, __LINE__,
"Unknown datatype.");
807#ifdef CLEAR_LOCAL_DATA
836 throw Error(
string(
"A method usable only with DAP2 variables was called on a DAP4 variable (")
841 switch (d_proto->type()) {
851 DBG(cerr <<
"Vector::deserialize: num = " << num << endl);
852 DBG(cerr <<
"Vector::deserialize: length = " <<
length() << endl);
857 if (num != (
unsigned int)
length())
859 "The server sent declarations and data with mismatched sizes for the variable '" +
862 if (!d_buf || !reuse) {
865 m_create_cardinal_data_buffer_for_type(
length_ll());
878 assert((
int)d_proto->width_ll() == d_proto->width_ll());
879 um.
get_vector((
char **)&d_buf, num, d_proto->width_ll(), *
this);
890 if (num != (
unsigned int)
length())
891 throw InternalErr(__FILE__, __LINE__,
"The client sent declarations and data with mismatched sizes.");
893 d_str.resize((num > 0) ? num : 0);
899 for (i = 0; i < num; ++i) {
910 throw InternalErr(__FILE__, __LINE__,
"Array of array!");
920 if (num != (
unsigned int)
length())
921 throw InternalErr(__FILE__, __LINE__,
"The client sent declarations and data with mismatched sizes.");
925 for (i = 0; i < num; ++i) {
926 d_compound_buf[i] = d_proto->ptr_duplicate();
927 d_compound_buf[i]->deserialize(um, dds);
933 throw InternalErr(__FILE__, __LINE__,
"Unknown type!");
940 switch (d_proto->type()) {
958 checksum.
AddData(
reinterpret_cast<uint8_t *
>(d_buf),
length_ll() * d_proto->width_ll());
963 for (int64_t i = 0, e =
length(); i < e; ++i)
964 checksum.
AddData(
reinterpret_cast<const uint8_t *
>(d_str[i].data()), d_str[i].size());
970 d_proto->compute_checksum(checksum);
976 throw InternalErr(__FILE__, __LINE__,
"Unknown or unsupported datatype (" + d_proto->type_name() +
").");
984 switch (d_proto->type()) {
1013 assert(d_compound_buf.capacity() >= (
unsigned)
length());
1015 for (
int i = 0, e =
length(); i < e; ++i)
1022 throw InternalErr(__FILE__, __LINE__,
"Unknown or unsupported datatype (" + d_proto->type_name() +
").");
1030 if (filter && !eval.eval_selection(dmr,
dataset()))
1035 DBG(cerr << __func__ <<
", num: " << num << endl);
1041 switch (d_proto->type()) {
1055 m.
put_vector(d_buf, num, (
int)d_proto->width_ll());
1059 if (d_proto->width_ll() == 1)
1062 m.
put_vector(d_buf, num, (
int)d_proto->width_ll());
1075 assert((int64_t)d_str.capacity() >= num);
1077 for (int64_t i = 0; i < num; ++i)
1083 throw InternalErr(__FILE__, __LINE__,
"Array of Array not allowed.");
1088 assert(d_compound_buf.capacity() >= 0);
1090 for (int64_t i = 0; i < num; ++i) {
1091 DBG(cerr << __func__ <<
"d_compound_buf[" << i <<
"] " << d_compound_buf[i] << endl);
1092 d_compound_buf[i]->serialize(m, dmr, filter);
1098 throw InternalErr(__FILE__, __LINE__,
"Grid is not part of DAP4.");
1101 throw InternalErr(__FILE__, __LINE__,
"Unknown datatype.");
1104#ifdef CLEAR_LOCAL_DATA
1110 if (m_is_cardinal_type()) {
1112 m_delete_cardinal_data_buffer();
1114 m_create_cardinal_data_buffer_for_type(
length());
1117 DBG(cerr << __FUNCTION__ <<
name() <<
", length(): " <<
length() << endl);
1123 switch (d_proto->type()) {
1141 if (d_proto->width_ll() == 1)
1158 d_str.resize((len > 0) ? len : 0);
1160 throw InternalErr(__FILE__, __LINE__,
"The number of string length is less than 0 ");
1165 for (int64_t i = 0; i < len; ++i) {
1173 throw InternalErr(__FILE__, __LINE__,
"Array of Array not allowed.");
1180 for (int64_t i = 0, end =
length(); i < end; ++i) {
1181 d_compound_buf[i] = d_proto->ptr_duplicate();
1182 d_compound_buf[i]->deserialize(um, dmr);
1189 throw InternalErr(__FILE__, __LINE__,
"Grid is not part of DAP4.");
1192 throw InternalErr(__FILE__, __LINE__,
"Unknown type.");
1229 if (!val &&
length() == 0)
1240 throw InternalErr(__FILE__, __LINE__,
"The incoming pointer does not contain any data.");
1242 switch (d_proto->
type()) {
1259 if (d_buf && !reuse)
1260 m_delete_cardinal_data_buffer();
1263 if (!d_buf || !reuse)
1264 m_create_cardinal_data_buffer_for_type(
length_ll());
1268 memcpy(d_buf, val, (uint64_t)
width_ll(
true));
1278 d_str.resize(d_length);
1279 d_capacity = d_length;
1280 for (
int i = 0; i < d_length; ++i)
1281 d_str[i] = *(
static_cast<string *
> (val) + i);
1285 throw InternalErr(__FILE__,__LINE__,
"The number of string length is less than 0 ");
1286 d_str.resize(str_len);
1288 for (int64_t i = 0; i < str_len; ++i)
1289 d_str[i] = *(
static_cast<string *
> (val) + i);
1295 throw InternalErr(__FILE__, __LINE__,
"Vector::val2buf: bad type");
1299 return (
unsigned int)
width_ll(
true);
1305 auto ret_value = (
unsigned int)
val2buf_ll(val, reuse);
1313 if (!val &&
length() == 0)
1324 throw InternalErr(__FILE__, __LINE__,
"The incoming pointer does not contain any data.");
1326 switch (d_proto->type()) {
1343 if (d_buf && !reuse)
1344 m_delete_cardinal_data_buffer();
1347 if (!d_buf || !reuse)
1348 m_create_cardinal_data_buffer_for_type(
length_ll());
1352 memcpy(d_buf, val, (uint64_t)
width_ll(
true));
1361 d_str.resize(d_length);
1362 d_capacity = d_length;
1363 for (
int i = 0; i < d_length; ++i)
1364 d_str[i] = *(
static_cast<string *
> (val) + i);
1368 throw InternalErr(__FILE__, __LINE__,
"The number of string length is less than 0 ");
1369 d_str.resize(str_len);
1371 for (int64_t i = 0; i < str_len; ++i)
1372 d_str[i] = *(
static_cast<string *
>(val) + i);
1378 throw InternalErr(__FILE__, __LINE__,
"Vector::val2buf: bad type");
1426 throw InternalErr(__FILE__, __LINE__,
"NULL pointer.");
1435 switch (d_proto->type()) {
1453 "Vector::buf2val: Logic error: called when cardinal type data buffer was empty!");
1455 *val =
new char[wid];
1457 memcpy(*val, d_buf, (uint64_t)wid);
1458 return (
unsigned int)wid;
1464 "Vector::buf2val: Logic error: called when string data buffer was empty!");
1466 *val =
new string[d_length];
1468 for (
int i = 0; i < d_length; ++i)
1469 *(
static_cast<string *
>(*val) + i) = d_str[i];
1475 throw InternalErr(__FILE__, __LINE__,
"Vector::buf2val: bad type");
1483 throw InternalErr(__FILE__, __LINE__,
"NULL pointer.");
1492 switch (d_proto->type()) {
1510 "Vector::buf2val: Logic error: called when cardinal type data buffer was empty!");
1512 *val =
new char[wid];
1514 memcpy(*val, d_buf, wid);
1521 "Vector::buf2val: Logic error: called when string data buffer was empty!");
1523 *val =
new string[d_length_ll];
1525 for (int64_t i = 0; i < d_length_ll; ++i)
1526 *(
static_cast<string *
>(*val) + i) = d_str[i];
1532 throw InternalErr(__FILE__, __LINE__,
"Vector::buf2val: bad type");
1576 if (i >=
static_cast<unsigned int>(d_length))
1577 throw InternalErr(__FILE__, __LINE__,
"Invalid data: index too large.");
1579 throw InternalErr(__FILE__, __LINE__,
"Invalid data: null pointer to BaseType object.");
1580 if (val->
type() != d_proto->type())
1582 "invalid data: type of incoming object does not match *this* vector type.");
1592 if (i >= d_compound_buf.size()) {
1596 d_compound_buf[i] = val;
1604 if (i >=
static_cast<uint64_t
>(
length_ll()))
1605 throw InternalErr(__FILE__, __LINE__,
"Invalid data: index too large.");
1607 throw InternalErr(__FILE__, __LINE__,
"Invalid data: null pointer to BaseType object.");
1608 if (val->
type() != d_proto->type())
1610 "invalid data: type of incoming object does not match *this* vector type.");
1620 if (i >= d_compound_buf.size()) {
1624 d_compound_buf[i] = val;
1642 for (
unsigned int i = 0; i < d_compound_buf.size(); ++i) {
1643 delete d_compound_buf[i];
1644 d_compound_buf[i] = 0;
1648 d_compound_buf.resize(0);
1677 throw InternalErr(__FILE__, __LINE__,
"reserve_value_capacity: Logic error: _var is null!");
1679 switch (d_proto->type()) {
1696 m_create_cardinal_data_buffer_for_type(numElements);
1703 d_str.reserve(numElements);
1705 d_capacity = numElements;
1711 throw InternalErr(__FILE__, __LINE__,
"reserve_value_capacity: Arrays not supported!");
1718 d_compound_buf.reserve(numElements);
1720 d_capacity = numElements;
1726 throw InternalErr(__FILE__, __LINE__,
"reserve_value_capacity: Unknown type!");
1750 throw InternalErr(__FILE__, __LINE__,
"reserve_value_capacity: Logic error: _var is null!");
1752 switch (d_proto->type()) {
1769 m_create_cardinal_data_buffer_for_type(numElements);
1776 d_str.reserve(numElements);
1778 d_capacity = numElements;
1784 throw InternalErr(__FILE__, __LINE__,
"reserve_value_capacity: Arrays not supported!");
1791 d_compound_buf.reserve(numElements);
1793 d_capacity = numElements;
1799 throw InternalErr(__FILE__, __LINE__,
"reserve_value_capacity: Unknown type!");
1848 static const string funcName =
"set_value_slice_from_row_major_vector:";
1851 Vector &rowMajorData =
const_cast<Vector &
>(rowMajorDataC);
1853 bool typesMatch = rowMajorData.
var() && d_proto && (rowMajorData.
var()->
type() == d_proto->
type());
1855 throw InternalErr(__FILE__, __LINE__, funcName +
"Logic error: types do not match so cannot be copied!");
1859 if (!rowMajorData.
read_p()) {
1862 "Logic error: the Vector to copy data from has !read_p() and should have been read in!");
1870 "Logic error: the Vector to copy data from has length_ll() < 0 and was probably not initialized!");
1879 funcName +
"Logic error: the Vector to copy from has a data capacity less than its length, can't copy!");
1884 if (d_capacity_ll < (startElement + rowMajorData.
length_ll())) {
1887 "Logic error: the capacity of this Vector cannot hold all the data in the from Vector!");
1891 switch (d_proto->type()) {
1908 throw InternalErr(__FILE__, __LINE__, funcName +
"Logic error: this->_buf was unexpectedly null!");
1910 if (!rowMajorData.d_buf) {
1911 throw InternalErr(__FILE__, __LINE__, funcName +
"Logic error: rowMajorData._buf was unexpectedly null!");
1914 int64_t varWidth = d_proto->width_ll();
1915 char *pFromBuf = rowMajorData.d_buf;
1916 int64_t numBytesToCopy = rowMajorData.
width_ll(
true);
1917 char *pIntoBuf = d_buf + (startElement * varWidth);
1918 memcpy(pIntoBuf, pFromBuf, numBytesToCopy);
1925 for (uint64_t i = 0; i < static_cast<uint64_t>(rowMajorData.
length_ll()); ++i) {
1926 d_str[startElement + i] = rowMajorData.d_str[i];
1938 "Unimplemented method for Vectors of type: array, opaque, structure, sequence or grid.");
1941 throw InternalErr(__FILE__, __LINE__, funcName +
": Unknown type!");
1945 return (uint64_t)rowMajorData.
length_ll();
1956template <
typename T>
static bool types_match(
Type t, T *cpp_var) {
1961 return typeid(cpp_var) ==
typeid(
dods_byte *);
1964 return typeid(cpp_var) ==
typeid(
dods_int8 *);
1966 return typeid(cpp_var) ==
typeid(
dods_int16 *);
1970 return typeid(cpp_var) ==
typeid(
dods_int32 *);
1974 return typeid(cpp_var) ==
typeid(
dods_int64 *);
2000template <
typename T>
bool Vector::set_value_worker(T *v,
int sz) {
2001 if (!v || !types_match(
2002 d_proto->type() ==
dods_enum_c ?
static_cast<D4Enum *
>(d_proto)->element_type() : d_proto->type(), v))
2004 m_set_cardinal_values_internal(v, (int64_t)sz);
2008template <
typename T>
bool Vector::set_value_ll_worker(T *v, int64_t sz) {
2009 if (!v || !types_match(
2010 d_proto->type() ==
dods_enum_c ?
static_cast<D4Enum *
>(d_proto)->element_type() : d_proto->type(), v))
2013 m_set_cardinal_values_internal(v, sz);
2055 for (
int t = 0; t < sz; t++) {
2073 for (int64_t t = 0; t < sz; t++) {
2084template <
typename T>
bool Vector::set_value_worker(vector<T> &v,
int sz) {
return set_value(v.data(), sz); }
2086template <
typename T>
bool Vector::set_value_ll_worker(vector<T> &v, int64_t sz) {
return set_value_ll(v.data(), sz); }
2115 for (
int t = 0; t < sz; t++) {
2130 for (int64_t t = 0; t < sz; t++) {
2161template <
typename T>
void Vector::value_worker(vector<unsigned int> *indices, T *b)
const {
2165 unsigned long currentIndex = *i;
2166 if(currentIndex > (
unsigned int)
length()){
2168 s <<
"Vector::value() - Subset index[" << i - subsetIndex->begin() <<
"] = " << currentIndex <<
" references a value that is " <<
2169 "outside the bounds of the internal storage [ length()= " <<
length() <<
" ] name: '" <<
name() <<
"'. ";
2170 throw Error(s.str());
2172 b[i - indices->begin()] =
reinterpret_cast<T*
>(d_buf )[currentIndex];
2175 for (
unsigned long i = 0, e = indices->size(); i < e; ++i) {
2176 unsigned long currentIndex = (*indices)[i];
2177 if (currentIndex > (
unsigned int)
length()) {
2179 s <<
"Vector::value() - Subset index[" << i <<
"] = " << currentIndex <<
" references a value that is "
2180 <<
"outside the bounds of the internal storage [ length()= " <<
length() <<
" ] name: '" <<
name()
2182 throw Error(s.str());
2184 b[i] =
reinterpret_cast<T *
>(d_buf)[currentIndex];
2188template <
typename T>
void Vector::value_ll_worker(vector<uint64_t> *indices, T *b)
const {
2191 for (vector<unsigned int>::iterator i = indices->begin(), e = indices->end(); i != e; ++i) {
2192 unsigned long currentIndex = *i;
2193 if(currentIndex > (
unsigned int)
length()){
2195 s <<
"Vector::value() - Subset index[" << i - subsetIndex->begin() <<
"] = " << currentIndex <<
" references a value that is " <<
2196 "outside the bounds of the internal storage [ length()= " <<
length() <<
" ] name: '" <<
name() <<
"'. ";
2197 throw Error(s.str());
2199 b[i - indices->begin()] =
reinterpret_cast<T*
>(d_buf )[currentIndex];
2202 for (uint64_t i = 0, e = indices->size(); i < e; ++i) {
2203 uint64_t currentIndex = (*indices)[i];
2204 if (currentIndex > (uint64_t)
length_ll()) {
2206 s <<
"Vector::value() - Subset index[" << i <<
"] = " << currentIndex <<
" references a value that is "
2207 <<
"outside the bounds of the internal storage [ length_ll()= " <<
length_ll() <<
" ] name: '" <<
name()
2209 throw Error(s.str());
2211 b[i] =
reinterpret_cast<T *
>(d_buf)[currentIndex];
2253 unsigned long currentIndex;
2256 for (
unsigned long i = 0; i < subsetIndex->size(); ++i) {
2257 currentIndex = (*subsetIndex)[i];
2258 if (currentIndex > (
unsigned int)
length()) {
2260 s <<
"Vector::value() - Subset index[" << i <<
"] = " << currentIndex <<
" references a value that is "
2261 <<
"outside the bounds of the internal storage [ length()= " <<
length() <<
" ] name: '" <<
name()
2263 throw Error(s.str());
2265 b[i] = d_str[currentIndex];
2271 uint64_t currentIndex;
2274 for (uint64_t i = 0; i < subsetIndex->size(); ++i) {
2275 currentIndex = (*subsetIndex)[i];
2276 if (currentIndex > (uint64_t)
length_ll()) {
2278 s <<
"Vector::value() - Subset index[" << i <<
"] = " << currentIndex <<
" references a value that is "
2279 <<
"outside the bounds of the internal storage [ length_ll()= " <<
length_ll() <<
" ] name: '"
2281 throw Error(s.str());
2283 b[i] = d_str[currentIndex];
2288template <
typename T>
void Vector::value_worker(T *v)
const {
2291 if (v && types_match(
2293 memcpy(v, d_buf,
length_ll() *
sizeof(T));
2328 void *buffer =
new char[
width_ll(
true)];
2330 memcpy(buffer, d_buf,
width_ll(
true));
2378 if (!v->
name().empty())
2381 d_proto->set_name(
name());
2383 d_proto->set_parent(
this);
2385 DBG(cerr <<
"Vector::add_var: Added variable " << v <<
" (" << v->
name() <<
" " << v->
type_name() <<
")"
2403 if (!v->
name().empty())
2406 d_proto->set_name(
name());
2408 d_proto->set_parent(
this);
2410 DBG(cerr <<
"Vector::add_var_no_copy: Added variable " << v <<
" (" << v->
name() <<
" " << v->
type_name() <<
")"
2425 bool has_projected_dap4 =
false;
2427 if (d_proto->is_constructor_type()) {
2428 has_projected_dap4 =
2432 if (has_projected_dap4) {
2437 if (has_projected_dap4) {
2441 return has_projected_dap4;
2453 strm <<
DapIndent::LMarg <<
"Vector::dump - (" << (
void *)
this <<
")" << endl;
2460 d_proto->dump(strm);
2467 for (
unsigned i = 0; i < d_compound_buf.size(); ++i) {
2468 if (d_compound_buf[i])
2469 d_compound_buf[i]->dump(strm);
2476 for (
unsigned i = 0; i < d_str.size(); i++) {
2481 switch (d_proto != 0 ? d_proto->type() : 0) {
2485 strm.write(d_buf, d_length);
void AddData(const uint8_t *pData, const uint32_t length)
The basic data type for the DODS DAP types.
BaseType & operator=(const BaseType &rhs)
virtual string type_name() const
Returns the type of the class instance as a string.
virtual bool read()
Read data into a local buffer.
virtual string name() const
Returns the name of the class instance.
virtual bool read_p()
Has this variable been read?
virtual void set_read_p(bool state)
Sets the value of the read_p property.
virtual string dataset() const
Returns the name of the dataset used to create this instance.
void dump(ostream &strm) const override
dumps information about this object
virtual bool is_dap4() const
virtual void set_name(const string &n)
Sets the name of the class instance.
virtual D4Attributes * attributes()
virtual std::string FQN() const
virtual bool send_p()
Should this variable be sent?
virtual void set_send_p(bool state)
virtual BaseType * ptr_duplicate()=0
virtual unsigned int val2buf(void *val, bool reuse=false)=0
Loads class data.
stack< BaseType * > btp_stack
virtual bool check_semantics(string &msg, bool all=false)
Compare an object's current state with the semantics of its type.
virtual int64_t width_ll(bool constrained=false) const
BaseType(const string &n, const Type &t, bool is_dap4=false)
The BaseType constructor.
virtual Type type() const
Returns the type of the class instance.
Evaluate a constraint expression.
bool eval_selection(DDS &dds, const std::string &dataset)
Evaluate a boolean-valued constraint expression. This is main method for the evaluator and is called ...
bool has_dap4_types(const std::string &path, std::vector< std::string > &inventory) const
Holds a DAP4 enumeration.
Marshaller that knows how to marshal/serialize dap data objects to a C++ iostream using DAP4's receiv...
virtual void put_vector_float32(char *val, int64_t num_elem)
Write a fixed size vector.
virtual void put_str(const string &val)
virtual void put_vector(char *val, int64_t num_bytes)
Write a fixed size vector.
virtual void put_vector_float64(char *val, int64_t num_elem)
Write a fixed size vector of float64s.
Read data from the stream made by D4StreamMarshaller.
virtual void get_vector_float64(char *val, int64_t num_elem)
virtual void get_vector_float32(char *val, int64_t num_elem)
virtual void get_str(string &val)
virtual void get_vector(char **, unsigned int &, Vector &)
static ostream & LMarg(ostream &strm)
A class for error processing.
A class for software fault reporting.
abstract base class used to marshal/serialize dap data objects
virtual void put_str(const std::string &val)=0
virtual void put_int(int val)=0
virtual void put_vector(char *val, int num, Vector &vec)=0
abstract base class used to unmarshall/deserialize dap data objects
virtual void get_int(int &val)=0
virtual void get_vector(char **val, unsigned int &num, Vector &vec)=0
virtual void get_str(string &val)=0
Holds a one-dimensional collection of DAP2 data types.
virtual void reserve_value_capacity_ll_byte(uint64_t numBytes)
bool deserialize(UnMarshaller &um, DDS *dds, bool reuse=false) override
Receive data from the net.
void set_send_p(bool state) override
Indicates that the data is ready to send.
int64_t width_ll(bool constrained=false) const override
Return the number of bytes needed to hold the array data.
void dump(ostream &strm) const override
dumps information about this object
virtual uint64_t get_value_capacity_ll() const
void compute_checksum(Crc32 &checksum) override
include the data for this variable in the checksum DAP4 includes a checksum with every data response....
virtual unsigned int get_value_capacity() const
void set_vec_nocopy(unsigned int i, BaseType *val)
Sets element i to value val. Set the ith element to val. Extend the vector if needed.
Vector & operator=(const Vector &rhs)
void add_var_nocopy(BaseType *v, Part p=nil) override
void add_var(BaseType *v, Part p=nil) override
Add the BaseType pointer to this constructor type instance.
int length() const override
Returns the number of elements in the vector. Note that some child classes of Vector use the length o...
int64_t val2buf_ll(void *val, bool reuse=false)
virtual void value_ll(vector< uint64_t > *indices, dods_byte *b) const
int64_t length_ll() const override
Get the number of elements in this Vector/Array This version of the function deprecates length() whic...
void set_read_p(bool state) override
Indicates that the data is ready to send.
int element_count(bool leaves) override
Count the members of constructor types.
void set_length_ll(int64_t l) override
Set the number of elements in this Vector/Array This version of the function deprecates set_length() ...
void set_vec(unsigned int i, BaseType *val)
Sets element i to value val.
bool is_dap4_projected(std::vector< std::string > &projected_dap4_inventory) override
void set_value_capacity(uint64_t l)
void set_name(const std::string &name) override
Sets the name of the class instance.
bool check_semantics(string &msg, bool all=false) override
Compare an object's current state with the semantics of its type.
void vec_resize_ll(int64_t l)
void intern_data() override
Read data into this variable.
virtual void reserve_value_capacity_ll()
unsigned int val2buf(void *val, bool reuse=false) override
Reads data into the Vector buffer.
int64_t buf2val_ll(void **val)
virtual bool set_value_ll(dods_byte *val, int64_t sz)
BaseType * var(const string &name="", bool exact_match=true, btp_stack *s=nullptr) override
virtual uint64_t set_value_slice_from_row_major_vector(const Vector &rowMajorData, uint64_t startElement)
virtual bool set_value(dods_byte *val, int sz)
bool serialize(ConstraintEvaluator &eval, DDS &dds, Marshaller &m, bool ce_eval=true) override
Serialize a Vector.
void set_vec_nocopy_ll(uint64_t i, BaseType *val)
void set_vec_ll(uint64_t i, BaseType *val)
virtual void reserve_value_capacity()
virtual BaseType * prototype() const
unsigned int buf2val(void **val) override
Copies data from the Vector buffer.
void clear_local_data() override
Vector(const string &n, BaseType *v, const Type &t, bool is_dap4=false)
The Vector constructor.
virtual BaseType * var_ll(uint64_t i)
void set_length(int64_t l) override
Sets the length of the vector. This function does not allocate any new space.
top level DAP object to house generic methods
Type
Identifies the data type.
string www2id(const string &in, const string &escape, const string &except)
Part
Names the parts of multi-section constructor data types.