ArtsPrimitive


[ libArts | Source | Keywords | Summary | Ancestors | All Members | Descendants ]

Quick Index

DESCRIPTION

Class Summary

class ArtsPrimitive

{

public:
int FdWrite(int fd, const void *ptr, int numBytes) const;
int FdRead(int fd, void *ptr, int numBytes) const;
ostream & WriteUint16(ostream & os, const uint16_t & value, uint8_t len) const;
int WriteUint16(int fd, const uint16_t & value, uint8_t len) const;
istream & ReadUint16(istream & is, uint16_t & value, uint8_t len) const;
int ReadUint16(int fd, uint16_t & value, uint8_t len) const;
ostream & WriteUint32(ostream & os, const uint32_t & value, uint8_t len) const;
int WriteUint32(int fd, const uint32_t & value, uint8_t len) const;
istream & ReadUint32(istream & is, uint32_t & value, uint8_t len) const;
int ReadUint32(int fd, uint32_t & value, uint8_t len) const;
ostream & WriteUint64(ostream & os, const uint64_t & value, uint8_t len) const;
int WriteUint64(int fd, const uint64_t & value, uint8_t len) const;
istream & ReadUint64(istream & is, uint64_t & value, uint8_t len) const;
int ReadUint64(int fd, uint64_t & value, uint8_t len) const;
istream & ReadIpv4Network(istream & is, ipv4addr_t & value, uint8_t len) const;
int ReadIpv4Network(int fd, ipv4addr_t & value, uint8_t len) const;
ostream & WriteIpv4Network(ostream & os, const ipv4addr_t & value, uint8_t len) const;
int WriteIpv4Network(int fd, const ipv4addr_t & value, uint8_t len) const;
istream & ReadFloat(istream & is, float & value) const;
int ReadFloat(int fd, float & value) const;
ostream & WriteFloat(ostream & os, float value) const;
int WriteFloat(int fd, float value) const;
istream & ReadDouble(istream & is, double & value) const;
int ReadDouble(int fd, double & value) const;
ostream & WriteDouble(ostream & os, double value) const;
int WriteDouble(int fd, double value) const;
protected:
}; // ArtsPrimitive

Back to the top of ArtsPrimitive


DESCRIPTION


---------------------------------------------------------------------------
class ArtsPrimitive
---------------------------------------------------------------------------
This class provides read/write routines for multi-byte integer data, floats and doubles. It also provides generic robust read/write routines for sockets (FdWrite() and FdRead()). All of the routines except FdWrite() and FdRead() assume that contents of an iostream or file descriptor are always in network byte order. Hence the Write / member functions for integer types convert to network byte order from host byte order before outputting to an ostream or file descriptor and the Read* member functions for integer types convert from network byte order to host byte order after reading from an istream or file descriptor.

The routines for floats and doubles use XDR under the hood. Hence the on-the-wire (or disk) format for these types is always 4 bytes for floats, 8 bytes for doubles (in IEEE format, see RFC 1832 and/or ANSI/IEEE Standard 754-1985). For the multi-byte integer types, the routines will handle run length encoded (RLE) values, but the caller is responsible for passing in the correct length (and reading/writing the length itself).
---------------------------------------------------------------------------

Back to the top of ArtsPrimitive


int FdWrite(int fd, const void *ptr, int numBytes) const;


-------------------------------------------------------------------------
int FdWrite(int fd, const void *ptr, int numBytes) const
.........................................................................
Writes numBytes of the data pointed to by ptr to the file descriptor fd. This is really just a wrapper around the UNIX write() system call, but we try to write all of numBytes until an error occurs (instead of just returning a short byte count). This is mostly useful when dealing with sockets (where fd is a socket file descriptor), but is used internally as well (to unify socket and file handling).
-------------------------------------------------------------------------

  int FdWrite(int fd, const void *ptr, int numBytes) const;

Back to the top of ArtsPrimitive


int FdRead(int fd, void *ptr, int numBytes) const;


-------------------------------------------------------------------------
int FdRead(int fd, void *ptr, int numBytes) const
.........................................................................
Reads numBytes from fd into ptr. This is really just a wrapper around the UNIX read() system call, but we try to read all of numBytes until an error occurs (instead of just returning a short byte count). This is mostly useful when dealing with sockets (where fd is a socket file descriptor), but is used internally as well (to unify socket and file handling).
-------------------------------------------------------------------------

  int FdRead(int fd, void *ptr, int numBytes) const;

Back to the top of ArtsPrimitive


ostream & WriteUint16(ostream & os, const uint16_t & value, uint8_t len) const;


------------------------------------------------------------------------
WriteUint16(ostream & os, const uint16_t & value, uint8_t len) const
........................................................................
Writes len (1 or 2) bytes of an uint16_t value to an ostream in network byte order. The caller's passed-in value is assumed to be in host byte order. The len field is useful for cases where an uint16_t value can be stored in a single byte and both reader and writer know this ahead of time. Legal len values are 1 and 2. Returns the ostream.
------------------------------------------------------------------------

  ostream & WriteUint16(ostream & os, const uint16_t & value,
                        uint8_t len) const;

Back to the top of ArtsPrimitive


int WriteUint16(int fd, const uint16_t & value, uint8_t len) const;


-------------------------------------------------------------------------
int WriteUint16(int fd, const uint16_t & value, uint8_t len) const
.........................................................................
Writes len (1 or 2) bytes of an uint16_t value to a file descriptor in network byte order. The caller's passed-in value is assumed to be in host byte order. The len field is useful for cases where an uint16_t value can be stored in a single byte and both reader and writer know this ahead of time. Legal len values are 1 and 2. Returns the number of bytes written on success, -1 on failure.
-------------------------------------------------------------------------

  int WriteUint16(int fd, const uint16_t & value, uint8_t len) const;

Back to the top of ArtsPrimitive


istream & ReadUint16(istream & is, uint16_t & value, uint8_t len) const;


------------------------------------------------------------------------
ReadUint16(istream & is, uint16_t & value, uint8_t len) const
........................................................................
Reads len (1 or 2) bytes from an ostream and converts the contents from network byte order to host byte order, storing the result in value. Returns the istream.
------------------------------------------------------------------------

  istream & ReadUint16(istream & is, uint16_t & value, uint8_t len) const;

Back to the top of ArtsPrimitive


int ReadUint16(int fd, uint16_t & value, uint8_t len) const;


-------------------------------------------------------------------------
int ReadUint16(int fd, uint16_t & value, uint8_t len) const
.........................................................................
Reads len (1 or 2) bytes from a file descriptor and converts the contents from network byte order to host byte order, storing the result in value. Returns the number of bytes read on success, -1 on failure.
-------------------------------------------------------------------------

  int ReadUint16(int fd, uint16_t & value, uint8_t len) const;

Back to the top of ArtsPrimitive


ostream & WriteUint32(ostream & os, const uint32_t & value, uint8_t len) const;


------------------------------------------------------------------------
WriteUint32(ostream & os, const uint32_t & value, uint8_t len) const
........................................................................
Writes len (1, 2 or 4) bytes of an uint32_t to an ostream in network byte order. The caller's passed-in value is assumed to be in host byte order. The len field is useful for cases where an uint32_t value can be stored in less than 4 bytes and both reader and writer know this ahead of time. Returns the ostream.
------------------------------------------------------------------------

  ostream & WriteUint32(ostream & os, const uint32_t & value,
                        uint8_t len) const;

Back to the top of ArtsPrimitive


int WriteUint32(int fd, const uint32_t & value, uint8_t len) const;


-------------------------------------------------------------------------
int WriteUint32(int fd, const uint32_t & value, uint8_t len) const
.........................................................................
Writes len (1, 2 or 4) bytes of an uint32_t to a file descriptor in network byte order. The caller's passed-in value is assumed to be in host byte order. The len field is useful for cases where an uint32_t value can be stored in less than 4 bytes and both reader and writer know this ahead of time. Returns the number of bytes written on success, -1 on failure.
-------------------------------------------------------------------------

  int WriteUint32(int fd, const uint32_t & value, uint8_t len) const;

Back to the top of ArtsPrimitive


istream & ReadUint32(istream & is, uint32_t & value, uint8_t len) const;


------------------------------------------------------------------------
ReadUint32(istream & is, uint32_t & value, uint8_t len) const
........................................................................
Reads len (1, 2 or 4) bytes from an ostream and converts the contents from network byte order to host byte order, storing the result in value. Returns the istream.
------------------------------------------------------------------------

  istream & ReadUint32(istream & is, uint32_t & value, uint8_t len) const;

Back to the top of ArtsPrimitive


int ReadUint32(int fd, uint32_t & value, uint8_t len) const;


-------------------------------------------------------------------------
int ReadUint32(int fd, uint32_t & value, uint8_t len) const
.........................................................................
Reads len (1, 2 or 4) bytes from a file descriptor and converts the contents from network byte order to host byte order, storing the result in value. Returns the number of bytes read on success, -1 on failure.
-------------------------------------------------------------------------

  int ReadUint32(int fd, uint32_t & value, uint8_t len) const;

Back to the top of ArtsPrimitive


ostream & WriteUint64(ostream & os, const uint64_t & value, uint8_t len) const;


------------------------------------------------------------------------
WriteUint64(ostream & os, const uint64_t & value, uint8_t len) const
........................................................................
Writes len (1, 2, 4 or 8) bytes of an uint32_t to an ostream in network byte order. The caller's passed-in value is assumed to be in host byte order. The len field is useful for cases where an uint64_t value can be stored in less than 8 bytes and both reader and writer know this ahead of time. Returns the ostream.
------------------------------------------------------------------------

  ostream & WriteUint64(ostream & os, const uint64_t & value,
                        uint8_t len) const;

Back to the top of ArtsPrimitive


int WriteUint64(int fd, const uint64_t & value, uint8_t len) const;


-------------------------------------------------------------------------
int WriteUint64(int fd, const uint64_t & value, uint8_t len) const
.........................................................................
Writes len (1, 2, 4 or 8) bytes of an uint32_t to a file descriptor in network byte order. The caller's passed-in value is assumed to be in host byte order. The len field is useful for cases where an uint64_t value can be stored in less than 8 bytes and both reader and writer know this ahead of time. Returns the number of bytes written on success, -1 on failure.
-------------------------------------------------------------------------

  int WriteUint64(int fd, const uint64_t & value, uint8_t len) const;

Back to the top of ArtsPrimitive


istream & ReadUint64(istream & is, uint64_t & value, uint8_t len) const;


------------------------------------------------------------------------
ReadUint64(istream & is, uint64_t & value, uint8_t len) const
........................................................................
Reads len (1, 2, 4 or 8) bytes from an ostream and converts the contents from network byte order to host byte order, storing the result in value. Returns the istream.
------------------------------------------------------------------------

  istream & ReadUint64(istream & is, uint64_t & value, uint8_t len) const;

Back to the top of ArtsPrimitive


int ReadUint64(int fd, uint64_t & value, uint8_t len) const;


-------------------------------------------------------------------------
int ReadUint64(int fd, uint64_t & value, uint8_t len) const
.........................................................................
Reads len (1, 2, 4 or 8) bytes from a file descriptor and converts the contents from network byte order to host byte order, storing the result in value. Returns the number of bytes read on success, -1 on failure.
-------------------------------------------------------------------------

  int ReadUint64(int fd, uint64_t & value, uint8_t len) const;

Back to the top of ArtsPrimitive


istream & ReadIpv4Network(istream & is, ipv4addr_t & value, uint8_t len) const;


-------------------------------------------------------------------------
istream & ReadIpv4Network(istream & is, ipv4addr_t & value, uint8_t len) const
.........................................................................
Reads len (1, 2, 3 or 4) bytes from an istream and stores the results in value. This function permits reading network addresses in shortened form; a class B network, for example, can be stored in only 2 bytes on disk.
-------------------------------------------------------------------------

  istream & ReadIpv4Network(istream & is, ipv4addr_t & value,
                            uint8_t len) const;

Back to the top of ArtsPrimitive


int ReadIpv4Network(int fd, ipv4addr_t & value, uint8_t len) const;


-------------------------------------------------------------------------
int ReadIpv4Network(int fd, ipv4addr_t & value, uint8_t len) const
.........................................................................
Reads len (1, 2, 3 or 4) bytes from a file descriptor and stores the results in value. This function permits reading network addresses in shortened form; a class B network, for example, can be stored in only 2 bytes on disk.
-------------------------------------------------------------------------

  int ReadIpv4Network(int fd, ipv4addr_t & value, uint8_t len) const;

Back to the top of ArtsPrimitive


ostream & WriteIpv4Network(ostream & os, const ipv4addr_t & value, uint8_t len) const;


-------------------------------------------------------------------------
ostream & WriteIpv4Network(ostream & os, const ipv4addr_t & value, uint8_t len) const
.........................................................................
Writes len bytes of value to an ostream. When using this function, the idea is that you're storing a byte-counted IP address, which means you can store a network address with the minimum required space (a class B network in 2 bytes, for example). Returns the number of bytes written. Always writes in network byte order.
-------------------------------------------------------------------------

  ostream & WriteIpv4Network(ostream & os, const ipv4addr_t & value,
                             uint8_t len) const;

Back to the top of ArtsPrimitive


int WriteIpv4Network(int fd, const ipv4addr_t & value, uint8_t len) const;


-------------------------------------------------------------------------
int WriteIpv4Network(int fd, const ipv4addr_t & value, uint8_t len) const
.........................................................................
Writes len bytes of value to a file descriptor. When using this function, the idea is that you're storing a byte-counted IP address, which means you can store a network address with the minimum required space (a class B network in 2 bytes, for example). Returns the number of bytes written. Always writes in network byte order.
-------------------------------------------------------------------------

  int WriteIpv4Network(int fd, const ipv4addr_t & value, uint8_t len) const;

Back to the top of ArtsPrimitive


istream & ReadFloat(istream & is, float & value) const;


-------------------------------------------------------------------------
istream & ReadFloat(istream & is, float & value) const
.........................................................................
UNTESTED Reads a float from an istream, using XDR. Returns the istream.
-------------------------------------------------------------------------

  istream & ReadFloat(istream & is, float & value) const;

Back to the top of ArtsPrimitive


int ReadFloat(int fd, float & value) const;


-------------------------------------------------------------------------
int ReadFloat(int fd, float & value) const
.........................................................................
UNTESTED Reads a float from a file descriptor, using XDR. Returns the number of bytes read on success (should be 4), -1 on error.
-------------------------------------------------------------------------

  int ReadFloat(int fd, float & value) const;

Back to the top of ArtsPrimitive


ostream & WriteFloat(ostream & os, float value) const;


-------------------------------------------------------------------------
ostream & WriteFloat(ostream & os, float value) const
.........................................................................
UNTESTED Writes a float to an ostream, using XDR. Returns the ostream.
-------------------------------------------------------------------------

  ostream & WriteFloat(ostream & os, float value) const;

Back to the top of ArtsPrimitive


int WriteFloat(int fd, float value) const;


-------------------------------------------------------------------------
int WriteFloat(int fd, float value) const
.........................................................................
UNTESTED Writes a float to a file descriptor, using XDR. Returns the number of bytes written on success (should be 4), -1 on error.
-------------------------------------------------------------------------

  int WriteFloat(int fd, float value) const;

Back to the top of ArtsPrimitive


istream & ReadDouble(istream & is, double & value) const;


-------------------------------------------------------------------------
istream & ReadDouble(istream & is, double & value) const
.........................................................................
UNTESTED Reads a souble from an istream, using XDR. Returns the istream.
-------------------------------------------------------------------------

  istream & ReadDouble(istream & is, double & value) const;

Back to the top of ArtsPrimitive


int ReadDouble(int fd, double & value) const;


-------------------------------------------------------------------------
int ReadDouble(int fd, double & value) const;
.........................................................................
UNTESTED Reads a double from a file descriptor, using XDR. Returns the number of bytes read on success (should be 8), -1 on failure.
-------------------------------------------------------------------------

  int ReadDouble(int fd, double & value) const;

Back to the top of ArtsPrimitive


ostream & WriteDouble(ostream & os, double value) const;


-------------------------------------------------------------------------
ostream & WriteDouble(ostream & os, double value) const
.........................................................................
UNTESTED Writes a double to an ostream, using XDR. Returns the ostream.
-------------------------------------------------------------------------

  ostream & WriteDouble(ostream & os, double value) const;

Back to the top of ArtsPrimitive


int WriteDouble(int fd, double value) const;


-------------------------------------------------------------------------
int WriteDouble(int fd, double value) const
.........................................................................
UNTESTED Writes a double to a file descriptor, using XDR. Returns the number of bytes written on success (should be 8), -1 on error.
-------------------------------------------------------------------------

  int WriteDouble(int fd, double value) const;

Back to the top of ArtsPrimitive


All Members

public:
int FdWrite(int fd, const void *ptr, int numBytes) const;
int FdRead(int fd, void *ptr, int numBytes) const;
ostream & WriteUint16(ostream & os, const uint16_t & value, uint8_t len) const;
int WriteUint16(int fd, const uint16_t & value, uint8_t len) const;
istream & ReadUint16(istream & is, uint16_t & value, uint8_t len) const;
int ReadUint16(int fd, uint16_t & value, uint8_t len) const;
ostream & WriteUint32(ostream & os, const uint32_t & value, uint8_t len) const;
int WriteUint32(int fd, const uint32_t & value, uint8_t len) const;
istream & ReadUint32(istream & is, uint32_t & value, uint8_t len) const;
int ReadUint32(int fd, uint32_t & value, uint8_t len) const;
ostream & WriteUint64(ostream & os, const uint64_t & value, uint8_t len) const;
int WriteUint64(int fd, const uint64_t & value, uint8_t len) const;
istream & ReadUint64(istream & is, uint64_t & value, uint8_t len) const;
int ReadUint64(int fd, uint64_t & value, uint8_t len) const;
istream & ReadIpv4Network(istream & is, ipv4addr_t & value, uint8_t len) const;
int ReadIpv4Network(int fd, ipv4addr_t & value, uint8_t len) const;
ostream & WriteIpv4Network(ostream & os, const ipv4addr_t & value, uint8_t len) const;
int WriteIpv4Network(int fd, const ipv4addr_t & value, uint8_t len) const;
istream & ReadFloat(istream & is, float & value) const;
int ReadFloat(int fd, float & value) const;
ostream & WriteFloat(ostream & os, float value) const;
int WriteFloat(int fd, float value) const;
istream & ReadDouble(istream & is, double & value) const;
int ReadDouble(int fd, double & value) const;
ostream & WriteDouble(ostream & os, double value) const;
int WriteDouble(int fd, double value) const;
protected:

Back to the top of ArtsPrimitive


Ancestors

Class does not inherit from any other class.

Back to the top of ArtsPrimitive


Descendants

Class is not inherited by any others.

Back to the top of ArtsPrimitive


Generated from source by the Cocoon utilities on Sat Oct 17 14:40:02 1998 .

Report problems to jkotula@unimax.com