home *** CD-ROM | disk | FTP | other *** search
- #ifndef RJS_NDR_CLASS_H
- #define RJS_NDR_CLASS_H
-
- #include <iostream.h>
- #include <RJS/Transport.h>
-
- class RJS_NDR_send;
- class RJS_NDR_receive;
-
- typedef unsigned short NDR_range;
- typedef char *NDR_data;
-
- class RJS_XNDR {
- public:
- virtual void to_internal(RJS_NDR_receive &)=0;
- virtual void to_external(RJS_NDR_send &)=0;
- };
-
-
- class RJS_NDR {
- public:
- enum NDR_endian {
- NdrBigEndian=0,
- NdrLittleEndian=1
- };
- enum NDR_character {
- NdrASCII=0,
- NdrEBCDIC=1
- };
- enum NDR_floating {
- NdrIEEE=0,
- NdrVAX=1,
- NdrCray=2,
- NdrIBM=3
- };
- virtual void reset()=0;
- virtual void reset(char *, int count)=0;
- virtual char *raw_data()=0;
- virtual NDR_range raw_length()=0;
- static NDR_endian local_endian() { return ndr_endian; }
- static NDR_character local_character() { return ndr_char; }
- static NDR_floating local_floating() { return ndr_float; }
- private:
- static NDR_endian ndr_endian;
- static NDR_character ndr_char;
- static NDR_floating ndr_float;
- };
-
- class RJS_NDR_send : public RJS_NDR {
- // friends!
- friend RJS_Transport &operator<<(RJS_Transport &tr, RJS_NDR_send &ndr);
- friend ostream &operator<<(ostream &, RJS_NDR_send &);
- friend RJS_NDR_send &operator<<(RJS_NDR_send &,RJS_XNDR &);
- friend RJS_NDR_send &operator<<(RJS_NDR_send &,RJS_NDR_send &);
- friend RJS_NDR_send &operator<<(RJS_NDR_send &,char);
- friend RJS_NDR_send &operator<<(RJS_NDR_send &,unsigned char);
- friend RJS_NDR_send &operator<<(RJS_NDR_send &,short);
- friend RJS_NDR_send &operator<<(RJS_NDR_send &,unsigned short);
- friend RJS_NDR_send &operator<<(RJS_NDR_send &,int);
- friend RJS_NDR_send &operator<<(RJS_NDR_send &,unsigned int);
- friend RJS_NDR_send &operator<<(RJS_NDR_send &,float);
- friend RJS_NDR_send &operator<<(RJS_NDR_send &,double);
-
- friend RJS_NDR_send &operator<<(RJS_NDR_send &,const char*);
- public:
- RJS_NDR_send();
- RJS_NDR_send &insert(char *, int count);
- void reset(); // reset for adding
- void init(char *buffer,int size); // reset for adding
- char *raw_data() { return (char *) start_data; }
- NDR_range raw_length() { return (end_data-start_data); }
- private:
- // internal data
- NDR_data start_data; // start of data
- NDR_data end_data; // pointer to end of NDR data
- NDR_data end_alloc; // end of allocated data
- };
-
- class RJS_NDR_receive : public RJS_NDR {
- //
- // friends!
- friend RJS_Transport &operator>>(RJS_Transport &tr, RJS_NDR_receive &ndr);
- friend ostream &operator<<(ostream &, RJS_NDR_receive &);
- friend RJS_NDR_receive &operator>>(RJS_NDR_receive &,RJS_XNDR &);
- friend RJS_NDR_receive &operator>>(RJS_NDR_receive &,RJS_NDR_receive &);
- friend RJS_NDR_receive &operator>>(RJS_NDR_receive &,char &);
- friend RJS_NDR_receive &operator>>(RJS_NDR_receive &,unsigned char &);
- friend RJS_NDR_receive &operator>>(RJS_NDR_receive &,short &);
- friend RJS_NDR_receive &operator>>(RJS_NDR_receive &,unsigned short &);
- friend RJS_NDR_receive &operator>>(RJS_NDR_receive &,int &);
- friend RJS_NDR_receive &operator>>(RJS_NDR_receive &,unsigned int &);
- friend RJS_NDR_receive &operator>>(RJS_NDR_receive &,float &);
- friend RJS_NDR_receive &operator>>(RJS_NDR_receive &,double &);
- friend RJS_NDR_receive &operator>>(RJS_NDR_receive &,char*);
- public:
- RJS_NDR_receive() { start_data=NULL; outptr=NULL; end_data=NULL; }
- RJS_NDR_receive &extract(char *, int &count);
- void reset(); // reset
- void init(char *buffer,int size);
- char *raw_data() { return start_data; }
- NDR_range raw_length() { return (end_data-start_data); }
- NDR_endian remote_endian() { return rem_endian; }
- NDR_character remote_character() { return rem_char; }
- NDR_floating remote_floating() { return rem_float; }
-
- private:
- // internal data
- NDR_endian rem_endian; // remote representation
- NDR_character rem_char;
- NDR_floating rem_float;
- NDR_data start_data; // start of data
- NDR_data outptr; // pointer to current extract
- NDR_data end_data; // end of the NDR
- };
-
- #endif
-