Utils::FixedSizeByteArray< Size > Class Template Reference

#include <FixedSizeByteArray.h> [code]

Inheritance diagram for Utils::FixedSizeByteArray< Size >:

Inheritance graph
[legend]
List of all members.

Detailed Description

template<uint Size>
class Utils::FixedSizeByteArray< Size >

Fixed size (length) byte array template class.

This class is used to store fixed size raw byte data and it guarantees that stored data will always be exactly Size bytes long. You can use it, for example, for identifiers or hashes storage, where their size is fixed and known.

It provides value semantics (objects copying allowed).

It does not throw its own exceptions and lets any thrown exceptions through to the user. In case an exception (e.g. bad_alloc) gets thrown, the FixedSizeByteArray object will be left in an unchanged state. Thus the class meets the strong guarantee of exception safety.

Definition at line 45 of file FixedSizeByteArray.h.

Public Member Functions

 FixedSizeByteArray ()
 Default constructor.
 FixedSizeByteArray (const QByteArray &byteArray)
 Constructor.
 ~FixedSizeByteArray ()
 Destructor.
bool operator== (const FixedSizeByteArray &other) const
 Equality comparison.
bool operator!= (const FixedSizeByteArray &other) const
 Inequality comparison.
bool operator< (const FixedSizeByteArray &other) const
 Less than comparison.
bool operator<= (const FixedSizeByteArray &other) const
 Less than or equal to comparison.
bool operator> (const FixedSizeByteArray &other) const
 Greater than comparison.
bool operator>= (const FixedSizeByteArray &other) const
 Greater than or equal to comparison.
char operator[] (uint index) const
 Subscript operator.
QByteArray toQByteArray () const

Static Public Member Functions

static uint size ()

Private Attributes

QByteArray array
 Stored byte array.


Constructor & Destructor Documentation

template<uint Size>
Utils::FixedSizeByteArray< Size >::FixedSizeByteArray  )  [inline]
 

Default constructor.

Creates and initializes a Null FixedSizeByteArray instance of Size bytes length filled with zero bytes.

Definition at line 53 of file FixedSizeByteArray.h.

template<uint Size>
Utils::FixedSizeByteArray< Size >::FixedSizeByteArray const QByteArray &  byteArray  )  [inline, explicit]
 

Constructor.

Parameters:
byteArray Byte array with which this array will be initialized.
Precondition:
byteArray must have exactly Size bytes.
Creates and initializes an instance of FixedSizeByteArray with byteArray array.

Definition at line 67 of file FixedSizeByteArray.h.

template<uint Size>
Utils::FixedSizeByteArray< Size >::~FixedSizeByteArray  )  [inline]
 

Destructor.

Destroys a FixedSizeByteArray object.

Definition at line 80 of file FixedSizeByteArray.h.


Member Function Documentation

template<uint Size>
bool Utils::FixedSizeByteArray< Size >::operator!= const FixedSizeByteArray< Size > &  other  )  const [inline]
 

Inequality comparison.

Returns:
true if this FixedSizeByteArray object is not equal to the other object.

false otherwise.

Definition at line 101 of file FixedSizeByteArray.h.

template<uint Size>
bool Utils::FixedSizeByteArray< Size >::operator< const FixedSizeByteArray< Size > &  other  )  const [inline]
 

Less than comparison.

Returns:
true if this FixedSizeByteArray object is lexically smaller than the other object.

false otherwise.

Definition at line 112 of file FixedSizeByteArray.h.

template<uint Size>
bool Utils::FixedSizeByteArray< Size >::operator<= const FixedSizeByteArray< Size > &  other  )  const [inline]
 

Less than or equal to comparison.

Returns:
true if this FixedSizeByteArray object is lexically smaller than or equal to the other object.

false otherwise.

Definition at line 123 of file FixedSizeByteArray.h.

template<uint Size>
bool Utils::FixedSizeByteArray< Size >::operator== const FixedSizeByteArray< Size > &  other  )  const [inline]
 

Equality comparison.

Returns:
true if this FixedSizeByteArray object is equal to the other object.

false otherwise.

Definition at line 90 of file FixedSizeByteArray.h.

template<uint Size>
bool Utils::FixedSizeByteArray< Size >::operator> const FixedSizeByteArray< Size > &  other  )  const [inline]
 

Greater than comparison.

Returns:
true if this FixedSizeByteArray object is lexically greater than the other object.

false otherwise.

Definition at line 134 of file FixedSizeByteArray.h.

template<uint Size>
bool Utils::FixedSizeByteArray< Size >::operator>= const FixedSizeByteArray< Size > &  other  )  const [inline]
 

Greater than or equal to comparison.

Returns:
true if this FixedSizeByteArray object is lexically greater than or equal to the other object.

false otherwise.

Definition at line 145 of file FixedSizeByteArray.h.

template<uint Size>
char Utils::FixedSizeByteArray< Size >::operator[] uint  index  )  const [inline]
 

Subscript operator.

Parameters:
index Index of the byte to be returned.
Returns:
The byte at index position.
Precondition:
index must be less than Size.

Definition at line 157 of file FixedSizeByteArray.h.

template<uint Size>
static uint Utils::FixedSizeByteArray< Size >::size  )  [inline, static]
 

Note:
This function can be called both using an object and the class name:
			FixedSizeByteArray <20> fixedArray;
			cout << fixedArray.size();					// prints 20
			cout << FixedSizeByteArray <20>::size();	// prints 20
		

Definition at line 179 of file FixedSizeByteArray.h.

template<uint Size>
QByteArray Utils::FixedSizeByteArray< Size >::toQByteArray  )  const [inline]
 

Returns:
The byte array converted to QByteArray.

Definition at line 164 of file FixedSizeByteArray.h.


Member Data Documentation

template<uint Size>
QByteArray Utils::FixedSizeByteArray< Size >::array [private]
 

Stored byte array.

Definition at line 185 of file FixedSizeByteArray.h.


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