libcryptosec
Public Member Functions | Static Public Member Functions | Friends | List of all members

Classe usada para transportar dados binários pelo sistema. Pode ser usada para conversão de texto em array de bytes e vice-versa. Usar esta classe ao invés do QByteArray por causa do uso de "unsigned char", e pela possibilidade de fazer "cópias profundas" dos dados. More...

#include <ByteArray.h>

Public Member Functions

 ByteArray ()
 
 ByteArray (unsigned int length)
 
 ByteArray (const unsigned char *data, unsigned int length)
 
 ByteArray (std::ostringstream *buffer)
 
 ByteArray (std::string data)
 
 ByteArray (char *data)
 
 ByteArray (int length)
 
 ByteArray (const ByteArray &value)
 
virtual ~ByteArray ()
 
char at (int pos) const throw (out_of_range)
 
ByteArrayoperator= (const ByteArray &value)
 
unsigned char & operator[] (int pos) throw (out_of_range)
 
void copyFrom (unsigned char *data, unsigned int length)
 
void copyFrom (int offset, int length, ByteArray &data, int offset2)
 
std::istringstream * toStream ()
 
void setDataPointer (unsigned char *data, unsigned int length)
 
unsigned char * getDataPointer ()
 
unsigned int size () const
 
virtual std::string toString ()
 
virtual std::string toHex ()
 
virtual std::string toHex (char separator)
 

Static Public Member Functions

static ByteArray xOr (vector< ByteArray > &array)
 

Friends

bool operator== (const ByteArray &left, const ByteArray &right)
 
bool operator!= (const ByteArray &left, const ByteArray &right)
 
ByteArrayoperator xor (const ByteArray &left, const ByteArray &right)
 

Detailed Description

Classe usada para transportar dados binários pelo sistema. Pode ser usada para conversão de texto em array de bytes e vice-versa. Usar esta classe ao invés do QByteArray por causa do uso de "unsigned char", e pela possibilidade de fazer "cópias profundas" dos dados.

Constructor & Destructor Documentation

◆ ByteArray() [1/8]

ByteArray::ByteArray ( )

Default constructor.

◆ ByteArray() [2/8]

ByteArray::ByteArray ( unsigned int  length)

ByteArray com tamanho definido.

Parameters
lengthTamanho do novo ByteArray.

◆ ByteArray() [3/8]

ByteArray::ByteArray ( const unsigned char *  data,
unsigned int  length 
)

ByteArray a partir do buffer desejado, copiando os dados.

Parameters
dataBuffer de origem dos bytes.
lengthTamanho do buffer.

◆ ByteArray() [4/8]

ByteArray::ByteArray ( std::ostringstream *  buffer)

ByteArray a partir de ostringstream copiando os dados.

Parameters
bufferostream com os dados para colocar no ByteArray

◆ ByteArray() [5/8]

ByteArray::ByteArray ( std::string  data)

ByteArray a partir de dados legíveis.

Parameters
datadados que serão colocados no objeto

◆ ByteArray() [6/8]

ByteArray::ByteArray ( char *  data)

◆ ByteArray() [7/8]

ByteArray::ByteArray ( int  length)

ByteArray com tamanho definido.

Parameters
lengthTamanho do novo ByteArray.

◆ ByteArray() [8/8]

ByteArray::ByteArray ( const ByteArray value)

ByteArray a partir de outro ByteArray (que será copiado).

Parameters
valueByteArray de origem.

◆ ~ByteArray()

ByteArray::~ByteArray ( )
virtual

Deafult destructor.

Member Function Documentation

◆ at()

char ByteArray::at ( int  pos) const
throw (out_of_range
)

Ler o byte da posição desejada.

Parameters
posPosição desejada.

◆ copyFrom() [1/2]

void ByteArray::copyFrom ( unsigned char *  data,
unsigned int  length 
)

Copy bytes from desired memory location.

Parameters
dataDesired memory location.
lengthAmount to copy.

◆ copyFrom() [2/2]

void ByteArray::copyFrom ( int  offset,
int  length,
ByteArray data,
int  offset2 
)

Copy bytes from desired ByteArray, considering an offset.

Parameters
offsetOffset to consider for copying.
lengthAmount to copy.
dataDesired ByteArray.
offset2Offset to consider for copy begin in data.

◆ getDataPointer()

unsigned char * ByteArray::getDataPointer ( )

Returns the memory location of byte array content.

◆ operator=()

ByteArray & ByteArray::operator= ( const ByteArray value)

Fazer uma cópia profunda ao invés de copiar a referência

Parameters
valueByteArray a ser copiado.

◆ operator[]()

unsigned char & ByteArray::operator[] ( int  pos)
throw (out_of_range
)

Ler o byte da posição desejada.

Parameters
posPosição desejada.

◆ setDataPointer()

void ByteArray::setDataPointer ( unsigned char *  data,
unsigned int  length 
)

Set the content of ByteArray to be an already allocated memory space.

Parameters
dataDesired memory location.
lengthLength of allocated memory.

◆ size()

unsigned int ByteArray::size ( ) const

Returns the memory location of byte array content. Returns the byte array content encoded as base 64 characters. Returns the size of current byte array.

◆ toHex() [1/2]

std::string ByteArray::toHex ( )
virtual

Converts the content of this bytearray to hexadecimal value.

◆ toHex() [2/2]

std::string ByteArray::toHex ( char  separator)
virtual

Converts the content of this bytearray to hexadecimal value separated using the char informed as argument.

◆ toStream()

std::istringstream * ByteArray::toStream ( )

Returns an istringstream representing current byte array.

◆ toString()

std::string ByteArray::toString ( )
virtual

Consider that current byte array is a char array, and retuirns it as a QString.

◆ xOr()

ByteArray ByteArray::xOr ( vector< ByteArray > &  array)
static

Computes multiple xor of vector elements.

Friends And Related Function Documentation

◆ operator xor

ByteArray& operator xor ( const ByteArray left,
const ByteArray right 
)
friend

Fazer ou-exclusivo entre dois ByteArray's.

Parameters
leftPrimeiro ByteArray da operação.
rightSegundo ByteArray da operação.

◆ operator!=

bool operator!= ( const ByteArray left,
const ByteArray right 
)
friend

Permitir diferença booleana de ByteArray's

Parameters
leftPrimeiro ByteArray da comparação.
rightSegundo ByteArray da comparação.

◆ operator==

bool operator== ( const ByteArray left,
const ByteArray right 
)
friend

Permitir comparação booleana de ByteArray's

Parameters
leftPrimeiro ByteArray da comparação.
rightSegundo ByteArray da comparação.

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