53 #include "Marshaller.h" 54 #include "UnMarshaller.h" 56 #include "D4StreamMarshaller.h" 57 #include "D4StreamUnMarshaller.h" 62 #include "dods-datatypes.h" 66 #include "InternalErr.h" 68 #undef CLEAR_LOCAL_DATA 75 void Vector::m_duplicate(
const Vector & v)
77 d_length = v.d_length;
93 if (v.d_compound_buf.empty()) {
94 d_compound_buf = v.d_compound_buf;
99 d_compound_buf.resize(d_length);
100 for (
int i = 0; i < d_length; ++i) {
105 d_compound_buf[i] = v.d_compound_buf[i]->ptr_duplicate();
117 d_capacity = v.d_capacity;
131 switch (d_proto->
type()) {
157 case dods_structure_c:
158 case dods_sequence_c:
164 assert(
"Vector::var: Unrecognized type");
185 throw InternalErr(__FILE__, __LINE__,
"create_cardinal_data_buffer_for_type: Logic error: _var is null!");
190 throw InternalErr(__FILE__, __LINE__,
"create_cardinal_data_buffer_for_type: incorrectly used on Vector whose type was not a cardinal (simple data types).");
196 if (numEltsOfType == 0)
200 unsigned int bytesPerElt = d_proto->
width();
201 unsigned int bytesNeeded = bytesPerElt * numEltsOfType;
202 d_buf =
new char[bytesNeeded];
204 d_capacity = numEltsOfType;
219 template<
class CardType>
223 throw InternalErr(__FILE__, __LINE__,
"Logic error: Vector::set_cardinal_values_internal() called with negative numElts!");
226 throw InternalErr(__FILE__, __LINE__,
"Logic error: Vector::set_cardinal_values_internal() called with null fromArray!");
230 memcpy(d_buf, fromArray, numElts *
sizeof(CardType));
250 BaseType(n, t, is_dap4), d_length(-1), d_proto(0), d_buf(0), d_compound_buf(0), d_capacity(0)
255 DBG2(cerr <<
"Entering Vector ctor for object: " <<
this << endl);
279 BaseType(n, d, t, is_dap4), d_length(-1), d_proto(0), d_buf(0), d_compound_buf(0), d_capacity(0)
284 DBG2(cerr <<
"Entering Vector ctor for object: " <<
this << endl);
293 DBG2(cerr <<
"Entering Vector const ctor for object: " <<
this <<
294 endl); DBG2(cerr <<
"RHS: " << &rhs << endl);
301 DBG2(cerr <<
"Entering ~Vector (" <<
this <<
")" << endl);
309 DBG2(cerr <<
"Exiting ~Vector" << endl);
317 dynamic_cast<BaseType &
> (*this) = rhs;
367 switch (d_proto->
type()) {
368 case dods_structure_c:
369 case dods_sequence_c:
371 if (d_compound_buf.size() > 0) {
372 for (
unsigned long long i = 0; i < (unsigned) d_length; ++i) {
373 if (d_compound_buf[i]) d_compound_buf[i]->set_send_p(state);
398 switch (d_proto->
type()) {
399 case dods_structure_c:
400 case dods_sequence_c:
402 if (d_compound_buf.size() > 0) {
403 for (
unsigned long long i = 0; i < (unsigned)d_length; ++i) {
404 if (d_compound_buf[i]) d_compound_buf[i]->set_read_p(state);
437 DBG2(cerr <<
"Vector::var: Looking for " << name << endl);
439 if (name ==
"" || d_proto->
name() ==
name) {
473 return d_proto->
var(name, s);
494 switch (d_proto->
type()) {
523 case dods_structure_c:
524 case dods_sequence_c:
526 return d_compound_buf[i];
530 throw Error (
"Vector::var: Unrecognized type");
579 throw InternalErr(__FILE__, __LINE__,
"Vector::vec_resize() is applicable to compound types only");
584 d_compound_buf.resize(l, 0);
585 d_capacity = d_compound_buf.size();
606 DBG(cerr <<
"Vector::intern_data: " <<
name() << endl);
613 switch (d_proto->
type()) {
633 throw InternalErr(__FILE__, __LINE__,
"Array of Array not supported.");
636 case dods_structure_c:
637 case dods_sequence_c:
639 DBG(cerr <<
"Vector::intern_data: found ctor" << endl);
645 if (d_compound_buf.capacity() < (unsigned)num)
646 throw InternalErr(__FILE__, __LINE__,
"The capacity of this Vector is less than the number of elements.");
648 for (
int i = 0; i < num; ++i)
654 throw InternalErr(__FILE__, __LINE__,
"Unknown datatype.");
695 switch (d_proto->
type()) {
697 m.put_vector(d_buf, num, *
this);
707 m.put_vector(d_buf, num, d_proto->
width(), *
this);
714 if (d_str.capacity() == 0)
715 throw InternalErr(__FILE__, __LINE__,
"The capacity of the string vector is 0");
719 for (
int i = 0; i < num; ++i)
726 case dods_structure_c:
727 case dods_sequence_c:
731 if (d_compound_buf.capacity() == 0)
732 throw InternalErr(__FILE__, __LINE__,
"The capacity of *this* vector is 0.");
736 for (
int i = 0; i < num && status; ++i)
737 status = status && d_compound_buf[i]->
serialize(eval, dds, m,
false);
742 throw InternalErr(__FILE__, __LINE__,
"Unknown datatype.");
746 #ifdef CLEAR_LOCAL_DATA 775 switch (d_proto->
type()) {
783 um.get_int((
int &) num);
785 DBG(cerr <<
"Vector::deserialize: num = " << num << endl);
786 DBG(cerr <<
"Vector::deserialize: length = " <<
length() << endl);
791 if (num != (
unsigned int)
length())
792 throw InternalErr(__FILE__, __LINE__,
"The server sent declarations and data with mismatched sizes for the variable '" +
name() +
"'.");
794 if (!d_buf || !reuse) {
798 DBG(cerr <<
"Vector::deserialize: allocating " 799 <<
width() <<
" bytes for an array of " 810 if (d_proto->
type() == dods_byte_c)
811 um.get_vector((
char **) &d_buf, num, *
this);
813 um.get_vector((
char **) &d_buf, num, d_proto->
width(), *
this);
815 DBG(cerr <<
"Vector::deserialize: read " << num <<
" elements\n");
821 um.get_int((
int &) num);
826 if (num != (
unsigned int)
length())
827 throw InternalErr(__FILE__, __LINE__,
"The client sent declarations and data with mismatched sizes.");
829 d_str.resize((num > 0) ? num : 0);
832 for (i = 0; i < num; ++i) {
844 throw InternalErr(__FILE__, __LINE__,
"Array of array!");
847 case dods_structure_c:
848 case dods_sequence_c:
850 um.get_int((
int &) num);
855 if (num != (
unsigned int)
length())
856 throw InternalErr(__FILE__, __LINE__,
"The client sent declarations and data with mismatched sizes.");
860 for (i = 0; i < num; ++i) {
862 d_compound_buf[i]->deserialize(um, dds);
868 throw InternalErr(__FILE__, __LINE__,
"Unknown type!");
877 switch (d_proto->
type()) {
900 for (int64_t i = 0, e =
length(); i < e; ++i)
901 checksum.
AddData(reinterpret_cast<const uint8_t*>(d_str[i].data()), d_str[i].
length());
905 case dods_structure_c:
906 case dods_sequence_c:
913 throw InternalErr(__FILE__, __LINE__,
"Unknown or unsupported datatype (" + d_proto->
type_name() +
").");
923 switch (d_proto->
type()) {
948 case dods_structure_c:
949 case dods_sequence_c:
952 assert(d_compound_buf.capacity() >= (unsigned)
length());
954 for (
int i = 0, e =
length(); i < e; ++i)
961 throw InternalErr(__FILE__, __LINE__,
"Unknown or unsupported datatype (" + d_proto->
type_name() +
").");
972 if (filter && !eval.eval_selection(dmr,
dataset()))
977 DBG(cerr << __func__ <<
", num: " << num << endl);
983 switch (d_proto->
type()) {
1001 if (d_proto->
width() == 1)
1007 case dods_float32_c:
1011 case dods_float64_c:
1017 assert((int64_t)d_str.capacity() >= num);
1019 for (int64_t i = 0; i < num; ++i)
1020 m.put_str(d_str[i]);
1025 throw InternalErr(__FILE__, __LINE__,
"Array of Array not allowed.");
1028 case dods_structure_c:
1029 case dods_sequence_c:
1030 assert(d_compound_buf.capacity() >= 0);
1032 for (int64_t i = 0; i < num; ++i) {
1033 DBG(cerr << __func__ <<
"d_compound_buf[" << i <<
"] " << d_compound_buf[i] << endl);
1034 d_compound_buf[i]->serialize(m, dmr, filter);
1040 throw InternalErr(__FILE__, __LINE__,
"Grid is not part of DAP4.");
1043 throw InternalErr(__FILE__, __LINE__,
"Unknown datatype.");
1047 #ifdef CLEAR_LOCAL_DATA 1062 DBG(cerr << __FUNCTION__ <<
name() <<
", length(): " <<
length() << endl);
1068 switch (d_proto->
type()) {
1073 um.get_vector((
char *)d_buf,
length());
1082 um.get_vector((
char *)d_buf,
length(), d_proto->
width());
1086 if (d_proto->
width() == 1)
1087 um.get_vector((
char *)d_buf,
length());
1089 um.get_vector((
char *)d_buf,
length(), d_proto->
width());
1092 case dods_float32_c:
1093 um.get_vector_float32((
char *)d_buf,
length());
1096 case dods_float64_c:
1097 um.get_vector_float64((
char *)d_buf,
length());
1103 d_str.resize((len > 0) ? len : 0);
1106 for (int64_t i = 0; i < len; ++i) {
1107 um.get_str(d_str[i]);
1114 throw InternalErr(__FILE__, __LINE__,
"Array of Array not allowed.");
1117 case dods_structure_c:
1118 case dods_sequence_c: {
1121 for (int64_t i = 0, end =
length(); i < end; ++i) {
1123 d_compound_buf[i]->deserialize(um, dmr);
1130 throw InternalErr(__FILE__, __LINE__,
"Grid is not part of DAP4.");
1133 throw InternalErr(__FILE__, __LINE__,
"Unknown type.");
1170 if (!val &&
length() == 0)
1181 throw InternalErr(__FILE__, __LINE__,
"The incoming pointer does not contain any data.");
1183 switch (d_proto->
type()) {
1197 case dods_float32_c:
1198 case dods_float64_c:
1200 if (d_buf && !reuse)
1204 if (!d_buf || !reuse)
1208 memcpy(d_buf, val,
width(
true));
1216 d_str.resize(d_length);
1217 d_capacity = d_length;
1218 for (
int i = 0; i < d_length; ++i)
1219 d_str[i] = *(static_cast<string *> (val) + i);
1224 throw InternalErr(__FILE__, __LINE__,
"Vector::val2buf: bad type");
1266 throw InternalErr(__FILE__, __LINE__,
"NULL pointer.");
1268 unsigned int wid =
static_cast<unsigned int> (
width(
true ));
1275 switch (d_proto->
type()) {
1289 case dods_float32_c:
1290 case dods_float64_c:
1292 throw InternalErr(__FILE__, __LINE__,
"Vector::buf2val: Logic error: called when cardinal type data buffer was empty!");
1294 *val =
new char[wid];
1296 memcpy(*val, d_buf, wid);
1303 throw InternalErr(__FILE__, __LINE__,
"Vector::buf2val: Logic error: called when string data buffer was empty!");
1305 *val =
new string[d_length];
1307 for (
int i = 0; i < d_length; ++i)
1308 *(static_cast<string *> (*val) + i) = d_str[i];
1315 throw InternalErr(__FILE__, __LINE__,
"Vector::buf2val: bad type");
1363 if (i >= static_cast<unsigned int> (d_length))
1364 throw InternalErr(__FILE__, __LINE__,
"Invalid data: index too large.");
1366 throw InternalErr(__FILE__, __LINE__,
"Invalid data: null pointer to BaseType object.");
1367 if (val->
type() != d_proto->
type())
1368 throw InternalErr(__FILE__, __LINE__,
"invalid data: type of incoming object does not match *this* vector type.");
1378 if (i >= d_compound_buf.size()) {
1382 d_compound_buf[i] = val;
1401 for (
unsigned int i = 0; i < d_compound_buf.size(); ++i) {
1402 delete d_compound_buf[i];
1403 d_compound_buf[i] = 0;
1407 d_compound_buf.resize(0);
1438 throw InternalErr(__FILE__, __LINE__,
"reserve_value_capacity: Logic error: _var is null!");
1440 switch (d_proto->
type()) {
1454 case dods_float32_c:
1455 case dods_float64_c:
1464 d_str.reserve(numElements);
1465 d_capacity = numElements;
1469 throw InternalErr(__FILE__, __LINE__,
"reserve_value_capacity: Arrays not supported!");
1473 case dods_structure_c:
1474 case dods_sequence_c:
1477 d_compound_buf.reserve(numElements);
1478 d_capacity = numElements;
1482 throw InternalErr(__FILE__, __LINE__,
"reserve_value_capacity: Unknown type!");
1531 static const string funcName =
"set_value_slice_from_row_major_vector:";
1534 Vector& rowMajorData =
const_cast<Vector&
>(rowMajorDataC);
1536 bool typesMatch = rowMajorData.
var() && d_proto && (rowMajorData.
var()->
type() == d_proto->
type());
1538 throw InternalErr(__FILE__, __LINE__, funcName +
"Logic error: types do not match so cannot be copied!");
1542 if (!rowMajorData.
read_p()) {
1544 funcName +
"Logic error: the Vector to copy data from has !read_p() and should have been read in!");
1548 if (rowMajorData.
length() < 0) {
1551 +
"Logic error: the Vector to copy data from has length() < 0 and was probably not initialized!");
1559 +
"Logic error: the Vector to copy from has a data capacity less than its length, can't copy!");
1564 if (d_capacity < (startElement + rowMajorData.
length())) {
1566 funcName +
"Logic error: the capacity of this Vector cannot hold all the data in the from Vector!");
1570 switch (d_proto->
type()) {
1584 case dods_float32_c:
1585 case dods_float64_c: {
1587 throw InternalErr(__FILE__, __LINE__, funcName +
"Logic error: this->_buf was unexpectedly null!");
1589 if (!rowMajorData.d_buf) {
1590 throw InternalErr(__FILE__, __LINE__, funcName +
"Logic error: rowMajorData._buf was unexpectedly null!");
1593 int varWidth = d_proto->
width();
1594 char* pFromBuf = rowMajorData.d_buf;
1595 int numBytesToCopy = rowMajorData.
width(
true);
1596 char* pIntoBuf = d_buf + (startElement * varWidth);
1597 memcpy(pIntoBuf, pFromBuf, numBytesToCopy);
1604 for (
unsigned int i = 0; i < static_cast<unsigned int>(rowMajorData.
length()); ++i) {
1605 d_str[startElement + i] = rowMajorData.d_str[i];
1611 case dods_structure_c:
1612 case dods_sequence_c:
1616 funcName +
"Unimplemented method for Vectors of type: array, opaque, structure, sequence or grid.");
1620 throw InternalErr(__FILE__, __LINE__, funcName +
": Unknown type!");
1626 return (
unsigned int) rowMajorData.
length();
1637 template <
typename T>
1638 static bool types_match(
Type t, T *cpp_var)
1644 return typeid(cpp_var) ==
typeid(dods_byte*);
1647 return typeid(cpp_var) ==
typeid(dods_int8*);
1649 return typeid(cpp_var) ==
typeid(dods_int16*);
1651 return typeid(cpp_var) ==
typeid(dods_uint16*);
1653 return typeid(cpp_var) ==
typeid(dods_int32*);
1655 return typeid(cpp_var) ==
typeid(dods_uint32*);
1657 return typeid(cpp_var) ==
typeid(dods_int64*);
1659 return typeid(cpp_var) ==
typeid(dods_uint64*);
1661 case dods_float32_c:
1662 return typeid(cpp_var) ==
typeid(dods_float32*);
1663 case dods_float64_c:
1664 return typeid(cpp_var) ==
typeid(dods_float64*);
1672 case dods_structure_c:
1673 case dods_sequence_c:
1683 template <
typename T>
1684 bool Vector::set_value_worker(T *v,
int sz)
1686 if (!v || !types_match(d_proto->
type() == dods_enum_c ?
static_cast<D4Enum*
>(d_proto)->element_type() : d_proto->
type(), v))
1693 bool Vector::set_value(dods_byte *val,
int sz)
1695 return set_value_worker(val, sz);
1697 bool Vector::set_value(dods_int8 *val,
int sz)
1699 return set_value_worker(val, sz);
1701 bool Vector::set_value(dods_int16 *val,
int sz)
1703 return set_value_worker(val, sz);
1705 bool Vector::set_value(dods_uint16 *val,
int sz)
1707 return set_value_worker(val, sz);
1709 bool Vector::set_value(dods_int32 *val,
int sz)
1711 return set_value_worker(val, sz);
1713 bool Vector::set_value(dods_uint32 *val,
int sz)
1715 return set_value_worker(val, sz);
1717 bool Vector::set_value(dods_int64 *val,
int sz)
1719 return set_value_worker(val, sz);
1721 bool Vector::set_value(dods_uint64 *val,
int sz)
1723 return set_value_worker(val, sz);
1725 bool Vector::set_value(dods_float32 *val,
int sz)
1727 return set_value_worker(val, sz);
1729 bool Vector::set_value(dods_float64 *val,
int sz)
1731 return set_value_worker(val, sz);
1735 bool Vector::set_value(
string *val,
int sz)
1737 if ((
var()->
type() == dods_str_c ||
var()->
type() == dods_url_c) && val) {
1740 for (
register int t = 0; t < sz; t++) {
1752 template<
typename T>
1753 bool Vector::set_value_worker(vector<T> &v,
int sz)
1755 return set_value(&v[0], sz);
1758 bool Vector::set_value(vector<dods_byte> &val,
int sz)
1760 return set_value_worker(val, sz);
1762 bool Vector::set_value(vector<dods_int8> &val,
int sz)
1764 return set_value_worker(val, sz);
1766 bool Vector::set_value(vector<dods_int16> &val,
int sz)
1768 return set_value_worker(val, sz);
1770 bool Vector::set_value(vector<dods_uint16> &val,
int sz)
1772 return set_value_worker(val, sz);
1774 bool Vector::set_value(vector<dods_int32> &val,
int sz)
1776 return set_value_worker(val, sz);
1778 bool Vector::set_value(vector<dods_uint32> &val,
int sz)
1780 return set_value_worker(val, sz);
1782 bool Vector::set_value(vector<dods_int64> &val,
int sz)
1784 return set_value_worker(val, sz);
1786 bool Vector::set_value(vector<dods_uint64> &val,
int sz)
1788 return set_value_worker(val, sz);
1790 bool Vector::set_value(vector<dods_float32> &val,
int sz)
1792 return set_value_worker(val, sz);
1794 bool Vector::set_value(vector<dods_float64> &val,
int sz)
1796 return set_value_worker(val, sz);
1801 bool Vector::set_value(vector<string> &val,
int sz)
1803 if (
var()->
type() == dods_str_c ||
var()->
type() == dods_url_c) {
1806 for (
register int t = 0; t < sz; t++) {
1837 template <
typename T>
1838 void Vector::value_worker(vector<unsigned int> *indices, T *b)
const 1843 for (vector<unsigned int>::iterator i = indices->begin(), e = indices->end(); i != e; ++i) {
1844 unsigned long currentIndex = *i;
1845 if(currentIndex > (
unsigned int)
length()){
1847 s <<
"Vector::value() - Subset index[" << i - subsetIndex->begin() <<
"] = " << currentIndex <<
" references a value that is " <<
1848 "outside the bounds of the internal storage [ length()= " <<
length() <<
" ] name: '" <<
name() <<
"'. ";
1849 throw Error(s.str());
1851 b[i - indices->begin()] =
reinterpret_cast<T*
>(d_buf )[currentIndex];
1854 for (
unsigned long i = 0, e = indices->size(); i < e; ++i) {
1855 unsigned long currentIndex = (*indices)[i];
1856 if (currentIndex > (
unsigned int)
length()) {
1858 s <<
"Vector::value() - Subset index[" << i <<
"] = " << currentIndex <<
" references a value that is " <<
1859 "outside the bounds of the internal storage [ length()= " <<
length() <<
" ] name: '" <<
name() <<
"'. ";
1860 throw Error(s.str());
1862 b[i] =
reinterpret_cast<T*
>(d_buf )[currentIndex];
1865 void Vector::value(vector<unsigned int> *indices, dods_byte *b)
const { value_worker(indices, b); }
1866 void Vector::value(vector<unsigned int> *indices, dods_int8 *b)
const { value_worker(indices, b); }
1867 void Vector::value(vector<unsigned int> *indices, dods_int16 *b)
const { value_worker(indices, b); }
1868 void Vector::value(vector<unsigned int> *indices, dods_uint16 *b)
const { value_worker(indices, b); }
1869 void Vector::value(vector<unsigned int> *indices, dods_int32 *b)
const { value_worker(indices, b); }
1870 void Vector::value(vector<unsigned int> *indices, dods_uint32 *b)
const { value_worker(indices, b); }
1871 void Vector::value(vector<unsigned int> *indices, dods_int64 *b)
const { value_worker(indices, b); }
1872 void Vector::value(vector<unsigned int> *indices, dods_uint64 *b)
const { value_worker(indices, b); }
1873 void Vector::value(vector<unsigned int> *indices, dods_float32 *b)
const { value_worker(indices, b); }
1874 void Vector::value(vector<unsigned int> *indices, dods_float64 *b)
const { value_worker(indices, b); }
1877 template void Vector::value(vector<unsigned int> *indices, dods_byte *b)
const;
1878 template void Vector::value(vector<unsigned int> *indices, dods_int8 *b)
const;
1879 template void Vector::value(vector<unsigned int> *indices, dods_int16 *b)
const;
1880 template void Vector::value(vector<unsigned int> *indices, dods_uint16 *b)
const;
1881 template void Vector::value(vector<unsigned int> *indices, dods_int32 *b)
const;
1882 template void Vector::value(vector<unsigned int> *indices, dods_uint32 *b)
const;
1883 template void Vector::value(vector<unsigned int> *indices, dods_int64 *b)
const;
1884 template void Vector::value(vector<unsigned int> *indices, dods_uint64 *b)
const;
1885 template void Vector::value(vector<unsigned int> *indices, dods_float32 *b)
const;
1886 template void Vector::value(vector<unsigned int> *indices, dods_float64 *b)
const;
1892 unsigned long currentIndex;
1894 if (d_proto->
type() == dods_str_c || d_proto->
type() == dods_url_c){
1895 for(
unsigned long i=0; i<subsetIndex->size() ;++i){
1896 currentIndex = (*subsetIndex)[i] ;
1897 if(currentIndex > (
unsigned int)
length()){
1899 s <<
"Vector::value() - Subset index[" << i <<
"] = " << currentIndex <<
" references a value that is " <<
1900 "outside the bounds of the internal storage [ length()= " <<
length() <<
" ] name: '" <<
name() <<
"'. ";
1901 throw Error(s.str());
1903 b[i] = d_str[currentIndex];
1908 template <
typename T>
1909 void Vector::value_worker(T *v)
const 1913 if (v && types_match(d_proto->
type() == dods_enum_c ?
static_cast<D4Enum*
>(d_proto)->element_type() : d_proto->
type(), v))
1914 memcpy(v, d_buf,
length() *
sizeof(T));
1918 void Vector::value(dods_int16 *b)
const { value_worker(b); }
1919 void Vector::value(dods_uint16 *b)
const { value_worker(b); }
1920 void Vector::value(dods_int32 *b)
const { value_worker(b); }
1921 void Vector::value(dods_uint32 *b)
const { value_worker(b); }
1922 void Vector::value(dods_int64 *b)
const { value_worker(b); }
1923 void Vector::value(dods_uint64 *b)
const { value_worker(b); }
1924 void Vector::value(dods_float32 *b)
const { value_worker(b); }
1925 void Vector::value(dods_float64 *b)
const { value_worker(b); }
1944 if (d_proto->
type() == dods_str_c || d_proto->
type() == dods_url_c)
1952 void *buffer =
new char[
width(
true)];
1954 memcpy(buffer, d_buf,
width(
true));
2002 if (!v->
name().empty())
2009 DBG(cerr <<
"Vector::add_var: Added variable " << v <<
" (" 2033 if (!v->
name().empty())
2040 DBG(cerr <<
"Vector::add_var_no_copy: Added variable " << v <<
" (" 2060 strm << DapIndent::LMarg <<
"Vector::dump - (" << (
void *)
this <<
")" << endl;
2061 DapIndent::Indent();
2063 strm << DapIndent::LMarg <<
"# elements in vector: " << d_length << endl;
2065 strm << DapIndent::LMarg <<
"base type:" << endl;
2066 DapIndent::Indent();
2067 d_proto->
dump(strm);
2068 DapIndent::UnIndent();
2071 strm << DapIndent::LMarg <<
"base type: not set" << endl;
2073 strm << DapIndent::LMarg <<
"vector contents:" << endl;
2074 DapIndent::Indent();
2075 for (
unsigned i = 0; i < d_compound_buf.size(); ++i) {
2076 if (d_compound_buf[i])
2077 d_compound_buf[i]->dump(strm);
2079 strm << DapIndent::LMarg <<
"vec[" << i <<
"] is null" << endl;
2081 DapIndent::UnIndent();
2082 strm << DapIndent::LMarg <<
"strings:" << endl;
2083 DapIndent::Indent();
2084 for (
unsigned i = 0; i < d_str.size(); i++) {
2085 strm << DapIndent::LMarg << d_str[i] << endl;
2087 DapIndent::UnIndent();
2089 switch (d_proto != 0 ? d_proto->
type() : 0) {
2092 strm << DapIndent::LMarg <<
"_buf: ";
2093 strm.write(d_buf, d_length);
2099 strm << DapIndent::LMarg <<
"_buf: " << (
void *) d_buf << endl;
2104 strm << DapIndent::LMarg <<
"_buf: EMPTY" << endl;
2107 DapIndent::UnIndent();
virtual bool read()
Read data into a local buffer.
virtual bool read_p()
Has this variable been read?
virtual string name() const
Returns the name of the class instance.
abstract base class used to unmarshall/deserialize dap data objects
void set_vec(unsigned int i, BaseType *val)
Sets element i to value val.
virtual void dump(ostream &strm) const
dumps information about this object
Part
Names the parts of multi-section constructor data types.
virtual void set_name(const string &n)
Sets the name of the class instance.
Holds a one-dimensional collection of DAP2 data types.
virtual unsigned int width(bool constrained=false) const
Returns the width of the data, in bytes.
virtual void intern_data()
Read data into this variable.
virtual void clear_local_data()
Read data from the stream made by D4StreamMarshaller.
virtual void compute_checksum(Crc32 &checksum)
include the data for this variable in the checksum DAP4 includes a checksum with every data response...
virtual void set_read_p(bool state)
Indicates that the data is ready to send.
virtual void add_var(BaseType *v, Part p=nil)
Add the BaseType pointer to this constructor type instance.
virtual int element_count(bool leaves)
Count the members of constructor types.
void m_set_cardinal_values_internal(const CardType *fromArray, int numElts)
virtual unsigned int set_value_slice_from_row_major_vector(const Vector &rowMajorData, unsigned int startElement)
virtual void put_vector_float32(char *val, int64_t num_elem)
Write a fixed size vector.
Type
Identifies the data type.
virtual bool serialize(ConstraintEvaluator &eval, DDS &dds, Marshaller &m, bool ce_eval=true)
Serialize a Vector.
virtual void set_parent(BaseType *parent)
A class for software fault reporting.
virtual BaseType * var(const string &name="", bool exact_match=true, btp_stack *s=0)
virtual bool deserialize(UnMarshaller &um, DDS *dds, bool reuse=false)
Receive data from the net.
virtual BaseType * var(const string &name="", bool exact_match=true, btp_stack *s=0)
Returns a pointer to a member of a constructor class.
virtual void compute_checksum(Crc32 &checksum)=0
include the data for this variable in the checksum DAP4 includes a checksum with every data response...
Holds a DAP4 enumeration.
virtual int element_count(bool leaves=false)
Count the members of constructor types.
Marshaller that knows how to marshal/serialize dap data objects to a C++ iostream using DAP4's receiv...
virtual void set_send_p(bool state)
virtual bool is_constructor_type() const
Returns true if the instance is a constructor (i.e., Structure, Sequence or Grid) type variable...
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.
bool m_is_cardinal_type() const
virtual Type type() const
Returns the type of the class instance.
virtual void reserve_value_capacity()
virtual void set_read_p(bool state)
Sets the value of the read_p property.
Vector(const string &n, BaseType *v, const Type &t, bool is_dap4=false)
The Vector constructor.
virtual unsigned int val2buf(void *val, bool reuse=false)
Reads data into the Vector buffer.
virtual bool check_semantics(string &msg, bool all=false)
Compare an object's current state with the semantics of its type.
void m_delete_cardinal_data_buffer()
void AddData(const uint8_t *pData, const uint32_t length)
virtual unsigned int val2buf(void *val, bool reuse=false)=0
Loads class data.
virtual BaseType * ptr_duplicate()=0
string www2id(const string &in, const string &escape, const string &except)
virtual unsigned int get_value_capacity() const
Evaluate a constraint expression.
virtual void set_send_p(bool state)
Indicates that the data is ready to send.
unsigned int m_create_cardinal_data_buffer_for_type(unsigned int numEltsOfType)
virtual void put_vector(char *val, int64_t num_bytes)
Write a fixed size vector.
The basic data type for the DODS DAP types.
abstract base class used to marshal/serialize dap data objects
virtual string type_name() const
Returns the type of the class instance as a string.
virtual void set_name(const std::string &name)
Sets the name of the class instance.
virtual int length() const
virtual unsigned int buf2val(void **val)
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 ...
virtual void set_length(int l)
A class for error processing.
virtual void put_vector_float64(char *val, int64_t num_elem)
Write a fixed size vector of float64s.
virtual unsigned int width(bool constrained=false) const
How many bytes does this use Return the number of bytes of storage this variable uses. For scalar types, this is pretty simple (an int32 uses 4 bytes, etc.). For arrays and Constructors, it is a bit more complex. Note that a scalar String variable uses sizeof(String*) bytes, not the length of the string. In other words, the value returned is independent of the type. Also note width() of a String array returns the number of elements in the array times sizeof(String*). That is, each different array size is a different data type.
virtual void dump(ostream &strm) const
dumps information about this object
virtual string dataset() const
Returns the name of the dataset used to create this instance.
virtual bool check_semantics(string &msg, bool all=false)
Compare an object's current state with the semantics of its type.