X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=include%2Fbyteorder.h;h=94fe9598dd6609de4de8f8279de87ab571d53232;hb=99dd1d6ed10db1f669a5fe6af71225a50fc0ddfb;hp=a3c51e88868665d0308e07eca1a4a32e3125b055;hpb=b5857e74e5735455b5ef11cbea5044ae7b2e8a0d;p=ctsim.git diff --git a/include/byteorder.h b/include/byteorder.h index a3c51e8..94fe959 100644 --- a/include/byteorder.h +++ b/include/byteorder.h @@ -1,18 +1,44 @@ #ifndef NETORDER_H #define NETORDER_H +#include + /* netorder.cpp */ -void *strreverse (void *dest, const void *src, size_t n); -int read_nint16 (kuint16 *n, int fd); -int write_nint16 (kuint16 const *n, int fd); -int read_nint32 (kuint32 *n, int fd); -int write_nint32 (kuint32 const *n, int fd); -int read_nfloat32 (float *f, int fd); -int write_nfloat32 (float const *f, int fd); -int read_nfloat64 (double *d, int fd); -int write_nfloat64 (double const *d, int fd); -void ConvertNetworkOrder (void* buffer, size_t bytes); -void ConvertReverseNetworkOrder (void* buffer, size_t bytes); +bool read_nint16 (kuint16 *n, int fd); +bool write_nint16 (kuint16 const *n, int fd); +bool read_nint32 (kuint32 *n, int fd); +bool write_nint32 (kuint32 const *n, int fd); +bool read_nfloat32 (float *f, int fd); +bool write_nfloat32 (float const *f, int fd); +bool read_nfloat64 (double *d, int fd); +bool write_nfloat64 (double const *d, int fd); +void ConvertNetworkOrder (void* buffer, size_t bytes); +void ConvertReverseNetworkOrder (void* buffer, size_t bytes); + +class inetorderstream : public istream { + public: + inetorderstream& readInt16 (kuint16& n); + inetorderstream& readInt32 (kuint32& n); + inetorderstream& readFloat32 (kfloat32& n); + inetorderstream& readFloat64 (kfloat64& n); +}; + +class onetorderstream : public ostream { + public: + onetorderstream& writeInt16 (kuint16 n); + onetorderstream& writeInt32 (kuint32 n); + onetorderstream& writeFloat32 (kfloat32 n); + onetorderstream& writeFloat64 (kfloat64 n); +}; + +void read_rnint16 (kuint16& n, istream istr); +void write_rnint16 (kuint16 n, ostream ostr); +void read_rnint32 (kuint32& n, istream istr); +void write_rnint32 (kuint32 n, ostream ostr); +void read_rnfloat32 (kfloat32& n, istream istr); +void write_rnfloat32 (kfloat32 n, ostream ostr); +void read_rnfloat64 (kfloat64& n, istream istr); +void write_rnfloat64 (kfloat64 n, ostream ostr); #endif