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." ) ;
83 XDRFileUnMarshaller::~XDRFileUnMarshaller( )
89 delete_xdrstdio( _source ) ;
93 XDRFileUnMarshaller::get_byte( dods_byte &val )
95 if( !xdr_char( _source, (
char *)&val ) )
96 throw Error(
"Network I/O Error. Could not read byte data.");
100 XDRFileUnMarshaller::get_int16( dods_int16 &val )
102 if( !XDR_INT16( _source, &val ) )
103 throw Error(
"Network I/O Error. Could not read int 16 data.");
107 XDRFileUnMarshaller::get_int32( dods_int32 &val )
109 if( !XDR_INT32( _source, &val ) )
110 throw Error(
"Network I/O Error. Could not read int 32 data.");
114 XDRFileUnMarshaller::get_float32( dods_float32 &val )
116 if( !xdr_float( _source, &val ) )
117 throw Error(
"Network I/O Error. Could not read float 32 data.");
121 XDRFileUnMarshaller::get_float64( dods_float64 &val )
123 if( !xdr_double( _source, &val ) )
124 throw Error(
"Network I/O Error.Could not read float 64 data.");
128 XDRFileUnMarshaller::get_uint16( dods_uint16 &val )
130 if( !XDR_UINT16( _source, &val ) )
131 throw Error(
"Network I/O Error. Could not read uint 16 data.");
135 XDRFileUnMarshaller::get_uint32( dods_uint32 &val )
137 if( !XDR_UINT32( _source, &val ) )
138 throw Error(
"Network I/O Error. Could not read uint 32 data.");
142 XDRFileUnMarshaller::get_str(
string &val )
144 char *in_tmp = NULL ;
146 if( !xdr_string( _source, &in_tmp, max_str_len ) )
147 throw Error(
"Network I/O Error. Could not read string data.");
155 XDRFileUnMarshaller::get_url(
string &val )
161 XDRFileUnMarshaller::get_opaque(
char *val,
unsigned int len )
163 xdr_opaque( _source, val, len ) ;
167 XDRFileUnMarshaller::get_int(
int &val )
169 if( !xdr_int( _source, &val ) )
170 throw Error(
"Network I/O Error(1). This may be due to a bug in libdap or a\nproblem with the network connection.");
174 XDRFileUnMarshaller::get_vector(
char **val,
unsigned int &num, Vector & )
176 if( !xdr_bytes( _source, val, &num, DODS_MAX_ARRAY) )
177 throw Error(
"Network I/O error (1).");
181 XDRFileUnMarshaller::get_vector(
char **val,
unsigned int &num,
int width, Vector &vec )
183 BaseType *var = vec.var() ;
185 if( !xdr_array( _source, val, &num, DODS_MAX_ARRAY, width,
188 throw Error(
"Network I/O error (2).");
195 strm << DapIndent::LMarg <<
"XDRFileUnMarshaller::dump - (" 196 << (
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.