Eneboo - Documentación para desarrolladores
Clases | Tipos públicos | Métodos públicos | Métodos protegidos | Amigas
Referencia de la Clase QGArray

The QGArray class is an internal class for implementing the QMemArray class. Más...

#include <qgarray.h>

Diagrama de herencias de QGArray
QMemArray< type > QMemArray< type > QMemArray< QPoint > QMemArray< QPoint > QPointArray QPointArray QPointArray QPointArray

Lista de todos los miembros.

Clases

struct  array_data

Tipos públicos

enum  Optimization { MemOptim, SpeedOptim, MemOptim, SpeedOptim }
enum  Optimization { MemOptim, SpeedOptim, MemOptim, SpeedOptim }

Métodos públicos

 QGArray ()
 QGArray ()

Métodos protegidos

 QGArray (int, int)
 QGArray (int size)
 QGArray (const QGArray &a)
virtual ~QGArray ()
QGArrayoperator= (const QGArray &a)
virtual void detach ()
char * data () const
uint nrefs () const
uint size () const
bool isEqual (const QGArray &a) const
bool resize (uint newsize, Optimization optim)
bool resize (uint newsize)
bool fill (const char *d, int len, uint sz)
QGArrayassign (const QGArray &a)
QGArrayassign (const char *d, uint len)
QGArrayduplicate (const QGArray &a)
QGArrayduplicate (const char *d, uint len)
void store (const char *d, uint len)
array_datasharedBlock () const
void setSharedBlock (array_data *p)
QGArraysetRawData (const char *d, uint len)
void resetRawData (const char *d, uint len)
int find (const char *d, uint index, uint sz) const
int contains (const char *d, uint sz) const
void sort (uint sz)
int bsearch (const char *d, uint sz) const
char * at (uint index) const
bool setExpand (uint index, const char *d, uint sz)
virtual array_datanewData ()
virtual void deleteData (array_data *p)
 QGArray (int, int)
 QGArray (int size)
 QGArray (const QGArray &a)
virtual ~QGArray ()
QGArrayoperator= (const QGArray &a)
virtual void detach ()
char * data () const
uint nrefs () const
uint size () const
bool isEqual (const QGArray &a) const
bool resize (uint newsize, Optimization optim)
bool resize (uint newsize)
bool fill (const char *d, int len, uint sz)
QGArrayassign (const QGArray &a)
QGArrayassign (const char *d, uint len)
QGArrayduplicate (const QGArray &a)
QGArrayduplicate (const char *d, uint len)
void store (const char *d, uint len)
array_datasharedBlock () const
void setSharedBlock (array_data *p)
QGArraysetRawData (const char *d, uint len)
void resetRawData (const char *d, uint len)
int find (const char *d, uint index, uint sz) const
int contains (const char *d, uint sz) const
void sort (uint sz)
int bsearch (const char *d, uint sz) const
char * at (uint index) const
bool setExpand (uint index, const char *d, uint sz)
virtual array_datanewData ()
virtual void deleteData (array_data *p)

Amigas

class QBuffer

Descripción detallada

The QGArray class is an internal class for implementing the QMemArray class.


Documentación de las enumeraciones miembro de la clase

Valores de enumeraciones:
MemOptim 
SpeedOptim 
MemOptim 
SpeedOptim 
Valores de enumeraciones:
MemOptim 
SpeedOptim 
MemOptim 
SpeedOptim 

Documentación del constructor y destructor

QGArray::QGArray ( )

Constructs a null array.

QGArray::QGArray ( int  ,
int   
) [protected]

Dummy constructor; does not allocate any data.

This constructor does not initialize any array data so subclasses must do it. The intention is to make the code more efficient.

QGArray::QGArray ( int  size) [protected]

Constructs an array with room for size bytes.

QGArray::QGArray ( const QGArray a) [protected]

Constructs a shallow copy of a.

QGArray::~QGArray ( ) [protected, virtual]

Dereferences the array data and deletes it if this was the last reference.

QGArray::QGArray ( )
QGArray::QGArray ( int  ,
int   
) [protected]
QGArray::QGArray ( int  size) [protected]
QGArray::QGArray ( const QGArray a) [protected]
virtual QGArray::~QGArray ( ) [protected, virtual]

Documentación de las funciones miembro

QGArray & QGArray::assign ( const QGArray a) [protected]

Esta es una función miembro sobrecargada que se suministra por conveniencia. Difiere de la anterior función solamente en los argumentos que acepta. Shallow copy. Dereference the current array and references the data contained in a instead. Returns a reference to this array.

Ver también:
operator=()
QGArray & QGArray::assign ( const char *  d,
uint  len 
) [protected]

Shallow copy. Dereference the current array and references the array data d, which contains len bytes. Returns a reference to this array.

Do not delete d later, because QGArray takes care of that.

Reimplementado en QMemArray< char >, QMemArray< char >, QMemArray< bool > y QMemArray< bool >.

QGArray& QGArray::assign ( const QGArray a) [protected]
QGArray& QGArray::assign ( const char *  d,
uint  len 
) [protected]
char * QGArray::at ( uint  index) const [inline, protected]
char* QGArray::at ( uint  index) const [protected]
int QGArray::bsearch ( const char *  d,
uint  sz 
) const [protected]

Binary search; assumes that d is a sorted array of size sz.

int QGArray::bsearch ( const char *  d,
uint  sz 
) const [protected]
int QGArray::contains ( const char *  d,
uint  sz 
) const [protected]

Returns the number of occurrences of d in the array, where sz is the size of the d element.

This function only compares whole cells, not bytes.

int QGArray::contains ( const char *  d,
uint  sz 
) const [protected]
char * QGArray::data ( ) const [inline, protected]
char* QGArray::data ( ) const [inline, protected]
virtual void QGArray::deleteData ( array_data p) [protected, virtual]
void QGArray::deleteData ( array_data p) [protected, virtual]

Deletes the shared array block p.

void QGArray::detach ( ) [inline, protected, virtual]
virtual void QGArray::detach ( ) [inline, protected, virtual]
QGArray & QGArray::duplicate ( const char *  d,
uint  len 
) [protected]

Esta es una función miembro sobrecargada que se suministra por conveniencia. Difiere de la anterior función solamente en los argumentos que acepta. Deep copy. Dereferences the current array and obtains a copy of len characters from array data d instead. Returns a reference to this array.

Ver también:
assign(), operator=()

Reimplementado en QMemArray< char >, QMemArray< char >, QMemArray< bool > y QMemArray< bool >.

QGArray& QGArray::duplicate ( const QGArray a) [protected]
QGArray& QGArray::duplicate ( const char *  d,
uint  len 
) [protected]
QGArray & QGArray::duplicate ( const QGArray a) [protected]

Deep copy. Dereference the current array and obtains a copy of the data contained in a instead. Returns a reference to this array.

Ver también:
assign(), operator=()
bool QGArray::fill ( const char *  d,
int  len,
uint  sz 
) [protected]
bool QGArray::fill ( const char *  d,
int  len,
uint  sz 
) [protected]

Fills the array with the repeated occurrences of d, which is sz bytes long. If len is specified as different from -1, then the array will be resized to len*sz before it is filled.

Returns TRUE if successful, or FALSE if the memory cannot be allocated (only when len != -1).

Ver también:
resize()
int QGArray::find ( const char *  d,
uint  index,
uint  sz 
) const [protected]

Finds the first occurrence of d in the array from position index, where sz is the size of the d element.

Note that index is given in units of sz, not bytes.

This function only compares whole cells, not bytes.

int QGArray::find ( const char *  d,
uint  index,
uint  sz 
) const [protected]
bool QGArray::isEqual ( const QGArray a) const [protected]
bool QGArray::isEqual ( const QGArray a) const [protected]

Returns TRUE if this array is equal to a, otherwise FALSE. The comparison is bitwise, of course.

virtual array_data* QGArray::newData ( ) [protected, virtual]
QGArray::array_data * QGArray::newData ( ) [protected, virtual]

Returns a new shared array block.

uint QGArray::nrefs ( ) const [inline, protected]
uint QGArray::nrefs ( ) const [inline, protected]
QGArray & QGArray::operator= ( const QGArray a) [inline, protected]

Assigns a shallow copy of a to this array and returns a reference to this array. Equivalent to assign().

QGArray& QGArray::operator= ( const QGArray a) [inline, protected]
void QGArray::resetRawData ( const char *  d,
uint  len 
) [protected]

Resets raw data.

The arguments must be the data, d, and length len, that were passed to setRawData(). This is for consistency checking.

Reimplementado en QMemArray< char >, QMemArray< char >, QMemArray< bool > y QMemArray< bool >.

void QGArray::resetRawData ( const char *  d,
uint  len 
) [protected]
bool QGArray::resize ( uint  newsize) [protected]
bool QGArray::resize ( uint  newsize) [protected]
bool QGArray::resize ( uint  newsize,
Optimization  optim 
) [protected]
bool QGArray::resize ( uint  newsize,
Optimization  optim 
) [protected]
bool QGArray::setExpand ( uint  index,
const char *  d,
uint  sz 
) [protected]

Expand the array if necessary, and copies (the first part of) its contents from the index * sz bytes at d.

Returns TRUE if the operation succeeds, FALSE if it runs out of memory.

Atención:
This function disregards the reference count mechanism. If other QGArrays reference the same data as this, all will be changed.
bool QGArray::setExpand ( uint  index,
const char *  d,
uint  sz 
) [protected]
QGArray& QGArray::setRawData ( const char *  d,
uint  len 
) [protected]
QGArray & QGArray::setRawData ( const char *  d,
uint  len 
) [protected]

Sets raw data and returns a reference to the array.

Dereferences the current array and sets the new array data to d and the new array size to len. Do not attempt to resize or re-assign the array data when raw data has been set. Call resetRawData(d,len) to reset the array.

Setting raw data is useful because it sets QMemArray data without allocating memory or copying data.

Example of intended use:

    static uchar bindata[] = { 231, 1, 44, ... };
    QByteArray  a;
    a.setRawData( bindata, sizeof(bindata) );   // a points to bindata
    QDataStream s( a, IO_ReadOnly );            // open on a's data
    s >> <something>;                           // read raw bindata
    s.close();
    a.resetRawData( bindata, sizeof(bindata) ); // finished

Example of misuse (do not do this):

    static uchar bindata[] = { 231, 1, 44, ... };
    QByteArray  a, b;
    a.setRawData( bindata, sizeof(bindata) );   // a points to bindata
    a.resize( 8 );                              // will crash
    b = a;                                      // will crash
    a[2] = 123;                                 // might crash
      // forget to resetRawData - will crash
Atención:
If you do not call resetRawData(), QGArray will attempt to deallocate or reallocate the raw data, which might not be too good. Be careful.

Reimplementado en QMemArray< char >, QMemArray< char >, QMemArray< bool > y QMemArray< bool >.

void QGArray::setSharedBlock ( array_data p) [inline, protected]

Sets the shared array block to p.

Atención:

Do not use this function. Using it is begging for trouble. We dare not remove it, for fear of breaking code, but we strongly discourage new use of it.

void QGArray::setSharedBlock ( array_data p) [inline, protected]
array_data* QGArray::sharedBlock ( ) const [inline, protected]
array_data * QGArray::sharedBlock ( ) const [inline, protected]

Returns a pointer to the shared array block.

Atención:

Do not use this function. Using it is begging for trouble. We dare not remove it, for fear of breaking code, but we strongly discourage new use of it.

uint QGArray::size ( ) const [inline, protected]
uint QGArray::size ( ) const [inline, protected]
void QGArray::sort ( uint  sz) [protected]

Sorts the first sz items of the array.

void QGArray::sort ( uint  sz) [protected]
void QGArray::store ( const char *  d,
uint  len 
) [protected]

Resizes this array to len bytes and copies the len bytes at address d into it.

Atención:
This function disregards the reference count mechanism. If other QGArrays reference the same data as this, all will be updated.
void QGArray::store ( const char *  d,
uint  len 
) [protected]

Documentación de las funciones relacionadas y clases amigas

QBuffer [friend]

La documentación para esta clase fue generada a partir de los siguientes ficheros:
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'