35#include "XDRFileUnMarshaller.h"
52#include "InternalErr.h"
57XDRFileUnMarshaller::XDRFileUnMarshaller(FILE *out) : _source(0) { _source = new_xdrstdio(out, XDR_DECODE); }
59XDRFileUnMarshaller::XDRFileUnMarshaller() : UnMarshaller(), _source(0) {
60 throw InternalErr(__FILE__, __LINE__,
"Default constructor not implemented.");
63XDRFileUnMarshaller::XDRFileUnMarshaller(
const XDRFileUnMarshaller &um) : UnMarshaller(um), _source(0) {
64 throw InternalErr(__FILE__, __LINE__,
"Copy constructor not implemented.");
67XDRFileUnMarshaller &XDRFileUnMarshaller::operator=(
const XDRFileUnMarshaller &) {
68 throw InternalErr(__FILE__, __LINE__,
"Copy operator not implemented.");
71XDRFileUnMarshaller::~XDRFileUnMarshaller() {
76 delete_xdrstdio(_source);
79void XDRFileUnMarshaller::get_byte(dods_byte &val) {
80 if (!xdr_char(_source, (
char *)&val))
81 throw Error(
"Network I/O Error. Could not read byte data.");
84void XDRFileUnMarshaller::get_int16(dods_int16 &val) {
85 if (!XDR_INT16(_source, &val))
86 throw Error(
"Network I/O Error. Could not read int 16 data.");
89void XDRFileUnMarshaller::get_int32(dods_int32 &val) {
90 if (!XDR_INT32(_source, &val))
91 throw Error(
"Network I/O Error. Could not read int 32 data.");
94void XDRFileUnMarshaller::get_float32(dods_float32 &val) {
95 if (!xdr_float(_source, &val))
96 throw Error(
"Network I/O Error. Could not read float 32 data.");
99void XDRFileUnMarshaller::get_float64(dods_float64 &val) {
100 if (!xdr_double(_source, &val))
101 throw Error(
"Network I/O Error.Could not read float 64 data.");
104void XDRFileUnMarshaller::get_uint16(dods_uint16 &val) {
105 if (!XDR_UINT16(_source, &val))
106 throw Error(
"Network I/O Error. Could not read uint 16 data.");
109void XDRFileUnMarshaller::get_uint32(dods_uint32 &val) {
110 if (!XDR_UINT32(_source, &val))
111 throw Error(
"Network I/O Error. Could not read uint 32 data.");
114void XDRFileUnMarshaller::get_str(
string &val) {
117 if (!xdr_string(_source, &in_tmp, max_str_len))
118 throw Error(
"Network I/O Error. Could not read string data.");
125void XDRFileUnMarshaller::get_url(
string &val) { get_str(val); }
127void XDRFileUnMarshaller::get_opaque(
char *val,
unsigned int len) { xdr_opaque(_source, val, len); }
129void XDRFileUnMarshaller::get_int(
int &val) {
130 if (!xdr_int(_source, &val))
132 "Network I/O Error(1). This may be due to a bug in libdap or a\nproblem with the network connection.");
135void XDRFileUnMarshaller::get_vector(
char **val,
unsigned int &num, Vector &) {
136 if (!xdr_bytes(_source, val, &num, DODS_MAX_ARRAY))
137 throw Error(
"Network I/O error (1).");
140void XDRFileUnMarshaller::get_vector(
char **val,
unsigned int &num,
int width, Vector &vec) {
141 BaseType *var = vec.var();
143 if (!xdr_array(_source, val, &num, DODS_MAX_ARRAY, width, XDRUtils::xdr_coder(var->type()))) {
144 throw Error(
"Network I/O error (2).");
149 strm << DapIndent::LMarg <<
"XDRFileUnMarshaller::dump - (" << (
void *)
this <<
")" << endl;
virtual void dump(ostream &strm) const
dump the contents of this object to the specified ostream
top level DAP object to house generic methods