|
Packit |
1c1d7e |
/****************************************************************************
|
|
Packit |
1c1d7e |
**
|
|
Packit |
1c1d7e |
**
|
|
Packit |
1c1d7e |
** Definition of QGArray class
|
|
Packit |
1c1d7e |
**
|
|
Packit |
1c1d7e |
** Created : 930906
|
|
Packit |
1c1d7e |
**
|
|
Packit |
1c1d7e |
** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
|
|
Packit |
1c1d7e |
**
|
|
Packit |
1c1d7e |
** This file is part of the tools module of the Qt GUI Toolkit.
|
|
Packit |
1c1d7e |
**
|
|
Packit |
1c1d7e |
** This file may be distributed under the terms of the Q Public License
|
|
Packit |
1c1d7e |
** as defined by Trolltech AS of Norway and appearing in the file
|
|
Packit |
1c1d7e |
** LICENSE.QPL included in the packaging of this file.
|
|
Packit |
1c1d7e |
**
|
|
Packit |
1c1d7e |
** This file may be distributed and/or modified under the terms of the
|
|
Packit |
1c1d7e |
** GNU General Public License version 2 as published by the Free Software
|
|
Packit |
1c1d7e |
** Foundation and appearing in the file LICENSE.GPL included in the
|
|
Packit |
1c1d7e |
** packaging of this file.
|
|
Packit |
1c1d7e |
**
|
|
Packit |
1c1d7e |
** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
|
|
Packit |
1c1d7e |
** licenses may use this file in accordance with the Qt Commercial License
|
|
Packit |
1c1d7e |
** Agreement provided with the Software.
|
|
Packit |
1c1d7e |
**
|
|
Packit |
1c1d7e |
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
|
Packit |
1c1d7e |
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
|
Packit |
1c1d7e |
**
|
|
Packit |
1c1d7e |
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
|
|
Packit |
1c1d7e |
** information about Qt Commercial License Agreements.
|
|
Packit |
1c1d7e |
** See http://www.trolltech.com/qpl/ for QPL licensing information.
|
|
Packit |
1c1d7e |
** See http://www.trolltech.com/gpl/ for GPL licensing information.
|
|
Packit |
1c1d7e |
**
|
|
Packit |
1c1d7e |
** Contact info@trolltech.com if any conditions of this licensing are
|
|
Packit |
1c1d7e |
** not clear to you.
|
|
Packit |
1c1d7e |
**
|
|
Packit |
1c1d7e |
**********************************************************************/
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
#ifndef QGARRAY_H
|
|
Packit |
1c1d7e |
#define QGARRAY_H
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
#ifndef QT_H
|
|
Packit |
1c1d7e |
#include "qshared.h"
|
|
Packit |
1c1d7e |
#endif // QT_H
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
class Q_EXPORT QGArray // generic array
|
|
Packit |
1c1d7e |
{
|
|
Packit |
1c1d7e |
friend class QBuffer;
|
|
Packit |
1c1d7e |
public:
|
|
Packit |
1c1d7e |
//### DO NOT USE THIS. IT IS PUBLIC BUT DO NOT USE IT IN NEW CODE.
|
|
Packit |
1c1d7e |
struct array_data : public QShared { // shared array
|
|
Packit |
1c1d7e |
array_data() { data=0; len=0; }
|
|
Packit |
1c1d7e |
char *data; // actual array data
|
|
Packit |
1c1d7e |
uint len;
|
|
Packit |
1c1d7e |
};
|
|
Packit |
1c1d7e |
QGArray();
|
|
Packit |
1c1d7e |
protected:
|
|
Packit |
1c1d7e |
QGArray( int, int ); // dummy; does not alloc
|
|
Packit |
1c1d7e |
QGArray( int size ); // allocate 'size' bytes
|
|
Packit |
1c1d7e |
QGArray( const QGArray &a ); // shallow copy
|
|
Packit |
1c1d7e |
virtual ~QGArray();
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
QGArray &operator=( const QGArray &a ) { return assign( a ); }
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
virtual void detach() { duplicate(*this); }
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
char *data() const { return shd->data; }
|
|
Packit |
1c1d7e |
uint nrefs() const { return shd->count; }
|
|
Packit |
1c1d7e |
uint size() const { return shd->len; }
|
|
Packit |
1c1d7e |
bool isEqual( const QGArray &a ) const;
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
bool resize( uint newsize );
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
bool fill( const char *d, int len, uint sz );
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
QGArray &assign( const QGArray &a );
|
|
Packit |
1c1d7e |
QGArray &assign( const char *d, uint len );
|
|
Packit |
1c1d7e |
QGArray &duplicate( const QGArray &a );
|
|
Packit |
1c1d7e |
QGArray &duplicate( const char *d, uint len );
|
|
Packit |
1c1d7e |
void store( const char *d, uint len );
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
array_data *sharedBlock() const { return shd; }
|
|
Packit |
1c1d7e |
void setSharedBlock( array_data *p ) { shd=(array_data*)p; }
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
QGArray &setRawData( const char *d, uint len );
|
|
Packit |
1c1d7e |
void resetRawData( const char *d, uint len );
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
int find( const char *d, uint index, uint sz ) const;
|
|
Packit |
1c1d7e |
int contains( const char *d, uint sz ) const;
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
void sort( uint sz );
|
|
Packit |
1c1d7e |
int bsearch( const char *d, uint sz ) const;
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
char *at( uint index ) const;
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
bool setExpand( uint index, const char *d, uint sz );
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
protected:
|
|
Packit |
1c1d7e |
virtual array_data *newData();
|
|
Packit |
1c1d7e |
virtual void deleteData( array_data *p );
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
private:
|
|
Packit |
1c1d7e |
static void msg_index( uint );
|
|
Packit |
1c1d7e |
array_data *shd;
|
|
Packit |
1c1d7e |
};
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
inline char *QGArray::at( uint index ) const
|
|
Packit |
1c1d7e |
{
|
|
Packit |
1c1d7e |
#if defined(CHECK_RANGE)
|
|
Packit |
1c1d7e |
if ( index >= size() ) {
|
|
Packit |
1c1d7e |
msg_index( index );
|
|
Packit |
1c1d7e |
index = 0;
|
|
Packit |
1c1d7e |
}
|
|
Packit |
1c1d7e |
#endif
|
|
Packit |
1c1d7e |
return &shd->data[index];
|
|
Packit |
1c1d7e |
}
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
|
|
Packit |
1c1d7e |
#endif // QGARRAY_H
|