summaryrefslogtreecommitdiffstats
path: root/qtools
diff options
context:
space:
mode:
authorDimitri van Heesch <doxygen@gmail.com>2019-09-21 14:52:17 (GMT)
committerDimitri van Heesch <doxygen@gmail.com>2019-09-21 14:57:24 (GMT)
commit4a9541d1605333e70b5ab9193d65cb300d8ef18e (patch)
tree2281e5242581485a4b3d61a8f0b3079f5dd30758 /qtools
parentc35960af3b0b867cbcd31141e94fe1573ad2bcc0 (diff)
downloadDoxygen-4a9541d1605333e70b5ab9193d65cb300d8ef18e.zip
Doxygen-4a9541d1605333e70b5ab9193d65cb300d8ef18e.tar.gz
Doxygen-4a9541d1605333e70b5ab9193d65cb300d8ef18e.tar.bz2
Reduce the use of QString in favor of the more efficient QCString
Diffstat (limited to 'qtools')
-rw-r--r--qtools/qcache.h47
-rw-r--r--qtools/qcstring.cpp241
-rw-r--r--qtools/qcstring.h15
-rw-r--r--qtools/qdatetime.cpp28
-rw-r--r--qtools/qdatetime.h12
-rw-r--r--qtools/qdict.h81
-rw-r--r--qtools/qgcache.cpp34
-rw-r--r--qtools/qgcache.h10
-rw-r--r--qtools/qgdict.cpp93
-rw-r--r--qtools/qgdict.h26
10 files changed, 305 insertions, 282 deletions
diff --git a/qtools/qcache.h b/qtools/qcache.h
index e1f13d6..39d4f7a 100644
--- a/qtools/qcache.h
+++ b/qtools/qcache.h
@@ -42,46 +42,6 @@
#include "qgcache.h"
#endif // QT_H
-#define USE_ASCII_STRING
-
-#ifndef USE_ASCII_STRING
-
-template<class type> class Q_EXPORT QCache : public QGCache
-{
-public:
- QCache( const QCache<type> &c ) : QGCache(c) {}
- QCache( int maxCost=100, int size=17, bool caseSensitive=TRUE )
- : QGCache( maxCost, size, StringKey, caseSensitive, FALSE ) {}
- ~QCache() { clear(); }
- QCache<type> &operator=( const QCache<type> &c )
- { return (QCache<type>&)QGCache::operator=(c); }
- int maxCost() const { return QGCache::maxCost(); }
- int totalCost() const { return QGCache::totalCost(); }
- void setMaxCost( int m ) { QGCache::setMaxCost(m); }
- uint count() const { return QGCache::count(); }
- uint size() const { return QGCache::size(); }
- bool isEmpty() const { return QGCache::count() == 0; }
- void clear() { QGCache::clear(); }
- bool insert( const QString &k, const type *d, int c=1, int p=0 )
- { return QGCache::insert_string(k,(Item)d,c,p);}
- bool remove( const QString &k )
- { return QGCache::remove_string(k); }
- type *take( const QString &k )
- { return (type *)QGCache::take_string(k); }
- type *find( const QString &k, bool ref=TRUE ) const
- { return (type *)QGCache::find_string(k,ref);}
- type *operator[]( const QString &k ) const
- { return (type *)QGCache::find_string(k);}
- void statistics() const { QGCache::statistics(); }
- int hits() const { return QGCache::hits(); }
- int misses() const { return QGCache::misses(); }
-private:
- void deleteItem( Item d ) { if ( del_item ) delete (type *)d; }
-};
-
-#else
-
-
template<class type> class Q_EXPORT QCache : public QGCache
{
public:
@@ -116,9 +76,6 @@ private:
};
-#endif
-
-
template<class type> class Q_EXPORT QCacheIterator : public QGCacheIterator
{
@@ -136,11 +93,7 @@ public:
type *toLast() { return (type *)QGCacheIterator::toLast(); }
operator type *() const { return (type *)QGCacheIterator::get(); }
type *current() const { return (type *)QGCacheIterator::get(); }
-#ifndef USE_ASCII_STRING
- QString currentKey() const{ return QGCacheIterator::getKeyString(); }
-#else
const char *currentKey() const{ return QGCacheIterator::getKeyAscii(); }
-#endif
type *operator()() { return (type *)QGCacheIterator::operator()();}
type *operator++() { return (type *)QGCacheIterator::operator++(); }
type *operator+=(uint j) { return (type *)QGCacheIterator::operator+=(j);}
diff --git a/qtools/qcstring.cpp b/qtools/qcstring.cpp
index 6a14d66..64417e3 100644
--- a/qtools/qcstring.cpp
+++ b/qtools/qcstring.cpp
@@ -17,6 +17,7 @@
#include "qgstring.h"
#include <qstring.h>
+#include <limits.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
@@ -88,8 +89,9 @@ int QCString::find( const QCString &str, int index, bool cs ) const
int QCString::find( const QRegExp &rx, int index ) const
{
- QString d = QString::fromLatin1( data() );
- return d.find( rx, index );
+ if ( index < 0 )
+ index += length();
+ return rx.match( data(), index );
}
int QCString::findRev( char c, int index, bool cs) const
@@ -146,8 +148,16 @@ int QCString::findRev( const char *str, int index, bool cs) const
int QCString::findRev( const QRegExp &rx, int index ) const
{
- QString d = QString::fromLatin1( data() );
- return d.findRev( rx, index );
+ if ( index < 0 ) // neg index ==> start from end
+ index += length();
+ if ( (uint)index > length() ) // bad index
+ return -1;
+ while( index >= 0 ) {
+ if ( rx.match( data(), index ) == index )
+ return index;
+ index--;
+ }
+ return -1;
}
int QCString::contains( char c, bool cs ) const
@@ -194,8 +204,26 @@ int QCString::contains( const char *str, bool cs ) const
int QCString::contains( const QRegExp &rx ) const
{
- QString d = QString::fromLatin1( data() );
- return d.contains( rx );
+ if ( isEmpty() )
+ return rx.match( data() ) < 0 ? 0 : 1;
+ int count = 0;
+ int index = -1;
+ int len = length();
+ while ( index < len-1 ) { // count overlapping matches
+ index = rx.match( data(), index+1 );
+ if ( index < 0 )
+ break;
+ count++;
+ }
+ return count;
+}
+
+bool QCString::startsWith( const char *s ) const
+{
+ const char *p = data();
+ if (p==0 || s==0) return s==0;
+ while (*p!=0 && *p==*s) p++,s++;
+ return *s==0;
}
bool QCString::stripPrefix(const char *prefix)
@@ -417,53 +445,204 @@ QCString &QCString::replace( uint index, uint len, const char *s)
QCString &QCString::replace( const QRegExp &rx, const char *str )
{
- QString d = QString::fromLatin1( data() );
- QString r = QString::fromLatin1( str );
- d.replace( rx, r );
- operator=( d.ascii() );
+ if ( isEmpty() )
+ return *this;
+ int index = 0;
+ int slen = qstrlen(str);
+ int len;
+ while ( index < (int)length() ) {
+ index = rx.match( data(), index, &len, FALSE );
+ if ( index >= 0 ) {
+ replace( index, len, str );
+ index += slen;
+ if ( !len )
+ break; // Avoid infinite loop on 0-length matches, e.g. [a-z]*
+ }
+ else
+ break;
+ }
return *this;
}
-short QCString::toShort(bool *ok) const
+static bool ok_in_base( char c, int base )
{
- QString s(data());
- return s.toShort(ok);
+ if ( base <= 10 )
+ return c>='0' && c<='9' && (c-'0') < base;
+ else
+ return (c>='0' && c<='9') ||
+ (c >= 'a' && c < char('a'+base-10)) ||
+ (c >= 'A' && c < char('A'+base-10));
}
-ushort QCString::toUShort(bool *ok) const
+short QCString::toShort(bool *ok, int base) const
{
- QString s(data());
- return s.toUShort(ok);
+ long v = toLong( ok, base );
+ if ( ok && *ok && (v < -32768 || v > 32767) ) {
+ *ok = FALSE;
+ v = 0;
+ }
+ return (short)v;
}
-int QCString::toInt(bool *ok) const
+ushort QCString::toUShort(bool *ok,int base) const
{
- QString s(data());
- return s.toInt(ok);
+ ulong v = toULong( ok, base );
+ if ( ok && *ok && (v > 65535) ) {
+ *ok = FALSE;
+ v = 0;
+ }
+ return (ushort)v;
}
-uint QCString::toUInt(bool *ok) const
+int QCString::toInt(bool *ok, int base) const
{
- QString s(data());
- return s.toUInt(ok);
+ return (int)toLong( ok, base );
}
-long QCString::toLong(bool *ok) const
+uint QCString::toUInt(bool *ok,int base) const
{
- QString s(data());
- return s.toLong(ok);
+ return (uint)toULong( ok, base );
}
-ulong QCString::toULong(bool *ok) const
+
+long QCString::toLong(bool *ok,int base) const
{
- QString s(data());
- return s.toULong(ok);
+ const char *p = data();
+ long val=0;
+ int l = length();
+ const long max_mult = INT_MAX / base;
+ bool is_ok = FALSE;
+ int neg = 0;
+ if ( !p )
+ goto bye;
+ while ( l && isspace(*p) ) // skip leading space
+ l--,p++;
+ if ( l && *p == '-' ) {
+ l--;
+ p++;
+ neg = 1;
+ } else if ( *p == '+' ) {
+ l--;
+ p++;
+ }
+
+ // NOTE: toULong() code is similar
+ if ( !l || !ok_in_base(*p,base) )
+ goto bye;
+ while ( l && ok_in_base(*p,base) ) {
+ l--;
+ int dv;
+ if ( *p>='0' && *p<='9' ) {
+ dv = *p-'0';
+ } else {
+ if ( *p >= 'a' && *p <= 'z' )
+ dv = *p - 'a' + 10;
+ else
+ dv = *p - 'A' + 10;
+ }
+ if ( val > max_mult || (val == max_mult && dv > (INT_MAX%base)+neg) )
+ goto bye;
+ val = base*val + dv;
+ p++;
+ }
+ if ( neg )
+ val = -val;
+ while ( l && isspace(*p) ) // skip trailing space
+ l--,p++;
+ if ( !l )
+ is_ok = TRUE;
+bye:
+ if ( ok )
+ *ok = is_ok;
+ return is_ok ? val : 0;
+}
+
+ulong QCString::toULong(bool *ok,int base) const
+{
+ const char *p = data();
+ ulong val=0;
+ int l = length();
+ const ulong max_mult = 429496729; // UINT_MAX/10, rounded down
+ bool is_ok = FALSE;
+ if ( !p )
+ goto bye;
+ while ( l && isspace(*p) ) // skip leading space
+ l--,p++;
+ if ( *p == '+' )
+ l--,p++;
+
+ // NOTE: toLong() code is similar
+ if ( !l || !ok_in_base(*p,base) )
+ goto bye;
+ while ( l && ok_in_base(*p,base) ) {
+ l--;
+ uint dv;
+ if ( *p>='0' && *p<='9' ) {
+ dv = *p-'0';
+ } else {
+ if ( *p >= 'a' && *p <= 'z' )
+ dv = *p - 'a' + 10;
+ else
+ dv = *p - 'A' + 10;
+ }
+ if ( val > max_mult || (val == max_mult && dv > (UINT_MAX%base)) )
+ goto bye;
+ val = base*val + dv;
+ p++;
+ }
+
+ while ( l && isspace(*p) ) // skip trailing space
+ l--,p++;
+ if ( !l )
+ is_ok = TRUE;
+bye:
+ if ( ok )
+ *ok = is_ok;
+ return is_ok ? val : 0;
}
-uint64 QCString::toUInt64(bool *ok) const
+uint64 QCString::toUInt64(bool *ok,int base) const
{
- QString s(data());
- return s.toUInt64(ok);
+ const char *p = data();
+ uint64 val=0;
+ int l = length();
+ const uint64 max_mult = 1844674407370955161ULL; // ULLONG_MAX/10, rounded down
+ bool is_ok = FALSE;
+ if ( !p )
+ goto bye;
+ while ( l && isspace(*p) ) // skip leading space
+ l--,p++;
+ if ( *p == '+' )
+ l--,p++;
+
+ // NOTE: toULong() code is similar
+ if ( !l || !ok_in_base(*p,base) )
+ goto bye;
+ while ( l && ok_in_base(*p,base) ) {
+ l--;
+ uint dv;
+ if ( *p>='0' && *p<='9' ) {
+ dv = *p-'0';
+ } else {
+ if ( *p >= 'a' && *p <= 'z' )
+ dv = *p - 'a' + 10;
+ else
+ dv = *p - 'A' + 10;
+ }
+ if ( val > max_mult || (val == max_mult && dv > (ULLONG_MAX%base)) )
+ goto bye;
+ val = base*val + dv;
+ p++;
+ }
+
+ while ( l && isspace(*p) ) // skip trailing space
+ l--,p++;
+ if ( !l )
+ is_ok = TRUE;
+bye:
+ if ( ok )
+ *ok = is_ok;
+ return is_ok ? val : 0;
}
QCString &QCString::setNum(short n)
diff --git a/qtools/qcstring.h b/qtools/qcstring.h
index abf30b3..f484207 100644
--- a/qtools/qcstring.h
+++ b/qtools/qcstring.h
@@ -282,19 +282,20 @@ public:
QCString &remove( uint index, uint len );
QCString &replace( uint index, uint len, const char *s);
QCString &replace( const QRegExp &rx, const char *str );
- short toShort( bool *ok=0 ) const;
- ushort toUShort( bool *ok=0 ) const;
- int toInt( bool *ok=0 ) const;
- uint toUInt( bool *ok=0 ) const;
- long toLong( bool *ok=0 ) const;
- ulong toULong( bool *ok=0 ) const;
- uint64 toUInt64( bool *ok=0 ) const;
+ short toShort( bool *ok=0, int base=10 ) const;
+ ushort toUShort( bool *ok=0, int base=10 ) const;
+ int toInt( bool *ok=0, int base=10 ) const;
+ uint toUInt( bool *ok=0, int base=10 ) const;
+ long toLong( bool *ok=0, int base=10 ) const;
+ ulong toULong( bool *ok=0, int base=10 ) const;
+ uint64 toUInt64( bool *ok=0, int base=10 ) const;
QCString &setNum(short n);
QCString &setNum(ushort n);
QCString &setNum(int n);
QCString &setNum(uint n);
QCString &setNum(long n);
QCString &setNum(ulong n);
+ bool startsWith( const char *s ) const;
/** Converts the string to a plain C string */
operator const char *() const
diff --git a/qtools/qdatetime.cpp b/qtools/qdatetime.cpp
index 88569f8..8f1cab2 100644
--- a/qtools/qdatetime.cpp
+++ b/qtools/qdatetime.cpp
@@ -279,7 +279,7 @@ int QDate::daysInYear() const
\sa toString(), dayName()
*/
-QString QDate::monthName( int month ) const
+QCString QDate::monthName( int month ) const
{
#if defined(CHECK_RANGE)
if ( month < 1 || month > 12 ) {
@@ -287,8 +287,7 @@ QString QDate::monthName( int month ) const
month = 1;
}
#endif
- // ### Remove the fromLatin1 during localization
- return QString::fromLatin1(monthNames[month-1]);
+ return monthNames[month-1];
}
/*!
@@ -299,7 +298,7 @@ QString QDate::monthName( int month ) const
\sa toString(), monthName()
*/
-QString QDate::dayName( int weekday ) const
+QCString QDate::dayName( int weekday ) const
{
#if defined(CHECK_RANGE)
if ( weekday < 1 || weekday > 7 ) {
@@ -307,8 +306,7 @@ QString QDate::dayName( int weekday ) const
weekday = 1;
}
#endif
- // ### Remove the fromLatin1 during localization
- return QString::fromLatin1(weekdayNames[weekday-1]);
+ return weekdayNames[weekday-1];
}
@@ -321,14 +319,14 @@ QString QDate::dayName( int weekday ) const
\sa dayName(), monthName()
*/
-QString QDate::toString() const
+QCString QDate::toString() const
{
int y, m, d;
jul2greg( jd, y, m, d );
- QString buf = dayName(dayOfWeek());
+ QCString buf = dayName(dayOfWeek());
buf += ' ';
buf += monthName(m);
- QString t;
+ QCString t;
t.sprintf( " %d %d", d, y);
buf += t;
return buf;
@@ -684,9 +682,9 @@ int QTime::msec() const
before midnight would be "23:59:59".
*/
-QString QTime::toString() const
+QCString QTime::toString() const
{
- QString buf;
+ QCString buf;
buf.sprintf( "%.2d:%.2d:%.2d", hour(), minute(), second() );
return buf;
}
@@ -1190,17 +1188,17 @@ void QDateTime::setTimeUtc_t( uint secsSince1Jan1970UTC )
*/
-QString QDateTime::toString() const
+QCString QDateTime::toString() const
{
- QString buf = d.dayName(d.dayOfWeek());
+ QCString buf = d.dayName(d.dayOfWeek());
buf += ' ';
buf += d.monthName(d.month());
buf += ' ';
- buf += QString().setNum(d.day());
+ buf += QCString().setNum(d.day());
buf += ' ';
buf += t.toString();
buf += ' ';
- buf += QString().setNum(d.year());
+ buf += QCString().setNum(d.year());
return buf;
}
diff --git a/qtools/qdatetime.h b/qtools/qdatetime.h
index 010ae73..63007f3 100644
--- a/qtools/qdatetime.h
+++ b/qtools/qdatetime.h
@@ -39,7 +39,7 @@
#define QDATETIME_H
#ifndef QT_H
-#include "qstring.h"
+#include "qcstring.h"
#endif // QT_H
@@ -65,10 +65,10 @@ public:
int daysInMonth() const; // 28..31
int daysInYear() const; // 365 or 366
- virtual QString monthName( int month ) const;
- virtual QString dayName( int weekday ) const;
+ virtual QCString monthName( int month ) const;
+ virtual QCString dayName( int weekday ) const;
- QString toString() const;
+ QCString toString() const;
bool setYMD( int y, int m, int d );
@@ -119,7 +119,7 @@ public:
int second() const; // 0..59
int msec() const; // 0..999
- QString toString() const;
+ QCString toString() const;
bool setHMS( int h, int m, int s, int ms=0 );
@@ -175,7 +175,7 @@ public:
void setTime_t( uint secsSince1Jan1970UTC );
void setTimeUtc_t( uint secsSince1Jan1970UTC );
- QString toString() const;
+ QCString toString() const;
QDateTime addDays( int days ) const;
QDateTime addSecs( int secs ) const;
diff --git a/qtools/qdict.h b/qtools/qdict.h
index efc5bd0..12db365 100644
--- a/qtools/qdict.h
+++ b/qtools/qdict.h
@@ -42,89 +42,8 @@
#include "qgdict.h"
#endif // QT_H
-#define USE_ASCII_STRING
-
-#ifdef USE_ASCII_STRING
-
#define QAsciiDict QDict
#define QAsciiDictIterator QDictIterator
#include "qasciidict.h"
-#else
-
-template<class type> class Q_EXPORT QDict : private QGDict
-{
-public:
- QDict(int size=17, bool caseSensitive=TRUE)
- : QGDict(size,StringKey,caseSensitive,FALSE) {}
- QDict( const QDict<type> &d ) : QGDict(d) {}
- ~QDict() { clear(); }
- QDict<type> &operator=(const QDict<type> &d)
- { return (QDict<type>&)QGDict::operator=(d); }
-
- // capacity
- uint count() const { return QGDict::count(); }
- uint size() const { return QGDict::size(); }
- bool isEmpty() const { return QGDict::count() == 0; }
-
- // modifiers
- void insert( const QString &k, const type *d )
- { QGDict::look_string(k,(Item)d,1); }
- void replace( const QString &k, const type *d )
- { QGDict::look_string(k,(Item)d,2); }
- bool remove( const QString &k ) { return QGDict::remove_string(k); }
- type *take( const QString &k ) { return (type *)QGDict::take_string(k); }
- void clear() { QGDict::clear(); }
- void resize( uint n ) { QGDict::resize(n); }
-
- // search
- type *find( const QString &k ) const
- { return (type *)((QGDict*)this)->QGDict::look_string(k,0,0); }
- type *operator[]( const QString &k ) const
- { return (type *)((QGDict*)this)->QGDict::look_string(k,0,0); }
-
- // operations
- void statistics() const { QGDict::statistics(); }
-private:
- void deleteItem( Item d );
-
- // new to be reimplemented methods
- virtual int compareValues(const type *t1,const type *t2) const
- { return const_cast<QDict<type>*>(this)->QGDict::compareItems((QCollection::Item)t1,(QCollection::Item)t2); }
-
- // reimplemented methods
- virtual int compareItems(QCollection::Item i1,QCollection::Item i2)
- { return compareValues((const type*)i1,(const type*)i2); }
-};
-
-#if defined(Q_DELETING_VOID_UNDEFINED)
-template<> inline void QDict<void>::deleteItem( Item )
-{
-}
-#endif
-
-template<class type> inline void QDict<type>::deleteItem( QCollection::Item d )
-{
- if ( del_item ) delete (type *)d;
-}
-
-
-template<class type> class Q_EXPORT QDictIterator : public QGDictIterator
-{
-public:
- QDictIterator(const QDict<type> &d) :QGDictIterator((QGDict &)d) {}
- ~QDictIterator() {}
- uint count() const { return dict->count(); }
- bool isEmpty() const { return dict->count() == 0; }
- type *toFirst() { return (type *)QGDictIterator::toFirst(); }
- operator type *() const { return (type *)QGDictIterator::get(); }
- type *current() const { return (type *)QGDictIterator::get(); }
- QString currentKey() const{ return QGDictIterator::getKeyString(); }
- type *operator()() { return (type *)QGDictIterator::operator()(); }
- type *operator++() { return (type *)QGDictIterator::operator++(); }
- type *operator+=(uint j) { return (type *)QGDictIterator::operator+=(j);}
-};
-
-#endif // USE_ASCII_STRING
-
#endif // QDICT_H
diff --git a/qtools/qgcache.cpp b/qtools/qgcache.cpp
index 03150fe..230823c 100644
--- a/qtools/qgcache.cpp
+++ b/qtools/qgcache.cpp
@@ -190,21 +190,21 @@ public:
QCDict( uint size, uint kt, bool caseSensitive, bool copyKeys )
: QGDict( size, (KeyType)kt, caseSensitive, copyKeys ) {}
- QCacheItem *find_string(const QString &key) const
+ QCacheItem *find_string(const QCString &key) const
{ return (QCacheItem*)((QCDict*)this)->look_string(key, 0, 0); }
QCacheItem *find_ascii(const char *key) const
{ return (QCacheItem*)((QCDict*)this)->look_ascii(key, 0, 0); }
QCacheItem *find_int(long key) const
{ return (QCacheItem*)((QCDict*)this)->look_int(key, 0, 0); }
- QCacheItem *take_string(const QString &key)
+ QCacheItem *take_string(const QCString &key)
{ return (QCacheItem*)QGDict::take_string(key); }
QCacheItem *take_ascii(const char *key)
{ return (QCacheItem*)QGDict::take_ascii(key); }
QCacheItem *take_int(long key)
{ return (QCacheItem*)QGDict::take_int(key); }
- bool insert_string( const QString &key, const QCacheItem *ci )
+ bool insert_string( const QCString &key, const QCacheItem *ci )
{ return QGDict::look_string(key,(Item)ci,1)!=0;}
bool insert_ascii( const char *key, const QCacheItem *ci )
{ return QGDict::look_ascii(key,(Item)ci,1)!=0;}
@@ -212,7 +212,7 @@ public:
{ return QGDict::look_int(key,(Item)ci,1)!=0;}
bool remove_string( QCacheItem *item )
- { return QGDict::remove_string(*((QString*)(item->key)),item); }
+ { return QGDict::remove_string(*((QCString*)(item->key)),item); }
bool remove_ascii( QCacheItem *item )
{ return QGDict::remove_ascii((const char *)item->key,item); }
bool remove_int( QCacheItem *item )
@@ -345,7 +345,7 @@ void QGCache::setMaxCost( int maxCost )
invalid.
*/
-bool QGCache::insert_string( const QString &key, QCollection::Item data,
+bool QGCache::insert_string( const QCString &key, QCollection::Item data,
int cost, int priority)
{
if ( tCost + cost > mCost ) {
@@ -365,7 +365,7 @@ bool QGCache::insert_string( const QString &key, QCollection::Item data,
priority = -32768;
else if ( priority > 32767 )
priority = 32677;
- QCacheItem *ci = new QCacheItem( new QString(key), newItem(data),
+ QCacheItem *ci = new QCacheItem( new QCString(key), newItem(data),
cost, (short)priority );
CHECK_PTR( ci );
lruList->insert( 0, ci );
@@ -417,7 +417,7 @@ bool QGCache::insert_other( const char *key, QCollection::Item data,
Removes an item from the cache.
*/
-bool QGCache::remove_string( const QString &key )
+bool QGCache::remove_string( const QCString &key )
{
Item d = take_string( key );
if ( d )
@@ -442,7 +442,7 @@ bool QGCache::remove_other( const char *key )
Takes an item out of the cache (no delete).
*/
-QCollection::Item QGCache::take_string( const QString &key )
+QCollection::Item QGCache::take_string( const QCString &key )
{
QCacheItem *ci = dict->take_string( key ); // take from dict
Item d;
@@ -450,7 +450,7 @@ QCollection::Item QGCache::take_string( const QString &key )
d = ci->data;
tCost -= ci->cost;
lruList->take( ci ); // take from list
- delete (QString*)ci->key;
+ delete (QCString*)ci->key;
delete ci;
} else {
d = 0;
@@ -497,7 +497,7 @@ void QGCache::clear()
switch ( keytype ) {
case StringKey:
dict->remove_string( ci );
- delete (QString*)ci->key;
+ delete (QCString*)ci->key;
break;
case AsciiKey:
dict->remove_ascii( ci );
@@ -522,7 +522,7 @@ void QGCache::clear()
Finds an item in the cache.
*/
-QCollection::Item QGCache::find_string( const QString &key, bool ref ) const
+QCollection::Item QGCache::find_string( const QCString &key, bool ref ) const
{
QCacheItem *ci = dict->find_string( key );
#if defined(DEBUG)
@@ -599,7 +599,7 @@ bool QGCache::makeRoomFor( int cost, int priority )
switch ( keytype ) {
case StringKey:
dict->remove_string( ci );
- delete (QString*)ci->key;
+ delete (QCString*)ci->key;
break;
case AsciiKey:
dict->remove_ascii( ci );
@@ -628,9 +628,9 @@ bool QGCache::makeRoomFor( int cost, int priority )
void QGCache::statistics() const
{
#if defined(DEBUG)
- QString line;
+ QCString line;
line.fill( '*', 80 );
- qDebug( "%s",line.ascii() );
+ qDebug( "%s",line.data() );
qDebug( "CACHE STATISTICS:" );
qDebug( "cache contains %d item%s, with a total cost of %d",
count(), count() != 1 ? "s" : "", tCost );
@@ -651,7 +651,7 @@ void QGCache::statistics() const
lruList->dumps != 1 ? "have" : "has", lruList->dumpCosts );
qDebug( "Statistics from internal dictionary class:" );
dict->statistics();
- qDebug( "%s",line.ascii() );
+ qDebug( "%s",line.data() );
#endif
}
@@ -794,10 +794,10 @@ QCollection::Item QGCacheIterator::get() const
Returns the key of the current item.
*/
-QString QGCacheIterator::getKeyString() const
+QCString QGCacheIterator::getKeyString() const
{
QCacheItem *item = it->current();
- return item ? *((QString*)item->key) : QString::null;
+ return item ? *((QCString*)item->key) : QCString();
}
/*!
diff --git a/qtools/qgcache.h b/qtools/qgcache.h
index a71f6d3..5d8a243 100644
--- a/qtools/qgcache.h
+++ b/qtools/qgcache.h
@@ -70,16 +70,16 @@ protected:
void setMaxCost( int maxCost );
void clear();
- bool insert_string( const QString &key, QCollection::Item,
+ bool insert_string( const QCString &key, QCollection::Item,
int cost, int priority );
bool insert_other( const char *key, QCollection::Item,
int cost, int priority );
- bool remove_string( const QString &key );
+ bool remove_string( const QCString &key );
bool remove_other( const char *key );
- QCollection::Item take_string( const QString &key );
+ QCollection::Item take_string( const QCString &key );
QCollection::Item take_other( const char *key );
- QCollection::Item find_string( const QString &key, bool ref=TRUE ) const;
+ QCollection::Item find_string( const QCString &key, bool ref=TRUE ) const;
QCollection::Item find_other( const char *key, bool ref=TRUE ) const;
void statistics() const;
@@ -112,7 +112,7 @@ protected:
QCollection::Item toLast();
QCollection::Item get() const;
- QString getKeyString() const;
+ QCString getKeyString() const;
const char *getKeyAscii() const;
intptr_t getKeyInt() const;
diff --git a/qtools/qgdict.cpp b/qtools/qgdict.cpp
index ab3fea9..a3db8de 100644
--- a/qtools/qgdict.cpp
+++ b/qtools/qgdict.cpp
@@ -83,36 +83,9 @@ public:
Returns the hash key for \e key, when key is a string.
*/
-int QGDict::hashKeyString( const QString &key )
+int QGDict::hashKeyString( const QCString &key )
{
-#if defined(CHECK_NULL)
- if ( key.isNull() )
- qWarning( "QGDict::hashStringKey: Invalid null key" );
-#endif
- int i;
- uint h=0;
- uint g;
- int len = key.length();
- const QChar *p = key.unicode();
- if ( cases ) { // case sensitive
- for ( i=0; i<len; i++ ) {
- h = (h<<4) + p[i].cell();
- if ( (g = h & 0xf0000000) )
- h ^= g >> 24;
- h &= ~g;
- }
- } else { // case insensitive
- for ( i=0; i<len; i++ ) {
- h = (h<<4) + p[i].lower().cell();
- if ( (g = h & 0xf0000000) )
- h ^= g >> 24;
- h &= ~g;
- }
- }
- int index = h;
- if ( index < 0 ) // adjust index to table size
- index = -index;
- return index;
+ return hashKeyAscii(key.data());
}
/*!
@@ -337,7 +310,7 @@ QGDict &QGDict::operator=( const QGDict &dict )
*/
-/*! \fn QString QGDictIterator::getKeyString() const
+/*! \fn QCString QGDictIterator::getKeyString() const
\internal
*/
@@ -379,21 +352,21 @@ QGDict &QGDict::operator=( const QGDict &dict )
The do-it-all function; op is one of op_find, op_insert, op_replace
*/
-QCollection::Item QGDict::look_string( const QString &key, QCollection::Item d, int op )
+QCollection::Item QGDict::look_string( const QCString &key, QCollection::Item d, int op )
{
- QStringBucket *n;
+ QCStringBucket *n;
int index = hashKeyString(key) % vlen;
if ( op == op_find ) { // find
if ( cases ) {
- for ( n=(QStringBucket*)vec[index]; n;
- n=(QStringBucket*)n->getNext() ) {
+ for ( n=(QCStringBucket*)vec[index]; n;
+ n=(QCStringBucket*)n->getNext() ) {
if ( key == n->getKey() )
return n->getData(); // item found
}
} else {
- QString k = key.lower();
- for ( n=(QStringBucket*)vec[index]; n;
- n=(QStringBucket*)n->getNext() ) {
+ QCString k = key.lower();
+ for ( n=(QCStringBucket*)vec[index]; n;
+ n=(QCStringBucket*)n->getNext() ) {
if ( k == n->getKey().lower() )
return n->getData(); // item found
}
@@ -405,7 +378,7 @@ QCollection::Item QGDict::look_string( const QString &key, QCollection::Item d,
remove_string( key );
}
// op_insert or op_replace
- n = new QStringBucket(key,newItem(d),vec[index]);
+ n = new QCStringBucket(key,newItem(d),vec[index]);
CHECK_PTR( n );
#if defined(CHECK_NULL)
if ( n->getData() == 0 )
@@ -542,10 +515,10 @@ void QGDict::resize( uint newsize )
switch ( keytype ) {
case StringKey:
{
- QStringBucket *n=(QStringBucket *)old_vec[index];
+ QCStringBucket *n=(QCStringBucket *)old_vec[index];
while ( n ) {
look_string( n->getKey(), n->getData(), op_insert );
- QStringBucket *t=(QStringBucket *)n->getNext();
+ QCStringBucket *t=(QCStringBucket *)n->getNext();
delete n;
n = t;
}
@@ -624,16 +597,16 @@ void QGDict::unlink_common( int index, QBaseBucket *node, QBaseBucket *prev )
numItems--;
}
-QStringBucket *QGDict::unlink_string( const QString &key, QCollection::Item d )
+QCStringBucket *QGDict::unlink_string( const QCString &key, QCollection::Item d )
{
if ( numItems == 0 ) // nothing in dictionary
return 0;
- QStringBucket *n;
- QStringBucket *prev = 0;
+ QCStringBucket *n;
+ QCStringBucket *prev = 0;
int index = hashKeyString(key) % vlen;
if ( cases ) {
- for ( n=(QStringBucket*)vec[index]; n;
- n=(QStringBucket*)n->getNext() ) {
+ for ( n=(QCStringBucket*)vec[index]; n;
+ n=(QCStringBucket*)n->getNext() ) {
bool found = (key == n->getKey());
if ( found && d )
found = (n->getData() == d);
@@ -644,9 +617,9 @@ QStringBucket *QGDict::unlink_string( const QString &key, QCollection::Item d )
prev = n;
}
} else {
- QString k = key.lower();
- for ( n=(QStringBucket*)vec[index]; n;
- n=(QStringBucket*)n->getNext() ) {
+ QCString k = key.lower();
+ for ( n=(QCStringBucket*)vec[index]; n;
+ n=(QCStringBucket*)n->getNext() ) {
bool found = (k == n->getKey().lower());
if ( found && d )
found = (n->getData() == d);
@@ -729,9 +702,9 @@ QPtrBucket *QGDict::unlink_ptr( void *key, QCollection::Item d )
item when several items have the same key).
*/
-bool QGDict::remove_string( const QString &key, QCollection::Item item )
+bool QGDict::remove_string( const QCString &key, QCollection::Item item )
{
- QStringBucket *n = unlink_string( key, item );
+ QCStringBucket *n = unlink_string( key, item );
if ( n ) {
deleteItem( n->getData() );
delete n;
@@ -785,9 +758,9 @@ bool QGDict::remove_ptr( void *key, QCollection::Item item )
/*! \internal */
-QCollection::Item QGDict::take_string( const QString &key )
+QCollection::Item QGDict::take_string( const QCString &key )
{
- QStringBucket *n = unlink_string( key );
+ QCStringBucket *n = unlink_string( key );
Item d;
if ( n ) {
d = n->getData();
@@ -864,9 +837,9 @@ void QGDict::clear()
switch ( keytype ) {
case StringKey:
{
- QStringBucket *n=(QStringBucket *)vec[j];
+ QCStringBucket *n=(QCStringBucket *)vec[j];
while ( n ) {
- QStringBucket *next = (QStringBucket*)n->getNext();
+ QCStringBucket *next = (QCStringBucket*)n->getNext();
deleteItem( n->getData() );
delete n;
n = next;
@@ -930,14 +903,14 @@ void QGDict::clear()
void QGDict::statistics() const
{
#if defined(DEBUG)
- QString line;
+ QCString line;
line.fill( '-', 60 );
double real, ideal;
- qDebug( "%s",line.ascii() );
+ qDebug( "%s",line.data() );
qDebug( "DICTIONARY STATISTICS:" );
if ( count() == 0 ) {
qDebug( "Empty!" );
- qDebug( "%s", line.ascii() );
+ qDebug( "%s", line.data() );
return;
}
real = 0.0;
@@ -966,7 +939,7 @@ void QGDict::statistics() const
qDebug( "Real dist = %g", real );
qDebug( "Rand dist = %g", ideal );
qDebug( "Real/Rand = %g", real/ideal );
- qDebug( "%s",line.ascii() );
+ qDebug( "%s",line.data() );
#endif // DEBUG
}
@@ -1004,7 +977,7 @@ QDataStream &QGDict::read( QDataStream &s )
switch ( keytype ) {
case StringKey:
{
- QString k;
+ QCString k;
s >> k;
read( s, d );
look_string( k, d, op_insert );
@@ -1060,7 +1033,7 @@ QDataStream& QGDict::write( QDataStream &s ) const
while ( n ) { // write all buckets
switch ( keytype ) {
case StringKey:
- s << ((QStringBucket*)n)->getKey();
+ s << ((QCStringBucket*)n)->getKey();
break;
case AsciiKey:
s << ((QAsciiBucket*)n)->getKey();
diff --git a/qtools/qgdict.h b/qtools/qgdict.h
index a5c8aa0..cf023fd 100644
--- a/qtools/qgdict.h
+++ b/qtools/qgdict.h
@@ -40,7 +40,7 @@
#ifndef QT_H
#include "qcollection.h"
-#include "qstring.h"
+#include "qcstring.h"
#endif // QT_H
class QGDictIterator;
@@ -60,14 +60,14 @@ protected:
QBaseBucket *next;
};
-class QStringBucket : public QBaseBucket
+class QCStringBucket : public QBaseBucket
{
public:
- QStringBucket( const QString &k, QCollection::Item d, QBaseBucket *n )
+ QCStringBucket( const QCString &k, QCollection::Item d, QBaseBucket *n )
: QBaseBucket(d,n), key(k) {}
- const QString &getKey() const { return key; }
+ const QCString &getKey() const { return key; }
private:
- QString key;
+ QCString key;
};
class QAsciiBucket : public QBaseBucket
@@ -106,7 +106,7 @@ class Q_EXPORT QGDict : public QCollection // generic dictionary class
public:
uint count() const { return numItems; }
uint size() const { return vlen; }
- QCollection::Item look_string( const QString& key, QCollection::Item,
+ QCollection::Item look_string( const QCString& key, QCollection::Item,
int );
QCollection::Item look_ascii( const char *key, QCollection::Item, int );
QCollection::Item look_int( long key, QCollection::Item, int );
@@ -124,11 +124,11 @@ protected:
QGDict &operator=( const QGDict & );
- bool remove_string( const QString &key, QCollection::Item item=0 );
+ bool remove_string( const QCString &key, QCollection::Item item=0 );
bool remove_ascii( const char *key, QCollection::Item item=0 );
bool remove_int( long key, QCollection::Item item=0 );
bool remove_ptr( void *key, QCollection::Item item=0 );
- QCollection::Item take_string( const QString &key );
+ QCollection::Item take_string( const QCString &key );
QCollection::Item take_ascii( const char *key );
QCollection::Item take_int( long key );
QCollection::Item take_ptr( void *key );
@@ -136,7 +136,7 @@ protected:
void clear();
void resize( uint );
- int hashKeyString( const QString & );
+ int hashKeyString( const QCString & );
int hashKeyAscii( const char * );
void statistics() const;
@@ -154,7 +154,7 @@ private:
uint copyk : 1;
QGDItList *iterators;
void unlink_common( int, QBaseBucket *, QBaseBucket * );
- QStringBucket *unlink_string( const QString &,
+ QCStringBucket *unlink_string( const QCString &,
QCollection::Item item = 0 );
QAsciiBucket *unlink_ascii( const char *, QCollection::Item item = 0 );
QIntBucket *unlink_int( long, QCollection::Item item = 0 );
@@ -176,7 +176,7 @@ public:
QCollection::Item toFirst();
QCollection::Item get() const;
- QString getKeyString() const;
+ QCString getKeyString() const;
const char *getKeyAscii() const;
intptr_t getKeyInt() const;
void *getKeyPtr() const;
@@ -198,9 +198,9 @@ inline QCollection::Item QGDictIterator::get() const
return curNode ? curNode->getData() : 0;
}
-inline QString QGDictIterator::getKeyString() const
+inline QCString QGDictIterator::getKeyString() const
{
- return curNode ? ((QStringBucket*)curNode)->getKey() : QString::null;
+ return curNode ? ((QCStringBucket*)curNode)->getKey() : QCString();
}
inline const char *QGDictIterator::getKeyAscii() const