#ifndef _SHAKE_XDR__H_ #define _SHAKE_XDR__H_ #ifdef _WINDOWS #include #endif #ifndef _WINDOWS #include #endif /*! \class Cxdr \brief eXternal Data Representation Required to send/receive data b/w different architectures Assumes that signed & unsigned have same byte order (based on ntoh fnc.) */ class Cxdr { private: // private is private inline void store(u_long &l) ; inline void store(u_short &l) ; inline void store(const char *s, int n) ; inline void restore(u_long &l) ; inline void restore(u_short &l) ; inline void restore(char *s, int n) ; inline void reserve(int n) ; inline void checksize(int n) ; static int PAGESIZE ; bool m_is_reverse; protected: char *m_buffer ; //!< the buffer that contains data in a "network representation" int m_len ; //!< the size of the buffer int m_truelen ; //!< the size allocated of the buffer int m_cur ; //!< current position in the buffer bool m_growable ; //!< true if growable public: Cxdr(int size=0) ; //!< initialize (buffer grows if required) Cxdr(char *buf,int size) ; //!< initialize (buffer grows if required) Cxdr(char *buf) ; //!< initialize (buffer grows if required) ~Cxdr() ; void reset(int size=0) ; inline Cxdr & operator << (double s) ; //!< store double inline Cxdr & operator << (signed long s) ; //!< store signed long inline Cxdr & operator << (unsigned long s) ; //!< store unsigned long inline Cxdr & operator << (signed short s) ; //!< store signed short inline Cxdr & operator << (unsigned short s) ; //!< store unsigned short inline Cxdr & operator << (const char *s) ; //!< store string inline Cxdr & operator >> (double &s) ; //!< get double inline Cxdr & operator >> (signed long &s) ; //!< get signed long inline Cxdr & operator >> (unsigned long &s) ; //!< get unsigned long inline Cxdr & operator >> (signed short &s) ; //!< get signed short inline Cxdr & operator >> (unsigned short &s) ; //!< get unsigned short inline Cxdr & operator >> (char *s) ; //!< get string inline char * data() ; //!< return the encoded buffer inline unsigned long len() ; //!< return size of the buffer } ; #include "shake_xdr.hpp" #endif