35 #include "XDRFileUnMarshaller.h" 47 #include "Structure.h" 52 #include "InternalErr.h" 53 #include "DapIndent.h" 57 XDRFileUnMarshaller::XDRFileUnMarshaller( FILE *out )
60 _source = new_xdrstdio( out, XDR_DECODE ) ;
63 XDRFileUnMarshaller::XDRFileUnMarshaller()
64 : UnMarshaller(), _source( 0 )
66 throw InternalErr( __FILE__, __LINE__,
"Default constructor not implemented." ) ;
69 XDRFileUnMarshaller::XDRFileUnMarshaller(
const XDRFileUnMarshaller &um )
70 : UnMarshaller( um ), _source( 0 )
72 throw InternalErr( __FILE__, __LINE__,
"Copy constructor not implemented." ) ;
76 XDRFileUnMarshaller::operator=(
const XDRFileUnMarshaller & )
78 throw InternalErr( __FILE__, __LINE__,
"Copy operator not implemented." ) ;
81 XDRFileUnMarshaller::~XDRFileUnMarshaller( )
87 delete_xdrstdio( _source ) ;
91 XDRFileUnMarshaller::get_byte( dods_byte &val )
93 if( !xdr_char( _source, (
char *)&val ) )
94 throw Error(
"Network I/O Error. Could not read byte data.");
98 XDRFileUnMarshaller::get_int16( dods_int16 &val )
100 if( !XDR_INT16( _source, &val ) )
101 throw Error(
"Network I/O Error. Could not read int 16 data.");
105 XDRFileUnMarshaller::get_int32( dods_int32 &val )
107 if( !XDR_INT32( _source, &val ) )
108 throw Error(
"Network I/O Error. Could not read int 32 data.");
112 XDRFileUnMarshaller::get_float32( dods_float32 &val )
114 if( !xdr_float( _source, &val ) )
115 throw Error(
"Network I/O Error. Could not read float 32 data.");
119 XDRFileUnMarshaller::get_float64( dods_float64 &val )
121 if( !xdr_double( _source, &val ) )
122 throw Error(
"Network I/O Error.Could not read float 64 data.");
126 XDRFileUnMarshaller::get_uint16( dods_uint16 &val )
128 if( !XDR_UINT16( _source, &val ) )
129 throw Error(
"Network I/O Error. Could not read uint 16 data.");
133 XDRFileUnMarshaller::get_uint32( dods_uint32 &val )
135 if( !XDR_UINT32( _source, &val ) )
136 throw Error(
"Network I/O Error. Could not read uint 32 data.");
140 XDRFileUnMarshaller::get_str(
string &val )
142 char *in_tmp = NULL ;
144 if( !xdr_string( _source, &in_tmp, max_str_len ) )
145 throw Error(
"Network I/O Error. Could not read string data.");
153 XDRFileUnMarshaller::get_url(
string &val )
159 XDRFileUnMarshaller::get_opaque(
char *val,
unsigned int len )
161 xdr_opaque( _source, val, len ) ;
165 XDRFileUnMarshaller::get_int(
int &val )
167 if( !xdr_int( _source, &val ) )
168 throw Error(
"Network I/O Error(1). This may be due to a bug in libdap or a\nproblem with the network connection.");
172 XDRFileUnMarshaller::get_vector(
char **val,
unsigned int &num, Vector & )
174 if( !xdr_bytes( _source, val, &num, DODS_MAX_ARRAY) )
175 throw Error(
"Network I/O error (1).");
179 XDRFileUnMarshaller::get_vector(
char **val,
unsigned int &num,
int width, Vector &vec )
181 BaseType *var = vec.var() ;
183 if( !xdr_array( _source, val, &num, DODS_MAX_ARRAY, width,
186 throw Error(
"Network I/O error (2).");
193 strm << DapIndent::LMarg <<
"XDRFileUnMarshaller::dump - (" 194 << (
void *)
this <<
")" << endl ;
top level DAP object to house generic methods
virtual void dump(ostream &strm) const
dump the contents of this object to the specified ostream
static xdrproc_t xdr_coder(const Type &t)
Returns a function used to encode elements of an array.