diff options
author | dimitri <dimitri@afe2bf4a-e733-0410-8a33-86f594647bc7> | 2005-04-21 21:10:51 (GMT) |
---|---|---|
committer | dimitri <dimitri@afe2bf4a-e733-0410-8a33-86f594647bc7> | 2005-04-21 21:10:51 (GMT) |
commit | 5d31b7ab211586100301d6838be82f066f8f9af4 (patch) | |
tree | 81218085d3e6e15b1ce6c418734013d48e9deda8 /qtools | |
parent | 76e39987363c93fdd3f2d99ffdb9f87743d6af7c (diff) | |
download | Doxygen-5d31b7ab211586100301d6838be82f066f8f9af4.zip Doxygen-5d31b7ab211586100301d6838be82f066f8f9af4.tar.gz Doxygen-5d31b7ab211586100301d6838be82f066f8f9af4.tar.bz2 |
Release-1.4.2-20050421
Diffstat (limited to 'qtools')
-rw-r--r-- | qtools/qasciidict.h | 13 | ||||
-rw-r--r-- | qtools/qcache.h | 44 | ||||
-rw-r--r-- | qtools/qdict.h | 10 | ||||
-rw-r--r-- | qtools/qfile_unix.cpp | 8 | ||||
-rw-r--r-- | qtools/qgdict.cpp | 8 |
5 files changed, 80 insertions, 3 deletions
diff --git a/qtools/qasciidict.h b/qtools/qasciidict.h index 3f2deaf..29fcf2f 100644 --- a/qtools/qasciidict.h +++ b/qtools/qasciidict.h @@ -71,9 +71,20 @@ public: void resize( uint n ) { QGDict::resize(n); } void statistics() const { QGDict::statistics(); } private: - void deleteItem( Item d ) { if ( del_item ) delete (type *)d; } + void deleteItem( Item d ); }; +#if defined(Q_DELETING_VOID_UNDEFINED) +template<> inline void QAsciiDict<void>::deleteItem( Item ) +{ +} +#endif + +template<class type> inline void QAsciiDict<type>::deleteItem( QCollection::Item d ) +{ + if ( del_item ) delete (type *)d; +} + template<class type> class Q_EXPORT QAsciiDictIterator : public QGDictIterator { diff --git a/qtools/qcache.h b/qtools/qcache.h index 39b9139..78cef3d 100644 --- a/qtools/qcache.h +++ b/qtools/qcache.h @@ -42,6 +42,9 @@ #include "qgcache.h" #endif // QT_H +#define USE_ASCII_STRING + +#ifndef USE_ASCII_STRING template<class type> class Q_EXPORT QCache : public QGCache { @@ -74,6 +77,43 @@ private: void deleteItem( Item d ) { if ( del_item ) delete (type *)d; } }; +#else + + +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, AsciiKey, caseSensitive, TRUE ) {} + ~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 char *k, const type *d, int c=1, int p=0 ) + { return QGCache::insert_other(k,(Item)d,c,p);} + bool remove( const char *k ) + { return QGCache::remove_other(k); } + type *take( const char *k ) + { return (type *)QGCache::take_ascii(k); } + type *find( const char *k, bool ref=TRUE ) const + { return (type *)QGCache::find_other(k,ref);} + type *operator[]( const char *k ) const + { return (type *)QGCache::find_other(k);} + void statistics() const { QGCache::statistics(); } +private: + void deleteItem( Item d ) { if ( del_item ) delete (type *)d; } +}; + + +#endif + template<class type> class Q_EXPORT QCacheIterator : public QGCacheIterator @@ -92,7 +132,11 @@ 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/qdict.h b/qtools/qdict.h index 3b70336..682b270 100644 --- a/qtools/qdict.h +++ b/qtools/qdict.h @@ -42,6 +42,15 @@ #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 : public QGDict { @@ -102,5 +111,6 @@ public: type *operator+=(uint j) { return (type *)QGDictIterator::operator+=(j);} }; +#endif // USE_ASCII_STRING #endif // QDICT_H diff --git a/qtools/qfile_unix.cpp b/qtools/qfile_unix.cpp index 43424b1..6b63d99 100644 --- a/qtools/qfile_unix.cpp +++ b/qtools/qfile_unix.cpp @@ -175,7 +175,11 @@ bool QFile::open( int m ) } #if defined(HAS_TEXT_FILEMODE) if ( isTranslated() ) +#ifdef __CYGWIN__ + /* Do nothing, allowing the Cygwin mount mode to take effect. */; +#else oflags |= OPEN_TEXT; +#endif else oflags |= OPEN_BINARY; #endif @@ -214,7 +218,11 @@ bool QFile::open( int m ) qstrcpy( perm2, perm ); #if defined(HAS_TEXT_FILEMODE) if ( isTranslated() ) +#ifdef __CYGWIN__ + /* Do nothing, allowing the Cygwin mount mode to take effect. */; +#else strcat( perm2, "t" ); +#endif else strcat( perm2, "b" ); #endif diff --git a/qtools/qgdict.cpp b/qtools/qgdict.cpp index e9306bb..e55d059 100644 --- a/qtools/qgdict.cpp +++ b/qtools/qgdict.cpp @@ -92,16 +92,17 @@ int QGDict::hashKeyString( const QString &key ) int i; register uint h=0; uint g; + int len = key.length(); const QChar *p = key.unicode(); if ( cases ) { // case sensitive - for ( i=0; i<(int)key.length(); i++ ) { + 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<(int)key.length(); i++ ) { + for ( i=0; i<len; i++ ) { h = (h<<4) + p[i].lower().cell(); if ( (g = h & 0xf0000000) ) h ^= g >> 24; @@ -123,7 +124,10 @@ int QGDict::hashKeyAscii( const char *key ) { #if defined(CHECK_NULL) if ( key == 0 ) + { qWarning( "QGDict::hashAsciiKey: Invalid null key" ); + return 0; + } #endif register const char *k = key; register uint h=0; |