35 #include "XDRFileUnMarshaller.h"
47 #include "Structure.h"
54 #include "InternalErr.h"
58 XDRFileUnMarshaller::XDRFileUnMarshaller( FILE *out )
61 _source = new_xdrstdio( out, XDR_DECODE ) ;
64 XDRFileUnMarshaller::XDRFileUnMarshaller()
65 : UnMarshaller(), _source( 0 )
67 throw InternalErr( __FILE__, __LINE__,
"Default constructor not implemented." ) ;
70 XDRFileUnMarshaller::XDRFileUnMarshaller(
const XDRFileUnMarshaller &um )
71 : UnMarshaller( um ), _source( 0 )
73 throw InternalErr( __FILE__, __LINE__,
"Copy constructor not implemented." ) ;
77 XDRFileUnMarshaller::operator=(
const XDRFileUnMarshaller & )
79 throw InternalErr( __FILE__, __LINE__,
"Copy operator not implemented." ) ;
84 XDRFileUnMarshaller::~XDRFileUnMarshaller( )
90 delete_xdrstdio( _source ) ;
94 XDRFileUnMarshaller::get_byte( dods_byte &val )
96 if( !xdr_char( _source, (
char *)&val ) )
97 throw Error(
"Network I/O Error. Could not read byte data.");
101 XDRFileUnMarshaller::get_int16( dods_int16 &val )
103 if( !XDR_INT16( _source, &val ) )
104 throw Error(
"Network I/O Error. Could not read int 16 data.");
108 XDRFileUnMarshaller::get_int32( dods_int32 &val )
110 if( !XDR_INT32( _source, &val ) )
111 throw Error(
"Network I/O Error. Could not read int 32 data.");
115 XDRFileUnMarshaller::get_float32( dods_float32 &val )
117 if( !xdr_float( _source, &val ) )
118 throw Error(
"Network I/O Error. Could not read float 32 data.");
122 XDRFileUnMarshaller::get_float64( dods_float64 &val )
124 if( !xdr_double( _source, &val ) )
125 throw Error(
"Network I/O Error.Could not read float 64 data.");
129 XDRFileUnMarshaller::get_uint16( dods_uint16 &val )
131 if( !XDR_UINT16( _source, &val ) )
132 throw Error(
"Network I/O Error. Could not read uint 16 data.");
136 XDRFileUnMarshaller::get_uint32( dods_uint32 &val )
138 if( !XDR_UINT32( _source, &val ) )
139 throw Error(
"Network I/O Error. Could not read uint 32 data.");
143 XDRFileUnMarshaller::get_str(
string &val )
145 char *in_tmp = NULL ;
147 if( !xdr_string( _source, &in_tmp, max_str_len ) )
148 throw Error(
"Network I/O Error. Could not read string data.");
156 XDRFileUnMarshaller::get_url(
string &val )
162 XDRFileUnMarshaller::get_opaque(
char *val,
unsigned int len )
164 xdr_opaque( _source, val, len ) ;
168 XDRFileUnMarshaller::get_int(
int &val )
170 if( !xdr_int( _source, &val ) )
171 throw Error(
"Network I/O Error(1). This may be due to a bug in libdap or a\nproblem with the network connection.");
175 XDRFileUnMarshaller::get_vector(
char **val,
unsigned int &num, Vector & )
177 if( !xdr_bytes( _source, val, &num, DODS_MAX_ARRAY) )
178 throw Error(
"Network I/O error (1).");
182 XDRFileUnMarshaller::get_vector(
char **val,
unsigned int &num,
int width, Vector &vec )
184 BaseType *var = vec.var() ;
186 if( !xdr_array( _source, val, &num, DODS_MAX_ARRAY, width,
189 throw Error(
"Network I/O error (2).");
196 strm << DapIndent::LMarg <<
"XDRFileUnMarshaller::dump - ("
197 << (
void *)
this <<
")" << endl ;