NDataStream Class Reference

NDataStream class provides serialization of raw, binary, data. More...

List of all members.

Public Types

enum  ByteOrder { BIGENDIAN, LITTLEENDIAN }

Public Member Functions

 NDataStream (void)
 Constructs a NDataStream object with no Data.
 NDataStream (const NDataStream &stream)
 Copy constructor for NDataStream.
 NDataStream (const char *str)
 Copy constructor for NDataStream.
 ~NDataStream (void)
 Destroys the NDataStream object, freeing any resource allocated.
void setByteOrder (ByteOrder bo)
 Sets the bytes in which data will be serialized.
ByteOrder getByteOrder (void) const
 Get the current configured byte order.
NDataStreamset (const void *src, nuint32 bytes)
 Sets the stream data.
NDataStreamset (const char *str)
 Sets the stream data.
NDataStreamset (const NString &str)
 Sets the stream data.
NDataStreamset (const nint16 val)
 Sets the stream data.
NDataStreamset (const nuint16 val)
 Sets the stream data.
NDataStreamset (const nint32 val)
 Sets the stream data.
NDataStreamset (const nuint32 val)
 Sets the stream data.
NDataStreamset (const nint64 val)
 Sets the stream data.
NDataStreamset (const nuint64 val)
 Sets the stream data.
NDataStreamappend (const char *str)
 Appends data to the stream.
NDataStreamappend (const NString &str)
 Sets the stream data.
NDataStreamappend (const void *src, nuint32 bytes)
 Appends data to the stream.
NDataStreamappend (const nint16 val)
 Appends data to the stream.
NDataStreamappend (const nuint16 val)
 Appends data to the stream.
NDataStreamappend (const nint32 val)
 Appends data to the stream.
NDataStreamappend (const nuint32 val)
 Appends data to the stream.
NDataStreamappend (const nint64 val)
 Appends data to the stream.
NDataStreamappend (const nuint64 val)
 Appends data to the stream.
NString toString (void) const
 Converts the stream data to a NString object.
NString toString (nuint32 size) const
 Converts the stream data to a NString object.
NString toString (nuint32 start, nuint32 bytes) const
 Converts the stream data to a NString object.
unsigned char toChar (void) const
 Converts the first byte of the stream data to char.
unsigned char toChar (nuint32 pos) const
 Converts a byte of the stream data to char.
nint16 toInt16 (void) const
 Converts the stream to a 16 bit signed integer.
nint32 toInt32 (void) const
 Converts the stream to a 32 bit signed integer.
nint64 toInt64 (void) const
 Converts the stream to a 64 bit signed integer.
bool isNull (void) const
 Returns true if the stream is null.
nuint32 size (void) const
 Returns the size of the stream.
const void * data (void) const
 Returns a pointer to the data associated with the stream.
bool operator== (const NDataStream &rhs) const
 Equality test.
bool operator!= (const NDataStream &rhs) const
 Equality test.
NDataStreamoperator= (const char *str)
 Sets the stream data.
NDataStreamoperator= (const NString &str)
 Sets the stream data.
NDataStreamoperator= (const NDataStream &str)
 Sets the stream data.
NDataStreamoperator= (const nint16 val)
 Sets the stream data.
NDataStreamoperator= (const nuint16 val)
 Sets the stream data.
NDataStreamoperator= (const nint32 val)
 Sets the stream data.
NDataStreamoperator= (const nuint32 val)
 Sets the stream data.
NDataStreamoperator= (const nint64 val)
 Sets the stream data.
NDataStreamoperator= (const nuint64 val)
 Sets the stream data.
NDataStreamoperator+= (const char *str)
 Appends data to the stream.
NDataStreamoperator+= (const NString &str)
 Sets the stream data.
NDataStreamoperator+= (const NDataStream &str)
 Appends data to the stream.
NDataStreamoperator+= (const nint16 val)
 Appends data to the stream.
NDataStreamoperator+= (const nuint16 val)
 Appends data to the stream.
NDataStreamoperator+= (const nint32 val)
 Appends data to the stream.
NDataStreamoperator+= (const nuint32 val)
 Appends data to the stream.
NDataStreamoperator+= (const nint64 val)
 Appends data to the stream.
NDataStreamoperator+= (const nuint64 val)
 Appends data to the stream.
NDataStream operator+ (const char *str)
 Appends data to the stream.
NDataStream operator+ (const NString &str)
 Sets the stream data.
NDataStream operator+ (const NDataStream &str)
 Appends data to the stream.
NDataStream operator+ (const nint16 val)
 Appends data to the stream.
NDataStream operator+ (const nuint16 val)
 Appends data to the stream.
NDataStream operator+ (const nint32 val)
 Appends data to the stream.
NDataStream operator+ (const nuint32 val)
 Appends data to the stream.
NDataStream operator+ (const nint64 val)
 Appends data to the stream.
NDataStream operator+ (const nuint64 val)
 Appends data to the stream.
unsigned char operator[] (nuint32 pos)
 Converts a byte of the stream data to char.


Detailed Description

NDataStream class provides serialization of raw, binary, data.
Examples:

clientapp.cpp, and ex_ndatastream.cpp.

Definition at line 38 of file ndatastream.h.


Member Enumeration Documentation

enum ByteOrder

Byte ordering for manipulating data

Enumerator:
BIGENDIAN  Big endian byte ordering
LITTLEENDIAN  Little endian byte ordering

Definition at line 43 of file ndatastream.h.


Constructor & Destructor Documentation

NDataStream ( const char *  str  ) 

Copy constructor for NDataStream.

Parameters:
str A pointer to a null terminated string

Definition at line 49 of file ndatastream.cpp.


Member Function Documentation

void setByteOrder ( NDataStream::ByteOrder  bo  ) 

Sets the bytes in which data will be serialized.

Note:
By default it uses BIGENDIAN
Examples:
ex_ndatastream.cpp.

Definition at line 126 of file ndatastream.cpp.

NDataStream::ByteOrder getByteOrder ( void   )  const

Get the current configured byte order.

Returns:
The current configured byte order

Definition at line 130 of file ndatastream.cpp.

NDataStream & set ( const void *  src,
nuint32  bytes 
)

Sets the stream data.

Parameters:
src A pointer to a source of data
bytes Size, in bytes, to be written
Returns:
A reference to the stream

Definition at line 156 of file ndatastream.cpp.

Referenced by NVtype::NVtype(), and NFile::read().

NDataStream & set ( const char *  str  ) 

Sets the stream data.

Parameters:
str A pointer to a null terminated string
Returns:
A reference to the stream

Definition at line 135 of file ndatastream.cpp.

NDataStream & set ( const NString str  ) 

Sets the stream data.

Parameters:
str A NString object
Returns:
A reference to the stream

Definition at line 151 of file ndatastream.cpp.

References NString::toChar().

NDataStream & set ( const nint16  val  ) 

Sets the stream data.

Parameters:
val A 16 bit integer
Returns:
A reference to the stream

Definition at line 198 of file ndatastream.cpp.

NDataStream & set ( const nuint16  val  ) 

Sets the stream data.

Parameters:
val A 16 bit unsigned integer
Returns:
A reference to the stream

Definition at line 203 of file ndatastream.cpp.

NDataStream & set ( const nint32  val  ) 

Sets the stream data.

Parameters:
val A 32 bit integer
Returns:
A reference to the stream

Definition at line 209 of file ndatastream.cpp.

NDataStream & set ( const nuint32  val  ) 

Sets the stream data.

Parameters:
val A 32 bit unsigned integer
Returns:
A reference to the stream

Definition at line 214 of file ndatastream.cpp.

NDataStream & set ( const nint64  val  ) 

Sets the stream data.

Parameters:
val A 64 bit integer
Returns:
A reference to the stream

Definition at line 219 of file ndatastream.cpp.

NDataStream & set ( const nuint64  val  ) 

Sets the stream data.

Parameters:
val A 64 bit unsigned integer
Returns:
A reference to the stream

Definition at line 232 of file ndatastream.cpp.

NDataStream & append ( const char *  str  ) 

Appends data to the stream.

Parameters:
str A pointer to a null terminated string
Returns:
A reference to the stream

Definition at line 259 of file ndatastream.cpp.

Referenced by append(), operator+(), operator+=(), NTcpSocket::read(), NFile::read(), NTcpSocket::readLine(), and NFile::readLine().

NDataStream & append ( const NString str  ) 

Sets the stream data.

Parameters:
str A NString object
Returns:
A reference to the stream

Definition at line 266 of file ndatastream.cpp.

References append(), and NString::toChar().

NDataStream & append ( const void *  src,
nuint32  bytes 
)

Appends data to the stream.

Parameters:
src A pointer to a source of data
bytes Size, in bytes, to be written
Returns:
A reference to the stream

Definition at line 245 of file ndatastream.cpp.

NDataStream & append ( const nint16  val  ) 

Appends data to the stream.

Parameters:
val A 16 bit integer
Returns:
A reference to the stream

Definition at line 300 of file ndatastream.cpp.

NDataStream & append ( const nuint16  val  ) 

Appends data to the stream.

Parameters:
val A 16 bit unsigned integer
Returns:
A reference to the stream

Definition at line 305 of file ndatastream.cpp.

NDataStream & append ( const nint32  val  ) 

Appends data to the stream.

Parameters:
val A 32 bit integer
Returns:
A reference to the stream

Definition at line 310 of file ndatastream.cpp.

NDataStream & append ( const nuint32  val  ) 

Appends data to the stream.

Parameters:
val A 32 bit unsigned integer
Returns:
A reference to the stream

Definition at line 315 of file ndatastream.cpp.

NDataStream & append ( const nint64  val  ) 

Appends data to the stream.

Parameters:
val A 64 bit integer
Returns:
A reference to the stream

Definition at line 320 of file ndatastream.cpp.

NDataStream & append ( const nuint64  val  ) 

Appends data to the stream.

Parameters:
val A 64 bit unsigned integer
Returns:
A reference to the stream

Definition at line 333 of file ndatastream.cpp.

NString toString ( void   )  const

Converts the stream data to a NString object.

Returns:
A NString object
Examples:
clientapp.cpp, and ex_ndatastream.cpp.

Definition at line 389 of file ndatastream.cpp.

Referenced by NDataStream(), operator+(), operator+=(), operator=(), NVtype::toString(), and toString().

NString toString ( nuint32  size  )  const

Converts the stream data to a NString object.

Parameters:
size Size, in bytes, to be converted
Returns:
A NString object

Definition at line 385 of file ndatastream.cpp.

References toString().

NString toString ( nuint32  start,
nuint32  bytes 
) const

Converts the stream data to a NString object.

Parameters:
start Position, to start the convertion
bytes Size, in bytes, to be converted
Returns:
A NString object

Definition at line 362 of file ndatastream.cpp.

References NException::BASE, NException::EX_OUT_OF_BOUNDS, and NString::set().

unsigned char toChar ( void   )  const

Converts the first byte of the stream data to char.

Returns:
The first byte as a char

Definition at line 394 of file ndatastream.cpp.

Referenced by NVtype::toChar().

unsigned char toChar ( nuint32  pos  )  const

Converts a byte of the stream data to char.

Parameters:
pos Position of the byte to be converted
Returns:
A byte as a char

Definition at line 398 of file ndatastream.cpp.

nint16 toInt16 ( void   )  const

Converts the stream to a 16 bit signed integer.

Returns:
A 16 bit signed integer.
Examples:
ex_ndatastream.cpp.

Definition at line 435 of file ndatastream.cpp.

nint32 toInt32 ( void   )  const

Converts the stream to a 32 bit signed integer.

Returns:
A 32 bit signed integer.

Definition at line 442 of file ndatastream.cpp.

Referenced by NVtype::toInt32(), and NVtype::toUInt32().

nint64 toInt64 ( void   )  const

Converts the stream to a 64 bit signed integer.

Returns:
A 64 bit signed integer.

Definition at line 448 of file ndatastream.cpp.

Referenced by NVtype::toInt64(), and NVtype::toUInt64().

bool isNull ( void   )  const

Returns true if the stream is null.

Returns:
True if the string is null. False otherwise

Definition at line 452 of file ndatastream.cpp.

nuint32 size ( void   )  const

Returns the size of the stream.

Returns:
The size of the stream
Examples:
ex_ndatastream.cpp.

Definition at line 460 of file ndatastream.cpp.

Referenced by NShaHash::calculateFile(), NSha1Hash::calculateFile(), NMd5Hash::calculateFile(), NMd4Hash::calculateFile(), NMd2Hash::calculateFile(), NVtype::getSize(), operator!=(), operator==(), NTcpSocket::write(), NFile::write(), and NTcpSocket::writeLine().

const void * data ( void   )  const

Returns a pointer to the data associated with the stream.

Returns:
Returns the data associated with the stream

Definition at line 465 of file ndatastream.cpp.

Referenced by NShaHash::calculate(), NSha1Hash::calculate(), NMd5Hash::calculate(), NMd4Hash::calculate(), NMd2Hash::calculate(), NShaHash::calculateFile(), NSha1Hash::calculateFile(), NMd5Hash::calculateFile(), NMd4Hash::calculateFile(), NMd2Hash::calculateFile(), NTcpSocket::write(), NFile::write(), and NTcpSocket::writeLine().

bool operator== ( const NDataStream rhs  )  const

Equality test.

Parameters:
rhs A NDataStream object to compare to
Returns:
true if equals or false ortherwise

Definition at line 470 of file ndatastream.cpp.

References m_data, and size().

bool operator!= ( const NDataStream rhs  )  const

Equality test.

Parameters:
rhs A NDataStream object to compare to
Returns:
false if equals or true ortherwise

Definition at line 482 of file ndatastream.cpp.

References m_data, and size().

NDataStream & operator= ( const char *  str  ) 

Sets the stream data.

Parameters:
str A pointer to a null terminated string
Returns:
A reference to the stream

Definition at line 494 of file ndatastream.cpp.

NDataStream & operator= ( const NString str  ) 

Sets the stream data.

Parameters:
str A NString object
Returns:
A reference to the stream

Definition at line 498 of file ndatastream.cpp.

NDataStream & operator= ( const NDataStream str  ) 

Sets the stream data.

Parameters:
str A NDataStream object
Returns:
A reference to the stream

Definition at line 502 of file ndatastream.cpp.

References toString().

NDataStream & operator= ( const nint16  val  ) 

Sets the stream data.

Parameters:
val A 16 bit integer
Returns:
A reference to the stream

Definition at line 506 of file ndatastream.cpp.

NDataStream & operator= ( const nuint16  val  ) 

Sets the stream data.

Parameters:
val A 16 bit unsigned integer
Returns:
A reference to the stream

Definition at line 510 of file ndatastream.cpp.

NDataStream & operator= ( const nint32  val  ) 

Sets the stream data.

Parameters:
val A 32 bit integer
Returns:
A reference to the stream

Definition at line 514 of file ndatastream.cpp.

NDataStream & operator= ( const nuint32  val  ) 

Sets the stream data.

Parameters:
val A 32 bit unsigned integer
Returns:
A reference to the stream

Definition at line 518 of file ndatastream.cpp.

NDataStream & operator= ( const nint64  val  ) 

Sets the stream data.

Parameters:
val A 64 bit integer
Returns:
A reference to the stream

Definition at line 522 of file ndatastream.cpp.

NDataStream & operator= ( const nuint64  val  ) 

Sets the stream data.

Parameters:
val A 64 bit unsigned integer
Returns:
A reference to the stream

Definition at line 526 of file ndatastream.cpp.

NDataStream & operator+= ( const char *  str  ) 

Appends data to the stream.

Parameters:
str A pointer to a null terminated string
Returns:
A reference to the stream

Definition at line 530 of file ndatastream.cpp.

References append().

NDataStream & operator+= ( const NString str  ) 

Sets the stream data.

Parameters:
str A NString object
Returns:
A reference to the stream

Definition at line 534 of file ndatastream.cpp.

References append().

NDataStream & operator+= ( const NDataStream str  ) 

Appends data to the stream.

Parameters:
str A NDataStream object
Returns:
A reference to the stream

Definition at line 538 of file ndatastream.cpp.

References append(), and toString().

NDataStream & operator+= ( const nint16  val  ) 

Appends data to the stream.

Parameters:
val A 16 bit integer
Returns:
A reference to the stream

Definition at line 542 of file ndatastream.cpp.

References append().

NDataStream & operator+= ( const nuint16  val  ) 

Appends data to the stream.

Parameters:
val A 16 bit unsigned integer
Returns:
A reference to the stream

Definition at line 546 of file ndatastream.cpp.

References append().

NDataStream & operator+= ( const nint32  val  ) 

Appends data to the stream.

Parameters:
val A 32 bit integer
Returns:
A reference to the stream

Definition at line 550 of file ndatastream.cpp.

References append().

NDataStream & operator+= ( const nuint32  val  ) 

Appends data to the stream.

Parameters:
val A 32 bit unsigned integer
Returns:
A reference to the stream

Definition at line 554 of file ndatastream.cpp.

References append().

NDataStream & operator+= ( const nint64  val  ) 

Appends data to the stream.

Parameters:
val A 64 bit integer
Returns:
A reference to the stream

Definition at line 558 of file ndatastream.cpp.

References append().

NDataStream & operator+= ( const nuint64  val  ) 

Appends data to the stream.

Parameters:
val A 64 bit unsigned integer
Returns:
A reference to the stream

Definition at line 562 of file ndatastream.cpp.

References append().

NDataStream operator+ ( const char *  str  ) 

Appends data to the stream.

Parameters:
str A pointer to a null terminated string
Returns:
A reference to the stream

Definition at line 566 of file ndatastream.cpp.

References append().

NDataStream operator+ ( const NString str  ) 

Sets the stream data.

Parameters:
str A NString object
Returns:
A reference to the stream

Definition at line 570 of file ndatastream.cpp.

References append().

NDataStream operator+ ( const NDataStream str  ) 

Appends data to the stream.

Parameters:
str A NDataStream object
Returns:
A reference to the stream

Definition at line 574 of file ndatastream.cpp.

References append(), and toString().

NDataStream operator+ ( const nint16  val  ) 

Appends data to the stream.

Parameters:
val A 16 bit integer
Returns:
A reference to the stream

Definition at line 578 of file ndatastream.cpp.

References append().

NDataStream operator+ ( const nuint16  val  ) 

Appends data to the stream.

Parameters:
val A 16 bit unsigned integer
Returns:
A reference to the stream

Definition at line 582 of file ndatastream.cpp.

References append().

NDataStream operator+ ( const nint32  val  ) 

Appends data to the stream.

Parameters:
val A 32 bit integer
Returns:
A reference to the stream

Definition at line 586 of file ndatastream.cpp.

References append().

NDataStream operator+ ( const nuint32  val  ) 

Appends data to the stream.

Parameters:
val A 32 bit unsigned integer
Returns:
A reference to the stream

Definition at line 590 of file ndatastream.cpp.

References append().

NDataStream operator+ ( const nint64  val  ) 

Appends data to the stream.

Parameters:
val A 64 bit integer
Returns:
A reference to the stream

Definition at line 594 of file ndatastream.cpp.

References append().

NDataStream operator+ ( const nuint64  val  ) 

Appends data to the stream.

Parameters:
val A 64 bit unsigned integer
Returns:
A reference to the stream

Definition at line 598 of file ndatastream.cpp.

References append().

unsigned char operator[] ( nuint32  pos  ) 

Converts a byte of the stream data to char.

Parameters:
pos Position of the byte to be converted
Returns:
A byte as a char or 0 if not found or out of bounds

Definition at line 602 of file ndatastream.cpp.


The documentation for this class was generated from the following files:
Generated on Wed Mar 5 23:10:36 2008 for NemesisUtilitiesSystem by  doxygen 1.5.4