summaryrefslogtreecommitdiffstats
path: root/qtools/qgarray.h
diff options
context:
space:
mode:
authordimitri <dimitri@afe2bf4a-e733-0410-8a33-86f594647bc7>2000-10-15 15:32:16 (GMT)
committerdimitri <dimitri@afe2bf4a-e733-0410-8a33-86f594647bc7>2000-10-15 15:32:16 (GMT)
commit868208ab61ca3aa6f506076f60de2745eaa8a6be (patch)
tree7824ba2a5c9f1fe6ddc8633a13cc7d1e7a6c79a3 /qtools/qgarray.h
parent499475795ed160e3a1e9cb571adc1ad86dc6a8ba (diff)
downloadDoxygen-868208ab61ca3aa6f506076f60de2745eaa8a6be.zip
Doxygen-868208ab61ca3aa6f506076f60de2745eaa8a6be.tar.gz
Doxygen-868208ab61ca3aa6f506076f60de2745eaa8a6be.tar.bz2
Release-1.2.2-20001015
Diffstat (limited to 'qtools/qgarray.h')
-rw-r--r--qtools/qgarray.h120
1 files changed, 120 insertions, 0 deletions
diff --git a/qtools/qgarray.h b/qtools/qgarray.h
new file mode 100644
index 0000000..12c463b
--- /dev/null
+++ b/qtools/qgarray.h
@@ -0,0 +1,120 @@
+/****************************************************************************
+**
+**
+** Definition of QGArray class
+**
+** Created : 930906
+**
+** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
+**
+** This file is part of the tools module of the Qt GUI Toolkit.
+**
+** This file may be distributed under the terms of the Q Public License
+** as defined by Trolltech AS of Norway and appearing in the file
+** LICENSE.QPL included in the packaging of this file.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
+** licenses may use this file in accordance with the Qt Commercial License
+** Agreement provided with the Software.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
+** information about Qt Commercial License Agreements.
+** See http://www.trolltech.com/qpl/ for QPL licensing information.
+** See http://www.trolltech.com/gpl/ for GPL licensing information.
+**
+** Contact info@trolltech.com if any conditions of this licensing are
+** not clear to you.
+**
+**********************************************************************/
+
+#ifndef QGARRAY_H
+#define QGARRAY_H
+
+#ifndef QT_H
+#include "qshared.h"
+#endif // QT_H
+
+
+class Q_EXPORT QGArray // generic array
+{
+friend class QBuffer;
+public:
+ //### DO NOT USE THIS. IT IS PUBLIC BUT DO NOT USE IT IN NEW CODE.
+ struct array_data : public QShared { // shared array
+ array_data() { data=0; len=0; }
+ char *data; // actual array data
+ uint len;
+ };
+ QGArray();
+protected:
+ QGArray( int, int ); // dummy; does not alloc
+ QGArray( int size ); // allocate 'size' bytes
+ QGArray( const QGArray &a ); // shallow copy
+ virtual ~QGArray();
+
+ QGArray &operator=( const QGArray &a ) { return assign( a ); }
+
+ virtual void detach() { duplicate(*this); }
+
+ char *data() const { return shd->data; }
+ uint nrefs() const { return shd->count; }
+ uint size() const { return shd->len; }
+ bool isEqual( const QGArray &a ) const;
+
+ bool resize( uint newsize );
+
+ bool fill( const char *d, int len, uint sz );
+
+ QGArray &assign( const QGArray &a );
+ QGArray &assign( const char *d, uint len );
+ QGArray &duplicate( const QGArray &a );
+ QGArray &duplicate( const char *d, uint len );
+ void store( const char *d, uint len );
+
+ array_data *sharedBlock() const { return shd; }
+ void setSharedBlock( array_data *p ) { shd=(array_data*)p; }
+
+ QGArray &setRawData( 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 );
+
+protected:
+ virtual array_data *newData();
+ virtual void deleteData( array_data *p );
+
+private:
+ static void msg_index( uint );
+ array_data *shd;
+};
+
+
+inline char *QGArray::at( uint index ) const
+{
+#if defined(CHECK_RANGE)
+ if ( index >= size() ) {
+ msg_index( index );
+ index = 0;
+ }
+#endif
+ return &shd->data[index];
+}
+
+
+#endif // QGARRAY_H