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" 67 #include "DapIndent.h" 69 #undef CLEAR_LOCAL_DATA 76 void Vector::m_duplicate(
const Vector & v)
78 d_length = v.d_length;
94 if (v.d_compound_buf.empty()) {
95 d_compound_buf = v.d_compound_buf;
100 d_compound_buf.resize(d_length);
101 for (
int i = 0; i < d_length; ++i) {
106 d_compound_buf[i] = v.d_compound_buf[i]->ptr_duplicate();
118 d_capacity = v.d_capacity;
132 switch (d_proto->
type()) {
158 case dods_structure_c:
159 case dods_sequence_c:
165 assert(
"Vector::var: Unrecognized type");
186 throw InternalErr(__FILE__, __LINE__,
"create_cardinal_data_buffer_for_type: Logic error: _var is null!");
191 throw InternalErr(__FILE__, __LINE__,
"create_cardinal_data_buffer_for_type: incorrectly used on Vector whose type was not a cardinal (simple data types).");
197 if (numEltsOfType == 0)
201 unsigned int bytesPerElt = d_proto->
width();
202 unsigned int bytesNeeded = bytesPerElt * numEltsOfType;
203 d_buf =
new char[bytesNeeded];
205 d_capacity = numEltsOfType;
220 template<
class CardType>
224 throw InternalErr(__FILE__, __LINE__,
"Logic error: Vector::set_cardinal_values_internal() called with negative numElts!");
227 throw InternalErr(__FILE__, __LINE__,
"Logic error: Vector::set_cardinal_values_internal() called with null fromArray!");
231 memcpy(d_buf, fromArray, numElts *
sizeof(CardType));
251 BaseType(n, t, is_dap4), d_length(-1), d_proto(0), d_buf(0), d_compound_buf(0), d_capacity(0)
256 DBG2(cerr <<
"Entering Vector ctor for object: " <<
this << endl);
280 BaseType(n, d, t, is_dap4), d_length(-1), d_proto(0), d_buf(0), d_compound_buf(0), d_capacity(0)
285 DBG2(cerr <<
"Entering Vector ctor for object: " <<
this << endl);
294 DBG2(cerr <<
"Entering Vector const ctor for object: " <<
this <<
295 endl); DBG2(cerr <<
"RHS: " << &rhs << endl);
302 DBG2(cerr <<
"Entering ~Vector (" <<
this <<
")" << endl);
310 DBG2(cerr <<
"Exiting ~Vector" << endl);
318 dynamic_cast<BaseType &
> (*this) = rhs;
368 switch (d_proto->
type()) {
369 case dods_structure_c:
370 case dods_sequence_c:
372 if (d_compound_buf.size() > 0) {
373 for (
unsigned long long i = 0; i < (unsigned) d_length; ++i) {
374 if (d_compound_buf[i]) d_compound_buf[i]->set_send_p(state);
399 switch (d_proto->
type()) {
400 case dods_structure_c:
401 case dods_sequence_c:
403 if (d_compound_buf.size() > 0) {
404 for (
unsigned long long i = 0; i < (unsigned)d_length; ++i) {
405 if (d_compound_buf[i]) d_compound_buf[i]->set_read_p(state);
438 DBG2(cerr <<
"Vector::var: Looking for " << name << endl);
440 if (name ==
"" || d_proto->
name() ==
name) {
474 return d_proto->
var(name, s);
495 switch (d_proto->
type()) {
524 case dods_structure_c:
525 case dods_sequence_c:
527 return d_compound_buf[i];
531 throw Error (
"Vector::var: Unrecognized type");
580 throw InternalErr(__FILE__, __LINE__,
"Vector::vec_resize() is applicable to compound types only");
585 d_compound_buf.resize(l, 0);
586 d_capacity = d_compound_buf.size();
607 DBG(cerr <<
"Vector::intern_data: " <<
name() << endl);
614 switch (d_proto->
type()) {
634 throw InternalErr(__FILE__, __LINE__,
"Array of Array not supported.");
637 case dods_structure_c:
638 case dods_sequence_c:
640 DBG(cerr <<
"Vector::intern_data: found ctor" << endl);
646 if (d_compound_buf.capacity() < (unsigned)num)
647 throw InternalErr(__FILE__, __LINE__,
"The capacity of this Vector is less than the number of elements.");
649 for (
int i = 0; i < num; ++i)
655 throw InternalErr(__FILE__, __LINE__,
"Unknown datatype.");
696 switch (d_proto->
type()) {
698 m.put_vector(d_buf, num, *
this);
708 m.put_vector(d_buf, num, d_proto->
width(), *
this);
715 if (d_str.capacity() == 0)
716 throw InternalErr(__FILE__, __LINE__,
"The capacity of the string vector is 0");
720 for (
int i = 0; i < num; ++i)
727 case dods_structure_c:
728 case dods_sequence_c:
732 if (d_compound_buf.capacity() == 0)
733 throw InternalErr(__FILE__, __LINE__,
"The capacity of *this* vector is 0.");
737 for (
int i = 0; i < num && status; ++i)
738 status = status && d_compound_buf[i]->
serialize(eval, dds, m,
false);
743 throw InternalErr(__FILE__, __LINE__,
"Unknown datatype.");
747 #ifdef CLEAR_LOCAL_DATA 776 switch (d_proto->
type()) {
784 um.get_int((
int &) num);
786 DBG(cerr <<
"Vector::deserialize: num = " << num << endl);
787 DBG(cerr <<
"Vector::deserialize: length = " <<
length() << endl);
792 if (num != (
unsigned int)
length())
793 throw InternalErr(__FILE__, __LINE__,
"The server sent declarations and data with mismatched sizes for the variable '" +
name() +
"'.");
795 if (!d_buf || !reuse) {
799 DBG(cerr <<
"Vector::deserialize: allocating " 800 <<
width() <<
" bytes for an array of " 811 if (d_proto->
type() == dods_byte_c)
812 um.get_vector((
char **) &d_buf, num, *
this);
814 um.get_vector((
char **) &d_buf, num, d_proto->
width(), *
this);
816 DBG(cerr <<
"Vector::deserialize: read " << num <<
" elements\n");
822 um.get_int((
int &) num);
827 if (num != (
unsigned int)
length())
828 throw InternalErr(__FILE__, __LINE__,
"The client sent declarations and data with mismatched sizes.");
830 d_str.resize((num > 0) ? num : 0);
833 for (i = 0; i < num; ++i) {
845 throw InternalErr(__FILE__, __LINE__,
"Array of array!");
848 case dods_structure_c:
849 case dods_sequence_c:
851 um.get_int((
int &) num);
856 if (num != (
unsigned int)
length())
857 throw InternalErr(__FILE__, __LINE__,
"The client sent declarations and data with mismatched sizes.");
861 for (i = 0; i < num; ++i) {
863 d_compound_buf[i]->deserialize(um, dds);
869 throw InternalErr(__FILE__, __LINE__,
"Unknown type!");
878 switch (d_proto->
type()) {
901 for (int64_t i = 0, e =
length(); i < e; ++i)
902 checksum.
AddData(reinterpret_cast<const uint8_t*>(d_str[i].data()), d_str[i].
length());
906 case dods_structure_c:
907 case dods_sequence_c:
914 throw InternalErr(__FILE__, __LINE__,
"Unknown or unsupported datatype (" + d_proto->
type_name() +
").");
924 switch (d_proto->
type()) {
949 case dods_structure_c:
950 case dods_sequence_c:
953 assert(d_compound_buf.capacity() >= (unsigned)
length());
955 for (
int i = 0, e =
length(); i < e; ++i)
962 throw InternalErr(__FILE__, __LINE__,
"Unknown or unsupported datatype (" + d_proto->
type_name() +
").");
973 if (filter && !eval.eval_selection(dmr,
dataset()))
978 DBG(cerr << __func__ <<
", num: " << num << endl);
984 switch (d_proto->
type()) {
1002 if (d_proto->
width() == 1)
1008 case dods_float32_c:
1012 case dods_float64_c:
1018 assert((int64_t)d_str.capacity() >= num);
1020 for (int64_t i = 0; i < num; ++i)
1021 m.put_str(d_str[i]);
1026 throw InternalErr(__FILE__, __LINE__,
"Array of Array not allowed.");
1029 case dods_structure_c:
1030 case dods_sequence_c:
1031 assert(d_compound_buf.capacity() >= 0);
1033 for (int64_t i = 0; i < num; ++i) {
1034 DBG(cerr << __func__ <<
"d_compound_buf[" << i <<
"] " << d_compound_buf[i] << endl);
1035 d_compound_buf[i]->serialize(m, dmr, filter);
1041 throw InternalErr(__FILE__, __LINE__,
"Grid is not part of DAP4.");
1044 throw InternalErr(__FILE__, __LINE__,
"Unknown datatype.");
1048 #ifdef CLEAR_LOCAL_DATA 1063 DBG(cerr << __FUNCTION__ <<
name() <<
", length(): " <<
length() << endl);
1069 switch (d_proto->
type()) {
1074 um.get_vector((
char *)d_buf,
length());
1083 um.get_vector((
char *)d_buf,
length(), d_proto->
width());
1087 if (d_proto->
width() == 1)
1088 um.get_vector((
char *)d_buf,
length());
1090 um.get_vector((
char *)d_buf,
length(), d_proto->
width());
1093 case dods_float32_c:
1094 um.get_vector_float32((
char *)d_buf,
length());
1097 case dods_float64_c:
1098 um.get_vector_float64((
char *)d_buf,
length());
1104 d_str.resize((len > 0) ? len : 0);
1107 for (int64_t i = 0; i < len; ++i) {
1108 um.get_str(d_str[i]);
1115 throw InternalErr(__FILE__, __LINE__,
"Array of Array not allowed.");
1118 case dods_structure_c:
1119 case dods_sequence_c: {
1122 for (int64_t i = 0, end =
length(); i < end; ++i) {
1124 d_compound_buf[i]->deserialize(um, dmr);
1131 throw InternalErr(__FILE__, __LINE__,
"Grid is not part of DAP4.");
1134 throw InternalErr(__FILE__, __LINE__,
"Unknown type.");
1171 if (!val &&
length() == 0)
1182 throw InternalErr(__FILE__, __LINE__,
"The incoming pointer does not contain any data.");
1184 switch (d_proto->
type()) {
1198 case dods_float32_c:
1199 case dods_float64_c:
1201 if (d_buf && !reuse)
1205 if (!d_buf || !reuse)
1209 memcpy(d_buf, val,
width(
true));
1217 d_str.resize(d_length);
1218 d_capacity = d_length;
1219 for (
int i = 0; i < d_length; ++i)
1220 d_str[i] = *(static_cast<string *> (val) + i);
1225 throw InternalErr(__FILE__, __LINE__,
"Vector::val2buf: bad type");
1267 throw InternalErr(__FILE__, __LINE__,
"NULL pointer.");
1269 unsigned int wid =
static_cast<unsigned int> (
width(
true ));
1276 switch (d_proto->
type()) {
1290 case dods_float32_c:
1291 case dods_float64_c:
1293 throw InternalErr(__FILE__, __LINE__,
"Vector::buf2val: Logic error: called when cardinal type data buffer was empty!");
1295 *val =
new char[wid];
1297 memcpy(*val, d_buf, wid);
1304 throw InternalErr(__FILE__, __LINE__,
"Vector::buf2val: Logic error: called when string data buffer was empty!");
1306 *val =
new string[d_length];
1308 for (
int i = 0; i < d_length; ++i)
1309 *(static_cast<string *> (*val) + i) = d_str[i];
1316 throw InternalErr(__FILE__, __LINE__,
"Vector::buf2val: bad type");
1364 if (i >= static_cast<unsigned int> (d_length))
1365 throw InternalErr(__FILE__, __LINE__,
"Invalid data: index too large.");
1367 throw InternalErr(__FILE__, __LINE__,
"Invalid data: null pointer to BaseType object.");
1368 if (val->
type() != d_proto->
type())
1369 throw InternalErr(__FILE__, __LINE__,
"invalid data: type of incoming object does not match *this* vector type.");
1379 if (i >= d_compound_buf.size()) {
1383 d_compound_buf[i] = val;
1402 for (
unsigned int i = 0; i < d_compound_buf.size(); ++i) {
1403 delete d_compound_buf[i];
1404 d_compound_buf[i] = 0;
1408 d_compound_buf.resize(0);
1439 throw InternalErr(__FILE__, __LINE__,
"reserve_value_capacity: Logic error: _var is null!");
1441 switch (d_proto->
type()) {
1455 case dods_float32_c:
1456 case dods_float64_c:
1465 d_str.reserve(numElements);
1466 d_capacity = numElements;
1470 throw InternalErr(__FILE__, __LINE__,
"reserve_value_capacity: Arrays not supported!");
1474 case dods_structure_c:
1475 case dods_sequence_c:
1478 d_compound_buf.reserve(numElements);
1479 d_capacity = numElements;
1483 throw InternalErr(__FILE__, __LINE__,
"reserve_value_capacity: Unknown type!");
1532 static const string funcName =
"set_value_slice_from_row_major_vector:";
1535 Vector& rowMajorData =
const_cast<Vector&
>(rowMajorDataC);
1537 bool typesMatch = rowMajorData.
var() && d_proto && (rowMajorData.
var()->
type() == d_proto->
type());
1539 throw InternalErr(__FILE__, __LINE__, funcName +
"Logic error: types do not match so cannot be copied!");
1543 if (!rowMajorData.
read_p()) {
1545 funcName +
"Logic error: the Vector to copy data from has !read_p() and should have been read in!");
1549 if (rowMajorData.
length() < 0) {
1552 +
"Logic error: the Vector to copy data from has length() < 0 and was probably not initialized!");
1560 +
"Logic error: the Vector to copy from has a data capacity less than its length, can't copy!");
1565 if (d_capacity < (startElement + rowMajorData.
length())) {
1567 funcName +
"Logic error: the capacity of this Vector cannot hold all the data in the from Vector!");
1571 switch (d_proto->
type()) {
1585 case dods_float32_c:
1586 case dods_float64_c: {
1588 throw InternalErr(__FILE__, __LINE__, funcName +
"Logic error: this->_buf was unexpectedly null!");
1590 if (!rowMajorData.d_buf) {
1591 throw InternalErr(__FILE__, __LINE__, funcName +
"Logic error: rowMajorData._buf was unexpectedly null!");
1594 int varWidth = d_proto->
width();
1595 char* pFromBuf = rowMajorData.d_buf;
1596 int numBytesToCopy = rowMajorData.
width(
true);
1597 char* pIntoBuf = d_buf + (startElement * varWidth);
1598 memcpy(pIntoBuf, pFromBuf, numBytesToCopy);
1605 for (
unsigned int i = 0; i < static_cast<unsigned int>(rowMajorData.
length()); ++i) {
1606 d_str[startElement + i] = rowMajorData.d_str[i];
1612 case dods_structure_c:
1613 case dods_sequence_c:
1617 funcName +
"Unimplemented method for Vectors of type: array, opaque, structure, sequence or grid.");
1621 throw InternalErr(__FILE__, __LINE__, funcName +
": Unknown type!");
1627 return (
unsigned int) rowMajorData.
length();
1638 template <
typename T>
1639 static bool types_match(
Type t, T *cpp_var)
1645 return typeid(cpp_var) ==
typeid(dods_byte*);
1648 return typeid(cpp_var) ==
typeid(dods_int8*);
1650 return typeid(cpp_var) ==
typeid(dods_int16*);
1652 return typeid(cpp_var) ==
typeid(dods_uint16*);
1654 return typeid(cpp_var) ==
typeid(dods_int32*);
1656 return typeid(cpp_var) ==
typeid(dods_uint32*);
1658 return typeid(cpp_var) ==
typeid(dods_int64*);
1660 return typeid(cpp_var) ==
typeid(dods_uint64*);
1662 case dods_float32_c:
1663 return typeid(cpp_var) ==
typeid(dods_float32*);
1664 case dods_float64_c:
1665 return typeid(cpp_var) ==
typeid(dods_float64*);
1673 case dods_structure_c:
1674 case dods_sequence_c:
1684 template <
typename T>
1685 bool Vector::set_value_worker(T *v,
int sz)
1687 if (!v || !types_match(d_proto->
type() == dods_enum_c ?
static_cast<D4Enum*
>(d_proto)->element_type() : d_proto->
type(), v))
1694 bool Vector::set_value(dods_byte *val,
int sz)
1696 return set_value_worker(val, sz);
1698 bool Vector::set_value(dods_int8 *val,
int sz)
1700 return set_value_worker(val, sz);
1702 bool Vector::set_value(dods_int16 *val,
int sz)
1704 return set_value_worker(val, sz);
1706 bool Vector::set_value(dods_uint16 *val,
int sz)
1708 return set_value_worker(val, sz);
1710 bool Vector::set_value(dods_int32 *val,
int sz)
1712 return set_value_worker(val, sz);
1714 bool Vector::set_value(dods_uint32 *val,
int sz)
1716 return set_value_worker(val, sz);
1718 bool Vector::set_value(dods_int64 *val,
int sz)
1720 return set_value_worker(val, sz);
1722 bool Vector::set_value(dods_uint64 *val,
int sz)
1724 return set_value_worker(val, sz);
1726 bool Vector::set_value(dods_float32 *val,
int sz)
1728 return set_value_worker(val, sz);
1730 bool Vector::set_value(dods_float64 *val,
int sz)
1732 return set_value_worker(val, sz);
1736 bool Vector::set_value(
string *val,
int sz)
1738 if ((
var()->
type() == dods_str_c ||
var()->
type() == dods_url_c) && val) {
1741 for (
register int t = 0; t < sz; t++) {
1753 template<
typename T>
1754 bool Vector::set_value_worker(vector<T> &v,
int sz)
1756 return set_value(&v[0], sz);
1759 bool Vector::set_value(vector<dods_byte> &val,
int sz)
1761 return set_value_worker(val, sz);
1763 bool Vector::set_value(vector<dods_int8> &val,
int sz)
1765 return set_value_worker(val, sz);
1767 bool Vector::set_value(vector<dods_int16> &val,
int sz)
1769 return set_value_worker(val, sz);
1771 bool Vector::set_value(vector<dods_uint16> &val,
int sz)
1773 return set_value_worker(val, sz);
1775 bool Vector::set_value(vector<dods_int32> &val,
int sz)
1777 return set_value_worker(val, sz);
1779 bool Vector::set_value(vector<dods_uint32> &val,
int sz)
1781 return set_value_worker(val, sz);
1783 bool Vector::set_value(vector<dods_int64> &val,
int sz)
1785 return set_value_worker(val, sz);
1787 bool Vector::set_value(vector<dods_uint64> &val,
int sz)
1789 return set_value_worker(val, sz);
1791 bool Vector::set_value(vector<dods_float32> &val,
int sz)
1793 return set_value_worker(val, sz);
1795 bool Vector::set_value(vector<dods_float64> &val,
int sz)
1797 return set_value_worker(val, sz);
1802 bool Vector::set_value(vector<string> &val,
int sz)
1804 if (
var()->
type() == dods_str_c ||
var()->
type() == dods_url_c) {
1807 for (
register int t = 0; t < sz; t++) {
1838 template <
typename T>
1839 void Vector::value_worker(vector<unsigned int> *indices, T *b)
const 1844 for (vector<unsigned int>::iterator i = indices->begin(), e = indices->end(); i != e; ++i) {
1845 unsigned long currentIndex = *i;
1846 if(currentIndex > (
unsigned int)
length()){
1848 s <<
"Vector::value() - Subset index[" << i - subsetIndex->begin() <<
"] = " << currentIndex <<
" references a value that is " <<
1849 "outside the bounds of the internal storage [ length()= " <<
length() <<
" ] name: '" <<
name() <<
"'. ";
1850 throw Error(s.str());
1852 b[i - indices->begin()] =
reinterpret_cast<T*
>(d_buf )[currentIndex];
1855 for (
unsigned long i = 0, e = indices->size(); i < e; ++i) {
1856 unsigned long currentIndex = (*indices)[i];
1857 if (currentIndex > (
unsigned int)
length()) {
1859 s <<
"Vector::value() - Subset index[" << i <<
"] = " << currentIndex <<
" references a value that is " <<
1860 "outside the bounds of the internal storage [ length()= " <<
length() <<
" ] name: '" <<
name() <<
"'. ";
1861 throw Error(s.str());
1863 b[i] =
reinterpret_cast<T*
>(d_buf )[currentIndex];
1866 void Vector::value(vector<unsigned int> *indices, dods_byte *b)
const { value_worker(indices, b); }
1867 void Vector::value(vector<unsigned int> *indices, dods_int8 *b)
const { value_worker(indices, b); }
1868 void Vector::value(vector<unsigned int> *indices, dods_int16 *b)
const { value_worker(indices, b); }
1869 void Vector::value(vector<unsigned int> *indices, dods_uint16 *b)
const { value_worker(indices, b); }
1870 void Vector::value(vector<unsigned int> *indices, dods_int32 *b)
const { value_worker(indices, b); }
1871 void Vector::value(vector<unsigned int> *indices, dods_uint32 *b)
const { value_worker(indices, b); }
1872 void Vector::value(vector<unsigned int> *indices, dods_int64 *b)
const { value_worker(indices, b); }
1873 void Vector::value(vector<unsigned int> *indices, dods_uint64 *b)
const { value_worker(indices, b); }
1874 void Vector::value(vector<unsigned int> *indices, dods_float32 *b)
const { value_worker(indices, b); }
1875 void Vector::value(vector<unsigned int> *indices, dods_float64 *b)
const { value_worker(indices, b); }
1878 template void Vector::value(vector<unsigned int> *indices, dods_byte *b)
const;
1879 template void Vector::value(vector<unsigned int> *indices, dods_int8 *b)
const;
1880 template void Vector::value(vector<unsigned int> *indices, dods_int16 *b)
const;
1881 template void Vector::value(vector<unsigned int> *indices, dods_uint16 *b)
const;
1882 template void Vector::value(vector<unsigned int> *indices, dods_int32 *b)
const;
1883 template void Vector::value(vector<unsigned int> *indices, dods_uint32 *b)
const;
1884 template void Vector::value(vector<unsigned int> *indices, dods_int64 *b)
const;
1885 template void Vector::value(vector<unsigned int> *indices, dods_uint64 *b)
const;
1886 template void Vector::value(vector<unsigned int> *indices, dods_float32 *b)
const;
1887 template void Vector::value(vector<unsigned int> *indices, dods_float64 *b)
const;
1893 unsigned long currentIndex;
1895 if (d_proto->
type() == dods_str_c || d_proto->
type() == dods_url_c){
1896 for(
unsigned long i=0; i<subsetIndex->size() ;++i){
1897 currentIndex = (*subsetIndex)[i] ;
1898 if(currentIndex > (
unsigned int)
length()){
1900 s <<
"Vector::value() - Subset index[" << i <<
"] = " << currentIndex <<
" references a value that is " <<
1901 "outside the bounds of the internal storage [ length()= " <<
length() <<
" ] name: '" <<
name() <<
"'. ";
1902 throw Error(s.str());
1904 b[i] = d_str[currentIndex];
1909 template <
typename T>
1910 void Vector::value_worker(T *v)
const 1914 if (v && types_match(d_proto->
type() == dods_enum_c ?
static_cast<D4Enum*
>(d_proto)->element_type() : d_proto->
type(), v))
1915 memcpy(v, d_buf,
length() *
sizeof(T));
1919 void Vector::value(dods_int16 *b)
const { value_worker(b); }
1920 void Vector::value(dods_uint16 *b)
const { value_worker(b); }
1921 void Vector::value(dods_int32 *b)
const { value_worker(b); }
1922 void Vector::value(dods_uint32 *b)
const { value_worker(b); }
1923 void Vector::value(dods_int64 *b)
const { value_worker(b); }
1924 void Vector::value(dods_uint64 *b)
const { value_worker(b); }
1925 void Vector::value(dods_float32 *b)
const { value_worker(b); }
1926 void Vector::value(dods_float64 *b)
const { value_worker(b); }
1945 if (d_proto->
type() == dods_str_c || d_proto->
type() == dods_url_c)
1953 void *buffer =
new char[
width(
true)];
1955 memcpy(buffer, d_buf,
width(
true));
2003 if (!v->
name().empty())
2010 DBG(cerr <<
"Vector::add_var: Added variable " << v <<
" (" 2034 if (!v->
name().empty())
2041 DBG(cerr <<
"Vector::add_var_no_copy: Added variable " << v <<
" (" 2061 strm << DapIndent::LMarg <<
"Vector::dump - (" << (
void *)
this <<
")" << endl;
2062 DapIndent::Indent();
2064 strm << DapIndent::LMarg <<
"# elements in vector: " << d_length << endl;
2066 strm << DapIndent::LMarg <<
"base type:" << endl;
2067 DapIndent::Indent();
2068 d_proto->
dump(strm);
2069 DapIndent::UnIndent();
2072 strm << DapIndent::LMarg <<
"base type: not set" << endl;
2074 strm << DapIndent::LMarg <<
"vector contents:" << endl;
2075 DapIndent::Indent();
2076 for (
unsigned i = 0; i < d_compound_buf.size(); ++i) {
2077 if (d_compound_buf[i])
2078 d_compound_buf[i]->dump(strm);
2080 strm << DapIndent::LMarg <<
"vec[" << i <<
"] is null" << endl;
2082 DapIndent::UnIndent();
2083 strm << DapIndent::LMarg <<
"strings:" << endl;
2084 DapIndent::Indent();
2085 for (
unsigned i = 0; i < d_str.size(); i++) {
2086 strm << DapIndent::LMarg << d_str[i] << endl;
2088 DapIndent::UnIndent();
2090 switch (d_proto != 0 ? d_proto->
type() : 0) {
2093 strm << DapIndent::LMarg <<
"_buf: ";
2094 strm.write(d_buf, d_length);
2100 strm << DapIndent::LMarg <<
"_buf: " << (
void *) d_buf << endl;
2105 strm << DapIndent::LMarg <<
"_buf: EMPTY" << endl;
2108 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)
top level DAP object to house generic methods
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.