35#include "XDRFileMarshaller.h"
52#include "InternalErr.h"
57XDRFileMarshaller::XDRFileMarshaller(FILE *out)
60 _sink = new_xdrstdio(out, XDR_ENCODE);
63XDRFileMarshaller::XDRFileMarshaller()
64 : Marshaller(), _sink(0)
66 throw InternalErr(__FILE__, __LINE__,
"Default constructor not implemented.");
69XDRFileMarshaller::XDRFileMarshaller(
const XDRFileMarshaller &m)
70 : Marshaller(m), _sink(0)
72 throw InternalErr(__FILE__, __LINE__,
"Copy constructor not implemented.");
75XDRFileMarshaller &XDRFileMarshaller::operator=(
const XDRFileMarshaller &) {
76 throw InternalErr(__FILE__, __LINE__,
"Copy operator not implemented.");
79XDRFileMarshaller::~XDRFileMarshaller() { delete_xdrstdio(_sink); }
81void XDRFileMarshaller::put_byte(dods_byte val) {
82 if (!xdr_char(_sink, (
char *)&val))
83 throw Error(
"Network I/O Error. Could not send byte data.\nThis may be due to a bug in DODS, on the server or "
84 "a\nproblem with the network connection.");
87void XDRFileMarshaller::put_int16(dods_int16 val) {
88 if (!XDR_INT16(_sink, &val))
89 throw Error(
"Network I/O Error. Could not send int 16 data.\nThis may be due to a bug in libdap, on the server "
90 "or a\nproblem with the network connection.");
93void XDRFileMarshaller::put_int32(dods_int32 val) {
94 if (!XDR_INT32(_sink, &val))
95 throw Error(
"Network I/O Error. Could not read int 32 data.\nThis may be due to a bug in libdap, on the server "
96 "or a\nproblem with the network connection.");
99void XDRFileMarshaller::put_float32(dods_float32 val) {
100 if (!xdr_float(_sink, &val))
101 throw Error(
"Network I/O Error. Could not send float 32 data.\nThis may be due to a bug in libdap, on the "
102 "server or a\nproblem with the network connection.");
105void XDRFileMarshaller::put_float64(dods_float64 val) {
106 if (!xdr_double(_sink, &val))
107 throw Error(
"Network I/O Error. Could not send float 64 data.\nThis may be due to a bug in libdap, on the "
108 "server or a\nproblem with the network connection.");
111void XDRFileMarshaller::put_uint16(dods_uint16 val) {
112 if (!XDR_UINT16(_sink, &val))
113 throw Error(
"Network I/O Error. Could not send uint 16 data.");
116void XDRFileMarshaller::put_uint32(dods_uint32 val) {
117 if (!XDR_UINT32(_sink, &val))
118 throw Error(
"Network I/O Error. Could not send uint 32 data.");
121void XDRFileMarshaller::put_str(
const string &val) {
122 const char *out_tmp = val.c_str();
124 if (!xdr_string(_sink, (
char **)&out_tmp, max_str_len))
125 throw Error(
"Network I/O Error. Could not send string data.");
128void XDRFileMarshaller::put_url(
const string &val) { put_str(val); }
130void XDRFileMarshaller::put_opaque(
char *val,
unsigned int len) {
131 if (!xdr_opaque(_sink, val, len))
132 throw Error(
"Network I/O Error. Could not send opaque data.");
135void XDRFileMarshaller::put_int(
int val) {
136 if (!xdr_int(_sink, &val))
137 throw Error(
"Network I/O Error(1).");
140void XDRFileMarshaller::put_vector(
char *val,
int num, Vector &) {
142 throw InternalErr(__FILE__, __LINE__,
"Buffer pointer is not set.");
146 if (!xdr_bytes(_sink, (
char **)&val, (
unsigned int *)&num, DODS_MAX_ARRAY)) {
147 throw Error(
"Network I/O Error(2).");
151void XDRFileMarshaller::put_vector(
char *val,
int num,
int width, Vector &vec) {
153 throw InternalErr(__FILE__, __LINE__,
"Buffer pointer is not set.");
157 BaseType *var = vec.var();
158 if (!xdr_array(_sink, (
char **)&val, (
unsigned int *)&num, DODS_MAX_ARRAY, width,
159 XDRUtils::xdr_coder(var->type()))) {
160 throw Error(
"Network I/O Error(2).");
165 strm << DapIndent::LMarg <<
"XDRFileMarshaller::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