activemq-cpp-3.6.0
decaf::io::DataOutput Class Reference

The DataOutput interface provides for converting data from any of the C++ primitive types to a series of bytes and writing these bytes to a binary stream. More...

#include <src/main/decaf/io/DataOutput.h>

Public Member Functions

virtual ~DataOutput ()
virtual void writeBoolean (bool value)=0
 Writes a boolean to the underlying output stream as a 1-byte value.
virtual void writeByte (unsigned char value)=0
 Writes out a byte to the underlying output stream as a 1-byte value.
virtual void writeShort (short value)=0
 Writes a short to the underlying output stream as two bytes, high byte first.
virtual void writeUnsignedShort (unsigned short value)=0
 Writes a unsigned short to the bytes message stream as a 2 byte value.
virtual void writeChar (char value)=0
 Writes out a char to the underlying output stream as a one byte value If no exception is thrown, the counter written is incremented by 1.
virtual void writeInt (int value)=0
 Writes an int to the underlying output stream as four bytes, high byte first.
virtual void writeLong (long long value)=0
 Writes an 64 bit long to the underlying output stream as eight bytes, high byte first.
virtual void writeFloat (float value)=0
 Converts the float argument to an int using the floatToIntBits method in class Float, and then writes that int value to the underlying output stream as a 4-byte quantity, high byte first.
virtual void writeDouble (double value)=0
 Converts the double argument to a long using the doubleToLongBits method in class Double, and then writes that long value to the underlying output stream as an 8-byte quantity, high byte first.
virtual void writeBytes (const std::string &value)=0
 Writes out the string to the underlying output stream as a sequence of bytes.
virtual void writeChars (const std::string &value)=0
 Writes a string to the underlying output stream as a sequence of characters.
virtual void writeUTF (const std::string &value)=0
 Writes out the string to the underlying output stream as a modeified UTF-8 encoded sequence of bytes.

Detailed Description

The DataOutput interface provides for converting data from any of the C++ primitive types to a series of bytes and writing these bytes to a binary stream.

There is also a facility for converting Strings into the Java standard modified UTF-8 format and writing the resulting series of bytes.

If a method in this interface encounters an error while writing it will throw an IOException.

See Also
DataInput
DataOutputStream
Since
1.0

Constructor & Destructor Documentation

virtual decaf::io::DataOutput::~DataOutput ( )
virtual

Member Function Documentation

virtual void decaf::io::DataOutput::writeBoolean ( bool  value)
pure virtual

Writes a boolean to the underlying output stream as a 1-byte value.

The value true is written out as the value (byte)1; the value false is written out as the value (byte)0. If no exception is thrown, the counter written is incremented by 1.

Parameters
valueThe boolean to write as a byte (1=true, 0=false).
Exceptions
IOExceptionif an I/O error is encountered.
virtual void decaf::io::DataOutput::writeByte ( unsigned char  value)
pure virtual

Writes out a byte to the underlying output stream as a 1-byte value.

If no exception is thrown, the counter written is incremented by 1.

Parameters
valueThe unsigned char value to write.
Exceptions
IOExceptionif an I/O error is encountered.
virtual void decaf::io::DataOutput::writeBytes ( const std::string &  value)
pure virtual

Writes out the string to the underlying output stream as a sequence of bytes.

Each character in the string is written out, in sequence, by discarding its high eight bits. If no exception is thrown, the counter written is incremented by the length of value. The value written does not include a trailing null as that is not part of the sequence of bytes, if the null is needed, then use the writeChars method.

Parameters
valueThe vector of bytes to write.
Exceptions
IOExceptionif an I/O error is encountered.
virtual void decaf::io::DataOutput::writeChar ( char  value)
pure virtual

Writes out a char to the underlying output stream as a one byte value If no exception is thrown, the counter written is incremented by 1.

Parameters
valueThe signed char value to write.
Exceptions
IOExceptionif an I/O error is encountered.
virtual void decaf::io::DataOutput::writeChars ( const std::string &  value)
pure virtual

Writes a string to the underlying output stream as a sequence of characters.

Each character is written to the data output stream as if by the writeChar method. If no exception is thrown, the counter written is incremented by the length of value. The trailing NULL character is written by this method.

Parameters
valueThe string value to write as raw bytes.
Exceptions
IOExceptionif an I/O error is encountered.
virtual void decaf::io::DataOutput::writeDouble ( double  value)
pure virtual

Converts the double argument to a long using the doubleToLongBits method in class Double, and then writes that long value to the underlying output stream as an 8-byte quantity, high byte first.

If no exception is thrown, the counter written is incremented by 8.

Parameters
valueThe 64bit double value to write.
Exceptions
IOExceptionif an I/O error is encountered.
virtual void decaf::io::DataOutput::writeFloat ( float  value)
pure virtual

Converts the float argument to an int using the floatToIntBits method in class Float, and then writes that int value to the underlying output stream as a 4-byte quantity, high byte first.

If no exception is thrown, the counter written is incremented by 4.

Parameters
valueThe 32bit floating point value to write.
Exceptions
IOExceptionif an I/O error is encountered.
virtual void decaf::io::DataOutput::writeInt ( int  value)
pure virtual

Writes an int to the underlying output stream as four bytes, high byte first.

If no exception is thrown, the counter written is incremented by 4.

Parameters
valueThe signed integer value to write.
Exceptions
IOExceptionif an I/O error is encountered.
virtual void decaf::io::DataOutput::writeLong ( long long  value)
pure virtual

Writes an 64 bit long to the underlying output stream as eight bytes, high byte first.

If no exception is thrown, the counter written is incremented by 8.

Parameters
valueThe signed 64bit long value to write.
Exceptions
IOExceptionif an I/O error is encountered.
virtual void decaf::io::DataOutput::writeShort ( short  value)
pure virtual

Writes a short to the underlying output stream as two bytes, high byte first.

If no exception is thrown, the counter written is incremented by 2.

Parameters
valueThe signed short value to write.
Exceptions
IOExceptionif an I/O error is encountered.
virtual void decaf::io::DataOutput::writeUnsignedShort ( unsigned short  value)
pure virtual

Writes a unsigned short to the bytes message stream as a 2 byte value.

Parameters
valueThe unsigned short to write to the stream.
Exceptions
IOExceptionif an I/O error is encountered.
virtual void decaf::io::DataOutput::writeUTF ( const std::string &  value)
pure virtual

Writes out the string to the underlying output stream as a modeified UTF-8 encoded sequence of bytes.

The first two bytes written are indicate its encoded length followed by the rest of the string's characters encoded as modified UTF-8. The length represent the encoded length of the data not the actual length of the string.

Parameters
valueThe string value value to write as modified UTF-8.
Exceptions
IOExceptionif an I/O error is encountered.
UTFDataFormatExceptionif the encoded size if greater than 65535

The documentation for this class was generated from the following file: