From d796c9dd933ab96ec83b9a634feedd5d32e1ba3f Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Tue, 8 Nov 2011 12:31:36 -0600 Subject: Test conversion to TQt3 from Qt3 8c6fc1f8e35fd264dd01c582ca5e7549b32ab731 --- src/tools/qasciicache.h | 125 + src/tools/qasciidict.h | 123 + src/tools/qbitarray.cpp | 665 ++ src/tools/qbitarray.h | 169 + src/tools/qbuffer.cpp | 498 ++ src/tools/qbuffer.h | 103 + src/tools/qcache.h | 121 + src/tools/qcleanuphandler.h | 130 + src/tools/qcom_p.h | 344 + src/tools/qcomlibrary.cpp | 538 ++ src/tools/qcomlibrary_p.h | 82 + src/tools/qcomponentfactory.cpp | 355 + src/tools/qcomponentfactory_p.h | 76 + src/tools/qconfig-dist.h | 11 + src/tools/qconfig-large.h | 42 + src/tools/qconfig-medium.h | 108 + src/tools/qconfig-minimal.h | 97 + src/tools/qconfig-small.h | 94 + src/tools/qcriticalsection_p.cpp | 76 + src/tools/qcriticalsection_p.h | 83 + src/tools/qcstring.cpp | 2539 +++++++ src/tools/qcstring.h | 392 ++ src/tools/qdatastream.cpp | 1170 ++++ src/tools/qdatastream.h | 193 + src/tools/qdatetime.cpp | 2600 +++++++ src/tools/qdatetime.h | 253 + src/tools/qdeepcopy.cpp | 168 + src/tools/qdeepcopy.h | 80 + src/tools/qdict.h | 123 + src/tools/qdir.cpp | 1390 ++++ src/tools/qdir.h | 250 + src/tools/qdir_p.h | 82 + src/tools/qdir_unix.cpp | 325 + src/tools/qfeatures.h | 994 +++ src/tools/qfeatures.txt | 1314 ++++ src/tools/qfile.cpp | 747 ++ src/tools/qfile.h | 131 + src/tools/qfile_unix.cpp | 746 ++ src/tools/qfiledefs_p.h | 67 + src/tools/qfileinfo.cpp | 710 ++ src/tools/qfileinfo.h | 157 + src/tools/qfileinfo_unix.cpp | 400 ++ src/tools/qgarray.cpp | 830 +++ src/tools/qgarray.h | 134 + src/tools/qgcache.cpp | 866 +++ src/tools/qgcache.h | 131 + src/tools/qgdict.cpp | 1151 ++++ src/tools/qgdict.h | 225 + src/tools/qgeneric.h | 46 + src/tools/qglist.cpp | 1267 ++++ src/tools/qglist.h | 271 + src/tools/qglobal.cpp | 927 +++ src/tools/qglobal.h | 1137 ++++ src/tools/qgpluginmanager.cpp | 550 ++ src/tools/qgpluginmanager_p.h | 110 + src/tools/qgvector.cpp | 598 ++ src/tools/qgvector.h | 124 + src/tools/qintcache.h | 124 + src/tools/qintdict.h | 119 + src/tools/qiodevice.cpp | 763 +++ src/tools/qiodevice.h | 164 + src/tools/qlibrary.cpp | 443 ++ src/tools/qlibrary.h | 86 + src/tools/qlibrary_p.h | 84 + src/tools/qlibrary_unix.cpp | 169 + src/tools/qlocale.cpp | 6322 +++++++++++++++++ src/tools/qlocale.h | 494 ++ src/tools/qlocale_p.h | 131 + src/tools/qmap.cpp | 257 + src/tools/qmap.h | 877 +++ src/tools/qmemarray.h | 121 + src/tools/qmutex.h | 114 + src/tools/qmutex_p.h | 73 + src/tools/qmutex_unix.cpp | 695 ++ src/tools/qmutexpool.cpp | 155 + src/tools/qmutexpool_p.h | 80 + src/tools/qpair.h | 109 + src/tools/qpluginmanager_p.h | 76 + src/tools/qptrcollection.cpp | 183 + src/tools/qptrcollection.h | 80 + src/tools/qptrdict.h | 118 + src/tools/qptrlist.h | 195 + src/tools/qptrqueue.h | 94 + src/tools/qptrstack.h | 94 + src/tools/qptrvector.h | 118 + src/tools/qregexp.cpp | 3996 +++++++++++ src/tools/qregexp.h | 120 + src/tools/qsemaphore.cpp | 255 + src/tools/qsemaphore.h | 81 + src/tools/qsettings.cpp | 2105 ++++++ src/tools/qsettings.h | 159 + src/tools/qsettings_p.h | 148 + src/tools/qshared.h | 58 + src/tools/qsortedlist.h | 63 + src/tools/qstring.cpp | 7179 +++++++++++++++++++ src/tools/qstring.h | 1115 +++ src/tools/qstringlist.cpp | 467 ++ src/tools/qstringlist.h | 106 + src/tools/qstrlist.h | 109 + src/tools/qstrvec.h | 85 + src/tools/qt_tools.pri | 150 + src/tools/qtextstream.cpp | 2609 +++++++ src/tools/qtextstream.h | 338 + src/tools/qthreadinstance_p.h | 101 + src/tools/qthreadstorage.h | 95 + src/tools/qthreadstorage_unix.cpp | 349 + src/tools/qtl.h | 325 + src/tools/qucom.cpp | 547 ++ src/tools/qucom_p.h | 470 ++ src/tools/qunicodetables.cpp | 13240 ++++++++++++++++++++++++++++++++++++ src/tools/qunicodetables_p.h | 266 + src/tools/quuid.cpp | 421 ++ src/tools/quuid.h | 194 + src/tools/qvaluelist.h | 670 ++ src/tools/qvaluestack.h | 67 + src/tools/qvaluevector.h | 577 ++ src/tools/qwaitcondition.h | 79 + src/tools/qwaitcondition_unix.cpp | 316 + src/tools/qwinexport.cpp | 31 + src/tools/qwinexport.h | 224 + 120 files changed, 76491 insertions(+) create mode 100644 src/tools/qasciicache.h create mode 100644 src/tools/qasciidict.h create mode 100644 src/tools/qbitarray.cpp create mode 100644 src/tools/qbitarray.h create mode 100644 src/tools/qbuffer.cpp create mode 100644 src/tools/qbuffer.h create mode 100644 src/tools/qcache.h create mode 100644 src/tools/qcleanuphandler.h create mode 100644 src/tools/qcom_p.h create mode 100644 src/tools/qcomlibrary.cpp create mode 100644 src/tools/qcomlibrary_p.h create mode 100644 src/tools/qcomponentfactory.cpp create mode 100644 src/tools/qcomponentfactory_p.h create mode 100644 src/tools/qconfig-dist.h create mode 100644 src/tools/qconfig-large.h create mode 100644 src/tools/qconfig-medium.h create mode 100644 src/tools/qconfig-minimal.h create mode 100644 src/tools/qconfig-small.h create mode 100644 src/tools/qcriticalsection_p.cpp create mode 100644 src/tools/qcriticalsection_p.h create mode 100644 src/tools/qcstring.cpp create mode 100644 src/tools/qcstring.h create mode 100644 src/tools/qdatastream.cpp create mode 100644 src/tools/qdatastream.h create mode 100644 src/tools/qdatetime.cpp create mode 100644 src/tools/qdatetime.h create mode 100644 src/tools/qdeepcopy.cpp create mode 100644 src/tools/qdeepcopy.h create mode 100644 src/tools/qdict.h create mode 100644 src/tools/qdir.cpp create mode 100644 src/tools/qdir.h create mode 100644 src/tools/qdir_p.h create mode 100644 src/tools/qdir_unix.cpp create mode 100644 src/tools/qfeatures.h create mode 100644 src/tools/qfeatures.txt create mode 100644 src/tools/qfile.cpp create mode 100644 src/tools/qfile.h create mode 100644 src/tools/qfile_unix.cpp create mode 100644 src/tools/qfiledefs_p.h create mode 100644 src/tools/qfileinfo.cpp create mode 100644 src/tools/qfileinfo.h create mode 100644 src/tools/qfileinfo_unix.cpp create mode 100644 src/tools/qgarray.cpp create mode 100644 src/tools/qgarray.h create mode 100644 src/tools/qgcache.cpp create mode 100644 src/tools/qgcache.h create mode 100644 src/tools/qgdict.cpp create mode 100644 src/tools/qgdict.h create mode 100644 src/tools/qgeneric.h create mode 100644 src/tools/qglist.cpp create mode 100644 src/tools/qglist.h create mode 100644 src/tools/qglobal.cpp create mode 100644 src/tools/qglobal.h create mode 100644 src/tools/qgpluginmanager.cpp create mode 100644 src/tools/qgpluginmanager_p.h create mode 100644 src/tools/qgvector.cpp create mode 100644 src/tools/qgvector.h create mode 100644 src/tools/qintcache.h create mode 100644 src/tools/qintdict.h create mode 100644 src/tools/qiodevice.cpp create mode 100644 src/tools/qiodevice.h create mode 100644 src/tools/qlibrary.cpp create mode 100644 src/tools/qlibrary.h create mode 100644 src/tools/qlibrary_p.h create mode 100644 src/tools/qlibrary_unix.cpp create mode 100644 src/tools/qlocale.cpp create mode 100644 src/tools/qlocale.h create mode 100644 src/tools/qlocale_p.h create mode 100644 src/tools/qmap.cpp create mode 100644 src/tools/qmap.h create mode 100644 src/tools/qmemarray.h create mode 100644 src/tools/qmutex.h create mode 100644 src/tools/qmutex_p.h create mode 100644 src/tools/qmutex_unix.cpp create mode 100644 src/tools/qmutexpool.cpp create mode 100644 src/tools/qmutexpool_p.h create mode 100644 src/tools/qpair.h create mode 100644 src/tools/qpluginmanager_p.h create mode 100644 src/tools/qptrcollection.cpp create mode 100644 src/tools/qptrcollection.h create mode 100644 src/tools/qptrdict.h create mode 100644 src/tools/qptrlist.h create mode 100644 src/tools/qptrqueue.h create mode 100644 src/tools/qptrstack.h create mode 100644 src/tools/qptrvector.h create mode 100644 src/tools/qregexp.cpp create mode 100644 src/tools/qregexp.h create mode 100644 src/tools/qsemaphore.cpp create mode 100644 src/tools/qsemaphore.h create mode 100644 src/tools/qsettings.cpp create mode 100644 src/tools/qsettings.h create mode 100644 src/tools/qsettings_p.h create mode 100644 src/tools/qshared.h create mode 100644 src/tools/qsortedlist.h create mode 100644 src/tools/qstring.cpp create mode 100644 src/tools/qstring.h create mode 100644 src/tools/qstringlist.cpp create mode 100644 src/tools/qstringlist.h create mode 100644 src/tools/qstrlist.h create mode 100644 src/tools/qstrvec.h create mode 100644 src/tools/qt_tools.pri create mode 100644 src/tools/qtextstream.cpp create mode 100644 src/tools/qtextstream.h create mode 100644 src/tools/qthreadinstance_p.h create mode 100644 src/tools/qthreadstorage.h create mode 100644 src/tools/qthreadstorage_unix.cpp create mode 100644 src/tools/qtl.h create mode 100644 src/tools/qucom.cpp create mode 100644 src/tools/qucom_p.h create mode 100644 src/tools/qunicodetables.cpp create mode 100644 src/tools/qunicodetables_p.h create mode 100644 src/tools/quuid.cpp create mode 100644 src/tools/quuid.h create mode 100644 src/tools/qvaluelist.h create mode 100644 src/tools/qvaluestack.h create mode 100644 src/tools/qvaluevector.h create mode 100644 src/tools/qwaitcondition.h create mode 100644 src/tools/qwaitcondition_unix.cpp create mode 100644 src/tools/qwinexport.cpp create mode 100644 src/tools/qwinexport.h (limited to 'src/tools') diff --git a/src/tools/qasciicache.h b/src/tools/qasciicache.h new file mode 100644 index 000000000..4ad8c2291 --- /dev/null +++ b/src/tools/qasciicache.h @@ -0,0 +1,125 @@ +/**************************************************************************** +** +** Definition of TQAsciiCache template/macro class +** +** Created : 950209 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQASCIICACHE_H +#define TQASCIICACHE_H + +#ifndef QT_H +#include "qgcache.h" +#endif // QT_H + + +template +class TQAsciiCache +#ifdef Q_QDOC + : public TQPtrCollection +#else + : public TQGCache +#endif +{ +public: + TQAsciiCache( const TQAsciiCache &c ) : TQGCache(c) {} + TQAsciiCache( int maxCost=100, int size=17, bool caseSensitive=TRUE, + bool copyKeys=TRUE ) + : TQGCache( maxCost, size, AsciiKey, caseSensitive, copyKeys ) {} + ~TQAsciiCache() { clear(); } + TQAsciiCache &operator=( const TQAsciiCache &c ) + { return (TQAsciiCache&)TQGCache::operator=(c); } + int maxCost() const { return TQGCache::maxCost(); } + int totalCost() const { return TQGCache::totalCost(); } + void setMaxCost( int m ) { TQGCache::setMaxCost(m); } + uint count() const { return TQGCache::count(); } + uint size() const { return TQGCache::size(); } + bool isEmpty() const { return TQGCache::count() == 0; } + void clear() { TQGCache::clear(); } + bool insert( const char *k, const type *d, int c=1, int p=0 ) + { return TQGCache::insert_other(k,(Item)d,c,p);} + bool remove( const char *k ) + { return TQGCache::remove_other(k); } + type *take( const char *k ) + { return (type *)TQGCache::take_other(k); } + type *find( const char *k, bool ref=TRUE ) const + { return (type *)TQGCache::find_other(k,ref);} + type *operator[]( const char *k ) const + { return (type *)TQGCache::find_other(k);} + void statistics() const { TQGCache::statistics(); } +private: + void deleteItem( Item d ); +}; + +#if !defined(Q_BROKEN_TEMPLATE_SPECIALIZATION) +template<> inline void TQAsciiCache::deleteItem( TQPtrCollection::Item ) +{ +} +#endif + +template inline void TQAsciiCache::deleteItem( TQPtrCollection::Item d ) +{ + if ( del_item ) delete (type *)d; +} + + +template +class TQAsciiCacheIterator : public TQGCacheIterator +{ +public: + TQAsciiCacheIterator( const TQAsciiCache &c ):TQGCacheIterator((TQGCache &)c) {} + TQAsciiCacheIterator( const TQAsciiCacheIterator &ci) + : TQGCacheIterator( (TQGCacheIterator &)ci ) {} + TQAsciiCacheIterator &operator=(const TQAsciiCacheIterator&ci) + { return ( TQAsciiCacheIterator&)TQGCacheIterator::operator=( ci ); } + uint count() const { return TQGCacheIterator::count(); } + bool isEmpty() const { return TQGCacheIterator::count() == 0; } + bool atFirst() const { return TQGCacheIterator::atFirst(); } + bool atLast() const { return TQGCacheIterator::atLast(); } + type *toFirst() { return (type *)TQGCacheIterator::toFirst(); } + type *toLast() { return (type *)TQGCacheIterator::toLast(); } + operator type *() const { return (type *)TQGCacheIterator::get(); } + type *current() const { return (type *)TQGCacheIterator::get(); } + const char *currentKey() const { return TQGCacheIterator::getKeyAscii(); } + type *operator()() { return (type *)TQGCacheIterator::operator()();} + type *operator++() { return (type *)TQGCacheIterator::operator++(); } + type *operator+=(uint j) { return (type *)TQGCacheIterator::operator+=(j);} + type *operator--() { return (type *)TQGCacheIterator::operator--(); } + type *operator-=(uint j) { return (type *)TQGCacheIterator::operator-=(j);} +}; + + +#endif // TQASCIICACHE_H diff --git a/src/tools/qasciidict.h b/src/tools/qasciidict.h new file mode 100644 index 000000000..df2888ada --- /dev/null +++ b/src/tools/qasciidict.h @@ -0,0 +1,123 @@ +/**************************************************************************** +** +** Definition of TQAsciiDict template class +** +** Created : 920821 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQASCIIDICT_H +#define TQASCIIDICT_H + +#ifndef QT_H +#include "qgdict.h" +#endif // QT_H + +template +class TQAsciiDict +#ifdef Q_QDOC + : public TQPtrCollection +#else + : public TQGDict +#endif +{ +public: + TQAsciiDict(int size=17, bool caseSensitive=TRUE, bool copyKeys=TRUE ) + : TQGDict(size,AsciiKey,caseSensitive,copyKeys) {} + TQAsciiDict( const TQAsciiDict &d ) : TQGDict(d) {} + ~TQAsciiDict() { clear(); } + TQAsciiDict &operator=(const TQAsciiDict &d) + { return (TQAsciiDict&)TQGDict::operator=(d); } + uint count() const { return TQGDict::count(); } + uint size() const { return TQGDict::size(); } + bool isEmpty() const { return TQGDict::count() == 0; } + + void insert( const char *k, const type *d ) + { TQGDict::look_ascii(k,(Item)d,1); } + void replace( const char *k, const type *d ) + { TQGDict::look_ascii(k,(Item)d,2); } + bool remove( const char *k ) { return TQGDict::remove_ascii(k); } + type *take( const char *k ) { return (type *)TQGDict::take_ascii(k); } + type *find( const char *k ) const + { return (type *)((TQGDict*)this)->TQGDict::look_ascii(k,0,0); } + type *operator[]( const char *k ) const + { return (type *)((TQGDict*)this)->TQGDict::look_ascii(k,0,0); } + + void clear() { TQGDict::clear(); } + void resize( uint n ) { TQGDict::resize(n); } + void statistics() const { TQGDict::statistics(); } + +#ifdef Q_QDOC +protected: + virtual TQDataStream& read( TQDataStream &, TQPtrCollection::Item & ); + virtual TQDataStream& write( TQDataStream &, TQPtrCollection::Item ) const; +#endif + +private: + void deleteItem( Item d ); +}; + +#if !defined(Q_BROKEN_TEMPLATE_SPECIALIZATION) +template<> inline void TQAsciiDict::deleteItem( TQPtrCollection::Item ) +{ +} +#endif + +template inline void TQAsciiDict::deleteItem( TQPtrCollection::Item d ) +{ + if ( del_item ) delete (type *)d; +} + +template +class TQAsciiDictIterator : public TQGDictIterator +{ +public: + TQAsciiDictIterator(const TQAsciiDict &d) + : TQGDictIterator((TQGDict &)d) {} + ~TQAsciiDictIterator() {} + uint count() const { return dict->count(); } + bool isEmpty() const { return dict->count() == 0; } + type *toFirst() { return (type *)TQGDictIterator::toFirst(); } + operator type *() const { return (type *)TQGDictIterator::get(); } + type *current() const { return (type *)TQGDictIterator::get(); } + const char *currentKey() const { return TQGDictIterator::getKeyAscii(); } + type *operator()() { return (type *)TQGDictIterator::operator()(); } + type *operator++() { return (type *)TQGDictIterator::operator++(); } + type *operator+=(uint j) { return (type *)TQGDictIterator::operator+=(j);} +}; + +#define Q_DEFINED_QASCIIDICT +#include "qwinexport.h" +#endif // TQASCIIDICT_H diff --git a/src/tools/qbitarray.cpp b/src/tools/qbitarray.cpp new file mode 100644 index 000000000..02a492d85 --- /dev/null +++ b/src/tools/qbitarray.cpp @@ -0,0 +1,665 @@ +/**************************************************************************** +** +** Implementation of TQBitArray class +** +** Created : 940118 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "qbitarray.h" +#include "qdatastream.h" + +#define SHBLOCK ((bitarr_data*)(sharedBlock())) + + +/*! + \class TQBitVal qbitarray.h + \reentrant + \brief The TQBitVal class is an internal class, used with TQBitArray. + + \ingroup collection + + The TQBitVal is retquired by the indexing [] operator on bit arrays. + It is not for use in any other context. +*/ + +/*! + \fn TQBitVal::TQBitVal (TQBitArray* a, uint i) + + Constructs a reference to element \a i in the TQBitArray \a a. + This is what TQBitArray::operator[] constructs its return value + with. +*/ + +/*! + \fn TQBitVal::operator int() + + Returns the value referenced by the TQBitVal. +*/ + +/*! + \fn TQBitVal& TQBitVal::operator= (const TQBitVal& v) + + Sets the value referenced by the TQBitVal to that referenced by + TQBitVal \a v. +*/ + +/*! + \overload TQBitVal& TQBitVal::operator= (bool v) + + Sets the value referenced by the TQBitVal to \a v. +*/ + + +/*! + \class TQBitArray qbitarray.h + \reentrant + \brief The TQBitArray class provides an array of bits. + + \ingroup collection + \ingroup tools + \ingroup shared + + Because TQBitArray is a TQMemArray, it uses explicit \link + shclass.html sharing\endlink with a reference count. + + A TQBitArray is a special byte array that can access individual + bits and perform bit-operations (AND, OR, XOR and NOT) on entire + arrays or bits. + + Bits can be manipulated by the setBit() and clearBit() functions, + but it is also possible to use the indexing [] operator to test + and set individual bits. The [] operator is a little slower than + setBit() and clearBit() because some tricks are retquired to + implement single-bit assignments. + + Example: + \code + TQBitArray a(3); + a.setBit( 0 ); + a.clearBit( 1 ); + a.setBit( 2 ); // a = [1 0 1] + + TQBitArray b(3); + b[0] = 1; + b[1] = 1; + b[2] = 0; // b = [1 1 0] + + TQBitArray c; + c = ~a & b; // c = [0 1 0] + \endcode + + When a TQBitArray is constructed the bits are uninitialized. Use + fill() to set all the bits to 0 or 1. The array can be resized + with resize() and copied with copy(). Bits can be set with + setBit() and cleared with clearBit(). Bits can be toggled with + toggleBit(). A bit's value can be obtained with testBit() and with + at(). + + TQBitArray supports the \& (AND), | (OR), ^ (XOR) and ~ (NOT) + operators. +*/ + +/*! \class TQBitArray::bitarr_data + \brief The TQBitArray::bitarr_data class is internal. + \internal +*/ + + +/*! + Constructs an empty bit array. +*/ + +TQBitArray::TQBitArray() : TQByteArray( 0, 0 ) +{ + bitarr_data *x = new bitarr_data; + Q_CHECK_PTR( x ); + x->nbits = 0; + setSharedBlock( x ); +} + +/*! + Constructs a bit array of \a size bits. The bits are uninitialized. + + \sa fill() +*/ + +TQBitArray::TQBitArray( uint size ) : TQByteArray( 0, 0 ) +{ + bitarr_data *x = new bitarr_data; + Q_CHECK_PTR( x ); + x->nbits = 0; + setSharedBlock( x ); + resize( size ); +} + +/*! + \fn TQBitArray::TQBitArray( const TQBitArray &a ) + + Constructs a shallow copy of \a a. +*/ + +/*! + \fn TQBitArray &TQBitArray::operator=( const TQBitArray &a ) + + Assigns a shallow copy of \a a to this bit array and returns a + reference to this array. +*/ + + +/*! + Pad last byte with 0-bits. +*/ +void TQBitArray::pad0() +{ + uint sz = size(); + if ( sz && sz%8 ) + *(data()+sz/8) &= (1 << (sz%8)) - 1; +} + + +/*! + \fn uint TQBitArray::size() const + + Returns the bit array's size (number of bits). + + \sa resize() +*/ + +/*! + Resizes the bit array to \a size bits and returns TRUE if the bit + array could be resized; otherwise returns FALSE. The array becomes + a null array if \a size == 0. + + If the array is expanded, the new bits are set to 0. + + \sa size() +*/ + +bool TQBitArray::resize( uint size ) +{ + uint s = this->size(); + if ( !TQByteArray::resize( (size+7)/8 ) ) + return FALSE; // cannot resize + SHBLOCK->nbits = size; + if ( size != 0 ) { // not null array + int ds = (int)(size+7)/8 - (int)(s+7)/8;// number of bytes difference + if ( ds > 0 ) // expanding array + memset( data() + (s+7)/8, 0, ds ); // reset new data + } + return TRUE; +} + + +/*! + Fills the bit array with \a v (1's if \a v is TRUE, or 0's if \a v + is FALSE). + + fill() resizes the bit array to \a size bits if \a size is + nonnegative. + + Returns FALSE if a nonnegative \e size was specified and the bit + array could not be resized; otherwise returns TRUE. + + \sa resize() +*/ + +bool TQBitArray::fill( bool v, int size ) +{ + if ( size >= 0 ) { // resize first + if ( !resize( size ) ) + return FALSE; // cannot resize + } else { + size = this->size(); + } + if ( size > 0 ) + memset( data(), v ? 0xff : 0, (size + 7) / 8 ); + if ( v ) + pad0(); + return TRUE; +} + + +/*! + Detaches from shared bit array data and makes sure that this bit + array is the only one referring to the data. + + If multiple bit arrays share common data, this bit array + dereferences the data and gets a copy of the data. Nothing happens + if there is only a single reference. + + \sa copy() +*/ + +void TQBitArray::detach() +{ + int nbits = SHBLOCK->nbits; + this->duplicate( *this ); + SHBLOCK->nbits = nbits; +} + +/*! + Returns a deep copy of the bit array. + + \sa detach() +*/ + +TQBitArray TQBitArray::copy() const +{ + TQBitArray tmp; + tmp.duplicate( *this ); + ((bitarr_data*)(tmp.sharedBlock()))->nbits = SHBLOCK->nbits; + return tmp; +} + + +/*! + Returns TRUE if the bit at position \a index is set, i.e. is 1; + otherwise returns FALSE. + + \sa setBit(), clearBit() +*/ + +bool TQBitArray::testBit( uint index ) const +{ +#if defined(QT_CHECK_RANGE) + if ( index >= size() ) { + qWarning( "TQBitArray::testBit: Index %d out of range", index ); + return FALSE; + } +#endif + return (*(data()+(index>>3)) & (1 << (index & 7))) != 0; +} + +/*! + \overload + + Sets the bit at position \a index to 1. + + \sa clearBit() toggleBit() +*/ + +void TQBitArray::setBit( uint index ) +{ +#if defined(QT_CHECK_RANGE) + if ( index >= size() ) { + qWarning( "TQBitArray::setBit: Index %d out of range", index ); + return; + } +#endif + *(data()+(index>>3)) |= (1 << (index & 7)); +} + +/*! + \fn void TQBitArray::setBit( uint index, bool value ) + + Sets the bit at position \a index to \a value. + + Equivalent to: + \code + if ( value ) + setBit( index ); + else + clearBit( index ); + \endcode + + \sa clearBit() toggleBit() +*/ + +/*! + Clears the bit at position \a index, i.e. sets it to 0. + + \sa setBit(), toggleBit() +*/ + +void TQBitArray::clearBit( uint index ) +{ +#if defined(QT_CHECK_RANGE) + if ( index >= size() ) { + qWarning( "TQBitArray::clearBit: Index %d out of range", index ); + return; + } +#endif + *(data()+(index>>3)) &= ~(1 << (index & 7)); +} + +/*! + Toggles the bit at position \a index. + + If the previous value was 0, the new value will be 1. If the + previous value was 1, the new value will be 0. + + \sa setBit(), clearBit() +*/ + +bool TQBitArray::toggleBit( uint index ) +{ +#if defined(QT_CHECK_RANGE) + if ( index >= size() ) { + qWarning( "TQBitArray::toggleBit: Index %d out of range", index ); + return FALSE; + } +#endif + register uchar *p = (uchar *)data() + (index>>3); + uchar b = (1 << (index & 7)); // bit position + uchar c = *p & b; // read bit + *p ^= b; // toggle bit + return c; +} + + +/*! + \fn bool TQBitArray::at( uint index ) const + + Returns the value (0 or 1) of the bit at position \a index. + + \sa operator[]() +*/ + +/*! + \fn TQBitVal TQBitArray::operator[]( int index ) + + Implements the [] operator for bit arrays. + + The returned TQBitVal is a context object. It makes it possible to + get and set a single bit value by its \a index position. + + Example: + \code + TQBitArray a( 3 ); + a[0] = 0; + a[1] = 1; + a[2] = a[0] ^ a[1]; + \endcode + + The functions testBit(), setBit() and clearBit() are faster. + + \sa at() +*/ + +/*! + \overload bool TQBitArray::operator[]( int index ) const + + Implements the [] operator for constant bit arrays. +*/ + + +/*! + Performs the AND operation between all bits in this bit array and + \a a. Returns a reference to this bit array. + + The result has the length of the longest of the two bit arrays, + with any missing bits (i.e. if one array is shorter than the + other), taken to be 0. + \code + TQBitArray a( 3 ), b( 2 ); + a[0] = 1; a[1] = 0; a[2] = 1; // a = [1 0 1] + b[0] = 1; b[1] = 0; // b = [1 0] + a &= b; // a = [1 0 0] + \endcode + + \sa operator|=(), operator^=(), operator~() +*/ + +TQBitArray &TQBitArray::operator&=( const TQBitArray &a ) +{ + resize( TQMAX(size(), a.size()) ); + register uchar *a1 = (uchar *)data(); + register uchar *a2 = (uchar *)a.data(); + int n = TQMIN( TQByteArray::size(), a.TQByteArray::size() ); + int p = TQMAX( TQByteArray::size(), a.TQByteArray::size() ) - n; + while ( n-- > 0 ) + *a1++ &= *a2++; + while ( p-- > 0 ) + *a1++ = 0; + return *this; +} + +/*! + Performs the OR operation between all bits in this bit array and + \a a. Returns a reference to this bit array. + + The result has the length of the longest of the two bit arrays, + with any missing bits (i.e. if one array is shorter than the + other), taken to be 0. + \code + TQBitArray a( 3 ), b( 2 ); + a[0] = 1; a[1] = 0; a[2] = 1; // a = [1 0 1] + b[0] = 1; b[1] = 0; // b = [1 0] + a |= b; // a = [1 0 1] + \endcode + + \sa operator&=(), operator^=(), operator~() +*/ + +TQBitArray &TQBitArray::operator|=( const TQBitArray &a ) +{ + resize( TQMAX(size(), a.size()) ); + register uchar *a1 = (uchar *)data(); + register uchar *a2 = (uchar *)a.data(); + int n = TQMIN( TQByteArray::size(), a.TQByteArray::size() ); + while ( n-- > 0 ) + *a1++ |= *a2++; + return *this; +} + +/*! + Performs the XOR operation between all bits in this bit array and + \a a. Returns a reference to this bit array. + + The result has the length of the longest of the two bit arrays, + with any missing bits (i.e. if one array is shorter than the + other), taken to be 0. + \code + TQBitArray a( 3 ), b( 2 ); + a[0] = 1; a[1] = 0; a[2] = 1; // a = [1 0 1] + b[0] = 1; b[1] = 0; // b = [1 0] + a ^= b; // a = [0 0 1] + \endcode + + \sa operator&=(), operator|=(), operator~() +*/ + +TQBitArray &TQBitArray::operator^=( const TQBitArray &a ) +{ + resize( TQMAX(size(), a.size()) ); + register uchar *a1 = (uchar *)data(); + register uchar *a2 = (uchar *)a.data(); + int n = TQMIN( TQByteArray::size(), a.TQByteArray::size() ); + while ( n-- > 0 ) + *a1++ ^= *a2++; + return *this; +} + +/*! + Returns a bit array that contains the inverted bits of this bit array. + + Example: + \code + TQBitArray a( 3 ), b; + a[0] = 1; a[1] = 0; a[2] = 1; // a = [1 0 1] + b = ~a; // b = [0 1 0] + \endcode +*/ + +TQBitArray TQBitArray::operator~() const +{ + TQBitArray a( size() ); + register uchar *a1 = (uchar *)data(); + register uchar *a2 = (uchar *)a.data(); + int n = TQByteArray::size(); + while ( n-- ) + *a2++ = ~*a1++; + a.pad0(); + return a; +} + + +/*! + \relates TQBitArray + + Returns the AND result between the bit arrays \a a1 and \a a2. + + The result has the length of the longest of the two bit arrays, + with any missing bits (i.e. if one array is shorter than the + other), taken to be 0. + + \sa TQBitArray::operator&=() +*/ + +TQBitArray operator&( const TQBitArray &a1, const TQBitArray &a2 ) +{ + TQBitArray tmp = a1.copy(); + tmp &= a2; + return tmp; +} + +/*! + \relates TQBitArray + + Returns the OR result between the bit arrays \a a1 and \a a2. + + The result has the length of the longest of the two bit arrays, + with any missing bits (i.e. if one array is shorter than the + other), taken to be 0. + + \sa TQBitArray::operator|=() +*/ + +TQBitArray operator|( const TQBitArray &a1, const TQBitArray &a2 ) +{ + TQBitArray tmp = a1.copy(); + tmp |= a2; + return tmp; +} + +/*! + \relates TQBitArray + + Returns the XOR result between the bit arrays \a a1 and \a a2. + + The result has the length of the longest of the two bit arrays, + with any missing bits (i.e. if one array is shorter than the + other), taken to be 0. + + \sa TQBitArray::operator^() +*/ + +TQBitArray operator^( const TQBitArray &a1, const TQBitArray &a2 ) +{ + TQBitArray tmp = a1.copy(); + tmp ^= a2; + return tmp; +} + + +/* \enum TQGArray::array_data + + \warning This will be renamed in the next major release of TQt. Until + then it is undocumented and we recommend against its use. + + \internal + + ### 3.0 rename ### + ### 3.0 move it to TQGArray? ### +*/ + + +/*! + \fn TQBitArray::array_data * TQBitArray::newData() + + \internal + + Returns data specific to TQBitArray that extends what TQGArray provides. + TQPtrCollection mechanism for allowing extra/different data. +*/ + + +/*! + \fn void TQBitArray::deleteData ( array_data * d ) + + \internal + + Deletes data specific to TQBitArray that extended what TQGArray provided. + + TQPtrCollection mechanism for allowing extra/different data. +*/ + + +/***************************************************************************** + TQBitArray stream functions + *****************************************************************************/ + +/*! + \relates TQBitArray + + Writes bit array \a a to stream \a s. + + \sa \link datastreamformat.html Format of the TQDataStream operators \endlink +*/ +#ifndef QT_NO_DATASTREAM +TQDataStream &operator<<( TQDataStream &s, const TQBitArray &a ) +{ + Q_UINT32 len = a.size(); + s << len; // write size of array + if ( len > 0 ) // write data + s.writeRawBytes( a.data(), a.TQByteArray::size() ); + return s; +} + +/*! + \relates TQBitArray + + Reads a bit array into \a a from stream \a s. + + \sa \link datastreamformat.html Format of the TQDataStream operators \endlink +*/ + +TQDataStream &operator>>( TQDataStream &s, TQBitArray &a ) +{ + Q_UINT32 len; + s >> len; // read size of array + if ( !a.resize( (uint)len ) ) { // resize array +#if defined(QT_CHECK_NULL) + qWarning( "TQDataStream: Not enough memory to read TQBitArray" ); +#endif + len = 0; + } + if ( len > 0 ) // read data + s.readRawBytes( a.data(), a.TQByteArray::size() ); + return s; +} + +#endif // QT_NO_DATASTREAM diff --git a/src/tools/qbitarray.h b/src/tools/qbitarray.h new file mode 100644 index 000000000..88e6f8df3 --- /dev/null +++ b/src/tools/qbitarray.h @@ -0,0 +1,169 @@ +/**************************************************************************** +** +** Definition of TQBitArray class +** +** Created : 940118 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQBITARRAY_H +#define TQBITARRAY_H + +#ifndef QT_H +#include "qstring.h" +#endif // QT_H + + +/***************************************************************************** + TQBitVal class; a context class for TQBitArray::operator[] + *****************************************************************************/ + +class TQBitArray; + +class Q_EXPORT TQBitVal +{ +private: + TQBitArray *array; + uint index; +public: + TQBitVal( TQBitArray *a, uint i ) : array(a), index(i) {} + operator int(); + TQBitVal &operator=( const TQBitVal &v ); + TQBitVal &operator=( bool v ); +}; + + +/***************************************************************************** + TQBitArray class + *****************************************************************************/ + +class Q_EXPORT TQBitArray : public TQByteArray +{ +public: + TQBitArray(); + TQBitArray( uint size ); + TQBitArray( const TQBitArray &a ) : TQByteArray( a ) {} + + TQBitArray &operator=( const TQBitArray & ); + + uint size() const; + bool resize( uint size ); + + bool fill( bool v, int size = -1 ); + + void detach(); + TQBitArray copy() const; + + bool testBit( uint index ) const; + void setBit( uint index ); + void setBit( uint index, bool value ); + void clearBit( uint index ); + bool toggleBit( uint index ); + + bool at( uint index ) const; + TQBitVal operator[]( int index ); + bool operator[]( int index ) const; + + TQBitArray &operator&=( const TQBitArray & ); + TQBitArray &operator|=( const TQBitArray & ); + TQBitArray &operator^=( const TQBitArray & ); + TQBitArray operator~() const; + +protected: + struct bitarr_data : public TQGArray::array_data { + uint nbits; + }; + array_data *newData() { return new bitarr_data; } + void deleteData( array_data *d ) { delete (bitarr_data*)d; } +private: + void pad0(); +}; + + +inline TQBitArray &TQBitArray::operator=( const TQBitArray &a ) +{ return (TQBitArray&)assign( a ); } + +inline uint TQBitArray::size() const +{ return ((bitarr_data*)sharedBlock())->nbits; } + +inline void TQBitArray::setBit( uint index, bool value ) +{ if ( value ) setBit(index); else clearBit(index); } + +inline bool TQBitArray::at( uint index ) const +{ return testBit(index); } + +inline TQBitVal TQBitArray::operator[]( int index ) +{ return TQBitVal( (TQBitArray*)this, index ); } + +inline bool TQBitArray::operator[]( int index ) const +{ return testBit( index ); } + + +/***************************************************************************** + Misc. TQBitArray operator functions + *****************************************************************************/ + +Q_EXPORT TQBitArray operator&( const TQBitArray &, const TQBitArray & ); +Q_EXPORT TQBitArray operator|( const TQBitArray &, const TQBitArray & ); +Q_EXPORT TQBitArray operator^( const TQBitArray &, const TQBitArray & ); + + +inline TQBitVal::operator int() +{ + return array->testBit( index ); +} + +inline TQBitVal &TQBitVal::operator=( const TQBitVal &v ) +{ + array->setBit( index, v.array->testBit(v.index) ); + return *this; +} + +inline TQBitVal &TQBitVal::operator=( bool v ) +{ + array->setBit( index, v ); + return *this; +} + + +/***************************************************************************** + TQBitArray stream functions + *****************************************************************************/ +#ifndef QT_NO_DATASTREAM +Q_EXPORT TQDataStream &operator<<( TQDataStream &, const TQBitArray & ); +Q_EXPORT TQDataStream &operator>>( TQDataStream &, TQBitArray & ); +#endif + +#endif // TQBITARRAY_H diff --git a/src/tools/qbuffer.cpp b/src/tools/qbuffer.cpp new file mode 100644 index 000000000..4fc48648c --- /dev/null +++ b/src/tools/qbuffer.cpp @@ -0,0 +1,498 @@ +/**************************************************************************** +** +** Implementation of TQBuffer class +** +** Created : 930812 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "qbuffer.h" +#include + +/*! + \class TQBuffer qbuffer.h + \reentrant + \brief The TQBuffer class is an I/O device that operates on a TQByteArray. + + \ingroup io + \ingroup collection + + TQBuffer is used to read and write to a memory buffer. It is + normally used with a TQTextStream or a TQDataStream. TQBuffer has an + associated TQByteArray which holds the buffer data. The size() of + the buffer is automatically adjusted as data is written. + + The constructor \c TQBuffer(TQByteArray) creates a TQBuffer using an + existing byte array. The byte array can also be set with + setBuffer(). Writing to the TQBuffer will modify the original byte + array because TQByteArray is \link shclass.html explicitly + shared.\endlink + + Use open() to open the buffer before use and to set the mode + (read-only, write-only, etc.). close() closes the buffer. The + buffer must be closed before reopening or calling setBuffer(). + + A common way to use TQBuffer is through \l TQDataStream or \l + TQTextStream, which have constructors that take a TQBuffer + parameter. For convenience, there are also TQDataStream and + TQTextStream constructors that take a TQByteArray parameter. These + constructors create and open an internal TQBuffer. + + Note that TQTextStream can also operate on a TQString (a Unicode + string); a TQBuffer cannot. + + You can also use TQBuffer directly through the standard TQIODevice + functions readBlock(), writeBlock() readLine(), at(), getch(), + putch() and ungetch(). + + \sa TQFile, TQDataStream, TQTextStream, TQByteArray, \link shclass.html Shared Classes\endlink +*/ + + +/*! + Constructs an empty buffer. +*/ + +TQBuffer::TQBuffer() +{ + setFlags( IO_Direct ); + a_inc = 16; // initial increment + a_len = 0; + ioIndex = 0; +} + + +/*! + Constructs a buffer that operates on \a buf. + + If you open the buffer in write mode (\c IO_WriteOnly or + \c IO_ReadWrite) and write something into the buffer, \a buf + will be modified. + + Example: + \code + TQCString str = "abc"; + TQBuffer b( str ); + b.open( IO_WriteOnly ); + b.at( 3 ); // position at the 4th character (the terminating \0) + b.writeBlock( "def", 4 ); // write "def" including the terminating \0 + b.close(); + // Now, str == "abcdef" with a terminating \0 + \endcode + + \sa setBuffer() +*/ + +TQBuffer::TQBuffer( TQByteArray buf ) : a(buf) +{ + setFlags( IO_Direct ); + a_len = a.size(); + a_inc = (a_len > 512) ? 512 : a_len; // initial increment + if ( a_inc < 16 ) + a_inc = 16; + ioIndex = 0; +} + +/*! + Destroys the buffer. +*/ + +TQBuffer::~TQBuffer() +{ +} + + +/*! + Replaces the buffer's contents with \a buf and returns TRUE. + + Does nothing (and returns FALSE) if isOpen() is TRUE. + + Note that if you open the buffer in write mode (\c IO_WriteOnly or + IO_ReadWrite) and write something into the buffer, \a buf is also + modified because TQByteArray is an explicitly shared class. + + \sa buffer(), open(), close() +*/ + +bool TQBuffer::setBuffer( TQByteArray buf ) +{ + if ( isOpen() ) { +#if defined(QT_CHECK_STATE) + qWarning( "TQBuffer::setBuffer: Buffer is open" ); +#endif + return FALSE; + } + a = buf; + a_len = a.size(); + a_inc = (a_len > 512) ? 512 : a_len; // initial increment + if ( a_inc < 16 ) + a_inc = 16; + ioIndex = 0; + return TRUE; +} + +/*! + \fn TQByteArray TQBuffer::buffer() const + + Returns this buffer's byte array. + + \sa setBuffer() +*/ + +/*! + \reimp + + Opens the buffer in mode \a m. Returns TRUE if successful; + otherwise returns FALSE. The buffer must be opened before use. + + The mode parameter \a m must be a combination of the following flags. + \list + \i \c IO_ReadOnly opens the buffer in read-only mode. + \i \c IO_WriteOnly opens the buffer in write-only mode. + \i \c IO_ReadWrite opens the buffer in read/write mode. + \i \c IO_Append sets the buffer index to the end of the buffer. + \i \c IO_Truncate truncates the buffer. + \endlist + + \sa close(), isOpen() +*/ + +bool TQBuffer::open( int m ) +{ + if ( isOpen() ) { // buffer already open +#if defined(QT_CHECK_STATE) + qWarning( "TQBuffer::open: Buffer already open" ); +#endif + return FALSE; + } + setMode( m ); + if ( m & IO_Truncate ) { // truncate buffer + a.resize( 0 ); + a_len = 0; + } + if ( m & IO_Append ) { // append to end of buffer + ioIndex = a.size(); + } else { + ioIndex = 0; + } + a_inc = 16; + setState( IO_Open ); + resetStatus(); + return TRUE; +} + +/*! + \reimp + + Closes an open buffer. + + \sa open() +*/ + +void TQBuffer::close() +{ + if ( isOpen() ) { + setFlags( IO_Direct ); + ioIndex = 0; + a_inc = 16; + } +} + +/*! + \reimp + + The flush function does nothing for a TQBuffer. +*/ + +void TQBuffer::flush() +{ + return; +} + + +/*! + \fn TQIODevice::Offset TQBuffer::at() const + + \reimp +*/ + +/*! + \fn TQIODevice::Offset TQBuffer::size() const + + \reimp +*/ + +/*! + \reimp +*/ + +bool TQBuffer::at( Offset pos ) +{ +#if defined(QT_CHECK_STATE) + if ( !isOpen() ) { + qWarning( "TQBuffer::at: Buffer is not open" ); + return FALSE; + } +#endif + if ( pos > a_len ) { +#if defined(QT_CHECK_RANGE) +#if defined(QT_ABI_QT4) + qWarning( "TQBuffer::at: Index %lld out of range", pos ); +#else + qWarning( "TQBuffer::at: Index %lu out of range", pos ); +#endif +#endif + return FALSE; + } + ioIndex = pos; + return TRUE; +} + + +/*! + \reimp +*/ + +Q_LONG TQBuffer::readBlock( char *p, Q_ULONG len ) +{ +#if defined(QT_CHECK_STATE) + if ( !p ) { + qWarning( "TQBuffer::readBlock: Null pointer error" ); + return -1; + } + if ( !isOpen() ) { // buffer not open + qWarning( "TQBuffer::readBlock: Buffer not open" ); + return -1; + } + if ( !isReadable() ) { // reading not permitted + qWarning( "TQBuffer::readBlock: Read operation not permitted" ); + return -1; + } +#endif + if ( ioIndex + len > a.size() ) { // overflow + if ( ioIndex >= a.size() ) { + return 0; + } else { + len = a.size() - ioIndex; + } + } + memcpy(p, a.data() + ioIndex, len); + ioIndex += len; + return len; +} + +/*! + \overload Q_LONG TQBuffer::writeBlock( const TQByteArray& data ) + + This convenience function is the same as calling + \c{writeBlock( data.data(), data.size() )} with \a data. +*/ + +/*! + Writes \a len bytes from \a p into the buffer at the current + index position, overwriting any characters there and extending the + buffer if necessary. Returns the number of bytes actually written. + + Returns -1 if an error occurred. + + \sa readBlock() +*/ + +Q_LONG TQBuffer::writeBlock( const char *p, Q_ULONG len ) +{ + if ( len == 0 ) + return 0; + +#if defined(QT_CHECK_NULL) + if ( p == 0 ) { + qWarning( "TQBuffer::writeBlock: Null pointer error" ); + return -1; + } +#endif +#if defined(QT_CHECK_STATE) + if ( !isOpen() ) { // buffer not open + qWarning( "TQBuffer::writeBlock: Buffer not open" ); + return -1; + } + if ( !isWritable() ) { // writing not permitted + qWarning( "TQBuffer::writeBlock: Write operation not permitted" ); + return -1; + } +#endif + if ( ioIndex + len > a_len ) { // overflow + Q_ULONG new_len = a_len + a_inc*((ioIndex+len-a_len)/a_inc+1); + if ( !a.resize( new_len ) ) { // could not resize +#if defined(QT_CHECK_NULL) + qWarning( "TQBuffer::writeBlock: Memory allocation error" ); +#endif + setStatus( IO_ResourceError ); + return -1; + } + a_inc *= 2; // double increment + a_len = new_len; + a.shd->len = ioIndex + len; + } + memcpy( a.data()+ioIndex, p, len ); + ioIndex += len; + if ( a.shd->len < ioIndex ) + a.shd->len = ioIndex; // fake (not alloc'd) length + return len; +} + + +/*! + \reimp +*/ + +Q_LONG TQBuffer::readLine( char *p, Q_ULONG maxlen ) +{ +#if defined(QT_CHECK_NULL) + if ( p == 0 ) { + qWarning( "TQBuffer::readLine: Null pointer error" ); + return -1; + } +#endif +#if defined(QT_CHECK_STATE) + if ( !isOpen() ) { // buffer not open + qWarning( "TQBuffer::readLine: Buffer not open" ); + return -1; + } + if ( !isReadable() ) { // reading not permitted + qWarning( "TQBuffer::readLine: Read operation not permitted" ); + return -1; + } +#endif + if ( maxlen == 0 ) + return 0; + Q_ULONG start = ioIndex; + char *d = a.data() + ioIndex; + maxlen--; // make room for 0-terminator + if ( a.size() - ioIndex < maxlen ) + maxlen = a.size() - ioIndex; + while ( maxlen-- ) { + if ( (*p++ = *d++) == '\n' ) + break; + } + *p = '\0'; + ioIndex = d - a.data(); + return ioIndex - start; +} + + +/*! + \reimp +*/ + +int TQBuffer::getch() +{ +#if defined(QT_CHECK_STATE) + if ( !isOpen() ) { // buffer not open + qWarning( "TQBuffer::getch: Buffer not open" ); + return -1; + } + if ( !isReadable() ) { // reading not permitted + qWarning( "TQBuffer::getch: Read operation not permitted" ); + return -1; + } +#endif + if ( ioIndex+1 > a.size() ) { // overflow + setStatus( IO_ReadError ); + return -1; + } + return uchar(*(a.data()+ioIndex++)); +} + +/*! + \reimp + + Writes the character \a ch into the buffer at the current index + position, overwriting any existing character and extending the + buffer if necessary. + + Returns \a ch, or -1 if an error occurred. + + \sa getch(), ungetch() +*/ + +int TQBuffer::putch( int ch ) +{ +#if defined(QT_CHECK_STATE) + if ( !isOpen() ) { // buffer not open + qWarning( "TQBuffer::putch: Buffer not open" ); + return -1; + } + if ( !isWritable() ) { // writing not permitted + qWarning( "TQBuffer::putch: Write operation not permitted" ); + return -1; + } +#endif + if ( ioIndex + 1 > a_len ) { // overflow + char buf[1]; + buf[0] = (char)ch; + if ( writeBlock(buf,1) != 1 ) + return -1; // write error + } else { + *(a.data() + ioIndex++) = (char)ch; + if ( a.shd->len < ioIndex ) + a.shd->len = ioIndex; + } + return ch; +} + +/*! + \reimp +*/ + +int TQBuffer::ungetch( int ch ) +{ +#if defined(QT_CHECK_STATE) + if ( !isOpen() ) { // buffer not open + qWarning( "TQBuffer::ungetch: Buffer not open" ); + return -1; + } + if ( !isReadable() ) { // reading not permitted + qWarning( "TQBuffer::ungetch: Read operation not permitted" ); + return -1; + } +#endif + if ( ch != -1 ) { + if ( ioIndex ) + ioIndex--; + else + ch = -1; + } + return ch; +} + diff --git a/src/tools/qbuffer.h b/src/tools/qbuffer.h new file mode 100644 index 000000000..7f5e5c8ee --- /dev/null +++ b/src/tools/qbuffer.h @@ -0,0 +1,103 @@ +/**************************************************************************** +** +** Definition of TQBuffer class +** +** Created : 930812 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQBUFFER_H +#define TQBUFFER_H + +#ifndef QT_H +#include "qiodevice.h" +#include "qstring.h" +#endif // QT_H + + +class Q_EXPORT TQBuffer : public TQIODevice +{ +public: + TQBuffer(); + TQBuffer( TQByteArray ); + ~TQBuffer(); + + TQByteArray buffer() const; + bool setBuffer( TQByteArray ); + + bool open( int ); + void close(); + void flush(); + + Offset size() const; + Offset at() const; + bool at( Offset ); + + Q_LONG readBlock( char *p, Q_ULONG ); + Q_LONG writeBlock( const char *p, Q_ULONG ); + Q_LONG writeBlock( const TQByteArray& data ) + { return TQIODevice::writeBlock(data); } + Q_LONG readLine( char *p, Q_ULONG ); + + int getch(); + int putch( int ); + int ungetch( int ); + +protected: + TQByteArray a; + +private: + uint a_len; + uint a_inc; + +private: // Disabled copy constructor and operator= +#if defined(Q_DISABLE_COPY) + TQBuffer( const TQBuffer & ); + TQBuffer &operator=( const TQBuffer & ); +#endif +}; + + +inline TQByteArray TQBuffer::buffer() const +{ return a; } + +inline TQIODevice::Offset TQBuffer::size() const +{ return (Offset)a.size(); } + +inline TQIODevice::Offset TQBuffer::at() const +{ return ioIndex; } + + +#endif // TQBUFFER_H diff --git a/src/tools/qcache.h b/src/tools/qcache.h new file mode 100644 index 000000000..d0a4f6f65 --- /dev/null +++ b/src/tools/qcache.h @@ -0,0 +1,121 @@ +/**************************************************************************** +** +** Definition of TQCache template class +** +** Created : 950209 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQCACHE_H +#define TQCACHE_H + +#ifndef QT_H +#include "qgcache.h" +#endif // QT_H + +template +class TQCache +#ifdef Q_QDOC + : public TQPtrCollection +#else + : public TQGCache +#endif +{ +public: + TQCache( const TQCache &c ) : TQGCache(c) {} + TQCache( int maxCost=100, int size=17, bool caseSensitive=TRUE ) + : TQGCache( maxCost, size, StringKey, caseSensitive, FALSE ) {} + ~TQCache() { clear(); } + TQCache &operator=( const TQCache &c ) + { return (TQCache&)TQGCache::operator=(c); } + int maxCost() const { return TQGCache::maxCost(); } + int totalCost() const { return TQGCache::totalCost(); } + void setMaxCost( int m ) { TQGCache::setMaxCost(m); } + uint count() const { return TQGCache::count(); } + uint size() const { return TQGCache::size(); } + bool isEmpty() const { return TQGCache::count() == 0; } + void clear() { TQGCache::clear(); } + bool insert( const TQString &k, const type *d, int c=1, int p=0 ) + { return TQGCache::insert_string(k,(Item)d,c,p);} + bool remove( const TQString &k ) + { return TQGCache::remove_string(k); } + type *take( const TQString &k ) + { return (type *)TQGCache::take_string(k); } + type *find( const TQString &k, bool ref=TRUE ) const + { return (type *)TQGCache::find_string(k,ref);} + type *operator[]( const TQString &k ) const + { return (type *)TQGCache::find_string(k);} + void statistics() const { TQGCache::statistics(); } +private: + void deleteItem( Item d ); +}; + +#if !defined(Q_BROKEN_TEMPLATE_SPECIALIZATION) +template<> inline void TQCache::deleteItem( TQPtrCollection::Item ) +{ +} +#endif + +template inline void TQCache::deleteItem( TQPtrCollection::Item d ) +{ + if ( del_item ) delete (type *)d; +} + +template +class TQCacheIterator : public TQGCacheIterator +{ +public: + TQCacheIterator( const TQCache &c ):TQGCacheIterator((TQGCache &)c) {} + TQCacheIterator( const TQCacheIterator &ci) + : TQGCacheIterator( (TQGCacheIterator &)ci ) {} + TQCacheIterator &operator=(const TQCacheIterator&ci) + { return ( TQCacheIterator&)TQGCacheIterator::operator=( ci ); } + uint count() const { return TQGCacheIterator::count(); } + bool isEmpty() const { return TQGCacheIterator::count() == 0; } + bool atFirst() const { return TQGCacheIterator::atFirst(); } + bool atLast() const { return TQGCacheIterator::atLast(); } + type *toFirst() { return (type *)TQGCacheIterator::toFirst(); } + type *toLast() { return (type *)TQGCacheIterator::toLast(); } + operator type *() const { return (type *)TQGCacheIterator::get(); } + type *current() const { return (type *)TQGCacheIterator::get(); } + TQString currentKey() const{ return TQGCacheIterator::getKeyString(); } + type *operator()() { return (type *)TQGCacheIterator::operator()();} + type *operator++() { return (type *)TQGCacheIterator::operator++(); } + type *operator+=(uint j) { return (type *)TQGCacheIterator::operator+=(j);} + type *operator--() { return (type *)TQGCacheIterator::operator--(); } + type *operator-=(uint j) { return (type *)TQGCacheIterator::operator-=(j);} +}; + +#endif // TQCACHE_H diff --git a/src/tools/qcleanuphandler.h b/src/tools/qcleanuphandler.h new file mode 100644 index 000000000..538890dc3 --- /dev/null +++ b/src/tools/qcleanuphandler.h @@ -0,0 +1,130 @@ +/**************************************************************************** +** +** ... +** +** Copyright (C) 2001-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQCLEANUPHANDLER_H +#define TQCLEANUPHANDLER_H + +#ifndef QT_H +#include "qptrlist.h" +#endif // QT_H + +template +class TQCleanupHandler +{ +public: + TQCleanupHandler() : cleanupObjects( 0 ) {} + ~TQCleanupHandler() { clear(); } + + Type* add( Type **object ) { + if ( !cleanupObjects ) + cleanupObjects = new TQPtrList; + cleanupObjects->insert( 0, object ); + return *object; + } + + void remove( Type **object ) { + if ( !cleanupObjects ) + return; + if ( cleanupObjects->findRef( object ) >= 0 ) + (void) cleanupObjects->take(); + } + + bool isEmpty() const { + return cleanupObjects ? cleanupObjects->isEmpty() : TRUE; + } + + void clear() { + if ( !cleanupObjects ) + return; + TQPtrListIterator it( *cleanupObjects ); + Type **object; + while ( ( object = it.current() ) ) { + delete *object; + *object = 0; + cleanupObjects->remove( object ); + } + delete cleanupObjects; + cleanupObjects = 0; + } + +private: + TQPtrList *cleanupObjects; +}; + +template +class TQSingleCleanupHandler +{ +public: + TQSingleCleanupHandler() : object( 0 ) {} + ~TQSingleCleanupHandler() { + if ( object ) { + delete *object; + *object = 0; + } + } + Type* set( Type **o ) { + object = o; + return *object; + } + void reset() { object = 0; } +private: + Type **object; +}; + +template +class TQSharedCleanupHandler +{ +public: + TQSharedCleanupHandler() : object( 0 ) {} + ~TQSharedCleanupHandler() { + if ( object ) { + if ( (*object)->deref() ) + delete *object; + *object = 0; + } + } + Type* set( Type **o ) { + object = o; + return *object; + } + void reset() { object = 0; } +private: + Type **object; +}; + +#endif //TQCLEANUPHANDLER_H diff --git a/src/tools/qcom_p.h b/src/tools/qcom_p.h new file mode 100644 index 000000000..a1e497579 --- /dev/null +++ b/src/tools/qcom_p.h @@ -0,0 +1,344 @@ +/**************************************************************************** +** +** ... +** +** Copyright (C) 2001-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQCOM_P_H +#define TQCOM_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the TQt API. It exists for the convenience +// of a number of TQt sources files. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// +// + +#ifndef QT_H +#include "qstringlist.h" +#include "quuid.h" +#endif // QT_H + +#if __GNUC__ - 0 > 3 +#pragma GCC system_header +#endif + +#ifndef QT_NO_COMPONENT + +class TQObject; +struct TQUInterfaceDescription; +struct TQUObject; + +#define TQRESULT unsigned long +#define TQS_OK (TQRESULT)0x00000000 +#define TQS_FALSE (TQRESULT)0x00000001 + +#define TQE_NOTIMPL (TQRESULT)0x80000001 +#define TQE_OUTOFMEMORY (TQRESULT)0x80000002 +#define TQE_INVALIDARG (TQRESULT)0x80000003 +#define TQE_NOINTERFACE (TQRESULT)0x80000004 +#define TQE_NOCOMPONENT (TQRESULT)0x80000005 + + +// {1D8518CD-E8F5-4366-99E8-879FD7E482DE} +#ifndef IID_QUnknown +#define IID_QUnknown TQUuid(0x1d8518cd, 0xe8f5, 0x4366, 0x99, 0xe8, 0x87, 0x9f, 0xd7, 0xe4, 0x82, 0xde) +#endif + +struct Q_EXPORT TQUnknownInterface +{ + virtual TQRESULT queryInterface( const TQUuid&, TQUnknownInterface** ) = 0; + virtual ulong addRef() = 0; + virtual ulong release() = 0; +}; + +// {FBAC965E-A441-413F-935E-CDF582573FAB} +#ifndef IID_QDispatch +#define IID_QDispatch TQUuid( 0xfbac965e, 0xa441, 0x413f, 0x93, 0x5e, 0xcd, 0xf5, 0x82, 0x57, 0x3f, 0xab) +#endif + +// the dispatch interface that inherits the unknown interface.. It is +// used to explore interfaces during runtime and to do dynamic calls. +struct Q_EXPORT TQDispatchInterface : public TQUnknownInterface +{ + // returns the interface description of this dispatch interface. + virtual const TQUInterfaceDescription* interfaceDescription() const = 0; + + // returns the event description of this dispatch interface. + virtual const TQUInterfaceDescription* eventsDescription() const = 0; + + // invokes method id with parameters V*. Returns some sort of + // exception code. + virtual TQRESULT invoke( int id, TQUObject* o ) = 0; + + // installs listener as event listener + virtual void installListener( TQDispatchInterface* listener ) = 0; + + // remove listener as event listener + virtual void removeListener( TQDispatchInterface* listener ) = 0; +}; + +template +class TQInterfacePtr +{ +public: + TQInterfacePtr():iface(0){} + + TQInterfacePtr( T* i) { + if ( (iface = i) ) + iface->addRef(); + } + + TQInterfacePtr(const TQInterfacePtr &p) { + if ( (iface = p.iface) ) + iface->addRef(); + } + + ~TQInterfacePtr() { + if ( iface ) + iface->release(); + } + + TQInterfacePtr &operator=(const TQInterfacePtr &p) { + if ( iface != p.iface ) { + if ( iface ) + iface->release(); + if ( (iface = p.iface) ) + iface->addRef(); + } + return *this; + } + + TQInterfacePtr &operator=(T* i) { + if (iface != i ) { + if ( iface ) + iface->release(); + if ( (iface = i) ) + iface->addRef(); + } + return *this; + } + + bool operator==( const TQInterfacePtr &p ) const { return iface == p.iface; } + + bool operator!= ( const TQInterfacePtr& p ) const { return !( *this == p ); } + + bool isNull() const { return !iface; } + + T* operator->() const { return iface; } + + T& operator*() const { return *iface; } + + operator T*() const { return iface; } + + TQUnknownInterface** operator &() const { + if( iface ) + iface->release(); + return (TQUnknownInterface**)&iface; + } + + T** operator &() { + if ( iface ) + iface->release(); + return &iface; + } + +private: + T* iface; +}; + +// {10A1501B-4C5F-4914-95DD-C400486CF900} +#ifndef IID_QObject +#define IID_QObject TQUuid( 0x10a1501b, 0x4c5f, 0x4914, 0x95, 0xdd, 0xc4, 0x00, 0x48, 0x6c, 0xf9, 0x00) +#endif + +struct Q_EXPORT TQObjectInterface +{ + virtual TQObject* qObject() = 0; +}; + +// {5F3968A5-F451-45b1-96FB-061AD98F926E} +#ifndef IID_QComponentInformation +#define IID_QComponentInformation TQUuid(0x5f3968a5, 0xf451, 0x45b1, 0x96, 0xfb, 0x6, 0x1a, 0xd9, 0x8f, 0x92, 0x6e) +#endif + +struct Q_EXPORT TQComponentInformationInterface : public TQUnknownInterface +{ + virtual TQString name() const = 0; + virtual TQString description() const = 0; + virtual TQString author() const = 0; + virtual TQString version() const = 0; +}; + +// {6CAA771B-17BB-4988-9E78-BA5CDDAAC31E} +#ifndef IID_QComponentFactory +#define IID_QComponentFactory TQUuid( 0x6caa771b, 0x17bb, 0x4988, 0x9e, 0x78, 0xba, 0x5c, 0xdd, 0xaa, 0xc3, 0x1e) +#endif + +struct Q_EXPORT TQComponentFactoryInterface : public TQUnknownInterface +{ + virtual TQRESULT createInstance( const TQUuid &cid, const TQUuid &iid, TQUnknownInterface** instance, TQUnknownInterface *outer ) = 0; +}; + +// {D16111D4-E1E7-4C47-8599-24483DAE2E07} +#ifndef IID_QLibrary +#define IID_QLibrary TQUuid( 0xd16111d4, 0xe1e7, 0x4c47, 0x85, 0x99, 0x24, 0x48, 0x3d, 0xae, 0x2e, 0x07) +#endif + +struct Q_EXPORT TQLibraryInterface : public TQUnknownInterface +{ + virtual bool init() = 0; + virtual void cleanup() = 0; + virtual bool canUnload() const = 0; +}; + +// {3F8FDC44-3015-4f3e-B6D6-E4AAAABDEAAD} +#ifndef IID_QFeatureList +#define IID_QFeatureList TQUuid(0x3f8fdc44, 0x3015, 0x4f3e, 0xb6, 0xd6, 0xe4, 0xaa, 0xaa, 0xbd, 0xea, 0xad) +#endif + +struct Q_EXPORT TQFeatureListInterface : public TQUnknownInterface +{ + virtual TQStringList featureList() const = 0; +}; + +// {B5FEB5DE-E0CD-4E37-B0EB-8A812499A0C1} +#ifndef IID_QComponentRegistration +#define IID_QComponentRegistration TQUuid( 0xb5feb5de, 0xe0cd, 0x4e37, 0xb0, 0xeb, 0x8a, 0x81, 0x24, 0x99, 0xa0, 0xc1) +#endif + +struct Q_EXPORT TQComponentRegistrationInterface : public TQUnknownInterface +{ + virtual bool registerComponents( const TQString &filepath ) const = 0; + virtual bool unregisterComponents() const = 0; +}; + +// internal class that wraps an initialized ulong +struct Q_EXPORT TQtULong +{ + TQtULong() : ref( 0 ) { } + operator unsigned long () const { return ref; } + unsigned long& operator++() { return ++ref; } + unsigned long operator++( int ) { return ref++; } + unsigned long& operator--() { return --ref; } + unsigned long operator--( int ) { return ref--; } + + unsigned long ref; +}; +// default implementation of ref counting. A variable "ulong ref" has to be a member + + +#define Q_REFCOUNT \ +private: \ + TQtULong qtrefcount; \ +public: \ + ulong addRef() {return qtrefcount++;} \ + ulong release() {if(!--qtrefcount){delete this;return 0;}return qtrefcount;} + +#ifndef Q_EXPORT_COMPONENT +#if defined(QT_THREAD_SUPPORT) +#define QT_THREADED_BUILD 1 +#define Q_UCM_FLAGS_STRING "11" +#else +#define QT_THREADED_BUILD 0 +#define Q_UCM_FLAGS_STRING "01" +#endif + +#ifndef Q_EXTERN_C +#ifdef __cplusplus +#define Q_EXTERN_C extern "C" +#else +#define Q_EXTERN_C extern +#endif +#endif + +// this is duplicated at Q_PLUGIN_VERIFICATION_DATA in qgplugin.h +// NOTE: if you change pattern, you MUST change the pattern in +// qcomlibrary.cpp as well. changing the pattern will break all +// backwards compatibility as well (no old plugins will be loaded). +#ifndef Q_UCM_VERIFICATION_DATA +# define Q_UCM_VERIFICATION_DATA \ + static const char *qt_ucm_verification_data = \ + "pattern=""QT_UCM_VERIFICATION_DATA""\n" \ + "version="QT_VERSION_STR"\n" \ + "flags="Q_UCM_FLAGS_STRING"\n" \ + "buildkey="QT_BUILD_KEY"\0"; +#endif // Q_UCM_VERIFICATION_DATA + +// This macro expands to the default implementation of ucm_instantiate. +#ifndef Q_CREATE_INSTANCE +# define Q_CREATE_INSTANCE( IMPLEMENTATION ) \ + IMPLEMENTATION *i = new IMPLEMENTATION; \ + TQUnknownInterface* iface = 0; \ + i->queryInterface( IID_QUnknown, &iface ); \ + return iface; +#endif // Q_CREATE_INSTANCE + +# ifdef Q_WS_WIN +# ifdef Q_CC_BOR +# define Q_EXPORT_COMPONENT() \ + Q_UCM_VERIFICATION_DATA \ + Q_EXTERN_C __declspec(dllexport) \ + const char * __stdcall qt_ucm_query_verification_data() \ + { return qt_ucm_verification_data; } \ + Q_EXTERN_C __declspec(dllexport) TQUnknownInterface* \ + __stdcall ucm_instantiate() +# else +# define Q_EXPORT_COMPONENT() \ + Q_UCM_VERIFICATION_DATA \ + Q_EXTERN_C __declspec(dllexport) \ + const char *qt_ucm_query_verification_data() \ + { return qt_ucm_verification_data; } \ + Q_EXTERN_C __declspec(dllexport) TQUnknownInterface* ucm_instantiate() +# endif +# else +# define Q_EXPORT_COMPONENT() \ + Q_UCM_VERIFICATION_DATA \ + Q_EXTERN_C \ + const char *qt_ucm_query_verification_data() \ + { return qt_ucm_verification_data; } \ + Q_EXTERN_C TQUnknownInterface* ucm_instantiate() +# endif +# define Q_EXPORT_INTERFACE() Q_EXPORT_COMPONENT() +#endif + +#endif //QT_NO_COMPONENT + +#endif //TQCOM_P_H diff --git a/src/tools/qcomlibrary.cpp b/src/tools/qcomlibrary.cpp new file mode 100644 index 000000000..58d1ecf8d --- /dev/null +++ b/src/tools/qcomlibrary.cpp @@ -0,0 +1,538 @@ +/**************************************************************************** +** +** Implementation of TQComLibrary class +** +** Copyright (C) 2001-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "qcomlibrary_p.h" + +#ifndef QT_NO_COMPONENT +#include +#include +#include +#include +#include +#ifndef NO_ERRNO_H +#include +#endif // NO_ERROR_H + +#ifdef QT_THREAD_SUPPORT +# include "qmutexpool_p.h" +#endif // QT_THREAD_SUPPORT + +#ifndef QT_DEBUG_COMPONENT +# if defined(QT_DEBUG) +# define QT_DEBUG_COMPONENT 1 +# endif +#endif + + +TQComLibrary::TQComLibrary( const TQString &filename ) + : TQLibrary( filename ), entry( 0 ), libiface( 0 ), qt_version( 0 ) +{ +} + +TQComLibrary::~TQComLibrary() +{ + if ( autoUnload() ) + unload(); + if ( libiface ) + libiface->release(); + if ( entry ) + entry->release(); +} + +bool TQComLibrary::unload() +{ + int refs = entry ? entry->release() : 0; + entry = 0; + if (refs || !libiface) + return FALSE; + + libiface->cleanup(); + if ( !libiface->canUnload() ) + return FALSE; + libiface->release(); + libiface = 0; + + return TQLibrary::unload(); +} + +static bool qt_verify( const TQString& library, uint version, uint flags, + const TQCString &key, bool warn ) +{ + uint our_flags = 1; +#if defined(QT_THREAD_SUPPORT) + our_flags |= 2; +#endif + + if ( (flags & 1) == 0 ) { + if ( warn ) + qWarning( "Conflict in %s:\n" + " Plugin cannot be queried successfully!", + (const char*) TQFile::encodeName(library) ); + } else if ( ( version > QT_VERSION ) || + ( ( QT_VERSION & 0xff0000 ) > ( version & 0xff0000 ) ) ) { + if ( warn ) + qWarning( "Conflict in %s:\n" + " Plugin uses incompatible TQt library (%d.%d.%d)!", + (const char*) TQFile::encodeName(library), + (version&0xff0000) >> 16, (version&0xff00) >> 8, version&0xff ); + } else if ( (flags & 2) != (our_flags & 2) ) { + if ( warn ) + qWarning( "Conflict in %s:\n" + " Plugin uses %s TQt library!", + (const char*) TQFile::encodeName(library), + (flags & 2) ? "multi threaded" : "single threaded" ); + } else if ( key != QT_BUILD_KEY ) { + if ( warn ) + qWarning( "Conflict in %s:\n" + " Plugin uses incompatible TQt library!\n" + " expected build key \"%s\", got \"%s\".", + (const char*) TQFile::encodeName(library), + QT_BUILD_KEY, + key.isEmpty() ? "" : (const char *) key ); + } else { + return TRUE; + } + return FALSE; +} + +struct qt_token_info +{ + qt_token_info( const char *f, const ulong fc ) + : fields( f ), field_count( fc ), results( fc ), lengths( fc ) + { + results.fill( 0 ); + lengths.fill( 0 ); + } + + const char *fields; + const ulong field_count; + + TQMemArray results; + TQMemArray lengths; +}; + +/* + return values: + 1 parse ok + 0 eos + -1 parse error +*/ +static int qt_tokenize( const char *s, ulong s_len, ulong *advance, + const qt_token_info &token_info ) +{ + ulong pos = 0, field = 0, fieldlen = 0; + char current; + int ret = -1; + *advance = 0; + for (;;) { + current = s[ pos ]; + + // next char + ++pos; + ++fieldlen; + ++*advance; + + if ( ! current || pos == s_len + 1 ) { + // save result + token_info.results[ (int)field ] = s; + token_info.lengths[ (int)field ] = fieldlen - 1; + + // end of string + ret = 0; + break; + } + + if ( current == token_info.fields[ field ] ) { + // save result + token_info.results[ (int)field ] = s; + token_info.lengths[ (int)field ] = fieldlen - 1; + + // end of field + fieldlen = 0; + ++field; + if ( field == token_info.field_count - 1 ) { + // parse ok + ret = 1; + } + if ( field == token_info.field_count ) { + // done parsing + break; + } + + // reset string and its length + s = s + pos; + s_len -= pos; + pos = 0; + } + } + + return ret; +} + +/* + returns TRUE if the string s was correctly parsed, FALSE otherwise. +*/ +static bool qt_parse_pattern( const char *s, uint *version, uint *flags, + TQCString *key ) +{ + bool ret = TRUE; + + qt_token_info pinfo("=\n", 2); + int parse; + ulong at = 0, advance, parselen = qstrlen( s ); + do { + parse = qt_tokenize( s + at, parselen, &advance, pinfo ); + if ( parse == -1 ) { + ret = FALSE; + break; + } + + at += advance; + parselen -= advance; + + if ( qstrncmp( "version", pinfo.results[ 0 ], pinfo.lengths[ 0 ] ) == 0 ) { + // parse version string + qt_token_info pinfo2("..-", 3); + if ( qt_tokenize( pinfo.results[ 1 ], pinfo.lengths[ 1 ], + &advance, pinfo2 ) != -1 ) { + TQCString m( pinfo2.results[ 0 ], pinfo2.lengths[ 0 ] + 1 ); + TQCString n( pinfo2.results[ 1 ], pinfo2.lengths[ 1 ] + 1 ); + TQCString p( pinfo2.results[ 2 ], pinfo2.lengths[ 2 ] + 1 ); + *version = (m.toUInt() << 16) | (n.toUInt() << 8) | p.toUInt(); + } else { + ret = FALSE; + break; + } + } else if ( qstrncmp( "flags", pinfo.results[ 0 ], pinfo.lengths[ 0 ] ) == 0 ) { + // parse flags string + char ch; + *flags = 0; + ulong p = 0, c = 0, bit = 0; + while ( p < pinfo.lengths[ 1 ] ) { + ch = pinfo.results[ 1 ][ p ]; + bit = pinfo.lengths[ 1 ] - p - 1; + c = 1 << bit; + if ( ch == '1' ) { + *flags |= c; + } else if ( ch != '0' ) { + ret = FALSE; + break; + } + ++p; + } + } else if ( qstrncmp( "buildkey", pinfo.results[ 0 ], + pinfo.lengths[ 0 ] ) == 0 ){ + // save buildkey + *key = TQCString( pinfo.results[ 1 ], pinfo.lengths[ 1 ] + 1 ); + } + } while ( parse == 1 && parselen > 0 ); + + return ret; +} + +#if defined(Q_OS_UNIX) + +#if defined(Q_OS_FREEBSD) || defined(Q_OS_LINUX) +# define USE_MMAP +# include +# include +#endif // Q_OS_FREEBSD || Q_OS_LINUX + +static long qt_find_pattern( const char *s, ulong s_len, + const char *pattern, ulong p_len ) +{ + /* + this uses the same algorithm as TQString::findRev... + + we search from the end of the file because on the supported + systems, the read-only data/text segments are placed at the end + of the file. HOWEVER, when building with debugging enabled, all + the debug symbols are placed AFTER the data/text segments. + + what does this mean? when building in release mode, the search + is fast because the data we are looking for is at the end of the + file... when building in debug mode, the search is slower + because we have to skip over all the debugging symbols first + */ + + if ( ! s || ! pattern || p_len > s_len ) return -1; + ulong i, hs = 0, hp = 0, delta = s_len - p_len; + + for (i = 0; i < p_len; ++i ) { + hs += s[delta + i]; + hp += pattern[i]; + } + i = delta; + for (;;) { + if ( hs == hp && qstrncmp( s + i, pattern, p_len ) == 0 ) + return i; + if ( i == 0 ) + break; + --i; + hs -= s[i + p_len]; + hs += s[i]; + } + + return -1; +} + +/* + This opens the specified library, mmaps it into memory, and searches + for the QT_UCM_VERIFICATION_DATA. The advantage of this approach is that + we can get the verification data without have to actually load the library. + This lets us detect mismatches more safely. + + Returns FALSE if version/flags/key information is not present, or if the + information could not be read. + Returns TRUE if version/flags/key information is present and succesfully read. +*/ +static bool qt_unix_query( const TQString &library, uint *version, uint *flags, + TQCString *key ) +{ + TQFile file( library ); + if (! file.open( IO_ReadOnly ) ) { + qWarning( "%s: %s", (const char*) TQFile::encodeName(library), + strerror( errno ) ); + return FALSE; + } + + TQByteArray data; + char *filedata = 0; + ulong fdlen = 0; + +#ifdef USE_MMAP + char *mapaddr = 0; + size_t maplen = file.size(); + mapaddr = (char *) mmap( mapaddr, maplen, PROT_READ, MAP_PRIVATE, file.handle(), 0 ); + if ( mapaddr != MAP_FAILED ) { + // mmap succeeded + filedata = mapaddr; + fdlen = maplen; + } else { + // mmap failed + qWarning( "mmap: %s", strerror( errno ) ); +#endif // USE_MMAP + // try reading the data into memory instead + data = file.readAll(); + filedata = data.data(); + fdlen = data.size(); +#ifdef USE_MMAP + } +#endif // USE_MMAP + + // verify that the pattern is present in the plugin + const char *pattern = "pattern=QT_UCM_VERIFICATION_DATA"; + const ulong plen = qstrlen( pattern ); + long pos = qt_find_pattern( filedata, fdlen, pattern, plen ); + + bool ret = FALSE; + if ( pos >= 0 ) { + ret = qt_parse_pattern( filedata + pos, version, flags, key ); + } + +#ifdef USE_MMAP + if ( mapaddr != MAP_FAILED && munmap(mapaddr, maplen) != 0 ) { + qWarning( "munmap: %s", strerror( errno ) ); + } +#endif // USE_MMAP + + file.close(); + return ret; +} + +#endif // Q_OS_UNIX + + +static TQSettings *cache = 0; +static TQSingleCleanupHandler cleanup_cache; + +void TQComLibrary::createInstanceInternal() +{ + if ( library().isEmpty() ) + return; + + TQFileInfo fileinfo( library() ); + TQString lastModified = fileinfo.lastModified().toString(TQt::ISODate); + TQString regkey = TQString("/TQt Plugins %1.%2/%3") + .arg( ( QT_VERSION & 0xff0000 ) >> 16 ) + .arg( ( QT_VERSION & 0xff00 ) >> 8 ) + .arg( library() ); + TQStringList reg; + uint flags = 0; + TQCString key; + bool query_done = FALSE; + bool warn_mismatch = TRUE; + +#ifdef QT_THREAD_SUPPORT + TQMutexLocker locker( qt_global_mutexpool ? + qt_global_mutexpool->get( &cache ) : 0 ); +#endif // QT_THREAD_SUPPORT + + if ( ! cache ) { + cache = new TQSettings; + cache->insertSearchPath( TQSettings::Windows, "/Trolltech" ); + cleanup_cache.set( &cache ); + } + + reg = cache->readListEntry( regkey ); + if ( reg.count() == 4 ) { + // check timestamp + if ( lastModified == reg[3] ) { + qt_version = reg[0].toUInt(0, 16); + flags = reg[1].toUInt(0, 16); + key = reg[2].latin1(); + + query_done = TRUE; + warn_mismatch = FALSE; + } + } + +#if defined(Q_OS_UNIX) + if ( ! query_done ) { + // get the query information directly from the plugin without loading + if ( qt_unix_query( library(), &qt_version, &flags, &key ) ) { + // info read succesfully from library + query_done = TRUE; + } + } +#else // !Q_OS_UNIX + if ( ! query_done ) { + // get the query information by loading the plugin + if ( !isLoaded() ) { + Q_ASSERT( entry == 0 ); + if ( !load() ) + return; + } + +# ifdef Q_CC_BOR + typedef const char * __stdcall (*UCMQueryVerificationDataProc)(); +# else + typedef const char * (*UCMQueryVerificationDataProc)(); +# endif + UCMQueryVerificationDataProc ucmQueryVerificationdataProc; + ucmQueryVerificationdataProc = + (UCMQueryVerificationDataProc) resolve( "qt_ucm_query_verification_data" ); + + if ( !ucmQueryVerificationdataProc || + !qt_parse_pattern( ucmQueryVerificationdataProc(), + &qt_version, &flags, &key ) ) { + qt_version = flags = 0; + key = "unknown"; + } else { + query_done = TRUE; + } + } +#endif // Q_OS_UNIX + + TQStringList queried; + queried << TQString::number( qt_version,16 ) + << TQString::number( flags, 16 ) + << key + << lastModified; + + if ( queried != reg ) { + cache->writeEntry( regkey, queried ); + // delete the cache, which forces the settings to be written + delete cache; + cache = 0; + } + + if ( ! query_done ) { + if ( warn_mismatch ) { + qWarning( "Conflict in %s:\n Plugin cannot be queried successfully!", + (const char*) TQFile::encodeName( library() ) ); + } + unload(); + return; + } + + if ( ! qt_verify( library(), qt_version, flags, key, warn_mismatch ) ) { + unload(); + return; + } else if ( !isLoaded() ) { + Q_ASSERT( entry == 0 ); + if ( !load() ) + return; + } + +#ifdef Q_CC_BOR + typedef TQUnknownInterface* __stdcall (*UCMInstanceProc)(); +#else + typedef TQUnknownInterface* (*UCMInstanceProc)(); +#endif + UCMInstanceProc ucmInstanceProc; + ucmInstanceProc = (UCMInstanceProc) resolve( "ucm_instantiate" ); +#if defined(QT_DEBUG_COMPONENT) + if ( !ucmInstanceProc ) + qWarning( "%s: Not a UCOM library.", (const char*) TQFile::encodeName(library()) ); +#endif + entry = ucmInstanceProc ? ucmInstanceProc() : 0; + + if ( entry ) { + if ( entry->queryInterface( IID_QLibrary, (TQUnknownInterface**)&libiface ) == TQS_OK ) { + if ( libiface && !libiface->init() ) { + libiface->release(); + libiface = 0; + unload(); + return; + } + } + } else { +#if defined(QT_DEBUG_COMPONENT) + qWarning( "%s: No exported component provided.", (const char*) TQFile::encodeName(library()) ); +#endif + unload(); + } +} + +TQRESULT TQComLibrary::queryInterface( const TQUuid& request, TQUnknownInterface** iface ) +{ + if ( !entry ) + createInstanceInternal(); + return entry ? entry->queryInterface( request, iface ) : TQE_NOCOMPONENT; +} + +uint TQComLibrary::qtVersion() +{ + if ( !entry ) + createInstanceInternal(); + return entry ? qt_version : 0; +} + + +#endif // QT_NO_COMPONENT diff --git a/src/tools/qcomlibrary_p.h b/src/tools/qcomlibrary_p.h new file mode 100644 index 000000000..71f7105e7 --- /dev/null +++ b/src/tools/qcomlibrary_p.h @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** Definition of TQComLibrary class +** +** Copyright (C) 2001-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQCOMLIBRARY_P_H +#define TQCOMLIBRARY_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the TQt API. It exists for the convenience +// of a number of TQt sources files. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// +// + +#ifndef QT_H +#include "qcom_p.h" +#include "qlibrary.h" +#endif // QT_H + +#ifndef QT_NO_COMPONENT + +class Q_EXPORT TQComLibrary : public TQLibrary +{ +public: + TQComLibrary( const TQString &filename ); + ~TQComLibrary(); + + bool unload(); + TQRESULT queryInterface( const TQUuid &iid, TQUnknownInterface **iface ); + uint qtVersion(); + +private: + void createInstanceInternal(); + + TQUnknownInterface *entry; + TQLibraryInterface *libiface; + uint qt_version; + +}; + +#endif //QT_NO_COMPONENT + +#endif diff --git a/src/tools/qcomponentfactory.cpp b/src/tools/qcomponentfactory.cpp new file mode 100644 index 000000000..51b545ec7 --- /dev/null +++ b/src/tools/qcomponentfactory.cpp @@ -0,0 +1,355 @@ +/**************************************************************************** +** +** Implementation of the TQComponentFactory class +** +** Created : 990101 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "qcomponentfactory_p.h" + +#ifndef QT_NO_COMPONENT +#include "qsettings.h" +#include +#include "qdir.h" +#include "qapplication.h" + +/*! + \class TQComponentFactory qcomponentfactory.h + \brief The TQComponentFactory class provides static functions to create and register components. + + \internal + + The static convenience functions can be used both by applications to instantiate components, + and by component servers to register components. + + The createInstance() function provides a pointer to an interface implemented in a specific + component if the component requested has been installed properly and implements the interface. + + Use registerServer() to load a component server and register its components, and unregisterServer() + to unregister the components. The component exported by the component server has to implement the + TQComponentRegistrationInterface. + + The static functions registerComponent() and unregisterComponent() register and unregister a single + component in the system component registry, and should be used when implementing the + \link TQComponentRegistrationInterface::registerComponents() registerCompontents() \endlink and + \link TQComponentRegistrationInterface::unregisterComponents() unregisterCompontents() \endlink functions + in the TQComponentRegistrationInterface. + + A component is registered using a UUID, but can additionally be registered with a name, version and + description. A component registered with a name and a version can be instantiated by client applications + using the name and specific version number, or the highest available version number for that component by + just using the name. A component that is registered calling + + \code + TQComponentFactory::registerComponent( TQUuid(...), filename, "MyProgram.Component", 1 ); + \endcode + + can be instantiated calling either: + + \code + TQComponentFactory::createInstance( TQUuid(...), IID_XYZ, (TQUnknownInterface**)&iface ); + \endcode + or + \code + TQComponentFactory::createInstance( "MyProgram.Component", IID_XYZ, (TQUnknownInterface**)&iface ); + \endcode + or + \code + TQComponentFactory::createInstance( "MyProgram.Component.1", IID_XYZ, (TQUnknownInterface**)&iface ); + \endcode + + The first and the last way will always instantiate exactly the component registered above, while + the second call might also return a later version of the same component. This allows smoother upgrading + of components, and is easier to use in application source code, but should only be used when new versions + of the component are guaranteed to work with the application. + + The component name can be anything, but should be unique on the system the component is being + installed on. A common naming convention for components is \e application.component. + + \sa TQComponentRegistrationInterface TQComponentFactoryInterface +*/ + + +static TQPtrList *libraries = 0; + +static void cleanup() +{ + delete libraries; + libraries = 0; +} + +static TQPtrList *liblist() +{ + if ( !libraries ) { + libraries = new TQPtrList(); + libraries->setAutoDelete( TRUE ); + qAddPostRoutine( cleanup ); + } + return libraries; +} + +/*! + Searches for the component identifier \a cid in the system component registry, + loads the corresponding component server and queries for the interface \a iid. + \a iface is set to the resulting interface pointer. \a cid can either be the + UUID or the name of the component. + + The parameter \a outer is a pointer to the outer interface used + for containment and aggregation and is propagated to the \link + TQComponentFactoryInterface::createInstance() createInstance() \endlink + implementation of the TQComponentFactoryInterface in the component server if + provided. + + The function returns TQS_OK if the interface was successfully instantiated, TQE_NOINTERFACE if + the component does not provide an interface \a iid, or TQE_NOCOMPONENT if there was + an error loading the component. + + Example: + \code + TQInterfacePtr iface; + if ( TQComponentFactory::createInstance( IID_MyInterface, CID_MyComponent, (TQUnknownInterface**)&iface ) == TQS_OK ) + iface->doSomething(); + ... + } + \endcode +*/ +TQRESULT TQComponentFactory::createInstance( const TQString &cid, const TQUuid &iid, TQUnknownInterface** iface, TQUnknownInterface *outer ) +{ + TQSettings settings; + settings.insertSearchPath( TQSettings::Windows, "/Classes" ); + bool ok = FALSE; + TQString cidStr = cid; + TQRESULT res = TQE_NOCOMPONENT; + + TQUuid uuid( cidStr ); // try to parse, and resolve CLSID if necessary + if ( uuid.isNull() ) { + uuid = settings.readEntry( "/" + cid + "/CLSID/Default", TQString::null, &ok ); + cidStr = uuid.toString().upper(); + } + + if ( cidStr.isEmpty() ) + return res; + + TQString file = settings.readEntry( "/CLSID/" + cidStr + "/InprocServer32/Default", TQString::null, &ok ); + if ( !ok ) + return res; + + TQComLibrary *library = new TQComLibrary( file ); + library->setAutoUnload( FALSE ); + + TQComponentFactoryInterface *cfIface =0; + library->queryInterface( IID_QComponentFactory, (TQUnknownInterface**)&cfIface ); + + if ( cfIface ) { + res = cfIface->createInstance( uuid, iid, iface, outer ); + cfIface->release(); + } else { + res = library->queryInterface( iid, iface ); + } + TQLibraryInterface *libiface = 0; + if ( library->queryInterface( IID_QLibrary, (TQUnknownInterface**)&libiface ) != TQS_OK || !qApp ) { + delete library; // only deletes the object, thanks to TQLibrary::Manual + } else { + libiface->release(); + library->setAutoUnload( TRUE ); + liblist()->prepend( library ); + } + return res; +} + +/*! + Loads the shared library \a filename and queries for a + TQComponentRegistrationInterface. If the library implements this interface, + the \link TQComponentRegistrationInterface::registerComponents() + registerComponents() \endlink function is called. + + Returns TRUE if the interface is found and successfully called, + otherwise returns FALSE. +*/ +TQRESULT TQComponentFactory::registerServer( const TQString &filename ) +{ + TQComLibrary lib( filename ); + lib.load(); + TQComponentRegistrationInterface *iface = 0; + TQRESULT res = lib.queryInterface( IID_QComponentRegistration, (TQUnknownInterface**)&iface ); + if ( res != TQS_OK ) + return res; + TQDir dir( filename ); + bool ok = iface->registerComponents( dir.absPath() ); + iface->release(); + return ok ? TQS_OK : TQS_FALSE; +} + +/*! + Loads the shared library \a filename and queries for a + TQComponentRegistrationInterface. If the library implements this interface, + the \link TQComponentRegistrationInterface::unregisterComponents() + unregisterComponents() \endlink function is called. + + Returns TRUE if the interface is found and successfully unregistered, + otherwise returns FALSE. +*/ +TQRESULT TQComponentFactory::unregisterServer( const TQString &filename ) +{ + TQComLibrary lib( filename ); + lib.load(); + TQComponentRegistrationInterface *iface = 0; + TQRESULT res = lib.queryInterface( IID_QComponentRegistration, (TQUnknownInterface**)&iface ); + if ( res != TQS_OK ) + return res; + bool ok = iface->unregisterComponents(); + iface->release(); + return ok ? TQS_OK : TQS_FALSE; +} + +/*! + Registers the component with id \a cid in the system component registry and + returns TRUE if the component was registerd successfully, otherwise returns + FALSE. The component is provided by the component server at \a filepath and + registered with an optional \a name, \a version and \a description. + + This function does nothing and returns FALSE if a component with an identical + \a cid does already exist on the system. + + A component that has been registered with a \a name can be created using both the + \a cid and the \a name value using createInstance(). + + Call this function for each component in an implementation of + \link TQComponentRegistrationInterface::registerComponents() registerComponents() \endlink. + + \sa unregisterComponent(), registerServer(), createInstance() +*/ +bool TQComponentFactory::registerComponent( const TQUuid &cid, const TQString &filepath, const TQString &name, int version, const TQString &description ) +{ + bool ok = FALSE; + TQSettings settings; + settings.insertSearchPath( TQSettings::Windows, "/Classes" ); + + TQString cidStr = cid.toString().upper(); + settings.readEntry( "/CLSID/" + cidStr + "/InprocServer32/Default", TQString::null, &ok ); + if ( ok ) // don't overwrite existing component + return FALSE; + + ok = settings.writeEntry( "/CLSID/" + cidStr + "/InprocServer32/Default", filepath ); + if ( ok && !!description ) + settings.writeEntry( "/CLSID/" + cidStr + "/Default", description ); + + // register the human readable part + if ( ok && !!name ) { + TQString vName = version ? name + "." + TQString::number( version ) : name; + settings.writeEntry( "/CLSID/" + cidStr + "/ProgID/Default", vName ); + ok = settings.writeEntry( "/" + vName + "/CLSID/Default", cidStr ); + if ( ok && !!description ) + settings.writeEntry( "/" + vName + "/Default", description ); + + if ( ok && version ) { + settings.writeEntry( "/CLSID/" + cidStr + "/VersionIndependentProgID/Default", name ); + TQString curVer = settings.readEntry( "/" + name + "/CurVer/Default" ); + if ( !curVer || curVer < vName ) { // no previous, or a lesser version installed + settings.writeEntry( "/" + name + "/CurVer/Default", vName ); + ok = settings.writeEntry( "/" + name + "/CLSID/Default", cidStr ); + if ( ok && !!description ) + settings.writeEntry( "/" + name + "/Default", description ); + } + } + } + + return ok; +} + +/*! + Unregisters the component with id \a cid from the system component registry and returns + TRUE if the component was unregistered successfully, otherwise returns FALSE. + + Call this function for each component in an implementation of + \link TQComponentRegistrationInterface::unregisterComponents() unregisterComponents() \endlink. + + \sa registerComponent(), unregisterServer() +*/ +bool TQComponentFactory::unregisterComponent( const TQUuid &cid ) +{ + TQSettings settings; + bool ok = FALSE; + settings.insertSearchPath( TQSettings::Windows, "/Classes" ); + + TQString cidStr = cid.toString().upper(); + if ( cidStr.isEmpty() ) + return FALSE; + + // unregister the human readable part + TQString vName = settings.readEntry( "/CLSID/" + cidStr + "/ProgID/Default", TQString::null, &ok ); + if ( ok ) { + TQString name = settings.readEntry( "/CLSID/" + cidStr + "/VersionIndependentProgID/Default", TQString::null ); + if ( !!name && settings.readEntry( "/" + name + "/CurVer/Default" ) == vName ) { + // unregistering the current version -> change CurVer to previous version + TQString version = vName.right( vName.length() - name.length() - 1 ); + TQString newVerName; + TQString newCidStr; + if ( version.find( '.' ) == -1 ) { + int ver = version.toInt(); + // see if a lesser version is installed, and make that the CurVer + while ( ver-- ) { + newVerName = name + "." + TQString::number( ver ); + newCidStr = settings.readEntry( "/" + newVerName + "/CLSID/Default" ); + if ( !!newCidStr ) + break; + } + } else { + // oh well... + } + if ( !!newCidStr ) { + settings.writeEntry( "/" + name + "/CurVer/Default", newVerName ); + settings.writeEntry( "/" + name + "/CLSID/Default", newCidStr ); + } else { + settings.removeEntry( "/" + name + "/CurVer/Default" ); + settings.removeEntry( "/" + name + "/CLSID/Default" ); + settings.removeEntry( "/" + name + "/Default" ); + } + } + + settings.removeEntry( "/" + vName + "/CLSID/Default" ); + settings.removeEntry( "/" + vName + "/Default" ); + } + + settings.removeEntry( "/CLSID/" + cidStr + "/VersionIndependentProgID/Default" ); + settings.removeEntry( "/CLSID/" + cidStr + "/ProgID/Default" ); + settings.removeEntry( "/CLSID/" + cidStr + "/InprocServer32/Default" ); + ok = settings.removeEntry( "/CLSID/" + cidStr + "/Default" ); + + return ok; +} + +#endif // QT_NO_COMPONENT diff --git a/src/tools/qcomponentfactory_p.h b/src/tools/qcomponentfactory_p.h new file mode 100644 index 000000000..e40dd4635 --- /dev/null +++ b/src/tools/qcomponentfactory_p.h @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Definition of the TQComponentFactory class +** +** Created : 990101 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQCOMPONENTFACTORY_P_H +#define TQCOMPONENTFACTORY_P_H + +#ifndef QT_H +#include "qcom_p.h" +#endif // QT_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the TQt API. It exists for the convenience +// of a number of TQt sources files. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// +// + +#ifndef QT_NO_COMPONENT + +class Q_EXPORT TQComponentFactory +{ +public: + static TQRESULT createInstance( const TQString &cid, const TQUuid &iid, TQUnknownInterface** instance, TQUnknownInterface *outer = 0 ); + static TQRESULT registerServer( const TQString &filename ); + static TQRESULT unregisterServer( const TQString &filename ); + + static bool registerComponent( const TQUuid &cid, const TQString &filename, const TQString &name = TQString::null, + int version = 0, const TQString &description = TQString::null ); + static bool unregisterComponent( const TQUuid &cid ); +}; + +#endif // QT_NO_COMPONENT + +#endif // TQCOMPONENTFACTORY_P_H diff --git a/src/tools/qconfig-dist.h b/src/tools/qconfig-dist.h new file mode 100644 index 000000000..ae56b2f27 --- /dev/null +++ b/src/tools/qconfig-dist.h @@ -0,0 +1,11 @@ +#ifndef QT_H +#endif /* QT_H */ + +/* + Empty leaves all features enabled. See doc/html/features.html for choices. + + Note that disabling some features will produce a libqt that is not + compatible with other libqt builds. Such modifications are only + supported on TQt/Embedded where reducing the library size is important + and where the application-suite is often a fixed set. +*/ diff --git a/src/tools/qconfig-large.h b/src/tools/qconfig-large.h new file mode 100644 index 000000000..63104ebec --- /dev/null +++ b/src/tools/qconfig-large.h @@ -0,0 +1,42 @@ +#ifndef QT_H +#endif /* QT_H */ +#ifndef QT_NO_CODECS +#define QT_NO_CODECS +#endif +#define QT_NO_UNICODETABLES +#define QT_NO_IMAGEIO_BMP +#define QT_NO_IMAGEIO_PPM +#define QT_NO_ASYNC_IO +#define QT_NO_ASYNC_IMAGE_IO +/* #define QT_NO_FREETYPE */ +#define QT_NO_BDF +//#define QT_NO_FONTDATABASE +#define QT_NO_TRANSLATION +#define QT_NO_DRAGANDDROP +#define QT_NO_CLIPBOARD +#define QT_NO_SOUND +#define QT_NO_PROPERTIES +#define QT_NO_DNS +#define QT_NO_NETWORKPROTOCOL +#define QT_NO_URL +#define QT_NO_COLORNAMES +#define QT_NO_TRANSFORMATIONS +#define QT_NO_PRINTER +#define QT_NO_PICTURE +#define QT_NO_ICONVIEW +#define QT_NO_DIAL +#define QT_NO_WORKSPACE +#define QT_NO_TABLE +#define QT_NO_ACTION +#define QT_NO_STYLE_MOTIF +#define QT_NO_STYLE_PLATINUM +/* #define QT_NO_FILEDIALOG */ +#define QT_NO_FONTDIALOG +#define QT_NO_PRINTDIALOG +/* #define QT_NO_COLORDIALOG */ +#define QT_NO_INPUTDIALOG +/* #define QT_NO_MESSAGEBOX */ +#define QT_NO_PROGRESSDIALOG +/* #define QT_NO_TABDIALOG */ +#define QT_NO_WIZARD +#define QT_NO_EFFECTS diff --git a/src/tools/qconfig-medium.h b/src/tools/qconfig-medium.h new file mode 100644 index 000000000..f7df2dcd3 --- /dev/null +++ b/src/tools/qconfig-medium.h @@ -0,0 +1,108 @@ +#ifndef QT_H +#endif /* QT_H */ +#ifndef QT_NO_TEXTCODEC /* moc? */ +#define QT_NO_TEXTCODEC +#endif +#define QT_NO_UNICODETABLES +#define QT_NO_IMAGEIO_BMP +#define QT_NO_IMAGEIO_PPM +/* #define QT_NO_IMAGEIO_PNG */ +#define QT_NO_ASYNC_IO +#define QT_NO_ASYNC_IMAGE_IO +/* #define QT_NO_FREETYPE */ +#define QT_NO_BDF +//#define QT_NO_FONTDATABASE +#define QT_NO_TRANSLATION +#define QT_NO_DRAGANDDROP +#define QT_NO_CLIPBOARD +#define QT_NO_SOUND +#define QT_NO_PROPERTIES +#define QT_NO_DNS +#define QT_NO_NETWORKPROTOCOL +#define QT_NO_COLORNAMES +#define QT_NO_TRANSFORMATIONS +#define QT_NO_PRINTER +#define QT_NO_PICTURE +#define QT_NO_ICONVIEW +#define QT_NO_DIAL +#define QT_NO_WORKSPACE +#define QT_NO_TABLE +#define QT_NO_ACTION +#define QT_NO_STYLE_MOTIF +#define QT_NO_STYLE_PLATINUM +/* #define QT_NO_FILEDIALOG */ +#define QT_NO_FONTDIALOG +#define QT_NO_PRINTDIALOG +/* #define QT_NO_COLORDIALOG */ +#define QT_NO_INPUTDIALOG +/* #define QT_NO_MESSAGEBOX */ +#define QT_NO_PROGRESSDIALOG +/* #define QT_NO_TABDIALOG */ +#define QT_NO_WIZARD +#define QT_NO_EFFECTS + + +#define QT_NO_MIME +/* #define QT_NO_NETWORK //??? means single-process only */ + + +#define QT_NO_IMAGE_TRUECOLOR +/* #define QT_NO_IMAGE_SMOOTHSCALE //needed for iconset --> pushbutton */ +#define QT_NO_IMAGE_TEXT +#define QT_NO_DIR + +/* #define QT_NO_TEXTSTREAM */ +#define QT_NO_DATASTREAM +#define QT_NO_QWS_SAVEFONTS + +#define QT_NO_SESSIONMANAGER + + +/* #define QT_NO_DIALOG */ + +#define QT_NO_SEMIMODAL + +#define QT_NO_EFFECTS +#define QT_NO_COP + +#define QT_NO_QWS_PROPERTIES + +/* #define QT_NO_RANGECONTROL */ +/* #define QT_NO_SPLITTER */ +#define QT_NO_STATUSBAR +#define QT_NO_TABBAR +#define QT_NO_TOOLBAR +#define QT_NO_TOOLTIP +/* #define QT_NO_VALIDATOR */ +#define QT_NO_WHATSTHIS +#define QT_NO_WIDGETSTACK +#define QT_NO_ACCEL +#define QT_NO_SIZEGRIP +#define QT_NO_HEADER +#define QT_NO_WORKSPACE +#define QT_NO_LCDNUMBER +#define QT_NO_STYLE_MOTIF +#define QT_NO_STYLE_PLATINUM +#define QT_NO_PROGRESSBAR + +#define QT_NO_ICONVIEW +#define QT_NO_DIAL + +#define QT_NO_TABLE + +/* #define QT_NO_FILEDIALOG */ +#define QT_NO_FONTDIALOG +#define QT_NO_PRINTDIALOG +#define QT_NO_COLORDIALOG +#define QT_NO_INPUTDIALOG +/* #define QT_NO_MESSAGEBOX */ +#define QT_NO_PROGRESSDIALOG +/* #define QT_NO_TABDIALOG */ +#define QT_NO_WIZARD +#define QT_NO_EFFECTS + +/* #define QT_NO_QWS_HYDRO_WM_STYLE */ +#define QT_NO_QWS_BEOS_WM_STYLE +#define QT_NO_QWS_KDE2_WM_STYLE +#define QT_NO_QWS_KDE_WM_STYLE +/* #define QT_NO_QWS_WINDOWS_WM_STYLE */ diff --git a/src/tools/qconfig-minimal.h b/src/tools/qconfig-minimal.h new file mode 100644 index 000000000..d3a795418 --- /dev/null +++ b/src/tools/qconfig-minimal.h @@ -0,0 +1,97 @@ +#ifndef QT_H +#endif /* QT_H */ + +#ifndef QT_NO_CHECK +# define QT_NO_CHECK +#endif +#define QT_NO_PROCESS +#define QT_NO_PALETTE +#define QT_NO_ACTION +#ifndef QT_NO_TEXTCODEC /* moc? */ +#define QT_NO_TEXTCODEC +#endif +#define QT_NO_UNICODETABLES +#define QT_NO_IMAGEIO_BMP +#define QT_NO_IMAGEIO_PPM +#define QT_NO_IMAGEIO_XBM +#define QT_NO_IMAGEIO_XPM +/* #define QT_NO_IMAGEIO_PNG //done by configure -no-png */ +#define QT_NO_ASYNC_IO +#define QT_NO_ASYNC_IMAGE_IO +/* //#define QT_NO_FREETYPE //done by configure -no-freetype */ +#define QT_NO_BDF +//#define QT_NO_FONTDATABASE +#define QT_NO_TRANSLATION +#define QT_NO_MIME +#define QT_NO_SOUND +/* #define QT_NO_PROPERTIES */ +#define QT_NO_QWS_CURSOR +#define QT_NO_CURSOR +#define QT_NO_QWS_GFX_SPEED +#define QT_NO_NETWORK +#define QT_NO_COLORNAMES +#define QT_NO_TRANSFORMATIONS +#define QT_NO_PRINTER +#define QT_NO_PICTURE +#define QT_NO_LAYOUT +#define QT_NO_DRAWUTIL +#define QT_NO_IMAGE_TRUECOLOR +#define QT_NO_IMAGE_SMOOTHSCALE +#define QT_NO_IMAGE_TEXT +#define QT_NO_DIR +#define QT_NO_QWS_MANAGER +#define QT_NO_TEXTSTREAM +#define QT_NO_DATASTREAM +#define QT_NO_QWS_SAVEFONTS +//#define QT_NO_STRINGLIST +#define QT_NO_TEMPLATE_VARIANT +#define QT_NO_SESSIONMANAGER +#define QT_NO_QWS_KEYBOARD +#define QT_NO_SYNTAXHIGHLIGHTER + +#define QT_NO_ACCEL +#define QT_NO_BUTTON +#define QT_NO_DIALOG +#define QT_NO_FRAME +#define QT_NO_SEMIMODAL + +#define QT_NO_STYLE +#define QT_NO_EFFECTS +#define QT_NO_COP + +#define QT_NO_SQL + +#define QT_NO_REGEXP_CAPTURE +#define QT_NO_REGEXP_WILDCARD + +#define QT_NO_VALIDATOR +#define QT_NO_SPRINTF + +#define QT_NO_REGEXP + +#define QT_NO_IMAGEIO + +/* #define QT_NO_VARIANT //needed for signals/slots */ + +#define QT_NO_RANGECONTROL +#define QT_NO_QUUID_STRING +#define QT_NO_SIGNALMAPPER + +#define QT_NO_WHEELEVENT +#define QT_NO_BEZIER + +#define QT_NO_QWS_MOUSE_AUTO +/* #define QT_NO_QWS_MOUSE_MANUAL */ + +#define QT_NO_IMAGE_DITHER_TO_1 +#define QT_NO_IMAGE_HEURISTIC_MASK +#define QT_NO_IMAGE_MIRROR + +#ifndef QT_NO_STL +# define QT_NO_STL +#endif + +#define QT_NO_DATESTRING +#define QT_NO_WMATRIX + +#define QT_NO_DIRECTPAINTER diff --git a/src/tools/qconfig-small.h b/src/tools/qconfig-small.h new file mode 100644 index 000000000..80007cc1c --- /dev/null +++ b/src/tools/qconfig-small.h @@ -0,0 +1,94 @@ +#define NO_CHECK +#ifndef QT_H +#endif /* QT_H */ + +#define QT_NO_ACTION +#ifndef QT_NO_TEXTCODEC /* moc? */ +#define QT_NO_TEXTCODEC +#endif +#define QT_NO_UNICODETABLES +#define QT_NO_IMAGEIO_BMP +#define QT_NO_IMAGEIO_PPM +#define QT_NO_IMAGEIO_XBM +#define QT_NO_IMAGEIO_XPM +/* #define QT_NO_IMAGEIO_PNG //done by configure -no-png */ +#define QT_NO_ASYNC_IO +#define QT_NO_ASYNC_IMAGE_IO +/* #define QT_NO_FREETYPE //done by configure -no-freetype */ +#define QT_NO_BDF +//#define QT_NO_FONTDATABASE +#define QT_NO_TRANSLATION +#define QT_NO_MIME +#define QT_NO_SOUND +#define QT_NO_PROPERTIES +#define QT_NO_SYNTAXHIGHLIGHTER + +#define QT_NO_QWS_GFX_SPEED +#define QT_NO_NETWORK /* ?????????????? */ +#define QT_NO_COLORNAMES +#define QT_NO_TRANSFORMATIONS +#define QT_NO_PRINTER +#define QT_NO_PICTURE + +#define QT_NO_IMAGE_TRUECOLOR +/* #define QT_NO_IMAGE_SMOOTHSCALE //needed for iconset --> pushbutton */ +#define QT_NO_IMAGE_TEXT +#define QT_NO_DIR + +#define QT_NO_TEXTSTREAM +#define QT_NO_DATASTREAM +#define QT_NO_QWS_SAVEFONTS +//#define QT_NO_STRINGLIST +#define QT_NO_SESSIONMANAGER + + +#define QT_NO_DIALOG + +#define QT_NO_SEMIMODAL + +/* #define QT_NO_STYLE //will retquire substantial work... */ + +#define QT_NO_EFFECTS +#define QT_NO_COP + +#define QT_NO_QWS_PROPERTIES + +#define QT_NO_RANGECONTROL +#define QT_NO_SPLITTER +#define QT_NO_STATUSBAR +#define QT_NO_TABBAR +#define QT_NO_TOOLBAR +#define QT_NO_TOOLTIP +#define QT_NO_VALIDATOR +#define QT_NO_WHATSTHIS +#define QT_NO_WIDGETSTACK +#define QT_NO_ACCEL +#define QT_NO_SIZEGRIP +#define QT_NO_HEADER +#define QT_NO_WORKSPACE +#define QT_NO_LCDNUMBER +#define QT_NO_STYLE_MOTIF +#define QT_NO_STYLE_PLATINUM +#define QT_NO_PROGRESSBAR + + +#define QT_NO_QWS_HYDRO_WM_STYLE +#define QT_NO_QWS_BEOS_WM_STYLE +#define QT_NO_QWS_KDE2_WM_STYLE +#define QT_NO_QWS_KDE_WM_STYLE +#define QT_NO_QWS_WINDOWS_WM_STYLE + + +/* other widgets that could be removed: */ +/* +#define QT_NO_MENUDATA +*/ + + +/* possible options: */ +/* +#define QT_NO_CURSOR +#define QT_NO_LAYOUT +#define QT_NO_QWS_MANAGER +#define QT_NO_QWS_KEYBOARD +*/ diff --git a/src/tools/qcriticalsection_p.cpp b/src/tools/qcriticalsection_p.cpp new file mode 100644 index 000000000..e905742a8 --- /dev/null +++ b/src/tools/qcriticalsection_p.cpp @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Implementation of TQCriticalSection class +** +** Copyright (C) 2005-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#if defined(QT_THREAD_SUPPORT) + +#include "qt_windows.h" + +#include + +class TQCriticalSectionPrivate +{ +public: + TQCriticalSectionPrivate() {} + + CRITICAL_SECTION section; +}; + + +TQCriticalSection::TQCriticalSection() +{ + d = new TQCriticalSectionPrivate; + InitializeCriticalSection( &d->section ); +} + +TQCriticalSection::~TQCriticalSection() +{ + DeleteCriticalSection( &d->section ); + delete d; +} + +void TQCriticalSection::enter() +{ + EnterCriticalSection( &d->section ); +} + +void TQCriticalSection::leave() +{ + LeaveCriticalSection( &d->section ); +} + +#endif diff --git a/src/tools/qcriticalsection_p.h b/src/tools/qcriticalsection_p.h new file mode 100644 index 000000000..506660e32 --- /dev/null +++ b/src/tools/qcriticalsection_p.h @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Definition of TQCriticalSection class +** +** Copyright (C) 2001-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQCRITICALSECTION_P_H +#define TQCRITICALSECTION_P_H + +#ifndef QT_H +#endif // QT_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the TQt API. It exists for the convenience +// of TQt Remote Control. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// +// + +#if defined(QT_THREAD_SUPPORT) + +#if defined(Q_WS_WIN) + +/* + TQCriticalSection +*/ + +class TQCriticalSectionPrivate; + +class TQCriticalSection +{ +public: + TQCriticalSection(); + ~TQCriticalSection(); + void enter(); + void leave(); + +private: + TQCriticalSectionPrivate *d; +}; + +#endif + +#endif + +#endif diff --git a/src/tools/qcstring.cpp b/src/tools/qcstring.cpp new file mode 100644 index 000000000..09bbf99ef --- /dev/null +++ b/src/tools/qcstring.cpp @@ -0,0 +1,2539 @@ +/**************************************************************************** +** +** Implementation of extended char array operations, and TQByteArray and +** TQCString classes +** +** Created : 920722 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "qstring.h" +#include "qregexp.h" +#include "qdatastream.h" + +#ifdef QT_THREAD_SUPPORT +# include +#endif // QT_THREAD_SUPPORT + +#include +#include +#include +#include +#include +#ifndef QT_NO_COMPRESS +#include "../3rdparty/zlib/zlib.h" +#endif + +/***************************************************************************** + Safe and portable C string functions; extensions to standard string.h + *****************************************************************************/ + +/*! + \relates TQCString + + This function is normally part of the C library. TQt implements + memmove() for platforms that do not provide it. + + memmove() copies \a len bytes from \a src into \a dst. The data + is copied correctly even if \a src and \a dst overlap. +*/ + +void *qmemmove( void *dst, const void *src, uint len ) +{ + register char *d; + register char *s; + if ( dst > src ) { + d = (char *)dst + len - 1; + s = (char *)src + len - 1; + while ( len-- ) + *d-- = *s--; + } else if ( dst < src ) { + d = (char *)dst; + s = (char *)src; + while ( len-- ) + *d++ = *s++; + } + return dst; +} + + +/*! + \relates TQCString + + Returns a duplicate string. + + Allocates space for a copy of \a src, copies it, and returns a + pointer to the copy. If \a src is 0, it immediately returns 0. + + The returned string must be deleted using \c delete[]. +*/ + +char *qstrdup( const char *src ) +{ + if ( !src ) + return 0; + char *dst = new char[strlen(src)+1]; + Q_CHECK_PTR( dst ); + return strcpy( dst, src ); +} + +/*! + \fn char *qstrcpy( char *dst, const char *src ) + + \relates TQCString + + A safe strcpy() function. + + Copies all characters up to and including the '\0' from \a src + into \a dst and returns a pointer to \a dst. +*/ + +/*! + \relates TQCString + + A safe strncpy() function. + + Copies at most \a len bytes from \a src (stopping at \a len or the + terminating '\0' whichever comes first) into \a dst and returns a + pointer to \a dst. Guarantees that \a dst is '\0'-terminated. If + \a src or \a dst is 0, returns 0 immediately. + + \sa qstrcpy() +*/ + +char *qstrncpy( char *dst, const char *src, uint len ) +{ + if ( !src || !dst ) + return 0; + strncpy( dst, src, len ); + if ( len > 0 ) + dst[len-1] = '\0'; + return dst; +} + +/*! + \fn uint qstrlen( const char *str ); + + \relates TQCString + + A safe strlen function. + + Returns the number of characters that precede the terminating '\0'. + or 0 if \a str is 0. +*/ + +/*! + \fn int qstrcmp( const char *str1, const char *str2 ); + + \relates TQCString + + A safe strcmp() function. + + Compares \a str1 and \a str2. Returns a negative value if \a str1 + is less than \a str2, 0 if \a str1 is equal to \a str2 or a + positive value if \a str1 is greater than \a str2. + + Special case I: Returns 0 if \a str1 and \a str2 are both 0. + + Special case II: Returns a random nonzero value if \a str1 is 0 + or \a str2 is 0 (but not both). + + \sa qstrncmp() qstricmp() qstrnicmp() + \link #asciinotion Note on character comparisons \endlink +*/ + +/*! + \fn int qstrncmp( const char *str1, const char *str2, uint len ); + + \relates TQCString + + A safe strncmp() function. + + Compares at most \a len bytes of \a str1 and \a str2. + + Returns a negative value if \a str1 is less than \a str2, 0 if \a + str1 is equal to \a str2 or a positive value if \a str1 is greater + than \a str2. + + Special case I: Returns 0 if \a str1 and \a str2 are both 0. + + Special case II: Returns a random nonzero value if \a str1 is 0 + or \a str2 is 0 (but not both). + + \sa qstrcmp(), qstricmp(), qstrnicmp() + \link #asciinotion Note on character comparisons \endlink +*/ + +/*! + \relates TQCString + + A safe stricmp() function. + + Compares \a str1 and \a str2 ignoring the case. + + Returns a negative value if \a str1 is less than \a str2, 0 if \a + str1 is equal to \a str2 or a positive value if \a str1 is greater + than \a str2. + + Special case I: Returns 0 if \a str1 and \a str2 are both 0. + + Special case II: Returns a random nonzero value if \a str1 is 0 + or \a str2 is 0 (but not both). + + \sa qstrcmp(), qstrncmp(), qstrnicmp() + \link #asciinotion Note on character comparisons \endlink +*/ + +int qstricmp( const char *str1, const char *str2 ) +{ + register const uchar *s1 = (const uchar *)str1; + register const uchar *s2 = (const uchar *)str2; + int res; + uchar c; + if ( !s1 || !s2 ) + return s1 ? 1 : ( s2 ? -1 : 0 ); + for ( ; !(res = (c=tolower(*s1)) - tolower(*s2)); s1++, s2++ ) + if ( !c ) // strings are equal + break; + return res; +} + +/*! + \relates TQCString + + A safe strnicmp() function. + + Compares at most \a len bytes of \a str1 and \a str2 ignoring the case. + + Returns a negative value if \a str1 is less than \a str2, 0 if \a str1 + is equal to \a str2 or a positive value if \a str1 is greater than \a + str2. + + Special case I: Returns 0 if \a str1 and \a str2 are both 0. + + Special case II: Returns a random nonzero value if \a str1 is 0 + or \a str2 is 0 (but not both). + + \sa qstrcmp(), qstrncmp() qstricmp() + \link #asciinotion Note on character comparisons \endlink +*/ + +int qstrnicmp( const char *str1, const char *str2, uint len ) +{ + register const uchar *s1 = (const uchar *)str1; + register const uchar *s2 = (const uchar *)str2; + int res; + uchar c; + if ( !s1 || !s2 ) + return s1 ? 1 : ( s2 ? -1 : 0 ); + for ( ; len--; s1++, s2++ ) { + if ( (res = (c=tolower(*s1)) - tolower(*s2)) ) + return res; + if ( !c ) // strings are equal + break; + } + return 0; +} + + +static Q_UINT16 crc_tbl[16]; +static bool crc_tbl_init = FALSE; + +static void createCRC16Table() // build CRC16 lookup table +{ + register uint i; + register uint j; + uint v0, v1, v2, v3; + for ( i = 0; i < 16; i++ ) { + v0 = i & 1; + v1 = ( i >> 1 ) & 1; + v2 = ( i >> 2 ) & 1; + v3 = ( i >> 3 ) & 1; + j = 0; +#undef SET_BIT +#define SET_BIT(x, b, v) (x) |= (v) << (b) + SET_BIT( j, 0, v0 ); + SET_BIT( j, 7, v0 ); + SET_BIT( j, 12, v0 ); + SET_BIT( j, 1, v1 ); + SET_BIT( j, 8, v1 ); + SET_BIT( j, 13, v1 ); + SET_BIT( j, 2, v2 ); + SET_BIT( j, 9, v2 ); + SET_BIT( j, 14, v2 ); + SET_BIT( j, 3, v3 ); + SET_BIT( j, 10, v3 ); + SET_BIT( j, 15, v3 ); + crc_tbl[i] = j; + } +} + +/*! + \relates TQMemArray + + Returns the CRC-16 checksum of \a len bytes starting at \a data. + + The checksum is independent of the byte order (endianness). +*/ + +Q_UINT16 qChecksum( const char *data, uint len ) +{ + if ( !crc_tbl_init ) { // create lookup table + +#ifdef QT_THREAD_SUPPORT + TQMutexLocker locker( qt_global_mutexpool ? + qt_global_mutexpool->get( &crc_tbl_init ) : 0 ); +#endif // QT_THREAD_SUPPORT + + if ( !crc_tbl_init ) { + createCRC16Table(); + crc_tbl_init = TRUE; + } + } + register Q_UINT16 crc = 0xffff; + uchar c; + uchar *p = (uchar *)data; + while ( len-- ) { + c = *p++; + crc = ( (crc >> 4) & 0x0fff ) ^ crc_tbl[((crc ^ c) & 15)]; + c >>= 4; + crc = ( (crc >> 4) & 0x0fff ) ^ crc_tbl[((crc ^ c) & 15)]; + } + return ~crc & 0xffff; +} + +/*! + \fn TQByteArray qCompress( const TQByteArray& data ) + + \relates TQByteArray + + Compresses the array \a data and returns the compressed byte + array using zlib. + + \sa qUncompress() +*/ + +/*! + \relates TQByteArray + + \overload + + Compresses the array \a data which is \a nbytes long and returns the + compressed byte array. +*/ + +#ifndef QT_NO_COMPRESS +TQByteArray qCompress( const uchar* data, int nbytes ) +{ + if ( nbytes == 0 ) { + TQByteArray tmp( 4 ); + tmp.fill( 0 ); + return tmp; + } + if ( !data ) { +#if defined(QT_CHECK_RANGE) + qWarning( "qCompress: data is NULL." ); +#endif + return TQByteArray(); + } + + ulong len = nbytes + nbytes / 100 + 13; + TQByteArray bazip; + int res; + do { + bazip.resize( len + 4 ); + res = ::compress( (uchar*)bazip.data()+4, &len, (uchar*)data, nbytes ); + + switch ( res ) { + case Z_OK: + bazip.resize( len + 4 ); + bazip[0] = ( nbytes & 0xff000000 ) >> 24; + bazip[1] = ( nbytes & 0x00ff0000 ) >> 16; + bazip[2] = ( nbytes & 0x0000ff00 ) >> 8; + bazip[3] = ( nbytes & 0x000000ff ); + break; + case Z_MEM_ERROR: +#if defined(QT_CHECK_RANGE) + qWarning( "qCompress: Z_MEM_ERROR: Not enough memory." ); +#endif + bazip.resize( 0 ); + break; + case Z_BUF_ERROR: + len *= 2; + break; + } + } while ( res == Z_BUF_ERROR ); + + return bazip; +} +#endif + +/*! + \fn TQByteArray qUncompress( const TQByteArray& data ) + + \relates TQByteArray + + Uncompresses the array \a data and returns the uncompressed byte + array. + + Returns an empty TQByteArray if the input data was corrupt. + \omit + ADD THE FOLLOWING FOR TQt 4.0 + This function will uncompress data compressed with qCompress() + from this and any earlier TQt version, back to TQt 3.1 when this + feature was added. + \endomit + + \sa qCompress() +*/ + +/*! + \relates TQByteArray + + \overload + + Uncompresses the array \a data which is \a nbytes long and returns + the uncompressed byte array. +*/ + +#ifndef QT_NO_COMPRESS +TQByteArray qUncompress( const uchar* data, int nbytes ) +{ + if ( !data ) { +#if defined(QT_CHECK_RANGE) + qWarning( "qUncompress: data is NULL." ); +#endif + return TQByteArray(); + } + if ( nbytes <= 4 ) { +#if defined(QT_CHECK_RANGE) + if ( nbytes < 4 || ( data[0]!=0 || data[1]!=0 || data[2]!=0 || data[3]!=0 ) ) + qWarning( "qUncompress: Input data is corrupted." ); +#endif + return TQByteArray(); + } + ulong expectedSize = ( data[0] << 24 ) | ( data[1] << 16 ) | ( data[2] << 8 ) | data[3]; + ulong len = TQMAX( expectedSize, 1 ); + TQByteArray baunzip; + int res; + do { + if ( baunzip.resize( len ) ) { + res = ::uncompress( (uchar*)baunzip.data(), &len, + (uchar*)data+4, nbytes-4 ); + } else { + res = Z_MEM_ERROR; + } + + switch ( res ) { + case Z_OK: + if ( len != baunzip.size() ) + baunzip.resize( len ); + break; + case Z_MEM_ERROR: +#if defined(QT_CHECK_RANGE) + qWarning( "qUncompress: Z_MEM_ERROR: Not enough memory." ); +#endif + break; + case Z_BUF_ERROR: + len *= 2; + break; + case Z_DATA_ERROR: +#if defined(QT_CHECK_RANGE) + qWarning( "qUncompress: Z_DATA_ERROR: Input data is corrupted." ); +#endif + break; + } + } while ( res == Z_BUF_ERROR ); + + if ( res != Z_OK ) + baunzip = TQByteArray(); + + return baunzip; +} +#endif + +/***************************************************************************** + TQByteArray documentation + *****************************************************************************/ + +/*! + \class TQByteArray + \reentrant + \brief The TQByteArray class provides an array of bytes. + + \ingroup collection + \ingroup tools + + The TQByteArray class provides an explicitly shared array of bytes. + It is useful for manipulating memory areas with custom data. + TQByteArray is implemented as a TQMemArray\. See the \l + TQMemArray documentation for further information. +*/ + +/*! + \fn TQByteArray::TQByteArray() + + Constructs an empty TQByteArray. +*/ + +/*! + \fn TQByteArray::TQByteArray( int size ) + + Constructs a TQByteArray of size \a size. +*/ + +/***************************************************************************** + TQByteArray stream functions + *****************************************************************************/ + +/*! + \relates TQMemArray + + Writes byte array \a a to the stream \a s and returns a reference + to the stream. + + \sa \link datastreamformat.html Format of the TQDataStream operators \endlink +*/ +#ifndef QT_NO_DATASTREAM + +TQDataStream &operator<<( TQDataStream &s, const TQByteArray &a ) +{ + return s.writeBytes( a.data(), a.size() ); +} + +/*! + \relates TQMemArray + + Reads a byte array into \a a from the stream \a s and returns a + reference to the stream. + + \sa \link datastreamformat.html Format of the TQDataStream operators \endlink +*/ + +TQDataStream &operator>>( TQDataStream &s, TQByteArray &a ) +{ + Q_UINT32 len; + s >> len; // read size of array + if ( len == 0 || s.eof() ) { // end of file reached + a.resize( 0 ); + return s; + } + if ( !a.resize( (uint)len ) ) { // resize array +#if defined(QT_CHECK_NULL) + qWarning( "TQDataStream: Not enough memory to read TQByteArray" ); +#endif + len = 0; + } + if ( len > 0 ) // not null array + s.readRawBytes( a.data(), (uint)len ); + return s; +} + +#endif //QT_NO_DATASTREAM + +/***************************************************************************** + TQCString member functions + *****************************************************************************/ + +/*! + \class TQCString qcstring.h + \reentrant + \brief The TQCString class provides an abstraction of the classic C + zero-terminated char array (char *). + + \ingroup text + \ingroup collection + \ingroup tools + \ingroup shared + + TQCString inherits TQByteArray, which is defined as + TQMemArray\. Since TQCString is a TQMemArray, it uses \link + shclass.html explicit sharing\endlink with a reference count. + + TQCString tries to behave like a more convenient \c{const char *}. + The price of doing this is that some algorithms will perform + badly. For example, append() is O(length()) since it scans for a + null terminator. Although you might use TQCString for text that is + never exposed to the user, for most purposes, and especially for + user-visible text, you should use TQString. TQString provides + implicit sharing, Unicode and other internationalization support, + and is well optimized. + + Note that for the TQCString methods that take a \c{const char *} + parameter the \c{const char *} must either be 0 (null) or not-null + and '\0' (NUL byte) terminated; otherwise the results are + undefined. + + A TQCString that has not been assigned to anything is \e null, i.e. + both the length and the data pointer is 0. A TQCString that + references the empty string ("", a single '\0' char) is \e empty. + Both null and empty TQCStrings are legal parameters to the methods. + Assigning \c{const char *} 0 to TQCString produces a null TQCString. + + The length() function returns the length of the string; resize() + resizes the string and truncate() truncates the string. A string + can be filled with a character using fill(). Strings can be left + or right padded with characters using leftJustify() and + rightJustify(). Characters, strings and regular expressions can be + searched for using find() and findRev(), and counted using + contains(). + + Strings and characters can be inserted with insert() and appended + with append(). A string can be prepended with prepend(). + Characters can be removed from the string with remove() and + replaced with replace(). + + Portions of a string can be extracted using left(), right() and + mid(). Whitespace can be removed using stripWhiteSpace() and + simplifyWhiteSpace(). Strings can be converted to uppercase or + lowercase with upper() and lower() respectively. + + Strings that contain numbers can be converted to numbers with + toShort(), toInt(), toLong(), toULong(), toFloat() and toDouble(). + Numbers can be converted to strings with setNum(). + + Many operators are overloaded to work with TQCStrings. TQCString + also supports some more obscure functions, e.g. sprintf(), + setStr() and setExpand(). + + \target asciinotion + \sidebar Note on Character Comparisons + + In TQCString the notion of uppercase and lowercase and of which + character is greater than or less than another character is locale + dependent. This affects functions which support a case insensitive + option or which compare or lowercase or uppercase their arguments. + Case insensitive operations and comparisons will be accurate if + both strings contain only ASCII characters. (If \c $LC_CTYPE is + set, most Unix systems do "the right thing".) Functions that this + affects include contains(), find(), findRev(), \l operator<(), \l + operator<=(), \l operator>(), \l operator>=(), lower() and + upper(). + + This issue does not apply to \l{TQString}s since they represent + characters using Unicode. + \endsidebar + + Performance note: The TQCString methods for TQRegExp searching are + implemented by converting the TQCString to a TQString and performing + the search on that. This implies a deep copy of the TQCString data. + If you are going to perform many TQRegExp searches on a large + TQCString, you will get better performance by converting the + TQCString to a TQString yourself, and then searching in the TQString. +*/ + +/*! + \fn TQCString::TQCString() + + Constructs a null string. + + \sa isNull() +*/ + +/*! + \fn TQCString::TQCString( const TQCString &s ) + + Constructs a shallow copy \a s. + + \sa assign() +*/ + +/*! + Constructs a string with room for \a size characters, including + the '\0'-terminator. Makes a null string if \a size == 0. + + If \a size \> 0, then the first and last characters in the string + are initialized to '\0'. All other characters are uninitialized. + + \sa resize(), isNull() +*/ + +TQCString::TQCString( int size ) + : TQByteArray( size ) +{ + if ( size > 0 ) { + *data() = '\0'; // set terminator + *(data()+(size-1)) = '\0'; + } +} + +/*! + Constructs a string that is a deep copy of \a str. + + If \a str is 0 a null string is created. + + \sa isNull() +*/ + +TQCString::TQCString( const char *str ) +{ + duplicate( str, qstrlen(str) + 1 ); +} + + +/*! + Constructs a string that is a deep copy of \a str. The copy will + be at most \a maxsize bytes long including the '\0'-terminator. + + Example: + \code + TQCString str( "helloworld", 6 ); // assigns "hello" to str + \endcode + + If \a str contains a 0 byte within the first \a maxsize bytes, the + resulting TQCString will be terminated by this 0. If \a str is 0 a + null string is created. + + \sa isNull() +*/ + +TQCString::TQCString( const char *str, uint maxsize ) +{ + if ( str == 0 ) + return; + uint len; // index of first '\0' + for ( len = 0; len < maxsize - 1; len++ ) { + if ( str[len] == '\0' ) + break; + } + TQByteArray::resize( len + 1 ); + memcpy( data(), str, len ); + data()[len] = 0; +} + +/*! + \reimp +*/ + +TQCString::~TQCString() +{ +} + +/*! + \fn TQCString &TQCString::operator=( const TQCString &s ) + + Assigns a shallow copy of \a s to this string and returns a + reference to this string. +*/ + +/*! + \overload TQCString &TQCString::operator=( const char *str ) + + Assigns a deep copy of \a str to this string and returns a + reference to this string. + + If \a str is 0 a null string is created. + + \sa isNull() +*/ + +/*! + \fn bool TQCString::isNull() const + + Returns TRUE if the string is null, i.e. if data() == 0; otherwise + returns FALSE. A null string is also an empty string. + + Example: + \code + TQCString a; // a.data() == 0, a.size() == 0, a.length() == 0 + TQCString b == ""; // b.data() == "", b.size() == 1, b.length() == 0 + a.isNull(); // TRUE because a.data() == 0 + a.isEmpty(); // TRUE because a.length() == 0 + b.isNull(); // FALSE because b.data() == "" + b.isEmpty(); // TRUE because b.length() == 0 + \endcode + + \sa isEmpty(), length(), size() +*/ + +/*! + \fn bool TQCString::isEmpty() const + + Returns TRUE if the string is empty, i.e. if length() == 0; + otherwise returns FALSE. An empty string is not always a null + string. + + See example in isNull(). + + \sa isNull(), length(), size() +*/ + +/*! + \fn uint TQCString::length() const + + Returns the length of the string, excluding the '\0'-terminator. + Equivalent to calling \c strlen(data()). + + Null strings and empty strings have zero length. + + \sa size(), isNull(), isEmpty() +*/ + +/*! + \fn bool TQCString::truncate( uint pos ) + + Truncates the string at position \a pos. + + Equivalent to calling \c resize(pos+1). + + Example: + \code + TQCString s = "truncate this string"; + s.truncate( 5 ); // s == "trunc" + \endcode + + \sa resize() +*/ + +/*! + Extends or shrinks the string to \a len bytes, including the + '\0'-terminator. + + A '\0'-terminator is set at position \c{len - 1} unless + \c{len == 0}. + + Example: + \code + TQCString s = "resize this string"; + s.resize( 7 ); // s == "resize" + \endcode + + \sa truncate() +*/ + +bool TQCString::resize( uint len ) +{ + detach(); + uint wasNull = isNull(); + if ( !TQByteArray::resize(len) ) + return FALSE; + if ( len ) + data()[len - 1] = '\0'; + if ( len > 0 && wasNull ) + data()[0] = '\0'; + return TRUE; +} + + +/*! + Implemented as a call to the native vsprintf() (see the manual for + your C library). + + If the string is shorter than 256 characters, this sprintf() calls + resize(256) to decrease the chance of memory corruption. The + string is resized back to its actual length before sprintf() + returns. + + Example: + \code + TQCString s; + s.sprintf( "%d - %s", 1, "first" ); // result < 256 chars + + TQCString big( 25000 ); // very long string + big.sprintf( "%d - %s", 2, longString ); // result < 25000 chars + \endcode + + \warning All vsprintf() implementations will write past the end of + the target string (*this) if the \a format specification and + arguments happen to be longer than the target string, and some + will also fail if the target string is longer than some arbitrary + implementation limit. + + Giving user-supplied arguments to sprintf() is risky: Sooner or + later someone will paste a huge line into your application. +*/ + +TQCString &TQCString::sprintf( const char *format, ... ) +{ + detach(); + va_list ap; + va_start( ap, format ); + if ( size() < 256 ) + TQByteArray::resize( 256 ); // make string big enough +#ifdef QT_VSNPRINTF + QT_VSNPRINTF( data(), size(), format, ap ); +#else + vsprintf( data(), format, ap ); +#endif + resize( qstrlen(data()) + 1 ); // truncate + va_end( ap ); + return *this; +} + + +/*! + Fills the string with \a len bytes of character \a c, followed by + a '\0'-terminator. + + If \a len is negative, then the current string length is used. + + Returns FALSE is \a len is nonnegative and there is not enough + memory to resize the string; otherwise returns TRUE. +*/ + +bool TQCString::fill( char c, int len ) +{ + detach(); + if ( len < 0 ) + len = length(); + if ( !TQByteArray::fill(c,len+1) ) + return FALSE; + *(data()+len) = '\0'; + return TRUE; +} + + +/*! + \fn TQCString TQCString::copy() const + + Returns a deep copy of this string. + + \sa detach() +*/ + + +/*! + Finds the first occurrence of the character \a c, starting at + position \a index. + + The search is case sensitive if \a cs is TRUE, or case insensitive + if \a cs is FALSE. + + Returns the position of \a c, or -1 if \a c could not be found. + + \sa \link #asciinotion Note on character comparisons \endlink +*/ + +int TQCString::find( char c, int index, bool cs ) const +{ + if ( (uint)index >= size() ) // index outside string + return -1; + register const char *d; + if ( cs ) { // case sensitive + d = strchr( data()+index, c ); + } else { + d = data()+index; + c = tolower( (uchar) c ); + while ( *d && tolower((uchar) *d) != c ) + d++; + if ( !*d && c ) // not found + d = 0; + } + return d ? (int)(d - data()) : -1; +} + +#define REHASH( a ) \ + if ( sl_minus_1 < sizeof(uint) * CHAR_BIT ) \ + hashHaystack -= (a) << sl_minus_1; \ + hashHaystack <<= 1 + +/*! + \overload + + Finds the first occurrence of the string \a str, starting at + position \a index. + + The search is case sensitive if \a cs is TRUE, or case insensitive + if \a cs is FALSE. + + Returns the position of \a str, or -1 if \a str could not be + found. + + \sa \link #asciinotion Note on character comparisons \endlink +*/ + +int TQCString::find( const char *str, int index, bool cs ) const +{ + return find( str, index, cs, length() ); +} + +int TQCString::find( const char *str, int index, bool cs, uint l ) const +{ + if ( (uint)index >= size() ) + return -1; + if ( !str ) + return -1; + if ( !*str ) + return index; + const uint sl = qstrlen( str ); + if ( sl + index > l ) + return -1; + + if ( sl == 1 ) + return find( *str, index, cs ); + + /* + See TQString::find() for details. + */ + const char* needle = str; + const char* haystack = data() + index; + const char* end = data() + (l-sl); + const uint sl_minus_1 = sl-1; + uint hashNeedle = 0, hashHaystack = 0,i; + + if ( cs ) { + for ( i = 0; i < sl; ++i ) { + hashNeedle = ((hashNeedle<<1) + needle[i] ); + hashHaystack = ((hashHaystack<<1) + haystack[i] ); + } + hashHaystack -= *(haystack+sl_minus_1); + + while ( haystack <= end ) { + hashHaystack += *(haystack+sl_minus_1); + if ( hashHaystack == hashNeedle && *needle == *haystack + && qstrncmp( needle, haystack, sl ) == 0 ) + return haystack - data(); + + REHASH( *haystack ); + ++haystack; + } + } else { + for ( i = 0; i < sl; ++i ) { + hashNeedle = ((hashNeedle<<1) + + tolower( needle[i] ) ); + hashHaystack = ((hashHaystack<<1) + + tolower( haystack[i] ) ); + } + hashHaystack -= tolower(*(haystack+sl_minus_1)); + + while ( haystack <= end ) { + hashHaystack += tolower(*(haystack+sl_minus_1)); + if ( hashHaystack == hashNeedle + && qstrnicmp( needle, haystack, sl ) == 0 ) + return haystack - data(); + + REHASH( tolower(*haystack) ); + ++haystack; + } + } + return -1; +} + + +/*! + Finds the first occurrence of the character \a c, starting at + position \a index and searching backwards. + + The search is case sensitive if \a cs is TRUE, or case insensitive + if \a cs is FALSE. + + Returns the position of \a c, or -1 if \a c could not be found. + + \sa \link #asciinotion Note on character comparisons \endlink +*/ + +int TQCString::findRev( char c, int index, bool cs ) const +{ + register const char *b = data(); + register const char *d; + if ( index < 0 ) + index = length(); + if ( (uint)index >= size() ) + return -1; + d = b + index; + if ( cs ) { + while ( d >= b && *d != c ) + d--; + } else { + c = tolower( (uchar) c ); + while ( d >= b && tolower((uchar) *d) != c ) + d--; + } + return d >= b ? (int)(d - b) : -1; +} + +/*! + \overload + + Finds the first occurrence of the string \a str, starting at + position \a index and searching backwards. + + The search is case sensitive if \a cs is TRUE, or case insensitive + if \a cs is FALSE. + + Returns the position of \a str, or -1 if \a str could not be + found. + + \sa \link #asciinotion Note on character comparisons \endlink +*/ + +int TQCString::findRev( const char *str, int index, bool cs ) const +{ + /* + See TQString::find() for explanations. + */ + const uint sl = qstrlen( str ); + const uint l = length(); + int delta = l-sl; + if ( index < 0 ) + index = delta; + if ( index < 0 || index > (int)l ) + return -1; + if ( index > delta ) + index = delta; + + if ( sl == 1 ) + return findRev( *str, index, cs ); + + const char* needle = str; + const char* haystack = data() + index; + const char* end = data(); + const uint sl_minus_1 = sl-1; + const char* n = needle+sl_minus_1; + const char* h = haystack+sl_minus_1; + uint hashNeedle = 0, hashHaystack = 0, i; + + if ( cs ) { + for ( i = 0; i < sl; ++i ) { + hashNeedle = ((hashNeedle<<1) + *(n-i) ); + hashHaystack = ((hashHaystack<<1) + *(h-i) ); + } + hashHaystack -= *haystack; + while ( haystack >= end ) { + hashHaystack += *haystack; + if ( hashHaystack == hashNeedle && qstrncmp( needle, haystack, sl ) == 0 ) + return haystack-data(); + --haystack; + REHASH( *(haystack+sl) ); + } + } else { + for ( i = 0; i < sl; ++i ) { + hashNeedle = ((hashNeedle<<1) + tolower( *(n-i) ) ); + hashHaystack = ((hashHaystack<<1) + tolower( *(h-i) ) ); + } + hashHaystack -= tolower(*haystack); + while ( haystack >= end ) { + hashHaystack += tolower(*haystack); + if ( hashHaystack == hashNeedle && qstrnicmp( needle, haystack, sl ) == 0 ) + return haystack-data(); + --haystack; + REHASH( tolower(*(haystack+sl)) ); + } + } + return -1; +} + + +/*! + Returns the number of times the character \a c occurs in the + string. + + The match is case sensitive if \a cs is TRUE, or case insensitive + if \a cs if FALSE. + + \sa \link #asciinotion Note on character comparisons \endlink +*/ + +int TQCString::contains( char c, bool cs ) const +{ + int count = 0; + char *d = data(); + if ( !d ) + return 0; + if ( cs ) { // case sensitive + while ( *d ) + if ( *d++ == c ) + count++; + } else { // case insensitive + c = tolower( (uchar) c ); + while ( *d ) { + if ( tolower((uchar) *d) == c ) + count++; + d++; + } + } + return count; +} + +/*! + \overload + + Returns the number of times \a str occurs in the string. + + The match is case sensitive if \a cs is TRUE, or case insensitive + if \a cs if FALSE. + + This function counts overlapping substrings, for example, "banana" + contains two occurrences of "ana". + + \sa findRev() + \link #asciinotion Note on character comparisons \endlink +*/ + +int TQCString::contains( const char *str, bool cs ) const +{ + int count = 0; + int i = -1; + uint l = length(); + // use find for the faster hashing algorithm + while ( ( i = find ( str, i+1, cs, l ) ) != -1 ) + count++; + return count; +} + +/*! + Returns a substring that contains the \a len leftmost characters + of the string. + + The whole string is returned if \a len exceeds the length of the + string. + + Example: + \code + TQCString s = "Pineapple"; + TQCString t = s.left( 4 ); // t == "Pine" + \endcode + + \sa right(), mid() +*/ +TQCString TQCString::left( uint len ) const +{ + if ( isEmpty() ) { + TQCString empty; + return empty; + } else if ( len >= size() ) { + TQCString same( data() ); + return same; + } else { + TQCString s( len+1 ); + strncpy( s.data(), data(), len ); + *(s.data()+len) = '\0'; + return s; + } +} + +/*! + Returns a substring that contains the \a len rightmost characters + of the string. + + The whole string is returned if \a len exceeds the length of the + string. + + Example: + \code + TQCString s = "Pineapple"; + TQCString t = s.right( 5 ); // t == "apple" + \endcode + + \sa left(), mid() +*/ + +TQCString TQCString::right( uint len ) const +{ + if ( isEmpty() ) { + TQCString empty; + return empty; + } else { + uint l = length(); + if ( len > l ) + len = l; + char *p = data() + (l - len); + return TQCString( p ); + } +} + +/*! + Returns a substring that contains at most \a len characters from + this string, starting at position \a index. + + Returns a null string if the string is empty or if \a index is out + of range. Returns the whole string from \a index if \a index+len + exceeds the length of the string. + + Example: + \code + TQCString s = "Two pineapples"; + TQCString t = s.mid( 4, 3 ); // t == "pin" + \endcode + + \sa left(), right() +*/ + +TQCString TQCString::mid( uint index, uint len ) const +{ + uint slen = qstrlen( data() ); + if ( isEmpty() || index >= slen ) { + TQCString empty; + return empty; + } else { + if ( len > slen-index ) + len = slen - index; + register char *p = data()+index; + TQCString s( len+1 ); + strncpy( s.data(), p, len ); + *(s.data()+len) = '\0'; + return s; + } +} + +/*! + Returns a string of length \a width (plus one for the terminating + '\0') that contains this string padded with the \a fill character. + + If the length of the string exceeds \a width and \a truncate is + FALSE (the default), then the returned string is a copy of the + string. If the length of the string exceeds \a width and \a + truncate is TRUE, then the returned string is a left(\a width). + + Example: + \code + TQCString s("apple"); + TQCString t = s.leftJustify(8, '.'); // t == "apple..." + \endcode + + \sa rightJustify() +*/ + +TQCString TQCString::leftJustify( uint width, char fill, bool truncate ) const +{ + TQCString result; + int len = qstrlen(data()); + int padlen = width - len; + if ( padlen > 0 ) { + result.TQByteArray::resize( len+padlen+1 ); + memcpy( result.data(), data(), len ); + memset( result.data()+len, fill, padlen ); + result[len+padlen] = '\0'; + } else { + if ( truncate ) + result = left( width ); + else + result = copy(); + } + return result; +} + +/*! + Returns a string of length \a width (plus one for the terminating + '\0') that contains zero or more of the \a fill character followed + by this string. + + If the length of the string exceeds \a width and \a truncate is + FALSE (the default), then the returned string is a copy of the + string. If the length of the string exceeds \a width and \a + truncate is TRUE, then the returned string is a left(\a width). + + Example: + \code + TQCString s("pie"); + TQCString t = s.rightJustify(8, '.'); // t == ".....pie" + \endcode + + \sa leftJustify() +*/ + +TQCString TQCString::rightJustify( uint width, char fill, bool truncate ) const +{ + TQCString result; + int len = qstrlen(data()); + int padlen = width - len; + if ( padlen > 0 ) { + result.TQByteArray::resize( len+padlen+1 ); + memset( result.data(), fill, padlen ); + memcpy( result.data()+padlen, data(), len ); + result[len+padlen] = '\0'; + } else { + if ( truncate ) + result = left( width ); + else + result = copy(); + } + return result; +} + +/*! + Returns a new string that is a copy of this string converted to lower + case. + + Example: + \code + TQCString s("Credit"); + TQCString t = s.lower(); // t == "credit" + \endcode + + \sa upper() + \link #asciinotion Note on character comparisons \endlink +*/ + +TQCString TQCString::lower() const +{ + TQCString s( data() ); + register char *p = s.data(); + if ( p ) { + while ( *p ) { + *p = tolower( (uchar) *p ); + p++; + } + } + return s; +} + +/*! + Returns a new string that is a copy of this string converted to upper case. + + Example: + \code + TQCString s( "Debit" ); + TQCString t = s.upper(); // t == "DEBIT" + \endcode + + \sa lower() + \link #asciinotion Note on character comparisons \endlink +*/ + +TQCString TQCString::upper() const +{ + TQCString s( data() ); + register char *p = s.data(); + if ( p ) { + while ( *p ) { + *p = toupper(*p); + p++; + } + } + return s; +} + + +/*! + Returns a new string that has white space removed from the start + and the end. + + White space means the decimal ASCII codes 9, 10, 11, 12, 13 and + 32. + + Example: + \code + TQCString s = " space "; + TQCString t = s.stripWhiteSpace(); // t == "space" + \endcode + + \sa simplifyWhiteSpace() +*/ + +TQCString TQCString::stripWhiteSpace() const +{ + if ( isEmpty() ) // nothing to do + return copy(); + + register char *s = data(); + TQCString result = s; + int reslen = result.length(); + if ( !isspace((uchar) s[0]) && !isspace((uchar) s[reslen-1]) ) + return result; // returns a copy + + s = result.data(); + int start = 0; + int end = reslen - 1; + while ( isspace((uchar) s[start]) ) // skip white space from start + start++; + if ( s[start] == '\0' ) { // only white space + result.resize( 1 ); + return result; + } + while ( end && isspace((uchar) s[end]) ) // skip white space from end + end--; + end -= start - 1; + memmove( result.data(), &s[start], end ); + result.resize( end + 1 ); + return result; +} + + +/*! + Returns a new string that has white space removed from the start + and the end, plus any sequence of internal white space replaced + with a single space (ASCII 32). + + White space means the decimal ASCII codes 9, 10, 11, 12, 13 and + 32. + + \code + TQCString s = " lots\t of\nwhite space "; + TQCString t = s.simplifyWhiteSpace(); // t == "lots of white space" + \endcode + + \sa stripWhiteSpace() +*/ + +TQCString TQCString::simplifyWhiteSpace() const +{ + if ( isEmpty() ) // nothing to do + return copy(); + TQCString result( size() ); + char *from = data(); + char *to = result.data(); + char *first = to; + for ( ;; ) { + while ( isspace((uchar) *from) ) + from++; + while ( *from && !isspace((uchar) *from) ) + *to++ = *from++; + if ( *from ) + *to++ = 0x20; // ' ' + else + break; + } + if ( to > first && *(to-1) == 0x20 ) + to--; + *to = '\0'; + result.resize( (int)(to - result.data()) + 1 ); + return result; +} + + +/*! + \overload + + Inserts string \a s into the string at position \a index. + + If \a index is beyond the end of the string, the string is + padded with spaces (ASCII 32) to length \a index and then \a s + is appended. + + \code + TQCString s = "I like fish"; + s.insert( 2, "don't "); // s == "I don't like fish" + + s = "x"; // index 01234 + s.insert( 3, "yz" ); // s == "x yz" + \endcode +*/ + +TQCString &TQCString::insert( uint index, const char *s ) +{ + int len = qstrlen(s); + if ( len == 0 ) + return *this; + uint olen = length(); + int nlen = olen + len; + if ( index >= olen ) { // insert after end of string + detach(); + if ( TQByteArray::resize(nlen+index-olen+1, TQByteArray::SpeedOptim ) ) { + memset( data()+olen, ' ', index-olen ); + memcpy( data()+index, s, len+1 ); + } + } else { + detach(); + if ( TQByteArray::resize(nlen+1, TQByteArray::SpeedOptim ) ) { // normal insert + memmove( data()+index+len, data()+index, olen-index+1 ); + memcpy( data()+index, s, len ); + } + } + return *this; +} + +/*! + Inserts character \a c into the string at position \a index and + returns a reference to the string. + + If \a index is beyond the end of the string, the string is + padded with spaces (ASCII 32) to length \a index and then \a c + is appended. + + Example: + \code + TQCString s = "Yes"; + s.insert( 3, '!'); // s == "Yes!" + \endcode + + \sa remove(), replace() +*/ + +TQCString &TQCString::insert( uint index, char c ) // insert char +{ + char buf[2]; + buf[0] = c; + buf[1] = '\0'; + return insert( index, buf ); +} + +/*! + \fn TQCString &TQCString::prepend( const char *s ) + + Prepend \a s to the string. Equivalent to insert(0, s). + + \sa insert() +*/ + +/*! + Removes \a len characters from the string, starting at position \a + index, and returns a reference to the string. + + If \a index is out of range, nothing happens. If \a index is + valid, but \a index + \a len is larger than the length of the + string, the string is truncated at position \a index. + + \code + TQCString s = "Montreal"; + s.remove( 1, 4 ); // s == "Meal" + \endcode + + \sa insert(), replace() +*/ + +TQCString &TQCString::remove( uint index, uint len ) +{ + uint olen = length(); + if ( index + len >= olen ) { // range problems + if ( index < olen ) { // index ok + detach(); + resize( index+1 ); + } + } else if ( len != 0 ) { + detach(); + memmove( data()+index, data()+index+len, olen-index-len+1 ); + TQByteArray::resize(olen-len+1, TQByteArray::SpeedOptim ); + } + return *this; +} + +/*! + Replaces \a len characters from the string, starting at position + \a index, with \a str, and returns a reference to the string. + + If \a index is out of range, nothing is removed and \a str is + appended at the end of the string. If \a index is valid, but \a + index + \a len is larger than the length of the string, \a str + replaces the rest of the string from position \a index. + + \code + TQCString s = "Say yes!"; + s.replace( 4, 3, "NO" ); // s == "Say NO!" + \endcode + + \sa insert(), remove() +*/ + +TQCString &TQCString::replace( uint index, uint len, const char *str ) +{ + remove( index, len ); + insert( index, str ); + return *this; +} + + +/*! \overload + + Replaces every occurrence of the character \a c in the string + with \a after. Returns a reference to the string. + + Example: + \code + TQCString s = "a,b,c"; + s.replace( ',', " or " ); + // s == "a or b or c" + \endcode +*/ +TQCString &TQCString::replace( char c, const char *after ) +{ + char str[2]; + str[0] = c; + str[1] = '\0'; + return replace( str, after ); +} + +/*! \overload + + Replaces every occurrence of the string \a before in the string + with the string \a after. Returns a reference to the string. + + Example: + \code + TQCString s = "Greek is Greek"; + s.replace( "Greek", "English" ); + // s == "English is English" + \endcode +*/ + +TQCString &TQCString::replace( const char *before, const char *after ) +{ + if ( before == after || isNull() ) + return *this; + + detach(); + + int index = 0; + const int bl = before ? int(strlen( before )) : 0; + const int al = after ? int(strlen( after )) : 0; + char *d = data(); + uint len = length(); + + if ( bl == al ) { + if ( bl ) { + while( (index = find( before, index, TRUE, len ) ) != -1 ) { + memcpy( d+index, after, al ); + index += bl; + } + } + } else if ( al < bl ) { + uint to = 0; + uint movestart = 0; + uint num = 0; + while( (index = find( before, index, TRUE, len ) ) != -1 ) { + if ( num ) { + int msize = index - movestart; + if ( msize > 0 ) { + memmove( d + to, d + movestart, msize ); + to += msize; + } + } else { + to = index; + } + if ( al ) { + memcpy( d + to, after, al ); + to += al; + } + index += bl; + movestart = index; + num++; + } + if ( num ) { + int msize = len - movestart; + if ( msize > 0 ) + memmove( d + to, d + movestart, msize ); + resize( len - num*(bl-al) + 1 ); + } + } else { + // the most complex case. We don't want to loose performance by doing repeated + // copies and reallocs of the string. + while( index != -1 ) { + uint indices[4096]; + uint pos = 0; + while( pos < 4095 ) { + index = find(before, index, TRUE, len); + if ( index == -1 ) + break; + indices[pos++] = index; + index += bl; + // avoid infinite loop + if ( !bl ) + index++; + } + if ( !pos ) + break; + + // we have a table of replacement positions, use them for fast replacing + int adjust = pos*(al-bl); + // index has to be adjusted in case we get back into the loop above. + if ( index != -1 ) + index += adjust; + uint newlen = len + adjust; + int moveend = len; + if ( newlen > len ) { + resize( newlen + 1 ); + len = newlen; + } + d = data(); + + while( pos ) { + pos--; + int movestart = indices[pos] + bl; + int insertstart = indices[pos] + pos*(al-bl); + int moveto = insertstart + al; + memmove( d + moveto, d + movestart, (moveend - movestart) ); + if ( after ) + memcpy( d + insertstart, after, al ); + moveend = movestart - bl; + } + } + } + return *this; +} + +/*! \overload + + Replaces every occurrence of \a c1 with the char \a c2. + Returns a reference to the string. +*/ +TQCString &TQCString::replace( char c1, char c2 ) +{ + detach(); + uint i = 0; + char *d = data(); + uint len = length(); + while ( i < len ) { + if ( d[i] == c1 ) + d[i] = c2; + i++; + } + return *this; +} + + +#ifndef QT_NO_REGEXP_CAPTURE +/*! + \overload + + Finds the first occurrence of the regular expression \a rx, + starting at position \a index. + + Returns the position of the next match, or -1 if \a rx was not + found. + + \warning If you want to apply this function repeatedly to the same + string it is more efficient to convert the string to a TQString and + apply the function to that. +*/ + +int TQCString::find( const TQRegExp& rx, int index ) const +{ + TQString d = TQString::fromAscii( data() ); + return d.find( rx, index ); +} + +/*! + \overload + + Finds the first occurrence of the regular expression \a rx, + starting at position \a index and searching backwards. + + Returns the position of the next match (backwards), or -1 if \a rx + was not found. + + \warning If you want to apply this function repeatedly to the same + string it is more efficient to convert the string to a TQString and + apply the function to that. +*/ + +int TQCString::findRev( const TQRegExp& rx, int index ) const +{ + TQString d = TQString::fromAscii( data() ); + return d.findRev( rx, index ); +} + +/*! + \overload + + Counts the number of overlapping occurrences of \a rx in the string. + + Example: + \code + TQString s = "banana and panama"; + TQRegExp r = TQRegExp( "a[nm]a", TRUE, FALSE ); + s.contains( r ); // 4 matches + \endcode + + \sa find(), findRev() + + \warning If you want to apply this function repeatedly to the same + string it is more efficient to convert the string to a TQString and + apply the function to that. +*/ + +int TQCString::contains( const TQRegExp &rx ) const +{ + TQString d = TQString::fromAscii( data() ); + return d.contains( rx ); +} + + +/*! + \overload + + Replaces every occurrence of \a rx in the string with \a str. + Returns a reference to the string. + + Example: + \code + TQString s = "banana"; + s.replace( TQRegExp("a.*a"), "" ); // becomes "b" + + s = "banana"; + s.replace( TQRegExp("^[bn]a"), "X" ); // becomes "Xnana" + + s = "banana"; + s.replace( TQRegExp("^[bn]a"), "" ); // becomes "nana" + \endcode + + \warning If you want to apply this function repeatedly to the same + string it is more efficient to convert the string to a TQString and + apply the function to that. +*/ + +TQCString &TQCString::replace( const TQRegExp &rx, const char *str ) +{ + TQString d = TQString::fromAscii( data() ); + TQString r = TQString::fromAscii( str ); + d.replace( rx, r ); + setStr( d.ascii() ); + return *this; +} +#endif //QT_NO_REGEXP + +/*! + Returns the string converted to a \c long value. + + If \a ok is not 0: \a *ok is set to FALSE if the string is not a + number, or if it has trailing garbage; otherwise \a *ok is set to + TRUE. +*/ + +long TQCString::toLong( bool *ok ) const +{ + char *p = data(); + long val=0; + const long max_mult = LONG_MAX / 10; + bool is_ok = FALSE; + int neg = 0; + if ( !p ) + goto bye; + while ( isspace((uchar) *p) ) // skip leading space + p++; + if ( *p == '-' ) { + p++; + neg = 1; + } else if ( *p == '+' ) { + p++; + } + if ( !isdigit((uchar) *p) ) + goto bye; + while ( isdigit((uchar) *p) ) { + if ( val > max_mult || (val == max_mult && (*p-'0') > 7+neg) ) + goto bye; + val = 10*val + (*p++ - '0'); + } + if ( neg ) + val = -val; + while ( isspace((uchar) *p) ) // skip trailing space + p++; + if ( *p == '\0' ) + is_ok = TRUE; +bye: + if ( ok ) + *ok = is_ok; + return is_ok ? val : 0; +} + +/*! + Returns the string converted to an \c{unsigned long} value. + + If \a ok is not 0: \a *ok is set to FALSE if the string is not a + number, or if it has trailing garbage; otherwise \a *ok is set to + TRUE. +*/ + +ulong TQCString::toULong( bool *ok ) const +{ + char *p = data(); + ulong val=0; + const ulong max_mult = ULONG_MAX / 10; + bool is_ok = FALSE; + if ( !p ) + goto bye; + while ( isspace((uchar) *p) ) // skip leading space + p++; + if ( *p == '+' ) + p++; + if ( !isdigit((uchar) *p) ) + goto bye; + while ( isdigit((uchar) *p) ) { + if ( val > max_mult || (val == max_mult && (*p-'0') > 5) ) + goto bye; + val = 10*val + (*p++ - '0'); + } + while ( isspace((uchar) *p) ) // skip trailing space + p++; + if ( *p == '\0' ) + is_ok = TRUE; +bye: + if ( ok ) + *ok = is_ok; + return is_ok ? val : 0; +} + +/*! + Returns the string converted to a \c{short} value. + + If \a ok is not 0: \a *ok is set to FALSE if the string is not a + number, is out of range, or if it has trailing garbage; otherwise + \a *ok is set to TRUE. +*/ + +short TQCString::toShort( bool *ok ) const +{ + long v = toLong( ok ); + if ( v < SHRT_MIN || v > SHRT_MAX ) { + if ( ok ) + *ok = FALSE; + v = 0; + } + return (short)v; +} + +/*! + Returns the string converted to an \c{unsigned short} value. + + If \a ok is not 0: \a *ok is set to FALSE if the string is not a + number, is out of range, or if it has trailing garbage; otherwise + \a *ok is set to TRUE. +*/ + +ushort TQCString::toUShort( bool *ok ) const +{ + ulong v = toULong( ok ); + if ( v > USHRT_MAX ) { + if ( ok ) + *ok = FALSE; + v = 0; + } + return (ushort)v; +} + + +/*! + Returns the string converted to a \c{int} value. + + If \a ok is not 0: \a *ok is set to FALSE if the string is not a + number, or if it has trailing garbage; otherwise \a *ok is set to + TRUE. +*/ + +int TQCString::toInt( bool *ok ) const +{ + long v = toLong( ok ); + if ( v < INT_MIN || v > INT_MAX ) { + if ( ok ) + *ok = FALSE; + v = 0; + } + return (int)v; +} + +/*! + Returns the string converted to an \c{unsigned int} value. + + If \a ok is not 0: \a *ok is set to FALSE if the string is not a + number, or if it has trailing garbage; otherwise \a *ok is set to + TRUE. +*/ + +uint TQCString::toUInt( bool *ok ) const +{ + ulong v = toULong( ok ); + if ( v > UINT_MAX ) { + if ( ok ) + *ok = FALSE; + v = 0; + } + return (uint)v; +} + +/*! + Returns the string converted to a \c{double} value. + + If \a ok is not 0: \a *ok is set to FALSE if the string is not a + number, or if it has trailing garbage; otherwise \a *ok is set to + TRUE. +*/ + +double TQCString::toDouble( bool *ok ) const +{ + char *end; + double val = strtod( data() ? data() : "", &end ); + if ( ok ) + *ok = ( data() && *data() && ( end == 0 || *end == '\0' ) ); + return val; +} + +/*! + Returns the string converted to a \c{float} value. + + If \a ok is not 0: \a *ok is set to FALSE if the string is not a + number, or if it has trailing garbage; otherwise \a *ok is set to + TRUE. +*/ + +float TQCString::toFloat( bool *ok ) const +{ + return (float)toDouble( ok ); +} + + +/*! + Makes a deep copy of \a str. Returns a reference to the string. +*/ + +TQCString &TQCString::setStr( const char *str ) +{ + detach(); + if ( str ) // valid string + store( str, qstrlen(str)+1 ); + else // empty + resize( 0 ); + return *this; +} + +/*! + \overload + + Sets the string to the string representation of the number \a n + and returns a reference to the string. +*/ + +TQCString &TQCString::setNum( long n ) +{ + detach(); + char buf[20]; + register char *p = &buf[19]; + bool neg; + if ( n < 0 ) { + neg = TRUE; + n = -n; + } else { + neg = FALSE; + } + *p = '\0'; + do { + *--p = ((int)(n%10)) + '0'; + n /= 10; + } while ( n ); + if ( neg ) + *--p = '-'; + store( p, qstrlen(p)+1 ); + return *this; +} + +/*! + \overload + + Sets the string to the string representation of the number \a n + and returns a reference to the string. +*/ + +TQCString &TQCString::setNum( ulong n ) +{ + detach(); + char buf[20]; + register char *p = &buf[19]; + *p = '\0'; + do { + *--p = ((int)(n%10)) + '0'; + n /= 10; + } while ( n ); + store( p, qstrlen(p)+1 ); + return *this; +} + +/*! + \overload TQCString &TQCString::setNum( int n ) + + Sets the string to the string representation of the number \a n + and returns a reference to the string. +*/ + +/*! + \overload TQCString &TQCString::setNum( uint n ) + + Sets the string to the string representation of the number \a n + and returns a reference to the string. +*/ + +/*! + \overload TQCString &TQCString::setNum( short n ) + + Sets the string to the string representation of the number \a n + and returns a reference to the string. +*/ + +/*! + \overload TQCString &TQCString::setNum( ushort n ) + + Sets the string to the string representation of the number \a n + and returns a reference to the string. +*/ + +/*! + Sets the string to the string representation of the number \a n + and returns a reference to the string. + + The format of the string representation is specified by the format + character \a f, and the precision (number of digits after the + decimal point) is specified with \a prec. + + The valid formats for \a f are 'e', 'E', 'f', 'g' and 'G'. The + formats are the same as for sprintf(); they are explained in \l + TQString::arg(). +*/ + +TQCString &TQCString::setNum( double n, char f, int prec ) +{ +#if defined(QT_CHECK_RANGE) + if ( !(f=='f' || f=='F' || f=='e' || f=='E' || f=='g' || f=='G') ) + qWarning( "TQCString::setNum: Invalid format char '%c'", f ); +#endif + char format[20]; + register char *fs = format; // generate format string + *fs++ = '%'; // "%.l" + if ( prec > 99 ) + prec = 99; + *fs++ = '.'; + if ( prec >= 10 ) { + *fs++ = prec / 10 + '0'; + *fs++ = prec % 10 + '0'; + } else { + *fs++ = prec + '0'; + } + *fs++ = 'l'; + *fs++ = f; + *fs = '\0'; + return sprintf( format, n ); +} + +/*! \overload TQCString &TQCString::setNum( float n, char f, int prec ) */ + + +/*! + Sets the character at position \a index to \a c and expands the + string if necessary, padding with spaces. + + Returns FALSE if \a index was out of range and the string could + not be expanded; otherwise returns TRUE. +*/ + +bool TQCString::setExpand( uint index, char c ) +{ + detach(); + uint oldlen = length(); + if ( index >= oldlen ) { + if ( !TQByteArray::resize( index+2 ) ) // no memory + return FALSE; + if ( index > oldlen ) + memset( data() + oldlen, ' ', index - oldlen ); + *(data() + index+1) = '\0'; // terminate padded string + } + *(data() + index) = c; + return TRUE; +} + + +/*! + \fn TQCString::operator const char *() const + + Returns the string data. +*/ + + +/*! + \fn TQCString& TQCString::append( const char *str ) + + Appends string \a str to the string and returns a reference to the + string. Equivalent to operator+=(). +*/ + +/*! + Appends string \a str to the string and returns a reference to the string. +*/ + +TQCString& TQCString::operator+=( const char *str ) +{ + if ( !str ) + return *this; // nothing to append + detach(); + uint len1 = length(); + uint len2 = qstrlen(str); + if ( !TQByteArray::resize( len1 + len2 + 1, TQByteArray::SpeedOptim ) ) + return *this; // no memory + memcpy( data() + len1, str, len2 + 1 ); + return *this; +} + +/*! + \overload + + Appends character \a c to the string and returns a reference to the string. +*/ + +TQCString &TQCString::operator+=( char c ) +{ + detach(); + uint len = length(); + if ( !TQByteArray::resize( len + 2, TQByteArray::SpeedOptim ) ) + return *this; // no memory + *(data() + len) = c; + *(data() + len+1) = '\0'; + return *this; +} + + +/***************************************************************************** + TQCString stream functions + *****************************************************************************/ +#ifndef QT_NO_DATASTREAM +/*! + \relates TQCString + + Writes string \a str to the stream \a s. + + \sa \link datastreamformat.html Format of the TQDataStream operators \endlink +*/ +TQDataStream &operator<<( TQDataStream &s, const TQCString &str ) +{ + return s.writeBytes( str.data(), str.size() ); +} + +/*! + \relates TQCString + + Reads a string into \a str from the stream \a s. + + \sa \link datastreamformat.html Format of the TQDataStream operators \endlink +*/ + +TQDataStream &operator>>( TQDataStream &s, TQCString &str ) +{ + str.detach(); + Q_UINT32 len; + s >> len; // read size of string + if ( len == 0 || s.eof() ) { // end of file reached + str.resize( 0 ); + return s; + } + if ( !str.TQByteArray::resize( (uint)len )) {// resize string +#if defined(QT_CHECK_NULL) + qWarning( "TQDataStream: Not enough memory to read TQCString" ); +#endif + len = 0; + } + if ( len > 0 ) // not null array + s.readRawBytes( str.data(), (uint)len ); + return s; +} +#endif //QT_NO_DATASTREAM + +/***************************************************************************** + Documentation for related functions + *****************************************************************************/ + +/*! + \fn bool operator==( const TQCString &s1, const TQCString &s2 ) + + \relates TQCString + + Returns TRUE if \a s1 and \a s2 are equal; otherwise returns FALSE. + + Equivalent to qstrcmp(\a s1, \a s2) == 0. +*/ + +/*! + \overload bool operator==( const TQCString &s1, const char *s2 ) + + \relates TQCString + + Returns TRUE if \a s1 and \a s2 are equal; otherwise returns FALSE. + + Equivalent to qstrcmp(\a s1, \a s2) == 0. +*/ + +/*! + \overload bool operator==( const char *s1, const TQCString &s2 ) + + \relates TQCString + + Returns TRUE if \a s1 and \a s2 are equal; otherwise returns FALSE. + + Equivalent to qstrcmp(\a s1, \a s2) == 0. +*/ + +/*! + \fn bool operator!=( const TQCString &s1, const TQCString &s2 ) + + \relates TQCString + + Returns TRUE if \a s1 and \a s2 are different; otherwise returns FALSE. + + Equivalent to qstrcmp(\a s1, \a s2) != 0. +*/ + +/*! + \overload bool operator!=( const TQCString &s1, const char *s2 ) + + \relates TQCString + + Returns TRUE if \a s1 and \a s2 are different; otherwise returns FALSE. + + Equivalent to qstrcmp(\a s1, \a s2) != 0. +*/ + +/*! + \overload bool operator!=( const char *s1, const TQCString &s2 ) + + \relates TQCString + + Returns TRUE if \a s1 and \a s2 are different; otherwise returns FALSE. + + Equivalent to qstrcmp(\a s1, \a s2) != 0. +*/ + +/*! + \fn bool operator<( const TQCString &s1, const char *s2 ) + + \relates TQCString + + Returns TRUE if \a s1 is less than \a s2; otherwise returns FALSE. + + Equivalent to qstrcmp(\a s1, \a s2) \< 0. + + \sa \link #asciinotion Note on character comparisons \endlink +*/ + +/*! + \overload bool operator<( const char *s1, const TQCString &s2 ) + + \relates TQCString + + Returns TRUE if \a s1 is less than \a s2; otherwise returns FALSE. + + Equivalent to qstrcmp(\a s1, \a s2) \< 0. + + \sa \link #asciinotion Note on character comparisons \endlink +*/ + +/*! + \fn bool operator<=( const TQCString &s1, const char *s2 ) + + \relates TQCString + + Returns TRUE if \a s1 is less than or equal to \a s2; otherwise + returns FALSE. + + Equivalent to qstrcmp(\a s1, \a s2) \<= 0. + + \sa \link #asciinotion Note on character comparisons \endlink +*/ + +/*! + \overload bool operator<=( const char *s1, const TQCString &s2 ) + + \relates TQCString + + Returns TRUE if \a s1 is less than or equal to \a s2; otherwise + returns FALSE. + + Equivalent to qstrcmp(\a s1, \a s2) \<= 0. + + \sa \link #asciinotion Note on character comparisons \endlink +*/ + +/*! + \fn bool operator>( const TQCString &s1, const char *s2 ) + + \relates TQCString + + Returns TRUE if \a s1 is greater than \a s2; otherwise returns FALSE. + + Equivalent to qstrcmp(\a s1, \a s2) \> 0. + + \sa \link #asciinotion Note on character comparisons \endlink +*/ + +/*! + \overload bool operator>( const char *s1, const TQCString &s2 ) + + \relates TQCString + + Returns TRUE if \a s1 is greater than \a s2; otherwise returns FALSE. + + Equivalent to qstrcmp(\a s1, \a s2) \> 0. + + \sa \link #asciinotion Note on character comparisons \endlink +*/ + +/*! + \fn bool operator>=( const TQCString &s1, const char *s2 ) + + \relates TQCString + + Returns TRUE if \a s1 is greater than or equal to \a s2; otherwise + returns FALSE. + + Equivalent to qstrcmp(\a s1, \a s2) \>= 0. + + \sa \link #asciinotion Note on character comparisons \endlink +*/ + +/*! + \overload bool operator>=( const char *s1, const TQCString &s2 ) + + \relates TQCString + + Returns TRUE if \a s1 is greater than or equal to \a s2; otherwise + returns FALSE. + + Equivalent to qstrcmp(\a s1, \a s2) \>= 0. + + \sa \link #asciinotion Note on character comparisons \endlink +*/ + +/*! + \fn const TQCString operator+( const TQCString &s1, const TQCString &s2 ) + + \relates TQCString + + Returns a string which consists of the concatenation of \a s1 and + \a s2. +*/ + +/*! + \overload const TQCString operator+( const TQCString &s1, const char *s2 ) + + \relates TQCString + + Returns a string which consists of the concatenation of \a s1 and \a s2. +*/ + +/*! + \overload const TQCString operator+( const char *s1, const TQCString &s2 ) + + \relates TQCString + + Returns a string which consists of the concatenation of \a s1 and \a s2. +*/ + +/*! + \overload const TQCString operator+( const TQCString &s, char c ) + + \relates TQCString + + Returns a string which consists of the concatenation of \a s and \a c. +*/ + +/*! + \overload const TQCString operator+( char c, const TQCString &s ) + + \relates TQCString + + Returns a string which consists of the concatenation of \a c and \a s. +*/ diff --git a/src/tools/qcstring.h b/src/tools/qcstring.h new file mode 100644 index 000000000..534e55eb3 --- /dev/null +++ b/src/tools/qcstring.h @@ -0,0 +1,392 @@ +/**************************************************************************** +** +** Definition of the extended char array operations, +** and TQByteArray and TQCString classes +** +** Created : 920609 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQCSTRING_H +#define TQCSTRING_H + +#ifndef QT_H +#include "qmemarray.h" +#endif // QT_H + +#include + + +/***************************************************************************** + Safe and portable C string functions; extensions to standard string.h + *****************************************************************************/ + +Q_EXPORT void *qmemmove( void *dst, const void *src, uint len ); + +Q_EXPORT char *qstrdup( const char * ); + +Q_EXPORT inline uint qstrlen( const char *str ) +{ return str ? (uint)strlen(str) : 0u; } + +Q_EXPORT inline char *qstrcpy( char *dst, const char *src ) +{ return src ? strcpy(dst, src) : 0; } + +Q_EXPORT char *qstrncpy( char *dst, const char *src, uint len ); + +Q_EXPORT inline int qstrcmp( const char *str1, const char *str2 ) +{ + return ( str1 && str2 ) ? strcmp( str1, str2 ) + : ( str1 ? 1 : ( str2 ? -1 : 0 ) ); +} + +Q_EXPORT inline int qstrncmp( const char *str1, const char *str2, uint len ) +{ + return ( str1 && str2 ) ? strncmp( str1, str2, len ) + : ( str1 ? 1 : ( str2 ? -1 : 0 ) ); +} + +Q_EXPORT int qstricmp( const char *, const char * ); + +Q_EXPORT int qstrnicmp( const char *, const char *, uint len ); + +#ifndef QT_CLEAN_NAMESPACE +Q_EXPORT inline uint cstrlen( const char *str ) +{ return (uint)strlen(str); } + +Q_EXPORT inline char *cstrcpy( char *dst, const char *src ) +{ return strcpy(dst,src); } + +Q_EXPORT inline int cstrcmp( const char *str1, const char *str2 ) +{ return strcmp(str1,str2); } + +Q_EXPORT inline int cstrncmp( const char *str1, const char *str2, uint len ) +{ return strncmp(str1,str2,len); } +#endif + + +// qChecksum: Internet checksum + +Q_EXPORT Q_UINT16 qChecksum( const char *s, uint len ); + +/***************************************************************************** + TQByteArray class + *****************************************************************************/ + +#if defined(Q_QDOC) +/* + We want qdoc to document TQByteArray as a real class that inherits + TQMemArray and that is inherited by TQBitArray. +*/ +class TQByteArray : public TQMemArray +{ +public: + TQByteArray(); + TQByteArray( int size ); +}; +#else +typedef TQMemArray TQByteArray; +#endif + +#ifndef QT_NO_COMPRESS +Q_EXPORT TQByteArray qCompress( const uchar* data, int nbytes ); +Q_EXPORT TQByteArray qUncompress( const uchar* data, int nbytes ); +Q_EXPORT inline TQByteArray qCompress( const TQByteArray& data) +{ return qCompress( (const uchar*)data.data(), data.size() ); } +Q_EXPORT inline TQByteArray qUncompress( const TQByteArray& data ) +{ return qUncompress( (const uchar*)data.data(), data.size() ); } +#endif + +/***************************************************************************** + TQByteArray stream functions + *****************************************************************************/ +#ifndef QT_NO_DATASTREAM +Q_EXPORT TQDataStream &operator<<( TQDataStream &, const TQByteArray & ); +Q_EXPORT TQDataStream &operator>>( TQDataStream &, TQByteArray & ); +#endif + +/***************************************************************************** + TQCString class + *****************************************************************************/ + +class TQRegExp; + +class Q_EXPORT TQCString : public TQByteArray // C string class +{ +public: + TQCString() {} // make null string + TQCString( int size ); // allocate size incl. \0 + TQCString( const TQCString &s ) : TQByteArray( s ) {} + TQCString( const char *str ); // deep copy + TQCString( const char *str, uint maxlen ); // deep copy, max length + ~TQCString(); + + TQCString &operator=( const TQCString &s );// shallow copy + TQCString &operator=( const char *str ); // deep copy + + bool isNull() const; + bool isEmpty() const; + uint length() const; + bool resize( uint newlen ); + bool truncate( uint pos ); + bool fill( char c, int len = -1 ); + + TQCString copy() const; + + TQCString &sprintf( const char *format, ... ); + + int find( char c, int index=0, bool cs=TRUE ) const; + int find( const char *str, int index=0, bool cs=TRUE ) const; +#ifndef QT_NO_REGEXP + int find( const TQRegExp &, int index=0 ) const; +#endif + int findRev( char c, int index=-1, bool cs=TRUE) const; + int findRev( const char *str, int index=-1, bool cs=TRUE) const; +#ifndef QT_NO_REGEXP_CAPTURE + int findRev( const TQRegExp &, int index=-1 ) const; +#endif + int contains( char c, bool cs=TRUE ) const; + int contains( const char *str, bool cs=TRUE ) const; +#ifndef QT_NO_REGEXP + int contains( const TQRegExp & ) const; +#endif + TQCString left( uint len ) const; + TQCString right( uint len ) const; + TQCString mid( uint index, uint len=0xffffffff) const; + + TQCString leftJustify( uint width, char fill=' ', bool trunc=FALSE)const; + TQCString rightJustify( uint width, char fill=' ',bool trunc=FALSE)const; + + TQCString lower() const; + TQCString upper() const; + + TQCString stripWhiteSpace() const; + TQCString simplifyWhiteSpace() const; + + TQCString &insert( uint index, const char * ); + TQCString &insert( uint index, char ); + TQCString &append( const char * ); + TQCString &prepend( const char * ); + TQCString &remove( uint index, uint len ); + TQCString &replace( uint index, uint len, const char * ); +#ifndef QT_NO_REGEXP + TQCString &replace( const TQRegExp &, const char * ); +#endif + TQCString &replace( char c, const char *after ); + TQCString &replace( const char *, const char * ); + TQCString &replace( char, char ); + + 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; + float toFloat( bool *ok=0 ) const; + double toDouble( bool *ok=0 ) const; + + TQCString &setStr( const char *s ); + TQCString &setNum( short ); + TQCString &setNum( ushort ); + TQCString &setNum( int ); + TQCString &setNum( uint ); + TQCString &setNum( long ); + TQCString &setNum( ulong ); + TQCString &setNum( float, char f='g', int prec=6 ); + TQCString &setNum( double, char f='g', int prec=6 ); + + bool setExpand( uint index, char c ); + + operator const char *() const; + TQCString &operator+=( const char *str ); + TQCString &operator+=( char c ); +private: + int find( const char *str, int index, bool cs, uint l ) const; +}; + + +/***************************************************************************** + TQCString stream functions + *****************************************************************************/ +#ifndef QT_NO_DATASTREAM +Q_EXPORT TQDataStream &operator<<( TQDataStream &, const TQCString & ); +Q_EXPORT TQDataStream &operator>>( TQDataStream &, TQCString & ); +#endif + +/***************************************************************************** + TQCString inline functions + *****************************************************************************/ + +inline TQCString &TQCString::operator=( const TQCString &s ) +{ return (TQCString&)assign( s ); } + +inline TQCString &TQCString::operator=( const char *str ) +{ return (TQCString&)duplicate( str, qstrlen(str)+1 ); } + +inline bool TQCString::isNull() const +{ return data() == 0; } + +inline bool TQCString::isEmpty() const +{ return data() == 0 || *data() == '\0'; } + +inline uint TQCString::length() const +{ return qstrlen( data() ); } + +inline bool TQCString::truncate( uint pos ) +{ return resize(pos+1); } + +inline TQCString TQCString::copy() const +{ return TQCString( data() ); } + +inline TQCString &TQCString::prepend( const char *s ) +{ return insert(0,s); } + +inline TQCString &TQCString::append( const char *s ) +{ return operator+=(s); } + +inline TQCString &TQCString::setNum( short n ) +{ return setNum((long)n); } + +inline TQCString &TQCString::setNum( ushort n ) +{ return setNum((ulong)n); } + +inline TQCString &TQCString::setNum( int n ) +{ return setNum((long)n); } + +inline TQCString &TQCString::setNum( uint n ) +{ return setNum((ulong)n); } + +inline TQCString &TQCString::setNum( float n, char f, int prec ) +{ return setNum((double)n,f,prec); } + +inline TQCString::operator const char *() const +{ return (const char *)data(); } + + +/***************************************************************************** + TQCString non-member operators + *****************************************************************************/ + +Q_EXPORT inline bool operator==( const TQCString &s1, const TQCString &s2 ) +{ return qstrcmp( s1.data(), s2.data() ) == 0; } + +Q_EXPORT inline bool operator==( const TQCString &s1, const char *s2 ) +{ return qstrcmp( s1.data(), s2 ) == 0; } + +Q_EXPORT inline bool operator==( const char *s1, const TQCString &s2 ) +{ return qstrcmp( s1, s2.data() ) == 0; } + +Q_EXPORT inline bool operator!=( const TQCString &s1, const TQCString &s2 ) +{ return qstrcmp( s1.data(), s2.data() ) != 0; } + +Q_EXPORT inline bool operator!=( const TQCString &s1, const char *s2 ) +{ return qstrcmp( s1.data(), s2 ) != 0; } + +Q_EXPORT inline bool operator!=( const char *s1, const TQCString &s2 ) +{ return qstrcmp( s1, s2.data() ) != 0; } + +Q_EXPORT inline bool operator<( const TQCString &s1, const TQCString& s2 ) +{ return qstrcmp( s1.data(), s2.data() ) < 0; } + +Q_EXPORT inline bool operator<( const TQCString &s1, const char *s2 ) +{ return qstrcmp( s1.data(), s2 ) < 0; } + +Q_EXPORT inline bool operator<( const char *s1, const TQCString &s2 ) +{ return qstrcmp( s1, s2.data() ) < 0; } + +Q_EXPORT inline bool operator<=( const TQCString &s1, const TQCString &s2 ) +{ return qstrcmp( s1.data(), s2.data() ) <= 0; } + +Q_EXPORT inline bool operator<=( const TQCString &s1, const char *s2 ) +{ return qstrcmp( s1.data(), s2 ) <= 0; } + +Q_EXPORT inline bool operator<=( const char *s1, const TQCString &s2 ) +{ return qstrcmp( s1, s2.data() ) <= 0; } + +Q_EXPORT inline bool operator>( const TQCString &s1, const TQCString &s2 ) +{ return qstrcmp( s1.data(), s2.data() ) > 0; } + +Q_EXPORT inline bool operator>( const TQCString &s1, const char *s2 ) +{ return qstrcmp( s1.data(), s2 ) > 0; } + +Q_EXPORT inline bool operator>( const char *s1, const TQCString &s2 ) +{ return qstrcmp( s1, s2.data() ) > 0; } + +Q_EXPORT inline bool operator>=( const TQCString &s1, const TQCString& s2 ) +{ return qstrcmp( s1.data(), s2.data() ) >= 0; } + +Q_EXPORT inline bool operator>=( const TQCString &s1, const char *s2 ) +{ return qstrcmp( s1.data(), s2 ) >= 0; } + +Q_EXPORT inline bool operator>=( const char *s1, const TQCString &s2 ) +{ return qstrcmp( s1, s2.data() ) >= 0; } + +Q_EXPORT inline const TQCString operator+( const TQCString &s1, + const TQCString &s2 ) +{ + TQCString tmp( s1.data() ); + tmp += s2; + return tmp; +} + +Q_EXPORT inline const TQCString operator+( const TQCString &s1, const char *s2 ) +{ + TQCString tmp( s1.data() ); + tmp += s2; + return tmp; +} + +Q_EXPORT inline const TQCString operator+( const char *s1, const TQCString &s2 ) +{ + TQCString tmp( s1 ); + tmp += s2; + return tmp; +} + +Q_EXPORT inline const TQCString operator+( const TQCString &s1, char c2 ) +{ + TQCString tmp( s1.data() ); + tmp += c2; + return tmp; +} + +Q_EXPORT inline const TQCString operator+( char c1, const TQCString &s2 ) +{ + TQCString tmp; + tmp += c1; + tmp += s2; + return tmp; +} +#include "qwinexport.h" +#endif // TQCSTRING_H diff --git a/src/tools/qdatastream.cpp b/src/tools/qdatastream.cpp new file mode 100644 index 000000000..0c59fdaf8 --- /dev/null +++ b/src/tools/qdatastream.cpp @@ -0,0 +1,1170 @@ +/**************************************************************************** +** +** Implementation of TQDataStream class +** +** Created : 930831 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "qdatastream.h" + +#ifndef QT_NO_DATASTREAM +#include "qbuffer.h" +#include +#include +#include +#ifndef Q_OS_TEMP +#include +#else +#include "qt_windows.h" +#endif + +/*! + \class TQDataStream qdatastream.h + \reentrant + \brief The TQDataStream class provides serialization of binary data + to a TQIODevice. + + \ingroup io + + A data stream is a binary stream of encoded information which is + 100% independent of the host computer's operating system, CPU or + byte order. For example, a data stream that is written by a PC + under Windows can be read by a Sun SPARC running Solaris. + + You can also use a data stream to read/write \link #raw raw + unencoded binary data\endlink. If you want a "parsing" input + stream, see TQTextStream. + + The TQDataStream class implements the serialization of C++'s basic + data types, like \c char, \c short, \c int, \c char*, etc. + Serialization of more complex data is accomplished by breaking up + the data into primitive units. + + A data stream cooperates closely with a TQIODevice. A TQIODevice + represents an input/output medium one can read data from and write + data to. The TQFile class is an example of an IO device. + + Example (write binary data to a stream): + \code + TQFile file( "file.dat" ); + file.open( IO_WriteOnly ); + TQDataStream stream( &file ); // we will serialize the data into the file + stream << "the answer is"; // serialize a string + stream << (Q_INT32)42; // serialize an integer + \endcode + + Example (read binary data from a stream): + \code + TQFile file( "file.dat" ); + file.open( IO_ReadOnly ); + TQDataStream stream( &file ); // read the data serialized from the file + TQString str; + Q_INT32 a; + stream >> str >> a; // extract "the answer is" and 42 + \endcode + + Each item written to the stream is written in a predefined binary + format that varies depending on the item's type. Supported TQt + types include TQBrush, TQColor, TQDateTime, TQFont, TQPixmap, TQString, + TQVariant and many others. For the complete list of all TQt types + supporting data streaming see the \link datastreamformat.html + Format of the TQDataStream operators \endlink. + + For integers it is best to always cast to a TQt integer type for + writing, and to read back into the same TQt integer type. This + ensures that you get integers of the size you want and insulates + you from compiler and platform differences. + + To take one example, a \c char* string is written as a 32-bit + integer equal to the length of the string including the NUL byte + ('\0'), followed by all the characters of the string including the + NUL byte. When reading a \c char* string, 4 bytes are read to + create the 32-bit length value, then that many characters for the + \c char* string including the NUL are read. + + The initial IODevice is usually set in the constructor, but can be + changed with setDevice(). If you've reached the end of the data + (or if there is no IODevice set) atEnd() will return TRUE. + + If you want the data to be compatible with an earlier version of + TQt use setVersion(). + + If you want the data to be human-readable, e.g. for debugging, you + can set the data stream into printable data mode with + setPrintableData(). The data is then written slower, in a bloated + but human readable format. + + If you are producing a new binary data format, such as a file + format for documents created by your application, you could use a + TQDataStream to write the data in a portable format. Typically, you + would write a brief header containing a magic string and a version + number to give yourself room for future expansion. For example: + + \code + TQFile file( "file.xxx" ); + file.open( IO_WriteOnly ); + TQDataStream stream( &file ); + + // Write a header with a "magic number" and a version + stream << (Q_UINT32)0xA0B0C0D0; + stream << (Q_INT32)123; + + // Write the data + stream << [lots of interesting data] + \endcode + + Then read it in with: + + \code + TQFile file( "file.xxx" ); + file.open( IO_ReadOnly ); + TQDataStream stream( &file ); + + // Read and check the header + Q_UINT32 magic; + stream >> magic; + if ( magic != 0xA0B0C0D0 ) + return XXX_BAD_FILE_FORMAT; + + // Read the version + Q_INT32 version; + stream >> version; + if ( version < 100 ) + return XXX_BAD_FILE_TOO_OLD; + if ( version > 123 ) + return XXX_BAD_FILE_TOO_NEW; + if ( version <= 110 ) + stream.setVersion(1); + + // Read the data + stream >> [lots of interesting data]; + if ( version > 120 ) + stream >> [data new in XXX version 1.2]; + stream >> [other interesting data]; + \endcode + + You can select which byte order to use when serializing data. The + default setting is big endian (MSB first). Changing it to little + endian breaks the portability (unless the reader also changes to + little endian). We recommend keeping this setting unless you have + special retquirements. + + \target raw + \section1 Reading and writing raw binary data + + You may wish to read/write your own raw binary data to/from the + data stream directly. Data may be read from the stream into a + preallocated char* using readRawBytes(). Similarly data can be + written to the stream using writeRawBytes(). Notice that any + encoding/decoding of the data must be done by you. + + A similar pair of functions is readBytes() and writeBytes(). These + differ from their \e raw counterparts as follows: readBytes() + reads a Q_UINT32 which is taken to be the length of the data to be + read, then that number of bytes is read into the preallocated + char*; writeBytes() writes a Q_UINT32 containing the length of the + data, followed by the data. Notice that any encoding/decoding of + the data (apart from the length Q_UINT32) must be done by you. + + \sa TQTextStream TQVariant +*/ + +/*! + \enum TQDataStream::ByteOrder + + The byte order used for reading/writing the data. + + \value BigEndian the default + \value LittleEndian +*/ + + +/***************************************************************************** + TQDataStream member functions + *****************************************************************************/ + +#if defined(QT_CHECK_STATE) +#undef CHECK_STREAM_PRECOND +#define CHECK_STREAM_PRECOND if ( !dev ) { \ + qWarning( "TQDataStream: No device" ); \ + return *this; } +#else +#define CHECK_STREAM_PRECOND +#endif + +static int systemWordSize = 0; +static bool systemBigEndian; + +static const int DefaultStreamVersion = 6; +// ### On next version bump, TQPen::width() should not be restricted to 8-bit values. +// ### On next version bump, when streaming invalid TQVariants, just the type should +// be written, no "data" after it +// 6 is default in TQt 3.3 +// 5 is default in TQt 3.1 +// 4 is default in TQt 3.0 +// 3 is default in TQt 2.1 +// 2 is the TQt 2.0.x format +// 1 is the TQt 1.x format + +/*! + Constructs a data stream that has no IO device. + + \sa setDevice() +*/ + +TQDataStream::TQDataStream() +{ + if ( systemWordSize == 0 ) // get system features + qSysInfo( &systemWordSize, &systemBigEndian ); + dev = 0; // no device set + owndev = FALSE; + byteorder = BigEndian; // default byte order + printable = FALSE; + ver = DefaultStreamVersion; + noswap = systemBigEndian; +} + +/*! + Constructs a data stream that uses the IO device \a d. + + \warning If you use TQSocket or TQSocketDevice as the IO device \a d + for reading data, you must make sure that enough data is available + on the socket for the operation to successfully proceed; + TQDataStream does not have any means to handle or recover from + short-reads. + + \sa setDevice(), device() +*/ + +TQDataStream::TQDataStream( TQIODevice *d ) +{ + if ( systemWordSize == 0 ) // get system features + qSysInfo( &systemWordSize, &systemBigEndian ); + dev = d; // set device + owndev = FALSE; + byteorder = BigEndian; // default byte order + printable = FALSE; + ver = DefaultStreamVersion; + noswap = systemBigEndian; +} + +/*! + Constructs a data stream that operates on a byte array, \a a, + through an internal TQBuffer device. The \a mode is a + TQIODevice::mode(), usually either \c IO_ReadOnly or \c + IO_WriteOnly. + + Example: + \code + static char bindata[] = { 231, 1, 44, ... }; + TQByteArray a; + a.setRawData( bindata, sizeof(bindata) ); // a points to bindata + TQDataStream stream( a, IO_ReadOnly ); // open on a's data + stream >> [something]; // read raw bindata + a.resetRawData( bindata, sizeof(bindata) ); // finished + \endcode + + The TQByteArray::setRawData() function is not for the inexperienced. +*/ + +TQDataStream::TQDataStream( TQByteArray a, int mode ) +{ + if ( systemWordSize == 0 ) // get system features + qSysInfo( &systemWordSize, &systemBigEndian ); + dev = new TQBuffer( a ); // create device + ((TQBuffer *)dev)->open( mode ); // open device + owndev = TRUE; + byteorder = BigEndian; // default byte order + printable = FALSE; + ver = DefaultStreamVersion; + noswap = systemBigEndian; +} + +/*! + Destroys the data stream. + + The destructor will not affect the current IO device, unless it is + an internal IO device processing a TQByteArray passed in the \e + constructor, in which case the internal IO device is destroyed. +*/ + +TQDataStream::~TQDataStream() +{ + if ( owndev ) + delete dev; +} + + +/*! + \fn TQIODevice *TQDataStream::device() const + + Returns the IO device currently set. + + \sa setDevice(), unsetDevice() +*/ + +/*! + void TQDataStream::setDevice(TQIODevice *d ) + + Sets the IO device to \a d. + + \sa device(), unsetDevice() +*/ + +void TQDataStream::setDevice(TQIODevice *d ) +{ + if ( owndev ) { + delete dev; + owndev = FALSE; + } + dev = d; +} + +/*! + Unsets the IO device. This is the same as calling setDevice( 0 ). + + \sa device(), setDevice() +*/ + +void TQDataStream::unsetDevice() +{ + setDevice( 0 ); +} + + +/*! + \fn bool TQDataStream::atEnd() const + + Returns TRUE if the IO device has reached the end position (end of + the stream or file) or if there is no IO device set; otherwise + returns FALSE, i.e. if the current position of the IO device is + before the end position. + + \sa TQIODevice::atEnd() +*/ + +/*!\fn bool TQDataStream::eof() const + + \obsolete + + Returns TRUE if the IO device has reached the end position (end of + stream or file) or if there is no IO device set. + + Returns FALSE if the current position of the read/write head of the IO + device is somewhere before the end position. + + \sa TQIODevice::atEnd() +*/ + +/*! + \fn int TQDataStream::byteOrder() const + + Returns the current byte order setting -- either \c BigEndian or + \c LittleEndian. + + \sa setByteOrder() +*/ + +/*! + Sets the serialization byte order to \a bo. + + The \a bo parameter can be \c TQDataStream::BigEndian or \c + TQDataStream::LittleEndian. + + The default setting is big endian. We recommend leaving this + setting unless you have special retquirements. + + \sa byteOrder() +*/ + +void TQDataStream::setByteOrder( int bo ) +{ + byteorder = bo; + if ( systemBigEndian ) + noswap = byteorder == BigEndian; + else + noswap = byteorder == LittleEndian; +} + + +/*! + \fn bool TQDataStream::isPrintableData() const + + Returns TRUE if the printable data flag has been set; otherwise + returns FALSE. + + \sa setPrintableData() +*/ + +/*! + \fn void TQDataStream::setPrintableData( bool enable ) + + If \a enable is TRUE, data will be output in a human readable + format. If \a enable is FALSE, data will be output in a binary + format. + + If \a enable is TRUE, the write functions will generate output + that consists of printable characters (7 bit ASCII). This output + will typically be a lot larger than the default binary output, and + consequently slower to write. + + We recommend only enabling printable data for debugging purposes. +*/ + + +/*! + \fn int TQDataStream::version() const + + Returns the version number of the data serialization format. In TQt + 3.1, this number is 5. + + \sa setVersion() +*/ + +/*! + \fn void TQDataStream::setVersion( int v ) + + Sets the version number of the data serialization format to \a v. + + You don't need to set a version if you are using the current + version of TQt. + + In order to accommodate new functionality, the datastream + serialization format of some TQt classes has changed in some + versions of TQt. If you want to read data that was created by an + earlier version of TQt, or write data that can be read by a program + that was compiled with an earlier version of TQt, use this function + to modify the serialization format of TQDataStream. + + \table + \header \i TQt Version \i TQDataStream Version + \row \i TQt 3.3 \i11 6 + \row \i TQt 3.2 \i11 5 + \row \i TQt 3.1 \i11 5 + \row \i TQt 3.0 \i11 4 + \row \i TQt 2.1.x and TQt 2.2.x \i11 3 + \row \i TQt 2.0.x \i11 2 + \row \i TQt 1.x \i11 1 + \endtable + + \sa version() +*/ + +/***************************************************************************** + TQDataStream read functions + *****************************************************************************/ + +#if defined(Q_OS_HPUX) && !defined(__LP64__) +extern "C" long long __strtoll( const char *, char**, int ); +#endif + +static Q_INT64 read_int_ascii( TQDataStream *s ) +{ + register int n = 0; + char buf[40]; + for ( ;; ) { + buf[n] = s->device()->getch(); + if ( buf[n] == '\n' || n > 38 ) // $-terminator + break; + n++; + } + buf[n] = '\0'; + +#if defined(__LP64__) || defined(Q_OS_OSF) + // sizeof(long) == 8 + return strtol(buf, (char **)0, 10); +#else +# if defined(Q_OS_TEMP) + return strtol( buf, (char**)0, 10 ); +# elif defined(Q_OS_WIN) + return _atoi64( buf ); +# elif defined(Q_OS_HPUX) + return __strtoll( buf, (char**)0, 10 ); +# elif defined(Q_OS_MACX) && defined(QT_MACOSX_VERSION) && QT_MACOSX_VERSION < 0x1020 + return strtoq( buf, (char**)0, 10 ); +# else + return strtoll( buf, (char**)0, 10 ); // C99 function +# endif +#endif +} + +/*! + \overload TQDataStream &TQDataStream::operator>>( Q_UINT8 &i ) + + Reads an unsigned byte from the stream into \a i, and returns a + reference to the stream. +*/ + +/*! + Reads a signed byte from the stream into \a i, and returns a + reference to the stream. +*/ + +TQDataStream &TQDataStream::operator>>( Q_INT8 &i ) +{ + CHECK_STREAM_PRECOND + if ( printable ) { // printable data + i = (Q_INT8)dev->getch(); + if ( i == '\\' ) { // read octal code + char buf[4]; + dev->readBlock( buf, 3 ); + i = (buf[2] & 0x07)+((buf[1] & 0x07) << 3)+((buf[0] & 0x07) << 6); + } + } else { // data or text + i = (Q_INT8)dev->getch(); + } + return *this; +} + + +/*! + \overload TQDataStream &TQDataStream::operator>>( Q_UINT16 &i ) + + Reads an unsigned 16-bit integer from the stream into \a i, and + returns a reference to the stream. +*/ + +/*! + \overload + + Reads a signed 16-bit integer from the stream into \a i, and + returns a reference to the stream. +*/ + +TQDataStream &TQDataStream::operator>>( Q_INT16 &i ) +{ + CHECK_STREAM_PRECOND + if ( printable ) { // printable data + i = (Q_INT16)read_int_ascii( this ); + } else if ( noswap ) { // no conversion needed + dev->readBlock( (char *)&i, sizeof(Q_INT16) ); + } else { // swap bytes + register uchar *p = (uchar *)(&i); + char b[2]; + dev->readBlock( b, 2 ); + *p++ = b[1]; + *p = b[0]; + } + return *this; +} + + +/*! + \overload TQDataStream &TQDataStream::operator>>( Q_UINT32 &i ) + + Reads an unsigned 32-bit integer from the stream into \a i, and + returns a reference to the stream. +*/ + +/*! + \overload + + Reads a signed 32-bit integer from the stream into \a i, and + returns a reference to the stream. +*/ + +TQDataStream &TQDataStream::operator>>( Q_INT32 &i ) +{ + CHECK_STREAM_PRECOND + if ( printable ) { // printable data + i = (Q_INT32)read_int_ascii( this ); + } else if ( noswap ) { // no conversion needed + dev->readBlock( (char *)&i, sizeof(Q_INT32) ); + } else { // swap bytes + uchar *p = (uchar *)(&i); + char b[4]; + dev->readBlock( b, 4 ); + *p++ = b[3]; + *p++ = b[2]; + *p++ = b[1]; + *p = b[0]; + } + return *this; +} + +/*! + \overload TQDataStream &TQDataStream::operator>>( Q_UINT64 &i ) + + Reads an unsigned 64-bit integer from the stream, into \a i, and + returns a reference to the stream. +*/ + +/*! + \overload + + Reads a signed 64-bit integer from the stream into \a i, and + returns a reference to the stream. +*/ + +TQDataStream &TQDataStream::operator>>( Q_INT64 &i ) +{ + CHECK_STREAM_PRECOND + if ( printable ) { // printable data + i = read_int_ascii( this ); + } else if ( version() < 6 ) { + Q_UINT32 i1, i2; + *this >> i2 >> i1; + i = ((Q_UINT64)i1 << 32) + i2; + } else if ( noswap ) { // no conversion needed + dev->readBlock( (char *)&i, sizeof(Q_INT64) ); + } else { // swap bytes + uchar *p = (uchar *)(&i); + char b[8]; + dev->readBlock( b, 8 ); + *p++ = b[7]; + *p++ = b[6]; + *p++ = b[5]; + *p++ = b[4]; + *p++ = b[3]; + *p++ = b[2]; + *p++ = b[1]; + *p = b[0]; + } + return *this; +} + + +/*! + \overload TQDataStream &TQDataStream::operator>>( Q_ULONG &i ) + + Reads an unsigned integer of the system's word length from the + stream, into \a i, and returns a reference to the stream. +*/ + +#if !defined(Q_OS_WIN64) +/*! + \overload + + Reads a signed integer of the system's word length from the stream + into \a i, and returns a reference to the stream. + +*/ + +TQDataStream &TQDataStream::operator>>( Q_LONG &i ) +{ + CHECK_STREAM_PRECOND + if ( printable ) { // printable data + i = (Q_LONG)read_int_ascii( this ); + } else if ( noswap ) { // no conversion needed + dev->readBlock( (char *)&i, sizeof(Q_LONG) ); + } else { // swap bytes + register uchar *p = (uchar *)(&i); + char b[sizeof(Q_LONG)]; + dev->readBlock( b, sizeof(Q_LONG) ); + for ( int j = sizeof(Q_LONG); j; ) + *p++ = b[--j]; + } + return *this; +} +#endif + +static double read_double_ascii( TQDataStream *s ) +{ + register int n = 0; + char buf[80]; + for ( ;; ) { + buf[n] = s->device()->getch(); + if ( buf[n] == '\n' || n > 78 ) // $-terminator + break; + n++; + } + buf[n] = '\0'; + return atof( buf ); +} + + +/*! + \overload + + Reads a 32-bit floating point number from the stream into \a f, + using the standard IEEE754 format. Returns a reference to the + stream. +*/ + +TQDataStream &TQDataStream::operator>>( float &f ) +{ + CHECK_STREAM_PRECOND + if ( printable ) { // printable data + f = (float)read_double_ascii( this ); + } else if ( noswap ) { // no conversion needed + dev->readBlock( (char *)&f, sizeof(float) ); + } else { // swap bytes + uchar *p = (uchar *)(&f); + char b[4]; + dev->readBlock( b, 4 ); + *p++ = b[3]; + *p++ = b[2]; + *p++ = b[1]; + *p = b[0]; + } + return *this; +} + + +/*! + \overload + + Reads a 64-bit floating point number from the stream into \a f, + using the standard IEEE754 format. Returns a reference to the + stream. +*/ + +TQDataStream &TQDataStream::operator>>( double &f ) +{ + CHECK_STREAM_PRECOND + if ( printable ) { // printable data + f = read_double_ascii( this ); + } else if ( noswap ) { // no conversion needed + dev->readBlock( (char *)&f, sizeof(double) ); + } else { // swap bytes + register uchar *p = (uchar *)(&f); + char b[8]; + dev->readBlock( b, 8 ); + *p++ = b[7]; + *p++ = b[6]; + *p++ = b[5]; + *p++ = b[4]; + *p++ = b[3]; + *p++ = b[2]; + *p++ = b[1]; + *p = b[0]; + } + return *this; +} + + +/*! + \overload + + Reads the '\0'-terminated string \a s from the stream and returns + a reference to the stream. + + Space for the string is allocated using \c new -- the caller must + destroy it with delete[]. +*/ + +TQDataStream &TQDataStream::operator>>( char *&s ) +{ + uint len = 0; + return readBytes( s, len ); +} + + +/*! + Reads the buffer \a s from the stream and returns a reference to + the stream. + + The buffer \a s is allocated using \c new. Destroy it with the \c + delete[] operator. If the length is zero or \a s cannot be + allocated, \a s is set to 0. + + The \a l parameter will be set to the length of the buffer. + + The serialization format is a Q_UINT32 length specifier first, + then \a l bytes of data. Note that the data is \e not encoded. + + \sa readRawBytes(), writeBytes() +*/ + +TQDataStream &TQDataStream::readBytes( char *&s, uint &l ) +{ + CHECK_STREAM_PRECOND + Q_UINT32 len; + *this >> len; // first read length spec + l = (uint)len; + if ( len == 0 || eof() ) { + s = 0; + return *this; + } else { + s = new char[len]; // create char array + Q_CHECK_PTR( s ); + if ( !s ) // no memory + return *this; + return readRawBytes( s, (uint)len ); + } +} + + +/*! + Reads \a len bytes from the stream into \a s and returns a + reference to the stream. + + The buffer \a s must be preallocated. The data is \e not encoded. + + \sa readBytes(), TQIODevice::readBlock(), writeRawBytes() +*/ + +TQDataStream &TQDataStream::readRawBytes( char *s, uint len ) +{ + CHECK_STREAM_PRECOND + if ( printable ) { // printable data + register Q_INT8 *p = (Q_INT8*)s; + if ( version() < 4 ) { + while ( len-- ) { + Q_INT32 tmp; + *this >> tmp; + *p++ = tmp; + } + } else { + while ( len-- ) + *this >> *p++; + } + } else { // read data char array + dev->readBlock( s, len ); + } + return *this; +} + + +/***************************************************************************** + TQDataStream write functions + *****************************************************************************/ + + +/*! + \overload TQDataStream &TQDataStream::operator<<( Q_UINT8 i ) + + Writes an unsigned byte, \a i, to the stream and returns a + reference to the stream. +*/ + +/*! + Writes a signed byte, \a i, to the stream and returns a reference + to the stream. +*/ + +TQDataStream &TQDataStream::operator<<( Q_INT8 i ) +{ + CHECK_STREAM_PRECOND + if ( printable && (i == '\\' || !isprint((uchar) i)) ) { + char buf[6]; // write octal code + buf[0] = '\\'; + buf[1] = '0' + ((i >> 6) & 0x07); + buf[2] = '0' + ((i >> 3) & 0x07); + buf[3] = '0' + (i & 0x07); + buf[4] = '\0'; + dev->writeBlock( buf, 4 ); + } else { + dev->putch( i ); + } + return *this; +} + + +/*! + \overload TQDataStream &TQDataStream::operator<<( Q_UINT16 i ) + + Writes an unsigned 16-bit integer, \a i, to the stream and returns + a reference to the stream. +*/ + +/*! + \overload + + Writes a signed 16-bit integer, \a i, to the stream and returns a + reference to the stream. +*/ + +TQDataStream &TQDataStream::operator<<( Q_INT16 i ) +{ + CHECK_STREAM_PRECOND + if ( printable ) { // printable data + char buf[16]; + sprintf( buf, "%d\n", i ); + dev->writeBlock( buf, strlen(buf) ); + } else if ( noswap ) { // no conversion needed + dev->writeBlock( (char *)&i, sizeof(Q_INT16) ); + } else { // swap bytes + register uchar *p = (uchar *)(&i); + char b[2]; + b[1] = *p++; + b[0] = *p; + dev->writeBlock( b, 2 ); + } + return *this; +} + +/*! + \overload + + Writes a signed 32-bit integer, \a i, to the stream and returns a + reference to the stream. +*/ + +TQDataStream &TQDataStream::operator<<( Q_INT32 i ) +{ + CHECK_STREAM_PRECOND + if ( printable ) { // printable data + char buf[16]; + sprintf( buf, "%d\n", i ); + dev->writeBlock( buf, strlen(buf) ); + } else if ( noswap ) { // no conversion needed + dev->writeBlock( (char *)&i, sizeof(Q_INT32) ); + } else { // swap bytes + register uchar *p = (uchar *)(&i); + char b[4]; + b[3] = *p++; + b[2] = *p++; + b[1] = *p++; + b[0] = *p; + dev->writeBlock( b, 4 ); + } + return *this; +} + +/*! + \overload TQDataStream &TQDataStream::operator<<( Q_UINT64 i ) + + Writes an unsigned 64-bit integer, \a i, to the stream and returns a + reference to the stream. +*/ + +/*! + \overload + + Writes a signed 64-bit integer, \a i, to the stream and returns a + reference to the stream. +*/ + +TQDataStream &TQDataStream::operator<<( Q_INT64 i ) +{ + CHECK_STREAM_PRECOND + if ( printable ) { // printable data + char buf[16]; +#ifdef Q_OS_WIN + sprintf( buf, "%I64d\n", i ); +#else + sprintf( buf, "%lld\n", i ); +#endif + dev->writeBlock( buf, strlen(buf) ); + } else if ( version() < 6 ) { + Q_UINT32 i1 = i & 0xffffffff; + Q_UINT32 i2 = i >> 32; + *this << i2 << i1; + } else if ( noswap ) { // no conversion needed + dev->writeBlock( (char *)&i, sizeof(Q_INT64) ); + } else { // swap bytes + register uchar *p = (uchar *)(&i); + char b[8]; + b[7] = *p++; + b[6] = *p++; + b[5] = *p++; + b[4] = *p++; + b[3] = *p++; + b[2] = *p++; + b[1] = *p++; + b[0] = *p; + dev->writeBlock( b, 8 ); + } + return *this; +} + +/*! + \overload TQDataStream &TQDataStream::operator<<( Q_ULONG i ) + + Writes an unsigned integer \a i, of the system's word length, to + the stream and returns a reference to the stream. +*/ + +#if !defined(Q_OS_WIN64) +/*! + \overload + + Writes a signed integer \a i, of the system's word length, to the + stream and returns a reference to the stream. +*/ + +TQDataStream &TQDataStream::operator<<( Q_LONG i ) +{ + CHECK_STREAM_PRECOND + if ( printable ) { // printable data + char buf[20]; + sprintf( buf, "%ld\n", i ); + dev->writeBlock( buf, strlen(buf) ); + } else if ( noswap ) { // no conversion needed + dev->writeBlock( (char *)&i, sizeof(Q_LONG) ); + } else { // swap bytes + register uchar *p = (uchar *)(&i); + char b[sizeof(Q_LONG)]; + for ( int j = sizeof(Q_LONG); j; ) + b[--j] = *p++; + dev->writeBlock( b, sizeof(Q_LONG) ); + } + return *this; +} +#endif + + +/*! + \overload TQDataStream &TQDataStream::operator<<( Q_UINT32 i ) + + Writes an unsigned integer, \a i, to the stream as a 32-bit + unsigned integer (Q_UINT32). Returns a reference to the stream. +*/ + +/*! + \overload + + Writes a 32-bit floating point number, \a f, to the stream using + the standard IEEE754 format. Returns a reference to the stream. +*/ + +TQDataStream &TQDataStream::operator<<( float f ) +{ + CHECK_STREAM_PRECOND + if ( printable ) { // printable data + TQString num = TQString::number((double)f); + dev->writeBlock(num.latin1(), num.length()); + dev->putch('\n'); + } else { + float g = f; // fixes float-on-stack problem + if ( noswap ) { // no conversion needed + dev->writeBlock( (char *)&g, sizeof(float) ); + } else { // swap bytes + register uchar *p = (uchar *)(&g); + char b[4]; + b[3] = *p++; + b[2] = *p++; + b[1] = *p++; + b[0] = *p; + dev->writeBlock( b, 4 ); + } + } + return *this; +} + + +/*! + \overload + + Writes a 64-bit floating point number, \a f, to the stream using + the standard IEEE754 format. Returns a reference to the stream. +*/ + +TQDataStream &TQDataStream::operator<<( double f ) +{ + CHECK_STREAM_PRECOND + if ( printable ) { // printable data + TQString num = TQString::number((double)f); + dev->writeBlock(num.latin1(), num.length()); + dev->putch('\n'); + } else if ( noswap ) { // no conversion needed + dev->writeBlock( (char *)&f, sizeof(double) ); + } else { // swap bytes + register uchar *p = (uchar *)(&f); + char b[8]; + b[7] = *p++; + b[6] = *p++; + b[5] = *p++; + b[4] = *p++; + b[3] = *p++; + b[2] = *p++; + b[1] = *p++; + b[0] = *p; + dev->writeBlock( b, 8 ); + } + return *this; +} + + +/*! + \overload + + Writes the '\0'-terminated string \a s to the stream and returns a + reference to the stream. + + The string is serialized using writeBytes(). +*/ + +TQDataStream &TQDataStream::operator<<( const char *s ) +{ + if ( !s ) { + *this << (Q_UINT32)0; + return *this; + } + uint len = qstrlen( s ) + 1; // also write null terminator + *this << (Q_UINT32)len; // write length specifier + return writeRawBytes( s, len ); +} + + +/*! + Writes the length specifier \a len and the buffer \a s to the + stream and returns a reference to the stream. + + The \a len is serialized as a Q_UINT32, followed by \a len bytes + from \a s. Note that the data is \e not encoded. + + \sa writeRawBytes(), readBytes() +*/ + +TQDataStream &TQDataStream::writeBytes(const char *s, uint len) +{ + CHECK_STREAM_PRECOND + *this << (Q_UINT32)len; // write length specifier + if ( len ) + writeRawBytes( s, len ); + return *this; +} + + +/*! + Writes \a len bytes from \a s to the stream and returns a + reference to the stream. The data is \e not encoded. + + \sa writeBytes(), TQIODevice::writeBlock(), readRawBytes() +*/ + +TQDataStream &TQDataStream::writeRawBytes( const char *s, uint len ) +{ + CHECK_STREAM_PRECOND + if ( printable ) { // write printable + if ( version() < 4 ) { + register char *p = (char *)s; + while ( len-- ) + *this << *p++; + } else { + register Q_INT8 *p = (Q_INT8*)s; + while ( len-- ) + *this << *p++; + } + } else { // write data char array + dev->writeBlock( s, len ); + } + return *this; +} + +#endif // QT_NO_DATASTREAM diff --git a/src/tools/qdatastream.h b/src/tools/qdatastream.h new file mode 100644 index 000000000..ffc9db34c --- /dev/null +++ b/src/tools/qdatastream.h @@ -0,0 +1,193 @@ +/**************************************************************************** +** +** Definition of TQDataStream class +** +** Created : 930831 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQDATASTREAM_H +#define TQDATASTREAM_H + +#ifndef QT_H +#include "qiodevice.h" +#include "qstring.h" +#endif // QT_H + +#ifndef QT_NO_DATASTREAM +class Q_EXPORT TQDataStream // data stream class +{ +public: + TQDataStream(); + TQDataStream( TQIODevice * ); + TQDataStream( TQByteArray, int mode ); + virtual ~TQDataStream(); + + TQIODevice *device() const; + void setDevice( TQIODevice * ); + void unsetDevice(); + + bool atEnd() const; + bool eof() const; + + enum ByteOrder { BigEndian, LittleEndian }; + int byteOrder() const; + void setByteOrder( int ); + + bool isPrintableData() const; + void setPrintableData( bool ); + + int version() const; + void setVersion( int ); + + TQDataStream &operator>>( Q_INT8 &i ); + TQDataStream &operator>>( Q_UINT8 &i ); + TQDataStream &operator>>( Q_INT16 &i ); + TQDataStream &operator>>( Q_UINT16 &i ); + TQDataStream &operator>>( Q_INT32 &i ); + TQDataStream &operator>>( Q_UINT32 &i ); + TQDataStream &operator>>( Q_INT64 &i ); + TQDataStream &operator>>( Q_UINT64 &i ); +#if !defined(Q_OS_WIN64) + TQDataStream &operator>>( Q_LONG &i ); + TQDataStream &operator>>( Q_ULONG &i ); +#endif + + TQDataStream &operator>>( float &f ); + TQDataStream &operator>>( double &f ); + TQDataStream &operator>>( char *&str ); + + TQDataStream &operator<<( Q_INT8 i ); + TQDataStream &operator<<( Q_UINT8 i ); + TQDataStream &operator<<( Q_INT16 i ); + TQDataStream &operator<<( Q_UINT16 i ); + TQDataStream &operator<<( Q_INT32 i ); + TQDataStream &operator<<( Q_UINT32 i ); + TQDataStream &operator<<( Q_INT64 i ); + TQDataStream &operator<<( Q_UINT64 i ); +#if !defined(Q_OS_WIN64) + TQDataStream &operator<<( Q_LONG i ); + TQDataStream &operator<<( Q_ULONG i ); +#endif + TQDataStream &operator<<( float f ); + TQDataStream &operator<<( double f ); + TQDataStream &operator<<( const char *str ); + + TQDataStream &readBytes( char *&, uint &len ); + TQDataStream &readRawBytes( char *, uint len ); + + TQDataStream &writeBytes( const char *, uint len ); + TQDataStream &writeRawBytes( const char *, uint len ); + +private: + TQIODevice *dev; + bool owndev; + int byteorder; + bool printable; + bool noswap; + int ver; + +private: // Disabled copy constructor and operator= +#if defined(Q_DISABLE_COPY) + TQDataStream( const TQDataStream & ); + TQDataStream &operator=( const TQDataStream & ); +#endif +}; + + +/***************************************************************************** + TQDataStream inline functions + *****************************************************************************/ + +inline TQIODevice *TQDataStream::device() const +{ return dev; } + +inline bool TQDataStream::atEnd() const +{ return dev ? dev->atEnd() : TRUE; } + +inline bool TQDataStream::eof() const +{ return atEnd(); } + +inline int TQDataStream::byteOrder() const +{ return byteorder; } + +inline bool TQDataStream::isPrintableData() const +{ return printable; } + +inline void TQDataStream::setPrintableData( bool p ) +{ printable = p; } + +inline int TQDataStream::version() const +{ return ver; } + +inline void TQDataStream::setVersion( int v ) +{ ver = v; } + +inline TQDataStream &TQDataStream::operator>>( Q_UINT8 &i ) +{ return *this >> (Q_INT8&)i; } + +inline TQDataStream &TQDataStream::operator>>( Q_UINT16 &i ) +{ return *this >> (Q_INT16&)i; } + +inline TQDataStream &TQDataStream::operator>>( Q_UINT32 &i ) +{ return *this >> (Q_INT32&)i; } + +inline TQDataStream &TQDataStream::operator>>( Q_UINT64 &i ) +{ return *this >> (Q_INT64&)i; } + +#if !defined(Q_OS_WIN64) +inline TQDataStream &TQDataStream::operator>>( Q_ULONG &i ) +{ return *this >> (Q_LONG&)i; } +#endif + +inline TQDataStream &TQDataStream::operator<<( Q_UINT8 i ) +{ return *this << (Q_INT8)i; } + +inline TQDataStream &TQDataStream::operator<<( Q_UINT16 i ) +{ return *this << (Q_INT16)i; } + +inline TQDataStream &TQDataStream::operator<<( Q_UINT32 i ) +{ return *this << (Q_INT32)i; } + +inline TQDataStream &TQDataStream::operator<<( Q_UINT64 i ) +{ return *this << (Q_INT64)i; } + +#if !defined(Q_OS_WIN64) +inline TQDataStream &TQDataStream::operator<<( Q_ULONG i ) +{ return *this << (Q_LONG)i; } +#endif + +#endif // QT_NO_DATASTREAM +#endif // TQDATASTREAM_H diff --git a/src/tools/qdatetime.cpp b/src/tools/qdatetime.cpp new file mode 100644 index 000000000..7343a5ad0 --- /dev/null +++ b/src/tools/qdatetime.cpp @@ -0,0 +1,2600 @@ +/**************************************************************************** +** +** Implementation of date and time classes +** +** Created : 940124 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "qplatformdefs.h" + +#include "qdatetime.h" +#include "qdatastream.h" +#include "qregexp.h" + +#include +#ifndef Q_OS_TEMP +#include +#endif + +#if defined(Q_OS_WIN32) +#include +#endif + +static const uint FIRST_DAY = 2361222; // Julian day for 1752-09-14 +static const int FIRST_YEAR = 1752; // ### wrong for many countries +static const uint SECS_PER_DAY = 86400; +static const uint MSECS_PER_DAY = 86400000; +static const uint SECS_PER_HOUR = 3600; +static const uint MSECS_PER_HOUR= 3600000; +static const uint SECS_PER_MIN = 60; +static const uint MSECS_PER_MIN = 60000; + +static const short monthDays[] = { + 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; + +static const char * const qt_shortMonthNames[] = { + "Jan", "Feb", "Mar", "Apr", "May", "Jun", + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; + +#ifndef QT_NO_DATESTRING +/***************************************************************************** + Some static function used by TQDate, TQTime and TQDateTime + *****************************************************************************/ + +// Replaces tokens by their value. See TQDateTime::toString() for a list of valid tokens +static TQString getFmtString( const TQString& f, const TQTime* dt = 0, const TQDate* dd = 0, bool am_pm = FALSE ) +{ + if ( f.isEmpty() ) + return TQString::null; + + TQString buf = f; + + if ( dt ) { + if ( f == "h" ) { + if ( ( am_pm ) && ( dt->hour() > 12 ) ) + buf = TQString::number( dt->hour() - 12 ); + else if ( ( am_pm ) && ( dt->hour() == 0 ) ) + buf = "12"; + else + buf = TQString::number( dt->hour() ); + } else if ( f == "hh" ) { + if ( ( am_pm ) && ( dt->hour() > 12 ) ) + buf = TQString::number( dt->hour() - 12 ).rightJustify( 2, '0', TRUE ); + else if ( ( am_pm ) && ( dt->hour() == 0 ) ) + buf = "12"; + else + buf = TQString::number( dt->hour() ).rightJustify( 2, '0', TRUE ); + } else if ( f == "m" ) { + buf = TQString::number( dt->minute() ); + } else if ( f == "mm" ) { + buf = TQString::number( dt->minute() ).rightJustify( 2, '0', TRUE ); + } else if ( f == "s" ) { + buf = TQString::number( dt->second() ); + } else if ( f == "ss" ) { + buf = TQString::number( dt->second() ).rightJustify( 2, '0', TRUE ); + } else if ( f == "z" ) { + buf = TQString::number( dt->msec() ); + } else if ( f == "zzz" ) { + buf = TQString::number( dt->msec() ).rightJustify( 3, '0', TRUE ); + } else if ( f == "ap" ) { + buf = dt->hour() < 12 ? "am" : "pm"; + } else if ( f == "AP" ) { + buf = dt->hour() < 12 ? "AM" : "PM"; + } + } + + if ( dd ) { + if ( f == "d" ) { + buf = TQString::number( dd->day() ); + } else if ( f == "dd" ) { + buf = TQString::number( dd->day() ).rightJustify( 2, '0', TRUE ); + } else if ( f == "M" ) { + buf = TQString::number( dd->month() ); + } else if ( f == "MM" ) { + buf = TQString::number( dd->month() ).rightJustify( 2, '0', TRUE ); +#ifndef QT_NO_TEXTDATE + } else if ( f == "ddd" ) { + buf = dd->shortDayName( dd->dayOfWeek() ); + } else if ( f == "dddd" ) { + buf = dd->longDayName( dd->dayOfWeek() ); + } else if ( f == "MMM" ) { + buf = dd->shortMonthName( dd->month() ); + } else if ( f == "MMMM" ) { + buf = dd->longMonthName( dd->month() ); +#endif + } else if ( f == "yy" ) { + buf = TQString::number( dd->year() ).right( 2 ); + } else if ( f == "yyyy" ) { + buf = TQString::number( dd->year() ); + } + } + + return buf; +} + +// Parses the format string and uses getFmtString to get the values for the tokens. Ret +static TQString fmtDateTime( const TQString& f, const TQTime* dt = 0, const TQDate* dd = 0 ) +{ + if ( f.isEmpty() ) { + return TQString::null; + } + + if ( dt && !dt->isValid() ) + return TQString::null; + if ( dd && !dd->isValid() ) + return TQString::null; + + bool ap = ( f.contains( "AP" ) || f.contains( "ap" ) ); + + TQString buf; + TQString frm; + TQChar status = '0'; + + for ( int i = 0; i < (int)f.length(); ++i ) { + + if ( f[ i ] == status ) { + if ( ( ap ) && ( ( f[ i ] == 'P' ) || ( f[ i ] == 'p' ) ) ) + status = '0'; + frm += f[ i ]; + } else { + buf += getFmtString( frm, dt, dd, ap ); + frm = TQString::null; + if ( ( f[ i ] == 'h' ) || ( f[ i ] == 'm' ) || ( f[ i ] == 's' ) || ( f[ i ] == 'z' ) ) { + status = f[ i ]; + frm += f[ i ]; + } else if ( ( f[ i ] == 'd' ) || ( f[ i ] == 'M' ) || ( f[ i ] == 'y' ) ) { + status = f[ i ]; + frm += f[ i ]; + } else if ( ( ap ) && ( f[ i ] == 'A' ) ) { + status = 'P'; + frm += f[ i ]; + } else if( ( ap ) && ( f[ i ] == 'a' ) ) { + status = 'p'; + frm += f[ i ]; + } else { + buf += f[ i ]; + status = '0'; + } + } + } + + buf += getFmtString( frm, dt, dd, ap ); + + return buf; +} +#endif // QT_NO_DATESTRING + +/***************************************************************************** + TQDate member functions + *****************************************************************************/ + +/*! + \class TQDate qdatetime.h + \reentrant + \brief The TQDate class provides date functions. + + \ingroup time + \mainclass + + A TQDate object contains a calendar date, i.e. year, month, and day + numbers, in the modern Western (Gregorian) calendar. It can read + the current date from the system clock. It provides functions for + comparing dates and for manipulating dates, e.g. by adding a + number of days or months or years. + + A TQDate object is typically created either by giving the year, + month and day numbers explicitly, or by using the static function + currentDate(), which creates a TQDate object containing the system + clock's date. An explicit date can also be set using setYMD(). The + fromString() function returns a TQDate given a string and a date + format which is used to interpret the date within the string. + + The year(), month(), and day() functions provide access to the + year, month, and day numbers. Also, dayOfWeek() and dayOfYear() + functions are provided. The same information is provided in + textual format by the toString(), shortDayName(), longDayName(), + shortMonthName() and longMonthName() functions. + + TQDate provides a full set of operators to compare two TQDate + objects where smaller means earlier and larger means later. + + You can increment (or decrement) a date by a given number of days + using addDays(). Similarly you can use addMonths() and addYears(). + The daysTo() function returns the number of days between two + dates. + + The daysInMonth() and daysInYear() functions return how many days + there are in this date's month and year, respectively. The + leapYear() function indicates whether this date is in a leap year. + + Note that TQDate should not be used for date calculations for dates + prior to the introduction of the Gregorian calendar. This calendar + was adopted by England from the 14th + September 1752 (hence this is the earliest valid TQDate), and + subsequently by most other Western countries, until 1923. + + The end of time is reached around the year 8000, by which time we + expect TQt to be obsolete. + + \sa TQTime TQDateTime TQDateEdit TQDateTimeEdit +*/ + +/*! + \enum TQt::DateFormat + + \value TextDate (default) TQt format + \value ISODate ISO 8601 extended format (YYYY-MM-DD, or with time, + YYYY-MM-DDTHH:MM:SS) + \value LocalDate locale dependent format +*/ + + +/*! + \enum TQt::TimeSpec + + \value LocalTime Locale dependent time (Timezones and Daylight Savings Time) + \value UTC Coordinated Universal Time, replaces Greenwich Time +*/ + +/*! + \fn TQDate::TQDate() + + Constructs a null date. Null dates are invalid. + + \sa isNull(), isValid() +*/ + + +/*! + Constructs a date with year \a y, month \a m and day \a d. + + \a y must be in the range 1752..8000, \a m must be in the range + 1..12, and \a d must be in the range 1..31. + + \warning If \a y is in the range 0..99, it is interpreted as + 1900..1999. + + \sa isValid() +*/ + +TQDate::TQDate( int y, int m, int d ) +{ + jd = 0; + setYMD( y, m, d ); +} + + +/*! + \fn bool TQDate::isNull() const + + Returns TRUE if the date is null; otherwise returns FALSE. A null + date is invalid. + + \sa isValid() +*/ + + +/*! + Returns TRUE if this date is valid; otherwise returns FALSE. + + \sa isNull() +*/ + +bool TQDate::isValid() const +{ + return jd >= FIRST_DAY; +} + + +/*! + Returns the year (1752..8000) of this date. + + \sa month(), day() +*/ + +int TQDate::year() const +{ + int y, m, d; + julianToGregorian( jd, y, m, d ); + return y; +} + +/*! + Returns the month (January=1..December=12) of this date. + + \sa year(), day() +*/ + +int TQDate::month() const +{ + int y, m, d; + julianToGregorian( jd, y, m, d ); + return m; +} + +/*! + Returns the day of the month (1..31) of this date. + + \sa year(), month(), dayOfWeek() +*/ + +int TQDate::day() const +{ + int y, m, d; + julianToGregorian( jd, y, m, d ); + return d; +} + +/*! + Returns the weekday (Monday=1..Sunday=7) for this date. + + \sa day(), dayOfYear() +*/ + +int TQDate::dayOfWeek() const +{ + return ( jd % 7 ) + 1; +} + +/*! + Returns the day of the year (1..365) for this date. + + \sa day(), dayOfWeek() +*/ + +int TQDate::dayOfYear() const +{ + return jd - gregorianToJulian(year(), 1, 1) + 1; +} + +/*! + Returns the number of days in the month (28..31) for this date. + + \sa day(), daysInYear() +*/ + +int TQDate::daysInMonth() const +{ + int y, m, d; + julianToGregorian( jd, y, m, d ); + if ( m == 2 && leapYear(y) ) + return 29; + else + return monthDays[m]; +} + +/*! + Returns the number of days in the year (365 or 366) for this date. + + \sa day(), daysInMonth() +*/ + +int TQDate::daysInYear() const +{ + int y, m, d; + julianToGregorian( jd, y, m, d ); + return leapYear( y ) ? 366 : 365; +} + +/*! + Returns the week number (1 to 53), and stores the year in \a + *yearNumber unless \a yearNumber is null (the default). + + Returns 0 if the date is invalid. + + In accordance with ISO 8601, weeks start on Monday and the first + Thursday of a year is always in week 1 of that year. Most years + have 52 weeks, but some have 53. + + \a *yearNumber is not always the same as year(). For example, 1 + January 2000 has week number 52 in the year 1999, and 31 December + 2002 has week number 1 in the year 2003. + + \legalese + + Copyright (c) 1989 The Regents of the University of California. + All rights reserved. + + Redistribution and use in source and binary forms are permitted + provided that the above copyright notice and this paragraph are + duplicated in all such forms and that any documentation, + advertising materials, and other materials related to such + distribution and use acknowledge that the software was developed + by the University of California, Berkeley. The name of the + University may not be used to endorse or promote products derived + from this software without specific prior written permission. + THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + + \sa isValid() +*/ + +int TQDate::weekNumber( int *yearNumber ) const +{ + if ( !isValid() ) + return 0; + + int year = TQDate::year(); + int yday = dayOfYear() - 1; + int wday = dayOfWeek(); + if (wday == 7) + wday = 0; + int w; + + for (;;) { + int len; + int bot; + int top; + + len = leapYear(year) ? 366 : 365; + /* + ** What yday (-3 ... 3) does + ** the ISO year begin on? + */ + bot = ((yday + 11 - wday) % 7) - 3; + /* + ** What yday does the NEXT + ** ISO year begin on? + */ + top = bot - (len % 7); + if (top < -3) + top += 7; + top += len; + if (yday >= top) { + ++year; + w = 1; + break; + } + if (yday >= bot) { + w = 1 + ((yday - bot) / 7); + break; + } + --year; + yday += leapYear(year) ? 366 : 365; + } + if (yearNumber != 0) + *yearNumber = year; + return w; +} + +/*! + \fn TQString TQDate::monthName( int month ) + \obsolete + + Use shortMonthName() instead. +*/ +#ifndef QT_NO_TEXTDATE +/*! + Returns the name of the \a month. + + 1 = "Jan", 2 = "Feb", ... 12 = "Dec" + + The month names will be localized according to the system's locale + settings. + + \sa toString(), longMonthName(), shortDayName(), longDayName() +*/ + +TQString TQDate::shortMonthName( int month ) +{ +#if defined(QT_CHECK_RANGE) + if ( month < 1 || month > 12 ) { + qWarning( "TQDate::shortMonthName: Parameter out ouf range" ); + month = 1; + } +#endif +#ifndef Q_WS_WIN + char buffer[255]; + tm tt; + memset( &tt, 0, sizeof( tm ) ); + tt.tm_mon = month - 1; + if ( strftime( buffer, sizeof( buffer ), "%b", &tt ) ) + return TQString::fromLocal8Bit( buffer ); +#else + SYSTEMTIME st; + memset( &st, 0, sizeof(SYSTEMTIME) ); + st.wYear = 2000; + st.wMonth = month; + st.wDay = 1; + const wchar_t mmm_t[] = L"MMM"; // workaround for Borland + QT_WA( { + TCHAR buf[255]; + if ( GetDateFormat( LOCALE_USER_DEFAULT, 0, &st, mmm_t, buf, 255 ) ) + return TQString::fromUcs2( (ushort*)buf ); + } , { + char buf[255]; + if ( GetDateFormatA( LOCALE_USER_DEFAULT, 0, &st, "MMM", (char*)&buf, 255 ) ) + return TQString::fromLocal8Bit( buf ); + } ); +#endif + return TQString::null; +} + +/*! + Returns the long name of the \a month. + + 1 = "January", 2 = "February", ... 12 = "December" + + The month names will be localized according to the system's locale + settings. + + \sa toString(), shortMonthName(), shortDayName(), longDayName() +*/ + +TQString TQDate::longMonthName( int month ) +{ +#if defined(QT_CHECK_RANGE) + if ( month < 1 || month > 12 ) { + qWarning( "TQDate::longMonthName: Parameter out ouf range" ); + month = 1; + } +#endif +#ifndef Q_WS_WIN + char buffer[255]; + tm tt; + memset( &tt, 0, sizeof( tm ) ); + tt.tm_mon = month - 1; + if ( strftime( buffer, sizeof( buffer ), "%B", &tt ) ) + return TQString::fromLocal8Bit( buffer ); +#else + SYSTEMTIME st; + memset( &st, 0, sizeof(SYSTEMTIME) ); + st.wYear = 2000; + st.wMonth = month; + st.wDay = 1 ; + const wchar_t mmmm_t[] = L"MMMM"; // workaround for Borland + QT_WA( { + TCHAR buf[255]; + if ( GetDateFormat( LOCALE_USER_DEFAULT, 0, &st, mmmm_t, buf, 255 ) ) + return TQString::fromUcs2( (ushort*)buf ); + } , { + char buf[255]; + if ( GetDateFormatA( LOCALE_USER_DEFAULT, 0, &st, "MMMM", (char*)&buf, 255 ) ) + return TQString::fromLocal8Bit( buf ); + } ) +#endif + + return TQString::null; +} + +/*! + \fn TQString TQDate::dayName( int weekday ) + \obsolete + + Use shortDayName() instead. +*/ + +/*! + Returns the name of the \a weekday. + + 1 = "Mon", 2 = "Tue", ... 7 = "Sun" + + The day names will be localized according to the system's locale + settings. + + \sa toString(), shortMonthName(), longMonthName(), longDayName() +*/ + +TQString TQDate::shortDayName( int weekday ) +{ +#if defined(QT_CHECK_RANGE) + if ( weekday < 1 || weekday > 7 ) { + qWarning( "TQDate::shortDayName: Parameter out of range" ); + weekday = 1; + } +#endif +#ifndef Q_WS_WIN + char buffer[255]; + tm tt; + memset( &tt, 0, sizeof( tm ) ); + tt.tm_wday = ( weekday == 7 ) ? 0 : weekday; + if ( strftime( buffer, sizeof( buffer ), "%a", &tt ) ) + return TQString::fromLocal8Bit( buffer ); +#else + SYSTEMTIME st; + memset( &st, 0, sizeof(SYSTEMTIME) ); + st.wYear = 2001; + st.wMonth = 10; + st.wDayOfWeek = ( weekday == 7 ) ? 0 : weekday; + st.wDay = 21 + st.wDayOfWeek; + const wchar_t ddd_t[] = L"ddd"; // workaround for Borland + QT_WA( { + TCHAR buf[255]; + if ( GetDateFormat( LOCALE_USER_DEFAULT, 0, &st, ddd_t, buf, 255 ) ) + return TQString::fromUcs2( (ushort*)buf ); + } , { + char buf[255]; + if ( GetDateFormatA( LOCALE_USER_DEFAULT, 0, &st, "ddd", (char*)&buf, 255 ) ) + return TQString::fromLocal8Bit( buf ); + } ); +#endif + + return TQString::null; +} + +/*! + Returns the long name of the \a weekday. + + 1 = "Monday", 2 = "Tuesday", ... 7 = "Sunday" + + The day names will be localized according to the system's locale + settings. + + \sa toString(), shortDayName(), shortMonthName(), longMonthName() +*/ + +TQString TQDate::longDayName( int weekday ) +{ +#if defined(QT_CHECK_RANGE) + if ( weekday < 1 || weekday > 7 ) { + qWarning( "TQDate::longDayName: Parameter out of range" ); + weekday = 1; + } +#endif +#ifndef Q_WS_WIN + char buffer[255]; + tm tt; + memset( &tt, 0, sizeof( tm ) ); + tt.tm_wday = ( weekday == 7 ) ? 0 : weekday; + if ( strftime( buffer, sizeof( buffer ), "%A", &tt ) ) + return TQString::fromLocal8Bit( buffer ); +#else + SYSTEMTIME st; + memset( &st, 0, sizeof(SYSTEMTIME) ); + st.wYear = 2001; + st.wMonth = 10; + st.wDayOfWeek = ( weekday == 7 ) ? 0 : weekday; + st.wDay = 21 + st.wDayOfWeek; + const wchar_t dddd_t[] = L"dddd"; // workaround for Borland + QT_WA( { + TCHAR buf[255]; + if ( GetDateFormat( LOCALE_USER_DEFAULT, 0, &st, dddd_t, buf, 255 ) ) + return TQString::fromUcs2( (ushort*)buf ); + } , { + char buf[255]; + if ( GetDateFormatA( LOCALE_USER_DEFAULT, 0, &st, "dddd", (char*)&buf, 255 ) ) + return TQString::fromLocal8Bit( buf ); + } ); +#endif + + return TQString::null; +} +#endif //QT_NO_TEXTDATE + +#ifndef QT_NO_DATESTRING + +#if !defined(QT_NO_SPRINTF) +/*! + \overload + + Returns the date as a string. The \a f parameter determines the + format of the string. + + If \a f is \c TQt::TextDate, the string format is "Sat May 20 1995" + (using the shortDayName() and shortMonthName() functions to + generate the string, so the day and month names are locale + specific). + + If \a f is \c TQt::ISODate, the string format corresponds to the + ISO 8601 specification for representations of dates, which is + YYYY-MM-DD where YYYY is the year, MM is the month of the year + (between 01 and 12), and DD is the day of the month between 01 and + 31. + + If \a f is \c TQt::LocalDate, the string format depends on the + locale settings of the system. + + If the date is an invalid date, then TQString::null will be returned. + + \sa shortDayName(), shortMonthName() +*/ +TQString TQDate::toString( TQt::DateFormat f ) const +{ + if ( !isValid() ) + return TQString::null; + int y, m, d; + julianToGregorian( jd, y, m, d ); + switch ( f ) { + case TQt::LocalDate: + { +#ifndef Q_WS_WIN + tm tt; + memset( &tt, 0, sizeof( tm ) ); + char buf[255]; + tt.tm_mday = day(); + tt.tm_mon = month() - 1; + tt.tm_year = year() - 1900; + + static const char * avoidEgcsWarning = "%x"; + if ( strftime( buf, sizeof(buf), avoidEgcsWarning, &tt ) ) + return TQString::fromLocal8Bit( buf ); +#else + SYSTEMTIME st; + memset( &st, 0, sizeof(SYSTEMTIME) ); + st.wYear = year(); + st.wMonth = month(); + st.wDay = day(); + QT_WA( { + TCHAR buf[255]; + if ( GetDateFormat( LOCALE_USER_DEFAULT, 0, &st, 0, buf, 255 ) ) + return TQString::fromUcs2( (ushort*)buf ); + } , { + char buf[255]; + if ( GetDateFormatA( LOCALE_USER_DEFAULT, 0, &st, 0, (char*)&buf, 255 ) ) + return TQString::fromLocal8Bit( buf ); + } ); +#endif + return TQString::null; + } + default: +#ifndef QT_NO_TEXTDATE + case TQt::TextDate: + { + TQString buf = shortDayName( dayOfWeek() ); + buf += ' '; + buf += shortMonthName( m ); + TQString t; + t.sprintf( " %d %d", d, y ); + buf += t; + return buf; + } +#endif + case TQt::ISODate: + { + TQString month( TQString::number( m ).rightJustify( 2, '0' ) ); + TQString day( TQString::number( d ).rightJustify( 2, '0' ) ); + return TQString::number( y ) + "-" + month + "-" + day; + } + } +} +#endif //QT_NO_SPRINTF + +/*! + Returns the date as a string. The \a format parameter determines + the format of the result string. + + These expressions may be used: + + \table + \header \i Expression \i Output + \row \i d \i the day as number without a leading zero (1-31) + \row \i dd \i the day as number with a leading zero (01-31) + \row \i ddd + \i the abbreviated localized day name (e.g. 'Mon'..'Sun'). + Uses TQDate::shortDayName(). + \row \i dddd + \i the long localized day name (e.g. 'Monday'..'Sunday'). + Uses TQDate::longDayName(). + \row \i M \i the month as number without a leading zero (1-12) + \row \i MM \i the month as number with a leading zero (01-12) + \row \i MMM + \i the abbreviated localized month name (e.g. 'Jan'..'Dec'). + Uses TQDate::shortMonthName(). + \row \i MMMM + \i the long localized month name (e.g. 'January'..'December'). + Uses TQDate::longMonthName(). + \row \i yy \i the year as two digit number (00-99) + \row \i yyyy \i the year as four digit number (1752-8000) + \endtable + + All other input characters will be ignored. + + Example format strings (assuming that the TQDate is the + 20th July 1969): + \table + \header \i Format \i Result + \row \i dd.MM.yyyy \i11 20.07.1969 + \row \i ddd MMMM d yy \i11 Sun July 20 69 + \endtable + + If the date is an invalid date, then TQString::null will be returned. + + \sa TQDateTime::toString() TQTime::toString() + +*/ +TQString TQDate::toString( const TQString& format ) const +{ + return fmtDateTime( format, 0, this ); +} +#endif //QT_NO_DATESTRING + +/*! + Sets the date's year \a y, month \a m and day \a d. + + \a y must be in the range 1752..8000, \a m must be in the range + 1..12, and \a d must be in the range 1..31. + + \warning If \a y is in the range 0..99, it is interpreted as + 1900..1999. + + Returns TRUE if the date is valid; otherwise returns FALSE. +*/ + +bool TQDate::setYMD( int y, int m, int d ) +{ + if ( year() == y && month() == m && day() == d ) + return isValid(); + if ( !isValid(y,m,d) ) { +#if defined(QT_CHECK_RANGE) + qWarning( "TQDate::setYMD: Invalid date %04d-%02d-%02d", y, m, d ); +#endif + return FALSE; + } + jd = gregorianToJulian( y, m, d ); + return TRUE; +} + +/*! + Returns a TQDate object containing a date \a ndays later than the + date of this object (or earlier if \a ndays is negative). + + \sa addMonths() addYears() daysTo() +*/ + +TQDate TQDate::addDays( int ndays ) const +{ + TQDate d; + d.jd = jd + ndays; + return d; +} + +/*! + Returns a TQDate object containing a date \a nmonths later than the + date of this object (or earlier if \a nmonths is negative). + + \sa addDays() addYears() +*/ + +TQDate TQDate::addMonths( int nmonths ) const +{ + int y, m, d; + julianToGregorian( jd, y, m, d ); + + while ( nmonths != 0 ) { + if ( nmonths < 0 && nmonths + 12 <= 0 ) { + y--; + nmonths+=12; + } else if ( nmonths < 0 ) { + m+= nmonths; + nmonths = 0; + if ( m <= 0 ) { + --y; + m+=12; + } + } else if ( nmonths - 12 >= 0 ) { + y++; + nmonths-=12; + } else if ( m == 12 ) { + y++; + m = 0; + } else { + m+= nmonths; + nmonths = 0; + if ( m > 12 ) { + ++y; + m -= 12; + } + } + } + + TQDate tmp(y,m,1); + + if( d > tmp.daysInMonth() ) + d = tmp.daysInMonth(); + + TQDate date(y, m, d); + return date; + +} + +/*! + Returns a TQDate object containing a date \a nyears later than the + date of this object (or earlier if \a nyears is negative). + + \sa addDays(), addMonths() +*/ + +TQDate TQDate::addYears( int nyears ) const +{ + int y, m, d; + julianToGregorian( jd, y, m, d ); + y += nyears; + + TQDate tmp(y,m,1); + + if( d > tmp.daysInMonth() ) + d = tmp.daysInMonth(); + + TQDate date(y, m, d); + return date; +} + + + +/*! + Returns the number of days from this date to \a d (which is + negative if \a d is earlier than this date). + + Example: + \code + TQDate d1( 1995, 5, 17 ); // May 17th 1995 + TQDate d2( 1995, 5, 20 ); // May 20th 1995 + d1.daysTo( d2 ); // returns 3 + d2.daysTo( d1 ); // returns -3 + \endcode + + \sa addDays() +*/ + +int TQDate::daysTo( const TQDate &d ) const +{ + return d.jd - jd; +} + + +/*! + \fn bool TQDate::operator==( const TQDate &d ) const + + Returns TRUE if this date is equal to \a d; otherwise returns FALSE. +*/ + +/*! + \fn bool TQDate::operator!=( const TQDate &d ) const + + Returns TRUE if this date is different from \a d; otherwise returns FALSE. +*/ + +/*! + \fn bool TQDate::operator<( const TQDate &d ) const + + Returns TRUE if this date is earlier than \a d, otherwise returns FALSE. +*/ + +/*! + \fn bool TQDate::operator<=( const TQDate &d ) const + + Returns TRUE if this date is earlier than or equal to \a d, + otherwise returns FALSE. +*/ + +/*! + \fn bool TQDate::operator>( const TQDate &d ) const + + Returns TRUE if this date is later than \a d, otherwise returns FALSE. +*/ + +/*! + \fn bool TQDate::operator>=( const TQDate &d ) const + + Returns TRUE if this date is later than or equal to \a d, + otherwise returns FALSE. +*/ + +/*! + \overload + Returns the current date, as reported by the system clock. + + \sa TQTime::currentTime(), TQDateTime::currentDateTime() +*/ + +TQDate TQDate::currentDate() +{ + return currentDate( TQt::LocalTime ); +} + +/*! + Returns the current date, as reported by the system clock, for the + TimeSpec \a ts. The default TimeSpec is LocalTime. + + \sa TQTime::currentTime(), TQDateTime::currentDateTime(), TQt::TimeSpec +*/ +TQDate TQDate::currentDate( TQt::TimeSpec ts ) +{ + TQDate d; +#if defined(Q_OS_WIN32) + SYSTEMTIME t; + memset( &t, 0, sizeof(SYSTEMTIME) ); + if ( ts == TQt::LocalTime ) + GetLocalTime( &t ); + else + GetSystemTime( &t ); + d.jd = gregorianToJulian( t.wYear, t.wMonth, t.wDay ); +#else + // posix compliant system + time_t ltime; + time( <ime ); + tm *t; + +# if defined(QT_THREAD_SUPPORT) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) + // use the reentrant versions of localtime() and gmtime() where available + tm res; + if ( ts == TQt::LocalTime ) + t = localtime_r( <ime, &res ); + else + t = gmtime_r( <ime, &res ); +# else + if ( ts == TQt::LocalTime ) + t = localtime( <ime ); + else + t = gmtime( <ime ); +# endif // QT_THREAD_SUPPORT && _POSIX_THREAD_SAFE_FUNCTIONS + + d.jd = gregorianToJulian( t->tm_year + 1900, t->tm_mon + 1, t->tm_mday ); +#endif + return d; +} + +#ifndef QT_NO_DATESTRING +/*! + Returns the TQDate represented by the string \a s, using the format + \a f, or an invalid date if the string cannot be parsed. + + Note for \c TQt::TextDate: It is recommended that you use the + English short month names (e.g. "Jan"). Although localized month + names can also be used, they depend on the user's locale settings. + + \warning \c TQt::LocalDate cannot be used here. +*/ +TQDate TQDate::fromString( const TQString& s, TQt::DateFormat f ) +{ + if ( ( s.isEmpty() ) || ( f == TQt::LocalDate ) ) { +#if defined(QT_CHECK_RANGE) + qWarning( "TQDate::fromString: Parameter out of range" ); +#endif + TQDate d; + d.jd = 0; + return d; + } + switch ( f ) { + case TQt::ISODate: + { + int year( s.mid( 0, 4 ).toInt() ); + int month( s.mid( 5, 2 ).toInt() ); + int day( s.mid( 8, 2 ).toInt() ); + if ( year && month && day ) + return TQDate( year, month, day ); + } + break; + default: +#ifndef QT_NO_TEXTDATE + case TQt::TextDate: + { + /* + This will fail gracefully if the input string doesn't + contain any space. + */ + int monthPos = s.find( ' ' ) + 1; + int dayPos = s.find( ' ', monthPos ) + 1; + + TQString monthName( s.mid(monthPos, dayPos - monthPos - 1) ); + int month = -1; + + // try English names first + for ( int i = 0; i < 12; i++ ) { + if ( monthName == qt_shortMonthNames[i] ) { + month = i + 1; + break; + } + } + + // try the localized names + if ( month == -1 ) { + for ( int i = 0; i < 12; i++ ) { + if ( monthName == shortMonthName( i + 1 ) ) { + month = i + 1; + break; + } + } + } +#if defined(QT_CHECK_RANGE) + if ( month < 1 || month > 12 ) { + qWarning( "TQDate::fromString: Parameter out of range" ); + TQDate d; + d.jd = 0; + return d; + } +#endif + int day = s.mid( dayPos, 2 ).stripWhiteSpace().toInt(); + int year = s.right( 4 ).toInt(); + return TQDate( year, month, day ); + } +#else + break; +#endif + } + return TQDate(); +} +#endif //QT_NO_DATESTRING + +/*! + \overload + + Returns TRUE if the specified date (year \a y, month \a m and day + \a d) is valid; otherwise returns FALSE. + + Example: + \code + TQDate::isValid( 2002, 5, 17 ); // TRUE May 17th 2002 is valid + TQDate::isValid( 2002, 2, 30 ); // FALSE Feb 30th does not exist + TQDate::isValid( 2004, 2, 29 ); // TRUE 2004 is a leap year + TQDate::isValid( 1202, 6, 6 ); // FALSE 1202 is pre-Gregorian + \endcode + + \warning A \a y value in the range 00..99 is interpreted as + 1900..1999. + + \sa isNull(), setYMD() +*/ + +bool TQDate::isValid( int y, int m, int d ) +{ + if ( y >= 0 && y <= 99 ) + y += 1900; + else if ( y < FIRST_YEAR || (y == FIRST_YEAR && (m < 9 || + (m == 9 && d < 14))) ) + return FALSE; + return (d > 0 && m > 0 && m <= 12) && + (d <= monthDays[m] || (d == 29 && m == 2 && leapYear(y))); +} + +/*! + Returns TRUE if the specified year \a y is a leap year; otherwise + returns FALSE. +*/ + +bool TQDate::leapYear( int y ) +{ + return y % 4 == 0 && y % 100 != 0 || y % 400 == 0; +} + +/*! + \internal + Converts a Gregorian date to a Julian day. + This algorithm is taken from Communications of the ACM, Vol 6, No 8. + \sa julianToGregorian() +*/ + +uint TQDate::gregorianToJulian( int y, int m, int d ) +{ + uint c, ya; + if ( y <= 99 ) + y += 1900; + if ( m > 2 ) { + m -= 3; + } else { + m += 9; + y--; + } + c = y; // NOTE: Sym C++ 6.0 bug + c /= 100; + ya = y - 100*c; + return 1721119 + d + (146097*c)/4 + (1461*ya)/4 + (153*m+2)/5; +} + +/*! + \internal + Converts a Julian day to a Gregorian date. + This algorithm is taken from Communications of the ACM, Vol 6, No 8. + \sa gregorianToJulian() +*/ + +void TQDate::julianToGregorian( uint jd, int &y, int &m, int &d ) +{ + uint x; + uint j = jd - 1721119; + y = (j*4 - 1)/146097; + j = j*4 - 146097*y - 1; + x = j/4; + j = (x*4 + 3) / 1461; + y = 100*y + j; + x = (x*4) + 3 - 1461*j; + x = (x + 4)/4; + m = (5*x - 3)/153; + x = 5*x - 3 - 153*m; + d = (x + 5)/5; + if ( m < 10 ) { + m += 3; + } else { + m -= 9; + y++; + } +} + + +/***************************************************************************** + TQTime member functions + *****************************************************************************/ + +/*! + \class TQTime qdatetime.h + \reentrant + + \brief The TQTime class provides clock time functions. + + \ingroup time + \mainclass + + A TQTime object contains a clock time, i.e. the number of hours, + minutes, seconds, and milliseconds since midnight. It can read the + current time from the system clock and measure a span of elapsed + time. It provides functions for comparing times and for + manipulating a time by adding a number of (milli)seconds. + + TQTime uses the 24-hour clock format; it has no concept of AM/PM. + It operates in local time; it knows nothing about time zones or + daylight savings time. + + A TQTime object is typically created either by giving the number of + hours, minutes, seconds, and milliseconds explicitly, or by using + the static function currentTime(), which creates a TQTime object + that contains the system's clock time. Note that the accuracy + depends on the accuracy of the underlying operating system; not + all systems provide 1-millisecond accuracy. + + The hour(), minute(), second(), and msec() functions provide + access to the number of hours, minutes, seconds, and milliseconds + of the time. The same information is provided in textual format by + the toString() function. + + TQTime provides a full set of operators to compare two TQTime + objects. One time is considered smaller than another if it is + earlier than the other. + + The time a given number of seconds or milliseconds later than a + given time can be found using the addSecs() or addMSecs() + functions. Correspondingly, the number of (milli)seconds between + two times can be found using the secsTo() or msecsTo() functions. + + TQTime can be used to measure a span of elapsed time using the + start(), restart(), and elapsed() functions. + + \sa TQDate, TQDateTime +*/ + +/*! + \fn TQTime::TQTime() + + Constructs the time 0 hours, minutes, seconds and milliseconds, + i.e. 00:00:00.000 (midnight). This is a valid time. + + \sa isValid() +*/ + +/*! + Constructs a time with hour \a h, minute \a m, seconds \a s and + milliseconds \a ms. + + \a h must be in the range 0..23, \a m and \a s must be in the + range 0..59, and \a ms must be in the range 0..999. + + \sa isValid() +*/ + +TQTime::TQTime( int h, int m, int s, int ms ) +{ + setHMS( h, m, s, ms ); +} + + +/*! + \fn bool TQTime::isNull() const + + Returns TRUE if the time is equal to 00:00:00.000; otherwise + returns FALSE. A null time is valid. + + \sa isValid() +*/ + +/*! + Returns TRUE if the time is valid; otherwise returns FALSE. The + time 23:30:55.746 is valid, whereas 24:12:30 is invalid. + + \sa isNull() +*/ + +bool TQTime::isValid() const +{ + return ds < MSECS_PER_DAY; +} + + +/*! + Returns the hour part (0..23) of the time. +*/ + +int TQTime::hour() const +{ + return ds / MSECS_PER_HOUR; +} + +/*! + Returns the minute part (0..59) of the time. +*/ + +int TQTime::minute() const +{ + return (ds % MSECS_PER_HOUR)/MSECS_PER_MIN; +} + +/*! + Returns the second part (0..59) of the time. +*/ + +int TQTime::second() const +{ + return (ds / 1000)%SECS_PER_MIN; +} + +/*! + Returns the millisecond part (0..999) of the time. +*/ + +int TQTime::msec() const +{ + return ds % 1000; +} + +#ifndef QT_NO_DATESTRING +#ifndef QT_NO_SPRINTF +/*! + \overload + + Returns the time as a string. Milliseconds are not included. The + \a f parameter determines the format of the string. + + If \a f is \c TQt::TextDate, the string format is HH:MM:SS; e.g. 1 + second before midnight would be "23:59:59". + + If \a f is \c TQt::ISODate, the string format corresponds to the + ISO 8601 extended specification for representations of dates, + which is also HH:MM:SS. + + If \a f is TQt::LocalDate, the string format depends on the locale + settings of the system. + + If the time is an invalid time, then TQString::null will be returned. +*/ + +TQString TQTime::toString( TQt::DateFormat f ) const +{ + if ( !isValid() ) + return TQString::null; + + switch ( f ) { + case TQt::LocalDate: + { +#ifndef Q_WS_WIN + tm tt; + memset( &tt, 0, sizeof( tm ) ); + char buf[255]; + tt.tm_sec = second(); + tt.tm_min = minute(); + tt.tm_hour = hour(); + if ( strftime( buf, sizeof(buf), "%X", &tt ) ) + return TQString::fromLocal8Bit( buf ); +#else + SYSTEMTIME st; + memset( &st, 0, sizeof(SYSTEMTIME) ); + st.wHour = hour(); + st.wMinute = minute(); + st.wSecond = second(); + st.wMilliseconds = 0; + QT_WA( { + TCHAR buf[255]; + if ( GetTimeFormat( LOCALE_USER_DEFAULT, 0, &st, 0, buf, 255 ) ) + return TQString::fromUcs2( (ushort*)buf ); + } , { + char buf[255]; + if ( GetTimeFormatA( LOCALE_USER_DEFAULT, 0, &st, 0, (char*)&buf, 255 ) ) + return TQString::fromLocal8Bit( buf ); + } ); +#endif + return TQString::null; + } + default: + case TQt::ISODate: + case TQt::TextDate: + TQString buf; + buf.sprintf( "%.2d:%.2d:%.2d", hour(), minute(), second() ); + return buf; + } +} +#endif + +/*! + Returns the time as a string. The \a format parameter determines + the format of the result string. + + These expressions may be used: + + \table + \header \i Expression \i Output + \row \i h + \i the hour without a leading zero (0..23 or 1..12 if AM/PM display) + \row \i hh + \i the hour with a leading zero (00..23 or 01..12 if AM/PM display) + \row \i m \i the minute without a leading zero (0..59) + \row \i mm \i the minute with a leading zero (00..59) + \row \i s \i the second whithout a leading zero (0..59) + \row \i ss \i the second whith a leading zero (00..59) + \row \i z \i the milliseconds without leading zeroes (0..999) + \row \i zzz \i the milliseconds with leading zeroes (000..999) + \row \i AP + \i use AM/PM display. \e AP will be replaced by either "AM" or "PM". + \row \i ap + \i use am/pm display. \e ap will be replaced by either "am" or "pm". + \endtable + + All other input characters will be ignored. + + Example format strings (assuming that the TQTime is 14:13:09.042) + + \table + \header \i Format \i Result + \row \i hh:mm:ss.zzz \i11 14:13:09.042 + \row \i h:m:s ap \i11 2:13:9 pm + \endtable + + If the time is an invalid time, then TQString::null will be returned. + + \sa TQDate::toString() TQDateTime::toString() +*/ +TQString TQTime::toString( const TQString& format ) const +{ + return fmtDateTime( format, this, 0 ); +} +#endif //QT_NO_DATESTRING +/*! + Sets the time to hour \a h, minute \a m, seconds \a s and + milliseconds \a ms. + + \a h must be in the range 0..23, \a m and \a s must be in the + range 0..59, and \a ms must be in the range 0..999. Returns TRUE + if the set time is valid; otherwise returns FALSE. + + \sa isValid() +*/ + +bool TQTime::setHMS( int h, int m, int s, int ms ) +{ + if ( !isValid(h,m,s,ms) ) { +#if defined(QT_CHECK_RANGE) + qWarning( "TQTime::setHMS Invalid time %02d:%02d:%02d.%03d", h, m, s, + ms ); +#endif + ds = MSECS_PER_DAY; // make this invalid + return FALSE; + } + ds = (h*SECS_PER_HOUR + m*SECS_PER_MIN + s)*1000 + ms; + return TRUE; +} + +/*! + Returns a TQTime object containing a time \a nsecs seconds later + than the time of this object (or earlier if \a nsecs is negative). + + Note that the time will wrap if it passes midnight. + + Example: + \code + TQTime n( 14, 0, 0 ); // n == 14:00:00 + TQTime t; + t = n.addSecs( 70 ); // t == 14:01:10 + t = n.addSecs( -70 ); // t == 13:58:50 + t = n.addSecs( 10*60*60 + 5 ); // t == 00:00:05 + t = n.addSecs( -15*60*60 ); // t == 23:00:00 + \endcode + + \sa addMSecs(), secsTo(), TQDateTime::addSecs() +*/ + +TQTime TQTime::addSecs( int nsecs ) const +{ + return addMSecs( nsecs * 1000 ); +} + +/*! + Returns the number of seconds from this time to \a t (which is + negative if \a t is earlier than this time). + + Because TQTime measures time within a day and there are 86400 + seconds in a day, the result is always between -86400 and 86400. + + \sa addSecs() TQDateTime::secsTo() +*/ + +int TQTime::secsTo( const TQTime &t ) const +{ + return ((int)t.ds - (int)ds)/1000; +} + +/*! + Returns a TQTime object containing a time \a ms milliseconds later + than the time of this object (or earlier if \a ms is negative). + + Note that the time will wrap if it passes midnight. See addSecs() + for an example. + + \sa addSecs(), msecsTo() +*/ + +TQTime TQTime::addMSecs( int ms ) const +{ + TQTime t; + if ( ms < 0 ) { + // % not well-defined for -ve, but / is. + int negdays = (MSECS_PER_DAY-ms) / MSECS_PER_DAY; + t.ds = ((int)ds + ms + negdays*MSECS_PER_DAY) + % MSECS_PER_DAY; + } else { + t.ds = ((int)ds + ms) % MSECS_PER_DAY; + } + return t; +} + +/*! + Returns the number of milliseconds from this time to \a t (which + is negative if \a t is earlier than this time). + + Because TQTime measures time within a day and there are 86400 + seconds in a day, the result is always between -86400000 and + 86400000 msec. + + \sa secsTo() +*/ + +int TQTime::msecsTo( const TQTime &t ) const +{ + return (int)t.ds - (int)ds; +} + + +/*! + \fn bool TQTime::operator==( const TQTime &t ) const + + Returns TRUE if this time is equal to \a t; otherwise returns FALSE. +*/ + +/*! + \fn bool TQTime::operator!=( const TQTime &t ) const + + Returns TRUE if this time is different from \a t; otherwise returns FALSE. +*/ + +/*! + \fn bool TQTime::operator<( const TQTime &t ) const + + Returns TRUE if this time is earlier than \a t; otherwise returns FALSE. +*/ + +/*! + \fn bool TQTime::operator<=( const TQTime &t ) const + + Returns TRUE if this time is earlier than or equal to \a t; + otherwise returns FALSE. +*/ + +/*! + \fn bool TQTime::operator>( const TQTime &t ) const + + Returns TRUE if this time is later than \a t; otherwise returns FALSE. +*/ + +/*! + \fn bool TQTime::operator>=( const TQTime &t ) const + + Returns TRUE if this time is later than or equal to \a t; + otherwise returns FALSE. +*/ + + + +/*! + \overload + + Returns the current time as reported by the system clock. + + Note that the accuracy depends on the accuracy of the underlying + operating system; not all systems provide 1-millisecond accuracy. +*/ + +TQTime TQTime::currentTime() +{ + return currentTime( TQt::LocalTime ); +} + +/*! + Returns the current time as reported by the system clock, for the + TimeSpec \a ts. The default TimeSpec is LocalTime. + + Note that the accuracy depends on the accuracy of the underlying + operating system; not all systems provide 1-millisecond accuracy. + + \sa TQt::TimeSpec +*/ +TQTime TQTime::currentTime( TQt::TimeSpec ts ) +{ + TQTime t; + currentTime( &t, ts ); + return t; +} + +#ifndef QT_NO_DATESTRING +/*! + Returns the representation \a s as a TQTime using the format \a f, + or an invalid time if this is not possible. + + \warning Note that \c TQt::LocalDate cannot be used here. +*/ +TQTime TQTime::fromString( const TQString& s, TQt::DateFormat f ) +{ + if ( ( s.isEmpty() ) || ( f == TQt::LocalDate ) ) { +#if defined(QT_CHECK_RANGE) + qWarning( "TQTime::fromString: Parameter out of range" ); +#endif + TQTime t; + t.ds = MSECS_PER_DAY; + return t; + } + + int hour( s.mid( 0, 2 ).toInt() ); + int minute( s.mid( 3, 2 ).toInt() ); + int second( s.mid( 6, 2 ).toInt() ); + int msec( s.mid( 9, 3 ).toInt() ); + return TQTime( hour, minute, second, msec ); +} +#endif + +/*! + \internal + \obsolete + + Fetches the current time and returns TRUE if the time is within one + minute after midnight, otherwise FALSE. The return value is used by + TQDateTime::currentDateTime() to ensure that the date there is correct. +*/ + +bool TQTime::currentTime( TQTime *ct ) +{ + return currentTime( ct, TQt::LocalTime ); +} + + +/*! + \internal + + Fetches the current time, for the TimeSpec \a ts, and returns TRUE + if the time is within one minute after midnight, otherwise FALSE. The + return value is used by TQDateTime::currentDateTime() to ensure that + the date there is correct. The default TimeSpec is LocalTime. + + \sa TQt::TimeSpec +*/ +bool TQTime::currentTime( TQTime *ct, TQt::TimeSpec ts ) +{ + if ( !ct ) { +#if defined(QT_CHECK_NULL) + qWarning( "TQTime::currentTime(TQTime *): Null pointer not allowed" ); +#endif + return FALSE; + } + +#if defined(Q_OS_WIN32) + SYSTEMTIME t; + if ( ts == TQt::LocalTime ) { + GetLocalTime( &t ); + } else { + GetSystemTime( &t ); + } + ct->ds = (uint)( MSECS_PER_HOUR*t.wHour + MSECS_PER_MIN*t.wMinute + + 1000*t.wSecond + t.wMilliseconds ); +#elif defined(Q_OS_UNIX) + // posix compliant system + struct timeval tv; + gettimeofday( &tv, 0 ); + time_t ltime = tv.tv_sec; + tm *t; + +# if defined(QT_THREAD_SUPPORT) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) + // use the reentrant versions of localtime() and gmtime() where available + tm res; + if ( ts == TQt::LocalTime ) + t = localtime_r( <ime, &res ); + else + t = gmtime_r( <ime, &res ); +# else + if ( ts == TQt::LocalTime ) + t = localtime( <ime ); + else + t = gmtime( <ime ); +# endif // QT_THREAD_SUPPORT && _POSIX_THREAD_SAFE_FUNCTIONS + + ct->ds = (uint)( MSECS_PER_HOUR * t->tm_hour + MSECS_PER_MIN * t->tm_min + + 1000 * t->tm_sec + tv.tv_usec / 1000 ); +#else + time_t ltime; // no millisecond resolution + ::time( <ime ); + tm *t; + if ( ts == TQt::LocalTime ) + localtime( <ime ); + else + gmtime( <ime ); + ct->ds = (uint) ( MSECS_PER_HOUR * t->tm_hour + MSECS_PER_MIN * t->tm_min + + 1000 * t->tm_sec ); +#endif + // 00:00.00 to 00:00.59.999 is considered as "midnight or right after" + return ct->ds < (uint) MSECS_PER_MIN; +} + +/*! + \overload + + Returns TRUE if the specified time is valid; otherwise returns + FALSE. + + The time is valid if \a h is in the range 0..23, \a m and \a s are + in the range 0..59, and \a ms is in the range 0..999. + + Example: + \code + TQTime::isValid(21, 10, 30); // returns TRUE + TQTime::isValid(22, 5, 62); // returns FALSE + \endcode +*/ + +bool TQTime::isValid( int h, int m, int s, int ms ) +{ + return (uint)h < 24 && (uint)m < 60 && (uint)s < 60 && (uint)ms < 1000; +} + + +/*! + Sets this time to the current time. This is practical for timing: + + \code + TQTime t; + t.start(); + some_lengthy_task(); + qDebug( "Time elapsed: %d ms", t.elapsed() ); + \endcode + + \sa restart(), elapsed(), currentTime() +*/ + +void TQTime::start() +{ + *this = currentTime(); +} + +/*! + Sets this time to the current time and returns the number of + milliseconds that have elapsed since the last time start() or + restart() was called. + + This function is guaranteed to be atomic and is thus very handy + for repeated measurements. Call start() to start the first + measurement and then restart() for each later measurement. + + Note that the counter wraps to zero 24 hours after the last call + to start() or restart(). + + \warning If the system's clock setting has been changed since the + last time start() or restart() was called, the result is + undefined. This can happen when daylight savings time is turned on + or off. + + \sa start(), elapsed(), currentTime() +*/ + +int TQTime::restart() +{ + TQTime t = currentTime(); + int n = msecsTo( t ); + if ( n < 0 ) // passed midnight + n += 86400*1000; + *this = t; + return n; +} + +/*! + Returns the number of milliseconds that have elapsed since the + last time start() or restart() was called. + + Note that the counter wraps to zero 24 hours after the last call + to start() or restart. + + Note that the accuracy depends on the accuracy of the underlying + operating system; not all systems provide 1-millisecond accuracy. + + \warning If the system's clock setting has been changed since the + last time start() or restart() was called, the result is + undefined. This can happen when daylight savings time is turned on + or off. + + \sa start(), restart() +*/ + +int TQTime::elapsed() const +{ + int n = msecsTo( currentTime() ); + if ( n < 0 ) // passed midnight + n += 86400*1000; + return n; +} + + +/***************************************************************************** + TQDateTime member functions + *****************************************************************************/ + +/*! + \class TQDateTime qdatetime.h + \reentrant + \brief The TQDateTime class provides date and time functions. + + \ingroup time + \mainclass + + A TQDateTime object contains a calendar date and a clock time (a + "datetime"). It is a combination of the TQDate and TQTime classes. + It can read the current datetime from the system clock. It + provides functions for comparing datetimes and for manipulating a + datetime by adding a number of seconds, days, months or years. + + A TQDateTime object is typically created either by giving a date + and time explicitly in the constructor, or by using the static + function currentDateTime(), which returns a TQDateTime object set + to the system clock's time. The date and time can be changed with + setDate() and setTime(). A datetime can also be set using the + setTime_t() function, which takes a POSIX-standard "number of + seconds since 00:00:00 on January 1, 1970" value. The fromString() + function returns a TQDateTime given a string and a date format + which is used to interpret the date within the string. + + The date() and time() functions provide access to the date and + time parts of the datetime. The same information is provided in + textual format by the toString() function. + + TQDateTime provides a full set of operators to compare two + TQDateTime objects where smaller means earlier and larger means + later. + + You can increment (or decrement) a datetime by a given number of + seconds using addSecs() or days using addDays(). Similarly you can + use addMonths() and addYears(). The daysTo() function returns the + number of days between two datetimes, and secsTo() returns the + number of seconds between two datetimes. + + The range of a datetime object is constrained to the ranges of the + TQDate and TQTime objects which it embodies. + + \sa TQDate TQTime TQDateTimeEdit +*/ + + +/*! + \fn TQDateTime::TQDateTime() + + Constructs a null datetime (i.e. null date and null time). A null + datetime is invalid, since the date is invalid. + + \sa isValid() +*/ + + +/*! + Constructs a datetime with date \a date and null (but valid) time + (00:00:00.000). +*/ + +TQDateTime::TQDateTime( const TQDate &date ) + : d(date) +{ +} + +/*! + Constructs a datetime with date \a date and time \a time. +*/ + +TQDateTime::TQDateTime( const TQDate &date, const TQTime &time ) + : d(date), t(time) +{ +} + + +/*! + \fn bool TQDateTime::isNull() const + + Returns TRUE if both the date and the time are null; otherwise + returns FALSE. A null datetime is invalid. + + \sa TQDate::isNull(), TQTime::isNull() +*/ + +/*! + \fn bool TQDateTime::isValid() const + + Returns TRUE if both the date and the time are valid; otherwise + returns FALSE. + + \sa TQDate::isValid(), TQTime::isValid() +*/ + +/*! + \fn TQDate TQDateTime::date() const + + Returns the date part of the datetime. + + \sa setDate(), time() +*/ + +/*! + \fn TQTime TQDateTime::time() const + + Returns the time part of the datetime. + + \sa setTime(), date() +*/ + +/*! + \fn void TQDateTime::setDate( const TQDate &date ) + + Sets the date part of this datetime to \a date. + + \sa date(), setTime() +*/ + +/*! + \fn void TQDateTime::setTime( const TQTime &time ) + + Sets the time part of this datetime to \a time. + + \sa time(), setDate() +*/ + + +/*! + Returns the datetime as the number of seconds that have passed + since 1970-01-01T00:00:00, Coordinated Universal Time (UTC). + + On systems that do not support timezones, this function will + behave as if local time were UTC. + + \sa setTime_t() +*/ + +uint TQDateTime::toTime_t() const +{ + tm brokenDown; + brokenDown.tm_sec = t.second(); + brokenDown.tm_min = t.minute(); + brokenDown.tm_hour = t.hour(); + brokenDown.tm_mday = d.day(); + brokenDown.tm_mon = d.month() - 1; + brokenDown.tm_year = d.year() - 1900; + brokenDown.tm_isdst = -1; + int secsSince1Jan1970UTC = (int) mktime( &brokenDown ); + if ( secsSince1Jan1970UTC < -1 ) + secsSince1Jan1970UTC = -1; + return (uint) secsSince1Jan1970UTC; +} + +/*! + \overload + + Convenience function that sets the date and time to local time + based on the given UTC time. +*/ + +void TQDateTime::setTime_t( uint secsSince1Jan1970UTC ) +{ + setTime_t( secsSince1Jan1970UTC, TQt::LocalTime ); +} + +/*! + Sets the date and time to \a ts time (\c TQt::LocalTime or \c + TQt::UTC) given the number of seconds that have passed since + 1970-01-01T00:00:00, Coordinated Universal Time (UTC). On systems + that do not support timezones this function will behave as if + local time were UTC. + + On Windows, only a subset of \a secsSince1Jan1970UTC values are + supported, as Windows starts counting from 1980. + + \sa toTime_t() +*/ +void TQDateTime::setTime_t( uint secsSince1Jan1970UTC, TQt::TimeSpec ts ) +{ + time_t tmp = (time_t) secsSince1Jan1970UTC; + tm *brokenDown = 0; + +#if defined(Q_OS_UNIX) && defined(QT_THREAD_SUPPORT) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) + // posix compliant system + // use the reentrant versions of localtime() and gmtime() where available + tm res; + if ( ts == TQt::LocalTime ) + brokenDown = localtime_r( &tmp, &res ); + if ( !brokenDown ) { + brokenDown = gmtime_r( &tmp, &res ); + if ( !brokenDown ) { + d.jd = TQDate::gregorianToJulian( 1970, 1, 1 ); + t.ds = 0; + return; + } + } +#else + if ( ts == TQt::LocalTime ) + brokenDown = localtime( &tmp ); + if ( !brokenDown ) { + brokenDown = gmtime( &tmp ); + if ( !brokenDown ) { + d.jd = TQDate::gregorianToJulian( 1970, 1, 1 ); + t.ds = 0; + return; + } + } +#endif + + d.jd = TQDate::gregorianToJulian( brokenDown->tm_year + 1900, + brokenDown->tm_mon + 1, + brokenDown->tm_mday ); + t.ds = MSECS_PER_HOUR * brokenDown->tm_hour + + MSECS_PER_MIN * brokenDown->tm_min + + 1000 * brokenDown->tm_sec; +} +#ifndef QT_NO_DATESTRING +#ifndef QT_NO_SPRINTF +/*! + \overload + + Returns the datetime as a string. The \a f parameter determines + the format of the string. + + If \a f is \c TQt::TextDate, the string format is "Wed May 20 + 03:40:13 1998" (using TQDate::shortDayName(), TQDate::shortMonthName(), + and TQTime::toString() to generate the string, so the day and month + names will have localized names). + + If \a f is \c TQt::ISODate, the string format corresponds to the + ISO 8601 extended specification for representations of dates and + times, which is YYYY-MM-DDTHH:MM:SS. + + If \a f is \c TQt::LocalDate, the string format depends on the + locale settings of the system. + + If the format \a f is invalid or the datetime is invalid, toString() + returns a null string. + + \sa TQDate::toString() TQTime::toString() +*/ + +TQString TQDateTime::toString( TQt::DateFormat f ) const +{ + if ( !isValid() ) + return TQString::null; + + if ( f == TQt::ISODate ) { + return d.toString( TQt::ISODate ) + "T" + t.toString( TQt::ISODate ); + } +#ifndef QT_NO_TEXTDATE + else if ( f == TQt::TextDate ) { +#ifndef Q_WS_WIN + TQString buf = d.shortDayName( d.dayOfWeek() ); + buf += ' '; + buf += d.shortMonthName( d.month() ); + buf += ' '; + buf += TQString().setNum( d.day() ); + buf += ' '; +#else + TQString buf; + TQString winstr; + QT_WA( { + TCHAR out[255]; + GetLocaleInfo( LOCALE_USER_DEFAULT, LOCALE_ILDATE, out, 255 ); + winstr = TQString::fromUcs2( (ushort*)out ); + } , { + char out[255]; + GetLocaleInfoA( LOCALE_USER_DEFAULT, LOCALE_ILDATE, (char*)&out, 255 ); + winstr = TQString::fromLocal8Bit( out ); + } ); + switch ( winstr.toInt() ) { + case 1: + buf = d.shortDayName( d.dayOfWeek() ) + " " + TQString().setNum( d.day() ) + ". " + d.shortMonthName( d.month() ) + " "; + break; + default: + buf = d.shortDayName( d.dayOfWeek() ) + " " + d.shortMonthName( d.month() ) + " " + TQString().setNum( d.day() ) + " "; + break; + } +#endif + buf += t.toString(); + buf += ' '; + buf += TQString().setNum( d.year() ); + return buf; + } +#endif + else if ( f == TQt::LocalDate ) { + return d.toString( TQt::LocalDate ) + " " + t.toString( TQt::LocalDate ); + } + return TQString::null; +} +#endif + +/*! + Returns the datetime as a string. The \a format parameter + determines the format of the result string. + + These expressions may be used for the date: + + \table + \header \i Expression \i Output + \row \i d \i the day as number without a leading zero (1-31) + \row \i dd \i the day as number with a leading zero (01-31) + \row \i ddd + \i the abbreviated localized day name (e.g. 'Mon'..'Sun'). + Uses TQDate::shortDayName(). + \row \i dddd + \i the long localized day name (e.g. 'Monday'..'Sunday'). + Uses TQDate::longDayName(). + \row \i M \i the month as number without a leading zero (1-12) + \row \i MM \i the month as number with a leading zero (01-12) + \row \i MMM + \i the abbreviated localized month name (e.g. 'Jan'..'Dec'). + Uses TQDate::shortMonthName(). + \row \i MMMM + \i the long localized month name (e.g. 'January'..'December'). + Uses TQDate::longMonthName(). + \row \i yy \i the year as two digit number (00-99) + \row \i yyyy \i the year as four digit number (1752-8000) + \endtable + + These expressions may be used for the time: + + \table + \header \i Expression \i Output + \row \i h + \i the hour without a leading zero (0..23 or 1..12 if AM/PM display) + \row \i hh + \i the hour with a leading zero (00..23 or 01..12 if AM/PM display) + \row \i m \i the minute without a leading zero (0..59) + \row \i mm \i the minute with a leading zero (00..59) + \row \i s \i the second whithout a leading zero (0..59) + \row \i ss \i the second whith a leading zero (00..59) + \row \i z \i the milliseconds without leading zeroes (0..999) + \row \i zzz \i the milliseconds with leading zeroes (000..999) + \row \i AP + \i use AM/PM display. \e AP will be replaced by either "AM" or "PM". + \row \i ap + \i use am/pm display. \e ap will be replaced by either "am" or "pm". + \endtable + + All other input characters will be ignored. + + Example format strings (assumed that the TQDateTime is + 21st May 2001 14:13:09) + + \table + \header \i Format \i Result + \row \i dd.MM.yyyy \i11 21.05.2001 + \row \i ddd MMMM d yy \i11 Tue May 21 01 + \row \i hh:mm:ss.zzz \i11 14:13:09.042 + \row \i h:m:s ap \i11 2:13:9 pm + \endtable + + If the datetime is an invalid datetime, then TQString::null will be returned. + + \sa TQDate::toString() TQTime::toString() +*/ +TQString TQDateTime::toString( const TQString& format ) const +{ + return fmtDateTime( format, &t, &d ); +} +#endif //QT_NO_DATESTRING + +/*! + Returns a TQDateTime object containing a datetime \a ndays days + later than the datetime of this object (or earlier if \a ndays is + negative). + + \sa daysTo(), addMonths(), addYears(), addSecs() +*/ + +TQDateTime TQDateTime::addDays( int ndays ) const +{ + return TQDateTime( d.addDays(ndays), t ); +} + +/*! + Returns a TQDateTime object containing a datetime \a nmonths months + later than the datetime of this object (or earlier if \a nmonths + is negative). + + \sa daysTo(), addDays(), addYears(), addSecs() +*/ + +TQDateTime TQDateTime::addMonths( int nmonths ) const +{ + return TQDateTime( d.addMonths(nmonths), t ); +} + +/*! + Returns a TQDateTime object containing a datetime \a nyears years + later than the datetime of this object (or earlier if \a nyears is + negative). + + \sa daysTo(), addDays(), addMonths(), addSecs() +*/ + +TQDateTime TQDateTime::addYears( int nyears ) const +{ + return TQDateTime( d.addYears(nyears), t ); +} + +/*! + Returns a TQDateTime object containing a datetime \a nsecs seconds + later than the datetime of this object (or earlier if \a nsecs is + negative). + + \sa secsTo(), addDays(), addMonths(), addYears() +*/ + +TQDateTime TQDateTime::addSecs( int nsecs ) const +{ + uint dd = d.jd; + int tt = t.ds; + int sign = 1; + if ( nsecs < 0 ) { + nsecs = -nsecs; + sign = -1; + } + if ( nsecs >= (int)SECS_PER_DAY ) { + dd += sign*(nsecs/SECS_PER_DAY); + nsecs %= SECS_PER_DAY; + } + tt += sign*nsecs*1000; + if ( tt < 0 ) { + tt = MSECS_PER_DAY - tt - 1; + dd -= tt / MSECS_PER_DAY; + tt = tt % MSECS_PER_DAY; + tt = MSECS_PER_DAY - tt - 1; + } else if ( tt >= (int)MSECS_PER_DAY ) { + dd += ( tt / MSECS_PER_DAY ); + tt = tt % MSECS_PER_DAY; + } + TQDateTime ret; + ret.t.ds = tt; + ret.d.jd = dd; + return ret; +} + +/*! + Returns the number of days from this datetime to \a dt (which is + negative if \a dt is earlier than this datetime). + + \sa addDays(), secsTo() +*/ + +int TQDateTime::daysTo( const TQDateTime &dt ) const +{ + return d.daysTo( dt.d ); +} + +/*! + Returns the number of seconds from this datetime to \a dt (which + is negative if \a dt is earlier than this datetime). + + Example: + \code + TQDateTime dt = TQDateTime::currentDateTime(); + TQDateTime xmas( TQDate(dt.date().year(),12,24), TQTime(17,00) ); + qDebug( "There are %d seconds to Christmas", dt.secsTo(xmas) ); + \endcode + + \sa addSecs(), daysTo(), TQTime::secsTo() +*/ + +int TQDateTime::secsTo( const TQDateTime &dt ) const +{ + return t.secsTo(dt.t) + d.daysTo(dt.d)*SECS_PER_DAY; +} + + +/*! + Returns TRUE if this datetime is equal to \a dt; otherwise returns FALSE. + + \sa operator!=() +*/ + +bool TQDateTime::operator==( const TQDateTime &dt ) const +{ + return t == dt.t && d == dt.d; +} + +/*! + Returns TRUE if this datetime is different from \a dt; otherwise + returns FALSE. + + \sa operator==() +*/ + +bool TQDateTime::operator!=( const TQDateTime &dt ) const +{ + return t != dt.t || d != dt.d; +} + +/*! + Returns TRUE if this datetime is earlier than \a dt; otherwise + returns FALSE. +*/ + +bool TQDateTime::operator<( const TQDateTime &dt ) const +{ + if ( d < dt.d ) + return TRUE; + return d == dt.d ? t < dt.t : FALSE; +} + +/*! + Returns TRUE if this datetime is earlier than or equal to \a dt; + otherwise returns FALSE. +*/ + +bool TQDateTime::operator<=( const TQDateTime &dt ) const +{ + if ( d < dt.d ) + return TRUE; + return d == dt.d ? t <= dt.t : FALSE; +} + +/*! + Returns TRUE if this datetime is later than \a dt; otherwise + returns FALSE. +*/ + +bool TQDateTime::operator>( const TQDateTime &dt ) const +{ + if ( d > dt.d ) + return TRUE; + return d == dt.d ? t > dt.t : FALSE; +} + +/*! + Returns TRUE if this datetime is later than or equal to \a dt; + otherwise returns FALSE. +*/ + +bool TQDateTime::operator>=( const TQDateTime &dt ) const +{ + if ( d > dt.d ) + return TRUE; + return d == dt.d ? t >= dt.t : FALSE; +} + +/*! + \overload + + Returns the current datetime, as reported by the system clock. + + \sa TQDate::currentDate(), TQTime::currentTime() +*/ + +TQDateTime TQDateTime::currentDateTime() +{ + return currentDateTime( TQt::LocalTime ); +} + +/*! + Returns the current datetime, as reported by the system clock, for the + TimeSpec \a ts. The default TimeSpec is LocalTime. + + \sa TQDate::currentDate(), TQTime::currentTime(), TQt::TimeSpec +*/ + +TQDateTime TQDateTime::currentDateTime( TQt::TimeSpec ts ) +{ + TQDateTime dt; + TQTime t; + dt.setDate( TQDate::currentDate(ts) ); + if ( TQTime::currentTime(&t, ts) ) // midnight or right after? + dt.setDate( TQDate::currentDate(ts) ); // fetch date again + dt.setTime( t ); + return dt; +} + +#ifndef QT_NO_DATESTRING +/*! + Returns the TQDateTime represented by the string \a s, using the + format \a f, or an invalid datetime if this is not possible. + + Note for \c TQt::TextDate: It is recommended that you use the + English short month names (e.g. "Jan"). Although localized month + names can also be used, they depend on the user's locale settings. + + \warning Note that \c TQt::LocalDate cannot be used here. +*/ +TQDateTime TQDateTime::fromString( const TQString& s, TQt::DateFormat f ) +{ + if ( ( s.isEmpty() ) || ( f == TQt::LocalDate ) ) { +#if defined(QT_CHECK_RANGE) + qWarning( "TQDateTime::fromString: Parameter out of range" ); +#endif + TQDateTime dt; + dt.d.jd = 0; + return dt; + } + if ( f == TQt::ISODate ) { + return TQDateTime( TQDate::fromString( s.mid(0,10), TQt::ISODate ), + TQTime::fromString( s.mid(11), TQt::ISODate ) ); + } +#if !defined(QT_NO_REGEXP) && !defined(QT_NO_TEXTDATE) + else if ( f == TQt::TextDate ) { + const int firstSpace = s.find(' '); + TQString monthName( s.mid( firstSpace + 1, 3 ) ); + int month = -1; + // Assume that English monthnames are the default + for ( int i = 0; i < 12; ++i ) { + if ( monthName == qt_shortMonthNames[i] ) { + month = i + 1; + break; + } + } + // If English names can't be found, search the localized ones + if ( month == -1 ) { + for ( int i = 1; i <= 12; ++i ) { + if ( monthName == TQDate::shortMonthName( i ) ) { + month = i; + break; + } + } + } +#if defined(QT_CHECK_RANGE) + if ( month < 1 || month > 12 ) { + qWarning( "TQDateTime::fromString: Parameter out of range" ); + TQDateTime dt; + dt.d.jd = 0; + return dt; + } +#endif + int day = s.mid( firstSpace + 5, 2 ).simplifyWhiteSpace().toInt(); + int year = s.right( 4 ).toInt(); + TQDate date( year, month, day ); + TQTime time; + int hour, minute, second; + int pivot = s.find( TQRegExp(TQString::fromLatin1("[0-9][0-9]:[0-9][0-9]:[0-9][0-9]")) ); + if ( pivot != -1 ) { + hour = s.mid( pivot, 2 ).toInt(); + minute = s.mid( pivot+3, 2 ).toInt(); + second = s.mid( pivot+6, 2 ).toInt(); + time.setHMS( hour, minute, second ); + } + return TQDateTime( date, time ); + } +#endif //QT_NO_REGEXP + return TQDateTime(); +} +#endif //QT_NO_DATESTRING + + +/***************************************************************************** + Date/time stream functions + *****************************************************************************/ + +#ifndef QT_NO_DATASTREAM +/*! + \relates TQDate + + Writes the date, \a d, to the data stream, \a s. + + \sa \link datastreamformat.html Format of the TQDataStream operators \endlink +*/ + +TQDataStream &operator<<( TQDataStream &s, const TQDate &d ) +{ + return s << (Q_UINT32)(d.jd); +} + +/*! + \relates TQDate + + Reads a date from the stream \a s into \a d. + + \sa \link datastreamformat.html Format of the TQDataStream operators \endlink +*/ + +TQDataStream &operator>>( TQDataStream &s, TQDate &d ) +{ + Q_UINT32 jd; + s >> jd; + d.jd = jd; + return s; +} + +/*! + \relates TQTime + + Writes time \a t to the stream \a s. + + \sa \link datastreamformat.html Format of the TQDataStream operators \endlink +*/ + +TQDataStream &operator<<( TQDataStream &s, const TQTime &t ) +{ + return s << (Q_UINT32)(t.ds); +} + +/*! + \relates TQTime + + Reads a time from the stream \a s into \a t. + + \sa \link datastreamformat.html Format of the TQDataStream operators \endlink +*/ + +TQDataStream &operator>>( TQDataStream &s, TQTime &t ) +{ + Q_UINT32 ds; + s >> ds; + t.ds = ds; + return s; +} + +/*! + \relates TQDateTime + + Writes the datetime \a dt to the stream \a s. + + \sa \link datastreamformat.html Format of the TQDataStream operators \endlink +*/ + +TQDataStream &operator<<( TQDataStream &s, const TQDateTime &dt ) +{ + return s << dt.d << dt.t; +} + +/*! + \relates TQDateTime + + Reads a datetime from the stream \a s into \a dt. + + \sa \link datastreamformat.html Format of the TQDataStream operators \endlink +*/ + +TQDataStream &operator>>( TQDataStream &s, TQDateTime &dt ) +{ + s >> dt.d >> dt.t; + return s; +} +#endif //QT_NO_DATASTREAM diff --git a/src/tools/qdatetime.h b/src/tools/qdatetime.h new file mode 100644 index 000000000..4472159ea --- /dev/null +++ b/src/tools/qdatetime.h @@ -0,0 +1,253 @@ +/************************************************************************* +** +** Definition of date and time classes +** +** Created : 940124 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQDATETIME_H +#define TQDATETIME_H + +#ifndef QT_H +#include "qstring.h" +#include "qnamespace.h" +#endif // QT_H + + +/***************************************************************************** + TQDate class + *****************************************************************************/ + +class Q_EXPORT TQDate +{ +public: + TQDate() { jd = 0; } + TQDate( int y, int m, int d ); + + bool isNull() const { return jd == 0; } + bool isValid() const; + + int year() const; + int month() const; + int day() const; + int dayOfWeek() const; + int dayOfYear() const; + int daysInMonth() const; + int daysInYear() const; + int weekNumber( int *yearNum = 0 ) const; + +#ifndef QT_NO_TEXTDATE +#ifndef QT_NO_COMPAT + static TQString monthName( int month ) { return shortMonthName( month ); } + static TQString dayName( int weekday ) { return shortDayName( weekday ); } +#endif + static TQString shortMonthName( int month ); + static TQString shortDayName( int weekday ); + static TQString longMonthName( int month ); + static TQString longDayName( int weekday ); +#endif //QT_NO_TEXTDATE +#ifndef QT_NO_TEXTSTRING +#if !defined(QT_NO_SPRINTF) + TQString toString( TQt::DateFormat f = TQt::TextDate ) const; +#endif + TQString toString( const TQString& format ) const; +#endif + bool setYMD( int y, int m, int d ); + + TQDate addDays( int days ) const; + TQDate addMonths( int months ) const; + TQDate addYears( int years ) const; + int daysTo( const TQDate & ) const; + + bool operator==( const TQDate &d ) const { return jd == d.jd; } + bool operator!=( const TQDate &d ) const { return jd != d.jd; } + bool operator<( const TQDate &d ) const { return jd < d.jd; } + bool operator<=( const TQDate &d ) const { return jd <= d.jd; } + bool operator>( const TQDate &d ) const { return jd > d.jd; } + bool operator>=( const TQDate &d ) const { return jd >= d.jd; } + + static TQDate currentDate(); + static TQDate currentDate( TQt::TimeSpec ); +#ifndef QT_NO_DATESTRING + static TQDate fromString( const TQString& s, TQt::DateFormat f = TQt::TextDate ); +#endif + static bool isValid( int y, int m, int d ); + static bool leapYear( int year ); + + static uint gregorianToJulian( int y, int m, int d ); + static void julianToGregorian( uint jd, int &y, int &m, int &d ); +private: + uint jd; + friend class TQDateTime; +#ifndef QT_NO_DATASTREAM + friend Q_EXPORT TQDataStream &operator<<( TQDataStream &, const TQDate & ); + friend Q_EXPORT TQDataStream &operator>>( TQDataStream &, TQDate & ); +#endif +}; + + +/***************************************************************************** + TQTime class + *****************************************************************************/ + +class Q_EXPORT TQTime +{ +public: + TQTime() { ds=0; } // set null time + TQTime( int h, int m, int s=0, int ms=0 ); // set time + + bool isNull() const { return ds == 0; } + bool isValid() const; // valid time + + int hour() const; // 0..23 + int minute() const; // 0..59 + int second() const; // 0..59 + int msec() const; // 0..999 +#ifndef QT_NO_DATESTRING +#ifndef QT_NO_SPRINTF + TQString toString( TQt::DateFormat f = TQt::TextDate ) const; +#endif + TQString toString( const TQString& format ) const; +#endif + bool setHMS( int h, int m, int s, int ms=0 ); + + TQTime addSecs( int secs ) const; + int secsTo( const TQTime & ) const; + TQTime addMSecs( int ms ) const; + int msecsTo( const TQTime & ) const; + + bool operator==( const TQTime &d ) const { return ds == d.ds; } + bool operator!=( const TQTime &d ) const { return ds != d.ds; } + bool operator<( const TQTime &d ) const { return ds < d.ds; } + bool operator<=( const TQTime &d ) const { return ds <= d.ds; } + bool operator>( const TQTime &d ) const { return ds > d.ds; } + bool operator>=( const TQTime &d ) const { return ds >= d.ds; } + + static TQTime currentTime(); + static TQTime currentTime( TQt::TimeSpec ); +#ifndef QT_NO_DATESTRING + static TQTime fromString( const TQString& s, TQt::DateFormat f = TQt::TextDate ); +#endif + static bool isValid( int h, int m, int s, int ms=0 ); + + void start(); + int restart(); + int elapsed() const; + +private: + static bool currentTime( TQTime * ); + static bool currentTime( TQTime *, TQt::TimeSpec ); + + uint ds; + friend class TQDateTime; +#ifndef QT_NO_DATASTREAM + friend Q_EXPORT TQDataStream &operator<<( TQDataStream &, const TQTime & ); + friend Q_EXPORT TQDataStream &operator>>( TQDataStream &, TQTime & ); +#endif +}; + + +/***************************************************************************** + TQDateTime class + *****************************************************************************/ + +class Q_EXPORT TQDateTime +{ +public: + TQDateTime() {} // set null date and null time + TQDateTime( const TQDate & ); + TQDateTime( const TQDate &, const TQTime & ); + + bool isNull() const { return d.isNull() && t.isNull(); } + bool isValid() const { return d.isValid() && t.isValid(); } + + TQDate date() const { return d; } + TQTime time() const { return t; } + uint toTime_t() const; + void setDate( const TQDate &date ) { d = date; } + void setTime( const TQTime &time ) { t = time; } + void setTime_t( uint secsSince1Jan1970UTC ); + void setTime_t( uint secsSince1Jan1970UTC, TQt::TimeSpec ); +#ifndef QT_NO_DATESTRING +#ifndef QT_NO_SPRINTF + TQString toString( TQt::DateFormat f = TQt::TextDate ) const; +#endif + TQString toString( const TQString& format ) const; +#endif + TQDateTime addDays( int days ) const; + TQDateTime addMonths( int months ) const; + TQDateTime addYears( int years ) const; + TQDateTime addSecs( int secs ) const; + int daysTo( const TQDateTime & ) const; + int secsTo( const TQDateTime & ) const; + + bool operator==( const TQDateTime &dt ) const; + bool operator!=( const TQDateTime &dt ) const; + bool operator<( const TQDateTime &dt ) const; + bool operator<=( const TQDateTime &dt ) const; + bool operator>( const TQDateTime &dt ) const; + bool operator>=( const TQDateTime &dt ) const; + + static TQDateTime currentDateTime(); + static TQDateTime currentDateTime( TQt::TimeSpec ); +#ifndef QT_NO_DATESTRING + static TQDateTime fromString( const TQString& s, TQt::DateFormat f = TQt::TextDate ); +#endif +private: + TQDate d; + TQTime t; +#ifndef QT_NO_DATASTREAM + friend Q_EXPORT TQDataStream &operator<<( TQDataStream &, const TQDateTime &); + friend Q_EXPORT TQDataStream &operator>>( TQDataStream &, TQDateTime & ); +#endif +}; + + +/***************************************************************************** + Date and time stream functions + *****************************************************************************/ + +#ifndef QT_NO_DATASTREAM +Q_EXPORT TQDataStream &operator<<( TQDataStream &, const TQDate & ); +Q_EXPORT TQDataStream &operator>>( TQDataStream &, TQDate & ); +Q_EXPORT TQDataStream &operator<<( TQDataStream &, const TQTime & ); +Q_EXPORT TQDataStream &operator>>( TQDataStream &, TQTime & ); +Q_EXPORT TQDataStream &operator<<( TQDataStream &, const TQDateTime & ); +Q_EXPORT TQDataStream &operator>>( TQDataStream &, TQDateTime & ); +#endif // QT_NO_DATASTREAM + +#endif // TQDATETIME_H + diff --git a/src/tools/qdeepcopy.cpp b/src/tools/qdeepcopy.cpp new file mode 100644 index 000000000..e955fadce --- /dev/null +++ b/src/tools/qdeepcopy.cpp @@ -0,0 +1,168 @@ +/**************************************************************************** +** +** Implementation of TQDeepCopy class +** +** Created : 20020613 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the kernel module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "qdeepcopy.h" + +/*! + \class TQDeepCopy qdeepcopy.h + \brief The TQDeepCopy class is a template class which ensures that + implicitly shared and explicitly shared classes reference unique + data. + + \reentrant + + \ingroup tools + \ingroup shared + + Normally, shared copies reference the same data to optimize memory + use and for maximum speed. In the example below, \c s1, \c s2, \c + s3, \c s4 and \c s5 share data. + + \code + // all 5 strings share the same data + TQString s1 = "abcd"; + TQString s2 = s1; + TQString s3 = s2; + TQString s4 = s3; + TQString s5 = s2; + \endcode + + TQDeepCopy can be used several ways to ensure that an object + references unique, unshared data. In the example below, \c s1, \c + s2 and \c s5 share data, while neither \c s3 nor \c s4 share data. + \code + // s1, s2 and s5 share the same data, neither s3 nor s4 are shared + TQString s1 = "abcd"; + TQString s2 = s1; + TQDeepCopy s3 = s2; // s3 is a deep copy of s2 + TQString s4 = s3; // s4 is a deep copy of s3 + TQString s5 = s2; + \endcode + + In the example below, \c s1, \c s2 and \c s5 share data, and \c s3 + and \c s4 share data. + \code + // s1, s2 and s5 share the same data, s3 and s4 share the same data + TQString s1 = "abcd"; + TQString s2 = s1; + TQString s3 = TQDeepCopy( s2 ); // s3 is a deep copy of s2 + TQString s4 = s3; // s4 is a shallow copy of s3 + TQString s5 = s2; + \endcode + + TQDeepCopy can also provide safety in multithreaded applications + that use shared classes. In the example below, the variable \c + global_string is used safely since the data contained in \c + global_string is always a deep copy. This ensures that all threads + get a unique copy of the data, and that any assignments to \c + global_string will result in a deep copy. + + \code + TQDeepCopy global_string; // global string data + TQMutex global_mutex; // mutex to protext global_string + + ... + + void setGlobalString( const TQString &str ) + { + global_mutex.lock(); + global_string = str; // global_string is a deep copy of str + global_mutex.unlock(); + } + + ... + + void MyThread::run() + { + global_mutex.lock(); + TQString str = global_string; // str is a deep copy of global_string + global_mutex.unlock(); + + // process the string data + ... + + // update global_string + setGlobalString( str ); + } + \endcode + + \warning It is the application developer's responsibility to + protect the object shared across multiple threads. + + The examples above use TQString, which is an implicitly shared + class. The behavior of TQDeepCopy is the same when using explicitly + shared classes like TQByteArray. + + Currently, TQDeepCopy works with the following classes: + \list + \i TQMemArray (including subclasses like TQByteArray and TQCString) + \i TQMap + \i TQString + \i TQValueList (including subclasses like TQStringList and TQValueStack) + \i TQValueVector + \endlist + + \sa \link threads.html Thread Support in TQt \endlink +*/ + +/*! + \fn TQDeepCopy::TQDeepCopy() + + Constructs an empty instance of type \e T. +*/ + +/*! + \fn TQDeepCopy::TQDeepCopy( const T &t ) + + Constructs a deep copy of \a t. +*/ + +/*! + \fn TQDeepCopy& TQDeepCopy::operator=( const T &t ) + + Assigns a deep copy of \a t. +*/ + +/*! + \fn TQDeepCopy::operator T () + + Returns a deep copy of the encapsulated data. +*/ + diff --git a/src/tools/qdeepcopy.h b/src/tools/qdeepcopy.h new file mode 100644 index 000000000..c0553aa79 --- /dev/null +++ b/src/tools/qdeepcopy.h @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Definition of TQDeepCopy class +** +** Created : 20020613 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the kernel module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQDEEPCOPY_H +#define TQDEEPCOPY_H + +#ifndef QT_H +# include "qglobal.h" +#endif // QT_H + +template +class TQDeepCopy +{ +public: + inline TQDeepCopy() + { + } + + inline TQDeepCopy( const T &t ) + : deepcopy( t ) + { + deepcopy.detach(); + } + + inline TQDeepCopy &operator=( const T &t ) + { + deepcopy = t; + deepcopy.detach(); + return *this; + } + + inline operator T () + { + T tmp = deepcopy; + tmp.detach(); + return tmp; + } + +private: + T deepcopy; +}; + +#endif // TQDEEPCOPY_H diff --git a/src/tools/qdict.h b/src/tools/qdict.h new file mode 100644 index 000000000..695376329 --- /dev/null +++ b/src/tools/qdict.h @@ -0,0 +1,123 @@ +/**************************************************************************** +** +** Definition of TQDict template class +** +** Created : 920821 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQDICT_H +#define TQDICT_H + +#ifndef QT_H +#include "qgdict.h" +#endif // QT_H + +template +class TQDict +#ifdef Q_QDOC + : public TQPtrCollection +#else + : public TQGDict +#endif +{ +public: + TQDict( int size = 17, bool caseSensitive = TRUE ) + : TQGDict( size, StringKey, caseSensitive, FALSE ) { } + TQDict( const TQDict &d ) : TQGDict( d ) { } + ~TQDict() { clear(); } + TQDict &operator=(const TQDict &d) + { return (TQDict&)TQGDict::operator=(d); } + uint count() const { return TQGDict::count(); } + uint size() const { return TQGDict::size(); } + bool isEmpty() const { return TQGDict::count() == 0; } + + void insert( const TQString &k, const type *d ) + { TQGDict::look_string(k,(Item)d,1); } + void replace( const TQString &k, const type *d ) + { TQGDict::look_string(k,(Item)d,2); } + bool remove( const TQString &k ) { return TQGDict::remove_string(k); } + type *take( const TQString &k ) { return (type *)TQGDict::take_string(k); } + type *find( const TQString &k ) const + { return (type *)((TQGDict*)this)->TQGDict::look_string(k,0,0); } + type *operator[]( const TQString &k ) const + { return (type *)((TQGDict*)this)->TQGDict::look_string(k,0,0); } + + void clear() { TQGDict::clear(); } + void resize( uint n ) { TQGDict::resize(n); } + void statistics() const { TQGDict::statistics(); } + +#ifdef Q_QDOC +protected: + virtual TQDataStream& read( TQDataStream &, TQPtrCollection::Item & ); + virtual TQDataStream& write( TQDataStream &, TQPtrCollection::Item ) const; +#endif + +private: + void deleteItem( Item d ); +}; + +#if !defined(Q_BROKEN_TEMPLATE_SPECIALIZATION) +template<> inline void TQDict::deleteItem( Item ) +{ +} +#endif + +template inline void TQDict::deleteItem( TQPtrCollection::Item d ) +{ + if ( del_item ) delete (type *)d; +} + +template +class TQDictIterator : public TQGDictIterator +{ +public: + TQDictIterator(const TQDict &d) : TQGDictIterator((TQGDict &)d) { } + ~TQDictIterator() {} + uint count() const { return dict->count(); } + bool isEmpty() const { return dict->count() == 0; } + type *toFirst() { return (type *)TQGDictIterator::toFirst(); } + operator type *() const { return (type *)TQGDictIterator::get(); } + type *operator*() { return (type *)TQGDictIterator::get(); } + type *current() const { return (type *)TQGDictIterator::get(); } + TQString currentKey() const{ return TQGDictIterator::getKeyString(); } + type *operator()() { return (type *)TQGDictIterator::operator()(); } + type *operator++() { return (type *)TQGDictIterator::operator++(); } + type *operator+=(uint j) { return (type *)TQGDictIterator::operator+=(j); } +}; + +#define Q_DEFINED_QDICT +#include "qwinexport.h" +#endif // TQDICT_H diff --git a/src/tools/qdir.cpp b/src/tools/qdir.cpp new file mode 100644 index 000000000..7b9b20476 --- /dev/null +++ b/src/tools/qdir.cpp @@ -0,0 +1,1390 @@ +/**************************************************************************** +** +** Implementation of TQDir class +** +** Created : 950427 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "qplatformdefs.h" +#include "qdir.h" + +#ifndef QT_NO_DIR +#include +#include "qfileinfo.h" +#include "qregexp.h" +#include "qstringlist.h" +#include "qdeepcopy.h" +#include + +#if defined(Q_FS_FAT) && !defined(Q_OS_UNIX) +const bool CaseSensitiveFS = FALSE; +#else +const bool CaseSensitiveFS = TRUE; +#endif + + +/*! + \class TQDir + \reentrant + \brief The TQDir class provides access to directory structures and their contents in a platform-independent way. + + \ingroup io + \mainclass + + A TQDir is used to manipulate path names, access information + regarding paths and files, and manipulate the underlying file + system. + + A TQDir can point to a file using either a relative or an absolute + path. Absolute paths begin with the directory separator "/" + (optionally preceded by a drive specification under Windows). If + you always use "/" as a directory separator, TQt will translate + your paths to conform to the underlying operating system. Relative + file names begin with a directory name or a file name and specify + a path relative to the current directory. + + The "current" path refers to the application's working directory. + A TQDir's own path is set and retrieved with setPath() and path(). + + An example of an absolute path is the string "/tmp/quartz", a + relative path might look like "src/fatlib". You can use the + function isRelative() to check if a TQDir is using a relative or an + absolute file path. Call convertToAbs() to convert a relative TQDir + to an absolute one. For a simplified path use cleanDirPath(). To + obtain a path which has no symbolic links or redundant ".." + elements use canonicalPath(). The path can be set with setPath(), + and changed with cd() and cdUp(). + + TQDir provides several static functions, for example, setCurrent() + to set the application's working directory and currentDirPath() to + retrieve the application's working directory. Access to some + common paths is provided with the static functions, current(), + home() and root() which return TQDir objects or currentDirPath(), + homeDirPath() and rootDirPath() which return the path as a string. + If you want to know about your application's path use + \l{TQApplication::applicationDirPath()}. + + The number of entries in a directory is returned by count(). + Obtain a string list of the names of all the files and directories + in a directory with entryList(). If you prefer a list of TQFileInfo + pointers use entryInfoList(). Both these functions can apply a + name filter, an attributes filter (e.g. read-only, files not + directories, etc.), and a sort order. The filters and sort may be + set with calls to setNameFilter(), setFilter() and setSorting(). + They may also be specified in the entryList() and + entryInfoList()'s arguments. + + Create a new directory with mkdir(), rename a directory with + rename() and remove an existing directory with rmdir(). Remove a + file with remove(). You can interrogate a directory with exists(), + isReadable() and isRoot(). + + To get a path with a filename use filePath(), and to get a + directory name use dirName(); neither of these functions checks + for the existence of the file or directory. + + The list of root directories is provided by drives(); on Unix + systems this returns a list containing one root directory, "/"; on + Windows the list will usually contain "C:/", and possibly "D:/", + etc. + + It is easiest to work with "/" separators in TQt code. If you need + to present a path to the user or need a path in a form suitable + for a function in the underlying operating system use + convertSeparators(). + + Examples: + + See if a directory exists. + \code + TQDir d( "example" ); // "./example" + if ( !d.exists() ) + qWarning( "Cannot find the example directory" ); + \endcode + + Traversing directories and reading a file. + \code + TQDir d = TQDir::root(); // "/" + if ( !d.cd("tmp") ) { // "/tmp" + qWarning( "Cannot find the \"/tmp\" directory" ); + } else { + TQFile f( d.filePath("ex1.txt") ); // "/tmp/ex1.txt" + if ( !f.open(IO_ReadWrite) ) + qWarning( "Cannot create the file %s", f.name() ); + } + \endcode + + A program that lists all the files in the current directory + (excluding symbolic links), sorted by size, smallest first: + \code + #include + #include + + int main( int argc, char **argv ) + { + TQDir d; + d.setFilter( TQDir::Files | TQDir::Hidden | TQDir::NoSymLinks ); + d.setSorting( TQDir::Size | TQDir::Reversed ); + + const TQFileInfoList *list = d.entryInfoList(); + TQFileInfoListIterator it( *list ); + TQFileInfo *fi; + + printf( " Bytes Filename\n" ); + while ( (fi = it.current()) != 0 ) { + printf( "%10li %s\n", fi->size(), fi->fileName().latin1() ); + ++it; + } + return 0; + } + \endcode + + \sa TQApplication::applicationDirPath() +*/ + +/*! + Constructs a TQDir pointing to the current directory ("."). + + \sa currentDirPath() +*/ + +TQDir::TQDir() +{ + dPath = TQString::fromLatin1("."); + init(); +} + +/*! + Constructs a TQDir with path \a path, that filters its entries by + name using \a nameFilter and by attributes using \a filterSpec. It + also sorts the names using \a sortSpec. + + The default \a nameFilter is an empty string, which excludes + nothing; the default \a filterSpec is \c All, which also means + exclude nothing. The default \a sortSpec is \c Name|IgnoreCase, + i.e. sort by name case-insensitively. + + Example that lists all the files in "/tmp": + \code + TQDir d( "/tmp" ); + for ( int i = 0; i < d.count(); i++ ) + printf( "%s\n", d[i] ); + \endcode + + If \a path is "" or TQString::null, TQDir uses "." (the current + directory). If \a nameFilter is "" or TQString::null, TQDir uses the + name filter "*" (all files). + + Note that \a path need not exist. + + \sa exists(), setPath(), setNameFilter(), setFilter(), setSorting() +*/ + +TQDir::TQDir( const TQString &path, const TQString &nameFilter, + int sortSpec, int filterSpec ) +{ + init(); + dPath = cleanDirPath( path ); + if ( dPath.isEmpty() ) + dPath = TQString::fromLatin1("."); + nameFilt = nameFilter; + if ( nameFilt.isEmpty() ) + nameFilt = TQString::fromLatin1("*"); + filtS = (FilterSpec)filterSpec; + sortS = (SortSpec)sortSpec; +} + +/*! + Constructs a TQDir that is a copy of the directory \a d. + + \sa operator=() +*/ + +TQDir::TQDir( const TQDir &d ) +{ + dPath = d.dPath; + fList = 0; + fiList = 0; + nameFilt = d.nameFilt; + dirty = TRUE; + allDirs = d.allDirs; + filtS = d.filtS; + sortS = d.sortS; +} + +/*! + Refreshes the directory information. +*/ +void TQDir::refresh() const +{ + TQDir* that = (TQDir*) this; + that->dirty = TRUE; +} + +void TQDir::init() +{ + fList = 0; + fiList = 0; + nameFilt = TQString::fromLatin1("*"); + dirty = TRUE; + allDirs = FALSE; + filtS = All; + sortS = SortSpec(Name | IgnoreCase); +} + +/*! + Destroys the TQDir frees up its resources. +*/ + +TQDir::~TQDir() +{ + delete fList; + delete fiList; +} + + +/*! + Sets the path of the directory to \a path. The path is cleaned of + redundant ".", ".." and of multiple separators. No check is made + to ensure that a directory with this path exists. + + The path can be either absolute or relative. Absolute paths begin + with the directory separator "/" (optionally preceded by a drive + specification under Windows). Relative file names begin with a + directory name or a file name and specify a path relative to the + current directory. An example of an absolute path is the string + "/tmp/quartz", a relative path might look like "src/fatlib". + + \sa path(), absPath(), exists(), cleanDirPath(), dirName(), + absFilePath(), isRelative(), convertToAbs() +*/ + +void TQDir::setPath( const TQString &path ) +{ + dPath = cleanDirPath( path ); + if ( dPath.isEmpty() ) + dPath = TQString::fromLatin1("."); + dirty = TRUE; +} + +/*! + \fn TQString TQDir::path() const + + Returns the path, this may contain symbolic links, but never + contains redundant ".", ".." or multiple separators. + + The returned path can be either absolute or relative (see + setPath()). + + \sa setPath(), absPath(), exists(), cleanDirPath(), dirName(), + absFilePath(), convertSeparators() +*/ + +/*! + Returns the absolute path (a path that starts with "/" or with a + drive specification), which may contain symbolic links, but never + contains redundant ".", ".." or multiple separators. + + \sa setPath(), canonicalPath(), exists(), cleanDirPath(), + dirName(), absFilePath() +*/ + +TQString TQDir::absPath() const +{ + if ( TQDir::isRelativePath(dPath) ) { + TQString tmp = currentDirPath(); + if ( tmp.right(1) != TQString::fromLatin1("/") ) + tmp += '/'; + tmp += dPath; + return cleanDirPath( tmp ); + } else { + return cleanDirPath( dPath ); + } +} + +/*! + Returns the name of the directory; this is \e not the same as the + path, e.g. a directory with the name "mail", might have the path + "/var/spool/mail". If the directory has no name (e.g. it is the + root directory) TQString::null is returned. + + No check is made to ensure that a directory with this name + actually exists. + + \sa path(), absPath(), absFilePath(), exists(), TQString::isNull() +*/ + +TQString TQDir::dirName() const +{ + int pos = dPath.findRev( '/' ); + if ( pos == -1 ) + return dPath; + return dPath.right( dPath.length() - pos - 1 ); +} + +/*! + Returns the path name of a file in the directory. Does \e not + check if the file actually exists in the directory. If the TQDir is + relative the returned path name will also be relative. Redundant + multiple separators or "." and ".." directories in \a fileName + will not be removed (see cleanDirPath()). + + If \a acceptAbsPath is TRUE a \a fileName starting with a + separator "/" will be returned without change. If \a acceptAbsPath + is FALSE an absolute path will be prepended to the fileName and + the resultant string returned. + + \sa absFilePath(), isRelative(), canonicalPath() +*/ + +TQString TQDir::filePath( const TQString &fileName, + bool acceptAbsPath ) const +{ + if ( acceptAbsPath && !isRelativePath(fileName) ) + return TQString(fileName); + + TQString tmp = dPath; + if ( tmp.isEmpty() || (tmp[(int)tmp.length()-1] != '/' && !!fileName && + fileName[0] != '/') ) + tmp += '/'; + tmp += fileName; + return tmp; +} + +/*! + Returns the absolute path name of a file in the directory. Does \e + not check if the file actually exists in the directory. Redundant + multiple separators or "." and ".." directories in \a fileName + will not be removed (see cleanDirPath()). + + If \a acceptAbsPath is TRUE a \a fileName starting with a + separator "/" will be returned without change. If \a acceptAbsPath + is FALSE an absolute path will be prepended to the fileName and + the resultant string returned. + + \sa filePath() +*/ + +TQString TQDir::absFilePath( const TQString &fileName, + bool acceptAbsPath ) const +{ + if ( acceptAbsPath && !isRelativePath( fileName ) ) + return fileName; + + TQString tmp = absPath(); +#ifdef Q_OS_WIN32 + if ( fileName[0].isLetter() && fileName[1] == ':' ) { + int drv = fileName.upper()[0].latin1() - 'A' + 1; + if ( _getdrive() != drv ) { + QT_WA( { + TCHAR buf[PATH_MAX]; + ::_wgetdcwd( drv, buf, PATH_MAX ); + tmp.setUnicodeCodes( (ushort*)buf, (uint)::wcslen(buf) ); + }, { + char buf[PATH_MAX]; + ::_getdcwd( drv, buf, PATH_MAX ); + tmp = buf; + } ); + if ( !tmp.endsWith("\\") ) + tmp += "\\"; + tmp += fileName.right( fileName.length() - 2 ); + int x; + for ( x = 0; x < (int) tmp.length(); x++ ) { + if ( tmp[x] == '\\' ) + tmp[x] = '/'; + } + } + } else +#endif + { + if ( tmp.isEmpty() || (tmp[(int)tmp.length()-1] != '/' && !!fileName && + fileName[0] != '/') ) + tmp += '/'; + tmp += fileName; + } + return tmp; +} + + +/*! + Returns \a pathName with the '/' separators converted to + separators that are appropriate for the underlying operating + system. + + On Windows, convertSeparators("c:/winnt/system32") returns + "c:\winnt\system32". + + The returned string may be the same as the argument on some + operating systems, for example on Unix. +*/ + +TQString TQDir::convertSeparators( const TQString &pathName ) +{ + TQString n( pathName ); +#if defined(Q_FS_FAT) || defined(Q_OS_OS2EMX) + for ( int i=0; i<(int)n.length(); i++ ) { + if ( n[i] == '/' ) + n[i] = '\\'; + } +#elif defined(Q_OS_MAC9) + while(n.length() && n[0] == '/' ) n = n.right(n.length()-1); + for ( int i=0; i<(int)n.length(); i++ ) { + if ( n[i] == '/' ) + n[i] = ':'; + } + if(n.contains(':') && n.left(1) != ':') + n.prepend(':'); +#endif + return n; +} + + +/*! + Changes the TQDir's directory to \a dirName. + + If \a acceptAbsPath is TRUE a path starting with separator "/" + will cause the function to change to the absolute directory. If \a + acceptAbsPath is FALSE any number of separators at the beginning + of \a dirName will be removed and the function will descend into + \a dirName. + + Returns TRUE if the new directory exists and is readable; + otherwise returns FALSE. Note that the logical cd() operation is + not performed if the new directory does not exist. + + Calling cd( ".." ) is equivalent to calling cdUp(). + + \sa cdUp(), isReadable(), exists(), path() +*/ + +bool TQDir::cd( const TQString &dirName, bool acceptAbsPath ) +{ + if ( dirName.isEmpty() || dirName == TQString::fromLatin1(".") ) + return TRUE; + TQString old = dPath; + if ( acceptAbsPath && !isRelativePath(dirName) ) { + dPath = cleanDirPath( dirName ); + } else { + if ( isRoot() ) { + if ( dirName == ".." ) { + dPath = old; + return FALSE; + } + } else { + dPath += '/'; + } + + dPath += dirName; + if ( dirName.find('/') >= 0 + || old == TQString::fromLatin1(".") + || dirName == TQString::fromLatin1("..") ) { + dPath = cleanDirPath( dPath ); + + /* + If dPath starts with .., we convert it to absolute to + avoid infinite looping on + + TQDir dir( "." ); + while ( dir.cdUp() ) + ; + */ + if ( dPath[0] == TQChar('.') && dPath[1] == TQChar('.') && + (dPath.length() == 2 || dPath[2] == TQChar('/')) ) + convertToAbs(); + } + } + if ( !exists() ) { + dPath = old; // regret + return FALSE; + } + dirty = TRUE; + return TRUE; +} + +/*! + Changes directory by moving one directory up from the TQDir's + current directory. + + Returns TRUE if the new directory exists and is readable; + otherwise returns FALSE. Note that the logical cdUp() operation is + not performed if the new directory does not exist. + + \sa cd(), isReadable(), exists(), path() +*/ + +bool TQDir::cdUp() +{ + return cd( TQString::fromLatin1("..") ); +} + +/*! + \fn TQString TQDir::nameFilter() const + + Returns the string set by setNameFilter() +*/ + +/*! + Sets the name filter used by entryList() and entryInfoList() to \a + nameFilter. + + The \a nameFilter is a wildcard (globbing) filter that understands + "*" and "?" wildcards. (See \link qregexp.html#wildcard-matching + TQRegExp wildcard matching\endlink.) You may specify several filter + entries all separated by a single space " " or by a semi-colon + ";". + + For example, if you want entryList() and entryInfoList() to list + all files ending with either ".cpp" or ".h", you would use either + dir.setNameFilter("*.cpp *.h") or dir.setNameFilter("*.cpp;*.h"). + + \sa nameFilter(), setFilter() +*/ + +void TQDir::setNameFilter( const TQString &nameFilter ) +{ + nameFilt = nameFilter; + if ( nameFilt.isEmpty() ) + nameFilt = TQString::fromLatin1("*"); + dirty = TRUE; +} + +/*! + \fn TQDir::FilterSpec TQDir::filter() const + + Returns the value set by setFilter() +*/ + +/*! + \enum TQDir::FilterSpec + + This enum describes the filtering options available to TQDir, e.g. + for entryList() and entryInfoList(). The filter value is specified + by OR-ing together values from the following list: + + \value Dirs List directories only. + \value Files List files only. + \value Drives List disk drives (ignored under Unix). + \value NoSymLinks Do not list symbolic links (ignored by operating + systems that don't support symbolic links). + \value All List directories, files, drives and symlinks (this does not list + broken symlinks unless you specify System). + \value TypeMask A mask for the the Dirs, Files, Drives and + NoSymLinks flags. + \value Readable List files for which the application has read access. + \value Writable List files for which the application has write access. + \value Executable List files for which the application has execute + access. Executables needs to be combined with Dirs or Files. + \value RWEMask A mask for the Readable, Writable and Executable flags. + \value Modified Only list files that have been modified (ignored + under Unix). + \value Hidden List hidden files (on Unix, files starting with a .). + \value System List system files (on Unix, FIFOs, sockets and + device files) + \value AccessMask A mask for the Readable, Writable, Executable + Modified, Hidden and System flags + \value DefaultFilter Internal flag. + + If you do not set any of \c Readable, \c Writable or \c + Executable, TQDir will set all three of them. This makes the + default easy to write and at the same time useful. + + Examples: \c Readable|Writable means list all files for which the + application has read access, write access or both. \c Dirs|Drives + means list drives, directories, all files that the application can + read, write or execute, and also symlinks to such + files/directories. +*/ + + +/*! + Sets the filter used by entryList() and entryInfoList() to \a + filterSpec. The filter is used to specify the kind of files that + should be returned by entryList() and entryInfoList(). See + \l{TQDir::FilterSpec}. + + \sa filter(), setNameFilter() +*/ + +void TQDir::setFilter( int filterSpec ) +{ + if ( filtS == (FilterSpec) filterSpec ) + return; + filtS = (FilterSpec) filterSpec; + dirty = TRUE; +} + +/*! + \fn TQDir::SortSpec TQDir::sorting() const + + Returns the value set by setSorting() + + \sa setSorting() SortSpec +*/ + +/*! + \enum TQDir::SortSpec + + This enum describes the sort options available to TQDir, e.g. for + entryList() and entryInfoList(). The sort value is specified by + OR-ing together values from the following list: + + \value Name Sort by name. + \value Time Sort by time (modification time). + \value Size Sort by file size. + \value Unsorted Do not sort. + \value SortByMask A mask for Name, Time and Size. + + \value DirsFirst Put the directories first, then the files. + \value Reversed Reverse the sort order. + \value IgnoreCase Sort case-insensitively. + \value LocaleAware Sort names using locale aware compares + \value DefaultSort Internal flag. + + You can only specify one of the first four. + + If you specify both \c DirsFirst and \c Reversed, directories are + still put first, but in reverse order; the files will be listed + after the directories, again in reverse order. +*/ + +// ### Unsorted+DirsFirst ? Unsorted+Reversed? + +/*! + Sets the sort order used by entryList() and entryInfoList(). + + The \a sortSpec is specified by OR-ing values from the enum + \l{TQDir::SortSpec}. + + \sa sorting() SortSpec +*/ + +void TQDir::setSorting( int sortSpec ) +{ + if ( sortS == (SortSpec) sortSpec ) + return; + sortS = (SortSpec) sortSpec; + dirty = TRUE; +} + +/*! + \fn bool TQDir::matchAllDirs() const + + Returns the value set by setMatchAllDirs() + + \sa setMatchAllDirs() +*/ + +/*! + If \a enable is TRUE then all directories are included (e.g. in + entryList()), and the nameFilter() is only applied to the files. + If \a enable is FALSE then the nameFilter() is applied to both + directories and files. + + \sa matchAllDirs() +*/ + +void TQDir::setMatchAllDirs( bool enable ) +{ + if ( (bool)allDirs == enable ) + return; + allDirs = enable; + dirty = TRUE; +} + + +/*! + Returns the total number of directories and files that were found. + + Equivalent to entryList().count(). + + \sa operator[](), entryList() +*/ + +uint TQDir::count() const +{ + return (uint)entryList().count(); +} + +/*! + Returns the file name at position \a index in the list of file + names. Equivalent to entryList().at(index). + + Returns a TQString::null if the \a index is out of range or if the + entryList() function failed. + + \sa count(), entryList() +*/ + +TQString TQDir::operator[]( int index ) const +{ + entryList(); + return fList && index >= 0 && index < (int)fList->count() ? + (*fList)[index] : TQString::null; +} + + +/*! + \obsolete + This function is included to easy porting from TQt 1.x to TQt 2.0, + it is the same as entryList(), but encodes the filenames as 8-bit + strings using TQFile::encodedName(). + + It is more efficient to use entryList(). +*/ +TQStrList TQDir::encodedEntryList( int filterSpec, int sortSpec ) const +{ + TQStrList r; + TQStringList l = entryList(filterSpec,sortSpec); + for ( TQStringList::Iterator it = l.begin(); it != l.end(); ++it ) { + r.append( TQFile::encodeName(*it) ); + } + return r; +} + +/*! + \obsolete + \overload + This function is included to easy porting from TQt 1.x to TQt 2.0, + it is the same as entryList(), but encodes the filenames as 8-bit + strings using TQFile::encodedName(). + + It is more efficient to use entryList(). +*/ +TQStrList TQDir::encodedEntryList( const TQString &nameFilter, + int filterSpec, + int sortSpec ) const +{ + TQStrList r; + TQStringList l = entryList(nameFilter,filterSpec,sortSpec); + for ( TQStringList::Iterator it = l.begin(); it != l.end(); ++it ) { + r.append( TQFile::encodeName(*it) ); + } + return r; +} + + + +/*! + \overload + + Returns a list of the names of all the files and directories in + the directory, ordered in accordance with setSorting() and + filtered in accordance with setFilter() and setNameFilter(). + + The filter and sorting specifications can be overridden using the + \a filterSpec and \a sortSpec arguments. + + Returns an empty list if the directory is unreadable or does not + exist. + + \sa entryInfoList(), setNameFilter(), setSorting(), setFilter() +*/ + +TQStringList TQDir::entryList( int filterSpec, int sortSpec ) const +{ + if ( !dirty && filterSpec == (int)DefaultFilter && + sortSpec == (int)DefaultSort ) + return *fList; + return entryList( nameFilt, filterSpec, sortSpec ); +} + +/*! + Returns a list of the names of all the files and directories in + the directory, ordered in accordance with setSorting() and + filtered in accordance with setFilter() and setNameFilter(). + + The filter and sorting specifications can be overridden using the + \a nameFilter, \a filterSpec and \a sortSpec arguments. + + Returns an empty list if the directory is unreadable or does not + exist. + + \sa entryInfoList(), setNameFilter(), setSorting(), setFilter() +*/ + +TQStringList TQDir::entryList( const TQString &nameFilter, + int filterSpec, int sortSpec ) const +{ + if ( filterSpec == (int)DefaultFilter ) + filterSpec = filtS; + if ( sortSpec == (int)DefaultSort ) + sortSpec = sortS; + TQDir *that = (TQDir*)this; // mutable function + if ( that->readDirEntries(nameFilter, filterSpec, sortSpec) ) { + if ( that->fList ) + return *that->fList; + } + return TQStringList(); +} + +/*! + \overload + + Returns a list of TQFileInfo objects for all the files and + directories in the directory, ordered in accordance with + setSorting() and filtered in accordance with setFilter() and + setNameFilter(). + + The filter and sorting specifications can be overridden using the + \a filterSpec and \a sortSpec arguments. + + Returns 0 if the directory is unreadable or does not exist. + + The returned pointer is a const pointer to a TQFileInfoList. The + list is owned by the TQDir object and will be reused on the next + call to entryInfoList() for the same TQDir instance. If you want to + keep the entries of the list after a subsequent call to this + function you must copy them. + + Note: TQFileInfoList is really a TQPtrList. + + \sa entryList(), setNameFilter(), setSorting(), setFilter() +*/ + +const TQFileInfoList *TQDir::entryInfoList( int filterSpec, int sortSpec ) const +{ + if ( !dirty && filterSpec == (int)DefaultFilter && + sortSpec == (int)DefaultSort ) + return fiList; + return entryInfoList( nameFilt, filterSpec, sortSpec ); +} + +/*! + Returns a list of TQFileInfo objects for all the files and + directories in the directory, ordered in accordance with + setSorting() and filtered in accordance with setFilter() and + setNameFilter(). + + The filter and sorting specifications can be overridden using the + \a nameFilter, \a filterSpec and \a sortSpec arguments. + + Returns 0 if the directory is unreadable or does not exist. + + The returned pointer is a const pointer to a TQFileInfoList. The + list is owned by the TQDir object and will be reused on the next + call to entryInfoList() for the same TQDir instance. If you want to + keep the entries of the list after a subsequent call to this + function you must copy them. + + Note: TQFileInfoList is really a TQPtrList. + + \sa entryList(), setNameFilter(), setSorting(), setFilter() +*/ + +const TQFileInfoList *TQDir::entryInfoList( const TQString &nameFilter, + int filterSpec, int sortSpec ) const +{ + if ( filterSpec == (int)DefaultFilter ) + filterSpec = filtS; + if ( sortSpec == (int)DefaultSort ) + sortSpec = sortS; + TQDir *that = (TQDir*)this; // mutable function + if ( that->readDirEntries(nameFilter, filterSpec, sortSpec) ) + return that->fiList; + else + return 0; +} + +/*! + \overload + + Returns TRUE if the \e directory exists; otherwise returns FALSE. + (If a file with the same name is found this function will return + FALSE). + + \sa TQFileInfo::exists(), TQFile::exists() +*/ + +bool TQDir::exists() const +{ + TQFileInfo fi( dPath ); + return fi.exists() && fi.isDir(); +} + +/*! + Returns TRUE if the directory path is relative to the current + directory and returns FALSE if the path is absolute (e.g. under + UNIX a path is relative if it does not start with a "/"). + + \sa convertToAbs() +*/ + +bool TQDir::isRelative() const +{ + return isRelativePath( dPath ); +} + +/*! + Converts the directory path to an absolute path. If it is already + absolute nothing is done. + + \sa isRelative() +*/ + +void TQDir::convertToAbs() +{ + dPath = absPath(); +} + +/*! + Makes a copy of TQDir \a d and assigns it to this TQDir. +*/ + +TQDir &TQDir::operator=( const TQDir &d ) +{ + dPath = d.dPath; + delete fList; + fList = 0; + delete fiList; + fiList = 0; + nameFilt = d.nameFilt; + dirty = TRUE; + allDirs = d.allDirs; + filtS = d.filtS; + sortS = d.sortS; + return *this; +} + +/*! + \overload + + Sets the directory path to be the given \a path. +*/ + +TQDir &TQDir::operator=( const TQString &path ) +{ + dPath = cleanDirPath( path ); + dirty = TRUE; + return *this; +} + + +/*! + \fn bool TQDir::operator!=( const TQDir &d ) const + + Returns TRUE if directory \a d and this directory have different + paths or different sort or filter settings; otherwise returns + FALSE. + + Example: + \code + // The current directory is "/usr/local" + TQDir d1( "/usr/local/bin" ); + TQDir d2( "bin" ); + if ( d1 != d2 ) + qDebug( "They differ" ); + \endcode +*/ + +/*! + Returns TRUE if directory \a d and this directory have the same + path and their sort and filter settings are the same; otherwise + returns FALSE. + + Example: + \code + // The current directory is "/usr/local" + TQDir d1( "/usr/local/bin" ); + TQDir d2( "bin" ); + d2.convertToAbs(); + if ( d1 == d2 ) + qDebug( "They're the same" ); + \endcode +*/ + +bool TQDir::operator==( const TQDir &d ) const +{ + return dPath == d.dPath && + nameFilt == d.nameFilt && + allDirs == d.allDirs && + filtS == d.filtS && + sortS == d.sortS; +} + + +/*! + Removes the file, \a fileName. + + If \a acceptAbsPath is TRUE a path starting with separator "/" + will remove the file with the absolute path. If \a acceptAbsPath + is FALSE any number of separators at the beginning of \a fileName + will be removed and the resultant file name will be removed. + + Returns TRUE if the file is removed successfully; otherwise + returns FALSE. +*/ + +bool TQDir::remove( const TQString &fileName, bool acceptAbsPath ) +{ + if ( fileName.isEmpty() ) { +#if defined(QT_CHECK_NULL) + qWarning( "TQDir::remove: Empty or null file name" ); +#endif + return FALSE; + } + TQString p = filePath( fileName, acceptAbsPath ); + return TQFile::remove( p ); +} + +/*! + Checks for the existence of the file \a name. + + If \a acceptAbsPath is TRUE a path starting with separator "/" + will check the file with the absolute path. If \a acceptAbsPath is + FALSE any number of separators at the beginning of \a name will be + removed and the resultant file name will be checked. + + Returns TRUE if the file exists; otherwise returns FALSE. + + \sa TQFileInfo::exists(), TQFile::exists() +*/ + +bool TQDir::exists( const TQString &name, bool acceptAbsPath ) //### const in 4.0 +{ + if ( name.isEmpty() ) { +#if defined(QT_CHECK_NULL) + qWarning( "TQDir::exists: Empty or null file name" ); +#endif + return FALSE; + } + TQString tmp = filePath( name, acceptAbsPath ); + return TQFile::exists( tmp ); +} + +/*! + Returns the native directory separator; "/" under UNIX (including + Mac OS X) and "\" under Windows. + + You do not need to use this function to build file paths. If you + always use "/", TQt will translate your paths to conform to the + underlying operating system. +*/ + +char TQDir::separator() +{ +#if defined(Q_OS_UNIX) + return '/'; +#elif defined (Q_FS_FAT) || defined(Q_WS_WIN) + return '\\'; +#elif defined (Q_OS_MAC) + return ':'; +#else + return '/'; +#endif +} + +/*! + Returns the application's current directory. + + Use path() to access a TQDir object's path. + + \sa currentDirPath(), TQDir::TQDir() +*/ + +TQDir TQDir::current() +{ + return TQDir( currentDirPath() ); +} + +/*! + Returns the home directory. + + Under Windows the \c HOME environment variable is used. If this + does not exist the \c USERPROFILE environment variable is used. If + that does not exist the path is formed by concatenating the \c + HOMEDRIVE and \c HOMEPATH environment variables. If they don't + exist the rootDirPath() is used (this uses the \c SystemDrive + environment variable). If none of these exist "C:\" is used. + + Under non-Windows operating systems the \c HOME environment + variable is used if it exists, otherwise rootDirPath() is used. + + \sa homeDirPath() +*/ + +TQDir TQDir::home() +{ + return TQDir( homeDirPath() ); +} + +/*! + Returns the root directory. + + \sa rootDirPath() drives() +*/ + +TQDir TQDir::root() +{ + return TQDir( rootDirPath() ); +} + +/*! + \fn TQString TQDir::homeDirPath() + + Returns the absolute path of the user's home directory. + + \sa home() +*/ + +TQValueList qt_makeFilterList( const TQString &filter ) +{ + TQValueList regExps; + if ( filter.isEmpty() ) + return regExps; + + TQChar sep( ';' ); + int i = filter.find( sep, 0 ); + if ( i == -1 && filter.find( ' ', 0 ) != -1 ) + sep = TQChar( ' ' ); + + TQStringList list = TQStringList::split( sep, filter ); + TQStringList::Iterator it = list.begin(); + while ( it != list.end() ) { + regExps << TQRegExp( (*it).stripWhiteSpace(), CaseSensitiveFS, TRUE ); + ++it; + } + return regExps; +} + +bool qt_matchFilterList( const TQValueList& filters, + const TQString &fileName ) +{ + TQValueList::ConstIterator rit = filters.begin(); + while ( rit != filters.end() ) { + if ( (*rit).exactMatch(fileName) ) + return TRUE; + ++rit; + } + return FALSE; +} + + +/*! + \overload + + Returns TRUE if the \a fileName matches any of the wildcard (glob) + patterns in the list of \a filters; otherwise returns FALSE. + + (See \link qregexp.html#wildcard-matching TQRegExp wildcard + matching.\endlink) + \sa TQRegExp::match() +*/ + +bool TQDir::match( const TQStringList &filters, const TQString &fileName ) +{ + TQStringList::ConstIterator sit = filters.begin(); + while ( sit != filters.end() ) { + TQRegExp rx( *sit, CaseSensitiveFS, TRUE ); + if ( rx.exactMatch(fileName) ) + return TRUE; + ++sit; + } + return FALSE; +} + +/*! + Returns TRUE if the \a fileName matches the wildcard (glob) + pattern \a filter; otherwise returns FALSE. The \a filter may + contain multiple patterns separated by spaces or semicolons. + + (See \link qregexp.html#wildcard-matching TQRegExp wildcard + matching.\endlink) + \sa TQRegExp::match() +*/ + +bool TQDir::match( const TQString &filter, const TQString &fileName ) +{ + return qt_matchFilterList( qt_makeFilterList(filter), fileName ); +} + + +/*! + Removes all multiple directory separators "/" and resolves any + "."s or ".."s found in the path, \a filePath. + + Symbolic links are kept. This function does not return the + canonical path, but rather the simplest version of the input. + For example, "./local" becomes "local", "local/../bin" becomes + "bin" and "/local/usr/../bin" becomes "/local/bin". + + \sa absPath() canonicalPath() +*/ + +TQString TQDir::cleanDirPath( const TQString &filePath ) +{ + TQString name = filePath; + TQString newPath; + + if ( name.isEmpty() ) + return name; + + slashify( name ); + + bool addedSeparator = isRelativePath( name ); + if ( addedSeparator ) + name.insert( 0, '/' ); + + int ePos, pos, upLevel; + + pos = ePos = name.length(); + upLevel = 0; + int len; + + while ( pos && (pos = name.findRev('/', pos - 1)) != -1 ) { + len = ePos - pos - 1; + if ( len == 2 && name.at(pos + 1) == '.' + && name.at(pos + 2) == '.' ) { + upLevel++; + } else { + if ( len != 0 && (len != 1 || name.at(pos + 1) != '.') ) { + if ( !upLevel ) + newPath = TQString::fromLatin1("/") + + name.mid(pos + 1, len) + newPath; + else + upLevel--; + } + } + ePos = pos; + } + if ( addedSeparator ) { + while ( upLevel-- ) + newPath.insert( 0, TQString::fromLatin1("/..") ); + if ( !newPath.isEmpty() ) + newPath.remove( (uint)0, (uint)1 ); + else + newPath = TQString::fromLatin1("."); + } else { + if ( newPath.isEmpty() ) + newPath = TQString::fromLatin1("/"); +#if defined(Q_FS_FAT) || defined(Q_OS_OS2EMX) + if ( name[0] == '/' ) { + if ( name[1] == '/' ) // "\\machine\x\ ..." + newPath.insert( 0, '/' ); + } else { + newPath = name.left(2) + newPath; + } +#endif + } + return newPath; +} + +int qt_cmp_si_sortSpec; + +#if defined(Q_C_CALLBACKS) +extern "C" { +#endif + +#ifdef Q_OS_TEMP +int __cdecl qt_cmp_si( const void *n1, const void *n2 ) +#else +int qt_cmp_si( const void *n1, const void *n2 ) +#endif +{ + if ( !n1 || !n2 ) + return 0; + + TQDirSortItem* f1 = (TQDirSortItem*)n1; + TQDirSortItem* f2 = (TQDirSortItem*)n2; + + if ( qt_cmp_si_sortSpec & TQDir::DirsFirst ) + if ( f1->item->isDir() != f2->item->isDir() ) + return f1->item->isDir() ? -1 : 1; + + int r = 0; + int sortBy = qt_cmp_si_sortSpec & TQDir::SortByMask; + + switch ( sortBy ) { + case TQDir::Time: + r = f1->item->lastModified().secsTo(f2->item->lastModified()); + break; + case TQDir::Size: + r = f2->item->size() - f1->item->size(); + break; + default: + ; + } + + if ( r == 0 && sortBy != TQDir::Unsorted ) { + // Still not sorted - sort by name + bool ic = qt_cmp_si_sortSpec & TQDir::IgnoreCase; + + if ( f1->filename_cache.isNull() ) + f1->filename_cache = ic ? f1->item->fileName().lower() + : f1->item->fileName(); + if ( f2->filename_cache.isNull() ) + f2->filename_cache = ic ? f2->item->fileName().lower() + : f2->item->fileName(); + + r = qt_cmp_si_sortSpec & TQDir::LocaleAware + ? f1->filename_cache.localeAwareCompare(f2->filename_cache) + : f1->filename_cache.compare(f2->filename_cache); + } + + if ( r == 0 ) { + // Enforce an order - the order the items appear in the array + r = (char*)n1 - (char*)n2; + } + + if ( qt_cmp_si_sortSpec & TQDir::Reversed ) + return -r; + else + return r; +} + +#if defined(Q_C_CALLBACKS) +} +#endif + +/*! \internal + Detaches all internal data. +*/ +void TQDir::detach() +{ + // deepcopy + dPath = TQDeepCopy(dPath); + nameFilt = TQDeepCopy(nameFilt); + + if ( fList ) + *fList = TQDeepCopy( *fList ); + + if ( fiList ) { + TQFileInfoList *newlist = new TQFileInfoList( *fiList ); + delete fiList; + fiList = newlist; + } +} + +#endif // QT_NO_DIR diff --git a/src/tools/qdir.h b/src/tools/qdir.h new file mode 100644 index 000000000..7934bed93 --- /dev/null +++ b/src/tools/qdir.h @@ -0,0 +1,250 @@ +/**************************************************************************** +** +** Definition of TQDir class +** +** Created : 950427 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQDIR_H +#define TQDIR_H + +#ifndef QT_H +#include "qglobal.h" +#include "qstrlist.h" +#include "qfileinfo.h" +#endif // QT_H + + +#ifndef QT_NO_DIR +typedef TQPtrList TQFileInfoList; +typedef TQPtrListIterator TQFileInfoListIterator; +class TQStringList; +template class TQDeepCopy; + + +class Q_EXPORT TQDir +{ +public: + enum FilterSpec { Dirs = 0x001, + Files = 0x002, + Drives = 0x004, + NoSymLinks = 0x008, + All = 0x007, + TypeMask = 0x00F, + + Readable = 0x010, + Writable = 0x020, + Executable = 0x040, + RWEMask = 0x070, + + Modified = 0x080, + Hidden = 0x100, + System = 0x200, + AccessMask = 0x3F0, + + DefaultFilter = -1 }; + + enum SortSpec { Name = 0x00, + Time = 0x01, + Size = 0x02, + Unsorted = 0x03, + SortByMask = 0x03, + + DirsFirst = 0x04, + Reversed = 0x08, + IgnoreCase = 0x10, + LocaleAware = 0x20, + DefaultSort = -1 }; + + TQDir(); + TQDir( const TQString &path, const TQString &nameFilter = TQString::null, + int sortSpec = Name | IgnoreCase, int filterSpec = All ); + TQDir( const TQDir & ); + + virtual ~TQDir(); + + TQDir &operator=( const TQDir & ); + TQDir &operator=( const TQString &path ); + + virtual void setPath( const TQString &path ); + virtual TQString path() const; + virtual TQString absPath() const; + virtual TQString canonicalPath() const; + + virtual TQString dirName() const; + virtual TQString filePath( const TQString &fileName, + bool acceptAbsPath = TRUE ) const; + virtual TQString absFilePath( const TQString &fileName, + bool acceptAbsPath = TRUE ) const; + + static TQString convertSeparators( const TQString &pathName ); + + virtual bool cd( const TQString &dirName, bool acceptAbsPath = TRUE ); + virtual bool cdUp(); + + TQString nameFilter() const; + virtual void setNameFilter( const TQString &nameFilter ); + FilterSpec filter() const; + virtual void setFilter( int filterSpec ); + SortSpec sorting() const; + virtual void setSorting( int sortSpec ); + + bool matchAllDirs() const; + virtual void setMatchAllDirs( bool ); + + uint count() const; + TQString operator[]( int ) const; + + virtual TQStrList encodedEntryList( int filterSpec = DefaultFilter, + int sortSpec = DefaultSort ) const; + virtual TQStrList encodedEntryList( const TQString &nameFilter, + int filterSpec = DefaultFilter, + int sortSpec = DefaultSort ) const; + virtual TQStringList entryList( int filterSpec = DefaultFilter, + int sortSpec = DefaultSort ) const; + virtual TQStringList entryList( const TQString &nameFilter, + int filterSpec = DefaultFilter, + int sortSpec = DefaultSort ) const; + + virtual const TQFileInfoList *entryInfoList( int filterSpec = DefaultFilter, + int sortSpec = DefaultSort ) const; + virtual const TQFileInfoList *entryInfoList( const TQString &nameFilter, + int filterSpec = DefaultFilter, + int sortSpec = DefaultSort ) const; + + static const TQFileInfoList *drives(); + + virtual bool mkdir( const TQString &dirName, + bool acceptAbsPath = TRUE ) const; + virtual bool rmdir( const TQString &dirName, + bool acceptAbsPath = TRUE ) const; + + virtual bool isReadable() const; + virtual bool exists() const; + virtual bool isRoot() const; + + virtual bool isRelative() const; + virtual void convertToAbs(); + + virtual bool operator==( const TQDir & ) const; + virtual bool operator!=( const TQDir & ) const; + + virtual bool remove( const TQString &fileName, + bool acceptAbsPath = TRUE ); + virtual bool rename( const TQString &name, const TQString &newName, + bool acceptAbsPaths = TRUE ); + virtual bool exists( const TQString &name, + bool acceptAbsPath = TRUE ); + + static char separator(); + + static bool setCurrent( const TQString &path ); + static TQDir current(); + static TQDir home(); + static TQDir root(); + static TQString currentDirPath(); + static TQString homeDirPath(); + static TQString rootDirPath(); + + static bool match( const TQStringList &filters, const TQString &fileName ); + static bool match( const TQString &filter, const TQString &fileName ); + static TQString cleanDirPath( const TQString &dirPath ); + static bool isRelativePath( const TQString &path ); + void refresh() const; + +private: +#ifdef Q_OS_MAC + typedef struct FSSpec FSSpec; + static FSSpec *make_spec(const TQString &); +#endif + void init(); + virtual bool readDirEntries( const TQString &nameFilter, + int FilterSpec, int SortSpec ); + + static void slashify( TQString & ); + + TQString dPath; + TQStringList *fList; + TQFileInfoList *fiList; + TQString nameFilt; + FilterSpec filtS; + SortSpec sortS; + uint dirty : 1; + uint allDirs : 1; + + void detach(); + friend class TQDeepCopy< TQDir >; +}; + + +inline TQString TQDir::path() const +{ + return dPath; +} + +inline TQString TQDir::nameFilter() const +{ + return nameFilt; +} + +inline TQDir::FilterSpec TQDir::filter() const +{ + return filtS; +} + +inline TQDir::SortSpec TQDir::sorting() const +{ + return sortS; +} + +inline bool TQDir::matchAllDirs() const +{ + return allDirs; +} + +inline bool TQDir::operator!=( const TQDir &d ) const +{ + return !(*this == d); +} + + +struct TQDirSortItem { + TQString filename_cache; + TQFileInfo* item; +}; + +#endif // QT_NO_DIR +#endif // TQDIR_H diff --git a/src/tools/qdir_p.h b/src/tools/qdir_p.h new file mode 100644 index 000000000..8c8ad02f6 --- /dev/null +++ b/src/tools/qdir_p.h @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** Definition of some private TQDir functions. +** +** Created : 001106 +** +** Copyright (C) 2005-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQDIR_P_H +#define TQDIR_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the TQt API. It exists for the convenience +// of qdir.cpp and qdir_*.cpp. +// This header file may change from version to version without notice, +// or even be removed. +// +// We mean it. +// +// + +#ifndef QT_H +#include "qregexp.h" +#include "qvaluelist.h" +#endif // QT_H + +extern TQValueList qt_makeFilterList( const TQString & ); +extern bool qt_matchFilterList( const TQValueList &, const TQString & ); + +extern int qt_cmp_si_sortSpec; + +#if defined(Q_C_CALLBACKS) +extern "C" { +#endif + +#ifdef Q_OS_TEMP +extern int __cdecl qt_cmp_si( const void *, const void * ); +#else +extern int qt_cmp_si( const void *, const void * ); +#endif + +#if defined(Q_C_CALLBACKS) +} +#endif + + +#endif // TQDIR_P_H diff --git a/src/tools/qdir_unix.cpp b/src/tools/qdir_unix.cpp new file mode 100644 index 000000000..1d2ce60af --- /dev/null +++ b/src/tools/qdir_unix.cpp @@ -0,0 +1,325 @@ +/**************************************************************************** +** +** Implementation of TQDir class +** +** Created : 950628 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "qplatformdefs.h" +#include "qdir.h" + +#ifndef QT_NO_DIR + +#include "qdir_p.h" +#include "qfileinfo.h" +#include "qregexp.h" +#include "qstringlist.h" + +#ifdef QT_THREAD_SUPPORT +# include +#endif // QT_THREAD_SUPPORT + +#include +#include +#include + + +void TQDir::slashify( TQString& ) +{ +} + +TQString TQDir::homeDirPath() +{ + TQString d; + d = TQFile::decodeName(getenv("HOME")); + slashify( d ); + if ( d.isNull() ) + d = rootDirPath(); + return d; +} + +TQString TQDir::canonicalPath() const +{ + TQString r; +#if defined(__GLIBC__) && !defined(PATH_MAX) + char *cur = ::get_current_dir_name(); + if ( cur ) { + char *tmp = canonicalize_file_name( TQFile::encodeName( dPath ).data() ); + if ( tmp ) { + r = TQFile::decodeName( tmp ); + free( tmp ); + } + slashify( r ); + // always make sure we go back to the current dir + ::chdir( cur ); + free( cur ); + } +#else + char cur[PATH_MAX+1]; + if ( ::getcwd( cur, PATH_MAX ) ) { + char tmp[PATH_MAX+1]; + // need the cast for old solaris versions of realpath that doesn't take + // a const char*. + if( ::realpath( (char*)TQFile::encodeName( dPath ).data(), tmp ) ) + r = TQFile::decodeName( tmp ); + slashify( r ); + + // always make sure we go back to the current dir + ::chdir( cur ); + } +#endif /* __GLIBC__ && !PATH_MAX */ + return r; +} + +bool TQDir::mkdir( const TQString &dirName, bool acceptAbsPath ) const +{ +#if defined(Q_OS_MACX) // Mac X doesn't support trailing /'s + TQString name = dirName; + if (dirName[dirName.length() - 1] == "/") + name = dirName.left( dirName.length() - 1 ); + int status = + ::mkdir( TQFile::encodeName(filePath(name,acceptAbsPath)), 0777 ); +#else + int status = + ::mkdir( TQFile::encodeName(filePath(dirName,acceptAbsPath)), 0777 ); +#endif + return status == 0; +} + +bool TQDir::rmdir( const TQString &dirName, bool acceptAbsPath ) const +{ + return ::rmdir( TQFile::encodeName(filePath(dirName,acceptAbsPath)) ) == 0; +} + +bool TQDir::isReadable() const +{ + return ::access( TQFile::encodeName(dPath), R_OK | X_OK ) == 0; +} + +bool TQDir::isRoot() const +{ + return dPath == TQString::fromLatin1("/"); +} + +bool TQDir::rename( const TQString &name, const TQString &newName, + bool acceptAbsPaths ) +{ + if ( name.isEmpty() || newName.isEmpty() ) { +#if defined(QT_CHECK_NULL) + qWarning( "TQDir::rename: Empty or null file name(s)" ); +#endif + return FALSE; + } + TQString fn1 = filePath( name, acceptAbsPaths ); + TQString fn2 = filePath( newName, acceptAbsPaths ); + return ::rename( TQFile::encodeName(fn1), + TQFile::encodeName(fn2) ) == 0; +} + +bool TQDir::setCurrent( const TQString &path ) +{ + int r; + r = ::chdir( TQFile::encodeName(path) ); + return r >= 0; +} + +TQString TQDir::currentDirPath() +{ + TQString result; + + struct stat st; + if ( ::stat( ".", &st ) == 0 ) { +#if defined(__GLIBC__) && !defined(PATH_MAX) + char *currentName = ::get_current_dir_name(); + if ( currentName ) { + result = TQFile::decodeName(currentName); + free( currentName ); + } +#else + char currentName[PATH_MAX+1]; + if ( ::getcwd( currentName, PATH_MAX ) ) + result = TQFile::decodeName(currentName); +#endif /* __GLIBC__ && !PATH_MAX */ +#if defined(QT_DEBUG) + if ( result.isNull() ) + qWarning( "TQDir::currentDirPath: getcwd() failed" ); +#endif + } else { +#if defined(QT_DEBUG) + qWarning( "TQDir::currentDirPath: stat(\".\") failed" ); +#endif + } + slashify( result ); + return result; +} + +TQString TQDir::rootDirPath() +{ + TQString d = TQString::fromLatin1( "/" ); + return d; +} + +bool TQDir::isRelativePath( const TQString &path ) +{ + int len = path.length(); + if ( len == 0 ) + return TRUE; + return path[0] != '/'; +} + +bool TQDir::readDirEntries( const TQString &nameFilter, + int filterSpec, int sortSpec ) +{ + int i; + if ( !fList ) { + fList = new TQStringList; + Q_CHECK_PTR( fList ); + fiList = new TQFileInfoList; + Q_CHECK_PTR( fiList ); + fiList->setAutoDelete( TRUE ); + } else { + fList->clear(); + fiList->clear(); + } + + TQValueList filters = qt_makeFilterList( nameFilter ); + + bool doDirs = (filterSpec & Dirs) != 0; + bool doFiles = (filterSpec & Files) != 0; + bool noSymLinks = (filterSpec & NoSymLinks) != 0; + bool doReadable = (filterSpec & Readable) != 0; + bool doWritable = (filterSpec & Writable) != 0; + bool doExecable = (filterSpec & Executable) != 0; + bool doHidden = (filterSpec & Hidden) != 0; + bool doSystem = (filterSpec & System) != 0; + + TQFileInfo fi; + DIR *dir; + dirent *file; + + dir = opendir( TQFile::encodeName(dPath) ); + if ( !dir ) + return FALSE; // cannot read the directory + +#if defined(QT_THREAD_SUPPORT) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_CYGWIN) + union { + struct dirent mt_file; + char b[sizeof(struct dirent) + MAXNAMLEN + 1]; + } u; + while ( readdir_r(dir, &u.mt_file, &file ) == 0 && file ) +#else + while ( (file = readdir(dir)) ) +#endif // QT_THREAD_SUPPORT && _POSIX_THREAD_SAFE_FUNCTIONS + { + TQString fn = TQFile::decodeName(file->d_name); + fi.setFile( *this, fn ); + if ( !qt_matchFilterList(filters, fn) && !(allDirs && fi.isDir()) ) + continue; + if ( (doDirs && fi.isDir()) || (doFiles && fi.isFile()) || + (doSystem && (!fi.isFile() && !fi.isDir())) ) { + if ( noSymLinks && fi.isSymLink() ) + continue; + if ( (filterSpec & RWEMask) != 0 ) + if ( (doReadable && !fi.isReadable()) || + (doWritable && !fi.isWritable()) || + (doExecable && !fi.isExecutable()) ) + continue; + if ( !doHidden && fn[0] == '.' && + fn != TQString::fromLatin1(".") + && fn != TQString::fromLatin1("..") ) + continue; + fiList->append( new TQFileInfo( fi ) ); + } + } + if ( closedir(dir) != 0 ) { +#if defined(QT_CHECK_NULL) + qWarning( "TQDir::readDirEntries: Cannot close the directory: %s", + dPath.local8Bit().data() ); +#endif + } + + // Sort... + if(fiList->count()) { + TQDirSortItem* si= new TQDirSortItem[fiList->count()]; + TQFileInfo* itm; + i=0; + for (itm = fiList->first(); itm; itm = fiList->next()) + si[i++].item = itm; + qt_cmp_si_sortSpec = sortSpec; + qsort( si, i, sizeof(si[0]), qt_cmp_si ); + // put them back in the list + fiList->setAutoDelete( FALSE ); + fiList->clear(); + int j; + for ( j=0; jappend( si[j].item ); + fList->append( si[j].item->fileName() ); + } + delete [] si; + fiList->setAutoDelete( TRUE ); + } + + if ( filterSpec == (FilterSpec)filtS && sortSpec == (SortSpec)sortS && + nameFilter == nameFilt ) + dirty = FALSE; + else + dirty = TRUE; + return TRUE; +} + +const TQFileInfoList * TQDir::drives() +{ + // at most one instance of TQFileInfoList is leaked, and this variable + // points to that list + static TQFileInfoList * knownMemoryLeak = 0; + + if ( !knownMemoryLeak ) { + +#ifdef QT_THREAD_SUPPORT + TQMutexLocker locker( qt_global_mutexpool ? + qt_global_mutexpool->get( &knownMemoryLeak ) : 0 ); +#endif // QT_THREAD_SUPPORT + + if ( !knownMemoryLeak ) { + knownMemoryLeak = new TQFileInfoList; + // non-win32 versions both use just one root directory + knownMemoryLeak->append( new TQFileInfo( rootDirPath() ) ); + } + } + + return knownMemoryLeak; +} +#endif //QT_NO_DIR diff --git a/src/tools/qfeatures.h b/src/tools/qfeatures.h new file mode 100644 index 000000000..6e0a38182 --- /dev/null +++ b/src/tools/qfeatures.h @@ -0,0 +1,994 @@ +// All feature and their dependencies +// +// This list is generated from $QTDIR/src/tools/qfeatures.txt +// +// Asynchronous I/O +//#define QT_NO_ASYNC_IO + +// Bezier curves +//#define QT_NO_BEZIER + +// Buttons +//#define QT_NO_BUTTON + +// Named colors +//#define QT_NO_COLORNAMES + +// Cursors +//#define QT_NO_CURSOR + +// TQDataStream +//#define QT_NO_DATASTREAM + +// TQDate/TQTime/TQDateTime toString() and fromString() +//#define QT_NO_DATESTRING + +// Dialogs +//#define QT_NO_DIALOG + +// TQDirectPainter +//#define QT_NO_DIRECTPAINTER + +// Special widget effects (fading, scrolling) +//#define QT_NO_EFFECTS + +// Freetype font engine +//#define QT_NO_FREETYPE + +// Dither TQImage to 1-bit image +//#define QT_NO_IMAGE_DITHER_TO_1 + +// TQImage::createHeuristicMask() +//#define QT_NO_IMAGE_HEURISTIC_MASK + +// TQImage mirroring +//#define QT_NO_IMAGE_MIRROR + +// Smooth TQImage scaling +//#define QT_NO_IMAGE_SMOOTHSCALE + +// TrueColor TQImage +//#define QT_NO_IMAGE_TRUECOLOR + +// Automatic widget layout +//#define QT_NO_LAYOUT + +// Networking +//#define QT_NO_NETWORK + +// Palettes +//#define QT_NO_PALETTE + +// Alpha-blended cursor +//#define QT_NO_QWS_ALPHA_CURSOR + +// 1-bit monochrome +//#define QT_NO_QWS_DEPTH_1 + +// 15 or 16-bit color +//#define QT_NO_QWS_DEPTH_16 + +// 24-bit color +//#define QT_NO_QWS_DEPTH_24 + +// 32-bit color +//#define QT_NO_QWS_DEPTH_32 + +// 4-bit grayscale +//#define QT_NO_QWS_DEPTH_4 + +// 8-bit color +//#define QT_NO_QWS_DEPTH_8 + +// 8-bit grayscale +//#define QT_NO_QWS_DEPTH_8GRAYSCALE + +// Favour code size over graphics speed +//#define QT_NO_QWS_GFX_SPEED + +// Console keyboard +//#define QT_NO_QWS_KEYBOARD + +// Linux framebuffer +//#define QT_NO_QWS_LINUXFB + +// Mach64 acceleration +//#define QT_NO_QWS_MACH64 + +// Window Manager +//#define QT_NO_QWS_MANAGER + +// Matrox MGA acceleration +//#define QT_NO_QWS_MATROX + +// Autodetecting mouse driver +//#define QT_NO_QWS_MOUSE_AUTO + +// Non-autodetecting mouse driver +//#define QT_NO_QWS_MOUSE_MANUAL + +// TQt/Embedded window system properties. +//#define QT_NO_QWS_PROPERTIES + +// Repeater display +//#define QT_NO_QWS_REPEATER + +// Saving of fonts +//#define QT_NO_QWS_SAVEFONTS + +// Shadow frame buffer +//#define QT_NO_QWS_SHADOWFB + +// Virtual frame buffer +//#define QT_NO_QWS_VFB + +// 4-bit VGA +//#define QT_NO_QWS_VGA_16 + +// Voodoo3 acceleration +//#define QT_NO_QWS_VOODOO3 + +// Range-control widgets +//#define QT_NO_RANGECONTROL + +// Regular expression capture +//#define QT_NO_REGEXP + +// TQSignalMapper +//#define QT_NO_SIGNALMAPPER + +// Playing sounds +//#define QT_NO_SOUND + +// Standard template library compatiblity +//#define QT_NO_STL + +// TQStringList +//#define QT_NO_STRINGLIST + +// Character set conversions +//#define QT_NO_TEXTCODEC + +// TQTextStream +//#define QT_NO_TEXTSTREAM + +// Unicode property tables +//#define QT_NO_UNICODETABLES + +// Input validators +//#define QT_NO_VALIDATOR + +// TQVariant +//#define QT_NO_VARIANT + +// Wheel-mouse events +//#define QT_NO_WHEELEVENT + +// TQWMatrix +//#define QT_NO_WMATRIX + +// Non-Unicode text conversions +#if !defined(QT_NO_CODECS) && (defined(QT_NO_TEXTCODEC)) +#define QT_NO_CODECS +#endif + +// TQCop IPC +#if !defined(QT_NO_COP) && (defined(QT_NO_DATASTREAM)) +#define QT_NO_COP +#endif + +// TQFontDatabase +#if !defined(QT_NO_FONTDATABASE) && (defined(QT_NO_STRINGLIST)) +#define QT_NO_FONTDATABASE +#endif + +// Image formats +#if !defined(QT_NO_IMAGEIO) && (defined(QT_NO_REGEXP)) +#define QT_NO_IMAGEIO +#endif + +// 16-bit TQImage +#if !defined(QT_NO_IMAGE_16_BIT) && (defined(QT_NO_IMAGE_TRUECOLOR)) +#define QT_NO_IMAGE_16_BIT +#endif + +// Image file text strings +#if !defined(QT_NO_IMAGE_TEXT) && (defined(QT_NO_STRINGLIST)) +#define QT_NO_IMAGE_TEXT +#endif + +// Shared library wrapper +#if !defined(QT_NO_LIBRARY) && (defined(QT_NO_REGEXP)) +#define QT_NO_LIBRARY +#endif + +// Pixmap transformations +#if !defined(QT_NO_PIXMAP_TRANSFORMATION) && (defined(QT_NO_WMATRIX)) +#define QT_NO_PIXMAP_TRANSFORMATION +#endif + +// Convert UUID to/from string +#if !defined(QT_NO_QUUID_STRING) && (defined(QT_NO_STRINGLIST)) +#define QT_NO_QUUID_STRING +#endif + +// The "BeOS" style +#if !defined(QT_NO_QWS_BEOS_WM_STYLE) && (defined(QT_NO_QWS_MANAGER)) +#define QT_NO_QWS_BEOS_WM_STYLE +#endif + +// Visible cursor +#if !defined(QT_NO_QWS_CURSOR) && (defined(QT_NO_CURSOR)) +#define QT_NO_QWS_CURSOR +#endif + +// 32-bit color, BGR order +#if !defined(QT_NO_QWS_DEPTH_32_BGR) && (defined(QT_NO_QWS_DEPTH_32)) +#define QT_NO_QWS_DEPTH_32_BGR +#endif + +// The "Hydro" style +#if !defined(QT_NO_QWS_HYDRO_WM_STYLE) && (defined(QT_NO_QWS_MANAGER)) +#define QT_NO_QWS_HYDRO_WM_STYLE +#endif + +// Keyboard for SHARP Zaurus SL5xxx devices +#if !defined(QT_NO_QWS_KBD_SHARP) && (defined(QT_NO_QWS_KEYBOARD)) +#define QT_NO_QWS_KBD_SHARP +#endif + +// The "KDE2" style +#if !defined(QT_NO_QWS_KDE2_WM_STYLE) && (defined(QT_NO_QWS_MANAGER)) +#define QT_NO_QWS_KDE2_WM_STYLE +#endif + +// The "KDE" style +#if !defined(QT_NO_QWS_KDE_WM_STYLE) && (defined(QT_NO_QWS_MANAGER)) +#define QT_NO_QWS_KDE_WM_STYLE +#endif + +// Multi-process architecture +#if !defined(QT_NO_QWS_MULTIPROCESS) && (defined(QT_NO_NETWORK)) +#define QT_NO_QWS_MULTIPROCESS +#endif + +// Transformed frame buffer +#if !defined(QT_NO_QWS_TRANSFORMED) && (defined(QT_NO_QWS_LINUXFB)) +#define QT_NO_QWS_TRANSFORMED +#endif + +// Remote frame buffer (VNC) +#if !defined(QT_NO_QWS_VNC) && (defined(QT_NO_NETWORK)) +#define QT_NO_QWS_VNC +#endif + +// The "Windows" style +#if !defined(QT_NO_QWS_WINDOWS_WM_STYLE) && (defined(QT_NO_QWS_MANAGER)) +#define QT_NO_QWS_WINDOWS_WM_STYLE +#endif + +// Regular expression anchors +#if !defined(QT_NO_REGEXP_ANCHOR_ALT) && (defined(QT_NO_REGEXP)) +#define QT_NO_REGEXP_ANCHOR_ALT +#endif + +// Regular expression back-reference +#if !defined(QT_NO_REGEXP_BACKREF) && (defined(QT_NO_REGEXP)) +#define QT_NO_REGEXP_BACKREF +#endif + +// Regular expression character-class +#if !defined(QT_NO_REGEXP_CCLASS) && (defined(QT_NO_REGEXP)) +#define QT_NO_REGEXP_CCLASS +#endif + +// Regular expression escape +#if !defined(QT_NO_REGEXP_ESCAPE) && (defined(QT_NO_REGEXP)) +#define QT_NO_REGEXP_ESCAPE +#endif + +// Regular expression interval +#if !defined(QT_NO_REGEXP_INTERVAL) && (defined(QT_NO_REGEXP)) +#define QT_NO_REGEXP_INTERVAL +#endif + +// Regular expression lookahead +#if !defined(QT_NO_REGEXP_LOOKAHEAD) && (defined(QT_NO_REGEXP)) +#define QT_NO_REGEXP_LOOKAHEAD +#endif + +// Regular expression optimization +#if !defined(QT_NO_REGEXP_OPTIM) && (defined(QT_NO_REGEXP)) +#define QT_NO_REGEXP_OPTIM +#endif + +// Regular expression wildcard +#if !defined(QT_NO_REGEXP_WILDCARD) && (defined(QT_NO_REGEXP)) +#define QT_NO_REGEXP_WILDCARD +#endif + +// Semi-modal dialogs +#if !defined(QT_NO_SEMIMODAL) && (defined(QT_NO_DIALOG)) +#define QT_NO_SEMIMODAL +#endif + +// Session management +#if !defined(QT_NO_SESSIONMANAGER) && (defined(QT_NO_STRINGLIST)) +#define QT_NO_SESSIONMANAGER +#endif + +// TQString::sprintf() +#if !defined(QT_NO_SPRINTF) && (defined(QT_NO_REGEXP)) +#define QT_NO_SPRINTF +#endif + +// Scaling and rotation +#if !defined(QT_NO_TRANSFORMATIONS) && (defined(QT_NO_WMATRIX)) +#define QT_NO_TRANSFORMATIONS +#endif + +// Translations via TQObject::tr() +#if !defined(QT_NO_TRANSLATION) && (defined(QT_NO_DATASTREAM)) +#define QT_NO_TRANSLATION +#endif + +// Window icon and caption +#if !defined(QT_NO_WIDGET_TOPEXTRA) && (defined(QT_NO_IMAGE_HEURISTIC_MASK)) +#define QT_NO_WIDGET_TOPEXTRA +#endif + +// Keyboard accelerators and shortcuts +#if !defined(QT_NO_ACCEL) && (defined(QT_NO_SPRINTF)) +#define QT_NO_ACCEL +#endif + +// Asynchronous image I/O +#if !defined(QT_NO_ASYNC_IMAGE_IO) && (defined(QT_NO_IMAGEIO)) +#define QT_NO_ASYNC_IMAGE_IO +#endif + +// BDF font files +#if !defined(QT_NO_BDF) && (defined(QT_NO_TEXTSTREAM) || defined(QT_NO_STRINGLIST)) +#define QT_NO_BDF +#endif + +// TQDir +#if !defined(QT_NO_DIR) && (defined(QT_NO_STRINGLIST) || defined(QT_NO_REGEXP)) +#define QT_NO_DIR +#endif + +// JPEG image I/O +#if !defined(QT_NO_IMAGEIO_JPEG) && (defined(QT_NO_IMAGEIO)) +#define QT_NO_IMAGEIO_JPEG +#endif + +// MNG image I/O +#if !defined(QT_NO_IMAGEIO_MNG) && (defined(QT_NO_IMAGEIO)) +#define QT_NO_IMAGEIO_MNG +#endif + +// PNG image I/O +#if !defined(QT_NO_IMAGEIO_PNG) && (defined(QT_NO_IMAGEIO)) +#define QT_NO_IMAGEIO_PNG +#endif + +// PPM image I/O +#if !defined(QT_NO_IMAGEIO_PPM) && (defined(QT_NO_IMAGEIO)) +#define QT_NO_IMAGEIO_PPM +#endif + +// XBM image I/O +#if !defined(QT_NO_IMAGEIO_XBM) && (defined(QT_NO_IMAGEIO)) +#define QT_NO_IMAGEIO_XBM +#endif + +// Image transformations +#if !defined(QT_NO_IMAGE_TRANSFORMATION) && (defined(QT_NO_PIXMAP_TRANSFORMATION)) +#define QT_NO_IMAGE_TRANSFORMATION +#endif + +// External process invocation. +#if !defined(QT_NO_PROCESS) && (defined(QT_NO_STRINGLIST) || defined(QT_NO_REGEXP)) +#define QT_NO_PROCESS +#endif + +// Regular expression capture +#if !defined(QT_NO_REGEXP_CAPTURE) && (defined(QT_NO_REGEXP) || defined(QT_NO_STRINGLIST)) +#define QT_NO_REGEXP_CAPTURE +#endif + +// Splash screen widget +#if !defined(QT_NO_SPLASHSCREEN) && (defined(QT_NO_IMAGEIO)) +#define QT_NO_SPLASHSCREEN +#endif + +// Template classes in TQVariant +#if !defined(QT_NO_TEMPLATE_VARIANT) && (defined(QT_NO_VARIANT) || defined(QT_NO_STRINGLIST)) +#define QT_NO_TEMPLATE_VARIANT +#endif + +// Month and day names in dates +#if !defined(QT_NO_TEXTDATE) && (defined(QT_NO_STRINGLIST) || defined(QT_NO_DATESTRING)) +#define QT_NO_TEXTDATE +#endif + +// Drawing utility functions +#if !defined(QT_NO_DRAWUTIL) && (defined(QT_NO_SPRINTF) || defined(QT_NO_PALETTE)) +#define QT_NO_DRAWUTIL +#endif + +// BMP image I/O +#if !defined(QT_NO_IMAGEIO_BMP) && (defined(QT_NO_IMAGEIO) || defined(QT_NO_DATASTREAM)) +#define QT_NO_IMAGEIO_BMP +#endif + +// TQPicture +#if !defined(QT_NO_PICTURE) && (defined(QT_NO_DATASTREAM) || defined(QT_NO_IMAGEIO)) +#define QT_NO_PICTURE +#endif + +// Translations via TQObject::trUtf8() +#if !defined(QT_NO_TRANSLATION_UTF8) && (defined(QT_NO_TRANSLATION) || defined(QT_NO_TEXTCODEC)) +#define QT_NO_TRANSLATION_UTF8 +#endif + +// URL parser +#if !defined(QT_NO_URL) && (defined(QT_NO_DIR)) +#define QT_NO_URL +#endif + +// Animated images +#if !defined(QT_NO_MOVIE) && (defined(QT_NO_ASYNC_IO) || defined(QT_NO_ASYNC_IMAGE_IO)) +#define QT_NO_MOVIE +#endif + +// TQStyle +#if !defined(QT_NO_STYLE) && (defined(QT_NO_DRAWUTIL)) +#define QT_NO_STYLE +#endif + +// DNS +#if !defined(QT_NO_DNS) && (defined(QT_NO_NETWORK) || defined(QT_NO_STRINGLIST) || defined(QT_NO_TEXTSTREAM) || defined(QT_NO_SPRINTF)) +#define QT_NO_DNS +#endif + +// Framed widgets +#if !defined(QT_NO_FRAME) && (defined(QT_NO_STYLE)) +#define QT_NO_FRAME +#endif + +// TQIconSet +#if !defined(QT_NO_ICONSET) && (defined(QT_NO_IMAGEIO) || defined(QT_NO_IMAGE_SMOOTHSCALE) || defined(QT_NO_PALETTE) || defined(QT_NO_IMAGE_HEURISTIC_MASK)) +#define QT_NO_ICONSET +#endif + +// XPM image I/O +#if !defined(QT_NO_IMAGEIO_XPM) && (defined(QT_NO_IMAGEIO) || defined(QT_NO_SPRINTF) || defined(QT_NO_TEXTSTREAM)) +#define QT_NO_IMAGEIO_XPM +#endif + +// Network file access +#if !defined(QT_NO_NETWORKPROTOCOL) && (defined(QT_NO_TEXTCODEC) || defined(QT_NO_URL)) +#define QT_NO_NETWORKPROTOCOL +#endif + +// TQSizeGrip +#if !defined(QT_NO_SIZEGRIP) && (defined(QT_NO_STYLE)) +#define QT_NO_SIZEGRIP +#endif + +// Motif style +#if !defined(QT_NO_STYLE_MOTIF) && (defined(QT_NO_STYLE)) +#define QT_NO_STYLE_MOTIF +#endif + +// Windows style +#if !defined(QT_NO_STYLE_WINDOWS) && (defined(QT_NO_STYLE)) +#define QT_NO_STYLE_WINDOWS +#endif + +// Internal titlebar widget +#if !defined(QT_NO_TITLEBAR) && (defined(QT_NO_STYLE)) +#define QT_NO_TITLEBAR +#endif + +// XML +#if !defined(QT_NO_XML) && (defined(QT_NO_TEXTSTREAM) || defined(QT_NO_TEXTCODEC) || defined(QT_NO_REGEXP_CAPTURE)) +#define QT_NO_XML +#endif + +// Check-boxes +#if !defined(QT_NO_CHECKBOX) && (defined(QT_NO_BUTTON) || defined(QT_NO_STYLE)) +#define QT_NO_CHECKBOX +#endif + +// Dials +#if !defined(QT_NO_DIAL) && (defined(QT_NO_RANGECONTROL) || defined(QT_NO_STYLE)) +#define QT_NO_DIAL +#endif + +// TQLabel +#if !defined(QT_NO_LABEL) && (defined(QT_NO_FRAME)) +#define QT_NO_LABEL +#endif + +// TQLCDNumber +#if !defined(QT_NO_LCDNUMBER) && (defined(QT_NO_FRAME)) +#define QT_NO_LCDNUMBER +#endif + +// Single-line edits +#if !defined(QT_NO_LINEEDIT) && (defined(QT_NO_FRAME)) +#define QT_NO_LINEEDIT +#endif + +// MIME +#if !defined(QT_NO_MIME) && (defined(QT_NO_DIR) || defined(QT_NO_IMAGEIO) || defined(QT_NO_TEXTCODEC)) +#define QT_NO_MIME +#endif + +// Progress bars +#if !defined(QT_NO_PROGRESSBAR) && (defined(QT_NO_FRAME)) +#define QT_NO_PROGRESSBAR +#endif + +// Push-buttons +#if !defined(QT_NO_PUSHBUTTON) && (defined(QT_NO_BUTTON) || defined(QT_NO_STYLE)) +#define QT_NO_PUSHBUTTON +#endif + +// Radio-buttons +#if !defined(QT_NO_RADIOBUTTON) && (defined(QT_NO_BUTTON) || defined(QT_NO_STYLE)) +#define QT_NO_RADIOBUTTON +#endif + +// Internal resize handler +#if !defined(QT_NO_RESIZEHANDLER) && (defined(QT_NO_FRAME)) +#define QT_NO_RESIZEHANDLER +#endif + +// Scroll bars +#if !defined(QT_NO_SCROLLBAR) && (defined(QT_NO_RANGECONTROL) || defined(QT_NO_STYLE)) +#define QT_NO_SCROLLBAR +#endif + +// Sliders +#if !defined(QT_NO_SLIDER) && (defined(QT_NO_RANGECONTROL) || defined(QT_NO_STYLE)) +#define QT_NO_SLIDER +#endif + +// Spinbox control widget +#if !defined(QT_NO_SPINWIDGET) && (defined(QT_NO_FRAME)) +#define QT_NO_SPINWIDGET +#endif + +// Status bars +#if !defined(QT_NO_STATUSBAR) && (defined(QT_NO_LAYOUT) || defined(QT_NO_STYLE)) +#define QT_NO_STATUSBAR +#endif + +// Compact Windows style +#if !defined(QT_NO_STYLE_COMPACT) && (defined(QT_NO_STYLE_WINDOWS)) +#define QT_NO_STYLE_COMPACT +#endif + +// Interlace-friendly style +#if !defined(QT_NO_STYLE_INTERLACE) && (defined(QT_NO_STYLE_MOTIF)) +#define QT_NO_STYLE_INTERLACE +#endif + +// Platinum style +#if !defined(QT_NO_STYLE_PLATINUM) && (defined(QT_NO_STYLE_WINDOWS)) +#define QT_NO_STYLE_PLATINUM +#endif + +// Widget stacks +#if !defined(QT_NO_WIDGETSTACK) && (defined(QT_NO_FRAME)) +#define QT_NO_WIDGETSTACK +#endif + +// Grid layout widgets +#if !defined(QT_NO_GRID) && (defined(QT_NO_LAYOUT) || defined(QT_NO_FRAME)) +#define QT_NO_GRID +#endif + +// Group boxes +#if !defined(QT_NO_GROUPBOX) && (defined(QT_NO_FRAME) || defined(QT_NO_LAYOUT)) +#define QT_NO_GROUPBOX +#endif + +// Horizontal box layout widgets +#if !defined(QT_NO_HBOX) && (defined(QT_NO_LAYOUT) || defined(QT_NO_FRAME)) +#define QT_NO_HBOX +#endif + +// Menu-oriented widgets +#if !defined(QT_NO_MENUDATA) && (defined(QT_NO_ICONSET) || defined(QT_NO_VARIANT)) +#define QT_NO_MENUDATA +#endif + +// Persistent application settings +#if !defined(QT_NO_SETTINGS) && (defined(QT_NO_DIR) || defined(QT_NO_TEXTSTREAM) || defined(QT_NO_REGEXP_CAPTURE)) +#define QT_NO_SETTINGS +#endif + +// Splitters +#if !defined(QT_NO_SPLITTER) && (defined(QT_NO_FRAME) || defined(QT_NO_LAYOUT)) +#define QT_NO_SPLITTER +#endif + +// Table-like widgets +#if !defined(QT_NO_TABLEVIEW) && (defined(QT_NO_SCROLLBAR)) +#define QT_NO_TABLEVIEW +#endif + +// Tool tips +#if !defined(QT_NO_TOOLTIP) && (defined(QT_NO_LABEL)) +#define QT_NO_TOOLTIP +#endif + +// Cut and paste +#if !defined(QT_NO_CLIPBOARD) && (defined(QT_NO_QWS_PROPERTIES) || defined(QT_NO_MIME)) +#define QT_NO_CLIPBOARD +#endif + +// Horizontal group boxes +#if !defined(QT_NO_HGROUPBOX) && (defined(QT_NO_GROUPBOX)) +#define QT_NO_HGROUPBOX +#endif + +// Properties +#if !defined(QT_NO_PROPERTIES) && (defined(QT_NO_VARIANT) || defined(QT_NO_STRINGLIST) || defined(QT_NO_ICONSET)) +#define QT_NO_PROPERTIES +#endif + +// RichText (HTML) display +#if !defined(QT_NO_RICHTEXT) && (defined(QT_NO_STYLE) || defined(QT_NO_LAYOUT) || defined(QT_NO_STRINGLIST) || defined(QT_NO_TEXTSTREAM)) +#define QT_NO_RICHTEXT +#endif + +// SQL classes +#if !defined(QT_NO_SQL) && (defined(QT_NO_STRINGLIST) || defined(QT_NO_REGEXP_CAPTURE) || defined(QT_NO_VARIANT) || defined(QT_NO_SPRINTF) || defined(QT_NO_DATESTRING)) +#define QT_NO_SQL +#endif + +// CDE style +#if !defined(QT_NO_STYLE_CDE) && (defined(QT_NO_STYLE_MOTIF) || defined(QT_NO_TRANSFORMATIONS)) +#define QT_NO_STYLE_CDE +#endif + +// Vertical box layout widgets +#if !defined(QT_NO_VBOX) && (defined(QT_NO_HBOX)) +#define QT_NO_VBOX +#endif + +// Button groups +#if !defined(QT_NO_BUTTONGROUP) && (defined(QT_NO_GROUPBOX) || defined(QT_NO_BUTTON)) +#define QT_NO_BUTTONGROUP +#endif + +// Complex scripts (eg. BiDi) +#if !defined(QT_NO_COMPLEXTEXT) && (defined(QT_NO_RICHTEXT)) +#define QT_NO_COMPLEXTEXT +#endif + +// Cut and paste non-text +#if !defined(QT_NO_MIMECLIPBOARD) && (defined(QT_NO_CLIPBOARD)) +#define QT_NO_MIMECLIPBOARD +#endif + +// Printing +#if !defined(QT_NO_PRINTER) && (defined(QT_NO_TEXTSTREAM) || defined(QT_NO_SPRINTF) || defined(QT_NO_FONTDATABASE) || defined(QT_NO_DATESTRING) || defined(QT_NO_REGEXP_CAPTURE)) +#define QT_NO_PRINTER +#endif + +// Aqua style +#if !defined(QT_NO_STYLE_AQUA) && (defined(QT_NO_STYLE_WINDOWS) || defined(QT_NO_IMAGE_TRANSFORMATION)) +#define QT_NO_STYLE_AQUA +#endif + +// Vertical group boxes +#if !defined(QT_NO_VGROUPBOX) && (defined(QT_NO_HGROUPBOX)) +#define QT_NO_VGROUPBOX +#endif + +// Horizontal button groups +#if !defined(QT_NO_HBUTTONGROUP) && (defined(QT_NO_BUTTONGROUP)) +#define QT_NO_HBUTTONGROUP +#endif + +// Server to play sound +#if !defined(QT_NO_QWS_SOUNDSERVER) && (defined(QT_NO_SOUND) || defined(QT_NO_DIR) || defined(QT_NO_DNS)) +#define QT_NO_QWS_SOUNDSERVER +#endif + +// TQHeader +#if !defined(QT_NO_HEADER) && (defined(QT_NO_STYLE) || defined(QT_NO_ICONSET)) +#define QT_NO_HEADER +#endif + +// Vertical button groups +#if !defined(QT_NO_VBUTTONGROUP) && (defined(QT_NO_HBUTTONGROUP)) +#define QT_NO_VBUTTONGROUP +#endif + +// Hebrew Codec +#if !defined(QT_NO_CODEC_HEBREW) && (defined(QT_NO_CODECS) || defined(QT_NO_COMPLEXTEXT)) +#define QT_NO_CODEC_HEBREW +#endif + +// HTTP file access +#if !defined(QT_NO_NETWORKPROTOCOL_HTTP) && (defined(QT_NO_NETWORKPROTOCOL) || defined(QT_NO_DNS)) +#define QT_NO_NETWORKPROTOCOL_HTTP +#endif + +// Tool-buttons +#if !defined(QT_NO_TOOLBUTTON) && (defined(QT_NO_BUTTON) || defined(QT_NO_ICONSET) || defined(QT_NO_STYLE)) +#define QT_NO_TOOLBUTTON +#endif + +// Big Codecs (eg. CJK) +#if !defined(QT_NO_BIG_CODECS) && (defined(QT_NO_CODEC_HEBREW)) +#define QT_NO_BIG_CODECS +#endif + +// Experimental internal class +#if !defined(QT_NO_DIALOGBUTTONS) && (defined(QT_NO_LAYOUT) || defined(QT_NO_STYLE) || defined(QT_NO_PUSHBUTTON)) +#define QT_NO_DIALOGBUTTONS +#endif + +// Document Object Model +#if !defined(QT_NO_DOM) && (defined(QT_NO_XML) || defined(QT_NO_MIME)) +#define QT_NO_DOM +#endif + +// Scrollable view widgets +#if !defined(QT_NO_SCROLLVIEW) && (defined(QT_NO_SCROLLBAR) || defined(QT_NO_FRAME)) +#define QT_NO_SCROLLVIEW +#endif + +// Tab-bars +#if !defined(QT_NO_TABBAR) && (defined(QT_NO_TOOLBUTTON)) +#define QT_NO_TABBAR +#endif + +// Drag and drop +#if !defined(QT_NO_DRAGANDDROP) && (defined(QT_NO_MIME) || defined(QT_NO_QWS_PROPERTIES) || defined(QT_NO_IMAGEIO_XPM)) +#define QT_NO_DRAGANDDROP +#endif + +// TQGridView +#if !defined(QT_NO_GRIDVIEW) && (defined(QT_NO_SCROLLVIEW)) +#define QT_NO_GRIDVIEW +#endif + +// Popup-menus +#if !defined(QT_NO_POPUPMENU) && (defined(QT_NO_MENUDATA) || defined(QT_NO_FRAME)) +#define QT_NO_POPUPMENU +#endif + +// TQCanvas +#if !defined(QT_NO_CANVAS) && (defined(QT_NO_SCROLLVIEW) || defined(QT_NO_BEZIER)) +#define QT_NO_CANVAS +#endif + +// Dynamic module linking +#if !defined(QT_NO_COMPONENT) && (defined(QT_NO_QUUID_STRING) || defined(QT_NO_SETTINGS) || defined(QT_NO_SPRINTF) || defined(QT_NO_LIBRARY) || defined(QT_NO_DATESTRING)) +#define QT_NO_COMPONENT +#endif + +// TQListBox +#if !defined(QT_NO_LISTBOX) && (defined(QT_NO_SCROLLVIEW) || defined(QT_NO_STRINGLIST)) +#define QT_NO_LISTBOX +#endif + +// Menu bars +#if !defined(QT_NO_MENUBAR) && (defined(QT_NO_POPUPMENU)) +#define QT_NO_MENUBAR +#endif + +// TQMessageBox +#if !defined(QT_NO_MESSAGEBOX) && (defined(QT_NO_DIALOG) || defined(QT_NO_PUSHBUTTON) || defined(QT_NO_LABEL)) +#define QT_NO_MESSAGEBOX +#endif + +// FTP file access +#if !defined(QT_NO_NETWORKPROTOCOL_FTP) && (defined(QT_NO_NETWORKPROTOCOL) || defined(QT_NO_DNS) || defined(QT_NO_TEXTDATE)) +#define QT_NO_NETWORKPROTOCOL_FTP +#endif + +// Spin boxes +#if !defined(QT_NO_SPINBOX) && (defined(QT_NO_RANGECONTROL) || defined(QT_NO_SPINWIDGET) || defined(QT_NO_LINEEDIT) || defined(QT_NO_VALIDATOR)) +#define QT_NO_SPINBOX +#endif + +// RichText (HTML) tables and images +#if !defined(QT_NO_TEXTCUSTOMITEM) && (defined(QT_NO_RICHTEXT) || defined(QT_NO_MIME)) +#define QT_NO_TEXTCUSTOMITEM +#endif + +// TQDateTimeEdit +#if !defined(QT_NO_DATETIMEEDIT) && (defined(QT_NO_RICHTEXT) || defined(QT_NO_SPINWIDGET) || defined(QT_NO_DATESTRING)) +#define QT_NO_DATETIMEEDIT +#endif + +// TQTextCodecPlugin +#if !defined(QT_NO_TEXTCODECPLUGIN) && (defined(QT_NO_COMPONENT) || defined(QT_NO_TEXTCODEC)) +#define QT_NO_TEXTCODECPLUGIN +#endif + +// TQImageFormatPlugin +#if !defined(QT_NO_IMAGEFORMATPLUGIN) && (defined(QT_NO_COMPONENT) || defined(QT_NO_IMAGEIO)) +#define QT_NO_IMAGEFORMATPLUGIN +#endif + +// TQSqlForm +#if !defined(QT_NO_SQL_FORM) && (defined(QT_NO_SQL) || defined(QT_NO_PROPERTIES)) +#define QT_NO_SQL_FORM +#endif + +// Scalable Vector Graphics (SVG) +#if !defined(QT_NO_SVG) && (defined(QT_NO_DOM) || defined(QT_NO_TRANSFORMATIONS) || defined(QT_NO_SPRINTF)) +#define QT_NO_SVG +#endif + +// TQIconView +#if !defined(QT_NO_ICONVIEW) && (defined(QT_NO_SCROLLVIEW) || defined(QT_NO_IMAGEIO_XPM) || defined(QT_NO_IMAGE_HEURISTIC_MASK)) +#define QT_NO_ICONVIEW +#endif + +// Tab widgets +#if !defined(QT_NO_TABWIDGET) && (defined(QT_NO_TABBAR) || defined(QT_NO_WIDGETSTACK)) +#define QT_NO_TABWIDGET +#endif + +// "What's this" help +#if !defined(QT_NO_WHATSTHIS) && (defined(QT_NO_TOOLTIP) || defined(QT_NO_TOOLBUTTON)) +#define QT_NO_WHATSTHIS +#endif + +// TQWidgetPlugin +#if !defined(QT_NO_WIDGETPLUGIN) && (defined(QT_NO_COMPONENT) || defined(QT_NO_ICONSET)) +#define QT_NO_WIDGETPLUGIN +#endif + +// TQProgressDialog +#if !defined(QT_NO_PROGRESSDIALOG) && (defined(QT_NO_SEMIMODAL) || defined(QT_NO_LABEL) || defined(QT_NO_PUSHBUTTON) || defined(QT_NO_PROGRESSBAR)) +#define QT_NO_PROGRESSDIALOG +#endif + +// Motif-plus style +#if !defined(QT_NO_STYLE_MOTIFPLUS) && (defined(QT_NO_STYLE_MOTIF) || defined(QT_NO_TRANSFORMATIONS) || defined(QT_NO_BUTTON) || defined(QT_NO_SCROLLBAR) || defined(QT_NO_SLIDER)) +#define QT_NO_STYLE_MOTIFPLUS +#endif + +// Rich text edit +#if !defined(QT_NO_TEXTEDIT) && (defined(QT_NO_RICHTEXT) || defined(QT_NO_SCROLLVIEW)) +#define QT_NO_TEXTEDIT +#endif + +// TQWizard +#if !defined(QT_NO_WIZARD) && (defined(QT_NO_DIALOG) || defined(QT_NO_WIDGETSTACK) || defined(QT_NO_PUSHBUTTON) || defined(QT_NO_LAYOUT) || defined(QT_NO_LABEL)) +#define QT_NO_WIZARD +#endif + +// Multi-line edits +#if !defined(QT_NO_MULTILINEEDIT) && (defined(QT_NO_TEXTEDIT)) +#define QT_NO_MULTILINEEDIT +#endif + +// Rich text syntax highlighting +#if !defined(QT_NO_SYNTAXHIGHLIGHTER) && (defined(QT_NO_TEXTEDIT)) +#define QT_NO_SYNTAXHIGHLIGHTER +#endif + +// TQTextView +#if !defined(QT_NO_TEXTVIEW) && (defined(QT_NO_TEXTEDIT)) +#define QT_NO_TEXTVIEW +#endif + +// TQTabDialog +#if !defined(QT_NO_TABDIALOG) && (defined(QT_NO_DIALOG) || defined(QT_NO_PUSHBUTTON) || defined(QT_NO_LAYOUT) || defined(QT_NO_TABWIDGET)) +#define QT_NO_TABDIALOG +#endif + +// TQTextBrowser +#if !defined(QT_NO_TEXTBROWSER) && (defined(QT_NO_TEXTVIEW) || defined(QT_NO_MIME)) +#define QT_NO_TEXTBROWSER +#endif + +// TQListView +#if !defined(QT_NO_LISTVIEW) && (defined(QT_NO_SCROLLVIEW) || defined(QT_NO_HEADER) || defined(QT_NO_LINEEDIT)) +#define QT_NO_LISTVIEW +#endif + +// TQComboBox +#if !defined(QT_NO_COMBOBOX) && (defined(QT_NO_LISTBOX) || defined(QT_NO_LINEEDIT) || defined(QT_NO_POPUPMENU)) +#define QT_NO_COMBOBOX +#endif + +// TQColorDialog +#if !defined(QT_NO_COLORDIALOG) && (defined(QT_NO_DIALOG) || defined(QT_NO_LABEL) || defined(QT_NO_PUSHBUTTON) || defined(QT_NO_LINEEDIT) || defined(QT_NO_VALIDATOR) || defined(QT_NO_GRIDVIEW) || defined(QT_NO_LAYOUT)) +#define QT_NO_COLORDIALOG +#endif + +// Tool box +#if !defined(QT_NO_TOOLBOX) && (defined(QT_NO_ICONSET) || defined(QT_NO_SCROLLVIEW) || defined(QT_NO_TOOLTIP) || defined(QT_NO_LAYOUT) || defined(QT_NO_TOOLBUTTON)) +#define QT_NO_TOOLBOX +#endif + +// SGI style +#if !defined(QT_NO_STYLE_SGI) && (defined(QT_NO_STYLE_MOTIF) || defined(QT_NO_TRANSFORMATIONS) || defined(QT_NO_BUTTON) || defined(QT_NO_SCROLLBAR) || defined(QT_NO_SLIDER) || defined(QT_NO_LINEEDIT) || defined(QT_NO_MENUBAR)) +#define QT_NO_STYLE_SGI +#endif + +// TQErrorMessage +#if !defined(QT_NO_ERRORMESSAGE) && (defined(QT_NO_DIALOG) || defined(QT_NO_PUSHBUTTON) || defined(QT_NO_LABEL) || defined(QT_NO_CHECKBOX) || defined(QT_NO_TEXTVIEW)) +#define QT_NO_ERRORMESSAGE +#endif + +// Main-windows +#if !defined(QT_NO_MAINWINDOW) && (defined(QT_NO_STRINGLIST) || defined(QT_NO_POPUPMENU) || defined(QT_NO_TITLEBAR) || defined(QT_NO_RESIZEHANDLER) || defined(QT_NO_TOOLBUTTON) || defined(QT_NO_STATUSBAR)) +#define QT_NO_MAINWINDOW +#endif + +// Toolbars +#if !defined(QT_NO_TOOLBAR) && (defined(QT_NO_MAINWINDOW)) +#define QT_NO_TOOLBAR +#endif + +// TQAction +#if !defined(QT_NO_ACTION) && (defined(QT_NO_TOOLBUTTON) || defined(QT_NO_COMBOBOX)) +#define QT_NO_ACTION +#endif + +// TQTable +#if !defined(QT_NO_TABLE) && (defined(QT_NO_COMBOBOX) || defined(QT_NO_HEADER) || defined(QT_NO_CHECKBOX)) +#define QT_NO_TABLE +#endif + +// TQFontDialog +#if !defined(QT_NO_FONTDIALOG) && (defined(QT_NO_DIALOG) || defined(QT_NO_FONTDATABASE) || defined(QT_NO_COMBOBOX) || defined(QT_NO_LABEL) || defined(QT_NO_CHECKBOX) || defined(QT_NO_PUSHBUTTON) || defined(QT_NO_VGROUPBOX) || defined(QT_NO_VALIDATOR)) +#define QT_NO_FONTDIALOG +#endif + +// TQInputDialog +#if !defined(QT_NO_INPUTDIALOG) && (defined(QT_NO_DIALOG) || defined(QT_NO_COMBOBOX) || defined(QT_NO_LABEL) || defined(QT_NO_PUSHBUTTON) || defined(QT_NO_SPINBOX) || defined(QT_NO_WIDGETSTACK) || defined(QT_NO_LAYOUT)) +#define QT_NO_INPUTDIALOG +#endif + +// SQL value editor widgets +#if !defined(QT_NO_SQL_EDIT_WIDGETS) && (defined(QT_NO_SQL) || defined(QT_NO_SPINBOX) || defined(QT_NO_COMBOBOX) || defined(QT_NO_CHECKBOX) || defined(QT_NO_DATETIMEEDIT)) +#define QT_NO_SQL_EDIT_WIDGETS +#endif + +// TQPrintDialog +#if !defined(QT_NO_PRINTDIALOG) && (defined(QT_NO_DIALOG) || defined(QT_NO_LISTVIEW) || defined(QT_NO_PRINTER) || defined(QT_NO_COMBOBOX) || defined(QT_NO_LABEL) || defined(QT_NO_BUTTONGROUP) || defined(QT_NO_SPINBOX) || defined(QT_NO_RADIOBUTTON) || defined(QT_NO_PUSHBUTTON) || defined(QT_NO_DIR)) +#define QT_NO_PRINTDIALOG +#endif + +// TQFileDialog +#if !defined(QT_NO_FILEDIALOG) && (defined(QT_NO_MESSAGEBOX) || defined(QT_NO_LISTVIEW) || defined(QT_NO_NETWORKPROTOCOL) || defined(QT_NO_COMBOBOX) || defined(QT_NO_SEMIMODAL) || defined(QT_NO_REGEXP_CAPTURE) || defined(QT_NO_TOOLBUTTON) || defined(QT_NO_BUTTONGROUP) || defined(QT_NO_VBOX) || defined(QT_NO_SPLITTER) || defined(QT_NO_PROGRESSBAR) || defined(QT_NO_WIDGETSTACK) || defined(QT_NO_DATESTRING)) +#define QT_NO_FILEDIALOG +#endif + +// SQL table widgets +#if !defined(QT_NO_SQL_VIEW_WIDGETS) && (defined(QT_NO_SQL_FORM) || defined(QT_NO_SQL_EDIT_WIDGETS) || defined(QT_NO_TABLE)) +#define QT_NO_SQL_VIEW_WIDGETS +#endif + +// TQWorkSpace +#if !defined(QT_NO_WORKSPACE) && (defined(QT_NO_SCROLLBAR) || defined(QT_NO_VBOX) || defined(QT_NO_TITLEBAR) || defined(QT_NO_RESIZEHANDLER) || defined(QT_NO_POPUPMENU) || defined(QT_NO_LABEL) || defined(QT_NO_TOOLBUTTON) || defined(QT_NO_MAINWINDOW) || defined(QT_NO_TOOLBAR) || defined(QT_NO_MENUBAR)) +#define QT_NO_WORKSPACE +#endif + +// Input method +#if !defined(QT_NO_IM) && (defined(QT_NO_STRINGLIST)) +#define QT_NO_IM +#endif + +// Input method extensions +#if !defined(QT_NO_IM_EXTENSIONS) && (defined(QT_NO_IM) || defined(QT_NO_STRINGLIST)) +#define QT_NO_IM_EXTENSIONS +#endif + diff --git a/src/tools/qfeatures.txt b/src/tools/qfeatures.txt new file mode 100644 index 000000000..0581fcb11 --- /dev/null +++ b/src/tools/qfeatures.txt @@ -0,0 +1,1314 @@ +Feature: WORKSPACE +Section: Widgets +Retquires: SCROLLBAR VBOX TITLEBAR RESIZEHANDLER POPUPMENU LABEL TOOLBUTTON MAINWINDOW TOOLBAR MENUBAR +Name: QWorkSpace +SeeAlso: ??? + +Feature: WHEELEVENT +Section: Kernel +Retquires: +Name: Wheel-mouse events +SeeAlso: ??? + +Feature: WMATRIX +Section: Data structures +Retquires: +Name: QWMatrix +SeeAlso: ??? + +Feature: STL +Section: Data structures +Retquires: +Name: Standard template library compatiblity +SeeAlso: ??? + +Feature: CANVAS +Section: Widgets +Retquires: SCROLLVIEW BEZIER +Name: QCanvas +SeeAlso: ??? + +Feature: TOOLBOX +Section: Widgets +Retquires: ICONSET SCROLLVIEW TOOLTIP LAYOUT TOOLBUTTON +Name: Tool box +SeeAlso: ??? + + +Feature: TABLE +Section: Widgets +Retquires: COMBOBOX HEADER CHECKBOX +Name: QTable +SeeAlso: ??? + +Feature: XML +Section: Data structures +Retquires: TEXTSTREAM TEXTCODEC REGEXP_CAPTURE +Name: XML +SeeAlso: ??? + +Feature: SQL +Section: Database +Retquires: STRINGLIST REGEXP_CAPTURE VARIANT SPRINTF DATESTRING +Name: SQL classes +SeeAlso: ??? + +Feature: SQL_FORM +Section: Database +Retquires: SQL PROPERTIES +Name: QSqlForm +SeeAlso: ??? + +Feature: SQL_EDIT_WIDGETS +Section: Database +Retquires: SQL SPINBOX COMBOBOX CHECKBOX DATETIMEEDIT +Name: SQL value editor widgets +SeeAlso: ??? + +Feature: SQL_VIEW_WIDGETS +Section: Database +Retquires: SQL_FORM SQL_EDIT_WIDGETS TABLE +Name: SQL table widgets +SeeAlso: ??? + +Feature: STRINGLIST +Section: Data structures +Retquires: +Name: QStringList +SeeAlso: ??? + +Feature: REGEXP +Section: Data structures +Retquires: +Name: Regular expression capture +SeeAlso: ??? + +Feature: REGEXP_CAPTURE +Section: Data structures +Retquires: REGEXP STRINGLIST +Name: Regular expression capture +SeeAlso: ??? + +Feature: TEMPLATE_VARIANT +Section: Data structures +Retquires: VARIANT STRINGLIST +Name: Template classes in QVariant +SeeAlso: ??? + +Feature: VARIANT +Section: Data structures +Retquires: +Name: QVariant +SeeAlso: ??? + +Feature: REGEXP_OPTIM +Section: Data structures +Retquires: REGEXP +Name: Regular expression optimization +SeeAlso: ??? + +Feature: REGEXP_LOOKAHEAD +Section: Data structures +Retquires: REGEXP +Name: Regular expression lookahead +SeeAlso: ??? + +Feature: REGEXP_INTERVAL +Section: Data structures +Retquires: REGEXP +Name: Regular expression interval +SeeAlso: ??? + +Feature: REGEXP_ESCAPE +Section: Data structures +Retquires: REGEXP +Name: Regular expression escape +SeeAlso: ??? + +Feature: REGEXP_CCLASS +Section: Data structures +Retquires: REGEXP +Name: Regular expression character-class +SeeAlso: ??? + +Feature: REGEXP_BACKREF +Section: Data structures +Retquires: REGEXP +Name: Regular expression back-reference +SeeAlso: ??? + +Feature: REGEXP_ANCHOR_ALT +Section: Data structures +Retquires: REGEXP +Name: Regular expression anchors +SeeAlso: ??? + +Feature: REGEXP_WILDCARD +Section: Data structures +Retquires: REGEXP +Name: Regular expression wildcard +SeeAlso: ??? + +Feature: SPRINTF +Section: Data structures +Retquires: REGEXP +Name: QString::sprintf() +SeeAlso: ??? + +Feature: QUUID_STRING +Section: Data structures +Retquires: STRINGLIST +Name: Convert UUID to/from string +SeeAlso: ??? + +Feature: TEXTDATE +Section: Data structures +Retquires: STRINGLIST DATESTRING +Name: Month and day names in dates +SeeAlso: ??? + +Feature: DATESTRING +Section: Data structures +Retquires: +Name: QDate/QTime/QDateTime toString() and fromString() +SeeAlso: ??? + +Feature: ICONSET +Section: Images +Retquires: IMAGEIO IMAGE_SMOOTHSCALE PALETTE IMAGE_HEURISTIC_MASK +Name: QIconSet +SeeAlso: ??? + +Feature: DIR +Section: File I/O +Retquires: STRINGLIST REGEXP +Name: QDir +SeeAlso: ??? + +Feature: PALETTE +Section: Kernel +Retquires: +Name: Palettes +SeeAlso: ??? + +Feature: TEXTSTREAM +Section: File I/O +Retquires: +Name: QTextStream +SeeAlso: ??? + +Feature: DATASTREAM +Section: File I/O +Retquires: +Name: QDataStream +SeeAlso: ??? + +Feature: LIBRARY +Section: File I/O +Retquires: REGEXP +Name: Shared library wrapper +SeeAlso: ??? + +Feature: COMPONENT +Section: File I/O +Retquires: QUUID_STRING SETTINGS SPRINTF LIBRARY DATESTRING +Name: Dynamic module linking +SeeAlso: ??? + +Feature: SETTINGS +Section: File I/O +Retquires: DIR TEXTSTREAM REGEXP_CAPTURE +Name: Persistent application settings +SeeAlso: ??? + +Feature: SIGNALMAPPER +Section: Widgets +Retquires: +Name: QSignalMapper +SeeAlso: ??? + +Feature: IMAGEIO +Section: Images +Retquires: REGEXP +Name: Image formats +SeeAlso: ??? + +Feature: IMAGEIO_BMP +Section: Images +Retquires: IMAGEIO DATASTREAM +Name: BMP image I/O +SeeAlso: ??? + +Feature: IMAGEIO_PPM +Section: Images +Retquires: IMAGEIO +Name: PPM image I/O +SeeAlso: ??? + +Feature: IMAGEIO_XBM +Section: Images +Retquires: IMAGEIO +Name: XBM image I/O +SeeAlso: ??? + +Feature: IMAGEIO_XPM +Section: Images +Retquires: IMAGEIO SPRINTF TEXTSTREAM +Name: XPM image I/O +SeeAlso: ??? + +Feature: IMAGEIO_PNG +Section: Images +Retquires: IMAGEIO +Name: PNG image I/O +SeeAlso: ??? + +Feature: IMAGEIO_MNG +Section: Images +Retquires: IMAGEIO +Name: MNG image I/O +SeeAlso: ??? + +Feature: IMAGEIO_JPEG +Section: Images +Retquires: IMAGEIO +Name: JPEG image I/O +SeeAlso: ??? + +Feature: ASYNC_IO +Section: Images +Retquires: +Name: Asynchronous I/O +SeeAlso: ??? + +Feature: ASYNC_IMAGE_IO +Section: Images +Retquires: IMAGEIO +Name: Asynchronous image I/O +SeeAlso: ??? + +Feature: MOVIE +Section: Images +Retquires: ASYNC_IO ASYNC_IMAGE_IO +Name: Animated images +SeeAlso: ??? + +Feature: FREETYPE +Section: Fonts +Retquires: +Name: Freetype font engine +SeeAlso: ??? + +Feature: BDF +Section: Fonts +Retquires: TEXTSTREAM STRINGLIST +Name: BDF font files +SeeAlso: ??? + +Feature: FONTDATABASE +Section: Fonts +Retquires: STRINGLIST +Name: QFontDatabase +SeeAlso: ??? + +Feature: TRANSLATION +Section: Internationalization +Retquires: DATASTREAM +Name: Translations via QObject::tr() +SeeAlso: ??? + +Feature: TRANSLATION_UTF8 +Section: Internationalization +Retquires: TRANSLATION TEXTCODEC +Name: Translations via QObject::trUtf8() +SeeAlso: ??? + +Feature: TEXTCODEC +Section: Internationalization +Retquires: +Name: Character set conversions +SeeAlso: ??? + +Feature: CODECS +Section: Internationalization +Retquires: TEXTCODEC +Name: Non-Unicode text conversions +SeeAlso: ??? + +Feature: BIG_CODECS +Section: Internationalization +Retquires: CODEC_HEBREW +Name: Big Codecs (eg. CJK) +SeeAlso: ??? + +Feature: CODEC_HEBREW +Section: Internationalization +Retquires: CODECS COMPLEXTEXT +Name: Hebrew Codec +SeeAlso: ??? + +Feature: UNICODETABLES +Section: Internationalization +Retquires: +Name: Unicode property tables +SeeAlso: ??? + +Feature: MIME +Section: File I/O +Retquires: DIR IMAGEIO TEXTCODEC +Name: MIME +SeeAlso: ??? + +Feature: RICHTEXT +Section: Widgets +Retquires: STYLE LAYOUT STRINGLIST TEXTSTREAM +Name: RichText (HTML) display +SeeAlso: ??? + +Feature: TEXTCUSTOMITEM +Section: Widgets +Retquires: RICHTEXT MIME +Name: RichText (HTML) tables and images +SeeAlso: ??? + + +Feature: COMPLEXTEXT +Section: Internationalization +Retquires: RICHTEXT +Name: Complex scripts (eg. BiDi) +SeeAlso: ??? + +Feature: DOM +Section: File I/O +Retquires: XML MIME +Name: Document Object Model +SeeAlso: ??? + +Feature: SOUND +Section: Kernel +Retquires: +Name: Playing sounds +SeeAlso: ??? + +Feature: QWS_SOUNDSERVER +Section: Qt/Embedded-specific +Retquires: SOUND DIR DNS +Name: Server to play sound +SeeAlso: ??? + +Feature: PROPERTIES +Section: Kernel +Retquires: VARIANT STRINGLIST ICONSET +Name: Properties +SeeAlso: ??? + +Feature: NETWORK +Section: Networking +Retquires: +Name: Networking +SeeAlso: ??? + +Feature: DNS +Section: Networking +Retquires: NETWORK STRINGLIST TEXTSTREAM SPRINTF +Name: DNS +SeeAlso: ??? + +Feature: URL +Section: Networking +Retquires: DIR +Name: URL parser +SeeAlso: ??? + +Feature: NETWORKPROTOCOL +Section: Networking +Retquires: TEXTCODEC URL +Name: Network file access +SeeAlso: ??? + +Feature: NETWORKPROTOCOL_FTP +Section: Networking +Retquires: NETWORKPROTOCOL DNS TEXTDATE +Name: FTP file access +SeeAlso: ??? + +Feature: NETWORKPROTOCOL_HTTP +Section: Networking +Retquires: NETWORKPROTOCOL DNS +Name: HTTP file access +SeeAlso: ??? + +Feature: PROCESS +Section: File I/O +Retquires: STRINGLIST REGEXP +Name: External process invocation. +SeeAlso: ??? + +Feature: QWS_MULTIPROCESS +Section: Qt/Embedded-specific +Retquires: NETWORK +Name: Multi-process architecture +SeeAlso: ??? + +Feature: COP +Section: Networking +Retquires: DATASTREAM +Name: QCop IPC +SeeAlso: ??? + +Feature: QWS_KEYBOARD +Section: Qt/Embedded-specific +Retquires: +Name: Console keyboard +SeeAlso: ??? + +Feature: QWS_KBD_SL5000 +Section: Qt/Embedded-specific +Retquires: QWS_KEYBOARD +Name: Keyboard for SHARP Zaurus SL5xxx devices +SeeAlso: ??? + +Feature: QWS_CURSOR +Section: Qt/Embedded-specific +Retquires: CURSOR +Name: Visible cursor +SeeAlso: ??? + +Feature: QWS_ALPHA_CURSOR +Section: Qt/Embedded-specific +Retquires: +Name: Alpha-blended cursor +SeeAlso: ??? + +Feature: QWS_MACH64 +Section: Qt/Embedded-specific +Retquires: +Name: Mach64 acceleration +SeeAlso: ??? + +Feature: QWS_VOODOO3 +Section: Qt/Embedded-specific +Retquires: +Name: Voodoo3 acceleration +SeeAlso: ??? + +Feature: QWS_MATROX +Section: Qt/Embedded-specific +Retquires: +Name: Matrox MGA acceleration +SeeAlso: ??? + +Feature: QWS_REPEATER +Section: Qt/Embedded-specific +Retquires: +Name: Repeater display +SeeAlso: ??? + +Feature: QWS_VFB +Section: Qt/Embedded-specific +Retquires: +Name: Virtual frame buffer +SeeAlso: ??? + +Feature: QWS_TRANSFORMED +Section: Qt/Embedded-specific +Retquires: QWS_LINUXFB +Name: Transformed frame buffer +SeeAlso: ??? + +Feature: QWS_LINUXFB +Section: Qt/Embedded-specific +Retquires: +Name: Linux framebuffer +SeeAlso: ??? + +Feature: QWS_VNC +Section: Qt/Embedded-specific +Retquires: NETWORK +Name: Remote frame buffer (VNC) +SeeAlso: ??? + +Feature: QWS_SHADOWFB +Section: Qt/Embedded-specific +Retquires: +Name: Shadow frame buffer +SeeAlso: ??? + +Feature: QWS_DEPTH_1 +Section: Qt/Embedded-specific +Retquires: +Name: 1-bit monochrome +SeeAlso: ??? + +Feature: QWS_DEPTH_4 +Section: Qt/Embedded-specific +Retquires: +Name: 4-bit grayscale +SeeAlso: ??? + +Feature: QWS_VGA_16 +Section: Qt/Embedded-specific +Retquires: +Name: 4-bit VGA +SeeAlso: ??? + +Feature: QWS_DEPTH_8GRAYSCALE +Section: Qt/Embedded-specific +Retquires: +Name: 8-bit grayscale +SeeAlso: ??? + +Feature: QWS_DEPTH_8 +Section: Qt/Embedded-specific +Retquires: +Name: 8-bit color +SeeAlso: ??? + +Feature: QWS_DEPTH_16 +Section: Qt/Embedded-specific +Retquires: +Name: 15 or 16-bit color +SeeAlso: ??? + +Feature: QWS_DEPTH_24 +Section: Qt/Embedded-specific +Retquires: +Name: 24-bit color +SeeAlso: ??? + +Feature: QWS_DEPTH_32 +Section: Qt/Embedded-specific +Retquires: +Name: 32-bit color +SeeAlso: ??? + +Feature: QWS_DEPTH_32_BGR +Section: Qt/Embedded-specific +Retquires: QWS_DEPTH_32 +Name: 32-bit color, BGR order +SeeAlso: ??? + +Feature: QWS_MANAGER +Section: Qt/Embedded-specific +Retquires: +Name: Window Manager +SeeAlso: ??? + +Feature: QWS_KDE2_WM_STYLE +Section: Qt/Embedded-specific +Retquires: QWS_MANAGER +Name: The "KDE2" style +SeeAlso: ??? + +Feature: QWS_HYDRO_WM_STYLE +Section: Qt/Embedded-specific +Retquires: QWS_MANAGER +Name: The "Hydro" style +SeeAlso: ??? + +Feature: QWS_BEOS_WM_STYLE +Section: Qt/Embedded-specific +Retquires: QWS_MANAGER +Name: The "BeOS" style +SeeAlso: ??? + +Feature: QWS_KDE_WM_STYLE +Section: Qt/Embedded-specific +Retquires: QWS_MANAGER +Name: The "KDE" style +SeeAlso: ??? + +Feature: QWS_WINDOWS_WM_STYLE +Section: Qt/Embedded-specific +Retquires: QWS_MANAGER +Name: The "Windows" style +SeeAlso: ??? + +Feature: QWS_MOUSE_AUTO +Section: Qt/Embedded-specific +Retquires: +Name: Autodetecting mouse driver +SeeAlso: ??? + +Feature: QWS_MOUSE_MANUAL +Section: Qt/Embedded-specific +Retquires: +Name: Non-autodetecting mouse driver +SeeAlso: ??? + +Feature: QWS_SAVEFONTS +Section: Qt/Embedded-specific +Retquires: +Name: Saving of fonts +SeeAlso: ??? + +Feature: QWS_GFX_SPEED +Section: Qt/Embedded-specific +Retquires: +Name: Favour code size over graphics speed +SeeAlso: ??? + +Feature: QWS_PROPERTIES +Section: Qt/Embedded-specific +Retquires: +Name: Qt/Embedded window system properties. +SeeAlso: ??? + +Feature: CLIPBOARD +Section: Kernel +Retquires: QWS_PROPERTIES MIME +Name: Cut and paste +SeeAlso: ??? + +Feature: DRAGANDDROP +Section: Kernel +Retquires: MIME QWS_PROPERTIES IMAGEIO_XPM +Name: Drag and drop +SeeAlso: ??? + +Feature: MIMECLIPBOARD +Section: Kernel +Retquires: CLIPBOARD +Name: Cut and paste non-text +SeeAlso: ??? + +Feature: DRAWUTIL +Section: Kernel +Retquires: SPRINTF PALETTE +Name: Drawing utility functions +SeeAlso: ??? + +Feature: IMAGE_TRUECOLOR +Section: Images +Retquires: +Name: TrueColor QImage +SeeAlso: ??? + +Feature: IMAGE_SMOOTHSCALE +Section: Images +Retquires: +Name: Smooth QImage scaling +SeeAlso: ??? + +Feature: IMAGE_DITHER_TO_1 +Section: Images +Retquires: +Name: Dither QImage to 1-bit image +SeeAlso: ??? + +Feature: IMAGE_HEURISTIC_MASK +Section: Images +Retquires: +Name: QImage::createHeuristicMask() +SeeAlso: ??? + +Feature: IMAGE_MIRROR +Section: Images +Retquires: +Name: QImage mirroring +SeeAlso: ??? + +Feature: IMAGE_TEXT +Section: Images +Retquires: STRINGLIST +Name: Image file text strings +SeeAlso: ??? + +Feature: IMAGE_16_BIT +Section: Qt/Embedded-specific +Retquires: IMAGE_TRUECOLOR +Name: 16-bit QImage +SeeAlso: ??? + +Feature: CURSOR +Section: Kernel +Retquires: +Name: Cursors +SeeAlso: ??? + +Feature: COLORNAMES +Section: Painting +Retquires: +Name: Named colors +SeeAlso: ??? + +Feature: TRANSFORMATIONS +Section: Painting +Retquires: WMATRIX +Name: Scaling and rotation +SeeAlso: ??? + +Feature: PIXMAP_TRANSFORMATION +Section: Painting +Retquires: WMATRIX +Name: Pixmap transformations +SeeAlso: ??? + +Feature: IMAGE_TRANSFORMATION +Section: Painting +Retquires: PIXMAP_TRANSFORMATION +Name: Image transformations +SeeAlso: ??? + +Feature: SVG +Section: Painting +Retquires: DOM TRANSFORMATIONS SPRINTF +Name: Scalable Vector Graphics (SVG) +SeeAlso: ??? + +Feature: BEZIER +Section: Painting +Retquires: +Name: Bezier curves +SeeAlso: ??? + +Feature: PRINTER +Section: Painting +Retquires: TEXTSTREAM SPRINTF FONTDATABASE DATESTRING REGEXP_CAPTURE +Name: Printing +SeeAlso: ??? + +Feature: PICTURE +Section: Painting +Retquires: DATASTREAM IMAGEIO +Name: QPicture +SeeAlso: ??? + +Feature: LAYOUT +Section: Kernel +Retquires: +Name: Automatic widget layout +SeeAlso: ??? + +Feature: STYLE +Section: Widgets +Retquires: DRAWUTIL +Name: QStyle +SeeAlso: ??? + +Feature: WIDGET_TOPEXTRA +Section: Kernel +Retquires: IMAGE_HEURISTIC_MASK +Name: Window icon and caption +SeeAlso: ??? + +Feature: DIALOG +Section: Widgets +Retquires: +Name: Dialogs +SeeAlso: ??? + +Feature: SEMIMODAL +Section: Widgets +Retquires: DIALOG +Name: Semi-modal dialogs +SeeAlso: ??? + +Feature: FRAME +Section: Widgets +Retquires: STYLE +Name: Framed widgets +SeeAlso: ??? + +Feature: EFFECTS +Section: Kernel +Retquires: +Name: Special widget effects (fading, scrolling) +SeeAlso: ??? + +Feature: LABEL +Section: Widgets +Retquires: FRAME +Name: QLabel +SeeAlso: ??? + +Feature: TOOLBAR +Section: Widgets +Retquires: MAINWINDOW +Name: Toolbars +SeeAlso: ??? + +Feature: BUTTON +Section: Widgets +Retquires: +Name: Buttons +SeeAlso: ??? + +Feature: CHECKBOX +Section: Widgets +Retquires: BUTTON STYLE +Name: Check-boxes +SeeAlso: ??? + +Feature: RADIOBUTTON +Section: Widgets +Retquires: BUTTON STYLE +Name: Radio-buttons +SeeAlso: ??? + +Feature: TOOLBUTTON +Section: Widgets +Retquires: BUTTON ICONSET STYLE +Name: Tool-buttons +SeeAlso: ??? + +Feature: GRID +Section: Widgets +Retquires: LAYOUT FRAME +Name: Grid layout widgets +SeeAlso: ??? + +Feature: GROUPBOX +Section: Widgets +Retquires: FRAME LAYOUT +Name: Group boxes +SeeAlso: ??? + +Feature: BUTTONGROUP +Section: Widgets +Retquires: GROUPBOX BUTTON RADIOBUTTON +Name: Button groups +SeeAlso: ??? + +Feature: HGROUPBOX +Section: Widgets +Retquires: GROUPBOX +Name: Horizontal group boxes +SeeAlso: ??? + +Feature: VGROUPBOX +Section: Widgets +Retquires: HGROUPBOX +Name: Vertical group boxes +SeeAlso: ??? + +Feature: HBUTTONGROUP +Section: Widgets +Retquires: BUTTONGROUP +Name: Horizontal button groups +SeeAlso: ??? + +Feature: VBUTTONGROUP +Section: Widgets +Retquires: HBUTTONGROUP +Name: Vertical button groups +SeeAlso: ??? + +Feature: HBOX +Section: Widgets +Retquires: LAYOUT FRAME +Name: Horizontal box layout widgets +SeeAlso: ??? + +Feature: VBOX +Section: Widgets +Retquires: HBOX +Name: Vertical box layout widgets +SeeAlso: ??? + +Feature: MAINWINDOW +Section: Widgets +Retquires: STRINGLIST POPUPMENU TITLEBAR RESIZEHANDLER TOOLBUTTON STATUSBAR +Name: Main-windows +SeeAlso: ??? + +Feature: RESIZEHANDLER +Section: Widgets +Retquires: FRAME +Name: Internal resize handler +SeeAlso: ??? + +Feature: MENUDATA +Section: Widgets +Retquires: ICONSET VARIANT +Name: Menu-oriented widgets +SeeAlso: ??? + +Feature: POPUPMENU +Section: Widgets +Retquires: MENUDATA FRAME +Name: Popup-menus +SeeAlso: ??? + +Feature: MENUBAR +Section: Widgets +Retquires: POPUPMENU +Name: Menu bars +SeeAlso: ??? + +Feature: PUSHBUTTON +Section: Widgets +Retquires: BUTTON STYLE +Name: Push-buttons +SeeAlso: ??? + +Feature: PROGRESSBAR +Section: Widgets +Retquires: FRAME +Name: Progress bars +SeeAlso: ??? + +Feature: RANGECONTROL +Section: Widgets +Retquires: +Name: Range-control widgets +SeeAlso: ??? + +Feature: SCROLLBAR +Section: Widgets +Retquires: RANGECONTROL STYLE +Name: Scroll bars +SeeAlso: ??? + +Feature: SLIDER +Section: Widgets +Retquires: RANGECONTROL STYLE +Name: Sliders +SeeAlso: ??? + +Feature: DIAL +Section: Widgets +Retquires: RANGECONTROL STYLE +Name: Dials +SeeAlso: ??? + +Feature: SPINWIDGET +Section: Widgets +Retquires: FRAME +Name: Spinbox control widget +SeeAlso: ??? + +Feature: SCROLLVIEW +Section: Widgets +Retquires: SCROLLBAR FRAME +Name: Scrollable view widgets +SeeAlso: ??? + +Feature: ICONVIEW +Section: Widgets +Retquires: SCROLLVIEW IMAGEIO_XPM IMAGE_HEURISTIC_MASK +Name: QIconView +SeeAlso: ??? + +Feature: GRIDVIEW +Section: Widgets +Retquires: SCROLLVIEW +Name: QGridView +SeeAlso: ??? + +Feature: TEXTVIEW +Section: Widgets +Retquires: TEXTEDIT +Name: QTextView +SeeAlso: ??? + +Feature: TEXTEDIT +Section: Widgets +Retquires: RICHTEXT SCROLLVIEW +Name: Rich text edit +SeeAlso: ??? + +Feature: SYNTAXHIGHLIGHTER +Section: Widgets +Retquires: TEXTEDIT +Name: Rich text syntax highlighting +SeeAlso: ??? + +Feature: SPLASHSCREEN +Section: Widgets +Retquires: IMAGEIO +Name: Splash screen widget +SeeAlso: ??? + + +Feature: TABLEVIEW +Section: Widgets +Retquires: SCROLLBAR +Name: Table-like widgets +SeeAlso: ??? + +Feature: LINEEDIT +Section: Widgets +Retquires: FRAME +Name: Single-line edits +SeeAlso: ??? + +Feature: MULTILINEEDIT +Section: Widgets +Retquires: TEXTEDIT +Name: Multi-line edits +SeeAlso: ??? + +Feature: SPINBOX +Section: Widgets +Retquires: RANGECONTROL SPINWIDGET LINEEDIT VALIDATOR +Name: Spin boxes +SeeAlso: ??? + +Feature: SPLITTER +Section: Widgets +Retquires: FRAME LAYOUT +Name: Splitters +SeeAlso: ??? + +Feature: STATUSBAR +Section: Widgets +Retquires: LAYOUT STYLE +Name: Status bars +SeeAlso: ??? + +Feature: TABBAR +Section: Widgets +Retquires: TOOLBUTTON +Name: Tab-bars +SeeAlso: ??? + +Feature: TABWIDGET +Section: Widgets +Retquires: TABBAR WIDGETSTACK +Name: Tab widgets +SeeAlso: ??? + +Feature: TOOLTIP +Section: Widgets +Retquires: LABEL +Name: Tool tips +SeeAlso: ??? + +Feature: VALIDATOR +Section: Widgets +Retquires: +Name: Input validators +SeeAlso: ??? + +Feature: WHATSTHIS +Section: Widgets +Retquires: TOOLTIP TOOLBUTTON +Name: "What's this" help +SeeAlso: ??? + +Feature: WIDGETSTACK +Section: Widgets +Retquires: FRAME +Name: Widget stacks +SeeAlso: ??? + +Feature: TEXTBROWSER +Section: Widgets +Retquires: TEXTVIEW MIME +Name: QTextBrowser +SeeAlso: ??? + +Feature: LISTBOX +Section: Widgets +Retquires: SCROLLVIEW STRINGLIST +Name: QListBox +SeeAlso: ??? + +Feature: ACCEL +Section: Kernel +Retquires: SPRINTF +Name: Keyboard accelerators and shortcuts +SeeAlso: ??? + +Feature: SIZEGRIP +Section: Widgets +Retquires: STYLE +Name: QSizeGrip +SeeAlso: ??? + +Feature: HEADER +Section: Widgets +Retquires: STYLE ICONSET +Name: QHeader +SeeAlso: ??? + +Feature: TITLEBAR +Section: Kernel +Retquires: STYLE +Name: Internal titlebar widget +SeeAlso: ??? + +Feature: LCDNUMBER +Section: Widgets +Retquires: FRAME +Name: QLCDNumber +SeeAlso: ??? + +Feature: ACTION +Section: Kernel +Retquires: TOOLBUTTON COMBOBOX +Name: QAction +SeeAlso: ??? + +Feature: COMBOBOX +Section: Widgets +Retquires: LISTBOX LINEEDIT POPUPMENU +Name: QComboBox +SeeAlso: ??? + +Feature: LISTVIEW +Section: Widgets +Retquires: SCROLLVIEW HEADER LINEEDIT +Name: QListView +SeeAlso: ??? + +Feature: STYLE_WINDOWS +Section: Widgets +Retquires: STYLE +Name: Windows style +SeeAlso: ??? + +Feature: STYLE_MOTIF +Section: Widgets +Retquires: STYLE +Name: Motif style +SeeAlso: ??? + +Feature: STYLE_INTERLACE +Section: Widgets +Retquires: STYLE_MOTIF +Name: Interlace-friendly style +SeeAlso: ??? + +Feature: STYLE_COMPACT +Section: Widgets +Retquires: STYLE_WINDOWS +Name: Compact Windows style +SeeAlso: ??? + +Feature: STYLE_PLATINUM +Section: Widgets +Retquires: STYLE_WINDOWS +Name: Platinum style +SeeAlso: ??? + +Feature: STYLE_AQUA +Section: Widgets +Retquires: STYLE_WINDOWS IMAGE_TRANSFORMATION +Name: Aqua style +SeeAlso: ??? + +Feature: STYLE_CDE +Section: Widgets +Retquires: STYLE_MOTIF TRANSFORMATIONS +Name: CDE style +SeeAlso: ??? + +Feature: STYLE_SGI +Section: Widgets +Retquires: STYLE_MOTIF TRANSFORMATIONS BUTTON SCROLLBAR SLIDER LINEEDIT MENUBAR +Name: SGI style +SeeAlso: ??? + +Feature: STYLE_MOTIFPLUS +Section: Widgets +Retquires: STYLE_MOTIF TRANSFORMATIONS BUTTON SCROLLBAR SLIDER +Name: Motif-plus style +SeeAlso: ??? + +Feature: COLORDIALOG +Section: Widgets +Retquires: DIALOG LABEL PUSHBUTTON LINEEDIT VALIDATOR GRIDVIEW LAYOUT +Name: QColorDialog +SeeAlso: ??? + +Feature: MESSAGEBOX +Section: Widgets +Retquires: DIALOG PUSHBUTTON LABEL +Name: QMessageBox +SeeAlso: ??? + +Feature: TABDIALOG +Section: Widgets +Retquires: DIALOG PUSHBUTTON LAYOUT TABWIDGET +Name: QTabDialog +SeeAlso: ??? + +Feature: WIZARD +Section: Widgets +Retquires: DIALOG WIDGETSTACK PUSHBUTTON LAYOUT LABEL +Name: QWizard +SeeAlso: ??? + +Feature: FILEDIALOG +Section: Widgets +Retquires: MESSAGEBOX LISTVIEW NETWORKPROTOCOL COMBOBOX SEMIMODAL REGEXP_CAPTURE TOOLBUTTON BUTTONGROUP VBOX SPLITTER PROGRESSBAR WIDGETSTACK DATESTRING +Name: QFileDialog +SeeAlso: ??? + +Feature: FONTDIALOG +Section: Widgets +Retquires: DIALOG FONTDATABASE COMBOBOX LABEL CHECKBOX PUSHBUTTON VGROUPBOX VALIDATOR +Name: QFontDialog +SeeAlso: ??? + +Feature: PRINTDIALOG +Section: Widgets +Retquires: DIALOG LISTVIEW PRINTER COMBOBOX LABEL BUTTONGROUP SPINBOX RADIOBUTTON PUSHBUTTON DIR +Name: QPrintDialog +SeeAlso: ??? + +Feature: PROGRESSDIALOG +Section: Widgets +Retquires: SEMIMODAL LABEL PUSHBUTTON PROGRESSBAR +Name: QProgressDialog +SeeAlso: ??? + +Feature: INPUTDIALOG +Section: Widgets +Retquires: DIALOG COMBOBOX LABEL PUSHBUTTON SPINBOX WIDGETSTACK LAYOUT +Name: QInputDialog +SeeAlso: ??? + +Feature: ERRORMESSAGE +Section: Widgets +Retquires: DIALOG PUSHBUTTON LABEL CHECKBOX TEXTVIEW +Name: QErrorMessage +SeeAlso: ??? + +Feature: SESSIONMANAGER +Section: Kernel +Retquires: STRINGLIST +Name: Session management +SeeAlso: ??? + +Feature: DATETIMEEDIT +Section: Widgets +Retquires: RICHTEXT SPINWIDGET DATESTRING +Name: QDateTimeEdit +SeeAlso: ??? + +Feature: TEXTCODECPLUGIN +Section: Internationalization +Retquires: COMPONENT TEXTCODEC +Name: QTextCodecPlugin +SeeAlso: ??? + + +Feature: IMAGEFORMATPLUGIN +Section: Images +Retquires: COMPONENT IMAGEIO +Name: QImageFormatPlugin +SeeAlso: ??? + + +Feature: WIDGETPLUGIN +Section: Widgets +Retquires: COMPONENT ICONSET +Name: QWidgetPlugin +SeeAlso: ??? + + +Feature: DIRECTPAINTER +Section: Painting +Retquires: +Name: QDirectPainter +SeeAlso: ??? + + +Feature: DIALOGBUTTONS +Section: Widgets +Retquires: LAYOUT STYLE PUSHBUTTON +Name: Experimental internal class +SeeAlso: ??? diff --git a/src/tools/qfile.cpp b/src/tools/qfile.cpp new file mode 100644 index 000000000..3a92f3470 --- /dev/null +++ b/src/tools/qfile.cpp @@ -0,0 +1,747 @@ +/**************************************************************************** +** +** Implementation of TQFile class +** +** Created : 930812 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "qplatformdefs.h" + +// POSIX Large File Support redefines open -> open64 +#if defined(open) +# undef open +#endif + +// POSIX Large File Support redefines truncate -> truncate64 +#if defined(truncate) +# undef truncate +#endif + +#include "qfile.h" +#ifndef NO_ERRNO_H +#include +#endif + + +// Duplicated from qobject.h, but we cannot include qobject.h here since +// it causes qmake to not build on irix g++ +#define QT_TRANSLATE_NOOP(scope,x) (x) + +const char* qt_fileerr_unknown = QT_TRANSLATE_NOOP( "TQFile", "Unknown error" ); +const char* qt_fileerr_read = QT_TRANSLATE_NOOP( "TQFile", "Could not read from the file" ); +const char* qt_fileerr_write = QT_TRANSLATE_NOOP( "TQFile", "Could not write to the file" ); + +#define TQFILEERR_EACCES QT_TRANSLATE_NOOP( "TQFile", "Permission denied" ) +#define TQFILEERR_EMFILE QT_TRANSLATE_NOOP( "TQFile", "Too many open files" ) +#define TQFILEERR_ENOENT QT_TRANSLATE_NOOP( "TQFile", "No such file or directory" ) +#define TQFILEERR_ENOSPC QT_TRANSLATE_NOOP( "TQFile", "No space left on device" ) + +class TQFilePrivate +{ +public: + TQString errorString; +}; + +extern bool qt_file_access( const TQString& fn, int t ); + +/*! + \class TQFile qfile.h + \reentrant + \brief The TQFile class is an I/O device that operates on files. + + \ingroup io + \mainclass + + TQFile is an I/O device for reading and writing binary and text + files. A TQFile may be used by itself or more conveniently with a + TQDataStream or TQTextStream. + + The file name is usually passed in the constructor but can be + changed with setName(). You can check for a file's existence with + exists() and remove a file with remove(). + + The file is opened with open(), closed with close() and flushed + with flush(). Data is usually read and written using TQDataStream + or TQTextStream, but you can read with readBlock() and readLine() + and write with writeBlock(). TQFile also supports getch(), + ungetch() and putch(). + + The size of the file is returned by size(). You can get the + current file position or move to a new file position using the + at() functions. If you've reached the end of the file, atEnd() + returns TRUE. The file handle is returned by handle(). + + Here is a code fragment that uses TQTextStream to read a text file + line by line. It prints each line with a line number. + \code + TQStringList lines; + TQFile file( "file.txt" ); + if ( file.open( IO_ReadOnly ) ) { + TQTextStream stream( &file ); + TQString line; + int i = 1; + while ( !stream.atEnd() ) { + line = stream.readLine(); // line of text excluding '\n' + printf( "%3d: %s\n", i++, line.latin1() ); + lines += line; + } + file.close(); + } + \endcode + + Writing text is just as easy. The following example shows how to + write the data we read into the string list from the previous + example: + \code + TQFile file( "file.txt" ); + if ( file.open( IO_WriteOnly ) ) { + TQTextStream stream( &file ); + for ( TQStringList::Iterator it = lines.begin(); it != lines.end(); ++it ) + stream << *it << "\n"; + file.close(); + } + \endcode + + The TQFileInfo class holds detailed information about a file, such + as access permissions, file dates and file types. + + The TQDir class manages directories and lists of file names. + + TQt uses Unicode file names. If you want to do your own I/O on Unix + systems you may want to use encodeName() (and decodeName()) to + convert the file name into the local encoding. + + \important readAll() at() + + \sa TQDataStream, TQTextStream +*/ + +/*! + \fn Q_LONG TQFile::writeBlock( const TQByteArray& data ) + + \overload +*/ + + +/*! + Constructs a TQFile with no name. +*/ + +TQFile::TQFile() +: d(0) +{ + init(); +} + +/*! + Constructs a TQFile with a file name \a name. + + \sa setName() +*/ + +TQFile::TQFile( const TQString &name ) + : fn(name), d(0) +{ + init(); +} + + +/*! + Destroys a TQFile. Calls close(). +*/ + +TQFile::~TQFile() +{ + close(); + delete d; +} + + +/*! + \internal + Initialize internal data. +*/ + +void TQFile::init() +{ + delete d; + d = new TQFilePrivate; + setFlags( IO_Direct ); + setStatus( IO_Ok ); + setErrorString( qt_fileerr_unknown ); + fh = 0; + fd = 0; + length = 0; + ioIndex = 0; + ext_f = FALSE; // not an external file handle +} + + +/*! + \fn TQString TQFile::name() const + + Returns the name set by setName(). + + \sa setName(), TQFileInfo::fileName() +*/ + +/*! + Sets the name of the file to \a name. The name can have no path, a + relative path or an absolute absolute path. + + Do not call this function if the file has already been opened. + + If the file name has no path or a relative path, the path used + will be whatever the application's current directory path is + \e{at the time of the open()} call. + + Example: + \code + TQFile file; + TQDir::setCurrent( "/tmp" ); + file.setName( "readme.txt" ); + TQDir::setCurrent( "/home" ); + file.open( IO_ReadOnly ); // opens "/home/readme.txt" under Unix + \endcode + + Note that the directory separator "/" works for all operating + systems supported by TQt. + + \sa name(), TQFileInfo, TQDir +*/ + +void TQFile::setName( const TQString &name ) +{ + if ( isOpen() ) { +#if defined(QT_CHECK_STATE) + qWarning( "TQFile::setName: File is open" ); +#endif + close(); + } + fn = name; +} + +/*! + \overload + + Returns TRUE if this file exists; otherwise returns FALSE. + + \sa name() +*/ + +bool TQFile::exists() const +{ + return qt_file_access( fn, F_OK ); +} + +/*! + Returns TRUE if the file given by \a fileName exists; otherwise + returns FALSE. +*/ + +bool TQFile::exists( const TQString &fileName ) +{ + return qt_file_access( fileName, F_OK ); +} + + +/*! + Removes the file specified by the file name currently set. Returns + TRUE if successful; otherwise returns FALSE. + + The file is closed before it is removed. +*/ + +bool TQFile::remove() +{ + close(); + return remove( fn ); +} + +#if defined(Q_OS_MAC) || defined(Q_OS_MSDOS) || defined(Q_OS_WIN32) || defined(Q_OS_OS2) +# define HAS_TEXT_FILEMODE // has translate/text filemode +#endif +#if defined(O_NONBLOCK) +# define HAS_ASYNC_FILEMODE +# define OPEN_ASYNC O_NONBLOCK +#elif defined(O_NDELAY) +# define HAS_ASYNC_FILEMODE +# define OPEN_ASYNC O_NDELAY +#endif + +/*! + Flushes the file buffer to the disk. + + close() also flushes the file buffer. +*/ + +void TQFile::flush() +{ + if ( isOpen() && fh ) { // can only flush open/buffered file + if ( fflush( fh ) ) { // write error + if ( errno == ENOSPC ) // disk is full + setStatus( IO_ResourceError ); + else + setStatus( IO_WriteError ); + setErrorStringErrno( errno ); + } + } +} + +/*! \reimp + \fn TQIODevice::Offset TQFile::at() const +*/ + +/*! + Returns TRUE if the end of file has been reached; otherwise returns FALSE. + If TQFile has not been open()'d, then the behavior is undefined. + + \sa size() +*/ + +bool TQFile::atEnd() const +{ + if ( !isOpen() ) { +#if defined(QT_CHECK_STATE) + qWarning( "TQFile::atEnd: File is not open" ); +#endif + return FALSE; + } + if ( isDirectAccess() && !isTranslated() ) { + if ( at() < size() ) + return FALSE; + } + const TQString errorString = d->errorString; + const bool ret = TQIODevice::atEnd(); + if (errorString != d->errorString) + d->errorString = errorString; + return ret; +} + +/*! + Reads a line of text. + + Reads bytes from the file into the char* \a p, until end-of-line + or \a maxlen bytes have been read, whichever occurs first. Returns + the number of bytes read, or -1 if there was an error. Any + terminating newline is not stripped. + + This function is only efficient for buffered files. Avoid + readLine() for files that have been opened with the \c IO_Raw + flag. + + \sa readBlock(), TQTextStream::readLine() +*/ + +Q_LONG TQFile::readLine( char *p, Q_ULONG maxlen ) +{ + if ( maxlen == 0 ) // application bug? + return 0; +#if defined(QT_CHECK_STATE) + Q_CHECK_PTR( p ); + if ( !isOpen() ) { // file not open + qWarning( "TQFile::readLine: File not open" ); + return -1; + } + if ( !isReadable() ) { // reading not permitted + qWarning( "TQFile::readLine: Read operation not permitted" ); + return -1; + } +#endif + Q_LONG nread; // number of bytes read + if ( isRaw() ) { // raw file + nread = TQIODevice::readLine( p, maxlen ); + } else { // buffered file + p = fgets( p, maxlen, fh ); + if ( p ) { + nread = qstrlen( p ); + if ( !isSequentialAccess() ) + ioIndex += nread; + } else { + nread = -1; + setStatus(IO_ReadError); + setErrorString( qt_fileerr_read ); + } + } + return nread; +} + + +/*! + \overload + + Reads a line of text. + + Reads bytes from the file into string \a s, until end-of-line or + \a maxlen bytes have been read, whichever occurs first. Returns + the number of bytes read, or -1 if there was an error, e.g. end of + file. Any terminating newline is not stripped. + + This function is only efficient for buffered files. Avoid using + readLine() for files that have been opened with the \c IO_Raw + flag. + + Note that the string is read as plain Latin1 bytes, not Unicode. + + \sa readBlock(), TQTextStream::readLine() +*/ + +Q_LONG TQFile::readLine( TQString& s, Q_ULONG maxlen ) +{ + TQByteArray ba(maxlen); + Q_LONG l = readLine(ba.data(),maxlen); + if ( l >= 0 ) { + ba.truncate(l); + s = TQString(ba); + } + return l; +} + + +/*! + Reads a single byte/character from the file. + + Returns the byte/character read, or -1 if the end of the file has + been reached. + + \sa putch(), ungetch() +*/ + +int TQFile::getch() +{ +#if defined(QT_CHECK_STATE) + if ( !isOpen() ) { // file not open + qWarning( "TQFile::getch: File not open" ); + return EOF; + } + if ( !isReadable() ) { // reading not permitted + qWarning( "TQFile::getch: Read operation not permitted" ); + return EOF; + } +#endif + + int ch; + + if ( !ungetchBuffer.isEmpty() ) { + int len = ungetchBuffer.length(); + ch = ungetchBuffer[ len-1 ]; + ungetchBuffer.truncate( len - 1 ); + return ch; + } + + if ( isRaw() ) { // raw file (inefficient) + char buf[1]; + ch = readBlock( buf, 1 ) == 1 ? buf[0] : EOF; + } else { // buffered file + if ( (ch = getc( fh )) != EOF ) { + if ( !isSequentialAccess() ) + ioIndex++; + } else { + setStatus(IO_ReadError); + setErrorString( qt_fileerr_read ); + } + } + return ch; +} + +/*! + Writes the character \a ch to the file. + + Returns \a ch, or -1 if some error occurred. + + \sa getch(), ungetch() +*/ + +int TQFile::putch( int ch ) +{ +#if defined(QT_CHECK_STATE) + if ( !isOpen() ) { // file not open + qWarning( "TQFile::putch: File not open" ); + return EOF; + } + if ( !isWritable() ) { // writing not permitted + qWarning( "TQFile::putch: Write operation not permitted" ); + return EOF; + } +#endif + if ( isRaw() ) { // raw file (inefficient) + char buf[1]; + buf[0] = ch; + ch = writeBlock( buf, 1 ) == 1 ? ch : EOF; + } else { // buffered file + if ( (ch = putc( ch, fh )) != EOF ) { + if ( !isSequentialAccess() ) + ioIndex++; + if ( ioIndex > length ) // update file length + length = ioIndex; + } else { + setStatus(IO_WriteError); + setErrorString( qt_fileerr_write ); + } + } + return ch; +} + +/*! + Puts the character \a ch back into the file and decrements the + index if it is not zero. + + This function is normally called to "undo" a getch() operation. + + Returns \a ch, or -1 if an error occurred. + + \sa getch(), putch() +*/ + +int TQFile::ungetch( int ch ) +{ +#if defined(QT_CHECK_STATE) + if ( !isOpen() ) { // file not open + qWarning( "TQFile::ungetch: File not open" ); + return EOF; + } + if ( !isReadable() ) { // reading not permitted + qWarning( "TQFile::ungetch: Read operation not permitted" ); + return EOF; + } +#endif + if ( ch == EOF ) // cannot unget EOF + return ch; + + if ( isSequentialAccess() && !fh) { + // pipe or similar => we cannot ungetch, so do it manually + ungetchBuffer += TQChar(ch); + return ch; + } + + if ( isRaw() ) { // raw file (very inefficient) + char buf[1]; + at( ioIndex-1 ); + buf[0] = ch; + if ( writeBlock(buf, 1) == 1 ) + at ( ioIndex-1 ); + else + ch = EOF; + } else { // buffered file + if ( (ch = ungetc(ch, fh)) != EOF ) { + if ( !isSequentialAccess() ) + ioIndex--; + } else { + setStatus( IO_ReadError ); + setErrorString( qt_fileerr_read ); + } + } + return ch; +} + + +static TQCString locale_encoder( const TQString &fileName ) +{ + return fileName.local8Bit(); +} + + +static TQFile::EncoderFn encoder = locale_encoder; + +/*! + When you use TQFile, TQFileInfo, and TQDir to access the file system + with TQt, you can use Unicode file names. On Unix, these file names + are converted to an 8-bit encoding. If you want to do your own + file I/O on Unix, you should convert the file name using this + function. On Windows NT/2000, Unicode file names are supported + directly in the file system and this function should be avoided. + On Windows 95, non-Latin1 locales are not supported. + + By default, this function converts \a fileName to the local 8-bit + encoding determined by the user's locale. This is sufficient for + file names that the user chooses. File names hard-coded into the + application should only use 7-bit ASCII filename characters. + + The conversion scheme can be changed using setEncodingFunction(). + This might be useful if you wish to give the user an option to + store file names in UTF-8, etc., but be aware that such file names + would probably then be unrecognizable when seen by other programs. + + \sa decodeName() +*/ + +TQCString TQFile::encodeName( const TQString &fileName ) +{ + return (*encoder)(fileName); +} + +/*! + \enum TQFile::EncoderFn + + This is used by TQFile::setEncodingFunction(). +*/ + +/*! + \nonreentrant + + Sets the function for encoding Unicode file names to \a f. The + default encodes in the locale-specific 8-bit encoding. + + \sa encodeName() +*/ +void TQFile::setEncodingFunction( EncoderFn f ) +{ + encoder = f; +} + +static +TQString locale_decoder( const TQCString &localFileName ) +{ +#ifndef Q_WS_MAC + return TQString::fromLocal8Bit(localFileName); +#else + extern TQString qt_mac_precomposeFileName(const TQString &); // qglobal.cpp + return qt_mac_precomposeFileName(TQString::fromLocal8Bit(localFileName)); +#endif +} + +static TQFile::DecoderFn decoder = locale_decoder; + +/*! + This does the reverse of TQFile::encodeName() using \a localFileName. + + \sa setDecodingFunction() +*/ +TQString TQFile::decodeName( const TQCString &localFileName ) +{ + return (*decoder)(localFileName); +} + +/*! + \enum TQFile::DecoderFn + + This is used by TQFile::setDecodingFunction(). +*/ + +/*! + \nonreentrant + + Sets the function for decoding 8-bit file names to \a f. The + default uses the locale-specific 8-bit encoding. + + \sa encodeName(), decodeName() +*/ + +void TQFile::setDecodingFunction( DecoderFn f ) +{ + decoder = f; +} + +/*! + Returns a human-readable description of the reason of an error that occurred + on the device. The error described by the string corresponds to changes of + TQIODevice::status(). If the status is reset, the error string is also reset. + + The returned strings are not translated with the TQObject::tr() or + TQApplication::translate() functions. They are marked as translatable + strings in the "TQFile" context. Before you show the string to the user you + should translate it first, for example: + + \code + TQFile f( "address.dat" ); + if ( !f.open( IO_ReadOnly ) { + TQMessageBox::critical( + this, + tr("Open failed"), + tr("Could not open file for reading: %1").arg( qApp->translate("TQFile",f.errorString()) ) + ); + return; + } + \endcode + + \sa TQIODevice::status(), TQIODevice::resetStatus(), setErrorString() +*/ + +TQString TQFile::errorString() const +{ + if ( status() == IO_Ok ) + return qt_fileerr_unknown; + return d->errorString; +} + +/*! + \nonreentrant + + Sets the error string returned by the errorString() function to \a str. + + \sa errorString(), TQIODevice::status() +*/ + +void TQFile::setErrorString( const TQString& str ) +{ + d->errorString = str; +} + +void TQFile::setErrorStringErrno( int errnum ) +{ + switch ( errnum ) { + case EACCES: + d->errorString = TQFILEERR_EACCES; + break; + case EMFILE: + d->errorString = TQFILEERR_EMFILE; + break; + case ENOENT: + d->errorString = TQFILEERR_ENOENT; + break; + case ENOSPC: + d->errorString = TQFILEERR_ENOSPC; + break; + default: +#ifndef Q_OS_TEMP + d->errorString = TQString::fromLocal8Bit( strerror( errnum ) ); +#else + { + unsigned short *string; + FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM, + NULL, + errnum, + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + (LPTSTR)&string, + 0, + NULL ); + d->errorString = TQString::fromUcs2( string ); + LocalFree( (HLOCAL)string ); + } +#endif + break; + } +} diff --git a/src/tools/qfile.h b/src/tools/qfile.h new file mode 100644 index 000000000..f1a418881 --- /dev/null +++ b/src/tools/qfile.h @@ -0,0 +1,131 @@ +/**************************************************************************** +** +** Definition of TQFile class +** +** Created : 930831 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQFILE_H +#define TQFILE_H + +#ifndef QT_H +#include "qiodevice.h" +#include "qstring.h" +#include +#endif // QT_H + +class TQDir; +class TQFilePrivate; + +class Q_EXPORT TQFile : public TQIODevice // file I/O device class +{ +public: + TQFile(); + TQFile( const TQString &name ); + ~TQFile(); + + TQString name() const; + void setName( const TQString &name ); + + typedef TQCString (*EncoderFn)( const TQString &fileName ); + typedef TQString (*DecoderFn)( const TQCString &localfileName ); + static TQCString encodeName( const TQString &fileName ); + static TQString decodeName( const TQCString &localFileName ); + static void setEncodingFunction( EncoderFn ); + static void setDecodingFunction( DecoderFn ); + + bool exists() const; + static bool exists( const TQString &fileName ); + + bool remove(); + static bool remove( const TQString &fileName ); + + bool open( int ); + bool open( int, FILE * ); + bool open( int, int ); + void close(); + void flush(); + + Offset size() const; + Offset at() const; + bool at( Offset ); + bool atEnd() const; + + Q_LONG readBlock( char *data, Q_ULONG len ); + Q_LONG writeBlock( const char *data, Q_ULONG len ); + Q_LONG writeBlock( const TQByteArray& data ) + { return TQIODevice::writeBlock(data); } + Q_LONG readLine( char *data, Q_ULONG maxlen ); + Q_LONG readLine( TQString &, Q_ULONG maxlen ); + + int getch(); + int putch( int ); + int ungetch( int ); + + int handle() const; + + TQString errorString() const; // ### TQt 4: move into TQIODevice + +protected: + void setErrorString( const TQString& ); // ### TQt 4: move into TQIODevice + TQString fn; + FILE *fh; + int fd; + Offset length; + bool ext_f; + TQFilePrivate *d; // ### TQt 4: make private + +private: + void init(); + void setErrorStringErrno( int ); + TQCString ungetchBuffer; + +private: // Disabled copy constructor and operator= +#if defined(Q_DISABLE_COPY) + TQFile( const TQFile & ); + TQFile &operator=( const TQFile & ); +#endif +}; + + +inline TQString TQFile::name() const +{ return fn; } + +inline TQIODevice::Offset TQFile::at() const +{ return ioIndex; } + + +#endif // TQFILE_H diff --git a/src/tools/qfile_unix.cpp b/src/tools/qfile_unix.cpp new file mode 100644 index 000000000..106ac57d7 --- /dev/null +++ b/src/tools/qfile_unix.cpp @@ -0,0 +1,746 @@ +/**************************************************************************** +** +** Implementation of TQFile class +** +** Created : 950628 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "qplatformdefs.h" + +// POSIX Large File Support redefines open -> open64 +static inline int qt_open(const char *pathname, int flags, mode_t mode) +{ return ::open(pathname, flags, mode); } +#if defined(open) +# undef open +#endif + +// POSIX Large File Support redefines truncate -> truncate64 +#if defined(truncate) +# undef truncate +#endif + +#include "qfile.h" +#include +#include + +extern const char* qt_fileerr_read; + +bool qt_file_access( const TQString& fn, int t ) +{ + if ( fn.isEmpty() ) + return FALSE; + return ::access( TQFile::encodeName(fn), t ) == 0; +} + +/*! + \overload + Removes the file \a fileName. + Returns TRUE if successful, otherwise FALSE. +*/ + +bool TQFile::remove( const TQString &fileName ) +{ + if ( fileName.isEmpty() ) { +#if defined(QT_CHECK_NULL) + qWarning( "TQFile::remove: Empty or null file name" ); +#endif + return FALSE; + } + return unlink( TQFile::encodeName(fileName) ) == 0; +} + +#if defined(O_NONBLOCK) +# define HAS_ASYNC_FILEMODE +# define OPEN_ASYNC O_NONBLOCK +#elif defined(O_NDELAY) +# define HAS_ASYNC_FILEMODE +# define OPEN_ASYNC O_NDELAY +#endif + +/*! + Opens the file specified by the file name currently set, using the + mode \a m. Returns TRUE if successful, otherwise FALSE. + + \keyword IO_Raw + \keyword IO_ReadOnly + \keyword IO_WriteOnly + \keyword IO_ReadWrite + \keyword IO_Append + \keyword IO_Truncate + \keyword IO_Translate + + The mode parameter \a m must be a combination of the following flags: + \table + \header \i Flag \i Meaning + \row \i IO_Raw + \i Raw (non-buffered) file access. + \row \i IO_ReadOnly + \i Opens the file in read-only mode. + \row \i IO_WriteOnly + \i Opens the file in write-only mode. If this flag is used + with another flag, e.g. \c IO_ReadOnly or \c IO_Raw or \c + IO_Append, the file is \e not truncated; but if used on + its own (or with \c IO_Truncate), the file is truncated. + \row \i IO_ReadWrite + \i Opens the file in read/write mode, equivalent to \c + (IO_ReadOnly | IO_WriteOnly). + \row \i IO_Append + \i Opens the file in append mode. (You must actually use \c + (IO_WriteOnly | IO_Append) to make the file writable and + to go into append mode.) This mode is very useful when you + want to write something to a log file. The file index is + set to the end of the file. Note that the result is + undefined if you position the file index manually using + at() in append mode. + \row \i IO_Truncate + \i Truncates the file. + \row \i IO_Translate + \i Enables carriage returns and linefeed translation for text + files under Windows. + \endtable + + The raw access mode is best when I/O is block-operated using a 4KB + block size or greater. Buffered access works better when reading + small portions of data at a time. + + \warning When working with buffered files, data may not be written + to the file at once. Call flush() to make sure that the data is + really written. + + \warning If you have a buffered file opened for both reading and + writing you must not perform an input operation immediately after + an output operation or vice versa. You should always call flush() + or a file positioning operation, e.g. at(), between input and + output operations, otherwise the buffer may contain garbage. + + If the file does not exist and \c IO_WriteOnly or \c IO_ReadWrite + is specified, it is created. + + Example: + \code + TQFile f1( "/tmp/data.bin" ); + f1.open( IO_Raw | IO_ReadWrite ); + + TQFile f2( "readme.txt" ); + f2.open( IO_ReadOnly | IO_Translate ); + + TQFile f3( "audit.log" ); + f3.open( IO_WriteOnly | IO_Append ); + \endcode + + \sa name(), close(), isOpen(), flush() +*/ + +bool TQFile::open( int m ) +{ + if ( isOpen() ) { // file already open +#if defined(QT_CHECK_STATE) + qWarning( "TQFile::open: File already open" ); +#endif + return FALSE; + } + if ( fn.isEmpty() ) { // no file name defined +#if defined(QT_CHECK_NULL) + qWarning( "TQFile::open: No file name specified" ); +#endif + return FALSE; + } + init(); // reset params + setMode( m ); + if ( !(isReadable() || isWritable()) ) { +#if defined(QT_CHECK_RANGE) + qWarning( "TQFile::open: File access not specified" ); +#endif + return FALSE; + } + bool ok = TRUE; + struct stat st; + if ( isRaw() ) { + int oflags = O_RDONLY; + if ( isReadable() && isWritable() ) + oflags = O_RDWR; + else if ( isWritable() ) + oflags = O_WRONLY; + if ( flags() & IO_Append ) { // append to end of file? + if ( flags() & IO_Truncate ) + oflags |= (O_CREAT | O_TRUNC); + else + oflags |= (O_APPEND | O_CREAT); + setFlags( flags() | IO_WriteOnly ); // append implies write + } else if ( isWritable() ) { // create/trunc if writable + if ( flags() & IO_Truncate ) + oflags |= (O_CREAT | O_TRUNC); + else + oflags |= O_CREAT; + } +#if defined(HAS_TEXT_FILEMODE) + if ( isTranslated() ) + oflags |= OPEN_TEXT; + else + oflags |= OPEN_BINARY; +#endif +#if defined(HAS_ASYNC_FILEMODE) + if ( isAsynchronous() ) + oflags |= OPEN_ASYNC; +#endif + fd = qt_open( TQFile::encodeName(fn), oflags, 0666 ); + + if ( fd != -1 ) { // open successful + ::fstat( fd, &st ); // get the stat for later usage + } else { + ok = FALSE; + } + } else { // buffered file I/O + TQCString perm; + char perm2[4]; + bool try_create = FALSE; + if ( flags() & IO_Append ) { // append to end of file? + setFlags( flags() | IO_WriteOnly ); // append implies write + perm = isReadable() ? "a+" : "a"; + } else { + if ( isReadWrite() ) { + if ( flags() & IO_Truncate ) { + perm = "w+"; + } else { + perm = "r+"; + try_create = TRUE; // try to create if not exists + } + } else if ( isReadable() ) { + perm = "r"; + } else if ( isWritable() ) { + perm = "w"; + } + } + qstrcpy( perm2, perm ); +#if defined(HAS_TEXT_FILEMODE) + if ( isTranslated() ) + strcat( perm2, "t" ); + else + strcat( perm2, "b" ); +#endif + for (;;) { // At most twice + + fh = fopen( TQFile::encodeName(fn), perm2 ); + + if ( !fh && try_create ) { + perm2[0] = 'w'; // try "w+" instead of "r+" + try_create = FALSE; + } else { + break; + } + } + if ( fh ) { + ::fstat( fileno(fh), &st ); // get the stat for later usage + } else { + ok = FALSE; + } + } + if ( ok ) { + setState( IO_Open ); + // on successful open the file stat was got; now test what type + // of file we have + if ( (st.st_mode & S_IFMT) != S_IFREG ) { + // non-seekable + setType( IO_Sequential ); + length = INT_MAX; + ioIndex = 0; + } else { +#if defined(QT_LARGEFILE_SUPPORT) && !defined(QT_ABI_QT4) + length = st.st_size > UINT_MAX ? UINT_MAX : (Offset)st.st_size; +#else + length = (Offset)st.st_size; +#endif + ioIndex = (flags() & IO_Append) == 0 ? 0 : length; + if ( !(flags()&IO_Truncate) && length == 0 && isReadable() ) { + // try if you can read from it (if you can, it's a sequential + // device; e.g. a file in the /proc filesystem) + int c = getch(); + if ( c != -1 ) { + ungetch(c); + setType( IO_Sequential ); + length = INT_MAX; + ioIndex = 0; + } + resetStatus(); + } + } + } else { + init(); + if ( errno == EMFILE ) // no more file handles/descrs + setStatus( IO_ResourceError ); + else + setStatus( IO_OpenError ); + setErrorStringErrno( errno ); + } + return ok; +} + +/*! + \overload + Opens a file in the mode \a m using an existing file handle \a f. + Returns TRUE if successful, otherwise FALSE. + + Example: + \code + #include + + void printError( const char* msg ) + { + TQFile f; + f.open( IO_WriteOnly, stderr ); + f.writeBlock( msg, qstrlen(msg) ); // write to stderr + f.close(); + } + \endcode + + When a TQFile is opened using this function, close() does not actually + close the file, only flushes it. + + \warning If \a f is \c stdin, \c stdout, \c stderr, you may not + be able to seek. See TQIODevice::isSequentialAccess() for more + information. + + \sa close() +*/ + +bool TQFile::open( int m, FILE *f ) +{ + if ( isOpen() ) { +#if defined(QT_CHECK_RANGE) + qWarning( "TQFile::open: File already open" ); +#endif + return FALSE; + } + init(); + setMode( m &~IO_Raw ); + setState( IO_Open ); + fh = f; + ext_f = TRUE; + struct stat st; + ::fstat( fileno(fh), &st ); +#if defined(QT_LARGEFILE_SUPPORT) +#if !defined(QT_ABI_QT4) + off_t tmp = ftello( fh ); + ioIndex = tmp > UINT_MAX ? UINT_MAX : (Offset)tmp; +#else + ioIndex = (Offset)ftello( fh ); +#endif +#else + ioIndex = (Offset)ftell( fh ); +#endif + if ( (st.st_mode & S_IFMT) != S_IFREG || f == stdin ) { //stdin is non seekable + // non-seekable + setType( IO_Sequential ); + length = INT_MAX; + ioIndex = 0; + } else { +#if defined(QT_LARGEFILE_SUPPORT) && !defined(QT_ABI_QT4) + length = st.st_size > UINT_MAX ? UINT_MAX : (Offset)st.st_size; +#else + length = (Offset)st.st_size; +#endif + if ( !(flags()&IO_Truncate) && length == 0 && isReadable() ) { + // try if you can read from it (if you can, it's a sequential + // device; e.g. a file in the /proc filesystem) + int c = getch(); + if ( c != -1 ) { + ungetch(c); + setType( IO_Sequential ); + length = INT_MAX; + ioIndex = 0; + } + resetStatus(); + } + } + return TRUE; +} + +/*! + \overload + Opens a file in the mode \a m using an existing file descriptor \a f. + Returns TRUE if successful, otherwise FALSE. + + When a TQFile is opened using this function, close() does not actually + close the file. + + The TQFile that is opened using this function, is automatically set to be in + raw mode; this means that the file input/output functions are slow. If you + run into performance issues, you should try to use one of the other open + functions. + + \warning If \a f is one of 0 (stdin), 1 (stdout) or 2 (stderr), you may not + be able to seek. size() is set to \c INT_MAX (in limits.h). + + \sa close() +*/ + + +bool TQFile::open( int m, int f ) +{ + if ( isOpen() ) { +#if defined(QT_CHECK_RANGE) + qWarning( "TQFile::open: File already open" ); +#endif + return FALSE; + } + init(); + setMode( m |IO_Raw ); + setState( IO_Open ); + fd = f; + ext_f = TRUE; + struct stat st; + ::fstat( fd, &st ); +#if defined(QT_LARGEFILE_SUPPORT) && !defined(QT_ABI_QT4) + off_t tmp = ::lseek(fd, 0, SEEK_CUR); + ioIndex = tmp > UINT_MAX ? UINT_MAX : (Offset)tmp; +#else + ioIndex = (Offset)::lseek(fd, 0, SEEK_CUR); +#endif + if ( (st.st_mode & S_IFMT) != S_IFREG || f == 0 ) { // stdin is not seekable... + // non-seekable + setType( IO_Sequential ); + length = INT_MAX; + ioIndex = 0; + } else { +#if defined(QT_LARGEFILE_SUPPORT) && !defined(QT_ABI_QT4) + length = st.st_size > UINT_MAX ? UINT_MAX : (Offset)st.st_size; +#else + length = (Offset)st.st_size; +#endif + if ( length == 0 && isReadable() ) { + // try if you can read from it (if you can, it's a sequential + // device; e.g. a file in the /proc filesystem) + int c = getch(); + if ( c != -1 ) { + ungetch(c); + setType( IO_Sequential ); + length = INT_MAX; + ioIndex = 0; + } + resetStatus(); + } + } + return TRUE; +} + +/*! + Returns the file size. + \sa at() +*/ + +TQIODevice::Offset TQFile::size() const +{ + struct stat st; + int ret = 0; + if ( isOpen() ) { + ret = ::fstat( fh ? fileno(fh) : fd, &st ); + } else { + ret = ::stat( TQFile::encodeName(fn), &st ); + } + if ( ret == -1 ) + return 0; +#if defined(QT_LARGEFILE_SUPPORT) && !defined(QT_ABI_QT4) + return (uint)st.st_size > UINT_MAX ? UINT_MAX : (Offset)st.st_size; +#else + return st.st_size; +#endif +} + + +/*! + \overload + + Sets the file index to \a pos. Returns TRUE if successful; + otherwise returns FALSE. + + Example: + \code + TQFile f( "data.bin" ); + f.open( IO_ReadOnly ); // index set to 0 + f.at( 100 ); // set index to 100 + f.at( f.at()+50 ); // set index to 150 + f.at( f.size()-80 ); // set index to 80 before EOF + f.close(); + \endcode + + Use \c at() without arguments to retrieve the file offset. + + \warning The result is undefined if the file was open()'ed using + the \c IO_Append specifier. + + \sa size(), open() +*/ + +bool TQFile::at( Offset pos ) +{ + if ( !isOpen() ) { +#if defined(QT_CHECK_STATE) + qWarning( "TQFile::at: File is not open" ); +#endif + return FALSE; + } + if ( isSequentialAccess() ) + return FALSE; + bool ok; + if ( isRaw() ) { + off_t l = ::lseek( fd, pos, SEEK_SET ); + ok = ( l != -1 ); + pos = (Offset)l; + } else { // buffered file +#if defined(QT_LARGEFILE_SUPPORT) + ok = ( ::fseeko(fh, pos, SEEK_SET) == 0 ); +#else + ok = ( ::fseek(fh, pos, SEEK_SET) == 0 ); +#endif + } + if ( ok ) +#if defined(QT_LARGEFILE_SUPPORT) && !defined(QT_ABI_QT4) + ioIndex = pos > UINT_MAX ? UINT_MAX : (Offset)pos; +#else + ioIndex = (Offset)pos; +#endif +#if defined(QT_CHECK_RANGE) + else +#if defined(QT_ABI_QT4) + qWarning( "TQFile::at: Cannot set file position %lld", pos ); +#else + qWarning( "TQFile::at: Cannot set file position %lu", pos ); +#endif +#endif + return ok; +} + +/*! + \reimp + + \warning We have experienced problems with some C libraries when a buffered + file is opened for both reading and writing. If a read operation takes place + immediately after a write operation, the read buffer contains garbage data. + Worse, the same garbage is written to the file. Calling flush() before + readBlock() solved this problem. +*/ + +Q_LONG TQFile::readBlock( char *p, Q_ULONG len ) +{ + if ( !len ) // nothing to do + return 0; + +#if defined(QT_CHECK_NULL) + if ( !p ) + qWarning( "TQFile::readBlock: Null pointer error" ); +#endif +#if defined(QT_CHECK_STATE) + if ( !isOpen() ) { + qWarning( "TQFile::readBlock: File not open" ); + return -1; + } + if ( !isReadable() ) { + qWarning( "TQFile::readBlock: Read operation not permitted" ); + return -1; + } +#endif + Q_ULONG nread = 0; // number of bytes read + if ( !ungetchBuffer.isEmpty() ) { + // need to add these to the returned string. + uint l = ungetchBuffer.length(); + while( nread < l ) { + *p = ungetchBuffer.at( l - nread - 1 ); + p++; + nread++; + } + ungetchBuffer.truncate( l - nread ); + } + + if ( nread < len ) { + if ( isRaw() ) { // raw file + nread += ::read( fd, p, len-nread ); + if ( len && nread <= 0 ) { + nread = 0; + setStatus(IO_ReadError); + setErrorStringErrno( errno ); + } + } else { // buffered file + nread += fread( p, 1, len-nread, fh ); + if ( (uint)nread != len ) { + if ( ferror( fh ) || nread==0 ) { + setStatus(IO_ReadError); + setErrorString( qt_fileerr_read ); + } + } + } + } + if ( !isSequentialAccess() ) + ioIndex += nread; + return nread; +} + + +/*! \reimp + + Writes \a len bytes from \a p to the file and returns the number of + bytes actually written. + + Returns -1 if a serious error occurred. + + \warning When working with buffered files, data may not be written + to the file at once. Call flush() to make sure the data is really + written. + + \sa readBlock() +*/ + +Q_LONG TQFile::writeBlock( const char *p, Q_ULONG len ) +{ + if ( !len ) // nothing to do + return 0; + +#if defined(QT_CHECK_NULL) + if ( p == 0 && len != 0 ) + qWarning( "TQFile::writeBlock: Null pointer error" ); +#endif +#if defined(QT_CHECK_STATE) + if ( !isOpen() ) { // file not open + qWarning( "TQFile::writeBlock: File not open" ); + return -1; + } + if ( !isWritable() ) { // writing not permitted + qWarning( "TQFile::writeBlock: Write operation not permitted" ); + return -1; + } +#endif + Q_ULONG nwritten; // number of bytes written + if ( isRaw() ) // raw file + nwritten = ::write( fd, (void *)p, len ); + else // buffered file + nwritten = fwrite( p, 1, len, fh ); + if ( nwritten != len ) { // write error + if ( errno == ENOSPC ) // disk is full + setStatus( IO_ResourceError ); + else + setStatus( IO_WriteError ); + setErrorStringErrno( errno ); + if ( !isSequentialAccess() ) { + if ( isRaw() ) { // recalc file position +#if defined(QT_LARGEFILE_SUPPORT) && !defined(QT_ABI_QT4) + off_t tmp = ::lseek( fd, 0, SEEK_CUR ); + ioIndex = tmp > UINT_MAX ? UINT_MAX : (Offset)tmp; +#else + ioIndex = (Offset)::lseek( fd, 0, SEEK_CUR ); +#endif + } else { +#if defined(QT_LARGEFILE_SUPPORT) +#if !defined(QT_ABI_QT4) + off_t tmp = (Offset)::fseeko( fh, 0, SEEK_CUR ); + ioIndex = tmp > UINT_MAX ? UINT_MAX : (Offset)tmp; +#else + ioIndex = (Offset)::fseeko( fh, 0, SEEK_CUR ); +#endif +#else + ioIndex = (Offset)::fseek( fh, 0, SEEK_CUR ); +#endif + } + } + } else { + if ( !isSequentialAccess() ) + ioIndex += nwritten; + } + if ( ioIndex > length ) // update file length + length = ioIndex; + return nwritten; +} + +/*! + Returns the file handle of the file. + + This is a small positive integer, suitable for use with C library + functions such as fdopen() and fcntl(). On systems that use file + descriptors for sockets (ie. Unix systems, but not Windows) the handle + can be used with TQSocketNotifier as well. + + If the file is not open or there is an error, handle() returns -1. + + \sa TQSocketNotifier +*/ + +int TQFile::handle() const +{ + if ( !isOpen() ) + return -1; + else if ( fh ) + return fileno( fh ); + else + return fd; +} + +/*! + Closes an open file. + + The file is not closed if it was opened with an existing file handle. + If the existing file handle is a \c FILE*, the file is flushed. + If the existing file handle is an \c int file descriptor, nothing + is done to the file. + + Some "write-behind" filesystems may report an unspecified error on + closing the file. These errors only indicate that something may + have gone wrong since the previous open(). In such a case status() + reports IO_UnspecifiedError after close(), otherwise IO_Ok. + + \sa open(), flush() +*/ + + +void TQFile::close() +{ + bool ok = FALSE; + if ( isOpen() ) { // file is not open + if ( fh ) { // buffered file + if ( ext_f ) + ok = fflush( fh ) != -1; // flush instead of closing + else + ok = fclose( fh ) != -1; + } else { // raw file + if ( ext_f ) + ok = TRUE; // cannot close + else + ok = ::close( fd ) != -1; + } + init(); // restore internal state + } + if (!ok) { + setStatus( IO_UnspecifiedError ); + setErrorStringErrno( errno ); + } +} diff --git a/src/tools/qfiledefs_p.h b/src/tools/qfiledefs_p.h new file mode 100644 index 000000000..45e5bcae8 --- /dev/null +++ b/src/tools/qfiledefs_p.h @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Common macros and system include files for TQFile, TQFileInfo and TQDir. +** +** Created : 930812 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQFILEDEFS_P_H +#define TQFILEDEFS_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the TQt API. It exists for the convenience +// of qfileinfo*.cpp. This header file may change from version to version +// without notice, or even be removed. +// +// We mean it. +// +// + +// Be sure to include qplatformdefs.h first! +struct TQFileInfoCache +{ +#if defined(Q_WS_WIN) + QT_STATBUF st; +#else + struct stat st; +#endif +}; + + +#endif diff --git a/src/tools/qfileinfo.cpp b/src/tools/qfileinfo.cpp new file mode 100644 index 000000000..4f9547deb --- /dev/null +++ b/src/tools/qfileinfo.cpp @@ -0,0 +1,710 @@ +/**************************************************************************** +** +** Implementation of TQFileInfo class +** +** Created : 950628 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "qplatformdefs.h" + +#include "qfileinfo.h" +#include "qdatetime.h" +#include "qdir.h" +#include "qfiledefs_p.h" +#include "qdeepcopy.h" +#if defined(QT_LARGEFILE_SUPPORT) && !defined(QT_ABI_QT4) +#include +#endif + + +extern bool qt_file_access( const TQString& fn, int t ); + +/*! + \class TQFileInfo + \reentrant + \brief The TQFileInfo class provides system-independent file information. + + \ingroup io + + TQFileInfo provides information about a file's name and position + (path) in the file system, its access rights and whether it is a + directory or symbolic link, etc. The file's size and last + modified/read times are also available. + + A TQFileInfo can point to a file with either a relative or an + absolute file path. Absolute file paths begin with the directory + separator "/" (or with a drive specification on Windows). Relative + file names begin with a directory name or a file name and specify + a path relative to the current working directory. An example of an + absolute path is the string "/tmp/quartz". A relative path might + look like "src/fatlib". You can use the function isRelative() to + check whether a TQFileInfo is using a relative or an absolute file + path. You can call the function convertToAbs() to convert a + relative TQFileInfo's path to an absolute path. + + The file that the TQFileInfo works on is set in the constructor or + later with setFile(). Use exists() to see if the file exists and + size() to get its size. + + To speed up performance, TQFileInfo caches information about the + file. Because files can be changed by other users or programs, or + even by other parts of the same program, there is a function that + refreshes the file information: refresh(). If you want to switch + off a TQFileInfo's caching and force it to access the file system + every time you request information from it call setCaching(FALSE). + + The file's type is obtained with isFile(), isDir() and + isSymLink(). The readLink() function provides the name of the file + the symlink points to. + + Elements of the file's name can be extracted with dirPath() and + fileName(). The fileName()'s parts can be extracted with + baseName() and extension(). + + The file's dates are returned by created(), lastModified() and + lastRead(). Information about the file's access permissions is + obtained with isReadable(), isWritable() and isExecutable(). The + file's ownership is available from owner(), ownerId(), group() and + groupId(). You can examine a file's permissions and ownership in a + single statement using the permission() function. + + If you need to read and traverse directories, see the TQDir class. +*/ + +/*! + \enum TQFileInfo::PermissionSpec + + This enum is used by the permission() function to report the + permissions and ownership of a file. The values may be OR-ed + together to test multiple permissions and ownership values. + + \value ReadOwner The file is readable by the owner of the file. + \value WriteOwner The file is writable by the owner of the file. + \value ExeOwner The file is executable by the owner of the file. + \value ReadUser The file is readable by the user. + \value WriteUser The file is writable by the user. + \value ExeUser The file is executable by the user. + \value ReadGroup The file is readable by the group. + \value WriteGroup The file is writable by the group. + \value ExeGroup The file is executable by the group. + \value ReadOther The file is readable by anyone. + \value WriteOther The file is writable by anyone. + \value ExeOther The file is executable by anyone. + + \warning The semantics of \c ReadUser, \c WriteUser and \c ExeUser are + unfortunately not platform independent: on Unix, the rights of the owner of + the file are returned and on Windows the rights of the current user are + returned. This behavior might change in a future TQt version. If you want to + find the rights of the owner of the file, you should use the flags \c + ReadOwner, \c WriteOwner and \c ExeOwner. If you want to find out the + rights of the current user, you should use isReadable(), isWritable() and + isExecutable(). +*/ + + +/*! + Constructs a new empty TQFileInfo. +*/ + +TQFileInfo::TQFileInfo() +{ + fic = 0; + cache = TRUE; +#if defined(Q_OS_UNIX) + symLink = FALSE; +#endif +} + +/*! + Constructs a new TQFileInfo that gives information about the given + file. The \a file can also include an absolute or relative path. + + \warning Some functions might behave in a counter-intuitive way + if \a file has a trailing directory separator. + + \sa setFile(), isRelative(), TQDir::setCurrent(), TQDir::isRelativePath() +*/ + +TQFileInfo::TQFileInfo( const TQString &file ) +{ + fn = file; + slashify( fn ); + fic = 0; + cache = TRUE; +#if defined(Q_OS_UNIX) + symLink = FALSE; +#endif +} + +/*! + Constructs a new TQFileInfo that gives information about file \a + file. + + If the \a file has a relative path, the TQFileInfo will also have a + relative path. + + \sa isRelative() +*/ + +TQFileInfo::TQFileInfo( const TQFile &file ) +{ + fn = file.name(); + slashify( fn ); + fic = 0; + cache = TRUE; +#if defined(Q_OS_UNIX) + symLink = FALSE; +#endif +} + +/*! + Constructs a new TQFileInfo that gives information about the file + called \a fileName in the directory \a d. + + If \a d has a relative path, the TQFileInfo will also have a + relative path. + + \sa isRelative() +*/ +#ifndef QT_NO_DIR +TQFileInfo::TQFileInfo( const TQDir &d, const TQString &fileName ) +{ + fn = d.filePath( fileName ); + slashify( fn ); + fic = 0; + cache = TRUE; +#if defined(Q_OS_UNIX) + symLink = FALSE; +#endif +} +#endif +/*! + Constructs a new TQFileInfo that is a copy of \a fi. +*/ + +TQFileInfo::TQFileInfo( const TQFileInfo &fi ) +{ + fn = fi.fn; + if ( fi.fic ) { + fic = new TQFileInfoCache; + *fic = *fi.fic; + } else { + fic = 0; + } + cache = fi.cache; +#if defined(Q_OS_UNIX) + symLink = fi.symLink; +#endif +} + +/*! + Destroys the TQFileInfo and frees its resources. +*/ + +TQFileInfo::~TQFileInfo() +{ + delete fic; +} + + +/*! + Makes a copy of \a fi and assigns it to this TQFileInfo. +*/ + +TQFileInfo &TQFileInfo::operator=( const TQFileInfo &fi ) +{ + fn = fi.fn; + if ( !fi.fic ) { + delete fic; + fic = 0; + } else { + if ( !fic ) { + fic = new TQFileInfoCache; + Q_CHECK_PTR( fic ); + } + *fic = *fi.fic; + } + cache = fi.cache; +#if defined(Q_OS_UNIX) + symLink = fi.symLink; +#endif + return *this; +} + + +/*! + Sets the file that the TQFileInfo provides information about to \a + file. + + The \a file can also include an absolute or relative file path. + Absolute paths begin with the directory separator (e.g. "/" under + Unix) or a drive specification (under Windows). Relative file + names begin with a directory name or a file name and specify a + path relative to the current directory. + + Example: + \code + TQString absolute = "/local/bin"; + TQString relative = "local/bin"; + TQFileInfo absFile( absolute ); + TQFileInfo relFile( relative ); + + TQDir::setCurrent( TQDir::rootDirPath() ); + // absFile and relFile now point to the same file + + TQDir::setCurrent( "/tmp" ); + // absFile now points to "/local/bin", + // while relFile points to "/tmp/local/bin" + \endcode + + \sa isRelative(), TQDir::setCurrent(), TQDir::isRelativePath() +*/ + +void TQFileInfo::setFile( const TQString &file ) +{ + fn = file; + slashify( fn ); + delete fic; + fic = 0; +} + +/*! + \overload + + Sets the file that the TQFileInfo provides information about to \a + file. + + If \a file includes a relative path, the TQFileInfo will also have + a relative path. + + \sa isRelative() +*/ + +void TQFileInfo::setFile( const TQFile &file ) +{ + fn = file.name(); + slashify( fn ); + delete fic; + fic = 0; +} + +/*! + \overload + + Sets the file that the TQFileInfo provides information about to \a + fileName in directory \a d. + + If \a fileName includes a relative path, the TQFileInfo will also + have a relative path. + + \sa isRelative() +*/ +#ifndef QT_NO_DIR +void TQFileInfo::setFile( const TQDir &d, const TQString &fileName ) +{ + fn = d.filePath( fileName ); + slashify( fn ); + delete fic; + fic = 0; +} +#endif + +/*! + Returns TRUE if the file exists; otherwise returns FALSE. +*/ + +bool TQFileInfo::exists() const +{ + return qt_file_access( fn, F_OK ); +} + +/*! + Refreshes the information about the file, i.e. reads in information + from the file system the next time a cached property is fetched. + + \sa setCaching() +*/ + +void TQFileInfo::refresh() const +{ + TQFileInfo *that = (TQFileInfo*)this; // Mutable function + delete that->fic; + that->fic = 0; +} + +/*! + \fn bool TQFileInfo::caching() const + + Returns TRUE if caching is enabled; otherwise returns FALSE. + + \sa setCaching(), refresh() +*/ + +/*! + If \a enable is TRUE, enables caching of file information. If \a + enable is FALSE caching is disabled. + + When caching is enabled, TQFileInfo reads the file information from + the file system the first time it's needed, but generally not + later. + + Caching is enabled by default. + + \sa refresh(), caching() +*/ + +void TQFileInfo::setCaching( bool enable ) +{ + if ( cache == enable ) + return; + cache = enable; + if ( cache ) { + delete fic; + fic = 0; + } +} + + +/*! + Returns the file name, including the path (which may be absolute + or relative). + + \sa isRelative(), absFilePath() +*/ + +TQString TQFileInfo::filePath() const +{ + return fn; +} + +/*! + Returns the base name of the file. + + If \a complete is FALSE (the default) the base name consists of + all characters in the file name up to (but not including) the \e + first '.' character. + + If \a complete is TRUE the base name consists of all characters in + the file up to (but not including) the \e last '.' character. + + The path is not included in either case. + + Example: + \code + TQFileInfo fi( "/tmp/archive.tar.gz" ); + TQString base = fi.baseName(); // base = "archive" + base = fi.baseName( TRUE ); // base = "archive.tar" + \endcode + + \sa fileName(), extension() +*/ + +TQString TQFileInfo::baseName( bool complete ) const +{ + TQString tmp = fileName(); + int pos = complete ? tmp.findRev( '.' ) : tmp.find( '.' ); + if ( pos == -1 ) + return tmp; + else + return tmp.left( pos ); +} + +/*! + Returns the file's extension name. + + If \a complete is TRUE (the default), extension() returns the + string of all characters in the file name after (but not + including) the first '.' character. + + If \a complete is FALSE, extension() returns the string of all + characters in the file name after (but not including) the last '.' + character. + + Example: + \code + TQFileInfo fi( "/tmp/archive.tar.gz" ); + TQString ext = fi.extension(); // ext = "tar.gz" + ext = fi.extension( FALSE ); // ext = "gz" + \endcode + + \sa fileName(), baseName() +*/ + +TQString TQFileInfo::extension( bool complete ) const +{ + TQString s = fileName(); + int pos = complete ? s.find( '.' ) : s.findRev( '.' ); + if ( pos < 0 ) + return TQString::fromLatin1( "" ); + else + return s.right( s.length() - pos - 1 ); +} + +/*! + Returns the file's path as a TQDir object. + + If the TQFileInfo is relative and \a absPath is FALSE, the TQDir + will be relative; otherwise it will be absolute. + + \sa dirPath(), filePath(), fileName(), isRelative() +*/ +#ifndef QT_NO_DIR +TQDir TQFileInfo::dir( bool absPath ) const +{ + return TQDir( dirPath(absPath) ); +} +#endif + + +/*! + Returns TRUE if the file is readable; otherwise returns FALSE. + + \sa isWritable(), isExecutable(), permission() +*/ + +bool TQFileInfo::isReadable() const +{ +#ifdef Q_WS_WIN + return qt_file_access( fn, R_OK ) && permission( ReadUser ); +#else + return qt_file_access( fn, R_OK ); +#endif +} + +/*! + Returns TRUE if the file is writable; otherwise returns FALSE. + + \sa isReadable(), isExecutable(), permission() +*/ + +bool TQFileInfo::isWritable() const +{ +#ifdef Q_WS_WIN + return qt_file_access( fn, W_OK ) && permission( WriteUser ); +#else + return qt_file_access( fn, W_OK ); +#endif +} + +/*! + Returns TRUE if the file is executable; otherwise returns FALSE. + + \sa isReadable(), isWritable(), permission() +*/ + +bool TQFileInfo::isExecutable() const +{ +#ifdef Q_WS_WIN +#if defined(_MSC_VER) && _MSC_VER >= 1400 + return permission( ExeUser ); +#else + return qt_file_access( fn, X_OK ) && permission( ExeUser ); +#endif //_MSC_VER >= 1400 +#else + return qt_file_access( fn, X_OK ); +#endif +} + +#ifndef Q_WS_WIN +bool TQFileInfo::isHidden() const +{ + return fileName()[ 0 ] == TQChar( '.' ); +} +#endif + +/*! + Returns TRUE if the file path name is relative. Returns FALSE if + the path is absolute (e.g. under Unix a path is absolute if it + begins with a "/"). +*/ +#ifndef QT_NO_DIR +bool TQFileInfo::isRelative() const +{ + return TQDir::isRelativePath( fn ); +} + +/*! + Converts the file's path to an absolute path. + + If it is already absolute, nothing is done. + + \sa filePath(), isRelative() +*/ + +bool TQFileInfo::convertToAbs() +{ + if ( isRelative() ) + fn = absFilePath(); + return TQDir::isRelativePath( fn ); +} +#endif + +/*! + Returns the file size in bytes, or 0 if the file does not exist or + if the size is 0 or if the size cannot be fetched. +*/ +#if defined(QT_ABI_QT4) +TQIODevice::Offset TQFileInfo::size() const +#else +uint TQFileInfo::size() const +#endif +{ + if ( !fic || !cache ) + doStat(); + if ( fic ) +#if defined(QT_ABI_QT4) + return (TQIODevice::Offset)fic->st.st_size; +#elif defined(QT_LARGEFILE_SUPPORT) + return (uint)fic->st.st_size > UINT_MAX ? UINT_MAX : (uint)fic->st.st_size; +#else + return (uint)fic->st.st_size; +#endif + else + return 0; +} + +/*! + Returns the date and time when the file was created. + + On platforms where this information is not available, returns the + same as lastModified(). + + \sa created() lastModified() lastRead() +*/ + +TQDateTime TQFileInfo::created() const +{ + TQDateTime dt; + if ( !fic || !cache ) + doStat(); + if ( fic && fic->st.st_ctime != 0 ) { + dt.setTime_t( fic->st.st_ctime ); + return dt; + } else { + return lastModified(); + } +} + +/*! + Returns the date and time when the file was last modified. + + \sa created() lastModified() lastRead() +*/ + +TQDateTime TQFileInfo::lastModified() const +{ + TQDateTime dt; + if ( !fic || !cache ) + doStat(); + if ( fic ) + dt.setTime_t( fic->st.st_mtime ); + return dt; +} + +/*! + Returns the date and time when the file was last read (accessed). + + On platforms where this information is not available, returns the + same as lastModified(). + + \sa created() lastModified() lastRead() +*/ + +TQDateTime TQFileInfo::lastRead() const +{ + TQDateTime dt; + if ( !fic || !cache ) + doStat(); + if ( fic && fic->st.st_atime != 0 ) { + dt.setTime_t( fic->st.st_atime ); + return dt; + } else { + return lastModified(); + } +} + +#ifndef QT_NO_DIR + +/*! + Returns the absolute path including the file name. + + The absolute path name consists of the full path and the file + name. On Unix this will always begin with the root, '/', + directory. On Windows this will always begin 'D:/' where D is a + drive letter, except for network shares that are not mapped to a + drive letter, in which case the path will begin '//sharename/'. + + This function returns the same as filePath(), unless isRelative() + is TRUE. + + If the TQFileInfo is empty it returns TQDir::currentDirPath(). + + This function can be time consuming under Unix (in the order of + milliseconds). + + \sa isRelative(), filePath() +*/ +TQString TQFileInfo::absFilePath() const +{ + TQString tmp; + if ( TQDir::isRelativePath(fn) +#if defined(Q_OS_WIN32) + && fn[1] != ':' +#endif + ) { + tmp = TQDir::currentDirPath(); + tmp += '/'; + } + tmp += fn; + makeAbs( tmp ); + return TQDir::cleanDirPath( tmp ); +} + +/*! \internal + Detaches all internal data. +*/ +void TQFileInfo::detach() +{ + fn = TQDeepCopy( fn ); + if ( fic ) { + TQFileInfoCache *cur = fic; + fic = new TQFileInfoCache; + *fic = *cur; + delete cur; + } +} + +#endif diff --git a/src/tools/qfileinfo.h b/src/tools/qfileinfo.h new file mode 100644 index 000000000..8cd31752d --- /dev/null +++ b/src/tools/qfileinfo.h @@ -0,0 +1,157 @@ +/**************************************************************************** +** +** Definition of TQFileInfo class +** +** Created : 950628 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQFILEINFO_H +#define TQFILEINFO_H + +#ifndef QT_H +#include "qfile.h" +#include "qdatetime.h" +#endif // QT_H + + +class TQDir; +struct TQFileInfoCache; +template class TQDeepCopy; + + +class Q_EXPORT TQFileInfo +{ +public: + enum PermissionSpec { + ReadOwner = 04000, WriteOwner = 02000, ExeOwner = 01000, + ReadUser = 00400, WriteUser = 00200, ExeUser = 00100, + ReadGroup = 00040, WriteGroup = 00020, ExeGroup = 00010, + ReadOther = 00004, WriteOther = 00002, ExeOther = 00001 }; + + TQFileInfo(); + TQFileInfo( const TQString &file ); + TQFileInfo( const TQFile & ); +#ifndef QT_NO_DIR + TQFileInfo( const TQDir &, const TQString &fileName ); +#endif + TQFileInfo( const TQFileInfo & ); + ~TQFileInfo(); + + TQFileInfo &operator=( const TQFileInfo & ); + + void setFile( const TQString &file ); + void setFile( const TQFile & ); +#ifndef QT_NO_DIR + void setFile( const TQDir &, const TQString &fileName ); +#endif + bool exists() const; + void refresh() const; + bool caching() const; + void setCaching( bool ); + + TQString filePath() const; + TQString fileName() const; +#ifndef QT_NO_DIR //### + TQString absFilePath() const; +#endif + TQString baseName( bool complete = FALSE ) const; + TQString extension( bool complete = TRUE ) const; + +#ifndef QT_NO_DIR //### + TQString dirPath( bool absPath = FALSE ) const; +#endif +#ifndef QT_NO_DIR + TQDir dir( bool absPath = FALSE ) const; +#endif + bool isReadable() const; + bool isWritable() const; + bool isExecutable() const; + bool isHidden() const; + +#ifndef QT_NO_DIR //### + bool isRelative() const; + bool convertToAbs(); +#endif + + bool isFile() const; + bool isDir() const; + bool isSymLink() const; + + TQString readLink() const; + + TQString owner() const; + uint ownerId() const; + TQString group() const; + uint groupId() const; + + bool permission( int permissionSpec ) const; + +#if (QT_VERSION-0 >= 0x040000) +#error "TQFileInfo::size() should return TQIODevice::Offset instead of uint" +#elif defined(QT_ABI_QT4) + TQIODevice::Offset size() const; +#else + uint size() const; +#endif + + TQDateTime created() const; + TQDateTime lastModified() const; + TQDateTime lastRead() const; + +private: + void doStat() const; + static void slashify( TQString & ); + static void makeAbs( TQString & ); + + TQString fn; + TQFileInfoCache *fic; + bool cache; +#if defined(Q_OS_UNIX) + bool symLink; +#endif + + void detach(); + friend class TQDeepCopy< TQFileInfo >; +}; + + +inline bool TQFileInfo::caching() const +{ + return cache; +} + + +#endif // TQFILEINFO_H diff --git a/src/tools/qfileinfo_unix.cpp b/src/tools/qfileinfo_unix.cpp new file mode 100644 index 000000000..25afb3be8 --- /dev/null +++ b/src/tools/qfileinfo_unix.cpp @@ -0,0 +1,400 @@ +/**************************************************************************** +** +** Implementation of TQFileInfo class +** +** Created : 950628 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "qplatformdefs.h" +#include "qfileinfo.h" +#include "qfiledefs_p.h" +#include "qdatetime.h" +#include "qdir.h" + +#include +#if !defined(TQWS) && defined(Q_OS_MAC) +# include +#endif +#if defined(Q_OS_HURD) +# include +#endif + +void TQFileInfo::slashify( TQString& ) +{ + return; +} + + +void TQFileInfo::makeAbs( TQString & ) +{ + return; +} + +/*! + Returns TRUE if this object points to a file. Returns FALSE if the + object points to something which isn't a file, e.g. a directory or + a symlink. + + \sa isDir(), isSymLink() +*/ +bool TQFileInfo::isFile() const +{ + if ( !fic || !cache ) + doStat(); + return fic ? (fic->st.st_mode & S_IFMT) == S_IFREG : FALSE; +} + +/*! + Returns TRUE if this object points to a directory or to a symbolic + link to a directory; otherwise returns FALSE. + + \sa isFile(), isSymLink() +*/ +bool TQFileInfo::isDir() const +{ + if ( !fic || !cache ) + doStat(); + return fic ? (fic->st.st_mode & S_IFMT) == S_IFDIR : FALSE; +} + +/*! + Returns TRUE if this object points to a symbolic link (or to a + shortcut on Windows, or an alias on Mac OS X); otherwise returns + FALSE. + + \sa isFile(), isDir(), readLink() +*/ + +bool TQFileInfo::isSymLink() const +{ + if ( !fic || !cache ) + doStat(); + if(symLink) + return TRUE; +#if !defined(TQWS) && defined(Q_OS_MAC) + { + FSRef fref; + if(FSPathMakeRef((const UInt8 *)TQFile::encodeName(fn).data(), &fref, NULL) == noErr) { + Boolean isAlias, isFolder; + if(FSIsAliasFile(&fref, &isAlias, &isFolder) == noErr) + return isAlias; + } + } +#endif + return FALSE; +} + +/*! + Returns the name a symlink (or shortcut on Windows) points to, or + a TQString::null if the object isn't a symbolic link. + + This name may not represent an existing file; it is only a string. + TQFileInfo::exists() returns TRUE if the symlink points to an + existing file. + + \sa exists(), isSymLink(), isDir(), isFile() +*/ + +TQString TQFileInfo::readLink() const +{ + if ( !isSymLink() ) + return TQString(); +#if defined(Q_OS_UNIX) && !defined(Q_OS_OS2EMX) +#if defined(__GLIBC__) && !defined(PATH_MAX) + int size = 256; + char *s = NULL, *s2; + + while (1) + { + s2 = (char *) realloc (s, size); + if (s2 == NULL) { + free( s ); + return TQString(); + } + s = s2; + int len = readlink ( TQFile::encodeName(fn).data(), s, size ); + if ( len < 0 ) { + free( s ); + return TQString(); + } + if ( len < size ) { + s[len] = '\0'; + TQString str = TQFile::decodeName(s); + free(s); + return str; + } + size *= 2; + } +#else + char s[PATH_MAX+1]; + int len = readlink( TQFile::encodeName(fn).data(), s, PATH_MAX ); + if ( len >= 0 ) { + s[len] = '\0'; + return TQFile::decodeName(s); + } +#endif /* __GLIBC__ && !PATH_MAX */ +#endif /* Q_OS_UNIX && !Q_OS_OS2EMX */ +#if !defined(TQWS) && defined(Q_OS_MAC) + { + FSRef fref; + if(FSPathMakeRef((const UInt8 *)TQFile::encodeName(fn).data(), &fref, NULL) == noErr) { + Boolean isAlias, isFolder; + if(FSResolveAliasFile(&fref, TRUE, &isFolder, &isAlias) == noErr && isAlias) { + AliasHandle alias; + if(FSNewAlias(0, &fref, &alias) == noErr && alias) { + CFStringRef cfstr; + if(FSCopyAliasInfo(alias, 0, 0, &cfstr, 0, 0) == noErr) { + TQString cfstring2qstring(CFStringRef str); //qglobal.cpp + return cfstring2qstring(cfstr); + } + } + } + } + } +#endif + return TQString(); +} + +static const uint nobodyID = (uint) -2; + +/*! + Returns the owner of the file. On systems where files + do not have owners, or if an error occurs, TQString::null is + returned. + + This function can be time consuming under Unix (in the order of + milliseconds). + + \sa ownerId(), group(), groupId() +*/ + +TQString TQFileInfo::owner() const +{ + passwd *pw = getpwuid( ownerId() ); + if ( pw ) + return TQFile::decodeName( pw->pw_name ); + return TQString::null; +} + +/*! + Returns the id of the owner of the file. + + On Windows and on systems where files do not have owners this + function returns ((uint) -2). + + \sa owner(), group(), groupId() +*/ + +uint TQFileInfo::ownerId() const +{ + if ( !fic || !cache ) + doStat(); + if ( fic ) + return fic->st.st_uid; + return nobodyID; +} + +/*! + Returns the group of the file. On Windows, on systems where files + do not have groups, or if an error occurs, TQString::null is + returned. + + This function can be time consuming under Unix (in the order of + milliseconds). + + \sa groupId(), owner(), ownerId() +*/ + +TQString TQFileInfo::group() const +{ + struct group *gr = getgrgid( groupId() ); + if ( gr ) + return TQFile::decodeName( gr->gr_name ); + return TQString::null; +} + +/*! + Returns the id of the group the file belongs to. + + On Windows and on systems where files do not have groups this + function always returns (uint) -2. + + \sa group(), owner(), ownerId() +*/ + +uint TQFileInfo::groupId() const +{ + if ( !fic || !cache ) + doStat(); + if ( fic ) + return fic->st.st_gid; + return nobodyID; +} + + +/*! + Tests for file permissions. The \a permissionSpec argument can be + several flags of type \c PermissionSpec OR-ed together to check + for permission combinations. + + On systems where files do not have permissions this function + always returns TRUE. + + Example: + \code + TQFileInfo fi( "/tmp/archive.tar.gz" ); + if ( fi.permission( TQFileInfo::WriteUser | TQFileInfo::ReadGroup ) ) + qWarning( "I can change the file; my group can read the file" ); + if ( fi.permission( TQFileInfo::WriteGroup | TQFileInfo::WriteOther ) ) + qWarning( "The group or others can change the file" ); + \endcode + + \sa isReadable(), isWritable(), isExecutable() +*/ + +bool TQFileInfo::permission( int permissionSpec ) const +{ + if ( !fic || !cache ) + doStat(); + if ( fic ) { + uint mask = 0; + if ( permissionSpec & ReadOwner ) + mask |= S_IRUSR; + if ( permissionSpec & WriteOwner ) + mask |= S_IWUSR; + if ( permissionSpec & ExeOwner ) + mask |= S_IXUSR; + if ( permissionSpec & ReadUser ) + mask |= S_IRUSR; + if ( permissionSpec & WriteUser ) + mask |= S_IWUSR; + if ( permissionSpec & ExeUser ) + mask |= S_IXUSR; + if ( permissionSpec & ReadGroup ) + mask |= S_IRGRP; + if ( permissionSpec & WriteGroup ) + mask |= S_IWGRP; + if ( permissionSpec & ExeGroup ) + mask |= S_IXGRP; + if ( permissionSpec & ReadOther ) + mask |= S_IROTH; + if ( permissionSpec & WriteOther ) + mask |= S_IWOTH; + if ( permissionSpec & ExeOther ) + mask |= S_IXOTH; + if ( mask ) { + return (fic->st.st_mode & mask) == mask; + } else { +#if defined(QT_CHECK_NULL) + qWarning( "TQFileInfo::permission: permissionSpec is 0" ); +#endif + return TRUE; + } + } else { + return FALSE; + } +} + +void TQFileInfo::doStat() const +{ + TQFileInfo *that = ((TQFileInfo*)this); // mutable function + if ( !that->fic ) + that->fic = new TQFileInfoCache; + that->symLink = FALSE; + struct stat *b = &that->fic->st; +#if defined(Q_OS_UNIX) && defined(S_IFLNK) + if ( ::lstat( TQFile::encodeName(fn), b ) == 0 ) { + if ( S_ISLNK( b->st_mode ) ) + that->symLink = TRUE; + else + return; + } +#endif + + int r = ::stat( TQFile::encodeName(fn), b ); + if ( r != 0 && !that->symLink ) { + delete that->fic; + that->fic = 0; + } +} + +/*! + Returns the file's path. + + If \a absPath is TRUE an absolute path is returned. + + \sa dir(), filePath(), fileName(), isRelative() +*/ +#ifndef QT_NO_DIR +TQString TQFileInfo::dirPath( bool absPath ) const +{ + TQString s; + if ( absPath ) + s = absFilePath(); + else + s = fn; + int pos = s.findRev( '/' ); + if ( pos == -1 ) { + return TQString::fromLatin1( "." ); + } else { + if ( pos == 0 ) + return TQString::fromLatin1( "/" ); + return s.left( pos ); + } +} +#endif + +/*! + Returns the name of the file, excluding the path. + + Example: + \code + TQFileInfo fi( "/tmp/archive.tar.gz" ); + TQString name = fi.fileName(); // name = "archive.tar.gz" + \endcode + + \sa isRelative(), filePath(), baseName(), extension() +*/ + +TQString TQFileInfo::fileName() const +{ + int p = fn.findRev( '/' ); + if ( p == -1 ) { + return fn; + } else { + return fn.mid( p + 1 ); + } +} diff --git a/src/tools/qgarray.cpp b/src/tools/qgarray.cpp new file mode 100644 index 000000000..4dc181e76 --- /dev/null +++ b/src/tools/qgarray.cpp @@ -0,0 +1,830 @@ +/**************************************************************************** +** +** Implementation of TQGArray class +** +** Created : 930906 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "qglobal.h" +#if defined(Q_CC_BOR) + // needed for qsort() because of a std namespace problem on Borland +# include "qplatformdefs.h" +#elif defined(Q_WS_WIN) + // needed for bsearch on some platforms +# include "qt_windows.h" +#endif + +#define TQGARRAY_CPP +#include "qgarray.h" +#include +#include + +#ifdef QT_THREAD_SUPPORT +# include +#endif // QT_THREAD_SUPPORT + +/* + If USE_MALLOC isn't defined, we use new[] and delete[] to allocate + memory. The documentation for TQMemArray::assign() explicitly + mentions that the array is freed using free(), so don't mess around + with USE_MALLOC unless you know what you're doing. +*/ +#define USE_MALLOC + +#undef NEW +#undef DELETE + +#if defined(USE_MALLOC) +#define NEW(type,size) ((type*)malloc(size*sizeof(type))) +#define DELETE(array) (free((char*)array)) +#else +#define NEW(type,size) (new type[size]) +#define DELETE(array) (delete[] array) +#define DONT_USE_REALLOC // comment to use realloc() +#endif + +/*! + \class TQShared qshared.h + \reentrant + \ingroup shared + \brief The TQShared class is used internally for implementing shared classes. + + \internal + + It only contains a reference count and member functions to increment and + decrement it. + + Shared classes normally have internal classes that inherit TQShared and + add the shared data. + + \sa \link shclass.html Shared Classes\endlink +*/ + +/*! + \class TQGArray qgarray.h + \reentrant + \ingroup shared + \ingroup collection + \brief The TQGArray class is an internal class for implementing the TQMemArray class. + + \internal + + TQGArray is a strictly internal class that acts as base class for the + TQMemArray template array. + + It contains an array of bytes and has no notion of an array element. +*/ + + +/*! + Constructs a null array. +*/ + +TQGArray::TQGArray() +{ + shd = newData(); + Q_CHECK_PTR( shd ); +} + +/*! + 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. +*/ + +TQGArray::TQGArray( int, int ) +{ +} + +/*! + Constructs an array with room for \a size bytes. +*/ + +TQGArray::TQGArray( int size ) +{ + if ( size < 0 ) { +#if defined(QT_CHECK_RANGE) + qWarning( "TQGArray: Cannot allocate array with negative length" ); +#endif + size = 0; + } + shd = newData(); + Q_CHECK_PTR( shd ); + if ( size == 0 ) // zero length + return; + shd->data = NEW(char,size); + Q_CHECK_PTR( shd->data ); + shd->len = +#ifdef QT_QGARRAY_SPEED_OPTIM + shd->maxl = +#endif + size; +} + +/*! + Constructs a shallow copy of \a a. +*/ + +TQGArray::TQGArray( const TQGArray &a ) +{ + shd = a.shd; + shd->ref(); +} + +/*! + Dereferences the array data and deletes it if this was the last + reference. +*/ + +TQGArray::~TQGArray() +{ + if ( shd && shd->deref() ) { // delete when last reference + if ( shd->data ) // is lost + DELETE(shd->data); + deleteData( shd ); + shd = 0; + } +} + + +/*! + \fn TQGArray &TQGArray::operator=( const TQGArray &a ) + + Assigns a shallow copy of \a a to this array and returns a reference to + this array. Equivalent to assign(). +*/ + +/*! + \fn void TQGArray::detach() + + Detaches this array from shared array data. +*/ + +/*! + \fn char *TQGArray::data() const + + Returns a pointer to the actual array data. +*/ + +/*! + \fn uint TQGArray::nrefs() const + + Returns the reference count. +*/ + +/*! + \fn uint TQGArray::size() const + + Returns the size of the array, in bytes. +*/ + + +/*! + Returns TRUE if this array is equal to \a a, otherwise FALSE. + The comparison is bitwise, of course. +*/ + +bool TQGArray::isEqual( const TQGArray &a ) const +{ + if ( size() != a.size() ) // different size + return FALSE; + if ( data() == a.data() ) // has same data + return TRUE; + return (size() ? memcmp( data(), a.data(), size() ) : 0) == 0; +} + + +/*! + Resizes the array to \a newsize bytes. \a optim is either + \c MemOptim (the default) or \c SpeedOptim. + + Note: \c SpeedOptim is only available if TQt is built in a + particular configuration. By default, \c SpeedOptim is not available + for general use. +*/ +bool TQGArray::resize( uint newsize, Optimization optim ) +{ +#ifndef QT_QGARRAY_SPEED_OPTIM + Q_UNUSED(optim); +#endif + + if ( newsize == shd->len +#ifdef QT_QGARRAY_SPEED_OPTIM + && newsize == shd->maxl +#endif + ) // nothing to do + return TRUE; + if ( newsize == 0 ) { // remove array + if ( shd->data ) + DELETE(shd->data); + shd->data = 0; + shd->len = 0; +#ifdef QT_QGARRAY_SPEED_OPTIM + shd->maxl = 0; +#endif + return TRUE; + } + + uint newmaxl = newsize; +#ifdef QT_QGARRAY_SPEED_OPTIM + if ( optim == SpeedOptim ) { + if ( newsize <= shd->maxl && + ( newsize * 4 > shd->maxl || shd->maxl <= 4 ) ) { + shd->len = newsize; + return TRUE; + } + newmaxl = 4; + while ( newmaxl < newsize ) + newmaxl *= 2; + // try to spare some memory + if ( newmaxl >= 1024 * 1024 && newsize <= newmaxl - (newmaxl >> 2) ) + newmaxl -= newmaxl >> 2; + } + shd->maxl = newmaxl; +#endif + + if ( shd->data ) { // existing data +#if defined(DONT_USE_REALLOC) + char *newdata = NEW(char,newsize); // manual realloc + memcpy( newdata, shd->data, TQMIN(shd->len,newmaxl) ); + DELETE(shd->data); + shd->data = newdata; +#else + shd->data = (char *)realloc( shd->data, newmaxl ); +#endif + } else { + shd->data = NEW(char,newmaxl); + } + if ( !shd->data ) // no memory + return FALSE; + shd->len = newsize; + return TRUE; +} + +/*!\overload +*/ +bool TQGArray::resize( uint newsize ) +{ + return resize( newsize, MemOptim ); +} + + +/*! + Fills the array with the repeated occurrences of \a d, which is + \a sz bytes long. + If \a len is specified as different from -1, then the array will be + resized to \a len*sz before it is filled. + + Returns TRUE if successful, or FALSE if the memory cannot be allocated + (only when \a len != -1). + + \sa resize() +*/ + +bool TQGArray::fill( const char *d, int len, uint sz ) +{ + if ( len < 0 ) + len = shd->len/sz; // default: use array length + else if ( !resize( len*sz ) ) + return FALSE; + if ( sz == 1 ) // 8 bit elements + memset( data(), *d, len ); + else if ( sz == 4 ) { // 32 bit elements + register Q_INT32 *x = (Q_INT32*)data(); + Q_INT32 v = *((Q_INT32*)d); + while ( len-- ) + *x++ = v; + } else if ( sz == 2 ) { // 16 bit elements + register Q_INT16 *x = (Q_INT16*)data(); + Q_INT16 v = *((Q_INT16*)d); + while ( len-- ) + *x++ = v; + } else { // any other size elements + register char *x = data(); + while ( len-- ) { // more complicated + memcpy( x, d, sz ); + x += sz; + } + } + return TRUE; +} + +/*! + \overload + Shallow copy. Dereference the current array and references the data + contained in \a a instead. Returns a reference to this array. + \sa operator=() +*/ + +TQGArray &TQGArray::assign( const TQGArray &a ) +{ + a.shd->ref(); // avoid 'a = a' + if ( shd->deref() ) { // delete when last reference + if ( shd->data ) // is lost + DELETE(shd->data); + deleteData( shd ); + } + shd = a.shd; + return *this; +} + +/*! + Shallow copy. Dereference the current array and references the + array data \a d, which contains \a len bytes. + Returns a reference to this array. + + Do not delete \a d later, because TQGArray takes care of that. +*/ + +TQGArray &TQGArray::assign( const char *d, uint len ) +{ + if ( shd->count > 1 ) { // disconnect this + shd->count--; + shd = newData(); + Q_CHECK_PTR( shd ); + } else { + if ( shd->data ) + DELETE(shd->data); + } + shd->data = (char *)d; + shd->len = +#ifdef QT_QGARRAY_SPEED_OPTIM + shd->maxl = +#endif + len; + return *this; +} + +/*! + Deep copy. Dereference the current array and obtains a copy of the data + contained in \a a instead. Returns a reference to this array. + \sa assign(), operator=() +*/ + +TQGArray &TQGArray::duplicate( const TQGArray &a ) +{ + if ( a.shd == shd ) { // a.duplicate(a) ! + if ( shd->count > 1 ) { + shd->count--; + register array_data *n = newData(); + Q_CHECK_PTR( n ); + if ( (n->len=shd->len) ) { + n->data = NEW(char,n->len); + Q_CHECK_PTR( n->data ); + if ( n->data ) + memcpy( n->data, shd->data, n->len ); + } else { + n->data = 0; + } + shd = n; + } + return *this; + } + char *oldptr = 0; + if ( shd->count > 1 ) { // disconnect this + shd->count--; + shd = newData(); + Q_CHECK_PTR( shd ); + } else { // delete after copy was made + oldptr = shd->data; + } + if ( a.shd->len ) { // duplicate data + shd->data = NEW(char,a.shd->len); + Q_CHECK_PTR( shd->data ); + if ( shd->data ) + memcpy( shd->data, a.shd->data, a.shd->len ); + } else { + shd->data = 0; + } + shd->len = +#ifdef QT_QGARRAY_SPEED_OPTIM + shd->maxl = +#endif + a.shd->len; + if ( oldptr ) + DELETE(oldptr); + return *this; +} + +/*! + \overload + Deep copy. Dereferences the current array and obtains a copy of + \a len characters from array data \a d instead. Returns a reference + to this array. + \sa assign(), operator=() +*/ + +TQGArray &TQGArray::duplicate( const char *d, uint len ) +{ + char *data; + if ( d == 0 || len == 0 ) { + data = 0; + len = 0; + } else { + if ( shd->count == 1 && shd->len == len ) { + if ( shd->data != d ) // avoid self-assignment + memcpy( shd->data, d, len ); // use same buffer + return *this; + } + data = NEW(char,len); + Q_CHECK_PTR( data ); + memcpy( data, d, len ); + } + if ( shd->count > 1 ) { // detach + shd->count--; + shd = newData(); + Q_CHECK_PTR( shd ); + } else { // just a single reference + if ( shd->data ) + DELETE(shd->data); + } + shd->data = data; + shd->len = +#ifdef QT_QGARRAY_SPEED_OPTIM + shd->maxl = +#endif + len; + return *this; +} + +/*! + Resizes this array to \a len bytes and copies the \a len bytes at + address \a d into it. + + \warning This function disregards the reference count mechanism. If + other TQGArrays reference the same data as this, all will be updated. +*/ + +void TQGArray::store( const char *d, uint len ) +{ // store, but not deref + resize( len ); + memcpy( shd->data, d, len ); +} + + +/*! + \fn array_data *TQGArray::sharedBlock() const + + Returns a pointer to the shared array block. + + \warning + + Do not use this function. Using it is begging for trouble. We dare + not remove it, for fear of breaking code, but we \e strongly + discourage new use of it. +*/ + +/*! + \fn void TQGArray::setSharedBlock( array_data *p ) + + Sets the shared array block to \a p. + + \warning + + Do not use this function. Using it is begging for trouble. We dare + not remove it, for fear of breaking code, but we \e strongly + discourage new use of it. +*/ + + +/*! + Sets raw data and returns a reference to the array. + + Dereferences the current array and sets the new array data to \a d and + the new array size to \a 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 TQMemArray data without + allocating memory or copying data. + + Example of intended use: + \code + static uchar bindata[] = { 231, 1, 44, ... }; + TQByteArray a; + a.setRawData( bindata, sizeof(bindata) ); // a points to bindata + TQDataStream s( a, IO_ReadOnly ); // open on a's data + s >> ; // read raw bindata + s.close(); + a.resetRawData( bindata, sizeof(bindata) ); // finished + \endcode + + Example of misuse (do not do this): + \code + static uchar bindata[] = { 231, 1, 44, ... }; + TQByteArray 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 + \endcode + + \warning If you do not call resetRawData(), TQGArray will attempt to + deallocate or reallocate the raw data, which might not be too good. + Be careful. +*/ + +TQGArray &TQGArray::setRawData( const char *d, uint len ) +{ + duplicate( 0, 0 ); // set null data + shd->data = (char *)d; + shd->len = len; + return *this; +} + +/*! + Resets raw data. + + The arguments must be the data, \a d, and length \a len, that were + passed to setRawData(). This is for consistency checking. +*/ + +void TQGArray::resetRawData( const char *d, uint len ) +{ + if ( d != shd->data || len != shd->len ) { +#if defined(QT_CHECK_STATE) + qWarning( "TQGArray::resetRawData: Inconsistent arguments" ); +#endif + return; + } + shd->data = 0; + shd->len = 0; +} + + +/*! + Finds the first occurrence of \a d in the array from position \a index, + where \a sz is the size of the \a d element. + + Note that \a index is given in units of \a sz, not bytes. + + This function only compares whole cells, not bytes. +*/ + +int TQGArray::find( const char *d, uint index, uint sz ) const +{ + index *= sz; + if ( index >= shd->len ) { +#if defined(QT_CHECK_RANGE) + qWarning( "TQGArray::find: Index %d out of range", index/sz ); +#endif + return -1; + } + register uint i; + uint ii; + switch ( sz ) { + case 1: { // 8 bit elements + register char *x = data() + index; + char v = *d; + for ( i=index; ilen; i++ ) { + if ( *x++ == v ) + break; + } + ii = i; + } + break; + case 2: { // 16 bit elements + register Q_INT16 *x = (Q_INT16*)(data() + index); + Q_INT16 v = *((Q_INT16*)d); + for ( i=index; ilen; i+=2 ) { + if ( *x++ == v ) + break; + } + ii = i/2; + } + break; + case 4: { // 32 bit elements + register Q_INT32 *x = (Q_INT32*)(data() + index); + Q_INT32 v = *((Q_INT32*)d); + for ( i=index; ilen; i+=4 ) { + if ( *x++ == v ) + break; + } + ii = i/4; + } + break; + default: { // any size elements + for ( i=index; ilen; i+=sz ) { + if ( memcmp( d, &shd->data[i], sz ) == 0 ) + break; + } + ii = i/sz; + } + break; + } + return ilen ? (int)ii : -1; +} + +/*! + Returns the number of occurrences of \a d in the array, where \a sz is + the size of the \a d element. + + This function only compares whole cells, not bytes. +*/ + +int TQGArray::contains( const char *d, uint sz ) const +{ + register uint i = shd->len; + int count = 0; + switch ( sz ) { + case 1: { // 8 bit elements + register char *x = data(); + char v = *d; + while ( i-- ) { + if ( *x++ == v ) + count++; + } + } + break; + case 2: { // 16 bit elements + register Q_INT16 *x = (Q_INT16*)data(); + Q_INT16 v = *((Q_INT16*)d); + i /= 2; + while ( i-- ) { + if ( *x++ == v ) + count++; + } + } + break; + case 4: { // 32 bit elements + register Q_INT32 *x = (Q_INT32*)data(); + Q_INT32 v = *((Q_INT32*)d); + i /= 4; + while ( i-- ) { + if ( *x++ == v ) + count++; + } + } + break; + default: { // any size elements + for ( i=0; ilen; i+=sz ) { + if ( memcmp(d, &shd->data[i], sz) == 0 ) + count++; + } + } + break; + } + return count; +} + +static int cmp_item_size = 0; + +#if defined(Q_C_CALLBACKS) +extern "C" { +#endif + +#ifdef Q_OS_TEMP +static int __cdecl cmp_arr( const void *n1, const void *n2 ) +#else +static int cmp_arr( const void *n1, const void *n2 ) +#endif +{ + return ( n1 && n2 ) ? memcmp( n1, n2, cmp_item_size ) + : ( n1 ? 1 : ( n2 ? -1 : 0 ) ); + // ### TQt 3.0: Add a virtual compareItems() method and call that instead +} + +#if defined(Q_C_CALLBACKS) +} +#endif + +/*! + Sorts the first \a sz items of the array. +*/ + +void TQGArray::sort( uint sz ) +{ + int numItems = size() / sz; + if ( numItems < 2 ) + return; + +#ifdef QT_THREAD_SUPPORT + TQMutexLocker locker( qt_global_mutexpool ? + qt_global_mutexpool->get( &cmp_item_size ) : 0 ); +#endif // QT_THREAD_SUPPORT + + cmp_item_size = sz; + qsort( shd->data, numItems, sz, cmp_arr ); +} + +/*! + Binary search; assumes that \a d is a sorted array of size \a sz. +*/ + +int TQGArray::bsearch( const char *d, uint sz ) const +{ + int numItems = size() / sz; + if ( !numItems ) + return -1; + +#ifdef QT_THREAD_SUPPORT + TQMutexLocker locker( qt_global_mutexpool ? + qt_global_mutexpool->get( &cmp_item_size ) : 0 ); +#endif // QT_THREAD_SUPPORT + + cmp_item_size = sz; + char* r = (char*)::bsearch( d, shd->data, numItems, sz, cmp_arr ); + if ( !r ) + return -1; + while( (r >= shd->data + sz) && (cmp_arr( r - sz, d ) == 0) ) + r -= sz; // search to first of equal elements; bsearch is undef + return (int)(( r - shd->data ) / sz); +} + + +/*! + \fn char *TQGArray::at( uint index ) const + + Returns a pointer to the byte at offset \a index in the array. +*/ + +/*! + Expand the array if necessary, and copies (the first part of) its + contents from the \a index * \a sz bytes at \a d. + + Returns TRUE if the operation succeeds, FALSE if it runs out of + memory. + + \warning This function disregards the reference count mechanism. If + other TQGArrays reference the same data as this, all will be changed. +*/ + +bool TQGArray::setExpand( uint index, const char *d, uint sz ) +{ + index *= sz; + if ( index >= shd->len ) { + if ( !resize( index+sz ) ) // no memory + return FALSE; + } + memcpy( data() + index, d, sz ); + return TRUE; +} + + +/*! + Prints a warning message if at() or [] is given a bad index. +*/ + +void TQGArray::msg_index( uint index ) +{ +#if defined(QT_CHECK_RANGE) + qWarning( "TQGArray::at: Absolute index %d out of range", index ); +#else + Q_UNUSED( index ) +#endif +} + + +/*! + Returns a new shared array block. +*/ + +TQGArray::array_data * TQGArray::newData() +{ + return new array_data; +} + + +/*! + Deletes the shared array block \a p. +*/ + +void TQGArray::deleteData( array_data *p ) +{ + delete p; +} diff --git a/src/tools/qgarray.h b/src/tools/qgarray.h new file mode 100644 index 000000000..614b8f5ec --- /dev/null +++ b/src/tools/qgarray.h @@ -0,0 +1,134 @@ +/**************************************************************************** +** +** Definition of TQGArray class +** +** Created : 930906 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQGARRAY_H +#define TQGARRAY_H + +#ifndef QT_H +#include "qshared.h" +#endif // QT_H + + +class Q_EXPORT TQGArray // generic array +{ +friend class TQBuffer; +public: + // do not use this, even though this is public + // ### make protected or private in TQt 4.0 beta? + struct array_data : public TQShared { // shared array + array_data():data(0),len(0) +#ifdef QT_QGARRAY_SPEED_OPTIM + ,maxl(0) +#endif + {} + char *data; // actual array data + uint len; +#ifdef QT_QGARRAY_SPEED_OPTIM + uint maxl; +#endif + }; + TQGArray(); + enum Optimization { MemOptim, SpeedOptim }; +protected: + TQGArray( int, int ); // dummy; does not alloc + TQGArray( int size ); // allocate 'size' bytes + TQGArray( const TQGArray &a ); // shallow copy + virtual ~TQGArray(); + + TQGArray &operator=( const TQGArray &a ) { return assign( a ); } + + virtual void detach() { duplicate(*this); } + + // ### TQt 4.0: maybe provide two versions of data(), at(), etc. + char *data() const { return shd->data; } + uint nrefs() const { return shd->count; } + uint size() const { return shd->len; } + bool isEqual( const TQGArray &a ) const; + + bool resize( uint newsize, Optimization optim ); + bool resize( uint newsize ); + + bool fill( const char *d, int len, uint sz ); + + TQGArray &assign( const TQGArray &a ); + TQGArray &assign( const char *d, uint len ); + TQGArray &duplicate( const TQGArray &a ); + TQGArray &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; } + + TQGArray &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 *TQGArray::at( uint index ) const +{ +#if defined(QT_CHECK_RANGE) + if ( index >= size() ) { + msg_index( index ); + index = 0; + } +#endif + return &shd->data[index]; +} + + +#endif // TQGARRAY_H diff --git a/src/tools/qgcache.cpp b/src/tools/qgcache.cpp new file mode 100644 index 000000000..2465f4a47 --- /dev/null +++ b/src/tools/qgcache.cpp @@ -0,0 +1,866 @@ +/**************************************************************************** +** +** Implementation of TQGCache and TQGCacheIterator classes +** +** Created : 950208 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "qgcache.h" +#include "qptrlist.h" +#include "qdict.h" +#include "qstring.h" + +/*! + \class TQGCache qgcache.h + \reentrant + \ingroup shared + \ingroup collection + \brief The TQGCache class is an internal class for implementing TQCache + template classes. + + \internal + + TQGCache is a strictly internal class that acts as a base class for the + \link collection.html collection classes\endlink TQCache and TQIntCache. +*/ + + +/***************************************************************************** + TQGCacheItem class (internal cache item) + *****************************************************************************/ + +struct TQCacheItem +{ + TQCacheItem( void *k, TQPtrCollection::Item d, int c, short p ) + : priority(p), skipPriority(p), cost(c), key(k), data(d), node(0) {} + short priority; + short skipPriority; + int cost; + void *key; + TQPtrCollection::Item data; + TQLNode *node; +}; + + +/***************************************************************************** + TQCList class (internal list of cache items) + *****************************************************************************/ + +class TQCList : private TQPtrList +{ +friend class TQGCacheIterator; +friend class TQCListIt; +public: + TQCList() {} + ~TQCList(); + + void insert( TQCacheItem * ); // insert according to priority + void insert( int, TQCacheItem * ); + void take( TQCacheItem * ); + void reference( TQCacheItem * ); + + void setAutoDelete( bool del ) { TQPtrCollection::setAutoDelete(del); } + + bool removeFirst() { return TQPtrList::removeFirst(); } + bool removeLast() { return TQPtrList::removeLast(); } + + TQCacheItem *first() { return TQPtrList::first(); } + TQCacheItem *last() { return TQPtrList::last(); } + TQCacheItem *prev() { return TQPtrList::prev(); } + TQCacheItem *next() { return TQPtrList::next(); } + +#if defined(QT_DEBUG) + int inserts; // variables for statistics + int insertCosts; + int insertMisses; + int finds; + int hits; + int hitCosts; + int dumps; + int dumpCosts; +#endif +}; + + +TQCList::~TQCList() +{ +#if defined(QT_DEBUG) + Q_ASSERT( count() == 0 ); +#endif +} + + +void TQCList::insert( TQCacheItem *ci ) +{ + TQCacheItem *item = first(); + while( item && item->skipPriority > ci->priority ) { + item->skipPriority--; + item = next(); + } + if ( item ) + TQPtrList::insert( at(), ci ); + else + append( ci ); +#if defined(QT_DEBUG) + Q_ASSERT( ci->node == 0 ); +#endif + ci->node = currentNode(); +} + +inline void TQCList::insert( int i, TQCacheItem *ci ) +{ + TQPtrList::insert( i, ci ); +#if defined(QT_DEBUG) + Q_ASSERT( ci->node == 0 ); +#endif + ci->node = currentNode(); +} + + +void TQCList::take( TQCacheItem *ci ) +{ + if ( ci ) { +#if defined(QT_DEBUG) + Q_ASSERT( ci->node != 0 ); +#endif + takeNode( ci->node ); + ci->node = 0; + } +} + + +inline void TQCList::reference( TQCacheItem *ci ) +{ +#if defined(QT_DEBUG) + Q_ASSERT( ci != 0 && ci->node != 0 ); +#endif + ci->skipPriority = ci->priority; + relinkNode( ci->node ); // relink as first item +} + + +class TQCListIt: public TQPtrListIterator +{ +public: + TQCListIt( const TQCList *p ): TQPtrListIterator( *p ) {} + TQCListIt( const TQCListIt *p ): TQPtrListIterator( *p ) {} +}; + + +/***************************************************************************** + TQCDict class (internal dictionary of cache items) + *****************************************************************************/ + +// +// Since we need to decide if the dictionary should use an int or const +// char * key (the "bool trivial" argument in the constructor below) +// we cannot use the macro/template dict, but inherit directly from TQGDict. +// + +class TQCDict : public TQGDict +{ +public: + TQCDict( uint size, uint kt, bool caseSensitive, bool copyKeys ) + : TQGDict( size, (KeyType)kt, caseSensitive, copyKeys ) {} + ~TQCDict(); + + void clear() { TQGDict::clear(); } + + TQCacheItem *find_string(const TQString &key) const + { return (TQCacheItem*)((TQCDict*)this)->look_string(key, 0, 0); } + TQCacheItem *find_ascii(const char *key) const + { return (TQCacheItem*)((TQCDict*)this)->look_ascii(key, 0, 0); } + TQCacheItem *find_int(long key) const + { return (TQCacheItem*)((TQCDict*)this)->look_int(key, 0, 0); } + + TQCacheItem *take_string(const TQString &key) + { return (TQCacheItem*)TQGDict::take_string(key); } + TQCacheItem *take_ascii(const char *key) + { return (TQCacheItem*)TQGDict::take_ascii(key); } + TQCacheItem *take_int(long key) + { return (TQCacheItem*)TQGDict::take_int(key); } + + bool insert_string( const TQString &key, const TQCacheItem *ci ) + { return TQGDict::look_string(key,(Item)ci,1)!=0;} + bool insert_ascii( const char *key, const TQCacheItem *ci ) + { return TQGDict::look_ascii(key,(Item)ci,1)!=0;} + bool insert_int( long key, const TQCacheItem *ci ) + { return TQGDict::look_int(key,(Item)ci,1)!=0;} + + bool remove_string( TQCacheItem *item ) + { return TQGDict::remove_string(*((TQString*)(item->key)),item); } + bool remove_ascii( TQCacheItem *item ) + { return TQGDict::remove_ascii((const char *)item->key,item); } + bool remove_int( TQCacheItem *item ) + { return TQGDict::remove_int((long)item->key,item);} + + void statistics() { TQGDict::statistics(); } + +private: + void deleteItem( void *item ) + { if ( del_item ) { TQCacheItem *d = (TQCacheItem*)item; delete d; } } +}; + +inline TQCDict::~TQCDict() +{ + clear(); +} + +/***************************************************************************** + TQGDict member functions + *****************************************************************************/ + +/*! + Constructs a cache. + The maximum cost of the cache is given by \a maxCost and the size by \a + size. The key type is \a kt which may be \c StringKey, \c AsciiKey, + \c IntKey or \c PtrKey. The case-sensitivity of lookups is set with + \a caseSensitive. Keys are copied if \a copyKeys is TRUE. +*/ + +TQGCache::TQGCache( int maxCost, uint size, KeyType kt, bool caseSensitive, + bool copyKeys ) +{ + keytype = kt; + lruList = new TQCList; + Q_CHECK_PTR( lruList ); + lruList->setAutoDelete( TRUE ); + copyk = ((keytype == AsciiKey) && copyKeys); + dict = new TQCDict( size, kt, caseSensitive, FALSE ); + Q_CHECK_PTR( dict ); + mCost = maxCost; + tCost = 0; +#if defined(QT_DEBUG) + lruList->inserts = 0; + lruList->insertCosts = 0; + lruList->insertMisses = 0; + lruList->finds = 0; + lruList->hits = 0; + lruList->hitCosts = 0; + lruList->dumps = 0; + lruList->dumpCosts = 0; +#endif +} + +/*! + Cannot copy a cache. +*/ + +TQGCache::TQGCache( const TQGCache & ) + : TQPtrCollection() +{ +#if defined(QT_CHECK_NULL) + qFatal( "TQGCache::TQGCache(TQGCache &): Cannot copy a cache" ); +#endif +} + +/*! + Removes all items from the cache and destroys it. +*/ + +TQGCache::~TQGCache() +{ + clear(); + delete dict; + delete lruList; +} + +/*! + Cannot assign a cache. +*/ + +TQGCache &TQGCache::operator=( const TQGCache & ) +{ +#if defined(QT_CHECK_NULL) + qFatal( "TQGCache::operator=: Cannot copy a cache" ); +#endif + return *this; +} + + +/*! + Returns the number of items in the cache. +*/ + +uint TQGCache::count() const +{ + return dict->count(); +} + +/*! + Returns the size of the hash array. +*/ + +uint TQGCache::size() const +{ + return dict->size(); +} + +/*! + \fn int TQGCache::maxCost() const + + Returns the maximum cache cost. +*/ + +/*! + \fn int TQGCache::totalCost() const + + Returns the total cache cost. +*/ + +/*! + Sets the maximum cache cost to \a maxCost. +*/ + +void TQGCache::setMaxCost( int maxCost ) +{ + if ( maxCost < tCost ) { + if ( !makeRoomFor(tCost - maxCost) ) // remove excess cost + return; + } + mCost = maxCost; +} + + +/*! + Inserts an item with data \a data into the cache using key \a key. + The item has cost \a cost and priority \a priority. + + \warning If this function returns FALSE, you must delete \a data + yourself. Additionally, be very careful about using \a data after + calling this function, as any other insertions into the cache, from + anywhere in the application, or within TQt itself, could cause the + data to be discarded from the cache, and the pointer to become + invalid. +*/ + +bool TQGCache::insert_string( const TQString &key, TQPtrCollection::Item data, + int cost, int priority) +{ + if ( tCost + cost > mCost ) { + if ( !makeRoomFor(tCost + cost - mCost, priority) ) { +#if defined(QT_DEBUG) + lruList->insertMisses++; +#endif + return FALSE; + } + } +#if defined(QT_DEBUG) + Q_ASSERT( keytype == StringKey ); + lruList->inserts++; + lruList->insertCosts += cost; +#endif + if ( priority < -32768 ) + priority = -32768; + else if ( priority > 32767 ) + priority = 32677; + TQCacheItem *ci = new TQCacheItem( new TQString(key), newItem(data), + cost, (short)priority ); + Q_CHECK_PTR( ci ); + lruList->insert( 0, ci ); + dict->insert_string( key, ci ); + tCost += cost; + return TRUE; +} + +bool TQGCache::insert_other( const char *key, TQPtrCollection::Item data, + int cost, int priority) +{ + if ( tCost + cost > mCost ) { + if ( !makeRoomFor(tCost + cost - mCost, priority) ) { +#if defined(QT_DEBUG) + lruList->insertMisses++; +#endif + return FALSE; + } + } +#if defined(QT_DEBUG) + Q_ASSERT( keytype != StringKey ); + lruList->inserts++; + lruList->insertCosts += cost; +#endif + if ( keytype == AsciiKey && copyk ) + key = qstrdup( key ); + if ( priority < -32768 ) + priority = -32768; + else if ( priority > 32767 ) + priority = 32677; + TQCacheItem *ci = new TQCacheItem( (void*)key, newItem(data), cost, + (short)priority ); + Q_CHECK_PTR( ci ); + lruList->insert( 0, ci ); + if ( keytype == AsciiKey ) + dict->insert_ascii( key, ci ); + else + dict->insert_int( (long)key, ci ); + tCost += cost; + return TRUE; +} + + +/*! + Removes the item with key \a key from the cache. Returns TRUE if the + item was removed; otherwise returns FALSE. +*/ + +bool TQGCache::remove_string( const TQString &key ) +{ + Item d = take_string( key ); + if ( d ) + deleteItem( d ); + return d != 0; +} + +bool TQGCache::remove_other( const char *key ) +{ + Item d = take_other( key ); + if ( d ) + deleteItem( d ); + return d != 0; +} + + +/*! + Takes the item with key \a key out of the cache. The item is not + deleted. If no item has this \a key 0 is returned. +*/ + +TQPtrCollection::Item TQGCache::take_string( const TQString &key ) +{ + TQCacheItem *ci = dict->take_string( key ); // take from dict + Item d; + if ( ci ) { + d = ci->data; + tCost -= ci->cost; + lruList->take( ci ); // take from list + delete (TQString*)ci->key; + delete ci; + } else { + d = 0; + } + return d; +} + +/*! + Takes the item with key \a key out of the cache. The item is not + deleted. If no item has this \a key 0 is returned. +*/ + +TQPtrCollection::Item TQGCache::take_other( const char *key ) +{ + TQCacheItem *ci; + if ( keytype == AsciiKey ) + ci = dict->take_ascii( key ); + else + ci = dict->take_int( (long)key ); + Item d; + if ( ci ) { + d = ci->data; + tCost -= ci->cost; + lruList->take( ci ); // take from list + if ( copyk ) + delete [] (char *)ci->key; + delete ci; + } else { + d = 0; + } + return d; +} + + +/*! + Clears the cache. +*/ + +void TQGCache::clear() +{ + TQCacheItem *ci; + while ( (ci = lruList->first()) ) { + switch ( keytype ) { + case StringKey: + dict->remove_string( ci ); + delete (TQString*)ci->key; + break; + case AsciiKey: + dict->remove_ascii( ci ); + if ( copyk ) + delete [] (char*)ci->key; + break; + case IntKey: + dict->remove_int( ci ); + break; + case PtrKey: // unused + break; + } + deleteItem( ci->data ); // delete data + lruList->removeFirst(); // remove from list + } + tCost = 0; +} + + +/*! + Finds an item for \a key in the cache and adds a reference if \a ref is TRUE. +*/ + +TQPtrCollection::Item TQGCache::find_string( const TQString &key, bool ref ) const +{ + TQCacheItem *ci = dict->find_string( key ); +#if defined(QT_DEBUG) + lruList->finds++; +#endif + if ( ci ) { +#if defined(QT_DEBUG) + lruList->hits++; + lruList->hitCosts += ci->cost; +#endif + if ( ref ) + lruList->reference( ci ); + return ci->data; + } + return 0; +} + + +/*! + Finds an item for \a key in the cache and adds a reference if \a ref is TRUE. +*/ + +TQPtrCollection::Item TQGCache::find_other( const char *key, bool ref ) const +{ + TQCacheItem *ci = keytype == AsciiKey ? dict->find_ascii(key) + : dict->find_int((long)key); +#if defined(QT_DEBUG) + lruList->finds++; +#endif + if ( ci ) { +#if defined(QT_DEBUG) + lruList->hits++; + lruList->hitCosts += ci->cost; +#endif + if ( ref ) + lruList->reference( ci ); + return ci->data; + } + return 0; +} + + +/*! + Allocates cache space for one or more items. +*/ + +bool TQGCache::makeRoomFor( int cost, int priority ) +{ + if ( cost > mCost ) // cannot make room for more + return FALSE; // than maximum cost + if ( priority == -1 ) + priority = 32767; + register TQCacheItem *ci = lruList->last(); + int cntCost = 0; + int dumps = 0; // number of items to dump + while ( cntCost < cost && ci && ci->skipPriority <= priority ) { + cntCost += ci->cost; + ci = lruList->prev(); + dumps++; + } + if ( cntCost < cost ) // can enough cost be dumped? + return FALSE; // no +#if defined(QT_DEBUG) + Q_ASSERT( dumps > 0 ); +#endif + while ( dumps-- ) { + ci = lruList->last(); +#if defined(QT_DEBUG) + lruList->dumps++; + lruList->dumpCosts += ci->cost; +#endif + switch ( keytype ) { + case StringKey: + dict->remove_string( ci ); + delete (TQString*)ci->key; + break; + case AsciiKey: + dict->remove_ascii( ci ); + if ( copyk ) + delete [] (char *)ci->key; + break; + case IntKey: + dict->remove_int( ci ); + break; + case PtrKey: // unused + break; + } + deleteItem( ci->data ); // delete data + lruList->removeLast(); // remove from list + } + tCost -= cntCost; + return TRUE; +} + + +/*! + Outputs debug statistics. +*/ + +void TQGCache::statistics() const +{ +#if defined(QT_DEBUG) + TQString line; + line.fill( '*', 80 ); + qDebug( line.ascii() ); + qDebug( "CACHE STATISTICS:" ); + qDebug( "cache contains %d item%s, with a total cost of %d", + count(), count() != 1 ? "s" : "", tCost ); + qDebug( "maximum cost is %d, cache is %d%% full.", + mCost, (200*tCost + mCost) / (mCost*2) ); + qDebug( "find() has been called %d time%s", + lruList->finds, lruList->finds != 1 ? "s" : "" ); + qDebug( "%d of these were hits, items found had a total cost of %d.", + lruList->hits,lruList->hitCosts ); + qDebug( "%d item%s %s been inserted with a total cost of %d.", + lruList->inserts,lruList->inserts != 1 ? "s" : "", + lruList->inserts != 1 ? "have" : "has", lruList->insertCosts ); + qDebug( "%d item%s %s too large or had too low priority to be inserted.", + lruList->insertMisses, lruList->insertMisses != 1 ? "s" : "", + lruList->insertMisses != 1 ? "were" : "was" ); + qDebug( "%d item%s %s been thrown away with a total cost of %d.", + lruList->dumps, lruList->dumps != 1 ? "s" : "", + lruList->dumps != 1 ? "have" : "has", lruList->dumpCosts ); + qDebug( "Statistics from internal dictionary class:" ); + dict->statistics(); + qDebug( line.ascii() ); +#endif +} + + +/***************************************************************************** + TQGCacheIterator member functions + *****************************************************************************/ + +/*! + \class TQGCacheIterator qgcache.h + \reentrant + \ingroup shared + \ingroup collection + \brief The TQGCacheIterator class is an internal class for implementing TQCacheIterator and + TQIntCacheIterator. + + \internal + + TQGCacheIterator is a strictly internal class that does the heavy work for + TQCacheIterator and TQIntCacheIterator. +*/ + +/*! + Constructs an iterator that operates on the cache \a c. +*/ + +TQGCacheIterator::TQGCacheIterator( const TQGCache &c ) +{ + it = new TQCListIt( c.lruList ); +#if defined(QT_DEBUG) + Q_ASSERT( it != 0 ); +#endif +} + +/*! + Constructs an iterator that operates on the same cache as \a ci. +*/ + +TQGCacheIterator::TQGCacheIterator( const TQGCacheIterator &ci ) +{ + it = new TQCListIt( ci.it ); +#if defined(QT_DEBUG) + Q_ASSERT( it != 0 ); +#endif +} + +/*! + Destroys the iterator. +*/ + +TQGCacheIterator::~TQGCacheIterator() +{ + delete it; +} + +/*! + Assigns the iterator \a ci to this cache iterator. +*/ + +TQGCacheIterator &TQGCacheIterator::operator=( const TQGCacheIterator &ci ) +{ + *it = *ci.it; + return *this; +} + +/*! + Returns the number of items in the cache. +*/ + +uint TQGCacheIterator::count() const +{ + return it->count(); +} + +/*! + Returns TRUE if the iterator points to the first item. +*/ + +bool TQGCacheIterator::atFirst() const +{ + return it->atFirst(); +} + +/*! + Returns TRUE if the iterator points to the last item. +*/ + +bool TQGCacheIterator::atLast() const +{ + return it->atLast(); +} + +/*! + Sets the list iterator to point to the first item in the cache. +*/ + +TQPtrCollection::Item TQGCacheIterator::toFirst() +{ + TQCacheItem *item = it->toFirst(); + return item ? item->data : 0; +} + +/*! + Sets the list iterator to point to the last item in the cache. +*/ + +TQPtrCollection::Item TQGCacheIterator::toLast() +{ + TQCacheItem *item = it->toLast(); + return item ? item->data : 0; +} + +/*! + Returns the current item. +*/ + +TQPtrCollection::Item TQGCacheIterator::get() const +{ + TQCacheItem *item = it->current(); + return item ? item->data : 0; +} + +/*! + Returns the key of the current item. +*/ + +TQString TQGCacheIterator::getKeyString() const +{ + TQCacheItem *item = it->current(); + return item ? *((TQString*)item->key) : TQString::null; +} + +/*! + Returns the key of the current item, as a \0-terminated C string. +*/ + +const char *TQGCacheIterator::getKeyAscii() const +{ + TQCacheItem *item = it->current(); + return item ? (const char *)item->key : 0; +} + +/*! + Returns the key of the current item, as a long. +*/ + +long TQGCacheIterator::getKeyInt() const +{ + TQCacheItem *item = it->current(); + return item ? (long)item->key : 0; +} + +/*! + Moves to the next item (postfix). +*/ + +TQPtrCollection::Item TQGCacheIterator::operator()() +{ + TQCacheItem *item = it->operator()(); + return item ? item->data : 0; +} + +/*! + Moves to the next item (prefix). +*/ + +TQPtrCollection::Item TQGCacheIterator::operator++() +{ + TQCacheItem *item = it->operator++(); + return item ? item->data : 0; +} + +/*! + Moves \a jump positions forward. +*/ + +TQPtrCollection::Item TQGCacheIterator::operator+=( uint jump ) +{ + TQCacheItem *item = it->operator+=(jump); + return item ? item->data : 0; +} + +/*! + Moves to the previous item (prefix). +*/ + +TQPtrCollection::Item TQGCacheIterator::operator--() +{ + TQCacheItem *item = it->operator--(); + return item ? item->data : 0; +} + +/*! + Moves \a jump positions backward. +*/ + +TQPtrCollection::Item TQGCacheIterator::operator-=( uint jump ) +{ + TQCacheItem *item = it->operator-=(jump); + return item ? item->data : 0; +} diff --git a/src/tools/qgcache.h b/src/tools/qgcache.h new file mode 100644 index 000000000..19b625f70 --- /dev/null +++ b/src/tools/qgcache.h @@ -0,0 +1,131 @@ +/**************************************************************************** +** +** Definition of TQGCache and TQGCacheIterator classes +** +** Created : 950208 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQGCACHE_H +#define TQGCACHE_H + +#ifndef QT_H +#include "qptrcollection.h" +#include "qglist.h" +#include "qgdict.h" +#endif // QT_H + + +class TQCList; // internal classes +class TQCListIt; +class TQCDict; + + +class Q_EXPORT TQGCache : public TQPtrCollection // generic LRU cache +{ +friend class TQGCacheIterator; +protected: + enum KeyType { StringKey, AsciiKey, IntKey, PtrKey }; + // identical to TQGDict's, but PtrKey is not used at the moment + + TQGCache( int maxCost, uint size, KeyType kt, bool caseSensitive, + bool copyKeys ); + TQGCache( const TQGCache & ); // not allowed, calls fatal() + ~TQGCache(); + TQGCache &operator=( const TQGCache & ); // not allowed, calls fatal() + + uint count() const; + uint size() const; + int maxCost() const { return mCost; } + int totalCost() const { return tCost; } + void setMaxCost( int maxCost ); + void clear(); + + bool insert_string( const TQString &key, TQPtrCollection::Item, + int cost, int priority ); + bool insert_other( const char *key, TQPtrCollection::Item, + int cost, int priority ); + bool remove_string( const TQString &key ); + bool remove_other( const char *key ); + TQPtrCollection::Item take_string( const TQString &key ); + TQPtrCollection::Item take_other( const char *key ); + + TQPtrCollection::Item find_string( const TQString &key, bool ref=TRUE ) const; + TQPtrCollection::Item find_other( const char *key, bool ref=TRUE ) const; + + void statistics() const; + +private: + bool makeRoomFor( int cost, int priority = -1 ); + KeyType keytype; + TQCList *lruList; + TQCDict *dict; + int mCost; + int tCost; + bool copyk; +}; + + +class Q_EXPORT TQGCacheIterator // generic cache iterator +{ +protected: + TQGCacheIterator( const TQGCache & ); + TQGCacheIterator( const TQGCacheIterator & ); + ~TQGCacheIterator(); + TQGCacheIterator &operator=( const TQGCacheIterator & ); + + uint count() const; + bool atFirst() const; + bool atLast() const; + TQPtrCollection::Item toFirst(); + TQPtrCollection::Item toLast(); + + TQPtrCollection::Item get() const; + TQString getKeyString() const; + const char *getKeyAscii() const; + long getKeyInt() const; + + TQPtrCollection::Item operator()(); + TQPtrCollection::Item operator++(); + TQPtrCollection::Item operator+=( uint ); + TQPtrCollection::Item operator--(); + TQPtrCollection::Item operator-=( uint ); + +protected: + TQCListIt *it; // iterator on cache list +}; + + +#endif // TQGCACHE_H diff --git a/src/tools/qgdict.cpp b/src/tools/qgdict.cpp new file mode 100644 index 000000000..1a5e2c31d --- /dev/null +++ b/src/tools/qgdict.cpp @@ -0,0 +1,1151 @@ +/**************************************************************************** +** +** Implementation of TQGDict and TQGDictIterator classes +** +** Created : 920529 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "qgdict.h" +#include "qptrlist.h" +#include "qstring.h" +#include "qdatastream.h" +#include + +/*! + \class TQGDict + \reentrant + \ingroup collection + \brief The TQGDict class is an internal class for implementing TQDict template classes. + + \internal + + TQGDict is a strictly internal class that acts as a base class for the + \link collection.html collection classes\endlink TQDict and TQIntDict. + + TQGDict has some virtual functions that can be reimplemented to customize + the subclasses. + \list + \i read() reads a collection/dictionary item from a TQDataStream. + \i write() writes a collection/dictionary item to a TQDataStream. + \endlist + Normally, you do not have to reimplement any of these functions. +*/ + +static const int op_find = 0; +static const int op_insert = 1; +static const int op_replace = 2; + + +class TQGDItList : public TQPtrList +{ +public: + TQGDItList() : TQPtrList() {} + TQGDItList( const TQGDItList &list ) : TQPtrList(list) {} + ~TQGDItList() { clear(); } + TQGDItList &operator=(const TQGDItList &list) + { return (TQGDItList&)TQPtrList::operator=(list); } +}; + + +/***************************************************************************** + Default implementation of special and virtual functions + *****************************************************************************/ + +/*! + Returns the hash key for \a key, when key is a string. +*/ + +int TQGDict::hashKeyString( const TQString &key ) +{ +#if defined(QT_CHECK_NULL) + if ( key.isNull() ) + qWarning( "TQGDict::hashKeyString: Invalid null key" ); +#endif + int i; + register uint h=0; + uint g; + const TQChar *p = key.unicode(); + if ( cases ) { // case sensitive + for ( i=0; i<(int)key.length(); 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++ ) { + 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; +} + +/*! + Returns the hash key for \a key, which is a C string. +*/ + +int TQGDict::hashKeyAscii( const char *key ) +{ +#if defined(QT_CHECK_NULL) + if ( key == 0 ) + qWarning( "TQGDict::hashAsciiKey: Invalid null key" ); +#endif + register const char *k = key; + register uint h=0; + uint g; + if ( cases ) { // case sensitive + while ( *k ) { + h = (h<<4) + *k++; + if ( (g = h & 0xf0000000) ) + h ^= g >> 24; + h &= ~g; + } + } else { // case insensitive + while ( *k ) { + h = (h<<4) + tolower((uchar) *k); + if ( (g = h & 0xf0000000) ) + h ^= g >> 24; + h &= ~g; + k++; + } + } + int index = h; + if ( index < 0 ) // adjust index to table size + index = -index; + return index; +} + +#ifndef QT_NO_DATASTREAM + +/*! + \overload + Reads a collection/dictionary item from the stream \a s and returns a + reference to the stream. + + The default implementation sets \a item to 0. + + \sa write() +*/ + +TQDataStream& TQGDict::read( TQDataStream &s, TQPtrCollection::Item &item ) +{ + item = 0; + return s; +} + +/*! + \overload + Writes a collection/dictionary item to the stream \a s and returns a + reference to the stream. + + \sa read() +*/ + +TQDataStream& TQGDict::write( TQDataStream &s, TQPtrCollection::Item ) const +{ + return s; +} +#endif //QT_NO_DATASTREAM + +/***************************************************************************** + TQGDict member functions + *****************************************************************************/ + +/*! + Constructs a dictionary. + + \a len is the initial size of the dictionary. + The key type is \a kt which may be \c StringKey, \c AsciiKey, + \c IntKey or \c PtrKey. The case-sensitivity of lookups is set with + \a caseSensitive. Keys are copied if \a copyKeys is TRUE. +*/ + +TQGDict::TQGDict( uint len, KeyType kt, bool caseSensitive, bool copyKeys ) +{ + init( len, kt, caseSensitive, copyKeys ); +} + + +void TQGDict::init( uint len, KeyType kt, bool caseSensitive, bool copyKeys ) +{ + vlen = len ? len : 17; + vec = new TQBaseBucket *[ vlen ]; + + Q_CHECK_PTR( vec ); + memset( (char*)vec, 0, vlen*sizeof(TQBaseBucket*) ); + numItems = 0; + iterators = 0; + // The caseSensitive and copyKey options don't make sense for + // all dict types. + switch ( (keytype = (uint)kt) ) { + case StringKey: + cases = caseSensitive; + copyk = FALSE; + break; + case AsciiKey: + cases = caseSensitive; + copyk = copyKeys; + break; + default: + cases = FALSE; + copyk = FALSE; + break; + } +} + + +/*! + Constructs a copy of \a dict. +*/ + +TQGDict::TQGDict( const TQGDict & dict ) + : TQPtrCollection( dict ) +{ + init( dict.vlen, (KeyType)dict.keytype, dict.cases, dict.copyk ); + TQGDictIterator it( dict ); + while ( it.get() ) { // copy from other dict + switch ( keytype ) { + case StringKey: + look_string( it.getKeyString(), it.get(), op_insert ); + break; + case AsciiKey: + look_ascii( it.getKeyAscii(), it.get(), op_insert ); + break; + case IntKey: + look_int( it.getKeyInt(), it.get(), op_insert ); + break; + case PtrKey: + look_ptr( it.getKeyPtr(), it.get(), op_insert ); + break; + } + ++it; + } +} + + +/*! + Removes all items from the dictionary and destroys it. +*/ + +TQGDict::~TQGDict() +{ + clear(); // delete everything + delete [] vec; + if ( !iterators ) // no iterators for this dict + return; + TQGDictIterator *i = iterators->first(); + while ( i ) { // notify all iterators that + i->dict = 0; // this dict is deleted + i = iterators->next(); + } + delete iterators; +} + + +/*! + Assigns \a dict to this dictionary. +*/ + +TQGDict &TQGDict::operator=( const TQGDict &dict ) +{ + if ( &dict == this ) + return *this; + clear(); + TQGDictIterator it( dict ); + while ( it.get() ) { // copy from other dict + switch ( keytype ) { + case StringKey: + look_string( it.getKeyString(), it.get(), op_insert ); + break; + case AsciiKey: + look_ascii( it.getKeyAscii(), it.get(), op_insert ); + break; + case IntKey: + look_int( it.getKeyInt(), it.get(), op_insert ); + break; + case PtrKey: + look_ptr( it.getKeyPtr(), it.get(), op_insert ); + break; + } + ++it; + } + return *this; +} + +/*! + \fn uint TQGDict::count() const + + Returns the number of items in the dictionary. +*/ + +/*! + \fn uint TQGDict::size() const + + Returns the size of the hash array. +*/ + +/*! + The do-it-all function; \a op is one of op_find, op_insert, op_replace. + The key is \a key and the item is \a d. +*/ + +TQPtrCollection::Item TQGDict::look_string( const TQString &key, TQPtrCollection::Item d, + int op ) +{ + TQStringBucket *n = 0; + int index = hashKeyString(key) % vlen; + if ( op == op_find ) { // find + if ( cases ) { + n = (TQStringBucket*)vec[index]; + while( n != 0 ) { + if ( key == n->getKey() ) + return n->getData(); // item found + n = (TQStringBucket*)n->getNext(); + } + } else { + TQString k = key.lower(); + n = (TQStringBucket*)vec[index]; + while( n != 0 ) { + if ( k == n->getKey().lower() ) + return n->getData(); // item found + n = (TQStringBucket*)n->getNext(); + } + } + return 0; // not found + } + if ( op == op_replace ) { // replace + if ( vec[index] != 0 ) // maybe something there + remove_string( key ); + } + // op_insert or op_replace + n = new TQStringBucket(key,newItem(d),vec[index]); + Q_CHECK_PTR( n ); +#if defined(QT_CHECK_NULL) + if ( n->getData() == 0 ) + qWarning( "TQDict: Cannot insert null item" ); +#endif + vec[index] = n; + numItems++; + return n->getData(); +} + +TQPtrCollection::Item TQGDict::look_ascii( const char *key, TQPtrCollection::Item d, int op ) +{ + TQAsciiBucket *n; + int index = hashKeyAscii(key) % vlen; + if ( op == op_find ) { // find + if ( cases ) { + for ( n=(TQAsciiBucket*)vec[index]; n; + n=(TQAsciiBucket*)n->getNext() ) { + if ( qstrcmp(n->getKey(),key) == 0 ) + return n->getData(); // item found + } + } else { + for ( n=(TQAsciiBucket*)vec[index]; n; + n=(TQAsciiBucket*)n->getNext() ) { + if ( qstricmp(n->getKey(),key) == 0 ) + return n->getData(); // item found + } + } + return 0; // not found + } + if ( op == op_replace ) { // replace + if ( vec[index] != 0 ) // maybe something there + remove_ascii( key ); + } + // op_insert or op_replace + n = new TQAsciiBucket(copyk ? qstrdup(key) : key,newItem(d),vec[index]); + Q_CHECK_PTR( n ); +#if defined(QT_CHECK_NULL) + if ( n->getData() == 0 ) + qWarning( "TQAsciiDict: Cannot insert null item" ); +#endif + vec[index] = n; + numItems++; + return n->getData(); +} + +TQPtrCollection::Item TQGDict::look_int( long key, TQPtrCollection::Item d, int op ) +{ + TQIntBucket *n; + int index = (int)((ulong)key % vlen); // simple hash + if ( op == op_find ) { // find + for ( n=(TQIntBucket*)vec[index]; n; + n=(TQIntBucket*)n->getNext() ) { + if ( n->getKey() == key ) + return n->getData(); // item found + } + return 0; // not found + } + if ( op == op_replace ) { // replace + if ( vec[index] != 0 ) // maybe something there + remove_int( key ); + } + // op_insert or op_replace + n = new TQIntBucket(key,newItem(d),vec[index]); + Q_CHECK_PTR( n ); +#if defined(QT_CHECK_NULL) + if ( n->getData() == 0 ) + qWarning( "TQIntDict: Cannot insert null item" ); +#endif + vec[index] = n; + numItems++; + return n->getData(); +} + +TQPtrCollection::Item TQGDict::look_ptr( void *key, TQPtrCollection::Item d, int op ) +{ + TQPtrBucket *n; + int index = (int)((ulong)key % vlen); // simple hash + if ( op == op_find ) { // find + for ( n=(TQPtrBucket*)vec[index]; n; + n=(TQPtrBucket*)n->getNext() ) { + if ( n->getKey() == key ) + return n->getData(); // item found + } + return 0; // not found + } + if ( op == op_replace ) { // replace + if ( vec[index] != 0 ) // maybe something there + remove_ptr( key ); + } + // op_insert or op_replace + n = new TQPtrBucket(key,newItem(d),vec[index]); + Q_CHECK_PTR( n ); +#if defined(QT_CHECK_NULL) + if ( n->getData() == 0 ) + qWarning( "TQPtrDict: Cannot insert null item" ); +#endif + vec[index] = n; + numItems++; + return n->getData(); +} + + +/*! + Changes the size of the hashtable to \a newsize. + The contents of the dictionary are preserved, + but all iterators on the dictionary become invalid. +*/ +void TQGDict::resize( uint newsize ) +{ + // Save old information + TQBaseBucket **old_vec = vec; + uint old_vlen = vlen; + bool old_copyk = copyk; + + vec = new TQBaseBucket *[vlen = newsize]; + Q_CHECK_PTR( vec ); + memset( (char*)vec, 0, vlen*sizeof(TQBaseBucket*) ); + numItems = 0; + copyk = FALSE; + + // Reinsert every item from vec, deleting vec as we go + for ( uint index = 0; index < old_vlen; index++ ) { + switch ( keytype ) { + case StringKey: + { + TQStringBucket *n=(TQStringBucket *)old_vec[index]; + while ( n ) { + look_string( n->getKey(), n->getData(), op_insert ); + TQStringBucket *t=(TQStringBucket *)n->getNext(); + delete n; + n = t; + } + } + break; + case AsciiKey: + { + TQAsciiBucket *n=(TQAsciiBucket *)old_vec[index]; + while ( n ) { + look_ascii( n->getKey(), n->getData(), op_insert ); + TQAsciiBucket *t=(TQAsciiBucket *)n->getNext(); + delete n; + n = t; + } + } + break; + case IntKey: + { + TQIntBucket *n=(TQIntBucket *)old_vec[index]; + while ( n ) { + look_int( n->getKey(), n->getData(), op_insert ); + TQIntBucket *t=(TQIntBucket *)n->getNext(); + delete n; + n = t; + } + } + break; + case PtrKey: + { + TQPtrBucket *n=(TQPtrBucket *)old_vec[index]; + while ( n ) { + look_ptr( n->getKey(), n->getData(), op_insert ); + TQPtrBucket *t=(TQPtrBucket *)n->getNext(); + delete n; + n = t; + } + } + break; + } + } + delete [] old_vec; + + // Restore state + copyk = old_copyk; + + // Invalidate all iterators, since order is lost + if ( iterators && iterators->count() ) { + TQGDictIterator *i = iterators->first(); + while ( i ) { + i->toFirst(); + i = iterators->next(); + } + } +} + +/*! + Unlinks the bucket with the specified key (and specified data pointer, + if it is set). +*/ + +void TQGDict::unlink_common( int index, TQBaseBucket *node, TQBaseBucket *prev ) +{ + if ( iterators && iterators->count() ) { // update iterators + TQGDictIterator *i = iterators->first(); + while ( i ) { // invalidate all iterators + if ( i->curNode == node ) // referring to pending node + i->operator++(); + i = iterators->next(); + } + } + if ( prev ) // unlink node + prev->setNext( node->getNext() ); + else + vec[index] = node->getNext(); + numItems--; +} + +TQStringBucket *TQGDict::unlink_string( const TQString &key, TQPtrCollection::Item d ) +{ + if ( numItems == 0 ) // nothing in dictionary + return 0; + TQStringBucket *n; + TQStringBucket *prev = 0; + int index = hashKeyString(key) % vlen; + if ( cases ) { + for ( n=(TQStringBucket*)vec[index]; n; + n=(TQStringBucket*)n->getNext() ) { + bool found = (key == n->getKey()); + if ( found && d ) + found = (n->getData() == d); + if ( found ) { + unlink_common(index,n,prev); + return n; + } + prev = n; + } + } else { + TQString k = key.lower(); + for ( n=(TQStringBucket*)vec[index]; n; + n=(TQStringBucket*)n->getNext() ) { + bool found = (k == n->getKey().lower()); + if ( found && d ) + found = (n->getData() == d); + if ( found ) { + unlink_common(index,n,prev); + return n; + } + prev = n; + } + } + return 0; +} + +TQAsciiBucket *TQGDict::unlink_ascii( const char *key, TQPtrCollection::Item d ) +{ + if ( numItems == 0 ) // nothing in dictionary + return 0; + TQAsciiBucket *n; + TQAsciiBucket *prev = 0; + int index = hashKeyAscii(key) % vlen; + for ( n=(TQAsciiBucket *)vec[index]; n; n=(TQAsciiBucket *)n->getNext() ) { + bool found = (cases ? qstrcmp(n->getKey(),key) + : qstricmp(n->getKey(),key)) == 0; + if ( found && d ) + found = (n->getData() == d); + if ( found ) { + unlink_common(index,n,prev); + return n; + } + prev = n; + } + return 0; +} + +TQIntBucket *TQGDict::unlink_int( long key, TQPtrCollection::Item d ) +{ + if ( numItems == 0 ) // nothing in dictionary + return 0; + TQIntBucket *n; + TQIntBucket *prev = 0; + int index = (int)((ulong)key % vlen); + for ( n=(TQIntBucket *)vec[index]; n; n=(TQIntBucket *)n->getNext() ) { + bool found = (n->getKey() == key); + if ( found && d ) + found = (n->getData() == d); + if ( found ) { + unlink_common(index,n,prev); + return n; + } + prev = n; + } + return 0; +} + +TQPtrBucket *TQGDict::unlink_ptr( void *key, TQPtrCollection::Item d ) +{ + if ( numItems == 0 ) // nothing in dictionary + return 0; + TQPtrBucket *n; + TQPtrBucket *prev = 0; + int index = (int)((ulong)key % vlen); + for ( n=(TQPtrBucket *)vec[index]; n; n=(TQPtrBucket *)n->getNext() ) { + bool found = (n->getKey() == key); + if ( found && d ) + found = (n->getData() == d); + if ( found ) { + unlink_common(index,n,prev); + return n; + } + prev = n; + } + return 0; +} + + +/*! + Removes the item with the specified \a key. If \a item is not null, + the remove will match the \a item as well (used to remove an + item when several items have the same key). +*/ + +bool TQGDict::remove_string( const TQString &key, TQPtrCollection::Item item ) +{ + TQStringBucket *n = unlink_string( key, item ); + if ( n ) { + deleteItem( n->getData() ); + delete n; + return TRUE; + } else { + return FALSE; + } +} + +bool TQGDict::remove_ascii( const char *key, TQPtrCollection::Item item ) +{ + TQAsciiBucket *n = unlink_ascii( key, item ); + if ( n ) { + if ( copyk ) + delete [] (char *)n->getKey(); + deleteItem( n->getData() ); + delete n; + } + return n != 0; +} + +bool TQGDict::remove_int( long key, TQPtrCollection::Item item ) +{ + TQIntBucket *n = unlink_int( key, item ); + if ( n ) { + deleteItem( n->getData() ); + delete n; + } + return n != 0; +} + +bool TQGDict::remove_ptr( void *key, TQPtrCollection::Item item ) +{ + TQPtrBucket *n = unlink_ptr( key, item ); + if ( n ) { + deleteItem( n->getData() ); + delete n; + } + return n != 0; +} + +TQPtrCollection::Item TQGDict::take_string( const TQString &key ) +{ + TQStringBucket *n = unlink_string( key ); + Item d; + if ( n ) { + d = n->getData(); + delete n; + } else { + d = 0; + } + return d; +} + +TQPtrCollection::Item TQGDict::take_ascii( const char *key ) +{ + TQAsciiBucket *n = unlink_ascii( key ); + Item d; + if ( n ) { + if ( copyk ) + delete [] (char *)n->getKey(); + d = n->getData(); + delete n; + } else { + d = 0; + } + return d; +} + +TQPtrCollection::Item TQGDict::take_int( long key ) +{ + TQIntBucket *n = unlink_int( key ); + Item d; + if ( n ) { + d = n->getData(); + delete n; + } else { + d = 0; + } + return d; +} + +TQPtrCollection::Item TQGDict::take_ptr( void *key ) +{ + TQPtrBucket *n = unlink_ptr( key ); + Item d; + if ( n ) { + d = n->getData(); + delete n; + } else { + d = 0; + } + return d; +} + +/*! + Removes all items from the dictionary. +*/ +void TQGDict::clear() +{ + if ( !numItems ) + return; + numItems = 0; // disable remove() function + for ( uint j=0; jgetNext(); + deleteItem( n->getData() ); + delete n; + n = next; + } + } + break; + case AsciiKey: + { + TQAsciiBucket *n=(TQAsciiBucket *)vec[j]; + while ( n ) { + TQAsciiBucket *next = (TQAsciiBucket*)n->getNext(); + if ( copyk ) + delete [] (char *)n->getKey(); + deleteItem( n->getData() ); + delete n; + n = next; + } + } + break; + case IntKey: + { + TQIntBucket *n=(TQIntBucket *)vec[j]; + while ( n ) { + TQIntBucket *next = (TQIntBucket*)n->getNext(); + deleteItem( n->getData() ); + delete n; + n = next; + } + } + break; + case PtrKey: + { + TQPtrBucket *n=(TQPtrBucket *)vec[j]; + while ( n ) { + TQPtrBucket *next = (TQPtrBucket*)n->getNext(); + deleteItem( n->getData() ); + delete n; + n = next; + } + } + break; + } + vec[j] = 0; // detach list of buckets + } + } + if ( iterators && iterators->count() ) { // invalidate all iterators + TQGDictIterator *i = iterators->first(); + while ( i ) { + i->curNode = 0; + i = iterators->next(); + } + } +} + +/*! + Outputs debug statistics. +*/ +void TQGDict::statistics() const +{ +#if defined(QT_DEBUG) + TQString line; + line.fill( '-', 60 ); + double real, ideal; + qDebug( line.ascii() ); + qDebug( "DICTIONARY STATISTICS:" ); + if ( count() == 0 ) { + qDebug( "Empty!" ); + qDebug( line.ascii() ); + return; + } + real = 0.0; + ideal = (float)count()/(2.0*size())*(count()+2.0*size()-1); + uint i = 0; + while ( igetNext(); + } + real = real + (double)b * ((double)b+1.0)/2.0; + char buf[80], *pbuf; + if ( b > 78 ) + b = 78; + pbuf = buf; + while ( b-- ) + *pbuf++ = '*'; + *pbuf = '\0'; + qDebug( buf ); + i++; + } + qDebug( "Array size = %d", size() ); + qDebug( "# items = %d", count() ); + qDebug( "Real dist = %g", real ); + qDebug( "Rand dist = %g", ideal ); + qDebug( "Real/Rand = %g", real/ideal ); + qDebug( line.ascii() ); +#endif // QT_DEBUG +} + + +/***************************************************************************** + TQGDict stream functions + *****************************************************************************/ +#ifndef QT_NO_DATASTREAM +TQDataStream &operator>>( TQDataStream &s, TQGDict &dict ) +{ + return dict.read( s ); +} + +TQDataStream &operator<<( TQDataStream &s, const TQGDict &dict ) +{ + return dict.write( s ); +} + +#if defined(Q_CC_DEC) && defined(__alpha) && (__DECCXX_VER-0 >= 50190001) +#pragma message disable narrowptr +#endif + +/*! + Reads a dictionary from the stream \a s. +*/ + +TQDataStream &TQGDict::read( TQDataStream &s ) +{ + uint num; + s >> num; // read number of items + clear(); // clear dict + while ( num-- ) { // read all items + Item d; + switch ( keytype ) { + case StringKey: + { + TQString k; + s >> k; + read( s, d ); + look_string( k, d, op_insert ); + } + break; + case AsciiKey: + { + char *k; + s >> k; + read( s, d ); + look_ascii( k, d, op_insert ); + if ( copyk ) + delete [] k; + } + break; + case IntKey: + { + Q_UINT32 k; + s >> k; + read( s, d ); + look_int( k, d, op_insert ); + } + break; + case PtrKey: + { + Q_UINT32 k; + s >> k; + read( s, d ); + // ### cannot insert 0 - this renders the thing + // useless since all pointers are written as 0, + // but hey, serializing pointers? can it be done + // at all, ever? + if ( k ) + look_ptr( (void *)k, d, op_insert ); + } + break; + } + } + return s; +} + +/*! + Writes the dictionary to the stream \a s. +*/ + +TQDataStream& TQGDict::write( TQDataStream &s ) const +{ + s << count(); // write number of items + uint i = 0; + while ( igetKey(); + break; + case AsciiKey: + s << ((TQAsciiBucket*)n)->getKey(); + break; + case IntKey: + s << (Q_UINT32)((TQIntBucket*)n)->getKey(); + break; + case PtrKey: + s << (Q_UINT32)0; // ### cannot serialize a pointer + break; + } + write( s, n->getData() ); // write data + n = n->getNext(); + } + i++; + } + return s; +} +#endif //QT_NO_DATASTREAM + +/***************************************************************************** + TQGDictIterator member functions + *****************************************************************************/ + +/*! + \class TQGDictIterator qgdict.h + \reentrant + \ingroup collection + \brief The TQGDictIterator class is an internal class for implementing TQDictIterator and TQIntDictIterator. + + \internal + + TQGDictIterator is a strictly internal class that does the heavy work for + TQDictIterator and TQIntDictIterator. +*/ + +/*! + Constructs an iterator that operates on the dictionary \a d. +*/ + +TQGDictIterator::TQGDictIterator( const TQGDict &d ) +{ + dict = (TQGDict *)&d; // get reference to dict + toFirst(); // set to first noe + if ( !dict->iterators ) { + dict->iterators = new TQGDItList; // create iterator list + Q_CHECK_PTR( dict->iterators ); + } + dict->iterators->append( this ); // attach iterator to dict +} + +/*! + Constructs a copy of the iterator \a it. +*/ + +TQGDictIterator::TQGDictIterator( const TQGDictIterator &it ) +{ + dict = it.dict; + curNode = it.curNode; + curIndex = it.curIndex; + if ( dict ) + dict->iterators->append( this ); // attach iterator to dict +} + +/*! + Assigns a copy of the iterator \a it and returns a reference to this + iterator. +*/ + +TQGDictIterator &TQGDictIterator::operator=( const TQGDictIterator &it ) +{ + if ( dict ) // detach from old dict + dict->iterators->removeRef( this ); + dict = it.dict; + curNode = it.curNode; + curIndex = it.curIndex; + if ( dict ) + dict->iterators->append( this ); // attach to new list + return *this; +} + +/*! + Destroys the iterator. +*/ + +TQGDictIterator::~TQGDictIterator() +{ + if ( dict ) // detach iterator from dict + dict->iterators->removeRef( this ); +} + + +/*! + Sets the iterator to point to the first item in the dictionary. +*/ + +TQPtrCollection::Item TQGDictIterator::toFirst() +{ + if ( !dict ) { +#if defined(QT_CHECK_NULL) + qWarning( "TQGDictIterator::toFirst: Dictionary has been deleted" ); +#endif + return 0; + } + if ( dict->count() == 0 ) { // empty dictionary + curNode = 0; + return 0; + } + register uint i = 0; + register TQBaseBucket **v = dict->vec; + while ( !(*v++) ) + i++; + curNode = dict->vec[i]; + curIndex = i; + return curNode->getData(); +} + + +/*! + Moves to the next item (postfix). +*/ + +TQPtrCollection::Item TQGDictIterator::operator()() +{ + if ( !dict ) { +#if defined(QT_CHECK_NULL) + qWarning( "TQGDictIterator::operator(): Dictionary has been deleted" ); +#endif + return 0; + } + if ( !curNode ) + return 0; + TQPtrCollection::Item d = curNode->getData(); + this->operator++(); + return d; +} + +/*! + Moves to the next item (prefix). +*/ + +TQPtrCollection::Item TQGDictIterator::operator++() +{ + if ( !dict ) { +#if defined(QT_CHECK_NULL) + qWarning( "TQGDictIterator::operator++: Dictionary has been deleted" ); +#endif + return 0; + } + if ( !curNode ) + return 0; + curNode = curNode->getNext(); + if ( !curNode ) { // no next bucket + register uint i = curIndex + 1; // look from next vec element + register TQBaseBucket **v = &dict->vec[i]; + while ( i < dict->size() && !(*v++) ) + i++; + if ( i == dict->size() ) { // nothing found + curNode = 0; + return 0; + } + curNode = dict->vec[i]; + curIndex = i; + } + return curNode->getData(); +} + +/*! + Moves \a jumps positions forward. +*/ + +TQPtrCollection::Item TQGDictIterator::operator+=( uint jumps ) +{ + while ( curNode && jumps-- ) + operator++(); + return curNode ? curNode->getData() : 0; +} diff --git a/src/tools/qgdict.h b/src/tools/qgdict.h new file mode 100644 index 000000000..13d27fd81 --- /dev/null +++ b/src/tools/qgdict.h @@ -0,0 +1,225 @@ +/**************************************************************************** +** +** Definition of TQGDict and TQGDictIterator classes +** +** Created : 920529 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQGDICT_H +#define TQGDICT_H + +#ifndef QT_H +#include "qptrcollection.h" +#include "qstring.h" +#endif // QT_H + +class TQGDictIterator; +class TQGDItList; + + +class TQBaseBucket // internal dict node +{ +public: + TQPtrCollection::Item getData() { return data; } + TQPtrCollection::Item setData( TQPtrCollection::Item d ) { return data = d; } + TQBaseBucket *getNext() { return next; } + void setNext( TQBaseBucket *n) { next = n; } +protected: + TQBaseBucket( TQPtrCollection::Item d, TQBaseBucket *n ) : data(d), next(n) {} + TQPtrCollection::Item data; + TQBaseBucket *next; +}; + +class TQStringBucket : public TQBaseBucket +{ +public: + TQStringBucket( const TQString &k, TQPtrCollection::Item d, TQBaseBucket *n ) + : TQBaseBucket(d,n), key(k) {} + const TQString &getKey() const { return key; } +private: + TQString key; +}; + +class TQAsciiBucket : public TQBaseBucket +{ +public: + TQAsciiBucket( const char *k, TQPtrCollection::Item d, TQBaseBucket *n ) + : TQBaseBucket(d,n), key(k) {} + const char *getKey() const { return key; } +private: + const char *key; +}; + +class TQIntBucket : public TQBaseBucket +{ +public: + TQIntBucket( long k, TQPtrCollection::Item d, TQBaseBucket *n ) + : TQBaseBucket(d,n), key(k) {} + long getKey() const { return key; } +private: + long key; +}; + +class TQPtrBucket : public TQBaseBucket +{ +public: + TQPtrBucket( void *k, TQPtrCollection::Item d, TQBaseBucket *n ) + : TQBaseBucket(d,n), key(k) {} + void *getKey() const { return key; } +private: + void *key; +}; + + +class Q_EXPORT TQGDict : public TQPtrCollection // generic dictionary class +{ +public: + uint count() const { return numItems; } + uint size() const { return vlen; } + TQPtrCollection::Item look_string( const TQString& key, TQPtrCollection::Item, + int ); + TQPtrCollection::Item look_ascii( const char *key, TQPtrCollection::Item, int ); + TQPtrCollection::Item look_int( long key, TQPtrCollection::Item, int ); + TQPtrCollection::Item look_ptr( void *key, TQPtrCollection::Item, int ); +#ifndef QT_NO_DATASTREAM + TQDataStream &read( TQDataStream & ); + TQDataStream &write( TQDataStream & ) const; +#endif +protected: + enum KeyType { StringKey, AsciiKey, IntKey, PtrKey }; + + TQGDict( uint len, KeyType kt, bool cs, bool ck ); + TQGDict( const TQGDict & ); + ~TQGDict(); + + TQGDict &operator=( const TQGDict & ); + + bool remove_string( const TQString &key, TQPtrCollection::Item item=0 ); + bool remove_ascii( const char *key, TQPtrCollection::Item item=0 ); + bool remove_int( long key, TQPtrCollection::Item item=0 ); + bool remove_ptr( void *key, TQPtrCollection::Item item=0 ); + TQPtrCollection::Item take_string( const TQString &key ); + TQPtrCollection::Item take_ascii( const char *key ); + TQPtrCollection::Item take_int( long key ); + TQPtrCollection::Item take_ptr( void *key ); + + void clear(); + void resize( uint ); + + int hashKeyString( const TQString & ); + int hashKeyAscii( const char * ); + + void statistics() const; + +#ifndef QT_NO_DATASTREAM + virtual TQDataStream &read( TQDataStream &, TQPtrCollection::Item & ); + virtual TQDataStream &write( TQDataStream &, TQPtrCollection::Item ) const; +#endif +private: + TQBaseBucket **vec; + uint vlen; + uint numItems; + uint keytype : 2; + uint cases : 1; + uint copyk : 1; + TQGDItList *iterators; + void unlink_common( int, TQBaseBucket *, TQBaseBucket * ); + TQStringBucket *unlink_string( const TQString &, + TQPtrCollection::Item item = 0 ); + TQAsciiBucket *unlink_ascii( const char *, TQPtrCollection::Item item = 0 ); + TQIntBucket *unlink_int( long, TQPtrCollection::Item item = 0 ); + TQPtrBucket *unlink_ptr( void *, TQPtrCollection::Item item = 0 ); + void init( uint, KeyType, bool, bool ); + friend class TQGDictIterator; +}; + + +class Q_EXPORT TQGDictIterator // generic dictionary iterator +{ +friend class TQGDict; +public: + TQGDictIterator( const TQGDict & ); + TQGDictIterator( const TQGDictIterator & ); + TQGDictIterator &operator=( const TQGDictIterator & ); + ~TQGDictIterator(); + + TQPtrCollection::Item toFirst(); + + TQPtrCollection::Item get() const; + TQString getKeyString() const; + const char *getKeyAscii() const; + long getKeyInt() const; + void *getKeyPtr() const; + + TQPtrCollection::Item operator()(); + TQPtrCollection::Item operator++(); + TQPtrCollection::Item operator+=(uint); + +protected: + TQGDict *dict; + +private: + TQBaseBucket *curNode; + uint curIndex; +}; + +inline TQPtrCollection::Item TQGDictIterator::get() const +{ + return curNode ? curNode->getData() : 0; +} + +inline TQString TQGDictIterator::getKeyString() const +{ + return curNode ? ((TQStringBucket*)curNode)->getKey() : TQString::null; +} + +inline const char *TQGDictIterator::getKeyAscii() const +{ + return curNode ? ((TQAsciiBucket*)curNode)->getKey() : 0; +} + +inline long TQGDictIterator::getKeyInt() const +{ + return curNode ? ((TQIntBucket*)curNode)->getKey() : 0; +} + +inline void *TQGDictIterator::getKeyPtr() const +{ + return curNode ? ((TQPtrBucket*)curNode)->getKey() : 0; +} + + +#endif // TQGDICT_H diff --git a/src/tools/qgeneric.h b/src/tools/qgeneric.h new file mode 100644 index 000000000..6f918c866 --- /dev/null +++ b/src/tools/qgeneric.h @@ -0,0 +1,46 @@ +/**************************************************************************** +** +** Macros for pasting tokens; utilized by our generic classes +** +** Created : 920529 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQGENERIC_H +#define TQGENERIC_H + +#error "do not include qgeneric.h any more" + +#endif // TQGENERIC_H diff --git a/src/tools/qglist.cpp b/src/tools/qglist.cpp new file mode 100644 index 000000000..adfc2a002 --- /dev/null +++ b/src/tools/qglist.cpp @@ -0,0 +1,1267 @@ +/**************************************************************************** +** +** Implementation of TQGList and TQGListIterator classes +** +** Created : 920624 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "qglist.h" +#include "qgvector.h" +#include "qdatastream.h" +#include "qvaluelist.h" + +/*! + \class TQLNode qglist.h + \reentrant + \ingroup collection + \brief The TQLNode class is an internal class for the TQPtrList template collection. + + \internal + + TQLNode is a doubly-linked list node. It has three pointers: + \list 1 + \i Pointer to the previous node. + \i Pointer to the next node. + \i Pointer to the actual data. + \endlist + + It might sometimes be practical to have direct access to the list nodes + in a TQPtrList, but it is seldom retquired. + + Be very careful if you want to access the list nodes. The heap can + easily get corrupted if you make a mistake. + + \sa TQPtrList::currentNode(), TQPtrList::removeNode(), TQPtrList::takeNode() +*/ + +/*! + \fn TQPtrCollection::Item TQLNode::getData() + Returns a pointer (\c void*) to the actual data in the list node. +*/ + + +/*! + \class TQGList qglist.h + \reentrant + \ingroup collection + \brief The TQGList class is an internal class for implementing TQt collection classes. + + \internal + + TQGList is a strictly internal class that acts as a base class for + several collection classes; TQPtrList, TQPtrQueue and TQPtrStack. + + TQGList has some virtual functions that can be reimplemented to + customize the subclasses, namely compareItems(), read() and + write. Normally, you do not have to reimplement any of these + functions. If you still want to reimplement them, see the TQStrList + class (qstrlist.h) for an example. +*/ + + +/* Internal helper class for TQGList. Contains some optimization for + the typically case where only one iterators is activre on the list. + */ +class TQGListIteratorList +{ +public: + TQGListIteratorList() + : list(0), iterator(0) { + } + ~TQGListIteratorList() { + notifyClear( TRUE ); + delete list; + } + + void add( TQGListIterator* i ) { + if ( !iterator ) { + iterator = i; + } else if ( list ) { + list->push_front( i ); + } else { + list = new TQValueList; + list->push_front( i ); + } + } + + void remove( TQGListIterator* i ) { + if ( iterator == i ) { + iterator = 0; + } else if ( list ) { + list->remove( i ); + if ( list->isEmpty() ) { + delete list; + list = 0; + } + } + } + + void notifyClear( bool zeroList ) { + if ( iterator ) { + if ( zeroList ) + iterator->list = 0; + iterator->curNode = 0; + } + if ( list ) { + for ( TQValueList::Iterator i = list->begin(); i != list->end(); ++i ) { + if ( zeroList ) + (*i)->list = 0; + (*i)->curNode = 0; + } + } + } + + void notifyRemove( TQLNode* n, TQLNode* curNode ) { + if ( iterator ) { + if ( iterator->curNode == n ) + iterator->curNode = curNode; + } + if ( list ) { + for ( TQValueList::Iterator i = list->begin(); i != list->end(); ++i ) { + if ( (*i)->curNode == n ) + (*i)->curNode = curNode; + } + } + } + +private: + TQValueList* list; + TQGListIterator* iterator; +}; + + + +/***************************************************************************** + Default implementation of virtual functions + *****************************************************************************/ + +/*! + Documented as TQPtrList::compareItems(). + + Compares \a item1 with \a item2. +*/ +int TQGList::compareItems( TQPtrCollection::Item item1, TQPtrCollection::Item item2 ) +{ + return item1 != item2; // compare pointers +} + +#ifndef QT_NO_DATASTREAM +/*! + \overload + Reads a collection/list item from the stream \a s and returns a reference + to the stream. + + The default implementation sets \a item to 0. + + \sa write() +*/ + +TQDataStream &TQGList::read( TQDataStream &s, TQPtrCollection::Item &item ) +{ + item = 0; + return s; +} + +/*! + \overload + Writes a collection/list item to the stream \a s and + returns a reference to the stream. + + The default implementation does nothing. + + \sa read() +*/ + +TQDataStream &TQGList::write( TQDataStream &s, TQPtrCollection::Item ) const +{ + return s; +} +#endif // QT_NO_DATASTREAM + +/***************************************************************************** + TQGList member functions + *****************************************************************************/ + +/*! + Constructs an empty list. +*/ + +TQGList::TQGList() +{ + firstNode = lastNode = curNode = 0; // initialize list + numNodes = 0; + curIndex = -1; + iterators = 0; // initialize iterator list +} + +/*! + Constructs a copy of \a list. +*/ + +TQGList::TQGList( const TQGList & list ) + : TQPtrCollection( list ) +{ + firstNode = lastNode = curNode = 0; // initialize list + numNodes = 0; + curIndex = -1; + iterators = 0; // initialize iterator list + TQLNode *n = list.firstNode; + while ( n ) { // copy all items from list + append( n->data ); + n = n->next; + } +} + +/*! + Removes all items from the list and destroys the list. +*/ + +TQGList::~TQGList() +{ + clear(); + delete iterators; + // Workaround for GCC 2.7.* bug. Compiler constructs 'static' TQGList + // instances twice on the same address and therefore tries to destruct + // twice on the same address! This is insane but let's try not to crash + // here. + iterators = 0; +} + + +/*! + Assigns \a list to this list. +*/ + +TQGList& TQGList::operator=( const TQGList &list ) +{ + if ( &list == this ) + return *this; + + clear(); + if ( list.count() > 0 ) { + TQLNode *n = list.firstNode; + while ( n ) { // copy all items from list + append( n->data ); + n = n->next; + } + curNode = firstNode; + curIndex = 0; + } + return *this; +} + +/*! + Compares this list with \a list. Returns TRUE if the lists + contain the same data, otherwise FALSE. +*/ + +bool TQGList::operator==( const TQGList &list ) const +{ + if ( count() != list.count() ) + return FALSE; + + if ( count() == 0 ) + return TRUE; + + TQLNode *n1 = firstNode; + TQLNode *n2 = list.firstNode; + while ( n1 && n2 ) { + // should be mutable + if ( ( (TQGList*)this )->compareItems( n1->data, n2->data ) != 0 ) + return FALSE; + n1 = n1->next; + n2 = n2->next; + } + + return TRUE; +} + +/*! + \fn uint TQGList::count() const + + Returns the number of items in the list. +*/ + + +/*! + Returns the node at position \a index. Sets this node to current. +*/ + +TQLNode *TQGList::locate( uint index ) +{ + if ( index == (uint)curIndex ) // current node ? + return curNode; + if ( !curNode && firstNode ) { // set current node + curNode = firstNode; + curIndex = 0; + } + register TQLNode *node; + int distance = index - curIndex; // node distance to cur node + bool forward; // direction to traverse + + if ( index >= numNodes ) + return 0; + + if ( distance < 0 ) + distance = -distance; + if ( (uint)distance < index && (uint)distance < numNodes - index ) { + node = curNode; // start from current node + forward = index > (uint)curIndex; + } else if ( index < numNodes - index ) { // start from first node + node = firstNode; + distance = index; + forward = TRUE; + } else { // start from last node + node = lastNode; + distance = numNodes - index - 1; + if ( distance < 0 ) + distance = 0; + forward = FALSE; + } + if ( forward ) { // now run through nodes + while ( distance-- ) + node = node->next; + } else { + while ( distance-- ) + node = node->prev; + } + curIndex = index; // must update index + return curNode = node; +} + + +/*! + Inserts item \a d at its sorted position in the list. +*/ + +void TQGList::inSort( TQPtrCollection::Item d ) +{ + int index = 0; + register TQLNode *n = firstNode; + while ( n && compareItems(n->data,d) < 0 ){ // find position in list + n = n->next; + index++; + } + insertAt( index, d ); +} + + +/*! + Inserts item \a d at the start of the list. +*/ + +void TQGList::prepend( TQPtrCollection::Item d ) +{ + register TQLNode *n = new TQLNode( newItem(d) ); + Q_CHECK_PTR( n ); + n->prev = 0; + if ( (n->next = firstNode) ) // list is not empty + firstNode->prev = n; + else // initialize list + lastNode = n; + firstNode = curNode = n; // curNode affected + numNodes++; + curIndex = 0; +} + + +/*! + Inserts item \a d at the end of the list. +*/ + +void TQGList::append( TQPtrCollection::Item d ) +{ + register TQLNode *n = new TQLNode( newItem(d) ); + Q_CHECK_PTR( n ); + n->next = 0; + if ( (n->prev = lastNode) ) // list is not empty + lastNode->next = n; + else // initialize list + firstNode = n; + lastNode = curNode = n; // curNode affected + curIndex = numNodes; + numNodes++; +} + + +/*! + Inserts item \a d at position \a index in the list. +*/ + +bool TQGList::insertAt( uint index, TQPtrCollection::Item d ) +{ + if ( index == 0 ) { + prepend( d ); + return TRUE; + } else if ( index == numNodes ) { + append( d ); + return TRUE; + } + TQLNode *nextNode = locate( index ); + if ( !nextNode ) + return FALSE; + TQLNode *prevNode = nextNode->prev; + register TQLNode *n = new TQLNode( newItem(d) ); + Q_CHECK_PTR( n ); + nextNode->prev = n; + prevNode->next = n; + n->prev = prevNode; // link new node into list + n->next = nextNode; + curNode = n; // curIndex set by locate() + numNodes++; + return TRUE; +} + + +/*! + Relinks node \a n and makes it the first node in the list. +*/ + +void TQGList::relinkNode( TQLNode *n ) +{ + if ( n == firstNode ) // already first + return; + curNode = n; + unlink(); + n->prev = 0; + if ( (n->next = firstNode) ) // list is not empty + firstNode->prev = n; + else // initialize list + lastNode = n; + firstNode = curNode = n; // curNode affected + numNodes++; + curIndex = 0; +} + + +/*! + Unlinks the current list node and returns a pointer to this node. +*/ + +TQLNode *TQGList::unlink() +{ + if ( curNode == 0 ) // null current node + return 0; + register TQLNode *n = curNode; // unlink this node + if ( n == firstNode ) { // removing first node ? + if ( (firstNode = n->next) ) { + firstNode->prev = 0; + } else { + lastNode = curNode = 0; // list becomes empty + curIndex = -1; + } + } else { + if ( n == lastNode ) { // removing last node ? + lastNode = n->prev; + lastNode->next = 0; + } else { // neither last nor first node + n->prev->next = n->next; + n->next->prev = n->prev; + } + } + + if ( n->next ) { // change current node + curNode = n->next; + } else if ( n->prev ) { + curNode = n->prev; + curIndex--; + } + + if ( iterators ) + iterators->notifyRemove( n, curNode ); + numNodes--; + return n; +} + + +/*! + Removes the node \a n from the list. +*/ + +bool TQGList::removeNode( TQLNode *n ) +{ +#if defined(QT_CHECK_NULL) + if ( n == 0 || (n->prev && n->prev->next != n) || + (n->next && n->next->prev != n) ) { + qWarning( "TQGList::removeNode: Corrupted node" ); + return FALSE; + } +#endif + curNode = n; + unlink(); // unlink node + deleteItem( n->data ); // deallocate this node + delete n; + curNode = firstNode; + curIndex = curNode ? 0 : -1; + return TRUE; +} + +/*! + Removes the item \a d from the list. Uses compareItems() to find the item. + + If \a d is 0, removes the current item. +*/ + +bool TQGList::remove( TQPtrCollection::Item d ) +{ + if ( d && find(d) == -1 ) + return FALSE; + TQLNode *n = unlink(); + if ( !n ) + return FALSE; + deleteItem( n->data ); + delete n; + return TRUE; +} + +/*! + Removes the item \a d from the list. +*/ + +bool TQGList::removeRef( TQPtrCollection::Item d ) +{ + if ( findRef(d) == -1 ) + return FALSE; + TQLNode *n = unlink(); + if ( !n ) + return FALSE; + deleteItem( n->data ); + delete n; + return TRUE; +} + +/*! + \fn bool TQGList::removeFirst() + + Removes the first item in the list. +*/ + +/*! + \fn bool TQGList::removeLast() + + Removes the last item in the list. +*/ + +/*! + Removes the item at position \a index from the list. +*/ + +bool TQGList::removeAt( uint index ) +{ + if ( !locate(index) ) + return FALSE; + TQLNode *n = unlink(); + if ( !n ) + return FALSE; + deleteItem( n->data ); + delete n; + return TRUE; +} + + +/*! + Replaces the item at index \a index with \a d. +*/ +bool TQGList::replaceAt( uint index, TQPtrCollection::Item d ) +{ + TQLNode *n = locate( index ); + if ( !n ) + return FALSE; + if ( n->data != d ) { + deleteItem( n->data ); + n->data = newItem( d ); + } + return TRUE; +} + + + +/*! + Takes the node \a n out of the list. +*/ + +TQPtrCollection::Item TQGList::takeNode( TQLNode *n ) +{ +#if defined(QT_CHECK_NULL) + if ( n == 0 || (n->prev && n->prev->next != n) || + (n->next && n->next->prev != n) ) { + qWarning( "TQGList::takeNode: Corrupted node" ); + return 0; + } +#endif + curNode = n; + unlink(); // unlink node + Item d = n->data; + delete n; // delete the node, not data + curNode = firstNode; + curIndex = curNode ? 0 : -1; + return d; +} + +/*! + Takes the current item out of the list. +*/ + +TQPtrCollection::Item TQGList::take() +{ + TQLNode *n = unlink(); // unlink node + Item d = n ? n->data : 0; + delete n; // delete node, keep contents + return d; +} + +/*! + Takes the item at position \a index out of the list. +*/ + +TQPtrCollection::Item TQGList::takeAt( uint index ) +{ + if ( !locate(index) ) + return 0; + TQLNode *n = unlink(); // unlink node + Item d = n ? n->data : 0; + delete n; // delete node, keep contents + return d; +} + +/*! + Takes the first item out of the list. +*/ + +TQPtrCollection::Item TQGList::takeFirst() +{ + first(); + TQLNode *n = unlink(); // unlink node + Item d = n ? n->data : 0; + delete n; + return d; +} + +/*! + Takes the last item out of the list. +*/ + +TQPtrCollection::Item TQGList::takeLast() +{ + last(); + TQLNode *n = unlink(); // unlink node + Item d = n ? n->data : 0; + delete n; + return d; +} + + +/*! + Removes all items from the list. +*/ + +void TQGList::clear() +{ + register TQLNode *n = firstNode; + + firstNode = lastNode = curNode = 0; // initialize list + numNodes = 0; + curIndex = -1; + + if ( iterators ) + iterators->notifyClear( FALSE ); + + TQLNode *prevNode; + while ( n ) { // for all nodes ... + deleteItem( n->data ); // deallocate data + prevNode = n; + n = n->next; + delete prevNode; // deallocate node + } +} + + +/*! + Finds item \a d in the list. If \a fromStart is TRUE the search + begins at the first node; otherwise it begins at the current node. +*/ + +int TQGList::findRef( TQPtrCollection::Item d, bool fromStart ) +{ + register TQLNode *n; + int index; + if ( fromStart ) { // start from first node + n = firstNode; + index = 0; + } else { // start from current node + n = curNode; + index = curIndex; + } + while ( n && n->data != d ) { // find exact match + n = n->next; + index++; + } + curNode = n; + curIndex = n ? index : -1; + return curIndex; // return position of item +} + +/*! + Finds item \a d in the list using compareItems(). If \a fromStart is + TRUE the search begins at the first node; otherwise it begins at the + current node. +*/ + +int TQGList::find( TQPtrCollection::Item d, bool fromStart ) +{ + register TQLNode *n; + int index; + if ( fromStart ) { // start from first node + n = firstNode; + index = 0; + } else { // start from current node + n = curNode; + index = curIndex; + } + while ( n && compareItems(n->data,d) ){ // find equal match + n = n->next; + index++; + } + curNode = n; + curIndex = n ? index : -1; + return curIndex; // return position of item +} + + +/*! + Counts the number item \a d occurs in the list. +*/ + +uint TQGList::containsRef( TQPtrCollection::Item d ) const +{ + register TQLNode *n = firstNode; + uint count = 0; + while ( n ) { // for all nodes... + if ( n->data == d ) // count # exact matches + count++; + n = n->next; + } + return count; +} + +/*! + Counts the number of times item \a d occurs in the list. Uses + compareItems(). +*/ + +uint TQGList::contains( TQPtrCollection::Item d ) const +{ + register TQLNode *n = firstNode; + uint count = 0; + TQGList *that = (TQGList*)this; // mutable for compareItems() + while ( n ) { // for all nodes... + if ( !that->compareItems(n->data,d) ) // count # equal matches + count++; + n = n->next; + } + return count; +} + + +/*! + \overload TQPtrCollection::Item TQGList::at( uint index ) + + Sets the item at position \a index to the current item. +*/ + +/*! + \fn int TQGList::at() const + + Returns the current index. +*/ + +/*! + \fn TQLNode *TQGList::currentNode() const + + Returns the current node. +*/ + +/*! + \fn TQPtrCollection::Item TQGList::get() const + + Returns the current item. +*/ + +/*! + \fn TQPtrCollection::Item TQGList::cfirst() const + + Returns the first item in the list. +*/ + +/*! + \fn TQPtrCollection::Item TQGList::clast() const + + Returns the last item in the list. +*/ + + +/*! + Returns the first list item. Sets this to current. +*/ + +TQPtrCollection::Item TQGList::first() +{ + if ( firstNode ) { + curIndex = 0; + return (curNode=firstNode)->data; + } + return 0; +} + +/*! + Returns the last list item. Sets this to current. +*/ + +TQPtrCollection::Item TQGList::last() +{ + if ( lastNode ) { + curIndex = numNodes-1; + return (curNode=lastNode)->data; + } + return 0; +} + +/*! + Returns the next list item (after current). Sets this to current. +*/ + +TQPtrCollection::Item TQGList::next() +{ + if ( curNode ) { + if ( curNode->next ) { + curIndex++; + curNode = curNode->next; + return curNode->data; + } + curIndex = -1; + curNode = 0; + } + return 0; +} + +/*! + Returns the previous list item (before current). Sets this to current. +*/ + +TQPtrCollection::Item TQGList::prev() +{ + if ( curNode ) { + if ( curNode->prev ) { + curIndex--; + curNode = curNode->prev; + return curNode->data; + } + curIndex = -1; + curNode = 0; + } + return 0; +} + + +/*! + Converts the list to a vector, \a vector. +*/ + +void TQGList::toVector( TQGVector *vector ) const +{ + vector->clear(); + if ( !vector->resize( count() ) ) + return; + register TQLNode *n = firstNode; + uint i = 0; + while ( n ) { + vector->insert( i, n->data ); + n = n->next; + i++; + } +} + +void TQGList::heapSortPushDown( TQPtrCollection::Item* heap, int first, int last ) +{ + int r = first; + while( r <= last/2 ) { + // Node r has only one child ? + if ( last == 2*r ) { + // Need for swapping ? + if ( compareItems( heap[r], heap[ 2*r ] ) > 0 ) { + TQPtrCollection::Item tmp = heap[r]; + heap[ r ] = heap[ 2*r ]; + heap[ 2*r ] = tmp; + } + // That's it ... + r = last; + } else { + // Node has two children + if ( compareItems( heap[r], heap[ 2*r ] ) > 0 && + compareItems( heap[ 2*r ], heap[ 2*r+1 ] ) <= 0 ) { + // Swap with left child + TQPtrCollection::Item tmp = heap[r]; + heap[ r ] = heap[ 2*r ]; + heap[ 2*r ] = tmp; + r *= 2; + } else if ( compareItems( heap[r], heap[ 2*r+1 ] ) > 0 && + compareItems( heap[ 2*r+1 ], heap[ 2*r ] ) < 0 ) { + // Swap with right child + TQPtrCollection::Item tmp = heap[r]; + heap[ r ] = heap[ 2*r+1 ]; + heap[ 2*r+1 ] = tmp; + r = 2*r+1; + } else { + // We are done + r = last; + } + } + } +} + + +/*! Sorts the list by the result of the virtual compareItems() function. + + The Heap-Sort algorithm is used for sorting. It sorts n items with + O(n*log n) compares. This is the asymptotic optimal solution of the + sorting problem. +*/ + +void TQGList::sort() +{ + uint n = count(); + if ( n < 2 ) + return; + + // Create the heap + TQPtrCollection::Item* realheap = new TQPtrCollection::Item[ n ]; + // Wow, what a fake. But I want the heap to be indexed as 1...n + TQPtrCollection::Item* heap = realheap - 1; + int size = 0; + TQLNode* insert = firstNode; + for( ; insert != 0; insert = insert->next ) { + heap[++size] = insert->data; + int i = size; + while( i > 1 && compareItems( heap[i], heap[ i / 2 ] ) < 0 ) { + TQPtrCollection::Item tmp = heap[ i ]; + heap[ i ] = heap[ i/2 ]; + heap[ i/2 ] = tmp; + i /= 2; + } + } + + insert = firstNode; + // Now do the sorting + for ( int i = n; i > 0; i-- ) { + insert->data = heap[1]; + insert = insert->next; + if ( i > 1 ) { + heap[1] = heap[i]; + heapSortPushDown( heap, 1, i - 1 ); + } + } + + delete [] realheap; +} + + +/***************************************************************************** + TQGList stream functions + *****************************************************************************/ + +#ifndef QT_NO_DATASTREAM +TQDataStream &operator>>( TQDataStream &s, TQGList &list ) +{ // read list + return list.read( s ); +} + +TQDataStream &operator<<( TQDataStream &s, const TQGList &list ) +{ // write list + return list.write( s ); +} + +/*! + Reads a list from the stream \a s. +*/ + +TQDataStream &TQGList::read( TQDataStream &s ) +{ + uint num; + s >> num; // read number of items + clear(); // clear list + while ( num-- ) { // read all items + Item d; + read( s, d ); + Q_CHECK_PTR( d ); + if ( !d ) // no memory + break; + TQLNode *n = new TQLNode( d ); + Q_CHECK_PTR( n ); + if ( !n ) // no memory + break; + n->next = 0; + if ( (n->prev = lastNode) ) // list is not empty + lastNode->next = n; + else // initialize list + firstNode = n; + lastNode = n; + numNodes++; + } + curNode = firstNode; + curIndex = curNode ? 0 : -1; + return s; +} + +/*! + Writes the list to the stream \a s. +*/ + +TQDataStream &TQGList::write( TQDataStream &s ) const +{ + s << count(); // write number of items + TQLNode *n = firstNode; + while ( n ) { // write all items + write( s, n->data ); + n = n->next; + } + return s; +} + +#endif // QT_NO_DATASTREAM + + + +/*! \internal + */ +TQLNode* TQGList::erase( TQLNode* it ) +{ + TQLNode* n = it; + it = it->next; + removeNode( n ); + return it; +} + + +/***************************************************************************** + TQGListIterator member functions + *****************************************************************************/ + +/*! + \class TQGListIterator qglist.h + \reentrant + \ingroup collection + \brief The TQGListIterator class is an internal class for implementing TQPtrListIterator. + + \internal + + TQGListIterator is a strictly internal class that does the heavy work for + TQPtrListIterator. +*/ + +/*! + \internal + Constructs an iterator that operates on the list \a l. +*/ + +TQGListIterator::TQGListIterator( const TQGList &l ) +{ + list = (TQGList *)&l; // get reference to list + curNode = list->firstNode; // set to first node + if ( !list->iterators ) { + list->iterators = new TQGListIteratorList; // create iterator list + Q_CHECK_PTR( list->iterators ); + } + list->iterators->add( this ); // attach iterator to list +} + +/*! + \internal + Constructs a copy of the iterator \a it. +*/ + +TQGListIterator::TQGListIterator( const TQGListIterator &it ) +{ + list = it.list; + curNode = it.curNode; + if ( list ) + list->iterators->add( this ); // attach iterator to list +} + +/*! + \internal + Assigns a copy of the iterator \a it and returns a reference to this + iterator. +*/ + +TQGListIterator &TQGListIterator::operator=( const TQGListIterator &it ) +{ + if ( list ) // detach from old list + list->iterators->remove( this ); + list = it.list; + curNode = it.curNode; + if ( list ) + list->iterators->add( this ); // attach to new list + return *this; +} + +/*! + \internal + Destroys the iterator. +*/ + +TQGListIterator::~TQGListIterator() +{ + if ( list ) // detach iterator from list + list->iterators->remove(this); +} + + +/*! + \fn bool TQGListIterator::atFirst() const + \internal + Returns TRUE if the iterator points to the first item, otherwise FALSE. +*/ + +/*! + \fn bool TQGListIterator::atLast() const + \internal + Returns TRUE if the iterator points to the last item, otherwise FALSE. +*/ + + +/*! + \internal + Sets the list iterator to point to the first item in the list. +*/ + +TQPtrCollection::Item TQGListIterator::toFirst() +{ + if ( !list ) { +#if defined(QT_CHECK_NULL) + qWarning( "TQGListIterator::toFirst: List has been deleted" ); +#endif + return 0; + } + return list->firstNode ? (curNode = list->firstNode)->getData() : 0; +} + +/*! + \internal + Sets the list iterator to point to the last item in the list. +*/ + +TQPtrCollection::Item TQGListIterator::toLast() +{ + if ( !list ) { +#if defined(QT_CHECK_NULL) + qWarning( "TQGListIterator::toLast: List has been deleted" ); +#endif + return 0; + } + return list->lastNode ? (curNode = list->lastNode)->getData() : 0; +} + + +/*! + \fn TQPtrCollection::Item TQGListIterator::get() const + \internal + Returns the iterator item. +*/ + + +/*! + \internal + Moves to the next item (postfix). +*/ + +TQPtrCollection::Item TQGListIterator::operator()() +{ + if ( !curNode ) + return 0; + TQPtrCollection::Item d = curNode->getData(); + curNode = curNode->next; + return d; +} + +/*! + \internal + Moves to the next item (prefix). +*/ + +TQPtrCollection::Item TQGListIterator::operator++() +{ + if ( !curNode ) + return 0; + curNode = curNode->next; + return curNode ? curNode->getData() : 0; +} + +/*! + \internal + Moves \a jumps positions forward. +*/ + +TQPtrCollection::Item TQGListIterator::operator+=( uint jumps ) +{ + while ( curNode && jumps-- ) + curNode = curNode->next; + return curNode ? curNode->getData() : 0; +} + +/*! + \internal + Moves to the previous item (prefix). +*/ + +TQPtrCollection::Item TQGListIterator::operator--() +{ + if ( !curNode ) + return 0; + curNode = curNode->prev; + return curNode ? curNode->getData() : 0; +} + +/*! + \internal + Moves \a jumps positions backward. +*/ + +TQPtrCollection::Item TQGListIterator::operator-=( uint jumps ) +{ + while ( curNode && jumps-- ) + curNode = curNode->prev; + return curNode ? curNode->getData() : 0; +} diff --git a/src/tools/qglist.h b/src/tools/qglist.h new file mode 100644 index 000000000..87425554b --- /dev/null +++ b/src/tools/qglist.h @@ -0,0 +1,271 @@ +/**************************************************************************** +** +** Definition of TQGList and TQGListIterator classes +** +** Created : 920624 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQGLIST_H +#define TQGLIST_H + +#ifndef QT_H +#include "qptrcollection.h" +#endif // QT_H + +class Q_EXPORT TQLNode +{ +friend class TQGList; +friend class TQGListIterator; +friend class TQGListStdIterator; +public: + TQPtrCollection::Item getData() { return data; } +private: + TQPtrCollection::Item data; + TQLNode *prev; + TQLNode *next; + TQLNode( TQPtrCollection::Item d ) { data = d; } +}; + +class TQGListIteratorList; // internal helper class + +class Q_EXPORT TQGList : public TQPtrCollection // doubly linked generic list +{ +friend class TQGListIterator; +friend class TQGListIteratorList; +friend class TQGVector; // needed by TQGVector::toList +public: + uint count() const; // return number of nodes + +#ifndef QT_NO_DATASTREAM + TQDataStream &read( TQDataStream & ); // read list from stream + TQDataStream &write( TQDataStream & ) const; // write list to stream +#endif +protected: + TQGList(); // create empty list + TQGList( const TQGList & ); // make copy of other list + virtual ~TQGList(); + + TQGList &operator=( const TQGList & ); // assign from other list + bool operator==( const TQGList& ) const; + + void inSort( TQPtrCollection::Item ); // add item sorted in list + void append( TQPtrCollection::Item ); // add item at end of list + bool insertAt( uint index, TQPtrCollection::Item ); // add item at i'th position + void relinkNode( TQLNode * ); // relink as first item + bool removeNode( TQLNode * ); // remove node + bool remove( TQPtrCollection::Item = 0 ); // remove item (0=current) + bool removeRef( TQPtrCollection::Item = 0 ); // remove item (0=current) + bool removeFirst(); // remove first item + bool removeLast(); // remove last item + bool removeAt( uint ); // remove item at i'th position + bool replaceAt( uint, TQPtrCollection::Item ); // replace item at position i with item + TQPtrCollection::Item takeNode( TQLNode * ); // take out node + TQPtrCollection::Item take(); // take out current item + TQPtrCollection::Item takeAt( uint index ); // take out item at i'th pos + TQPtrCollection::Item takeFirst(); // take out first item + TQPtrCollection::Item takeLast(); // take out last item + + void sort(); // sort all items; + void clear(); // remove all items + + int findRef( TQPtrCollection::Item, bool = TRUE ); // find exact item in list + int find( TQPtrCollection::Item, bool = TRUE ); // find equal item in list + + uint containsRef( TQPtrCollection::Item ) const; // get number of exact matches + uint contains( TQPtrCollection::Item ) const; // get number of equal matches + + TQPtrCollection::Item at( uint index ); // access item at i'th pos + int at() const; // get current index + TQLNode *currentNode() const; // get current node + + TQPtrCollection::Item get() const; // get current item + + TQPtrCollection::Item cfirst() const; // get ptr to first list item + TQPtrCollection::Item clast() const; // get ptr to last list item + TQPtrCollection::Item first(); // set first item in list curr + TQPtrCollection::Item last(); // set last item in list curr + TQPtrCollection::Item next(); // set next item in list curr + TQPtrCollection::Item prev(); // set prev item in list curr + + void toVector( TQGVector * ) const; // put items in vector + + virtual int compareItems( TQPtrCollection::Item, TQPtrCollection::Item ); + +#ifndef QT_NO_DATASTREAM + virtual TQDataStream &read( TQDataStream &, TQPtrCollection::Item & ); + virtual TQDataStream &write( TQDataStream &, TQPtrCollection::Item ) const; +#endif + + TQLNode* begin() const { return firstNode; } + TQLNode* end() const { return 0; } + TQLNode* erase( TQLNode* it ); + +private: + void prepend( TQPtrCollection::Item ); // add item at start of list + + void heapSortPushDown( TQPtrCollection::Item* heap, int first, int last ); + + TQLNode *firstNode; // first node + TQLNode *lastNode; // last node + TQLNode *curNode; // current node + int curIndex; // current index + uint numNodes; // number of nodes + TQGListIteratorList *iterators; // list of iterators + + TQLNode *locate( uint ); // get node at i'th pos + TQLNode *unlink(); // unlink node +}; + + +inline uint TQGList::count() const +{ + return numNodes; +} + +inline bool TQGList::removeFirst() +{ + first(); + return remove(); +} + +inline bool TQGList::removeLast() +{ + last(); + return remove(); +} + +inline int TQGList::at() const +{ + return curIndex; +} + +inline TQPtrCollection::Item TQGList::at( uint index ) +{ + TQLNode *n = locate( index ); + return n ? n->data : 0; +} + +inline TQLNode *TQGList::currentNode() const +{ + return curNode; +} + +inline TQPtrCollection::Item TQGList::get() const +{ + return curNode ? curNode->data : 0; +} + +inline TQPtrCollection::Item TQGList::cfirst() const +{ + return firstNode ? firstNode->data : 0; +} + +inline TQPtrCollection::Item TQGList::clast() const +{ + return lastNode ? lastNode->data : 0; +} + + +/***************************************************************************** + TQGList stream functions + *****************************************************************************/ + +#ifndef QT_NO_DATASTREAM +Q_EXPORT TQDataStream &operator>>( TQDataStream &, TQGList & ); +Q_EXPORT TQDataStream &operator<<( TQDataStream &, const TQGList & ); +#endif + +/***************************************************************************** + TQGListIterator class + *****************************************************************************/ + +class Q_EXPORT TQGListIterator // TQGList iterator +{ +friend class TQGList; +friend class TQGListIteratorList; +protected: + TQGListIterator( const TQGList & ); + TQGListIterator( const TQGListIterator & ); + TQGListIterator &operator=( const TQGListIterator & ); + ~TQGListIterator(); + + bool atFirst() const; // test if at first item + bool atLast() const; // test if at last item + TQPtrCollection::Item toFirst(); // move to first item + TQPtrCollection::Item toLast(); // move to last item + + TQPtrCollection::Item get() const; // get current item + TQPtrCollection::Item operator()(); // get current and move to next + TQPtrCollection::Item operator++(); // move to next item (prefix) + TQPtrCollection::Item operator+=(uint); // move n positions forward + TQPtrCollection::Item operator--(); // move to prev item (prefix) + TQPtrCollection::Item operator-=(uint); // move n positions backward + +protected: + TQGList *list; // reference to list + +private: + TQLNode *curNode; // current node in list +}; + + +inline bool TQGListIterator::atFirst() const +{ + return curNode == list->firstNode; +} + +inline bool TQGListIterator::atLast() const +{ + return curNode == list->lastNode; +} + +inline TQPtrCollection::Item TQGListIterator::get() const +{ + return curNode ? curNode->data : 0; +} + +class Q_EXPORT TQGListStdIterator +{ +public: + inline TQGListStdIterator( TQLNode* n ) : node( n ){} + inline operator TQLNode* () { return node; } +protected: + inline TQLNode *next() { return node->next; } + TQLNode *node; +}; + + +#endif // TQGLIST_H diff --git a/src/tools/qglobal.cpp b/src/tools/qglobal.cpp new file mode 100644 index 000000000..4bb43db69 --- /dev/null +++ b/src/tools/qglobal.cpp @@ -0,0 +1,927 @@ +/**************************************************************************** +** +** Global functions +** +** Created : 920604 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "qplatformdefs.h" + +#include "qasciidict.h" +#include +#include +#include +#include +#include + +#if defined(Q_CC_MSVC) && !defined(Q_CC_MSVC_NET) && !defined(Q_OS_TEMP) +#include +#endif + + +/*! + \relates TQApplication + + Returns the TQt version number as a string, for example, "2.3.0" or + "3.0.5". + + The \c QT_VERSION define has the numeric value in the form: + 0xmmiibb (m = major, i = minor, b = bugfix). For example, TQt + 3.0.5's \c QT_VERSION is 0x030005. +*/ + +const char *qVersion() +{ + return QT_VERSION_STR; +} + +bool qSharedBuild() +{ +#ifdef QT_SHARED + return TRUE; +#else + return FALSE; +#endif +} + +/***************************************************************************** + System detection routines + *****************************************************************************/ + +static bool si_alreadyDone = FALSE; +static int si_wordSize; +static bool si_bigEndian; + +/*! + \relates TQApplication + + Obtains information about the system. + + The system's word size in bits (typically 32) is returned in \a + *wordSize. The \a *bigEndian is set to TRUE if this is a big-endian + machine, or to FALSE if this is a little-endian machine. + + In debug mode, this function calls qFatal() with a message if the + computer is truly weird (i.e. different endianness for 16 bit and + 32 bit integers); in release mode it returns FALSE. +*/ + +bool qSysInfo( int *wordSize, bool *bigEndian ) +{ +#if defined(QT_CHECK_NULL) + Q_ASSERT( wordSize != 0 ); + Q_ASSERT( bigEndian != 0 ); +#endif + + if ( si_alreadyDone ) { // run it only once + *wordSize = si_wordSize; + *bigEndian = si_bigEndian; + return TRUE; + } + + si_wordSize = 0; + Q_ULONG n = (Q_ULONG)(~0); + while ( n ) { // detect word size + si_wordSize++; + n /= 2; + } + *wordSize = si_wordSize; + + if ( *wordSize != 64 && + *wordSize != 32 && + *wordSize != 16 ) { // word size: 16, 32 or 64 +#if defined(QT_CHECK_RANGE) + qFatal( "qSysInfo: Unsupported system word size %d", *wordSize ); +#endif + return FALSE; + } + if ( sizeof(Q_INT8) != 1 || sizeof(Q_INT16) != 2 || sizeof(Q_INT32) != 4 || + sizeof(Q_ULONG)*8 != si_wordSize || sizeof(float) != 4 || sizeof(double) != 8 ) { +#if defined(QT_CHECK_RANGE) + qFatal( "qSysInfo: Unsupported system data type size" ); +#endif + return FALSE; + } + + bool be16, be32; // determine byte ordering + short ns = 0x1234; + int nl = 0x12345678; + + unsigned char *p = (unsigned char *)(&ns); // 16-bit integer + be16 = *p == 0x12; + + p = (unsigned char *)(&nl); // 32-bit integer + if ( p[0] == 0x12 && p[1] == 0x34 && p[2] == 0x56 && p[3] == 0x78 ) + be32 = TRUE; + else + if ( p[0] == 0x78 && p[1] == 0x56 && p[2] == 0x34 && p[3] == 0x12 ) + be32 = FALSE; + else + be32 = !be16; + + if ( be16 != be32 ) { // strange machine! +#if defined(QT_CHECK_RANGE) + qFatal( "qSysInfo: Inconsistent system byte order" ); +#endif + return FALSE; + } + + *bigEndian = si_bigEndian = be32; + si_alreadyDone = TRUE; + return TRUE; +} + +#if !defined(TQWS) && defined(Q_OS_MAC) + +#include "qt_mac.h" + +// This function has descended from Apple Source Code (FSpLocationFromFullPath), +// but changes have been made. [Creates a minimal alias from the full pathname] +OSErr qt_mac_create_fsspec(const TQString &file, FSSpec *spec) +{ + FSRef fref; + TQCString utfs = file.utf8(); + OSErr ret = FSPathMakeRef((const UInt8 *)utfs.data(), &fref, NULL); + if(ret == noErr) + ret = FSGetCatalogInfo(&fref, kFSCatInfoNone, NULL, NULL, spec, NULL); + return ret; +} + +CFStringRef qstring2cfstring(const TQString &str) +{ + return CFStringCreateWithCharacters(0, (UniChar *)str.unicode(), str.length()); +} + +TQString cfstring2qstring(CFStringRef str) +{ + if(!str) + return TQString(); + + CFIndex length = CFStringGetLength(str); + if(const UniChar *chars = CFStringGetCharactersPtr(str)) + return TQString((TQChar *)chars, length); + UniChar *buffer = (UniChar*)malloc(length * sizeof(UniChar)); + CFStringGetCharacters(str, CFRangeMake(0, length), buffer); + TQString ret((TQChar *)buffer, length); + free(buffer); + return ret; +} + +unsigned char *p_str(const TQString &s) +{ + CFStringRef cfstr = qstring2cfstring(s); + uchar *p = (uchar*)malloc(256); + CFStringGetPascalString(cfstr, p, 256, CFStringGetSystemEncoding()); + CFRelease(cfstr); + return p; +} + +TQString p2qstring(const unsigned char *c) { + CFStringRef cfstr = CFStringCreateWithPascalString(0, c, CFStringGetSystemEncoding()); + TQString str = cfstring2qstring(cfstr); + CFRelease(cfstr); + return str; +} + +int qMacVersion() +{ + static int macver = TQt::MV_Unknown; + static bool first = TRUE; + if(first) { + first = FALSE; + long gestalt_version; + if(Gestalt(gestaltSystemVersion, &gestalt_version) == noErr) { + macver = ((gestalt_version & 0x00f0) >> 4) + 2; + + } + } + return macver; +} +TQt::MacintoshVersion qt_macver = (TQt::MacintoshVersion)qMacVersion(); + +// HFS+ filesystems use decomposing unicode for certain layers in unicode +// In general these don't look great as a user visible string. +// Therefore it is a good idea to normalize them ourselves. +// These technotes on Apple's website: +// http://developer.apple.com/qa/qa2001/qa1235.html +// http://developer.apple.com/qa/qa2001/qa1173.html +TQString qt_mac_precomposeFileName(const TQString &str) +{ + if (str.isEmpty()) + return str; + int strLength = str.length(); + CFMutableStringRef cfmstr = CFStringCreateMutable(0, strLength); + CFStringAppendCharacters(cfmstr, (UniChar *)str.unicode(), strLength); + CFStringNormalize(cfmstr, kCFStringNormalizationFormC); + TQString newStr = cfstring2qstring(cfmstr); + CFRelease(cfmstr); + return newStr; +} +#elif defined(Q_OS_WIN32) || defined(Q_OS_CYGWIN) || defined(Q_OS_TEMP) +bool qt_winunicode; +# ifdef Q_OS_TEMP + DWORD qt_cever = 0; +# endif // Q_OS_TEMP + +#include "qt_windows.h" + +int qWinVersion() +{ +#ifndef VER_PLATFORM_WIN32s +#define VER_PLATFORM_WIN32s 0 +#endif +#ifndef VER_PLATFORM_WIN32_WINDOWS +#define VER_PLATFORM_WIN32_WINDOWS 1 +#endif +#ifndef VER_PLATFORM_WIN32_NT +#define VER_PLATFORM_WIN32_NT 2 +#endif +#ifndef VER_PLATFORM_WIN32_CE +#define VER_PLATFORM_WIN32_CE 3 +#endif + + static int winver = TQt::WV_NT; + static int t=0; + if ( !t ) { + t=1; +#ifndef Q_OS_TEMP + OSVERSIONINFOA osver; + osver.dwOSVersionInfoSize = sizeof(osver); + GetVersionExA( &osver ); +#else + OSVERSIONINFOW osver; + osver.dwOSVersionInfoSize = sizeof(osver); + GetVersionEx( &osver ); + qt_cever = osver.dwMajorVersion * 100; + qt_cever += osver.dwMinorVersion * 10; +#endif + switch ( osver.dwPlatformId ) { + case VER_PLATFORM_WIN32s: + winver = TQt::WV_32s; + break; + case VER_PLATFORM_WIN32_WINDOWS: + // We treat Windows Me (minor 90) the same as Windows 98 + if ( osver.dwMinorVersion == 90 ) + winver = TQt::WV_Me; + else if ( osver.dwMinorVersion == 10 ) + winver = TQt::WV_98; + else + winver = TQt::WV_95; + break; + case VER_PLATFORM_WIN32_CE: +#ifdef Q_OS_TEMP + if ( qt_cever >= 400 ) + winver = TQt::WV_CENET; + else +#endif + winver = TQt::WV_CE; + break; + default: // VER_PLATFORM_WIN32_NT + if ( osver.dwMajorVersion < 5 ) { + winver = TQt::WV_NT; + } else if (osver.dwMajorVersion == 6) { + winver = TQt::WV_VISTA; + } else if ( osver.dwMinorVersion == 0 ) { + winver = TQt::WV_2000; + } else if ( osver.dwMinorVersion == 1 ) { + winver = TQt::WV_XP; + } else if ( osver.dwMinorVersion == 2 ) { + winver = TQt::WV_2003; + } else { + qWarning("Untested Windows version detected!"); + winver = TQt::WV_NT_based; + } + } + } + +#if defined(UNICODE) + if ( winver & TQt::WV_NT_based ) + qt_winunicode = TRUE; + else +#endif + qt_winunicode = FALSE; + + return winver; +} + +TQt::WindowsVersion qt_winver = (TQt::WindowsVersion)qWinVersion(); +#endif + + +/***************************************************************************** + Debug output routines + *****************************************************************************/ + +/*! + \fn void qDebug( const char *msg, ... ) + + \relates TQApplication + + Prints a debug message \a msg, or calls the message handler (if it + has been installed). + + This function takes a format string and a list of arguments, + similar to the C printf() function. + + Example: + \code + qDebug( "my window handle = %x", myWidget->id() ); + \endcode + + Under X11, the text is printed to stderr. Under Windows, the text + is sent to the debugger. + + \warning The internal buffer is limited to 8196 bytes (including + the '\0'-terminator). + + \warning Passing (const char *)0 as argument to qDebug might lead + to crashes on certain platforms due to the platforms printf implementation. + + \sa qWarning(), qFatal(), qInstallMsgHandler(), + \link debug.html Debugging\endlink +*/ + +/*! + \fn void qWarning( const char *msg, ... ) + + \relates TQApplication + + Prints a warning message \a msg, or calls the message handler (if + it has been installed). + + This function takes a format string and a list of arguments, + similar to the C printf() function. + + Example: + \code + void f( int c ) + { + if ( c > 200 ) + qWarning( "f: bad argument, c == %d", c ); + } + \endcode + + Under X11, the text is printed to stderr. Under Windows, the text + is sent to the debugger. + + \warning The internal buffer is limited to 8196 bytes (including + the '\0'-terminator). + + \warning Passing (const char *)0 as argument to qWarning might lead + to crashes on certain platforms due to the platforms printf implementation. + + \sa qDebug(), qFatal(), qInstallMsgHandler(), + \link debug.html Debugging\endlink +*/ + +/*! + \fn void qFatal( const char *msg, ... ) + + \relates TQApplication + + Prints a fatal error message \a msg and exits, or calls the + message handler (if it has been installed). + + This function takes a format string and a list of arguments, + similar to the C printf() function. + + Example: + \code + int divide( int a, int b ) + { + if ( b == 0 ) // program error + qFatal( "divide: cannot divide by zero" ); + return a/b; + } + \endcode + + Under X11, the text is printed to stderr. Under Windows, the text + is sent to the debugger. + + \warning The internal buffer is limited to 8196 bytes (including + the '\0'-terminator). + + \warning Passing (const char *)0 as argument to qFatal might lead + to crashes on certain platforms due to the platforms printf implementation. + + \sa qDebug(), qWarning(), qInstallMsgHandler(), + \link debug.html Debugging\endlink +*/ + + +static TQtMsgHandler handler = 0; // pointer to debug handler +static const int QT_BUFFER_LENGTH = 8196; // internal buffer length + + +#ifdef Q_CC_MWERKS + +#include "qt_mac.h" + +extern bool qt_is_gui_used; +static void mac_default_handler( const char *msg ) +{ + if ( qt_is_gui_used ) { + const unsigned char *p = p_str(msg); + DebugStr(p); + free((void*)p); + } else { + fprintf( stderr, msg ); + } +} + +#endif + + +void qDebug( const char *msg, ... ) +{ + char buf[QT_BUFFER_LENGTH]; + va_list ap; + va_start( ap, msg ); // use variable arg list +#if defined(QT_VSNPRINTF) + QT_VSNPRINTF( buf, QT_BUFFER_LENGTH, msg, ap ); +#else + vsprintf( buf, msg, ap ); +#endif + va_end( ap ); + if ( handler ) { + (*handler)( TQtDebugMsg, buf ); + } else { +#if defined(Q_CC_MWERKS) + mac_default_handler(buf); +#elif defined(Q_OS_TEMP) + TQString fstr( buf ); + OutputDebugString( (fstr + "\n").ucs2() ); +#else + fprintf( stderr, "%s\n", buf ); // add newline +#endif + } +} + +// copied... this looks really bad. +void debug( const char *msg, ... ) +{ + char buf[QT_BUFFER_LENGTH]; + va_list ap; + va_start( ap, msg ); // use variable arg list +#if defined(QT_VSNPRINTF) + QT_VSNPRINTF( buf, QT_BUFFER_LENGTH, msg, ap ); +#else + vsprintf( buf, msg, ap ); +#endif + va_end( ap ); + if ( handler ) { + (*handler)( TQtDebugMsg, buf ); + } else { +#if defined(Q_CC_MWERKS) + mac_default_handler(buf); +#elif defined(Q_OS_TEMP) + TQString fstr( buf ); + OutputDebugString( (fstr + "\n").ucs2() ); +#else + fprintf( stderr, "%s\n", buf ); // add newline +#endif + } +} + +void qWarning( const char *msg, ... ) +{ + char buf[QT_BUFFER_LENGTH]; + va_list ap; + va_start( ap, msg ); // use variable arg list +#if defined(QT_VSNPRINTF) + QT_VSNPRINTF( buf, QT_BUFFER_LENGTH, msg, ap ); +#else + vsprintf( buf, msg, ap ); +#endif + va_end( ap ); + if ( handler ) { + (*handler)( TQtWarningMsg, buf ); + } else { +#if defined(Q_CC_MWERKS) + mac_default_handler(buf); +#elif defined(Q_OS_TEMP) + TQString fstr( buf ); + OutputDebugString( (fstr + "\n").ucs2() ); +#else + fprintf( stderr, "%s\n", buf ); // add newline +#endif + } +} + + +// again, copied +void warning( const char *msg, ... ) +{ + char buf[QT_BUFFER_LENGTH]; + va_list ap; + va_start( ap, msg ); // use variable arg list +#if defined(QT_VSNPRINTF) + QT_VSNPRINTF( buf, QT_BUFFER_LENGTH, msg, ap ); +#else + vsprintf( buf, msg, ap ); +#endif + va_end( ap ); + if ( handler ) { + (*handler)( TQtWarningMsg, buf ); + } else { +#if defined(Q_CC_MWERKS) + mac_default_handler(buf); +#elif defined(Q_OS_TEMP) + TQString fstr( buf ); + OutputDebugString( (fstr + "\n").ucs2() ); +#else + fprintf( stderr, "%s\n", buf ); // add newline +#endif + } +} + +void qFatal( const char *msg, ... ) +{ + char buf[QT_BUFFER_LENGTH]; + va_list ap; + va_start( ap, msg ); // use variable arg list +#if defined(QT_VSNPRINTF) + QT_VSNPRINTF( buf, QT_BUFFER_LENGTH, msg, ap ); +#else + vsprintf( buf, msg, ap ); +#endif + va_end( ap ); + if ( handler ) { + (*handler)( TQtFatalMsg, buf ); + } else { +#if defined(Q_CC_MWERKS) + mac_default_handler(buf); +#else + fprintf( stderr, "%s\n", buf ); // add newline +#endif +#if defined(Q_OS_UNIX) && defined(QT_DEBUG) + abort(); // trap; generates core dump +#elif defined(Q_OS_TEMP) && defined(QT_DEBUG) + TQString fstr; + fstr.sprintf( "%s:%s %s %s\n", __FILE__, __LINE__, QT_VERSION_STR, buf ); + OutputDebugString( fstr.ucs2() ); +#elif defined(_CRT_ERROR) && defined(_DEBUG) + _CrtDbgReport( _CRT_ERROR, __FILE__, __LINE__, QT_VERSION_STR, buf ); +#else + exit( 1 ); // goodbye cruel world +#endif + } +} + +// yet again, copied +void fatal( const char *msg, ... ) +{ + char buf[QT_BUFFER_LENGTH]; + va_list ap; + va_start( ap, msg ); // use variable arg list +#if defined(QT_VSNPRINTF) + QT_VSNPRINTF( buf, QT_BUFFER_LENGTH, msg, ap ); +#else + vsprintf( buf, msg, ap ); +#endif + va_end( ap ); + if ( handler ) { + (*handler)( TQtFatalMsg, buf ); + } else { +#if defined(Q_CC_MWERKS) + mac_default_handler(buf); +#else + fprintf( stderr, "%s\n", buf ); // add newline +#endif +#if defined(Q_OS_UNIX) && defined(QT_DEBUG) + abort(); // trap; generates core dump +#elif defined(Q_OS_TEMP) && defined(QT_DEBUG) + TQString fstr; + fstr.sprintf( "%s:%s %s %s\n", __FILE__, __LINE__, QT_VERSION_STR, buf ); + OutputDebugString( fstr.ucs2() ); +#elif defined(_CRT_ERROR) && defined(_DEBUG) + _CrtDbgReport( _CRT_ERROR, __FILE__, __LINE__, QT_VERSION_STR, buf ); +#else + exit( 1 ); // goodbye cruel world +#endif + } +} + +/*! + \relates TQApplication + + Prints the message \a msg and uses \a code to get a system specific + error message. When \a code is -1 (the default), the system's last + error code will be used if possible. Use this method to handle + failures in platform specific API calls. + + This function does nothing when TQt is built with \c QT_NO_DEBUG + defined. +*/ +void qSystemWarning( const char* msg, int code ) +{ +#ifndef QT_NO_DEBUG +#if defined(Q_OS_WIN32) + if ( code == -1 ) + code = GetLastError(); + + if ( !code ) + return; + + unsigned short *string; + QT_WA( { + FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM, + NULL, + code, + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + (LPTSTR)&string, + 0, + NULL ); + + qWarning( "%s\n\tError code %d - %s", msg, code, TQString::fromUcs2(string).latin1() ); + }, { + FormatMessageA( FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM, + NULL, + code, + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + (char*)&string, + 0, + NULL ); + + qWarning( "%s\n\tError code %d - %s", msg, code, (const char*)string ); + } ); + LocalFree( (HLOCAL)string ); +#else + if ( code != -1 ) + qWarning( "%s\n\tError code %d - %s", msg, code, strerror( code ) ); + else + qWarning( "%s", msg ); +#endif +#else + Q_UNUSED( msg ); + Q_UNUSED( code ); +#endif +} + +/*! + \fn void Q_ASSERT( bool test ) + + \relates TQApplication + + Prints a warning message containing the source code file name and + line number if \a test is FALSE. + + This is really a macro defined in \c qglobal.h. + + Q_ASSERT is useful for testing pre- and post-conditions. + + Example: + \code + // + // File: div.cpp + // + + #include + + int divide( int a, int b ) + { + Q_ASSERT( b != 0 ); // this is line 9 + return a/b; + } + \endcode + + If \c b is zero, the Q_ASSERT statement will output the following + message using the qWarning() function: + \code + ASSERT: "b != 0" in div.cpp (9) + \endcode + + \sa qWarning(), \link debug.html Debugging\endlink +*/ + + +/*! + \fn void Q_CHECK_PTR( void *p ) + + \relates TQApplication + + If \a p is 0, prints a warning message containing the source code file + name and line number, saying that the program ran out of memory. + + This is really a macro defined in \c qglobal.h. + + Example: + \code + int *a; + + Q_CHECK_PTR( a = new int[80] ); // WRONG! + + a = new (nothrow) int[80]; // Right + Q_CHECK_PTR( a ); + \endcode + + \sa qWarning(), \link debug.html Debugging\endlink +*/ + + +// +// The Q_CHECK_PTR macro calls this function to check if an allocation went ok. +// +#if (QT_VERSION-0 >= 0x040000) +#if defined(Q_CC_GNU) +#warning "Change Q_CHECK_PTR to '{if ((p)==0) qt_check_pointer(__FILE__,__LINE__);}'" +#warning "No need for qt_check_pointer() to return a value - make it void!" +#endif +#endif +bool qt_check_pointer( bool c, const char *n, int l ) +{ + if ( c ) + qWarning( "In file %s, line %d: Out of memory", n, l ); + return TRUE; +} + + +static bool firstObsoleteWarning(const char *obj, const char *oldfunc ) +{ + static TQAsciiDict *obsoleteDict = 0; + if ( !obsoleteDict ) { // first time func is called + obsoleteDict = new TQAsciiDict; +#if defined(QT_DEBUG) + qDebug( + "You are using obsolete functions in the TQt library. Call the function\n" + "qSuppressObsoleteWarnings() to suppress obsolete warnings.\n" + ); +#endif + } + TQCString s( obj ); + s += "::"; + s += oldfunc; + if ( obsoleteDict->find(s.data()) == 0 ) { + obsoleteDict->insert( s.data(), (int*)1 ); // anything different from 0 + return TRUE; + } + return FALSE; +} + +static bool suppressObsolete = FALSE; + +void qSuppressObsoleteWarnings( bool suppress ) +{ + suppressObsolete = suppress; +} + +void qObsolete( const char *obj, const char *oldfunc, const char *newfunc ) +{ + if ( suppressObsolete ) + return; + if ( !firstObsoleteWarning(obj, oldfunc) ) + return; + if ( obj ) + qDebug( "%s::%s: This function is obsolete, use %s instead.", + obj, oldfunc, newfunc ); + else + qDebug( "%s: This function is obsolete, use %s instead.", + oldfunc, newfunc ); +} + +void qObsolete( const char *obj, const char *oldfunc ) +{ + if ( suppressObsolete ) + return; + if ( !firstObsoleteWarning(obj, oldfunc) ) + return; + if ( obj ) + qDebug( "%s::%s: This function is obsolete.", obj, oldfunc ); + else + qDebug( "%s: This function is obsolete.", oldfunc ); +} + +void qObsolete( const char *message ) +{ + if ( suppressObsolete ) + return; + if ( !firstObsoleteWarning( "TQt", message) ) + return; + qDebug( "%s", message ); +} + + +/*! + \relates TQApplication + + Installs a TQt message handler \a h. Returns a pointer to the + message handler previously defined. + + The message handler is a function that prints out debug messages, + warnings and fatal error messages. The TQt library (debug version) + contains hundreds of warning messages that are printed when + internal errors (usually invalid function arguments) occur. If you + implement your own message handler, you get total control of these + messages. + + The default message handler prints the message to the standard + output under X11 or to the debugger under Windows. If it is a + fatal message, the application aborts immediately. + + Only one message handler can be defined, since this is usually + done on an application-wide basis to control debug output. + + To restore the message handler, call \c qInstallMsgHandler(0). + + Example: + \code + #include + #include + #include + + void myMessageOutput( TQtMsgType type, const char *msg ) + { + switch ( type ) { + case TQtDebugMsg: + fprintf( stderr, "Debug: %s\n", msg ); + break; + case TQtWarningMsg: + fprintf( stderr, "Warning: %s\n", msg ); + break; + case TQtFatalMsg: + fprintf( stderr, "Fatal: %s\n", msg ); + abort(); // deliberately core dump + } + } + + int main( int argc, char **argv ) + { + qInstallMsgHandler( myMessageOutput ); + TQApplication a( argc, argv ); + ... + return a.exec(); + } + \endcode + + \sa qDebug(), qWarning(), qFatal(), \link debug.html Debugging\endlink +*/ + +TQtMsgHandler qInstallMsgHandler( TQtMsgHandler h ) +{ + TQtMsgHandler old = handler; + handler = h; + return old; +} + + +/* + Dijkstra's bisection algorithm to find the square root as an integer. + Deliberately not exported as part of the TQt API, but used in both + qsimplerichtext.cpp and qgfxraster_qws.cpp +*/ +unsigned int qt_int_sqrt( unsigned int n ) +{ + // n must be in the range 0...UINT_MAX/2-1 + if ( n >= ( UINT_MAX>>2 ) ) { + unsigned int r = 2 * qt_int_sqrt( n / 4 ); + unsigned int r2 = r + 1; + return ( n >= r2 * r2 ) ? r2 : r; + } + uint h, p= 0, q= 1, r= n; + while ( q <= n ) + q <<= 2; + while ( q != 1 ) { + q >>= 2; + h= p + q; + p >>= 1; + if ( r >= h ) { + p += q; + r -= h; + } + } + return p; +} + diff --git a/src/tools/qglobal.h b/src/tools/qglobal.h new file mode 100644 index 000000000..9afc8cf16 --- /dev/null +++ b/src/tools/qglobal.h @@ -0,0 +1,1137 @@ +/**************************************************************************** +** +** Global type declarations and definitions +** +** Created : 920529 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQGLOBAL_H +#define TQGLOBAL_H + +#define TQT_REAL_TQT 1 + +#define QT_VERSION_STR "3.3.8d" +/* + QT_VERSION is (major << 16) + (minor << 8) + patch. + */ +#define QT_VERSION 0x030308 + +/* + The operating system, must be one of: (Q_OS_x) + + MACX - Mac OS X + MAC9 - Mac OS 9 + DARWIN - Darwin OS (Without Mac OS X) + MSDOS - MS-DOS and Windows + OS2 - OS/2 + OS2EMX - XFree86 on OS/2 (not PM) + WIN32 - Win32 (Windows 95/98/ME and Windows NT/2000/XP) + CYGWIN - Cygwin + SOLARIS - Sun Solaris + HPUX - HP-UX + ULTRIX - DEC Ultrix + LINUX - Linux + FREEBSD - FreeBSD + NETBSD - NetBSD + OPENBSD - OpenBSD + BSDI - BSD/OS + IRIX - SGI Irix + OSF - HP Tru64 UNIX + SCO - SCO OpenServer 5 + UNIXWARE - UnixWare 7, Open UNIX 8 + AIX - AIX + HURD - GNU Hurd + DGUX - DG/UX + RELIANT - Reliant UNIX + DYNIX - DYNIX/ptx + TQNX - TQNX + TQNX6 - TQNX RTP 6.1 + LYNX - LynxOS + BSD4 - Any BSD 4.4 system + UNIX - Any UNIX BSD/SYSV system +*/ + +#if defined(__DARWIN_X11__) +# define Q_OS_DARWIN +#elif defined(__APPLE__) && (defined(__GNUC__) || defined(__xlC__)) +# define Q_OS_MACX +#elif defined(__MACOSX__) +# define Q_OS_MACX +#elif defined(macintosh) +# define Q_OS_MAC9 +#elif defined(__CYGWIN__) +# define Q_OS_CYGWIN +#elif defined(MSDOS) || defined(_MSDOS) +# define Q_OS_MSDOS +#elif defined(__OS2__) +# if defined(__EMX__) +# define Q_OS_OS2EMX +# else +# define Q_OS_OS2 +# endif +#elif !defined(SAG_COM) && (defined(WIN64) || defined(_WIN64) || defined(__WIN64__)) +# define Q_OS_WIN32 +# define Q_OS_WIN64 +#elif !defined(SAG_COM) && (defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)) +# define Q_OS_WIN32 +#elif defined(__MWERKS__) && defined(__INTEL__) +# define Q_OS_WIN32 +#elif defined(__sun) || defined(sun) +# define Q_OS_SOLARIS +#elif defined(hpux) || defined(__hpux) +# define Q_OS_HPUX +#elif defined(__ultrix) || defined(ultrix) +# define Q_OS_ULTRIX +#elif defined(sinix) +# define Q_OS_RELIANT +#elif defined(__GNU__) +# define Q_OS_HURD +#elif defined(__linux__) || defined(__linux) || defined(__GNU__) || defined(__GLIBC__) +# define Q_OS_LINUX +#elif defined(__FreeBSD__) || defined(__DragonFly__) +# define Q_OS_FREEBSD +# define Q_OS_BSD4 +#elif defined(__NetBSD__) +# define Q_OS_NETBSD +# define Q_OS_BSD4 +#elif defined(__OpenBSD__) +# define Q_OS_OPENBSD +# define Q_OS_BSD4 +#elif defined(__bsdi__) +# define Q_OS_BSDI +# define Q_OS_BSD4 +#elif defined(__sgi) +# define Q_OS_IRIX +#elif defined(__osf__) +# define Q_OS_OSF +#elif defined(_AIX) +# define Q_OS_AIX +#elif defined(__Lynx__) +# define Q_OS_LYNX +#elif defined(__DGUX__) +# define Q_OS_DGUX +#elif defined(__QNXNTO__) +# define Q_OS_QNX6 +#elif defined(__QNX__) +# define Q_OS_QNX +#elif defined(_SETQUENT_) +# define Q_OS_DYNIX +#elif defined(_SCO_DS) /* SCO OpenServer 5 + GCC */ +# define Q_OS_SCO +#elif defined(__USLC__) /* all SCO platforms + UDK or OUDK */ +# define Q_OS_UNIXWARE +# define Q_OS_UNIXWARE7 +#elif defined(__svr4__) && defined(i386) /* Open UNIX 8 + GCC */ +# define Q_OS_UNIXWARE +# define Q_OS_UNIXWARE7 +#elif defined(__MAKEDEPEND__) +#else +# error "TQt has not been ported to this OS - talk to qt-bugs@trolltech.com" +#endif + +#if defined(Q_OS_WIN32) || defined(Q_OS_WIN64) +# define Q_OS_WIN +#endif + +#if defined(Q_OS_MAC9) || defined(Q_OS_MACX) +# define Q_OS_MAC +#endif + +#if defined(Q_OS_MAC9) || defined(Q_OS_MSDOS) || defined(Q_OS_OS2) || defined(Q_OS_WIN) +# undef Q_OS_UNIX +#elif !defined(Q_OS_UNIX) +# define Q_OS_UNIX +#endif + +#if defined(Q_OS_MACX) +# ifdef MAC_OS_X_VERSION_MIN_RETQUIRED +# undef MAC_OS_X_VERSION_MIN_RETQUIRED +# endif +# define MAC_OS_X_VERSION_MIN_RETQUIRED MAC_OS_X_VERSION_10_2 +# include +# if !defined(MAC_OS_X_VERSION_10_3) +# define MAC_OS_X_VERSION_10_3 MAC_OS_X_VERSION_10_2 + 1 +# endif +# if !defined(MAC_OS_X_VERSION_10_4) +# define MAC_OS_X_VERSION_10_4 MAC_OS_X_VERSION_10_3 + 1 +# endif +# if (MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_4) +# error "This version of Mac OS X is unsupported" +# endif +#endif + + +/* + The compiler, must be one of: (Q_CC_x) + + SYM - Symantec C++ for both PC and Macintosh + MPW - MPW C++ + MWERKS - Metrowerks CodeWarrior + MSVC - Microsoft Visual C/C++, Intel C++ for Windows + BOR - Borland/Turbo C++ + WAT - Watcom C++ + GNU - GNU C++ + COMEAU - Comeau C++ + EDG - Edison Design Group C++ + OC - CenterLine C++ + SUN - Sun WorkShop, Forte Developer, or Sun ONE Studio C++ + MIPS - MIPSpro C++ + DEC - DEC C++ + HP - HPUX C++ + HPACC - HPUX ANSI C++ + USLC - SCO OUDK, UDK, and UnixWare 2.X C++ + CDS - Reliant C++ + KAI - KAI C++ + INTEL - Intel C++ for Linux, Intel C++ for Windows + HIGHC - MetaWare High C/C++ + PGI - Portland Group C++ + GHS - Green Hills Optimizing C++ Compilers + + Should be sorted most to least authoritative. +*/ + +/* Symantec C++ is now Digital Mars */ +#if defined(__DMC__) || defined(__SC__) +# define Q_CC_SYM +/* "explicit" semantics implemented in 8.1e but keyword recognized since 7.5 */ +# if defined(__SC__) && __SC__ < 0x750 +# define Q_NO_EXPLICIT_KEYWORD +# endif +# define Q_NO_USING_KEYWORD +# if !defined(_CPPUNWIND) +# define Q_NO_EXCEPTIONS +# endif + +#elif defined(applec) +# define Q_CC_MPW +# define Q_NO_BOOL_TYPE +# define Q_NO_EXPLICIT_KEYWORD +# define Q_NO_USING_KEYWORD + +#elif defined(__MWERKS__) +# define Q_CC_MWERKS +/* "explicit" recognized since 4.0d1 */ +# define TQMAC_PASCAL pascal + +#elif defined(_MSC_VER) +# define Q_CC_MSVC +/* proper support of bool for _MSC_VER >= 1100 */ +# define Q_CANNOT_DELETE_CONSTANT +# define Q_INLINE_TEMPLATES inline +/* Visual C++.Net issues for _MSC_VER >= 1300 */ +# if _MSC_VER >= 1300 +# define Q_CC_MSVC_NET +# if _MSC_VER < 1310 || (defined(Q_OS_WIN64) && defined(_M_IA64)) +# define Q_TYPENAME +# endif +# endif +/* Intel C++ disguising as Visual C++: the `using' keyword avoids warnings */ +# if defined(__INTEL_COMPILER) +# define Q_CC_INTEL +# if !defined(__EXCEPTIONS) +# define Q_NO_EXCEPTIONS +# endif +# else +# define Q_NO_USING_KEYWORD /* ### check "using" status */ +# endif + +#elif defined(__BORLANDC__) || defined(__TURBOC__) +# define Q_CC_BOR +# if __BORLANDC__ < 0x502 +# define Q_NO_BOOL_TYPE +# define Q_NO_EXPLICIT_KEYWORD +# endif +# define Q_NO_USING_KEYWORD /* ### check "using" status */ + +#elif defined(__WATCOMC__) +# define Q_CC_WAT +# if defined(Q_OS_QNX4) +/* compiler flags */ +# define Q_TYPENAME +# define Q_NO_BOOL_TYPE +# define Q_CANNOT_DELETE_CONSTANT +# define mutable +/* ??? */ +# define Q_BROKEN_TEMPLATE_SPECIALIZATION +/* no template classes in TQVariant */ +# define QT_NO_TEMPLATE_VARIANT +/* Wcc does not fill in functions needed by valuelists, maps, and + valuestacks implicitly */ +# define Q_FULL_TEMPLATE_INSTANTIATION +/* can we just compare the structures? */ +# define Q_FULL_TEMPLATE_INSTANTIATION_MEMCMP +/* these are not useful to our customers */ +# define QT_QWS_NO_SHM +# define QT_NO_QWS_MULTIPROCESS +# define QT_NO_SQL +# define QT_NO_QWS_CURSOR +# endif + +#elif defined(__GNUC__) +# define Q_CC_GNU +# define Q_C_CALLBACKS +# if __GNUC__ == 2 && __GNUC_MINOR__ <= 7 +# define Q_FULL_TEMPLATE_INSTANTIATION +# endif +/* GCC 2.95 knows "using" but does not support it correctly */ +# if __GNUC__ == 2 && __GNUC_MINOR__ <= 95 +# define Q_NO_USING_KEYWORD +# endif +/* GCC 3.1 and GCC 3.2 wrongly define _SB_CTYPE_MACROS on HP-UX */ +# if defined(Q_OS_HPUX) && __GNUC__ == 3 && __GNUC_MINOR__ >= 1 +# define Q_WRONG_SB_CTYPE_MACROS +# endif + +/* ARM gcc pads structs to 32 bits, even when they contain a single + char, or short. We tell gcc to pack TQChars to 16 bits, to avoid + TQString bloat. However, gcc 3.4 doesn't allow us to create references to + members of a packed struct. (Pointers are OK, because then you + supposedly know what you are doing.) */ +# if (defined(__arm__) || defined(__ARMEL__)) && !defined(__ARM_EABI__) && !defined(QT_MOC_CPP) +# define Q_PACKED __attribute__ ((packed)) +# if __GNUC__ == 3 && __GNUC_MINOR__ >= 4 || __GNUC__ > 3 +# define Q_NO_PACKED_REFERENCE +# endif +# endif +# if !defined(__EXCEPTIONS) +# define Q_NO_EXCEPTIONS +# endif + +/* IBM compiler versions are a bit messy. There are actually two products: + the C product, and the C++ product. The C++ compiler is always packaged + with the latest version of the C compiler. Version numbers do not always + match. This little table (I'm not sure it's accurate) should be helpful: + + C++ product C product + + C Set 3.1 C Compiler 3.0 + ... ... + C++ Compiler 3.6.6 C Compiler 4.3 + ... ... + Visual Age C++ 4.0 ... + ... ... + Visual Age C++ 5.0 C Compiler 5.0 + ... ... + Visual Age C++ 6.0 C Compiler 6.0 + + Now: + __xlC__ is the version of the C compiler in hexadecimal notation + is only an approximation of the C++ compiler version + __IBMCPP__ is the version of the C++ compiler in decimal notation + but it is not defined on older compilers like C Set 3.1 */ +#elif defined(__xlC__) +# define Q_CC_XLC +# define Q_FULL_TEMPLATE_INSTANTIATION +# if __xlC__ < 0x400 +# define Q_NO_BOOL_TYPE +# define Q_NO_EXPLICIT_KEYWORD +# define Q_NO_USING_KEYWORD +# define Q_TYPENAME +# define Q_INLINE_TEMPLATES inline +# define Q_BROKEN_TEMPLATE_SPECIALIZATION +# define Q_CANNOT_DELETE_CONSTANT +# endif + +/* Older versions of DEC C++ do not define __EDG__ or __EDG - observed + on DEC C++ V5.5-004. New versions do define __EDG__ - observed on + Compaq C++ V6.3-002. + This compiler is different enough from other EDG compilers to handle + it separately anyway. */ +#elif defined(__DECCXX) || defined(__DECC) +# define Q_CC_DEC +/* Compaq C++ V6 compilers are EDG-based but I'm not sure about older + DEC C++ V5 compilers. */ +# if defined(__EDG__) +# define Q_CC_EDG +# endif +/* Compaq have disabled EDG's _BOOL macro and use _BOOL_EXISTS instead + - observed on Compaq C++ V6.3-002. + In any case versions prior to Compaq C++ V6.0-005 do not have bool. */ +# if !defined(_BOOL_EXISTS) +# define Q_NO_BOOL_TYPE +# endif +/* Spurious (?) error messages observed on Compaq C++ V6.5-014. */ +# define Q_NO_USING_KEYWORD +/* Apply to all versions prior to Compaq C++ V6.0-000 - observed on + DEC C++ V5.5-004. */ +# if __DECCXX_VER < 60060000 +# define Q_TYPENAME +# define Q_BROKEN_TEMPLATE_SPECIALIZATION +# define Q_CANNOT_DELETE_CONSTANT +# endif +/* avoid undefined symbol problems with out-of-line template members */ +# define Q_INLINE_TEMPLATES inline + +/* Compilers with EDG front end are similar. To detect them we test: + __EDG documented by SGI, observed on MIPSpro 7.3.1.1 and KAI C++ 4.0b + __EDG__ documented in EDG online docs, observed on Compaq C++ V6.3-002 */ +#elif defined(__EDG) || defined(__EDG__) +# define Q_CC_EDG +/* From the EDG documentation (does not seem to apply to Compaq C++): + _BOOL + Defined in C++ mode when bool is a keyword. The name of this + predefined macro is specified by a configuration flag. _BOOL + is the default. + __BOOL_DEFINED + Defined in Microsoft C++ mode when bool is a keyword. */ +# if !defined(_BOOL) && !defined(__BOOL_DEFINED) +# define Q_NO_BOOL_TYPE +# endif + +/* The Comeau compiler is based on EDG and does define __EDG__ */ +# if defined(__COMO__) +# define Q_CC_COMEAU +# define Q_C_CALLBACKS + +/* The `using' keyword was introduced to avoid KAI C++ warnings + but it's now causing KAI C++ errors instead. The standard is + unclear about the use of this keyword, and in practice every + compiler is using its own set of rules. Forget it. */ +# elif defined(__KCC) +# define Q_CC_KAI +# if !defined(_EXCEPTIONS) +# define Q_NO_EXCEPTIONS +# endif +# define Q_NO_USING_KEYWORD + +/* Using the `using' keyword avoids Intel C++ for Linux warnings */ +# elif defined(__INTEL_COMPILER) +# define Q_CC_INTEL +# if !defined(__EXCEPTIONS) +# define Q_NO_EXCEPTIONS +# endif + +/* The Portland Group compiler is based on EDG and does define __EDG__ */ +# elif defined(__PGI) +# define Q_CC_PGI +# if !defined(__EXCEPTIONS) +# define Q_NO_EXCEPTIONS +# endif + +/* Never tested! */ +# elif defined(__ghs) +# define Q_CC_GHS + +/* The UnixWare 7 UDK compiler is based on EDG and does define __EDG__ */ +# elif defined(__USLC__) && defined(__SCO_VERSION__) +# define Q_CC_USLC +/* The latest UDK 7.1.1b does not need this, but previous versions do */ +# if !defined(__SCO_VERSION__) || (__SCO_VERSION__ < 302200010) +# define Q_INLINE_TEMPLATES inline +# endif +# define Q_NO_USING_KEYWORD /* ### check "using" status */ + +/* Never tested! */ +# elif defined(CENTERLINE_CLPP) || defined(OBJECTCENTER) +# define Q_CC_OC +# define Q_NO_USING_KEYWORD + +/* CDS++ defines __EDG__ although this is not documented in the Reliant + documentation. It also follows conventions like _BOOL and this documented */ +# elif defined(sinix) +# define Q_CC_CDS +# define Q_NO_USING_KEYWORD +# if defined(__cplusplus) && (__cplusplus < 2) /* Cfront C++ mode */ +# define Q_NO_EXCEPTIONS +# endif + +/* The MIPSpro compiler in o32 mode is based on EDG but disables features + such as template specialization nevertheless */ +# elif defined(__sgi) +# define Q_CC_MIPS +# if defined(_MIPS_SIM) && (_MIPS_SIM == _ABIO32) /* o32 ABI */ +# define Q_TYPENAME +# define Q_BROKEN_TEMPLATE_SPECIALIZATION +# define Q_NO_EXPLICIT_KEYWORD +# define Q_INLINE_TEMPLATES inline +# elif defined(_COMPILER_VERSION) && (_COMPILER_VERSION < 730) /* 7.2 */ +# define Q_TYPENAME +# define Q_BROKEN_TEMPLATE_SPECIALIZATION +# endif +# define Q_NO_USING_KEYWORD /* ### check "using" status */ +# if defined(_COMPILER_VERSION) && (_COMPILER_VERSION >= 740) +# pragma set woff 3624,3625, 3649 /* turn off some harmless warnings */ +# endif +# endif + +/* The older UnixWare 2.X compiler? */ +#elif defined(__USLC__) +# define Q_CC_USLC +# define Q_TYPENAME +# define Q_NO_BOOL_TYPE +# define Q_NO_EXPLICIT_KEYWORD +# define Q_NO_USING_KEYWORD +# define Q_INLINE_TEMPLATES inline + +/* Never tested! */ +#elif defined(__HIGHC__) +# define Q_CC_HIGHC + +#elif defined(__SUNPRO_CC) || defined(__SUNPRO_C) +# define Q_CC_SUN +/* 5.0 compiler or better + 'bool' is enabled by default but can be disabled using -features=nobool + in which case _BOOL is not defined + this is the default in 4.2 compatibility mode triggered by -compat=4 */ +# if __SUNPRO_CC >= 0x500 +# if !defined(_BOOL) +# define Q_NO_BOOL_TYPE +# endif +# if defined(__SUNPRO_CC_COMPAT) && (__SUNPRO_CC_COMPAT <= 4) +# define Q_NO_USING_KEYWORD +# endif +# define Q_C_CALLBACKS +/* 4.2 compiler or older */ +# else +# define Q_NO_BOOL_TYPE +# define Q_NO_EXPLICIT_KEYWORD +# define Q_NO_USING_KEYWORD +# endif + +/* CDS++ does not seem to define __EDG__ or __EDG according to Reliant + documentation but nevertheless uses EDG conventions like _BOOL */ +#elif defined(sinix) +# define Q_CC_EDG +# define Q_CC_CDS +# if !defined(_BOOL) +# define Q_NO_BOOL_TYPE +# endif +# define Q_BROKEN_TEMPLATE_SPECIALIZATION + +#elif defined(Q_OS_HPUX) +/* __HP_aCC was not defined in first aCC releases */ +# if defined(__HP_aCC) || __cplusplus >= 199707L +# define Q_CC_HPACC +# else +# define Q_CC_HP +# define Q_NO_BOOL_TYPE +# define Q_FULL_TEMPLATE_INSTANTIATION +# define Q_BROKEN_TEMPLATE_SPECIALIZATION +# define Q_NO_EXPLICIT_KEYWORD +# endif +# define Q_NO_USING_KEYWORD /* ### check "using" status */ + +#else +# error "TQt has not been tested with this compiler - talk to qt-bugs@trolltech.com" +#endif + +#ifndef Q_PACKED +# define Q_PACKED +#endif + + +/* + The window system, must be one of: (Q_WS_x) + + MACX - Mac OS X + MAC9 - Mac OS 9 + TQWS - TQt/Embedded + WIN32 - Windows + X11 - X Window System + PM - unsupported + WIN16 - unsupported +*/ + +#if defined(Q_OS_MAC9) +# define Q_WS_MAC9 +#elif defined(Q_OS_MSDOS) +# define Q_WS_WIN16 +# error "TQt retquires Win32 and does not work with Windows 3.x" +#elif defined(_WIN32_X11_) +# define Q_WS_X11 +#elif defined(Q_OS_WIN32) +# define Q_WS_WIN32 +# if defined(Q_OS_WIN64) +# define Q_WS_WIN64 +# endif +#elif defined(Q_OS_OS2) +# define Q_WS_PM +# error "TQt does not work with OS/2 Presentation Manager or Workplace Shell" +#elif defined(Q_OS_UNIX) +# if defined(TQWS) +# define Q_WS_QWS +# define QT_NO_QWS_IM +# elif defined(Q_OS_MACX) +# define Q_WS_MACX +# else +# define Q_WS_X11 +# endif +#endif +#if defined(Q_OS_MAC) && !defined(TQMAC_PASCAL) +# define TQMAC_PASCAL +#endif + +#if defined(Q_WS_WIN16) || defined(Q_WS_WIN32) +# define Q_WS_WIN +#endif + +#if (defined(Q_WS_MAC9) || defined(Q_WS_MACX)) && !defined(Q_WS_QWS) && !defined(Q_WS_X11) +# define Q_WS_MAC +#endif + + +/* + Some classes do not permit copies to be made of an object. + These classes contains a private copy constructor and operator= + to disable copying (the compiler gives an error message). + Undefine Q_DISABLE_COPY to turn off this checking. +*/ + +#define Q_DISABLE_COPY + +#if defined(__cplusplus) + + +// +// Useful type definitions for TQt +// + +#if defined(Q_NO_BOOL_TYPE) +#if defined(Q_CC_HP) +// bool is an unsupported reserved keyword in later versions +#define bool int +#else +typedef int bool; +#endif +#endif + +typedef unsigned char uchar; +typedef unsigned short ushort; +typedef unsigned uint; +typedef unsigned long ulong; +typedef char *pchar; +typedef uchar *puchar; +typedef const char *pcchar; + + +// +// Constant bool values +// + +#ifndef TRUE +const bool FALSE = 0; +const bool TRUE = !0; +#endif +#if defined(__WATCOMC__) +# if defined(Q_OS_QNX4) +const bool false = FALSE; +const bool true = TRUE; +# endif +#endif + +// +// Proper for-scoping +// ### turn on in 4.0 + +#if 0 && defined(Q_CC_MSVC) && !defined(Q_CC_MSVC_NET) +# define for if(0){}else for +#endif + +// +// Use the "explicit" keyword on platforms that support it. +// + +#if !defined(Q_NO_EXPLICIT_KEYWORD) +# define Q_EXPLICIT explicit +#else +# define Q_EXPLICIT +#endif + + +// +// Workaround for static const members on MSVC++. +// + +#if defined(Q_CC_MSVC) +# define QT_STATIC_CONST static +# define QT_STATIC_CONST_IMPL +#else +# define QT_STATIC_CONST static const +# define QT_STATIC_CONST_IMPL const +#endif + + +// +// Utility macros and inline functions +// + +#define TQMAX(a, b) ((b) < (a) ? (a) : (b)) +#define TQMIN(a, b) ((a) < (b) ? (a) : (b)) +#define TQABS(a) ((a) >= 0 ? (a) : -(a)) + +inline int qRound( double d ) +{ + return d >= 0.0 ? int(d + 0.5) : int( d - ((int)d-1) + 0.5 ) + ((int)d-1); +} + + +// +// Size-dependent types (architechture-dependent byte order) +// + +#if !defined(QT_CLEAN_NAMESPACE) +// source compatibility with TQt 1.x +typedef signed char INT8; // 8 bit signed +typedef unsigned char UINT8; // 8 bit unsigned +typedef short INT16; // 16 bit signed +typedef unsigned short UINT16; // 16 bit unsigned +typedef int INT32; // 32 bit signed +typedef unsigned int UINT32; // 32 bit unsigned +#endif + +typedef signed char Q_INT8; // 8 bit signed +typedef unsigned char Q_UINT8; // 8 bit unsigned +typedef short Q_INT16; // 16 bit signed +typedef unsigned short Q_UINT16; // 16 bit unsigned +typedef int Q_INT32; // 32 bit signed +typedef unsigned int Q_UINT32; // 32 bit unsigned +#if defined(Q_OS_WIN64) +typedef __int64 Q_LONG; // word up to 64 bit signed +typedef unsigned __int64 Q_ULONG; // word up to 64 bit unsigned +#else +typedef long Q_LONG; // word up to 64 bit signed +typedef unsigned long Q_ULONG; // word up to 64 bit unsigned +#endif +#if defined(Q_OS_WIN) && !defined(Q_CC_GNU) +# define Q_INT64_C(c) c ## i64 // signed 64 bit constant +# define Q_UINT64_C(c) c ## ui64 // unsigned 64 bit constant +typedef __int64 Q_INT64; // 64 bit signed +typedef unsigned __int64 Q_UINT64; // 64 bit unsigned +#else +# define Q_INT64_C(c) c ## LL // signed 64 bit constant +# define Q_UINT64_C(c) c ## ULL // unsigned 64 bit constant +typedef long long Q_INT64; // 64 bit signed +typedef unsigned long long Q_UINT64; // 64 bit unsigned +#endif +typedef Q_INT64 Q_LLONG; // signed long long +typedef Q_UINT64 Q_ULLONG; // unsigned long long + +#if defined(Q_OS_MACX) && !defined(QT_LARGEFILE_SUPPORT) +# define QT_LARGEFILE_SUPPORT 64 +#endif +#if defined(QT_LARGEFILE_SUPPORT) + typedef Q_ULLONG TQtOffset; +#else + typedef Q_ULONG TQtOffset; +#endif + + +// +// Data stream functions is provided by many classes (defined in qdatastream.h) +// + +class TQDataStream; + + +// +// Feature subsetting +// +// Note that disabling some features will produce a libqt that is not +// compatible with other libqt builds. Such modifications are only +// supported on TQt/Embedded where reducing the library size is important +// and where the application-suite is often a fixed set. +// + +#if !defined(QT_MOC) +#if defined(TQCONFIG_LOCAL) +#include "qconfig-local.h" +#elif defined(TQCONFIG_MINIMAL) +#include "qconfig-minimal.h" +#elif defined(TQCONFIG_SMALL) +#include "qconfig-small.h" +#elif defined(TQCONFIG_MEDIUM) +#include "qconfig-medium.h" +#elif defined(TQCONFIG_LARGE) +#include "qconfig-large.h" +#else // everything... +#include "qconfig.h" +#endif +#endif + + +#ifndef QT_BUILD_KEY +#define QT_BUILD_KEY "unspecified" +#endif + +// prune to local config +#include "qmodules.h" +#ifndef QT_MODULE_DIALOGS +# define QT_NO_DIALOG +#endif +#ifndef QT_MODULE_ICONVIEW +# define QT_NO_ICONVIEW +#endif +#ifndef QT_MODULE_WORKSPACE +# define QT_NO_WORKSPACE +#endif +#ifndef QT_MODULE_NETWORK +#define QT_NO_NETWORK +#endif +#ifndef QT_MODULE_CANVAS +# define QT_NO_CANVAS +#endif +#ifndef QT_MODULE_TABLE +#define QT_NO_TABLE +#endif +#ifndef QT_MODULE_XML +# define QT_NO_XML +#endif +#ifndef QT_MODULE_OPENGL +# define QT_NO_OPENGL +#endif +#if !defined(QT_MODULE_SQL) +# define QT_NO_SQL +#endif + +#if defined(Q_WS_MAC9) +//No need for menu merging +# ifndef TQMAC_QMENUBAR_NO_MERGE +# define TQMAC_QMENUBAR_NO_MERGE +# endif +//Mac9 does not use quartz +# ifndef TQMAC_NO_QUARTZ +# define TQMAC_NO_QUARTZ +# endif +# ifndef TQMAC_QMENUBAR_NO_EVENT +# define TQMAC_QMENUBAR_NO_EVENT +# endif +#endif +#if defined(Q_WS_MACX) //for no nobody uses quartz, just putting in first level hooks +# ifndef TQMAC_NO_QUARTZ +# define TQMAC_NO_QUARTZ +# endif +# ifndef TQMAC_QMENUBAR_NO_EVENT +# define TQMAC_QMENUBAR_NO_EVENT +# endif +#endif + +#if !defined(Q_WS_QWS) && !defined(QT_NO_COP) +# define QT_NO_COP +#endif + +#ifndef QT_H +#include "qfeatures.h" +#endif /* QT_H */ + + +// +// Create TQt DLL if QT_DLL is defined (Windows only) +// or QT_SHARED is defined (Kylix only) +// + +#if defined(Q_OS_WIN) +# if defined(QT_NODLL) +# undef QT_MAKEDLL +# undef QT_DLL +# elif defined(QT_MAKEDLL) /* create a TQt DLL library */ +# if defined(QT_DLL) +# undef QT_DLL +# endif +# define Q_EXPORT __declspec(dllexport) +# define Q_TEMPLATEDLL +# define Q_TEMPLATE_EXTERN +# undef Q_DISABLE_COPY /* avoid unresolved externals */ +# elif defined(QT_DLL) /* use a TQt DLL library */ +# define Q_EXPORT __declspec(dllimport) +# define Q_TEMPLATEDLL +# ifndef Q_TEMPLATE_EXTERN +# if defined(Q_CC_MSVC_NET) +# define Q_TEMPLATE_EXTERN extern +# else +# define Q_TEMPLATE_EXTERN +# endif +# endif +# undef Q_DISABLE_COPY /* avoid unresolved externals */ +# endif +#elif defined(Q_OS_LINUX) && defined(Q_CC_BOR) +# if defined(QT_SHARED) /* create a TQt shared library */ +# define Q_EXPORT __declspec(dllexport) +# define Q_TEMPLATEDLL +# define Q_TEMPLATE_EXTERN +# undef Q_DISABLE_COPY /* avoid unresolved externals */ +# else +# define Q_TEMPLATEDLL +# define Q_TEMPLATE_EXTERN +# undef Q_DISABLE_COPY /* avoid unresolved externals */ +# endif +#else +# undef QT_MAKEDLL /* ignore these for other platforms */ +# undef QT_DLL +#endif + +#ifndef Q_EXPORT +# define Q_EXPORT +#endif + + +// +// Some platform specific stuff +// + +#if defined(Q_WS_WIN) +extern Q_EXPORT bool qt_winunicode; +#endif + + +// +// System information +// + +Q_EXPORT const char *qVersion(); +Q_EXPORT bool qSysInfo( int *wordSize, bool *bigEndian ); +Q_EXPORT bool qSharedBuild(); +#if defined(Q_OS_MAC) +int qMacVersion(); +#elif defined(Q_WS_WIN) +Q_EXPORT int qWinVersion(); +#if defined(UNICODE) +#define QT_WA( uni, ansi ) if ( qt_winunicode ) { uni } else { ansi } +#define QT_WA_INLINE( uni, ansi ) ( qt_winunicode ? uni : ansi ) +#else +#define QT_WA( uni, ansi ) ansi +#define QT_WA_INLINE( uni, ansi ) ansi +#endif +#endif + +#ifdef Q_OS_TEMP +#ifdef QT_WA +#undef QT_WA +#undef QT_WA_INLINE +#endif +#define QT_WA( uni, ansi ) uni +#define QT_WA_INLINE( uni, ansi ) ( uni ) +#endif + +#ifndef Q_INLINE_TEMPLATES +# define Q_INLINE_TEMPLATES +#endif + +#ifndef Q_TYPENAME +# define Q_TYPENAME typename +#endif + +// +// Use to avoid "unused parameter" warnings +// +#define Q_UNUSED(x) (void)x; + +// +// Debugging and error handling +// + +#if !defined(QT_NO_CHECK) +# define QT_CHECK_STATE // check state of objects etc. +# define QT_CHECK_RANGE // check range of indexes etc. +# define QT_CHECK_NULL // check null pointers +# define QT_CHECK_MATH // check math functions +#endif + +#if !defined(QT_NO_DEBUG) && !defined(QT_DEBUG) +# define QT_DEBUG // display debug messages +# if !defined(QT_NO_COMPAT) // compatibility with TQt 2 +# if !defined(NO_DEBUG) && !defined(DEBUG) +# if !defined(Q_OS_MACX) // clash with MacOS X headers +# define DEBUG +# endif +# endif +# endif +#endif + + +Q_EXPORT void qDebug( const char *, ... ) // print debug message +#if defined(Q_CC_GNU) && !defined(__INSURE__) + __attribute__ ((format (printf, 1, 2))) +#endif +; + +Q_EXPORT void qWarning( const char *, ... ) // print warning message +#if defined(Q_CC_GNU) && !defined(__INSURE__) + __attribute__ ((format (printf, 1, 2))) +#endif +; + +Q_EXPORT void qFatal( const char *, ... ) // print fatal message and exit +#if defined(Q_CC_GNU) + __attribute__ ((format (printf, 1, 2))) +#endif +; + +Q_EXPORT void qSystemWarning( const char *, int code = -1 ); + +#if !defined(QT_CLEAN_NAMESPACE) // compatibility with TQt 1 + +Q_EXPORT void debug( const char *, ... ) // print debug message +#if defined(Q_CC_GNU) && !defined(__INSURE__) + __attribute__ ((format (printf, 1, 2))) +#endif +; + +Q_EXPORT void warning( const char *, ... ) // print warning message +#if defined(Q_CC_GNU) && !defined(__INSURE__) + __attribute__ ((format (printf, 1, 2))) +#endif +; + +Q_EXPORT void fatal( const char *, ... ) // print fatal message and exit +#if defined(Q_CC_GNU) && !defined(__INSURE__) + __attribute__ ((format (printf, 1, 2))) +#endif +; + +#endif // QT_CLEAN_NAMESPACE + + +#if !defined(Q_ASSERT) +# if defined(QT_CHECK_STATE) +# if defined(QT_FATAL_ASSERT) +# define Q_ASSERT(x) ((x) ? (void)0 : qFatal("ASSERT: \"%s\" in %s (%d)",#x,__FILE__,__LINE__)) +# else +# define Q_ASSERT(x) ((x) ? (void)0 : qWarning("ASSERT: \"%s\" in %s (%d)",#x,__FILE__,__LINE__)) +# endif +# else +# define Q_ASSERT(x) +# endif +#endif + +#if !defined(QT_NO_COMPAT) // compatibility with TQt 2 +# if !defined(ASSERT) +# if !defined(Q_OS_TEMP) +# define ASSERT(x) Q_ASSERT(x) +# endif +# endif +#endif // QT_NO_COMPAT + + +Q_EXPORT bool qt_check_pointer( bool c, const char *, int ); + +#if defined(QT_CHECK_NULL) +# define Q_CHECK_PTR(p) (qt_check_pointer((p)==0,__FILE__,__LINE__)) +#else +# define Q_CHECK_PTR(p) +#endif + +#if !defined(QT_NO_COMPAT) // compatibility with TQt 2 +# if !defined(CHECK_PTR) +# define CHECK_PTR(x) Q_CHECK_PTR(x) +# endif +#endif // QT_NO_COMPAT + +enum TQtMsgType { TQtDebugMsg, TQtWarningMsg, TQtFatalMsg }; + +typedef void (*TQtMsgHandler)(TQtMsgType, const char *); +Q_EXPORT TQtMsgHandler qInstallMsgHandler( TQtMsgHandler ); + +#if !defined(QT_NO_COMPAT) // compatibility with TQt 2 +typedef TQtMsgHandler msg_handler; +#endif // QT_NO_COMPAT + +Q_EXPORT void qSuppressObsoleteWarnings( bool = TRUE ); + +Q_EXPORT void qObsolete( const char *obj, const char *oldfunc, + const char *newfunc ); +Q_EXPORT void qObsolete( const char *obj, const char *oldfunc ); +Q_EXPORT void qObsolete( const char *message ); + + +// +// Install paths from configure +// + +Q_EXPORT const char *qInstallPath(); +Q_EXPORT const char *qInstallPathDocs(); +Q_EXPORT const char *qInstallPathHeaders(); +Q_EXPORT const char *qInstallPathLibs(); +Q_EXPORT const char *qInstallPathBins(); +Q_EXPORT const char *qInstallPathPlugins(); +Q_EXPORT const char *qInstallPathData(); +Q_EXPORT const char *qInstallPathTranslations(); +Q_EXPORT const char *qInstallPathSysconf(); + +#endif /* __cplusplus */ + +/* + compilers which follow outdated template instantiation rules + retquire a class to have a comparison operator to exist when + a TQValueList of this type is instantiated. It's not actually + used in the list, though. Hence the dummy implementation. + Just in case other code relies on it we better trigger a warning + mandating a real implementation. +*/ +#ifdef Q_FULL_TEMPLATE_INSTANTIATION +# define Q_DUMMY_COMPARISON_OPERATOR(C) \ + bool operator==( const C& ) const { \ + qWarning( #C"::operator==( const "#C"& ) got called." ); \ + return FALSE; \ + } +#else +# define Q_DUMMY_COMPARISON_OPERATOR(C) +#endif + +#endif /* TQGLOBAL_H */ + +/* + Avoid some particularly useless warnings from some stupid compilers. + To get ALL C++ compiler warnings, define QT_CC_WARNINGS or comment out + the line "#define QT_NO_WARNINGS" +*/ + +#if !defined(QT_CC_WARNINGS) +# define QT_NO_WARNINGS +#endif +#if defined(QT_NO_WARNINGS) +# if defined(Q_CC_MSVC) +# pragma warning(disable: 4244) // 'conversion' conversion from 'type1' to 'type2', possible loss of data +# pragma warning(disable: 4275) // non - DLL-interface classkey 'identifier' used as base for DLL-interface classkey 'identifier' +# pragma warning(disable: 4514) // unreferenced inline/local function has been removed +# pragma warning(disable: 4800) // 'type' : forcing value to bool 'true' or 'false' (performance warning) +# pragma warning(disable: 4097) // typedef-name 'identifier1' used as synonym for class-name 'identifier2' +# pragma warning(disable: 4706) // assignment within conditional expression +# pragma warning(disable: 4786) // truncating debug info after 255 characters +# pragma warning(disable: 4660) // template-class specialization 'identifier' is already instantiated +# pragma warning(disable: 4355) // 'this' : used in base member initializer list +# pragma warning(disable: 4231) // nonstandard extension used : 'extern' before template explicit instantiation +# pragma warning(disable: 4710) // function not inlined +# elif defined(Q_CC_BOR) +# pragma option -w-inl +# pragma option -w-aus +# pragma warn -inl +# pragma warn -pia +# pragma warn -ccc +# pragma warn -rch +# pragma warn -sig +# endif +#endif + diff --git a/src/tools/qgpluginmanager.cpp b/src/tools/qgpluginmanager.cpp new file mode 100644 index 000000000..39bd4cdfb --- /dev/null +++ b/src/tools/qgpluginmanager.cpp @@ -0,0 +1,550 @@ +/**************************************************************************** +** +** Implementation of TQGPluginManager class +** +** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "qgpluginmanager_p.h" +#ifndef QT_NO_COMPONENT +#include "qcomlibrary_p.h" +#include "qmap.h" +#include "qdir.h" + +/* + The following co-occurrence code is borrowed from TQt Linguist. + + How similar are two texts? The approach used here relies on + co-occurrence matrices and is very efficient. + + Let's see with an example: how similar are "here" and "hither"? The + co-occurrence matrix M for "here" is M[h,e] = 1, M[e,r] = 1, + M[r,e] = 1 and 0 elsewhere; the matrix N for "hither" is N[h,i] = 1, + N[i,t] = 1, ..., N[h,e] = 1, N[e,r] = 1 and 0 elsewhere. The union + U of both matrices is the matrix U[i,j] = max { M[i,j], N[i,j] }, + and the intersection V is V[i,j] = min { M[i,j], N[i,j] }. The score + for a pair of texts is + + score = (sum of V[i,j] over all i, j) / (sum of U[i,j] over all i, j), + + a formula suggested by Arnt Gulbrandsen. Here we have + + score = 2 / 6, + + or one third. + + The implementation differs from this in a few details. Most + importantly, repetitions are ignored; for input "xxx", M[x,x] equals + 1, not 2. +*/ + +/* + Every character is assigned to one of 20 buckets so that the + co-occurrence matrix retquires only 20 * 20 = 400 bits, not + 256 * 256 = 65536 bits or even more if we want the whole Unicode. + Which character falls in which bucket is arbitrary. + + The second half of the table is a replica of the first half, because of + laziness. +*/ +static const char indexOf[256] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +// ! " # $ % & ' ( ) * + , - . / + 0, 2, 6, 7, 10, 12, 15, 19, 2, 6, 7, 10, 12, 15, 19, 0, +// 0 1 2 3 4 5 6 7 8 9 : ; < = > ? + 1, 3, 4, 5, 8, 9, 11, 13, 14, 16, 2, 6, 7, 10, 12, 15, +// @ A B C D E F G H I J K L M N O + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 6, 10, 11, 12, 13, 14, +// P Q R S T U V W X Y Z [ \ ] ^ _ + 15, 12, 16, 17, 18, 19, 2, 10, 15, 7, 19, 2, 6, 7, 10, 0, +// ` a b c d e f g h i j k l m n o + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 6, 10, 11, 12, 13, 14, +// p q r s t u v w x y z { | } ~ + 15, 12, 16, 17, 18, 19, 2, 10, 15, 7, 19, 2, 6, 7, 10, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 2, 6, 7, 10, 12, 15, 19, 2, 6, 7, 10, 12, 15, 19, 0, + 1, 3, 4, 5, 8, 9, 11, 13, 14, 16, 2, 6, 7, 10, 12, 15, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 6, 10, 11, 12, 13, 14, + 15, 12, 16, 17, 18, 19, 2, 10, 15, 7, 19, 2, 6, 7, 10, 0, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 6, 10, 11, 12, 13, 14, + 15, 12, 16, 17, 18, 19, 2, 10, 15, 7, 19, 2, 6, 7, 10, 0 +}; + +/* + The entry bitCount[i] (for i between 0 and 255) is the number of + bits used to represent i in binary. +*/ +static const char bitCount[256] = { + 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, + 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, + 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, + 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, + 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, + 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8 +}; + +class TQCoMatrix +{ +public: + /* + The matrix has 20 * 20 = 400 entries. This retquires 50 bytes, or + 13 words. Some operations are performed on words for more + efficiency. + */ + union { + Q_UINT8 b[52]; + Q_UINT32 w[13]; + }; + + TQCoMatrix() { memset( b, 0, 52 ); } + TQCoMatrix( const char *text ) { + char c = '\0', d; + memset( b, 0, 52 ); + while ( (d = *text) != '\0' ) { + setCoocc( c, d ); + if ( (c = *++text) != '\0' ) { + setCoocc( d, c ); + text++; + } + } + } + + void setCoocc( char c, char d ) { + int k = indexOf[(uchar) c] + 20 * indexOf[(uchar) d]; + b[k >> 3] |= k & 0x7; + } + + int worth() const { + int result = 0; + for ( int i = 0; i < 50; i++ ) + result += bitCount[b[i]]; + return result; + } + + static TQCoMatrix reunion( const TQCoMatrix& m, const TQCoMatrix& n ) + { + TQCoMatrix p; + for ( int i = 0; i < 13; i++ ) + p.w[i] = m.w[i] | n.w[i]; + return p; + } + static TQCoMatrix intersection( const TQCoMatrix& m, const TQCoMatrix& n ) + { + TQCoMatrix p; + for ( int i = 0; i < 13; i++ ) + p.w[i] = m.w[i] & n.w[i]; + return p; + } +}; + +/* + Returns an integer between 0 (dissimilar) and 15 (very similar) + depending on how similar the string is to \a target. + + This function is efficient, but its results might change in future + versions of TQt as the algorithm evolves. + + \code + TQString s( "color" ); + a = similarity( s, "color" ); // a == 15 + a = similarity( s, "colour" ); // a == 8 + a = similarity( s, "flavor" ); // a == 4 + a = similarity( s, "dahlia" ); // a == 0 + \endcode +*/ +static int similarity( const TQString& s1, const TQString& s2 ) +{ + TQCoMatrix m1( s1 ); + TQCoMatrix m2( s2 ); + return ( 15 * (TQCoMatrix::intersection(m1, m2).worth() + 1) ) / + ( TQCoMatrix::reunion(m1, m2).worth() + 1 ); +} + +/*! + \class TQPluginManager qpluginmanager.h + \reentrant + \brief The TQPluginManager class provides basic functions to access a certain kind of functionality in libraries. + \ingroup componentmodel + + \internal + + A common usage of components is to extend the existing functionality in an application using plugins. The application + defines interfaces that abstract a certain group of functionality, and a plugin provides a specialized implementation + of one or more of those interfaces. + + The TQPluginManager template has to be instantiated with an interface definition and the IID for this interface. + + \code + TQPluginManager *manager = new TQPluginManager( IID_MyPluginInterface ); + \endcode + + It searches a specified directory for all shared libraries, queries for components that implement the specific interface and + reads information about the features the plugin wants to add to the application. The component can provide the set of features + provided by implementing either the TQFeatureListInterface or the TQComponentInformationInterface. The strings returned by the implementations + of + + \code + TQStringList TQFeatureListInterface::featureList() const + \endcode + + or + + \code + TQString TQComponentInformationInterface::name() const + \endcode + + respectively, can then be used to access the component that provides the requested feature: + + \code + MyPluginInterface *iface; + manager->queryInterface( "feature", &iface ); + if ( iface ) + iface->execute( "feature" ); + \endcode + + The application can use a TQPluginManager instance to create parts of the user interface based on the list of features + found in plugins: + + \code + TQPluginManager *manager = new TQPluginManager( IID_ImageFilterInterface ); + manager->addLibraryPath(...); + + TQStringList features = manager->featureList(); + for ( TQStringList::Iterator it = features.begin(); it != features.end(); ++it ) { + MyPluginInterface *iface; + manager->queryInterface( *it, &iface ); + + // use TQAction to provide toolbuttons and menuitems for each feature... + } + \endcode +*/ + +/*! + \fn TQPluginManager::TQPluginManager( const TQUuid& id, const TQStringList& paths = TQString::null, const TQString &suffix = TQString::null, bool cs = TRUE ) + + Creates an TQPluginManager for interfaces \a id that will load all shared library files in the \a paths + \a suffix. + If \a cs is FALSE the manager will handle feature strings case insensitive. + + \warning + Setting the cs flag to FALSE retquires that components also convert to lower case when comparing with passed strings, so this has + to be handled with care and documented very well. + + \sa TQApplication::libraryPaths() +*/ + + +/*! + \fn TQRESULT TQPluginManager::queryInterface(const TQString& feature, Type** iface) const + + Sets \a iface to point to the interface providing \a feature. + + \sa featureList(), library() +*/ + + + +#include + +TQGPluginManager::TQGPluginManager( const TQUuid& id, const TQStringList& paths, const TQString &suffix, bool cs ) + : interfaceId( id ), plugDict( 17, cs ), casesens( cs ), autounload( TRUE ) +{ + // Every TQLibrary object is destroyed on destruction of the manager + libDict.setAutoDelete( TRUE ); + for ( TQStringList::ConstIterator it = paths.begin(); it != paths.end(); ++it ) { + TQString path = *it; + addLibraryPath( path + suffix ); + } +} + +TQGPluginManager::~TQGPluginManager() +{ + if ( !autounload ) { + TQDictIterator it( libDict ); + while ( it.current() ) { + TQLibrary *lib = it.current(); + ++it; + lib->setAutoUnload( FALSE ); + } + } +} + +void TQGPluginManager::addLibraryPath( const TQString& path ) +{ + if ( !enabled() || !TQDir( path ).exists( ".", TRUE ) ) + return; + +#if defined(Q_OS_WIN32) + TQString filter = "*.dll"; +#elif defined(Q_OS_MACX) + TQString filter = "*.dylib; *.so; *.bundle"; +#elif defined(Q_OS_HPUX) + TQString filter = "*.sl"; +#elif defined(Q_OS_UNIX) + TQString filter = "*.so"; +#endif + + TQStringList plugins = TQDir(path).entryList( filter ); + for ( TQStringList::Iterator p = plugins.begin(); p != plugins.end(); ++p ) { + TQString lib = TQDir::cleanDirPath( path + "/" + *p ); + if ( libList.contains( lib ) ) + continue; + libList.append( lib ); + } +} + +const TQLibrary* TQGPluginManager::library( const TQString& feature ) const +{ + if ( !enabled() || feature.isEmpty() ) + return 0; + + // We already have a TQLibrary object for this feature + TQLibrary *library = 0; + if ( ( library = plugDict[feature] ) ) + return library; + + // Find the filename that matches the feature request best + TQMap map; + TQStringList::ConstIterator it = libList.begin(); + int best = 0; + int worst = 15; + while ( it != libList.end() ) { + if ( (*it).isEmpty() || libDict[*it] ) { + ++it; + continue; + } + TQString basename = TQFileInfo(*it).baseName(); + int s = similarity( feature, basename ); + if ( s < worst ) + worst = s; + if ( s > best ) + best = s; + map[s].append( basename + TQChar(0xfffd) + *it ); + ++it; + } + + if ( map.isEmpty() ) + return 0; // no libraries to add + + // Start with the best match to get the library object + TQGPluginManager *that = (TQGPluginManager*)this; + for ( int s = best; s >= worst; --s ) { + TQStringList group = map[s]; + group.sort(); // sort according to the base name + TQStringList::ConstIterator git = group.begin(); + while ( git != group.end() ) { + TQString lib = (*git).mid( (*git).find( TQChar(0xfffd) ) + 1 ); + TQString basename = (*git).left( (*git).find( TQChar(0xfffd) ) ); + ++git; + + TQStringList sameBasename; + while( git != group.end() && + basename == (*git).left( (*git).find( TQChar(0xfffd) ) ) ) { + sameBasename << (*git).mid( (*git).find( TQChar(0xfffd) ) + 1 ); + ++git; + } + + if ( sameBasename.isEmpty() ) { + that->addLibrary( new TQComLibrary( lib ) ); + } else { + TQPtrList same; + same.setAutoDelete( TRUE ); + same.append( new TQComLibrary( lib ) ); + for ( TQStringList::ConstIterator bit = sameBasename.begin(); + bit != sameBasename.end(); ++bit ) + same.append( new TQComLibrary( *bit ) ); + TQComLibrary* bestMatch = 0; + for ( TQComLibrary* candidate = same.first(); candidate; candidate = same.next() ) + if ( candidate->qtVersion() && candidate->qtVersion() <= QT_VERSION + && ( !bestMatch || candidate->qtVersion() > bestMatch->qtVersion() ) ) + bestMatch = candidate; + if ( bestMatch ) { + same.find( bestMatch ); + that->addLibrary( same.take() ); + } + } + + if ( ( library = that->plugDict[feature] ) ) + return library; + } + } + return 0; +} + +TQStringList TQGPluginManager::featureList() const +{ + TQStringList features; + + if ( !enabled() ) + return features; + + TQGPluginManager *that = (TQGPluginManager*)this; + TQStringList theLibs = libList; + TQStringList phase2Libs; + TQStringList phase2Deny; + + /* In order to get the feature list we need to add all interesting + libraries. If there are libraries with the same base name, we + prioritze the one that fits our TQt version number and ignore the + others */ + TQStringList::Iterator it; + for ( it = theLibs.begin(); it != theLibs.end(); ++it ) { + if ( (*it).isEmpty() || libDict[*it] ) + continue; + TQComLibrary* library = new TQComLibrary( *it ); + if ( library->qtVersion() == QT_VERSION ) { + that->addLibrary( library ); + phase2Deny << TQFileInfo( *it ).baseName(); + } else { + delete library; + phase2Libs << *it; + } + } + for ( it = phase2Libs.begin(); it != phase2Libs.end(); ++it ) + if ( !phase2Deny.contains( TQFileInfo( *it ).baseName() ) ) + that->addLibrary( new TQComLibrary( *it ) ); + + for ( TQDictIterator pit( plugDict ); pit.current(); ++pit ) + features << pit.currentKey(); + + return features; +} + +bool TQGPluginManager::addLibrary( TQLibrary* lib ) +{ + if ( !enabled() || !lib ) + return FALSE; + + TQComLibrary* plugin = (TQComLibrary*)lib; + bool useful = FALSE; + + TQUnknownInterface* iFace = 0; + plugin->queryInterface( interfaceId, &iFace ); + if ( iFace ) { + TQFeatureListInterface *fliFace = 0; + TQComponentInformationInterface *cpiFace = 0; + iFace->queryInterface( IID_QFeatureList, (TQUnknownInterface**)&fliFace ); + if ( !fliFace ) + plugin->queryInterface( IID_QFeatureList, (TQUnknownInterface**)&fliFace ); + if ( !fliFace ) { + iFace->queryInterface( IID_QComponentInformation, (TQUnknownInterface**)&cpiFace ); + if ( !cpiFace ) + plugin->queryInterface( IID_QComponentInformation, (TQUnknownInterface**)&cpiFace ); + } + TQStringList fl; + if ( fliFace ) + // Map all found features to the library + fl = fliFace->featureList(); + else if ( cpiFace ) + fl << cpiFace->name(); + + for ( TQStringList::Iterator f = fl.begin(); f != fl.end(); ++f ) { + TQLibrary *old = plugDict[*f]; + if ( !old ) { + useful = TRUE; + plugDict.replace( *f, plugin ); + } else { + // we have old *and* plugin, which one to pick? + TQComLibrary* first = (TQComLibrary*)old; + TQComLibrary* second = (TQComLibrary*)plugin; + bool takeFirst = TRUE; + if ( first->qtVersion() != QT_VERSION ) { + if ( second->qtVersion() == QT_VERSION ) + takeFirst = FALSE; + else if ( second->qtVersion() < QT_VERSION && + first->qtVersion() > QT_VERSION ) + takeFirst = FALSE; + } + if ( !takeFirst ) { + useful = TRUE; + plugDict.replace( *f, plugin ); + qWarning("%s: Discarding feature %s in %s!", + (const char*) TQFile::encodeName( plugin->library()), + (*f).latin1(), + (const char*) TQFile::encodeName( old->library() ) ); + } else { + qWarning("%s: Feature %s already defined in %s!", + (const char*) TQFile::encodeName( old->library() ), + (*f).latin1(), + (const char*) TQFile::encodeName( plugin->library() ) ); + } + } + } + if ( fliFace ) + fliFace->release(); + if ( cpiFace ) + cpiFace->release(); + iFace->release(); + } + + if ( useful ) { + libDict.replace( plugin->library(), plugin ); + if ( !libList.contains( plugin->library() ) ) + libList.append( plugin->library() ); + return TRUE; + } + delete plugin; + return FALSE; +} + + +bool TQGPluginManager::enabled() const +{ +#ifdef QT_SHARED + return TRUE; +#else + return FALSE; +#endif +} + +TQRESULT TQGPluginManager::queryUnknownInterface(const TQString& feature, TQUnknownInterface** iface) const +{ + TQComLibrary* plugin = 0; + plugin = (TQComLibrary*)library( feature ); + return plugin ? plugin->queryInterface( interfaceId, (TQUnknownInterface**)iface ) : TQE_NOINTERFACE; +} + +#endif //QT_NO_COMPONENT diff --git a/src/tools/qgpluginmanager_p.h b/src/tools/qgpluginmanager_p.h new file mode 100644 index 000000000..33e07dc7a --- /dev/null +++ b/src/tools/qgpluginmanager_p.h @@ -0,0 +1,110 @@ +/********************************************************************** +** +** Definition of TQGPluginManager class +** +** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQGPLUGINMANAGER_P_H +#define TQGPLUGINMANAGER_P_H + +#ifndef QT_H +#include "qdict.h" +#include "qlibrary.h" +#include "quuid.h" +#include "qstringlist.h" +#include "qcom_p.h" +#endif // QT_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the TQt API. It exists for the convenience +// of a number of TQt sources files. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// +// + +#ifndef QT_NO_COMPONENT + +#if defined(Q_TEMPLATEDLL) +// MOC_SKIP_BEGIN +//Q_TEMPLATE_EXTERN template class Q_EXPORT TQDict; +// MOC_SKIP_END +#endif + +class Q_EXPORT TQGPluginManager +{ +public: + TQGPluginManager( const TQUuid& id, const TQStringList& paths = TQString::null, const TQString &suffix = TQString::null, bool cs = TRUE ); + ~TQGPluginManager(); + + void addLibraryPath( const TQString& path ); + const TQLibrary* library( const TQString& feature ) const; + TQStringList featureList() const; + + bool autoUnload() const; + void setAutoUnload( bool ); + +protected: + bool enabled() const; + bool addLibrary( TQLibrary* plugin ); + + TQRESULT queryUnknownInterface(const TQString& feature, TQUnknownInterface** iface) const; + + TQUuid interfaceId; + TQDict plugDict; // Dict to match feature with library + TQDict libDict; // Dict to match library file with library + TQStringList libList; + + uint casesens : 1; + uint autounload : 1; +}; + +inline void TQGPluginManager::setAutoUnload( bool unload ) +{ + autounload = unload; +} + +inline bool TQGPluginManager::autoUnload() const +{ + return autounload; +} + +#endif + +#endif //TQGPLUGINMANAGER_P_H diff --git a/src/tools/qgvector.cpp b/src/tools/qgvector.cpp new file mode 100644 index 000000000..5d7b7cdb2 --- /dev/null +++ b/src/tools/qgvector.cpp @@ -0,0 +1,598 @@ +/**************************************************************************** +** +** Implementation of TQGVector class +** +** Created : 930907 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "qglobal.h" +#if defined(Q_CC_BOR) +// needed for qsort() because of a std namespace problem on Borland +#include "qplatformdefs.h" +#endif + +#define TQGVECTOR_CPP +#include "qgvector.h" +#include "qglist.h" +#include "qstring.h" +#include "qdatastream.h" +#include + +#ifdef QT_THREAD_SUPPORT +# include +#endif // QT_THREAD_SUPPORT + +#define USE_MALLOC // comment to use new/delete + +#undef NEW +#undef DELETE + +#if defined(USE_MALLOC) +#define NEW(type,size) ((type*)malloc(size*sizeof(type))) +#define DELETE(array) (free((char*)array)) +#else +#define NEW(type,size) (new type[size]) +#define DELETE(array) (delete[] array) +#define DONT_USE_REALLOC // comment to use realloc() +#endif + +/*! + \class TQGVector + \reentrant + \ingroup collection + + \brief The TQGVector class is an internal class for implementing TQt + collection classes. + + \internal + + TQGVector is an internal class that acts as a base class for the + TQPtrVector collection class. + + TQGVector has some virtual functions that may be reimplemented in + subclasses to customize behavior. + + \list + \i compareItems() compares two collection/vector items. + \i read() reads a collection/vector item from a TQDataStream. + \i write() writes a collection/vector item to a TQDataStream. + \endlist +*/ + +/***************************************************************************** + Default implementation of virtual functions + *****************************************************************************/ + +/*! + This virtual function compares two list items. + + Returns: +
    +
  • 0 if \a d1 == \a d2 +
  • non-zero if \a d1 != \a d2 +
+ + This function returns \e int rather than \e bool so that + reimplementations can return one of three values and use it to sort + by: +
    +
  • 0 if \a d1 == \a d2 +
  • \> 0 (positive integer) if \a d1 \> \a d2 +
  • \< 0 (negative integer) if \a d1 \< \a d2 +
+ + The TQPtrVector::sort() and TQPtrVector::bsearch() functions retquire that + compareItems() is implemented as described here. + + This function should not modify the vector because some const + functions call compareItems(). +*/ + +int TQGVector::compareItems( Item d1, Item d2 ) +{ + return d1 != d2; // compare pointers +} + +#ifndef QT_NO_DATASTREAM +/*! + Reads a collection/vector item from the stream \a s and returns a reference + to the stream. + + The default implementation sets \a d to 0. + + \sa write() +*/ + +TQDataStream &TQGVector::read( TQDataStream &s, Item &d ) +{ // read item from stream + d = 0; + return s; +} + +/*! + Writes a collection/vector item to the stream \a s and returns a reference + to the stream. + + The default implementation does nothing. + + \sa read() +*/ + +TQDataStream &TQGVector::write( TQDataStream &s, Item ) const +{ // write item to stream + return s; +} +#endif // QT_NO_DATASTREAM + +/***************************************************************************** + TQGVector member functions + *****************************************************************************/ + +TQGVector::TQGVector() // create empty vector +{ + vec = 0; + len = numItems = 0; +} + +TQGVector::TQGVector( uint size ) // create vectors with nullptrs +{ + len = size; + numItems = 0; + if ( len == 0 ) { // zero length + vec = 0; + return; + } + vec = NEW(Item,len); + Q_CHECK_PTR( vec ); + memset( (void*)vec, 0, len*sizeof(Item) ); // fill with nulls +} + +TQGVector::TQGVector( const TQGVector &a ) // make copy of other vector + : TQPtrCollection( a ) +{ + len = a.len; + numItems = a.numItems; + if ( len == 0 ) { + vec = 0; + return; + } + vec = NEW( Item, len ); + Q_CHECK_PTR( vec ); + for ( uint i = 0; i < len; i++ ) { + if ( a.vec[i] ) { + vec[i] = newItem( a.vec[i] ); + Q_CHECK_PTR( vec[i] ); + } else { + vec[i] = 0; + } + } +} + +TQGVector::~TQGVector() +{ + clear(); +} + +TQGVector& TQGVector::operator=( const TQGVector &v ) +{ + if ( &v == this ) + return *this; + + clear(); + len = v.len; + numItems = v.numItems; + if ( len == 0 ) { + vec = 0; + return *this; + } + vec = NEW( Item, len ); + Q_CHECK_PTR( vec ); + for ( uint i = 0; i < len; i++ ) { + if ( v.vec[i] ) { + vec[i] = newItem( v.vec[i] ); + Q_CHECK_PTR( vec[i] ); + } else { + vec[i] = 0; + } + } + return *this; +} + + +bool TQGVector::insert( uint index, Item d ) // insert item at index +{ +#if defined(QT_CHECK_RANGE) + if ( index >= len ) { // range error + qWarning( "TQGVector::insert: Index %d out of range", index ); + return FALSE; + } +#endif + if ( vec[index] ) { // remove old item + deleteItem( vec[index] ); + numItems--; + } + if ( d ) { + vec[index] = newItem( d ); + Q_CHECK_PTR( vec[index] ); + numItems++; + return vec[index] != 0; + } else { + vec[index] = 0; // reset item + } + return TRUE; +} + +bool TQGVector::remove( uint index ) // remove item at index +{ +#if defined(QT_CHECK_RANGE) + if ( index >= len ) { // range error + qWarning( "TQGVector::remove: Index %d out of range", index ); + return FALSE; + } +#endif + if ( vec[index] ) { // valid item + deleteItem( vec[index] ); // delete it + vec[index] = 0; // reset pointer + numItems--; + } + return TRUE; +} + +TQPtrCollection::Item TQGVector::take( uint index ) // take out item +{ +#if defined(QT_CHECK_RANGE) + if ( index >= len ) { // range error + qWarning( "TQGVector::take: Index %d out of range", index ); + return 0; + } +#endif + Item d = vec[index]; // don't delete item + if ( d ) + numItems--; + vec[index] = 0; + return d; +} + +void TQGVector::clear() // clear vector +{ + if ( vec ) { + for ( uint i=0; i len ) // init extra space added + memset( (void*)&vec[len], 0, (newsize-len)*sizeof(Item) ); + len = newsize; + return TRUE; +} + + +bool TQGVector::fill( Item d, int flen ) // resize and fill vector +{ + if ( flen < 0 ) + flen = len; // default: use vector length + else if ( !resize( flen ) ) + return FALSE; + for ( uint i=0; i<(uint)flen; i++ ) // insert d at every index + insert( i, d ); + return TRUE; +} + + +static TQGVector *sort_vec=0; // current sort vector + + +#if defined(Q_C_CALLBACKS) +extern "C" { +#endif + +#ifdef Q_OS_TEMP +static int _cdecl cmp_vec( const void *n1, const void *n2 ) +#else +static int cmp_vec( const void *n1, const void *n2 ) +#endif +{ + return sort_vec->compareItems( *((TQPtrCollection::Item*)n1), *((TQPtrCollection::Item*)n2) ); +} + +#if defined(Q_C_CALLBACKS) +} +#endif + + +void TQGVector::sort() // sort vector +{ + if ( count() == 0 ) // no elements + return; + register Item *start = &vec[0]; + register Item *end = &vec[len-1]; + Item tmp; + for (;;) { // put all zero elements behind + while ( start < end && *start != 0 ) + start++; + while ( end > start && *end == 0 ) + end--; + if ( start < end ) { + tmp = *start; + *start = *end; + *end = tmp; + } else { + break; + } + } + +#ifdef QT_THREAD_SUPPORT + TQMutexLocker locker( qt_global_mutexpool ? + qt_global_mutexpool->get( &sort_vec ) : 0 ); +#endif // QT_THREAD_SUPPORT + + sort_vec = (TQGVector*)this; + qsort( vec, count(), sizeof(Item), cmp_vec ); + sort_vec = 0; +} + +int TQGVector::bsearch( Item d ) const // binary search; when sorted +{ + if ( !len ) + return -1; + if ( !d ) { +#if defined(QT_CHECK_NULL) + qWarning( "TQGVector::bsearch: Cannot search for null object" ); +#endif + return -1; + } + int n1 = 0; + int n2 = len - 1; + int mid = 0; + bool found = FALSE; + while ( n1 <= n2 ) { + int res; + mid = (n1 + n2)/2; + if ( vec[mid] == 0 ) // null item greater + res = -1; + else + res = ((TQGVector*)this)->compareItems( d, vec[mid] ); + if ( res < 0 ) + n2 = mid - 1; + else if ( res > 0 ) + n1 = mid + 1; + else { // found it + found = TRUE; + break; + } + } + if ( !found ) + return -1; + // search to first of equal items + while ( (mid - 1 >= 0) && !((TQGVector*)this)->compareItems(d, vec[mid-1]) ) + mid--; + return mid; +} + +int TQGVector::findRef( Item d, uint index) const // find exact item in vector +{ +#if defined(QT_CHECK_RANGE) + if ( index > len ) { // range error + qWarning( "TQGVector::findRef: Index %d out of range", index ); + return -1; + } +#endif + for ( uint i=index; i= len ) { // range error + qWarning( "TQGVector::find: Index %d out of range", index ); + return -1; + } +#endif + for ( uint i=index; icompareItems( vec[i], d ) == 0 ) + return i; + } + return -1; +} + +uint TQGVector::containsRef( Item d ) const // get number of exact matches +{ + uint count = 0; + for ( uint i=0; icompareItems( vec[i], d ) == 0 ) + count++; + } + return count; +} + +bool TQGVector::insertExpand( uint index, Item d )// insert and grow if necessary +{ + if ( index >= len ) { + if ( !resize( index+1 ) ) // no memory + return FALSE; + } + insert( index, d ); + return TRUE; +} + +void TQGVector::toList( TQGList *list ) const // store items in list +{ + list->clear(); + for ( uint i=0; iappend( vec[i] ); + } +} + + +void TQGVector::warningIndexRange( uint i ) +{ +#if defined(QT_CHECK_RANGE) + qWarning( "TQGVector::operator[]: Index %d out of range", i ); +#else + Q_UNUSED( i ) +#endif +} + + +/***************************************************************************** + TQGVector stream functions + *****************************************************************************/ +#ifndef QT_NO_DATASTREAM +TQDataStream &operator>>( TQDataStream &s, TQGVector &vec ) +{ // read vector + return vec.read( s ); +} + +TQDataStream &operator<<( TQDataStream &s, const TQGVector &vec ) +{ // write vector + return vec.write( s ); +} + +TQDataStream &TQGVector::read( TQDataStream &s ) // read vector from stream +{ + uint num; + s >> num; // read number of items + clear(); // clear vector + resize( num ); + for (uint i=0; icompareItems( at( i ), v.at( i ) ) != 0 ) + return FALSE; + } + return TRUE; +} + +#endif // QT_NO_DATASTREAM diff --git a/src/tools/qgvector.h b/src/tools/qgvector.h new file mode 100644 index 000000000..356666dd7 --- /dev/null +++ b/src/tools/qgvector.h @@ -0,0 +1,124 @@ +/**************************************************************************** +** +** Definition of TQGVector class +** +** Created : 930907 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQGVECTOR_H +#define TQGVECTOR_H + +#ifndef QT_H +#include "qptrcollection.h" +#endif // QT_H + + +class Q_EXPORT TQGVector : public TQPtrCollection // generic vector +{ +friend class TQGList; // needed by TQGList::toVector +public: +#ifndef QT_NO_DATASTREAM + TQDataStream &read( TQDataStream & ); // read vector from stream + TQDataStream &write( TQDataStream & ) const; // write vector to stream +#endif + virtual int compareItems( Item, Item ); + +protected: + TQGVector(); // create empty vector + TQGVector( uint size ); // create vector with nullptrs + TQGVector( const TQGVector &v ); // make copy of other vector + ~TQGVector(); + + TQGVector &operator=( const TQGVector &v ); // assign from other vector + bool operator==( const TQGVector &v ) const; + + Item *data() const { return vec; } + uint size() const { return len; } + uint count() const { return numItems; } + + bool insert( uint index, Item ); // insert item at index + bool remove( uint index ); // remove item + Item take( uint index ); // take out item + + void clear(); // clear vector + bool resize( uint newsize ); // resize vector + + bool fill( Item, int flen ); // resize and fill vector + + void sort(); // sort vector + int bsearch( Item ) const; // binary search (when sorted) + + int findRef( Item, uint index ) const; // find exact item in vector + int find( Item, uint index ) const; // find equal item in vector + uint containsRef( Item ) const; // get number of exact matches + uint contains( Item ) const; // get number of equal matches + + Item at( uint index ) const // return indexed item + { +#if defined(QT_CHECK_RANGE) + if ( index >= len ) + warningIndexRange( index ); +#endif + return vec[index]; + } + + bool insertExpand( uint index, Item ); // insert, expand if necessary + + void toList( TQGList * ) const; // put items in list + +#ifndef QT_NO_DATASTREAM + virtual TQDataStream &read( TQDataStream &, Item & ); + virtual TQDataStream &write( TQDataStream &, Item ) const; +#endif +private: + Item *vec; + uint len; + uint numItems; + + static void warningIndexRange( uint ); +}; + + +/***************************************************************************** + TQGVector stream functions + *****************************************************************************/ + +#ifndef QT_NO_DATASTREAM +Q_EXPORT TQDataStream &operator>>( TQDataStream &, TQGVector & ); +Q_EXPORT TQDataStream &operator<<( TQDataStream &, const TQGVector & ); +#endif + +#endif // TQGVECTOR_H diff --git a/src/tools/qintcache.h b/src/tools/qintcache.h new file mode 100644 index 000000000..00599542b --- /dev/null +++ b/src/tools/qintcache.h @@ -0,0 +1,124 @@ +/**************************************************************************** +** +** Definition of TQIntCache template class +** +** Created : 950209 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQINTCACHE_H +#define TQINTCACHE_H + +#ifndef QT_H +#include "qgcache.h" +#endif // QT_H + + +template +class TQIntCache +#ifdef Q_QDOC + : public TQPtrCollection +#else + : public TQGCache +#endif +{ +public: + TQIntCache( const TQIntCache &c ) : TQGCache(c) {} + TQIntCache( int maxCost=100, int size=17 ) + : TQGCache( maxCost, size, IntKey, FALSE, FALSE ) {} + ~TQIntCache() { clear(); } + TQIntCache &operator=( const TQIntCache &c ) + { return (TQIntCache&)TQGCache::operator=(c); } + int maxCost() const { return TQGCache::maxCost(); } + int totalCost() const { return TQGCache::totalCost(); } + void setMaxCost( int m) { TQGCache::setMaxCost(m); } + uint count() const { return TQGCache::count(); } + uint size() const { return TQGCache::size(); } + bool isEmpty() const { return TQGCache::count() == 0; } + bool insert( long k, const type *d, int c=1, int p=0 ) + { return TQGCache::insert_other((const char*)k,(Item)d,c,p); } + bool remove( long k ) + { return TQGCache::remove_other((const char*)k); } + type *take( long k ) + { return (type *)TQGCache::take_other((const char*)k);} + void clear() { TQGCache::clear(); } + type *find( long k, bool ref=TRUE ) const + { return (type *)TQGCache::find_other( (const char*)k,ref);} + type *operator[]( long k ) const + { return (type *)TQGCache::find_other( (const char*)k); } + void statistics() const { TQGCache::statistics(); } +private: + void deleteItem( Item d ); +}; + +#if !defined(Q_BROKEN_TEMPLATE_SPECIALIZATION) +template<> inline void TQIntCache::deleteItem( TQPtrCollection::Item ) +{ +} +#endif + +template inline void TQIntCache::deleteItem( TQPtrCollection::Item d ) +{ + if ( del_item ) delete (type *)d; +} + +template +class TQIntCacheIterator : public TQGCacheIterator +{ +public: + TQIntCacheIterator( const TQIntCache &c ) + : TQGCacheIterator( (TQGCache &)c ) {} + TQIntCacheIterator( const TQIntCacheIterator &ci ) + : TQGCacheIterator((TQGCacheIterator &)ci) {} + TQIntCacheIterator &operator=( const TQIntCacheIterator&ci ) + { return ( TQIntCacheIterator&)TQGCacheIterator::operator=( ci );} + uint count() const { return TQGCacheIterator::count(); } + bool isEmpty() const { return TQGCacheIterator::count() == 0; } + bool atFirst() const { return TQGCacheIterator::atFirst(); } + bool atLast() const { return TQGCacheIterator::atLast(); } + type *toFirst() { return (type *)TQGCacheIterator::toFirst(); } + type *toLast() { return (type *)TQGCacheIterator::toLast(); } + operator type *() const { return (type *)TQGCacheIterator::get(); } + type *current() const { return (type *)TQGCacheIterator::get(); } + long currentKey() const { return (long)TQGCacheIterator::getKeyInt();} + type *operator()() { return (type *)TQGCacheIterator::operator()();} + type *operator++() { return (type *)TQGCacheIterator::operator++(); } + type *operator+=(uint j) { return (type *)TQGCacheIterator::operator+=(j);} + type *operator--() { return (type *)TQGCacheIterator::operator--(); } + type *operator-=(uint j) { return (type *)TQGCacheIterator::operator-=(j);} +}; + + +#endif // TQINTCACHE_H diff --git a/src/tools/qintdict.h b/src/tools/qintdict.h new file mode 100644 index 000000000..4b04fdf81 --- /dev/null +++ b/src/tools/qintdict.h @@ -0,0 +1,119 @@ +/**************************************************************************** +** +** Definition of TQIntDict template class +** +** Created : 940624 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQINTDICT_H +#define TQINTDICT_H + +#ifndef QT_H +#include "qgdict.h" +#endif // QT_H + +template +class TQIntDict +#ifdef Q_QDOC + : public TQPtrCollection +#else + : public TQGDict +#endif +{ +public: + TQIntDict(int size=17) : TQGDict(size,IntKey,0,0) {} + TQIntDict( const TQIntDict &d ) : TQGDict(d) {} + ~TQIntDict() { clear(); } + TQIntDict &operator=(const TQIntDict &d) + { return (TQIntDict&)TQGDict::operator=(d); } + uint count() const { return TQGDict::count(); } + uint size() const { return TQGDict::size(); } + bool isEmpty() const { return TQGDict::count() == 0; } + void insert( long k, const type *d ) + { TQGDict::look_int(k,(Item)d,1); } + void replace( long k, const type *d ) + { TQGDict::look_int(k,(Item)d,2); } + bool remove( long k ) { return TQGDict::remove_int(k); } + type *take( long k ) { return (type*)TQGDict::take_int(k); } + type *find( long k ) const + { return (type *)((TQGDict*)this)->TQGDict::look_int(k,0,0); } + type *operator[]( long k ) const + { return (type *)((TQGDict*)this)->TQGDict::look_int(k,0,0); } + void clear() { TQGDict::clear(); } + void resize( uint n ) { TQGDict::resize(n); } + void statistics() const { TQGDict::statistics(); } + +#ifdef Q_QDOC +protected: + virtual TQDataStream& read( TQDataStream &, TQPtrCollection::Item & ); + virtual TQDataStream& write( TQDataStream &, TQPtrCollection::Item ) const; +#endif + +private: + void deleteItem( Item d ); +}; + +#if !defined(Q_BROKEN_TEMPLATE_SPECIALIZATION) +template<> inline void TQIntDict::deleteItem( TQPtrCollection::Item ) +{ +} +#endif + +template inline void TQIntDict::deleteItem( TQPtrCollection::Item d ) +{ + if ( del_item ) delete (type*)d; +} + +template +class TQIntDictIterator : public TQGDictIterator +{ +public: + TQIntDictIterator(const TQIntDict &d) :TQGDictIterator((TQGDict &)d) {} + ~TQIntDictIterator() {} + uint count() const { return dict->count(); } + bool isEmpty() const { return dict->count() == 0; } + type *toFirst() { return (type *)TQGDictIterator::toFirst(); } + operator type *() const { return (type *)TQGDictIterator::get(); } + type *current() const { return (type *)TQGDictIterator::get(); } + long currentKey() const { return TQGDictIterator::getKeyInt(); } + type *operator()() { return (type *)TQGDictIterator::operator()(); } + type *operator++() { return (type *)TQGDictIterator::operator++(); } + type *operator+=(uint j) { return (type *)TQGDictIterator::operator+=(j);} +}; + +#define Q_DEFINED_QINTDICT +#include "qwinexport.h" +#endif // TQINTDICT_H diff --git a/src/tools/qiodevice.cpp b/src/tools/qiodevice.cpp new file mode 100644 index 000000000..a2b6e997b --- /dev/null +++ b/src/tools/qiodevice.cpp @@ -0,0 +1,763 @@ +/**************************************************************************** +** +** Implementation of TQIODevice class +** +** Created : 940913 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "qiodevice.h" + +/*! + \class TQIODevice qiodevice.h + \reentrant + + \brief The TQIODevice class is the base class of I/O devices. + + \ingroup io + + An I/O device represents a medium that one can read bytes from + and/or write bytes to. The TQIODevice class is the abstract + superclass of all such devices; classes such as TQFile, TQBuffer and + TQSocket inherit TQIODevice and implement virtual functions such as + write() appropriately. + + Although applications sometimes use TQIODevice directly, it is + usually better to use TQTextStream and TQDataStream, which provide + stream operations on any TQIODevice subclass. TQTextStream provides + text-oriented stream functionality (for human-readable ASCII + files, for example), whereas TQDataStream deals with binary data in + a totally platform-independent manner. + + The public member functions in TQIODevice roughly fall into two + groups: the action functions and the state access functions. The + most important action functions are: + + \list + + \i open() opens a device for reading and/or writing, depending on + the mode argument. + + \i close() closes the device and tidies up (e.g. flushes buffered + data) + + \i readBlock() reads a block of data from the device. + + \i writeBlock() writes a block of data to the device. + + \i readLine() reads a line (of text, usually) from the device. + + \i flush() ensures that all buffered data are written to the real device. + + \endlist + + There are also some other, less used, action functions: + + \list + + \i getch() reads a single character. + + \i ungetch() forgets the last call to getch(), if possible. + + \i putch() writes a single character. + + \i size() returns the size of the device, if there is one. + + \i at() returns the current read/write pointer's position, if there + is one for this device, or it moves the pointer if given an offset. + + \i atEnd() indicates whether there is more to read, if this is + meaningful for this device. + + \i reset() moves the read/write pointer to the start of the + device, if that is possible for this device. + + \endlist + + The state access are all "get" functions. The TQIODevice subclass + calls setState() to update the state, and simple access functions + tell the user of the device what the device's state is. Here are + the settings, and their associated access functions: + + \list + + \i Access type. Some devices are direct access (it is possible + to read/write anywhere), whereas others are sequential. TQIODevice + provides the access functions (isDirectAccess(), + isSequentialAccess(), and isCombinedAccess()) to tell users what a + given I/O device supports. + + \i Buffering. Some devices are accessed in raw mode, whereas + others are buffered. Buffering usually provides greater + efficiency, particularly for small read/write operations. + isBuffered() tells the user whether a given device is buffered. + (This can often be set by the application in the call to open().) + + \i Synchronicity. Synchronous devices work immediately (for + example, files). When you read from a file, the file delivers its + data straight away. Other kinds of device, such as a socket + connected to a HTTP server, may not deliver the data until seconds + after you ask to read it. isSynchronous() and isAsynchronous() + tell the user how this device operates. + + \i CR/LF translation. For simplicity, applications often like to + see just a single CR/LF style, and TQIODevice subclasses can + provide this. isTranslated() returns TRUE if this object + translates CR/LF to just LF. (This can often be set by the + application in the call to open().) + + \i Permissions. Some files cannot be written. For example, + isReadable(), isWritable() and isReadWrite() tell the application + whether it can read from and write to a given device. (This can + often be set by the application in the call to open().) + + \i Finally, isOpen() returns TRUE if the device is open, i.e. + after an open() call. + + \endlist + + TQIODevice provides numerous pure virtual functions that you need + to implement when subclassing it. Here is a skeleton subclass with + all the members you are sure to need and some that you will + probably need: + + \code + class MyDevice : public TQIODevice + { + public: + MyDevice(); + ~MyDevice(); + + bool open( int mode ); + void close(); + void flush(); + + uint size() const; + int at() const; // non-pure virtual + bool at( int ); // non-pure virtual + bool atEnd() const; // non-pure virtual + + int readBlock( char *data, uint maxlen ); + int writeBlock( const char *data, uint len ); + int readLine( char *data, uint maxlen ); + + int getch(); + int putch( int ); + int ungetch( int ); + }; + \endcode + + The three non-pure virtual functions need not be reimplemented for + sequential devices. + + \sa TQDataStream, TQTextStream +*/ + +/*! + \enum TQIODevice::Offset + + The offset within the device. +*/ + + +/*! + Constructs an I/O device. +*/ + +TQIODevice::TQIODevice() +{ + ioMode = 0; // initial mode + ioSt = IO_Ok; + ioIndex = 0; +} + +/*! + Destroys the I/O device. +*/ + +TQIODevice::~TQIODevice() +{ +} + + +/*! + \fn int TQIODevice::flags() const + + Returns the current I/O device flags setting. + + Flags consists of mode flags and state flags. + + \sa mode(), state() +*/ + +/*! + \fn int TQIODevice::mode() const + + Returns bits OR'ed together that specify the current operation + mode. + + These are the flags that were given to the open() function. + + The flags are \c IO_ReadOnly, \c IO_WriteOnly, \c IO_ReadWrite, + \c IO_Append, \c IO_Truncate and \c IO_Translate. +*/ + +/*! + \fn int TQIODevice::state() const + + Returns bits OR'ed together that specify the current state. + + The flags are: \c IO_Open. + + Subclasses may define additional flags. +*/ + +/*! + \fn bool TQIODevice::isDirectAccess() const + + Returns TRUE if the I/O device is a direct access device; + otherwise returns FALSE, i.e. if the device is a sequential access + device. + + \sa isSequentialAccess() +*/ + +/*! + \fn bool TQIODevice::isSequentialAccess() const + + Returns TRUE if the device is a sequential access device; + otherwise returns FALSE, i.e. if the device is a direct access + device. + + Operations involving size() and at(int) are not valid on + sequential devices. + + \sa isDirectAccess() +*/ + +/*! + \fn bool TQIODevice::isCombinedAccess() const + + Returns TRUE if the I/O device is a combined access (both direct + and sequential) device; otherwise returns FALSE. + + This access method is currently not in use. +*/ + +/*! + \fn bool TQIODevice::isBuffered() const + + Returns TRUE if the I/O device is a buffered device; otherwise + returns FALSE, i.e. the device is a raw device. + + \sa isRaw() +*/ + +/*! + \fn bool TQIODevice::isRaw() const + + Returns TRUE if the device is a raw device; otherwise returns + FALSE, i.e. if the device is a buffered device. + + \sa isBuffered() +*/ + +/*! + \fn bool TQIODevice::isSynchronous() const + + Returns TRUE if the I/O device is a synchronous device; otherwise + returns FALSE, i.e. the device is an asynchronous device. + + \sa isAsynchronous() +*/ + +/*! + \fn bool TQIODevice::isAsynchronous() const + + Returns TRUE if the device is an asynchronous device; otherwise + returns FALSE, i.e. if the device is a synchronous device. + + This mode is currently not in use. + + \sa isSynchronous() +*/ + +/*! + \fn bool TQIODevice::isTranslated() const + + Returns TRUE if the I/O device translates carriage-return and + linefeed characters; otherwise returns FALSE. + + A TQFile is translated if it is opened with the \c IO_Translate + mode flag. +*/ + +/*! + \fn bool TQIODevice::isReadable() const + + Returns TRUE if the I/O device was opened using \c IO_ReadOnly or + \c IO_ReadWrite mode; otherwise returns FALSE. + + \sa isWritable(), isReadWrite() +*/ + +/*! + \fn bool TQIODevice::isWritable() const + + Returns TRUE if the I/O device was opened using \c IO_WriteOnly or + \c IO_ReadWrite mode; otherwise returns FALSE. + + \sa isReadable(), isReadWrite() +*/ + +/*! + \fn bool TQIODevice::isReadWrite() const + + Returns TRUE if the I/O device was opened using \c IO_ReadWrite + mode; otherwise returns FALSE. + + \sa isReadable(), isWritable() +*/ + +/*! + \fn bool TQIODevice::isInactive() const + + Returns TRUE if the I/O device state is 0, i.e. the device is not + open; otherwise returns FALSE. + + \sa isOpen() +*/ + +/*! + \fn bool TQIODevice::isOpen() const + + Returns TRUE if the I/O device has been opened; otherwise returns + FALSE. + + \sa isInactive() +*/ + + +/*! + \fn int TQIODevice::status() const + + Returns the I/O device status. + + The I/O device status returns an error code. If open() returns + FALSE or readBlock() or writeBlock() return -1, this function can + be called to find out the reason why the operation failed. + + \keyword IO_Ok + \keyword IO_ReadError + \keyword IO_WriteError + \keyword IO_FatalError + \keyword IO_OpenError + \keyword IO_ConnectError + \keyword IO_AbortError + \keyword IO_TimeOutError + \keyword IO_UnspecifiedError + + The status codes are: + \table + \header \i Status code \i Meaning + \row \i \c IO_Ok \i The operation was successful. + \row \i \c IO_ReadError \i Could not read from the device. + \row \i \c IO_WriteError \i Could not write to the device. + \row \i \c IO_FatalError \i A fatal unrecoverable error occurred. + \row \i \c IO_OpenError \i Could not open the device. + \row \i \c IO_ConnectError \i Could not connect to the device. + \row \i \c IO_AbortError \i The operation was unexpectedly aborted. + \row \i \c IO_TimeOutError \i The operation timed out. + \row \i \c IO_UnspecifiedError \i An unspecified error happened on close. + \endtable + + \sa resetStatus() +*/ + +/*! + \fn void TQIODevice::resetStatus() + + Sets the I/O device status to \c IO_Ok. + + \sa status() +*/ + + +/*! + \fn void TQIODevice::setFlags( int flags ) + + Used by subclasses to set the device flags to the \a flags specified. +*/ + +/*! + \fn void TQIODevice::setType( int type ) + + Used by subclasses to set the device type to the \a type specified. +*/ + +void TQIODevice::setType( int t ) +{ +#if defined(QT_CHECK_RANGE) + if ( (t & IO_TypeMask) != t ) + qWarning( "TQIODevice::setType: Specified type out of range" ); +#endif + ioMode &= ~IO_TypeMask; // reset type bits + ioMode |= t; +} + +/*! + \fn void TQIODevice::setMode( int mode ) + + Used by subclasses to set the device mode to the \a mode specified. +*/ + +void TQIODevice::setMode( int m ) +{ +#if defined(QT_CHECK_RANGE) + if ( (m & IO_ModeMask) != m ) + qWarning( "TQIODevice::setMode: Specified mode out of range" ); +#endif + ioMode &= ~IO_ModeMask; // reset mode bits + ioMode |= m; +} + +/*! + \fn void TQIODevice::setState( int state ) + + Used by subclasses to set the device state to the \a state specified. +*/ + +void TQIODevice::setState( int s ) +{ +#if defined(QT_CHECK_RANGE) + if ( ((uint)s & IO_StateMask) != (uint)s ) + qWarning( "TQIODevice::setState: Specified state out of range" ); +#endif + ioMode &= ~IO_StateMask; // reset state bits + ioMode |= (uint)s; +} + +/*! + Used by subclasses to set the device status (not state) to \a s. +*/ + +void TQIODevice::setStatus( int s ) +{ + ioSt = s; +} + + +/*! + \fn bool TQIODevice::open( int mode ) + + Opens the I/O device using the specified \a mode. Returns TRUE if + the device was successfully opened; otherwise returns FALSE. + + The mode parameter \a mode must be an OR'ed combination of the + following flags. + \table + \header \i Mode flags \i Meaning + \row \i \c IO_Raw \i specifies raw (unbuffered) file access. + \row \i \c IO_ReadOnly \i opens a file in read-only mode. + \row \i \c IO_WriteOnly \i opens a file in write-only mode. + \row \i \c IO_ReadWrite \i opens a file in read/write mode. + \row \i \c IO_Append \i sets the file index to the end of the file. + \row \i \c IO_Truncate \i truncates the file. + \row \i \c IO_Translate \i enables carriage returns and linefeed + translation for text files under MS-DOS, Windows and Macintosh. On + Unix systems this flag has no effect. Use with caution as it will + also transform every linefeed written to the file into a CRLF + pair. This is likely to corrupt your file if you write write + binary data. Cannot be combined with \c IO_Raw. + \endtable + + This virtual function must be reimplemented by all subclasses. + + \sa close() +*/ + +/*! + \fn void TQIODevice::close() + + Closes the I/O device. + + This virtual function must be reimplemented by all subclasses. + + \sa open() +*/ + +/*! + \fn void TQIODevice::flush() + + Flushes an open I/O device. + + This virtual function must be reimplemented by all subclasses. +*/ + + +/*! + \fn TQIODevice::Offset TQIODevice::size() const + + Virtual function that returns the size of the I/O device. + + \sa at() +*/ + +/*! + Virtual function that returns the current I/O device position. + + This is the position of the data read/write head of the I/O + device. + + \sa size() +*/ + +TQIODevice::Offset TQIODevice::at() const +{ + return ioIndex; +} + + +/* + The following is a "bad" overload, since it does "not behave essentially + the same" like the above. So don't use \overload in the documentation of + this function and we have to live with the qdoc warning which is generated + for this. +*/ +/*! + Virtual function that sets the I/O device position to \a pos. + Returns TRUE if the position was successfully set, i.e. \a pos is + within range and the seek was successful; otherwise returns FALSE. + + \sa size() +*/ + +bool TQIODevice::at( Offset pos ) +{ +#if defined(QT_CHECK_RANGE) + if ( pos > size() ) { +#if defined(QT_ABI_QT4) + qWarning( "TQIODevice::at: Index %lld out of range", pos ); +#else + qWarning( "TQIODevice::at: Index %lu out of range", pos ); +#endif + return FALSE; + } +#endif + ioIndex = pos; + return TRUE; +} + +/*! + Virtual function that returns TRUE if the I/O device position is + at the end of the input; otherwise returns FALSE. +*/ + +bool TQIODevice::atEnd() const +{ + if ( isSequentialAccess() || isTranslated() ) { + TQIODevice* that = (TQIODevice*)this; + const int oldStatus = ioSt; + int c = that->getch(); + bool result = c < 0; + that->ungetch(c); + if (ioSt != oldStatus) + that->ioSt = oldStatus; + return result; + } else { + return at() == size(); + } +} + +/*! + \fn bool TQIODevice::reset() + + Sets the device index position to 0. + + \sa at() +*/ + + +/*! + \fn int TQIODevice::readBlock( char *data, Q_ULONG maxlen ) + + Reads at most \a maxlen bytes from the I/O device into \a data and + returns the number of bytes actually read. + + This function should return -1 if a fatal error occurs and should + return 0 if there are no bytes to read. + + The device must be opened for reading, and \a data must not be 0. + + This virtual function must be reimplemented by all subclasses. + + \sa writeBlock() isOpen() isReadable() +*/ + +/*! + This convenience function returns all of the remaining data in the + device. +*/ +TQByteArray TQIODevice::readAll() +{ + if ( isDirectAccess() ) { + // we know the size + int n = size()-at(); // ### fix for 64-bit or large files? + int totalRead = 0; + TQByteArray ba( n ); + char* c = ba.data(); + while ( n ) { + int r = readBlock( c, n ); + if ( r < 0 ) + return TQByteArray(); + n -= r; + c += r; + totalRead += r; + // If we have a translated file, then it is possible that + // we read less bytes than size() reports + if ( atEnd() ) { + ba.resize( totalRead ); + break; + } + } + return ba; + } else { + // read until we reach the end + const int blocksize = 512; + int nread = 0; + TQByteArray ba; + while ( !atEnd() ) { + ba.resize( nread + blocksize ); + int r = readBlock( ba.data()+nread, blocksize ); + if ( r < 0 ) + return TQByteArray(); + nread += r; + } + ba.resize( nread ); + return ba; + } +} + +/*! + \fn int TQIODevice::writeBlock( const char *data, Q_ULONG len ) + + Writes \a len bytes from \a data to the I/O device and returns the + number of bytes actually written. + + This function should return -1 if a fatal error occurs. + + This virtual function must be reimplemented by all subclasses. + + \sa readBlock() +*/ + +/*! + \overload + + This convenience function is the same as calling writeBlock( + data.data(), data.size() ). +*/ +Q_LONG TQIODevice::writeBlock( const TQByteArray& data ) +{ + return writeBlock( data.data(), data.size() ); +} + +/*! + Reads a line of text, (or up to \a maxlen bytes if a newline isn't + encountered) plus a terminating '\0' into \a data. If there is a + newline at the end if the line, it is not stripped. + + Returns the number of bytes read including the terminating '\0', + or -1 if an error occurred. + + This virtual function can be reimplemented much more efficiently + by the most subclasses. + + \sa readBlock(), TQTextStream::readLine() +*/ + +Q_LONG TQIODevice::readLine( char *data, Q_ULONG maxlen ) +{ + if ( maxlen == 0 ) // application bug? + return 0; + char *p = data; + while ( --maxlen && (readBlock(p,1)>0) ) { // read one byte at a time + if ( *p++ == '\n' ) // end of line + break; + } + *p++ = '\0'; + return p - data; +} + + +/*! + \fn int TQIODevice::getch() + + Reads a single byte/character from the I/O device. + + Returns the byte/character read, or -1 if the end of the I/O + device has been reached. + + This virtual function must be reimplemented by all subclasses. + + \sa putch(), ungetch() +*/ + +/*! + \fn int TQIODevice::putch( int ch ) + + Writes the character \a ch to the I/O device. + + Returns \a ch, or -1 if an error occurred. + + This virtual function must be reimplemented by all subclasses. + + \sa getch(), ungetch() +*/ + +/*! + \fn int TQIODevice::ungetch( int ch ) + + Puts the character \a ch back into the I/O device and decrements + the index position if it is not zero. + + This function is normally called to "undo" a getch() operation. + + Returns \a ch, or -1 if an error occurred. + + This virtual function must be reimplemented by all subclasses. + + \sa getch(), putch() +*/ diff --git a/src/tools/qiodevice.h b/src/tools/qiodevice.h new file mode 100644 index 000000000..5fbae38bc --- /dev/null +++ b/src/tools/qiodevice.h @@ -0,0 +1,164 @@ +/**************************************************************************** +** +** Definition of TQIODevice class +** +** Created : 940913 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQIODEVICE_H +#define TQIODEVICE_H + +#ifndef QT_H +#include "qglobal.h" +#include "qcstring.h" +#endif // QT_H + + +// IO device access types + +#define IO_Direct 0x0100 // direct access device +#define IO_Sequential 0x0200 // sequential access device +#define IO_Combined 0x0300 // combined direct/sequential +#define IO_TypeMask 0x0f00 + +// IO handling modes + +#define IO_Raw 0x0040 // raw access (not buffered) +#define IO_Async 0x0080 // asynchronous mode + +// IO device open modes + +#define IO_ReadOnly 0x0001 // readable device +#define IO_WriteOnly 0x0002 // writable device +#define IO_ReadWrite 0x0003 // read+write device +#define IO_Append 0x0004 // append +#define IO_Truncate 0x0008 // truncate device +#define IO_Translate 0x0010 // translate CR+LF +#define IO_ModeMask 0x00ff + +// IO device state + +#define IO_Open 0x1000 // device is open +#define IO_StateMask 0xf000 + +// IO device status + +#define IO_Ok 0 +#define IO_ReadError 1 // read error +#define IO_WriteError 2 // write error +#define IO_FatalError 3 // fatal unrecoverable error +#define IO_ResourceError 4 // resource limitation +#define IO_OpenError 5 // cannot open device +#define IO_ConnectError 5 // cannot connect to device +#define IO_AbortError 6 // abort error +#define IO_TimeOutError 7 // time out +#define IO_UnspecifiedError 8 // unspecified error + + +class Q_EXPORT TQIODevice +{ +public: +#if defined(QT_ABI_QT4) + typedef Q_LLONG Offset; +#else + typedef Q_ULONG Offset; +#endif + + TQIODevice(); + virtual ~TQIODevice(); + + int flags() const { return ioMode; } + int mode() const { return ioMode & IO_ModeMask; } + int state() const { return ioMode & IO_StateMask; } + + bool isDirectAccess() const { return ((ioMode & IO_Direct) == IO_Direct); } + bool isSequentialAccess() const { return ((ioMode & IO_Sequential) == IO_Sequential); } + bool isCombinedAccess() const { return ((ioMode & IO_Combined) == IO_Combined); } + bool isBuffered() const { return ((ioMode & IO_Raw) != IO_Raw); } + bool isRaw() const { return ((ioMode & IO_Raw) == IO_Raw); } + bool isSynchronous() const { return ((ioMode & IO_Async) != IO_Async); } + bool isAsynchronous() const { return ((ioMode & IO_Async) == IO_Async); } + bool isTranslated() const { return ((ioMode & IO_Translate) == IO_Translate); } + bool isReadable() const { return ((ioMode & IO_ReadOnly) == IO_ReadOnly); } + bool isWritable() const { return ((ioMode & IO_WriteOnly) == IO_WriteOnly); } + bool isReadWrite() const { return ((ioMode & IO_ReadWrite) == IO_ReadWrite); } + bool isInactive() const { return state() == 0; } + bool isOpen() const { return state() == IO_Open; } + + int status() const { return ioSt; } + void resetStatus() { ioSt = IO_Ok; } + + virtual bool open( int mode ) = 0; + virtual void close() = 0; + virtual void flush() = 0; + + virtual Offset size() const = 0; + virtual Offset at() const; + virtual bool at( Offset ); + virtual bool atEnd() const; + bool reset() { return at(0); } + + virtual Q_LONG readBlock( char *data, Q_ULONG maxlen ) = 0; + virtual Q_LONG writeBlock( const char *data, Q_ULONG len ) = 0; + virtual Q_LONG readLine( char *data, Q_ULONG maxlen ); + Q_LONG writeBlock( const TQByteArray& data ); + virtual TQByteArray readAll(); + + virtual int getch() = 0; + virtual int putch( int ) = 0; + virtual int ungetch( int ) = 0; + +protected: + void setFlags( int f ) { ioMode = f; } + void setType( int ); + void setMode( int ); + void setState( int ); + void setStatus( int ); + Offset ioIndex; + +private: + int ioMode; + int ioSt; + +private: // Disabled copy constructor and operator= +#if defined(Q_DISABLE_COPY) + TQIODevice( const TQIODevice & ); + TQIODevice &operator=( const TQIODevice & ); +#endif +}; + + +#endif // TQIODEVICE_H diff --git a/src/tools/qlibrary.cpp b/src/tools/qlibrary.cpp new file mode 100644 index 000000000..8a3248b23 --- /dev/null +++ b/src/tools/qlibrary.cpp @@ -0,0 +1,443 @@ +/**************************************************************************** +** +** Implementation of TQLibrary class +** +** Created : 000101 +** +** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "qplatformdefs.h" +#include +#include +#include + +#ifndef QT_NO_LIBRARY + +// uncomment this to get error messages +//#define QT_DEBUG_COMPONENT 1 +// uncomment this to get error and success messages +//#define QT_DEBUG_COMPONENT 2 + +#ifndef QT_DEBUG_COMPONENT +# if defined(QT_DEBUG) +# define QT_DEBUG_COMPONENT 1 +# endif +#endif + +#if (defined(Q_WS_WIN) && !defined(QT_MAKEDLL)) \ + || (defined(Q_OS_FREEBSD) && defined(Q_CC_INTEL)) \ + || (defined(Q_OS_IRIX) && defined(Q_CC_GNU)) +#define QT_NO_LIBRARY_UNLOAD +#endif + +TQLibraryPrivate::TQLibraryPrivate( TQLibrary *lib ) + : pHnd( 0 ), library( lib ) +{ +} + + +/*! + \class TQLibrary qlibrary.h + \reentrant + \brief The TQLibrary class provides a wrapper for handling shared libraries. + + \mainclass + \ingroup plugins + + An instance of a TQLibrary object can handle a single shared + library and provide access to the functionality in the library in + a platform independent way. If the library is a component server, + TQLibrary provides access to the exported component and can + directly query this component for interfaces. + + TQLibrary ensures that the shared library is loaded and stays in + memory whilst it is in use. TQLibrary can also unload the library + on destruction and release unused resources. + + A typical use of TQLibrary is to resolve an exported symbol in a + shared object, and to call the function that this symbol + represents. This is called "explicit linking" in contrast to + "implicit linking", which is done by the link step in the build + process when linking an executable against a library. + + The following code snippet loads a library, resolves the symbol + "mysymbol", and calls the function if everything succeeded. If + something went wrong, e.g. the library file does not exist or the + symbol is not defined, the function pointer will be 0 and won't be + called. When the TQLibrary object is destroyed the library will be + unloaded, making all references to memory allocated in the library + invalid. + + \code + typedef void (*MyPrototype)(); + MyPrototype myFunction; + + TQLibrary myLib( "mylib" ); + myFunction = (MyPrototype) myLib.resolve( "mysymbol" ); + if ( myFunction ) { + myFunction(); + } + \endcode +*/ + +/*! + Creates a TQLibrary object for the shared library \a filename. The + library will be unloaded in the destructor. + + Note that \a filename does not need to include the (platform specific) + file extension, so calling + \code + TQLibrary lib( "mylib" ); + \endcode + is equivalent to calling + \code + TQLibrary lib( "mylib.dll" ); + \endcode + on Windows, and + \code + TQLibrary lib( "libmylib.so" ); + \endcode + on Unix. Specifying the extension is not recommended, since + doing so introduces a platform dependency. + + If \a filename does not include a path, the library loader will + look for the file in the platform specific search paths. + + \sa load() unload(), setAutoUnload() +*/ +TQLibrary::TQLibrary( const TQString& filename ) + : libfile( filename ), aunload( TRUE ) +{ + libfile.replace( '\\', '/' ); + d = new TQLibraryPrivate( this ); +} + +/*! + Deletes the TQLibrary object. + + The library will be unloaded if autoUnload() is TRUE (the + default), otherwise it stays in memory until the application + exits. + + \sa unload(), setAutoUnload() +*/ +TQLibrary::~TQLibrary() +{ + if ( autoUnload() ) + unload(); + + delete d; +} + +/*! + Returns the address of the exported symbol \a symb. The library is + loaded if necessary. The function returns 0 if the symbol could + not be resolved or the library could not be loaded. + + \code + typedef int (*avgProc)( int, int ); + + avgProc avg = (avgProc) library->resolve( "avg" ); + if ( avg ) + return avg( 5, 8 ); + else + return -1; + \endcode + + The symbol must be exported as a C-function from the library. This + retquires the \c {extern "C"} notation if the library is compiled + with a C++ compiler. On Windows you also have to explicitly export + the function from the DLL using the \c {__declspec(dllexport)} + compiler directive. + + \code + extern "C" MY_EXPORT_MACRO int avg(int a, int b) + { + return (a + b) / 2; + } + \endcode + + with \c MY_EXPORT defined as + + \code + #ifdef Q_WS_WIN + # define MY_EXPORT __declspec(dllexport) + #else + # define MY_EXPORT + #endif + \endcode + + On Darwin and Mac OS X this function uses code from dlcompat, part of the + OpenDarwin project. + + \legalese + + Copyright (c) 2002 Jorge Acereda and Peter O'Gorman + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ +void *TQLibrary::resolve( const char* symb ) +{ + if ( !d->pHnd ) + load(); + if ( !d->pHnd ) + return 0; + + void *address = d->resolveSymbol( symb ); + + return address; +} + +/*! + \overload + + Loads the library \a filename and returns the address of the + exported symbol \a symb. Note that like the constructor, \a + filename does not need to include the (platform specific) file + extension. The library remains loaded until the process exits. + + The function returns 0 if the symbol could not be resolved or the + library could not be loaded. + + This function is useful only if you want to resolve a single + symbol, e.g. a function pointer from a specific library once: + + \code + typedef void (*FunctionType)(); + static FunctionType *ptrFunction = 0; + static bool triedResolve = FALSE; + if ( !ptrFunction && !triedResolve ) + ptrFunction = TQLibrary::resolve( "mylib", "mysymb" ); + + if ( ptrFunction ) + ptrFunction(); + else + ... + \endcode + + If you want to resolve multiple symbols, use a TQLibrary object and + call the non-static version of resolve(). + + \sa resolve() +*/ +void *TQLibrary::resolve( const TQString &filename, const char *symb ) +{ + TQLibrary lib( filename ); + lib.setAutoUnload( FALSE ); + return lib.resolve( symb ); +} + +/*! + Returns TRUE if the library is loaded; otherwise returns FALSE. + + \sa unload() +*/ +bool TQLibrary::isLoaded() const +{ + return d->pHnd != 0; +} + +/*! + Loads the library. Since resolve() always calls this function + before resolving any symbols it is not necessary to call it + explicitly. In some situations you might want the library loaded + in advance, in which case you would use this function. + + On Darwin and Mac OS X this function uses code from dlcompat, part of the + OpenDarwin project. + + \legalese + + Copyright (c) 2002 Jorge Acereda and Peter O'Gorman + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ +bool TQLibrary::load() +{ + if (libfile.isEmpty()) + return FALSE; + return d->loadLibrary(); +} + +/*! + Unloads the library and returns TRUE if the library could be + unloaded; otherwise returns FALSE. + + This function is called by the destructor if autoUnload() is + enabled. + + \sa resolve() +*/ +bool TQLibrary::unload() +{ + if ( !d->pHnd ) + return TRUE; + +#if !defined(QT_NO_LIBRARY_UNLOAD) + if ( !d->freeLibrary() ) { +# if defined(QT_DEBUG_COMPONENT) + qWarning( "%s could not be unloaded", (const char*) TQFile::encodeName(library()) ); +# endif + return FALSE; + } + +# if defined(QT_DEBUG_COMPONENT) && QT_DEBUG_COMPONENT == 2 + qWarning( "%s has been unloaded", (const char*) TQFile::encodeName(library()) ); +# endif + d->pHnd = 0; +#endif + return TRUE; +} + +/*! + Returns TRUE if the library will be automatically unloaded when + this wrapper object is destructed; otherwise returns FALSE. The + default is TRUE. + + \sa setAutoUnload() +*/ +bool TQLibrary::autoUnload() const +{ + return (bool)aunload; +} + +/*! + If \a enabled is TRUE (the default), the wrapper object is set to + automatically unload the library upon destruction. If \a enabled + is FALSE, the wrapper object is not unloaded unless you explicitly + call unload(). + + \sa autoUnload() +*/ +void TQLibrary::setAutoUnload( bool enabled ) +{ + aunload = enabled; +} + +/*! + Returns the filename of the shared library this TQLibrary object + handles, including the platform specific file extension. + + For example: + \code + TQLibrary lib( "mylib" ); + TQString str = lib.library(); + \endcode + will set \e str to "mylib.dll" on Windows, and "libmylib.so" on Linux. +*/ +TQString TQLibrary::library() const +{ + if ( libfile.isEmpty() ) + return libfile; + + TQString filename = libfile; + +#if defined(Q_WS_WIN) + if ( filename.findRev( '.' ) <= filename.findRev( '/' ) ) + filename += ".dll"; +#else + TQStringList filters = ""; +#ifdef Q_OS_MACX + filters << ".so"; + filters << ".bundle"; + filters << ".dylib"; //the last one is also the default one.. +#elif defined(Q_OS_HPUX) + filters << ".sl"; +#else + filters << ".so"; +#endif + for(TQStringList::Iterator it = filters.begin(); TRUE; ) { + TQString filter = (*it); + ++it; + + if(TQFile::exists(filename + filter)) { + filename += filter; + break; + } else if(!filter.isEmpty()) { + TQString tmpfilename = filename; + const int x = tmpfilename.findRev( "/" ); + if ( x != -1 ) { + TQString path = tmpfilename.left( x + 1 ); + TQString file = tmpfilename.right( tmpfilename.length() - x - 1 ); + tmpfilename = TQString( "%1lib%2" ).arg( path ).arg( file ); + } else { + tmpfilename = TQString( "lib%1" ).arg( filename ); + } + if ( !filename.contains(".so") ) + tmpfilename += filter; + if(TQFile::exists(tmpfilename) || it == filters.end()) { + filename = tmpfilename; + break; + } + } + } +#endif + return filename; +} +#endif //QT_NO_LIBRARY diff --git a/src/tools/qlibrary.h b/src/tools/qlibrary.h new file mode 100644 index 000000000..a0795dc93 --- /dev/null +++ b/src/tools/qlibrary.h @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** Definition of TQLibrary class +** +** Created : 000101 +** +** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQLIBRARY_H +#define TQLIBRARY_H + +#ifndef QT_H +#include "qstring.h" +#endif // QT_H + +#ifndef QT_NO_LIBRARY + +class TQLibraryPrivate; + +class Q_EXPORT TQLibrary +{ +public: + TQLibrary( const TQString& filename ); + virtual ~TQLibrary(); + + void *resolve( const char* ); + static void *resolve( const TQString &filename, const char * ); + + bool load(); + virtual bool unload(); + bool isLoaded() const; + + bool autoUnload() const; + void setAutoUnload( bool enable ); + + TQString library() const; + +private: + TQLibraryPrivate *d; + + TQString libfile; + uint aunload : 1; + +private: // Disabled copy constructor and operator= +#if defined(Q_DISABLE_COPY) + TQLibrary( const TQLibrary & ); + TQLibrary &operator=( const TQLibrary & ); +#endif +}; + +#define Q_DEFINED_QLIBRARY +#include "qwinexport.h" +#endif //QT_NO_LIBRARY +#endif //TQLIBRARY_H diff --git a/src/tools/qlibrary_p.h b/src/tools/qlibrary_p.h new file mode 100644 index 000000000..4e558d38b --- /dev/null +++ b/src/tools/qlibrary_p.h @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Definition of an internal TQLibrary class +** +** Created : 000101 +** +** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQLIBRARY_P_H +#define TQLIBRARY_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the TQt API. It exists for the convenience +// of the TQLibrary class. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// +// + +#include "qlibrary.h" + +#ifndef QT_NO_LIBRARY + +#ifndef QT_H +#include "qwindowdefs.h" +#endif // QT_H + +class TQLibraryPrivate +{ +public: + TQLibraryPrivate( TQLibrary *lib ); + +#ifdef Q_WS_WIN + HINSTANCE pHnd; +#else + void *pHnd; +#endif + + bool loadLibrary(); + bool freeLibrary(); + void *resolveSymbol( const char * ); + +private: + TQLibrary *library; +}; + +#endif // QT_NO_LIBRARY +#endif // TQLIBRARY_P_H diff --git a/src/tools/qlibrary_unix.cpp b/src/tools/qlibrary_unix.cpp new file mode 100644 index 000000000..114ec7c26 --- /dev/null +++ b/src/tools/qlibrary_unix.cpp @@ -0,0 +1,169 @@ +/**************************************************************************** +** +** Implementation of TQLibraryPrivate class +** +** Created : 000101 +** +** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "qplatformdefs.h" +#include "private/qlibrary_p.h" + +#ifndef QT_NO_LIBRARY + +#if defined(QT_AOUT_UNDERSCORE) +#include +#endif + +/* + The platform dependent implementations of + - loadLibrary + - freeLibrary + - resolveSymbol + + It's not too hard to guess what the functions do. +*/ + +#if defined(QT_HPUX_LD) // for HP-UX < 11.x and 32 bit + +bool TQLibraryPrivate::loadLibrary() +{ + if ( pHnd ) + return TRUE; + + TQString filename = library->library(); + + pHnd = (void*)shl_load( filename.latin1(), BIND_DEFERRED | BIND_NONFATAL | DYNAMIC_PATH, 0 ); +#if defined(QT_DEBUG) || defined(QT_DEBUG_COMPONENT) + if ( !pHnd ) + qWarning( "%s: failed to load library!", filename.latin1() ); +#endif + return pHnd != 0; +} + +bool TQLibraryPrivate::freeLibrary() +{ + if ( !pHnd ) + return TRUE; + + if ( shl_unload( (shl_t)pHnd ) ) { +#if defined(QT_DEBUG) || defined(QT_DEBUG_COMPONENT) + TQString filename = library->library(); + qWarning( "%s: Failed to unload library!", filename.latin1() ); +#endif + return FALSE; + } + pHnd = 0; + return TRUE; +} + +void* TQLibraryPrivate::resolveSymbol( const char* symbol ) +{ + if ( !pHnd ) + return 0; + + void* address = 0; + if ( shl_findsym( (shl_t*)&pHnd, symbol, TYPE_UNDEFINED, &address ) < 0 ) { +#if defined(QT_DEBUG_COMPONENT) + TQString filename = library->library(); + qWarning( "%s: couldn't resolve symbol \"%s\"", filename.latin1(), symbol ); +#endif + } + return address; +} + +#else // POSIX +#include +#ifndef DL_PREFIX //for mac dlcompat +# define DL_PREFIX(x) x +#endif + +bool TQLibraryPrivate::loadLibrary() +{ + if ( pHnd ) + return TRUE; + + TQString filename = library->library(); + + pHnd = DL_PREFIX(dlopen)( filename.latin1(), RTLD_LAZY ); +#if defined(QT_DEBUG) || defined(QT_DEBUG_COMPONENT) + if ( !pHnd ) + qWarning( "%s", DL_PREFIX(dlerror)() ); +#endif + return pHnd != 0; +} + +bool TQLibraryPrivate::freeLibrary() +{ + if ( !pHnd ) + return TRUE; + + if ( DL_PREFIX(dlclose)( pHnd ) ) { +#if defined(QT_DEBUG) || defined(QT_DEBUG_COMPONENT) + qWarning( "%s", DL_PREFIX(dlerror)() ); +#endif + return FALSE; + } + + pHnd = 0; + return TRUE; +} + +void* TQLibraryPrivate::resolveSymbol( const char* symbol ) +{ + if ( !pHnd ) + return 0; + +#if defined(QT_AOUT_UNDERSCORE) + // older a.out systems add an underscore in front of symbols + char* undrscr_symbol = new char[strlen(symbol)+2]; + undrscr_symbol[0] = '_'; + strcpy(undrscr_symbol+1, symbol); + void* address = DL_PREFIX(dlsym)( pHnd, undrscr_symbol ); + delete [] undrscr_symbol; +#else + void* address = DL_PREFIX(dlsym)( pHnd, symbol ); +#endif +#if defined(QT_DEBUG_COMPONENT) + const char* error = DL_PREFIX(dlerror)(); + if ( error ) + qWarning( "%s", error ); +#endif + return address; +} + +#endif // POSIX + +#endif diff --git a/src/tools/qlocale.cpp b/src/tools/qlocale.cpp new file mode 100644 index 000000000..cf81effb7 --- /dev/null +++ b/src/tools/qlocale.cpp @@ -0,0 +1,6322 @@ +/**************************************************************************** +** +** Implementation of the TQLocale class +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include +#include +#include +#include +#include +#include + +#include "qlocale.h" +#include "qlocale_p.h" +#include "qnamespace.h" + +#ifdef QT_QLOCALE_USES_FCVT +# include +# include +#endif + +#if defined (Q_OS_WIN) +# include +# undef NAN // we want to use our fallback on Windows +# undef INFINITY +#endif + +#ifdef Q_OS_LINUX +# include +#endif + +#if !defined( TQWS ) && defined( Q_OS_MAC ) +# include +#endif + +#if defined (Q_OS_SOLARIS) +# include +#endif + +#if defined (Q_OS_OSF) && (defined(__DECC) || defined(__DECCXX)) +# define INFINITY DBL_INFINITY +# define NAN DBL_QNAN +#endif + +#if (defined(Q_CC_GNU) && defined(Q_OS_WIN)) || __GNUC__ == 4 || defined(QT_QLOCALE_NEEDS_VOLATILE) +# define NEEDS_VOLATILE volatile +#else +# define NEEDS_VOLATILE +#endif + +enum { + LittleEndian, + BigEndian + +#ifdef Q_BYTE_ORDER +# if Q_BYTE_ORDER == Q_BIG_ENDIAN + , ByteOrder = BigEndian +# elif Q_BYTE_ORDER == Q_LITTLE_ENDIAN + , ByteOrder = LittleEndian +# else +# error "undefined byte order" +# endif +}; +#else +}; +static const unsigned int one = 1; +static const bool ByteOrder = ((*((unsigned char *) &one) == 0) ? BigEndian : LittleEndian); +#endif + +#if !defined(INFINITY) +static const unsigned char be_inf_bytes[] = { 0x7f, 0xf0, 0, 0, 0, 0, 0, 0 }; +static const unsigned char le_inf_bytes[] = { 0, 0, 0, 0, 0, 0, 0xf0, 0x7f }; +static inline double inf() +{ + return (ByteOrder == BigEndian ? + *((const double *) be_inf_bytes) : + *((const double *) le_inf_bytes)); +} +# define INFINITY (::inf()) +#endif + +#if !defined(NAN) +static const unsigned char be_nan_bytes[] = { 0x7f, 0xf8, 0, 0, 0, 0, 0, 0 }; +static const unsigned char le_nan_bytes[] = { 0, 0, 0, 0, 0, 0, 0xf8, 0x7f }; +static inline double nan() +{ + return (ByteOrder == BigEndian ? + *((const double *) be_nan_bytes) : + *((const double *) le_nan_bytes)); +} +# define NAN (::nan()) +#endif + +// We can't rely on -NAN, since all operations on a NAN should return a NAN. +static double be_neg_nan; +static double le_neg_nan; +static const unsigned char be_neg_nan_bytes[] = { 0xff, 0xf8, 0, 0, 0, 0, 0, 0 }; +static const unsigned char le_neg_nan_bytes[] = { 0, 0, 0, 0, 0, 0, 0xf8, 0xff }; +static bool neg_nan_init = false; + +static inline double negNan() +{ + if (!neg_nan_init) + { + memcpy(&be_neg_nan,be_neg_nan_bytes,sizeof(be_neg_nan_bytes)); + memcpy(&le_neg_nan,le_neg_nan_bytes,sizeof(le_neg_nan_bytes)); + neg_nan_init = true; + } + return (ByteOrder == BigEndian ? + be_neg_nan : + le_neg_nan); + +} + +// Sizes as defined by the ISO C99 standard - fallback +#ifndef LLONG_MAX +# define LLONG_MAX Q_INT64_C(9223372036854775807) +#endif +#ifndef LLONG_MIN +# define LLONG_MIN (-LLONG_MAX - Q_INT64_C(1)) +#endif +#ifndef ULLONG_MAX +# define ULLONG_MAX Q_UINT64_C(0xffffffffffffffff) +#endif + +#ifndef QT_QLOCALE_USES_FCVT +static char *qdtoa(double d, int mode, int ndigits, int *decpt, + int *sign, char **rve, char **digits_str); +static char *_qdtoa(double d, int mode, int ndigits, int *decpt, + int *sign, char **rve, char **digits_str); +static double qstrtod(const char *s00, char const **se, bool *ok); +#endif +static Q_LLONG qstrtoll(const char *nptr, const char **endptr, register int base, bool *ok); +static Q_ULLONG qstrtoull(const char *nptr, const char **endptr, register int base, bool *ok); + +static inline bool compareBits(double d1, double d2) +{ + return memcmp((const char*)&d1, (const char*)&d2, sizeof(double)) == 0; +} + +static inline bool qIsInf(double d) +{ + return compareBits(d, INFINITY) || compareBits(d, -INFINITY); +} + +static inline bool qIsNan(double d) +{ + return compareBits(d, NAN) || compareBits(d, negNan()); +} + +static const uint locale_index[] = { + 0, // unused + 0, // C + 0, // Abkhazian + 0, // Afan + 0, // Afar + 1, // Afrikaans + 2, // Albanian + 0, // Amharic + 3, // Arabic + 19, // Armenian + 0, // Assamese + 0, // Aymara + 20, // Azerbaijani + 0, // Bashkir + 21, // Basque + 22, // Bengali + 0, // Bhutani + 0, // Bihari + 0, // Bislama + 0, // Breton + 23, // Bulgarian + 0, // Burmese + 24, // Byelorussian + 0, // Cambodian + 25, // Catalan + 26, // Chinese + 0, // Corsican + 31, // Croatian + 32, // Czech + 33, // Danish + 34, // Dutch + 36, // English + 0, // Esperanto + 48, // Estonian + 49, // Faroese + 0, // Fiji + 50, // Finnish + 51, // French + 0, // Frisian + 0, // Gaelic + 57, // Galician + 58, // Georgian + 59, // German + 64, // Greek + 0, // Greenlandic + 0, // Guarani + 65, // Gujarati + 0, // Hausa + 66, // Hebrew + 67, // Hindi + 68, // Hungarian + 69, // Icelandic + 70, // Indonesian + 0, // Interlingua + 0, // Interlingue + 0, // Inuktitut + 0, // Inupiak + 0, // Irish + 71, // Italian + 73, // Japanese + 0, // Javanese + 74, // Kannada + 0, // Kashmiri + 75, // Kazakh + 0, // Kinyarwanda + 76, // Kirghiz + 77, // Korean + 0, // Kurdish + 0, // Kurundi + 0, // Laothian + 0, // Latin + 78, // Latvian + 0, // Lingala + 79, // Lithuanian + 80, // Macedonian + 0, // Malagasy + 81, // Malay + 0, // Malayalam + 0, // Maltese + 0, // Maori + 83, // Marathi + 0, // Moldavian + 84, // Mongolian + 0, // Nauru + 0, // Nepali + 85, // Norwegian + 0, // Occitan + 0, // Oriya + 0, // Pashto + 86, // Persian + 87, // Polish + 88, // Portuguese + 90, // Punjabi + 0, // Quechua + 0, // RhaetoRomance + 91, // Romanian + 92, // Russian + 0, // Samoan + 0, // Sangho + 93, // Sanskrit + 0, // Serbian + 0, // SerboCroatian + 0, // Sesotho + 0, // Setswana + 0, // Shona + 0, // Sindhi + 0, // Singhalese + 0, // Siswati + 94, // Slovak + 95, // Slovenian + 0, // Somali + 96, // Spanish + 0, // Sundanese + 115, // Swahili + 116, // Swedish + 0, // Tagalog + 0, // Tajik + 118, // Tamil + 0, // Tatar + 119, // Telugu + 120, // Thai + 0, // Tibetan + 0, // Tigrinya + 0, // Tonga + 0, // Tsonga + 121, // Turkish + 0, // Turkmen + 0, // Twi + 0, // Uigur + 122, // Ukrainian + 123, // Urdu + 124, // Uzbek + 125, // Vietnamese + 0, // Volapuk + 0, // Welsh + 0, // Wolof + 0, // Xhosa + 0, // Yiddish + 0, // Yoruba + 0, // Zhuang + 0, // Zulu + 0 // trailing 0 +}; + +static const TQLocalePrivate locale_data[] = { +// lang terr dec group list prcnt zero minus exp + { 1, 0, 46, 44, 59, 37, 48, 45, 101 }, // C/AnyCountry + { 5, 195, 46, 44, 44, 37, 48, 45, 101 }, // Afrikaans/SouthAfrica + { 6, 2, 44, 46, 59, 37, 48, 45, 101 }, // Albanian/Albania + { 8, 186, 46, 44, 59, 37, 1632, 45, 101 }, // Arabic/SaudiArabia + { 8, 3, 46, 44, 59, 37, 48, 45, 101 }, // Arabic/Algeria + { 8, 17, 46, 44, 59, 37, 1632, 45, 101 }, // Arabic/Bahrain + { 8, 64, 46, 44, 59, 37, 1632, 45, 101 }, // Arabic/Egypt + { 8, 103, 46, 44, 59, 37, 1632, 45, 101 }, // Arabic/Iraq + { 8, 109, 46, 44, 59, 37, 1632, 45, 101 }, // Arabic/Jordan + { 8, 115, 46, 44, 59, 37, 1632, 45, 101 }, // Arabic/Kuwait + { 8, 119, 46, 44, 59, 37, 1632, 45, 101 }, // Arabic/Lebanon + { 8, 122, 46, 44, 59, 37, 48, 45, 101 }, // Arabic/LibyanArabJamahiriya + { 8, 145, 46, 44, 59, 37, 48, 45, 101 }, // Arabic/Morocco + { 8, 162, 46, 44, 59, 37, 1632, 45, 101 }, // Arabic/Oman + { 8, 175, 46, 44, 59, 37, 1632, 45, 101 }, // Arabic/Qatar + { 8, 207, 46, 44, 59, 37, 1632, 45, 101 }, // Arabic/SyrianArabRepublic + { 8, 216, 46, 44, 59, 37, 48, 45, 101 }, // Arabic/Tunisia + { 8, 223, 46, 44, 59, 37, 1632, 45, 101 }, // Arabic/UnitedArabEmirates + { 8, 237, 46, 44, 59, 37, 1632, 45, 101 }, // Arabic/Yemen + { 9, 11, 46, 44, 44, 37, 48, 45, 101 }, // Armenian/Armenia + { 12, 15, 44, 160, 59, 37, 48, 45, 101 }, // Azerbaijani/Azerbaijan + { 14, 197, 44, 46, 59, 37, 48, 45, 101 }, // Basque/Spain + { 15, 100, 46, 44, 59, 37, 48, 45, 101 }, // Bengali/India + { 20, 33, 44, 160, 59, 37, 48, 45, 101 }, // Bulgarian/Bulgaria + { 22, 20, 44, 160, 59, 37, 48, 45, 101 }, // Byelorussian/Belarus + { 24, 197, 44, 46, 59, 37, 48, 45, 101 }, // Catalan/Spain + { 25, 44, 46, 44, 44, 37, 48, 45, 101 }, // Chinese/China + { 25, 97, 46, 44, 44, 37, 48, 45, 101 }, // Chinese/HongKong + { 25, 126, 46, 44, 44, 37, 48, 45, 101 }, // Chinese/Macau + { 25, 190, 46, 44, 44, 37, 48, 45, 101 }, // Chinese/Singapore + { 25, 208, 46, 44, 44, 37, 48, 45, 101 }, // Chinese/Taiwan + { 27, 54, 44, 46, 59, 37, 48, 45, 101 }, // Croatian/Croatia + { 28, 57, 44, 160, 59, 37, 48, 45, 101 }, // Czech/CzechRepublic + { 29, 58, 44, 46, 59, 37, 48, 45, 101 }, // Danish/Denmark + { 30, 151, 44, 46, 59, 37, 48, 45, 101 }, // Dutch/Netherlands + { 30, 21, 44, 46, 59, 37, 48, 45, 101 }, // Dutch/Belgium + { 31, 225, 46, 44, 44, 37, 48, 45, 101 }, // English/UnitedStates + { 31, 13, 46, 44, 44, 37, 48, 45, 101 }, // English/Australia + { 31, 22, 46, 44, 59, 37, 48, 45, 101 }, // English/Belize + { 31, 38, 46, 44, 44, 37, 48, 45, 101 }, // English/Canada + { 31, 104, 46, 44, 44, 37, 48, 45, 101 }, // English/Ireland + { 31, 107, 46, 44, 44, 37, 48, 45, 101 }, // English/Jamaica + { 31, 154, 46, 44, 44, 37, 48, 45, 101 }, // English/NewZealand + { 31, 170, 46, 44, 44, 37, 48, 45, 101 }, // English/Philippines + { 31, 195, 46, 44, 44, 37, 48, 45, 101 }, // English/SouthAfrica + { 31, 215, 46, 44, 59, 37, 48, 45, 101 }, // English/TrinidadAndTobago + { 31, 224, 46, 44, 44, 37, 48, 45, 101 }, // English/UnitedKingdom + { 31, 240, 46, 44, 44, 37, 48, 45, 101 }, // English/Zimbabwe + { 33, 68, 44, 160, 59, 37, 48, 45, 101 }, // Estonian/Estonia + { 34, 71, 44, 46, 59, 37, 48, 45, 101 }, // Faroese/FaroeIslands + { 36, 73, 44, 160, 59, 37, 48, 45, 101 }, // Finnish/Finland + { 37, 74, 44, 160, 59, 37, 48, 45, 101 }, // French/France + { 37, 21, 44, 46, 59, 37, 48, 45, 101 }, // French/Belgium + { 37, 38, 44, 160, 59, 37, 48, 45, 101 }, // French/Canada + { 37, 125, 44, 160, 59, 37, 48, 45, 101 }, // French/Luxembourg + { 37, 142, 44, 160, 59, 37, 48, 45, 101 }, // French/Monaco + { 37, 206, 46, 39, 59, 37, 48, 45, 101 }, // French/Switzerland + { 40, 197, 44, 46, 44, 37, 48, 45, 101 }, // Galician/Spain + { 41, 81, 44, 160, 59, 37, 48, 45, 101 }, // Georgian/Georgia + { 42, 82, 44, 46, 59, 37, 48, 45, 101 }, // German/Germany + { 42, 14, 44, 46, 59, 37, 48, 45, 101 }, // German/Austria + { 42, 123, 46, 39, 59, 37, 48, 45, 101 }, // German/Liechtenstein + { 42, 125, 44, 46, 59, 37, 48, 45, 101 }, // German/Luxembourg + { 42, 206, 46, 39, 59, 37, 48, 45, 101 }, // German/Switzerland + { 43, 85, 44, 46, 59, 37, 48, 45, 101 }, // Greek/Greece + { 46, 100, 46, 44, 44, 37, 2790, 45, 101 }, // Gujarati/India + { 48, 105, 46, 44, 44, 37, 48, 45, 101 }, // Hebrew/Israel + { 49, 100, 46, 44, 44, 37, 48, 45, 101 }, // Hindi/India + { 50, 98, 44, 160, 59, 37, 48, 45, 101 }, // Hungarian/Hungary + { 51, 99, 44, 46, 59, 37, 48, 45, 101 }, // Icelandic/Iceland + { 52, 101, 44, 46, 59, 37, 48, 45, 101 }, // Indonesian/Indonesia + { 58, 106, 44, 46, 59, 37, 48, 45, 101 }, // Italian/Italy + { 58, 206, 46, 39, 59, 37, 48, 45, 101 }, // Italian/Switzerland + { 59, 108, 46, 44, 44, 37, 48, 45, 101 }, // Japanese/Japan + { 61, 100, 46, 44, 44, 37, 3302, 45, 101 }, // Kannada/India + { 63, 110, 44, 160, 59, 37, 48, 45, 101 }, // Kazakh/Kazakhstan + { 65, 116, 44, 160, 59, 37, 48, 45, 101 }, // Kirghiz/Kyrgyzstan + { 66, 114, 46, 44, 44, 37, 48, 45, 101 }, // Korean/RepublicOfKorea + { 71, 118, 44, 160, 59, 37, 48, 45, 101 }, // Latvian/Latvia + { 73, 124, 44, 46, 59, 37, 48, 45, 101 }, // Lithuanian/Lithuania + { 74, 127, 44, 46, 59, 37, 48, 45, 101 }, // Macedonian/Macedonia + { 76, 130, 44, 46, 59, 37, 48, 45, 101 }, // Malay/Malaysia + { 76, 32, 44, 46, 59, 37, 48, 45, 101 }, // Malay/BruneiDarussalam + { 80, 100, 46, 44, 44, 37, 2406, 45, 101 }, // Marathi/India + { 82, 143, 44, 160, 59, 37, 48, 45, 101 }, // Mongolian/Mongolia + { 85, 161, 44, 160, 59, 37, 48, 45, 101 }, // Norwegian/Norway + { 89, 102, 46, 44, 59, 37, 1776, 45, 101 }, // Persian/Iran + { 90, 172, 44, 160, 59, 37, 48, 45, 101 }, // Polish/Poland + { 91, 173, 44, 46, 59, 37, 48, 45, 101 }, // Portuguese/Portugal + { 91, 30, 44, 46, 59, 37, 48, 45, 101 }, // Portuguese/Brazil + { 92, 100, 46, 44, 44, 37, 2662, 45, 101 }, // Punjabi/India + { 95, 177, 44, 46, 59, 37, 48, 45, 101 }, // Romanian/Romania + { 96, 178, 44, 160, 59, 37, 48, 45, 101 }, // Russian/RussianFederation + { 99, 100, 46, 44, 44, 37, 2406, 45, 101 }, // Sanskrit/India + { 108, 191, 44, 160, 59, 37, 48, 45, 101 }, // Slovak/Slovakia + { 109, 192, 44, 46, 59, 37, 48, 45, 101 }, // Slovenian/Slovenia + { 111, 197, 44, 46, 59, 37, 48, 45, 101 }, // Spanish/Spain + { 111, 10, 44, 46, 44, 37, 48, 45, 101 }, // Spanish/Argentina + { 111, 26, 44, 46, 44, 37, 48, 45, 101 }, // Spanish/Bolivia + { 111, 43, 44, 46, 44, 37, 48, 45, 101 }, // Spanish/Chile + { 111, 47, 44, 46, 44, 37, 48, 45, 101 }, // Spanish/Colombia + { 111, 52, 44, 46, 44, 37, 48, 45, 101 }, // Spanish/CostaRica + { 111, 61, 46, 44, 44, 37, 48, 45, 101 }, // Spanish/DominicanRepublic + { 111, 63, 44, 46, 44, 37, 48, 45, 101 }, // Spanish/Ecuador + { 111, 65, 46, 44, 44, 37, 48, 45, 101 }, // Spanish/ElSalvador + { 111, 90, 46, 44, 44, 37, 48, 45, 101 }, // Spanish/Guatemala + { 111, 96, 46, 44, 44, 37, 48, 45, 101 }, // Spanish/Honduras + { 111, 139, 46, 44, 44, 37, 48, 45, 101 }, // Spanish/Mexico + { 111, 155, 46, 44, 44, 37, 48, 45, 101 }, // Spanish/Nicaragua + { 111, 166, 46, 44, 44, 37, 48, 45, 101 }, // Spanish/Panama + { 111, 168, 44, 46, 44, 37, 48, 45, 101 }, // Spanish/Paraguay + { 111, 169, 46, 44, 44, 37, 48, 45, 101 }, // Spanish/Peru + { 111, 174, 46, 44, 44, 37, 48, 45, 101 }, // Spanish/PuertoRico + { 111, 227, 44, 46, 44, 37, 48, 45, 101 }, // Spanish/Uruguay + { 111, 231, 44, 46, 44, 37, 48, 45, 101 }, // Spanish/Venezuela + { 113, 111, 46, 44, 44, 37, 48, 45, 101 }, // Swahili/Kenya + { 114, 205, 44, 160, 59, 37, 48, 45, 101 }, // Swedish/Sweden + { 114, 73, 44, 160, 59, 37, 48, 45, 101 }, // Swedish/Finland + { 117, 100, 46, 44, 44, 37, 48, 45, 101 }, // Tamil/India + { 119, 100, 46, 44, 44, 37, 3174, 45, 101 }, // Telugu/India + { 120, 211, 46, 44, 44, 37, 3664, 45, 101 }, // Thai/Thailand + { 125, 217, 44, 46, 59, 37, 48, 45, 101 }, // Turkish/Turkey + { 129, 222, 44, 160, 59, 37, 48, 45, 101 }, // Ukrainian/Ukraine + { 130, 163, 46, 44, 59, 37, 1776, 45, 101 }, // Urdu/Pakistan + { 131, 228, 44, 160, 59, 37, 48, 45, 101 }, // Uzbek/Uzbekistan + { 132, 232, 44, 46, 44, 37, 48, 45, 101 }, // Vietnamese/VietNam + { 0, 0, 0, 0, 0, 0, 0, 0, 0 } // trailing 0s +}; + +static const char language_name_list[] = +"Default\0" +"C\0" +"Abkhazian\0" +"Afan\0" +"Afar\0" +"Afrikaans\0" +"Albanian\0" +"Amharic\0" +"Arabic\0" +"Armenian\0" +"Assamese\0" +"Aymara\0" +"Azerbaijani\0" +"Bashkir\0" +"Basque\0" +"Bengali\0" +"Bhutani\0" +"Bihari\0" +"Bislama\0" +"Breton\0" +"Bulgarian\0" +"Burmese\0" +"Byelorussian\0" +"Cambodian\0" +"Catalan\0" +"Chinese\0" +"Corsican\0" +"Croatian\0" +"Czech\0" +"Danish\0" +"Dutch\0" +"English\0" +"Esperanto\0" +"Estonian\0" +"Faroese\0" +"Fiji\0" +"Finnish\0" +"French\0" +"Frisian\0" +"Gaelic\0" +"Galician\0" +"Georgian\0" +"German\0" +"Greek\0" +"Greenlandic\0" +"Guarani\0" +"Gujarati\0" +"Hausa\0" +"Hebrew\0" +"Hindi\0" +"Hungarian\0" +"Icelandic\0" +"Indonesian\0" +"Interlingua\0" +"Interlingue\0" +"Inuktitut\0" +"Inupiak\0" +"Irish\0" +"Italian\0" +"Japanese\0" +"Javanese\0" +"Kannada\0" +"Kashmiri\0" +"Kazakh\0" +"Kinyarwanda\0" +"Kirghiz\0" +"Korean\0" +"Kurdish\0" +"Kurundi\0" +"Laothian\0" +"Latin\0" +"Latvian\0" +"Lingala\0" +"Lithuanian\0" +"Macedonian\0" +"Malagasy\0" +"Malay\0" +"Malayalam\0" +"Maltese\0" +"Maori\0" +"Marathi\0" +"Moldavian\0" +"Mongolian\0" +"Nauru\0" +"Nepali\0" +"Norwegian\0" +"Occitan\0" +"Oriya\0" +"Pashto\0" +"Persian\0" +"Polish\0" +"Portuguese\0" +"Punjabi\0" +"Quechua\0" +"RhaetoRomance\0" +"Romanian\0" +"Russian\0" +"Samoan\0" +"Sangho\0" +"Sanskrit\0" +"Serbian\0" +"SerboCroatian\0" +"Sesotho\0" +"Setswana\0" +"Shona\0" +"Sindhi\0" +"Singhalese\0" +"Siswati\0" +"Slovak\0" +"Slovenian\0" +"Somali\0" +"Spanish\0" +"Sundanese\0" +"Swahili\0" +"Swedish\0" +"Tagalog\0" +"Tajik\0" +"Tamil\0" +"Tatar\0" +"Telugu\0" +"Thai\0" +"Tibetan\0" +"Tigrinya\0" +"Tonga\0" +"Tsonga\0" +"Turkish\0" +"Turkmen\0" +"Twi\0" +"Uigur\0" +"Ukrainian\0" +"Urdu\0" +"Uzbek\0" +"Vietnamese\0" +"Volapuk\0" +"Welsh\0" +"Wolof\0" +"Xhosa\0" +"Yiddish\0" +"Yoruba\0" +"Zhuang\0" +"Zulu\0"; + +static const uint language_name_index[] = { + 0,// Unused + 8,// C + 10,// Abkhazian + 20,// Afan + 25,// Afar + 30,// Afrikaans + 40,// Albanian + 49,// Amharic + 57,// Arabic + 64,// Armenian + 73,// Assamese + 82,// Aymara + 89,// Azerbaijani + 101,// Bashkir + 109,// Basque + 116,// Bengali + 124,// Bhutani + 132,// Bihari + 139,// Bislama + 147,// Breton + 154,// Bulgarian + 164,// Burmese + 172,// Byelorussian + 185,// Cambodian + 195,// Catalan + 203,// Chinese + 211,// Corsican + 220,// Croatian + 229,// Czech + 235,// Danish + 242,// Dutch + 248,// English + 256,// Esperanto + 266,// Estonian + 275,// Faroese + 283,// Fiji + 288,// Finnish + 296,// French + 303,// Frisian + 311,// Gaelic + 318,// Galician + 327,// Georgian + 336,// German + 343,// Greek + 349,// Greenlandic + 361,// Guarani + 369,// Gujarati + 378,// Hausa + 384,// Hebrew + 391,// Hindi + 397,// Hungarian + 407,// Icelandic + 417,// Indonesian + 428,// Interlingua + 440,// Interlingue + 452,// Inuktitut + 462,// Inupiak + 470,// Irish + 476,// Italian + 484,// Japanese + 493,// Javanese + 502,// Kannada + 510,// Kashmiri + 519,// Kazakh + 526,// Kinyarwanda + 538,// Kirghiz + 546,// Korean + 553,// Kurdish + 561,// Kurundi + 569,// Laothian + 578,// Latin + 584,// Latvian + 592,// Lingala + 600,// Lithuanian + 611,// Macedonian + 622,// Malagasy + 631,// Malay + 637,// Malayalam + 647,// Maltese + 655,// Maori + 661,// Marathi + 669,// Moldavian + 679,// Mongolian + 689,// Nauru + 695,// Nepali + 702,// Norwegian + 712,// Occitan + 720,// Oriya + 726,// Pashto + 733,// Persian + 741,// Polish + 748,// Portuguese + 759,// Punjabi + 767,// Quechua + 775,// RhaetoRomance + 789,// Romanian + 798,// Russian + 806,// Samoan + 813,// Sangho + 820,// Sanskrit + 829,// Serbian + 837,// SerboCroatian + 851,// Sesotho + 859,// Setswana + 868,// Shona + 874,// Sindhi + 881,// Singhalese + 892,// Siswati + 900,// Slovak + 907,// Slovenian + 917,// Somali + 924,// Spanish + 932,// Sundanese + 942,// Swahili + 950,// Swedish + 958,// Tagalog + 966,// Tajik + 972,// Tamil + 978,// Tatar + 984,// Telugu + 991,// Thai + 996,// Tibetan + 1004,// Tigrinya + 1013,// Tonga + 1019,// Tsonga + 1026,// Turkish + 1034,// Turkmen + 1042,// Twi + 1046,// Uigur + 1052,// Ukrainian + 1062,// Urdu + 1067,// Uzbek + 1073,// Vietnamese + 1084,// Volapuk + 1092,// Welsh + 1098,// Wolof + 1104,// Xhosa + 1110,// Yiddish + 1118,// Yoruba + 1125,// Zhuang + 1132// Zulu +}; + +static const char country_name_list[] = +"Default\0" +"Afghanistan\0" +"Albania\0" +"Algeria\0" +"AmericanSamoa\0" +"Andorra\0" +"Angola\0" +"Anguilla\0" +"Antarctica\0" +"AntiguaAndBarbuda\0" +"Argentina\0" +"Armenia\0" +"Aruba\0" +"Australia\0" +"Austria\0" +"Azerbaijan\0" +"Bahamas\0" +"Bahrain\0" +"Bangladesh\0" +"Barbados\0" +"Belarus\0" +"Belgium\0" +"Belize\0" +"Benin\0" +"Bermuda\0" +"Bhutan\0" +"Bolivia\0" +"BosniaAndHerzegowina\0" +"Botswana\0" +"BouvetIsland\0" +"Brazil\0" +"BritishIndianOceanTerritory\0" +"BruneiDarussalam\0" +"Bulgaria\0" +"BurkinaFaso\0" +"Burundi\0" +"Cambodia\0" +"Cameroon\0" +"Canada\0" +"CapeVerde\0" +"CaymanIslands\0" +"CentralAfricanRepublic\0" +"Chad\0" +"Chile\0" +"China\0" +"ChristmasIsland\0" +"CocosIslands\0" +"Colombia\0" +"Comoros\0" +"DemocraticRepublicOfCongo\0" +"PeoplesRepublicOfCongo\0" +"CookIslands\0" +"CostaRica\0" +"IvoryCoast\0" +"Croatia\0" +"Cuba\0" +"Cyprus\0" +"CzechRepublic\0" +"Denmark\0" +"Djibouti\0" +"Dominica\0" +"DominicanRepublic\0" +"EastTimor\0" +"Ecuador\0" +"Egypt\0" +"ElSalvador\0" +"EquatorialGuinea\0" +"Eritrea\0" +"Estonia\0" +"Ethiopia\0" +"FalklandIslands\0" +"FaroeIslands\0" +"Fiji\0" +"Finland\0" +"France\0" +"MetropolitanFrance\0" +"FrenchGuiana\0" +"FrenchPolynesia\0" +"FrenchSouthernTerritories\0" +"Gabon\0" +"Gambia\0" +"Georgia\0" +"Germany\0" +"Ghana\0" +"Gibraltar\0" +"Greece\0" +"Greenland\0" +"Grenada\0" +"Guadeloupe\0" +"Guam\0" +"Guatemala\0" +"Guinea\0" +"GuineaBissau\0" +"Guyana\0" +"Haiti\0" +"HeardAndMcDonaldIslands\0" +"Honduras\0" +"HongKong\0" +"Hungary\0" +"Iceland\0" +"India\0" +"Indonesia\0" +"Iran\0" +"Iraq\0" +"Ireland\0" +"Israel\0" +"Italy\0" +"Jamaica\0" +"Japan\0" +"Jordan\0" +"Kazakhstan\0" +"Kenya\0" +"Kiribati\0" +"DemocraticRepublicOfKorea\0" +"RepublicOfKorea\0" +"Kuwait\0" +"Kyrgyzstan\0" +"Lao\0" +"Latvia\0" +"Lebanon\0" +"Lesotho\0" +"Liberia\0" +"LibyanArabJamahiriya\0" +"Liechtenstein\0" +"Lithuania\0" +"Luxembourg\0" +"Macau\0" +"Macedonia\0" +"Madagascar\0" +"Malawi\0" +"Malaysia\0" +"Maldives\0" +"Mali\0" +"Malta\0" +"MarshallIslands\0" +"Martinique\0" +"Mauritania\0" +"Mauritius\0" +"Mayotte\0" +"Mexico\0" +"Micronesia\0" +"Moldova\0" +"Monaco\0" +"Mongolia\0" +"Montserrat\0" +"Morocco\0" +"Mozambique\0" +"Myanmar\0" +"Namibia\0" +"Nauru\0" +"Nepal\0" +"Netherlands\0" +"NetherlandsAntilles\0" +"NewCaledonia\0" +"NewZealand\0" +"Nicaragua\0" +"Niger\0" +"Nigeria\0" +"Niue\0" +"NorfolkIsland\0" +"NorthernMarianaIslands\0" +"Norway\0" +"Oman\0" +"Pakistan\0" +"Palau\0" +"PalestinianTerritory\0" +"Panama\0" +"PapuaNewGuinea\0" +"Paraguay\0" +"Peru\0" +"Philippines\0" +"Pitcairn\0" +"Poland\0" +"Portugal\0" +"PuertoRico\0" +"Qatar\0" +"Reunion\0" +"Romania\0" +"RussianFederation\0" +"Rwanda\0" +"SaintKittsAndNevis\0" +"StLucia\0" +"StVincentAndTheGrenadines\0" +"Samoa\0" +"SanMarino\0" +"SaoTomeAndPrincipe\0" +"SaudiArabia\0" +"Senegal\0" +"Seychelles\0" +"SierraLeone\0" +"Singapore\0" +"Slovakia\0" +"Slovenia\0" +"SolomonIslands\0" +"Somalia\0" +"SouthAfrica\0" +"SouthGeorgiaAndTheSouthSandwichIslands\0" +"Spain\0" +"SriLanka\0" +"StHelena\0" +"StPierreAndMiquelon\0" +"Sudan\0" +"Suriname\0" +"SvalbardAndJanMayenIslands\0" +"Swaziland\0" +"Sweden\0" +"Switzerland\0" +"SyrianArabRepublic\0" +"Taiwan\0" +"Tajikistan\0" +"Tanzania\0" +"Thailand\0" +"Togo\0" +"Tokelau\0" +"Tonga\0" +"TrinidadAndTobago\0" +"Tunisia\0" +"Turkey\0" +"Turkmenistan\0" +"TurksAndCaicosIslands\0" +"Tuvalu\0" +"Uganda\0" +"Ukraine\0" +"UnitedArabEmirates\0" +"UnitedKingdom\0" +"UnitedStates\0" +"UnitedStatesMinorOutlyingIslands\0" +"Uruguay\0" +"Uzbekistan\0" +"Vanuatu\0" +"VaticanCityState\0" +"Venezuela\0" +"VietNam\0" +"BritishVirginIslands\0" +"USVirginIslands\0" +"WallisAndFutunaIslands\0" +"WesternSahara\0" +"Yemen\0" +"Yugoslavia\0" +"Zambia\0" +"Zimbabwe\0"; + +static const uint country_name_index[] = { + 0,// AnyCountry + 8,// Afghanistan + 20,// Albania + 28,// Algeria + 36,// AmericanSamoa + 50,// Andorra + 58,// Angola + 65,// Anguilla + 74,// Antarctica + 85,// AntiguaAndBarbuda + 103,// Argentina + 113,// Armenia + 121,// Aruba + 127,// Australia + 137,// Austria + 145,// Azerbaijan + 156,// Bahamas + 164,// Bahrain + 172,// Bangladesh + 183,// Barbados + 192,// Belarus + 200,// Belgium + 208,// Belize + 215,// Benin + 221,// Bermuda + 229,// Bhutan + 236,// Bolivia + 244,// BosniaAndHerzegowina + 265,// Botswana + 274,// BouvetIsland + 287,// Brazil + 294,// BritishIndianOceanTerritory + 322,// BruneiDarussalam + 339,// Bulgaria + 348,// BurkinaFaso + 360,// Burundi + 368,// Cambodia + 377,// Cameroon + 386,// Canada + 393,// CapeVerde + 403,// CaymanIslands + 417,// CentralAfricanRepublic + 440,// Chad + 445,// Chile + 451,// China + 457,// ChristmasIsland + 473,// CocosIslands + 486,// Colombia + 495,// Comoros + 503,// DemocraticRepublicOfCongo + 529,// PeoplesRepublicOfCongo + 552,// CookIslands + 564,// CostaRica + 574,// IvoryCoast + 585,// Croatia + 593,// Cuba + 598,// Cyprus + 605,// CzechRepublic + 619,// Denmark + 627,// Djibouti + 636,// Dominica + 645,// DominicanRepublic + 663,// EastTimor + 673,// Ecuador + 681,// Egypt + 687,// ElSalvador + 698,// EquatorialGuinea + 715,// Eritrea + 723,// Estonia + 731,// Ethiopia + 740,// FalklandIslands + 756,// FaroeIslands + 769,// Fiji + 774,// Finland + 782,// France + 789,// MetropolitanFrance + 808,// FrenchGuiana + 821,// FrenchPolynesia + 837,// FrenchSouthernTerritories + 863,// Gabon + 869,// Gambia + 876,// Georgia + 884,// Germany + 892,// Ghana + 898,// Gibraltar + 908,// Greece + 915,// Greenland + 925,// Grenada + 933,// Guadeloupe + 944,// Guam + 949,// Guatemala + 959,// Guinea + 966,// GuineaBissau + 979,// Guyana + 986,// Haiti + 992,// HeardAndMcDonaldIslands + 1016,// Honduras + 1025,// HongKong + 1034,// Hungary + 1042,// Iceland + 1050,// India + 1056,// Indonesia + 1066,// Iran + 1071,// Iraq + 1076,// Ireland + 1084,// Israel + 1091,// Italy + 1097,// Jamaica + 1105,// Japan + 1111,// Jordan + 1118,// Kazakhstan + 1129,// Kenya + 1135,// Kiribati + 1144,// DemocraticRepublicOfKorea + 1170,// RepublicOfKorea + 1186,// Kuwait + 1193,// Kyrgyzstan + 1204,// Lao + 1208,// Latvia + 1215,// Lebanon + 1223,// Lesotho + 1231,// Liberia + 1239,// LibyanArabJamahiriya + 1260,// Liechtenstein + 1274,// Lithuania + 1284,// Luxembourg + 1295,// Macau + 1301,// Macedonia + 1311,// Madagascar + 1322,// Malawi + 1329,// Malaysia + 1338,// Maldives + 1347,// Mali + 1352,// Malta + 1358,// MarshallIslands + 1374,// Martinique + 1385,// Mauritania + 1396,// Mauritius + 1406,// Mayotte + 1414,// Mexico + 1421,// Micronesia + 1432,// Moldova + 1440,// Monaco + 1447,// Mongolia + 1456,// Montserrat + 1467,// Morocco + 1475,// Mozambique + 1486,// Myanmar + 1494,// Namibia + 1502,// Nauru + 1508,// Nepal + 1514,// Netherlands + 1526,// NetherlandsAntilles + 1546,// NewCaledonia + 1559,// NewZealand + 1570,// Nicaragua + 1580,// Niger + 1586,// Nigeria + 1594,// Niue + 1599,// NorfolkIsland + 1613,// NorthernMarianaIslands + 1636,// Norway + 1643,// Oman + 1648,// Pakistan + 1657,// Palau + 1663,// PalestinianTerritory + 1684,// Panama + 1691,// PapuaNewGuinea + 1706,// Paraguay + 1715,// Peru + 1720,// Philippines + 1732,// Pitcairn + 1741,// Poland + 1748,// Portugal + 1757,// PuertoRico + 1768,// Qatar + 1774,// Reunion + 1782,// Romania + 1790,// RussianFederation + 1808,// Rwanda + 1815,// SaintKittsAndNevis + 1834,// StLucia + 1842,// StVincentAndTheGrenadines + 1868,// Samoa + 1874,// SanMarino + 1884,// SaoTomeAndPrincipe + 1903,// SaudiArabia + 1915,// Senegal + 1923,// Seychelles + 1934,// SierraLeone + 1946,// Singapore + 1956,// Slovakia + 1965,// Slovenia + 1974,// SolomonIslands + 1989,// Somalia + 1997,// SouthAfrica + 2009,// SouthGeorgiaAndTheSouthSandwichIslands + 2048,// Spain + 2054,// SriLanka + 2063,// StHelena + 2072,// StPierreAndMiquelon + 2092,// Sudan + 2098,// Suriname + 2107,// SvalbardAndJanMayenIslands + 2134,// Swaziland + 2144,// Sweden + 2151,// Switzerland + 2163,// SyrianArabRepublic + 2182,// Taiwan + 2189,// Tajikistan + 2200,// Tanzania + 2209,// Thailand + 2218,// Togo + 2223,// Tokelau + 2231,// Tonga + 2237,// TrinidadAndTobago + 2255,// Tunisia + 2263,// Turkey + 2270,// Turkmenistan + 2283,// TurksAndCaicosIslands + 2305,// Tuvalu + 2312,// Uganda + 2319,// Ukraine + 2327,// UnitedArabEmirates + 2346,// UnitedKingdom + 2360,// UnitedStates + 2373,// UnitedStatesMinorOutlyingIslands + 2406,// Uruguay + 2414,// Uzbekistan + 2425,// Vanuatu + 2433,// VaticanCityState + 2450,// Venezuela + 2460,// VietNam + 2468,// BritishVirginIslands + 2489,// USVirginIslands + 2505,// WallisAndFutunaIslands + 2528,// WesternSahara + 2542,// Yemen + 2548,// Yugoslavia + 2559,// Zambia + 2566// Zimbabwe +}; + +static const char language_code_list[] = +" " // Unused +" " // C +"ab" // Abkhazian +"om" // Afan +"aa" // Afar +"af" // Afrikaans +"sq" // Albanian +"am" // Amharic +"ar" // Arabic +"hy" // Armenian +"as" // Assamese +"ay" // Aymara +"az" // Azerbaijani +"ba" // Bashkir +"eu" // Basque +"bn" // Bengali +"dz" // Bhutani +"bh" // Bihari +"bi" // Bislama +"br" // Breton +"bg" // Bulgarian +"my" // Burmese +"be" // Byelorussian +"km" // Cambodian +"ca" // Catalan +"zh" // Chinese +"co" // Corsican +"hr" // Croatian +"cs" // Czech +"da" // Danish +"nl" // Dutch +"en" // English +"eo" // Esperanto +"et" // Estonian +"fo" // Faroese +"fj" // Fiji +"fi" // Finnish +"fr" // French +"fy" // Frisian +"gd" // Gaelic +"gl" // Galician +"ka" // Georgian +"de" // German +"el" // Greek +"kl" // Greenlandic +"gn" // Guarani +"gu" // Gujarati +"ha" // Hausa +"he" // Hebrew +"hi" // Hindi +"hu" // Hungarian +"is" // Icelandic +"id" // Indonesian +"ia" // Interlingua +"ie" // Interlingue +"iu" // Inuktitut +"ik" // Inupiak +"ga" // Irish +"it" // Italian +"ja" // Japanese +"jv" // Javanese +"kn" // Kannada +"ks" // Kashmiri +"kk" // Kazakh +"rw" // Kinyarwanda +"ky" // Kirghiz +"ko" // Korean +"ku" // Kurdish +"rn" // Kurundi +"lo" // Laothian +"la" // Latin +"lv" // Latvian +"ln" // Lingala +"lt" // Lithuanian +"mk" // Macedonian +"mg" // Malagasy +"ms" // Malay +"ml" // Malayalam +"mt" // Maltese +"mi" // Maori +"mr" // Marathi +"mo" // Moldavian +"mn" // Mongolian +"na" // Nauru +"ne" // Nepali +"no" // Norwegian +"oc" // Occitan +"or" // Oriya +"ps" // Pashto +"fa" // Persian +"pl" // Polish +"pt" // Portuguese +"pa" // Punjabi +"qu" // Quechua +"rm" // RhaetoRomance +"ro" // Romanian +"ru" // Russian +"sm" // Samoan +"sg" // Sangho +"sa" // Sanskrit +"sr" // Serbian +"sh" // SerboCroatian +"st" // Sesotho +"tn" // Setswana +"sn" // Shona +"sd" // Sindhi +"si" // Singhalese +"ss" // Siswati +"sk" // Slovak +"sl" // Slovenian +"so" // Somali +"es" // Spanish +"su" // Sundanese +"sw" // Swahili +"sv" // Swedish +"tl" // Tagalog +"tg" // Tajik +"ta" // Tamil +"tt" // Tatar +"te" // Telugu +"th" // Thai +"bo" // Tibetan +"ti" // Tigrinya +"to" // Tonga +"ts" // Tsonga +"tr" // Turkish +"tk" // Turkmen +"tw" // Twi +"ug" // Uigur +"uk" // Ukrainian +"ur" // Urdu +"uz" // Uzbek +"vi" // Vietnamese +"vo" // Volapuk +"cy" // Welsh +"wo" // Wolof +"xh" // Xhosa +"yi" // Yiddish +"yo" // Yoruba +"za" // Zhuang +"zu" // Zulu +; + +static const char country_code_list[] = +" " // AnyLanguage +"AF" // Afghanistan +"AL" // Albania +"DZ" // Algeria +"AS" // AmericanSamoa +"AD" // Andorra +"AO" // Angola +"AI" // Anguilla +"AQ" // Antarctica +"AG" // AntiguaAndBarbuda +"AR" // Argentina +"AM" // Armenia +"AW" // Aruba +"AU" // Australia +"AT" // Austria +"AZ" // Azerbaijan +"BS" // Bahamas +"BH" // Bahrain +"BD" // Bangladesh +"BB" // Barbados +"BY" // Belarus +"BE" // Belgium +"BZ" // Belize +"BJ" // Benin +"BM" // Bermuda +"BT" // Bhutan +"BO" // Bolivia +"BA" // BosniaAndHerzegowina +"BW" // Botswana +"BV" // BouvetIsland +"BR" // Brazil +"IO" // BritishIndianOceanTerritory +"BN" // BruneiDarussalam +"BG" // Bulgaria +"BF" // BurkinaFaso +"BI" // Burundi +"KH" // Cambodia +"CM" // Cameroon +"CA" // Canada +"CV" // CapeVerde +"KY" // CaymanIslands +"CF" // CentralAfricanRepublic +"TD" // Chad +"CL" // Chile +"CN" // China +"CX" // ChristmasIsland +"CC" // CocosIslands +"CO" // Colombia +"KM" // Comoros +"CD" // DemocraticRepublicOfCongo +"CG" // PeoplesRepublicOfCongo +"CK" // CookIslands +"CR" // CostaRica +"CI" // IvoryCoast +"HR" // Croatia +"CU" // Cuba +"CY" // Cyprus +"CZ" // CzechRepublic +"DK" // Denmark +"DJ" // Djibouti +"DM" // Dominica +"DO" // DominicanRepublic +"TL" // EastTimor +"EC" // Ecuador +"EG" // Egypt +"SV" // ElSalvador +"GQ" // EquatorialGuinea +"ER" // Eritrea +"EE" // Estonia +"ET" // Ethiopia +"FK" // FalklandIslands +"FO" // FaroeIslands +"FJ" // Fiji +"FI" // Finland +"FR" // France +"FX" // MetropolitanFrance +"GF" // FrenchGuiana +"PF" // FrenchPolynesia +"TF" // FrenchSouthernTerritories +"GA" // Gabon +"GM" // Gambia +"GE" // Georgia +"DE" // Germany +"GH" // Ghana +"GI" // Gibraltar +"GR" // Greece +"GL" // Greenland +"GD" // Grenada +"GP" // Guadeloupe +"GU" // Guam +"GT" // Guatemala +"GN" // Guinea +"GW" // GuineaBissau +"GY" // Guyana +"HT" // Haiti +"HM" // HeardAndMcDonaldIslands +"HN" // Honduras +"HK" // HongKong +"HU" // Hungary +"IS" // Iceland +"IN" // India +"ID" // Indonesia +"IR" // Iran +"IQ" // Iraq +"IE" // Ireland +"IL" // Israel +"IT" // Italy +"JM" // Jamaica +"JP" // Japan +"JO" // Jordan +"KZ" // Kazakhstan +"KE" // Kenya +"KI" // Kiribati +"KP" // DemocraticRepublicOfKorea +"KR" // RepublicOfKorea +"KW" // Kuwait +"KG" // Kyrgyzstan +"LA" // Lao +"LV" // Latvia +"LB" // Lebanon +"LS" // Lesotho +"LR" // Liberia +"LY" // LibyanArabJamahiriya +"LI" // Liechtenstein +"LT" // Lithuania +"LU" // Luxembourg +"MO" // Macau +"MK" // Macedonia +"MG" // Madagascar +"MW" // Malawi +"MY" // Malaysia +"MV" // Maldives +"ML" // Mali +"MT" // Malta +"MH" // MarshallIslands +"MQ" // Martinique +"MR" // Mauritania +"MU" // Mauritius +"YT" // Mayotte +"MX" // Mexico +"FM" // Micronesia +"MD" // Moldova +"MC" // Monaco +"MN" // Mongolia +"MS" // Montserrat +"MA" // Morocco +"MZ" // Mozambique +"MM" // Myanmar +"NA" // Namibia +"NR" // Nauru +"NP" // Nepal +"NL" // Netherlands +"AN" // NetherlandsAntilles +"NC" // NewCaledonia +"NZ" // NewZealand +"NI" // Nicaragua +"NE" // Niger +"NG" // Nigeria +"NU" // Niue +"NF" // NorfolkIsland +"MP" // NorthernMarianaIslands +"NO" // Norway +"OM" // Oman +"PK" // Pakistan +"PW" // Palau +"PS" // PalestinianTerritory +"PA" // Panama +"PG" // PapuaNewGuinea +"PY" // Paraguay +"PE" // Peru +"PH" // Philippines +"PN" // Pitcairn +"PL" // Poland +"PT" // Portugal +"PR" // PuertoRico +"QA" // Qatar +"RE" // Reunion +"RO" // Romania +"RU" // RussianFederation +"RW" // Rwanda +"KN" // SaintKittsAndNevis +"LC" // StLucia +"VC" // StVincentAndTheGrenadines +"WS" // Samoa +"SM" // SanMarino +"ST" // SaoTomeAndPrincipe +"SA" // SaudiArabia +"SN" // Senegal +"SC" // Seychelles +"SL" // SierraLeone +"SG" // Singapore +"SK" // Slovakia +"SI" // Slovenia +"SB" // SolomonIslands +"SO" // Somalia +"ZA" // SouthAfrica +"GS" // SouthGeorgiaAndTheSouthSandwichIslands +"ES" // Spain +"LK" // SriLanka +"SH" // StHelena +"PM" // StPierreAndMiquelon +"SD" // Sudan +"SR" // Suriname +"SJ" // SvalbardAndJanMayenIslands +"SZ" // Swaziland +"SE" // Sweden +"CH" // Switzerland +"SY" // SyrianArabRepublic +"TW" // Taiwan +"TJ" // Tajikistan +"TZ" // Tanzania +"TH" // Thailand +"TG" // Togo +"TK" // Tokelau +"TO" // Tonga +"TT" // TrinidadAndTobago +"TN" // Tunisia +"TR" // Turkey +"TM" // Turkmenistan +"TC" // TurksAndCaicosIslands +"TV" // Tuvalu +"UG" // Uganda +"UA" // Ukraine +"AE" // UnitedArabEmirates +"GB" // UnitedKingdom +"US" // UnitedStates +"UM" // UnitedStatesMinorOutlyingIslands +"UY" // Uruguay +"UZ" // Uzbekistan +"VU" // Vanuatu +"VA" // VaticanCityState +"VE" // Venezuela +"VN" // VietNam +"VG" // BritishVirginIslands +"VI" // USVirginIslands +"WF" // WallisAndFutunaIslands +"EH" // WesternSahara +"YE" // Yemen +"YU" // Yugoslavia +"ZM" // Zambia +"ZW" // Zimbabwe +; + +static TQLocale::Language codeToLanguage(const TQString &code) +{ + if (code.length() != 2) + return TQLocale::C; + + ushort uc1 = code.unicode()[0].unicode(); + ushort uc2 = code.unicode()[1].unicode(); + + const char *c = language_code_list; + for (; *c != 0; c += 2) { + if (uc1 == (unsigned char)c[0] && uc2 == (unsigned char)c[1]) + return (TQLocale::Language) ((c - language_code_list)/2); + } + + return TQLocale::C; +} + +static TQLocale::Country codeToCountry(const TQString &code) +{ + if (code.length() != 2) + return TQLocale::AnyCountry; + + ushort uc1 = code.unicode()[0].unicode(); + ushort uc2 = code.unicode()[1].unicode(); + + const char *c = country_code_list; + for (; *c != 0; c += 2) { + if (uc1 == (unsigned char)c[0] && uc2 == (unsigned char)c[1]) + return (TQLocale::Country) ((c - country_code_list)/2); + } + + return TQLocale::AnyCountry; +} + +static TQString languageToCode(TQLocale::Language language) +{ + if (language == TQLocale::C) + return "C"; + + TQString code; + code.setLength(2); + const char *c = language_code_list + 2*(uint)language; + code[0] = c[0]; + code[1] = c[1]; + return code; +} + +static TQString countryToCode(TQLocale::Country country) +{ + if (country == TQLocale::AnyCountry) + return TQString::null; + + TQString code; + code.setLength(2); + const char *c = country_code_list + 2*(uint)country; + code[0] = c[0]; + code[1] = c[1]; + return code; +} + +const TQLocalePrivate *TQLocale::default_d = 0; + +TQString TQLocalePrivate::infinity() const +{ + return TQString::fromLatin1("inf"); +} + +TQString TQLocalePrivate::nan() const +{ + return TQString::fromLatin1("nan"); +} + +#if defined(Q_OS_WIN) +/* Win95 doesn't have a function to return the ISO lang/country name of the user's locale. + Instead it can return a "Windows code". This maps windows codes to ISO country names. */ + +struct WindowsToISOListElt { + int windows_code; + char iso_name[6]; +}; + +static const WindowsToISOListElt windows_to_iso_list[] = { + { 0x0401, "ar_SA" }, + { 0x0402, "bg\0 " }, + { 0x0403, "ca\0 " }, + { 0x0404, "zh_TW" }, + { 0x0405, "cs\0 " }, + { 0x0406, "da\0 " }, + { 0x0407, "de\0 " }, + { 0x0408, "el\0 " }, + { 0x0409, "en_US" }, + { 0x040a, "es\0 " }, + { 0x040b, "fi\0 " }, + { 0x040c, "fr\0 " }, + { 0x040d, "he\0 " }, + { 0x040e, "hu\0 " }, + { 0x040f, "is\0 " }, + { 0x0410, "it\0 " }, + { 0x0411, "ja\0 " }, + { 0x0412, "ko\0 " }, + { 0x0413, "nl\0 " }, + { 0x0414, "no\0 " }, + { 0x0415, "pl\0 " }, + { 0x0416, "pt_BR" }, + { 0x0418, "ro\0 " }, + { 0x0419, "ru\0 " }, + { 0x041a, "hr\0 " }, + { 0x041c, "sq\0 " }, + { 0x041d, "sv\0 " }, + { 0x041e, "th\0 " }, + { 0x041f, "tr\0 " }, + { 0x0420, "ur\0 " }, + { 0x0421, "in\0 " }, + { 0x0422, "uk\0 " }, + { 0x0423, "be\0 " }, + { 0x0425, "et\0 " }, + { 0x0426, "lv\0 " }, + { 0x0427, "lt\0 " }, + { 0x0429, "fa\0 " }, + { 0x042a, "vi\0 " }, + { 0x042d, "eu\0 " }, + { 0x042f, "mk\0 " }, + { 0x0436, "af\0 " }, + { 0x0438, "fo\0 " }, + { 0x0439, "hi\0 " }, + { 0x043e, "ms\0 " }, + { 0x0458, "mt\0 " }, + { 0x0801, "ar_IQ" }, + { 0x0804, "zh_CN" }, + { 0x0807, "de_CH" }, + { 0x0809, "en_GB" }, + { 0x080a, "es_MX" }, + { 0x080c, "fr_BE" }, + { 0x0810, "it_CH" }, + { 0x0812, "ko\0 " }, + { 0x0813, "nl_BE" }, + { 0x0814, "no\0 " }, + { 0x0816, "pt\0 " }, + { 0x081a, "sr\0 " }, + { 0x081d, "sv_FI" }, + { 0x0c01, "ar_EG" }, + { 0x0c04, "zh_HK" }, + { 0x0c07, "de_AT" }, + { 0x0c09, "en_AU" }, + { 0x0c0a, "es\0 " }, + { 0x0c0c, "fr_CA" }, + { 0x0c1a, "sr\0 " }, + { 0x1001, "ar_LY" }, + { 0x1004, "zh_SG" }, + { 0x1007, "de_LU" }, + { 0x1009, "en_CA" }, + { 0x100a, "es_GT" }, + { 0x100c, "fr_CH" }, + { 0x1401, "ar_DZ" }, + { 0x1407, "de_LI" }, + { 0x1409, "en_NZ" }, + { 0x140a, "es_CR" }, + { 0x140c, "fr_LU" }, + { 0x1801, "ar_MA" }, + { 0x1809, "en_IE" }, + { 0x180a, "es_PA" }, + { 0x1c01, "ar_TN" }, + { 0x1c09, "en_ZA" }, + { 0x1c0a, "es_DO" }, + { 0x2001, "ar_OM" }, + { 0x2009, "en_JM" }, + { 0x200a, "es_VE" }, + { 0x2401, "ar_YE" }, + { 0x2409, "en\0 " }, + { 0x240a, "es_CO" }, + { 0x2801, "ar_SY" }, + { 0x2809, "en_BZ" }, + { 0x280a, "es_PE" }, + { 0x2c01, "ar_JO" }, + { 0x2c09, "en_TT" }, + { 0x2c0a, "es_AR" }, + { 0x3001, "ar_LB" }, + { 0x300a, "es_EC" }, + { 0x3401, "ar_KW" }, + { 0x340a, "es_CL" }, + { 0x3801, "ar_AE" }, + { 0x380a, "es_UY" }, + { 0x3c01, "ar_BH" }, + { 0x3c0a, "es_PY" }, + { 0x4001, "ar_QA" }, + { 0x400a, "es_BO" }, + { 0x440a, "es_SV" }, + { 0x480a, "es_HN" }, + { 0x4c0a, "es_NI" }, + { 0x500a, "es_PR" } +}; + +static const int windows_to_iso_count + = sizeof(windows_to_iso_list)/sizeof(WindowsToISOListElt); + +static const char *winLangCodeToIsoName(int code) +{ + int cmp = code - windows_to_iso_list[0].windows_code; + if (cmp < 0) + return 0; + + if (cmp == 0) + return windows_to_iso_list[0].iso_name; + + int begin = 0; + int end = windows_to_iso_count; + + while (end - begin > 1) { + uint mid = (begin + end)/2; + + const WindowsToISOListElt *elt = windows_to_iso_list + mid; + int cmp = code - elt->windows_code; + if (cmp < 0) + end = mid; + else if (cmp > 0) + begin = mid; + else + return elt->iso_name; + } + + return 0; + +} +#endif // Q_OS_WIN + +const char* TQLocalePrivate::systemLocaleName() +{ + static TQCString lang; + lang = getenv( "LANG" ); + +#if !defined( TQWS ) && defined( Q_OS_MAC ) + if ( !lang.isEmpty() ) + return lang; + + char mac_ret[255]; + if(!LocaleRefGetPartString(NULL, kLocaleLanguageMask | kLocaleRegionMask, 255, mac_ret)) + lang = mac_ret; +#endif + +#if defined(Q_WS_WIN) + if ( !lang.isEmpty() ) { + long id = 0; + bool ok = false; + id = qstrtoll(lang.data(), 0, 0, &ok); + if ( !ok || id == 0 || id < INT_MIN || id > INT_MAX ) + return lang; + else + return winLangCodeToIsoName( (int)id ); + } + + if (qWinVersion() == TQt::WV_95) { + lang = winLangCodeToIsoName(GetUserDefaultLangID()); + } else { + QT_WA( { + wchar_t out[256]; + TQString language; + TQString sublanguage; + if ( GetLocaleInfoW( LOCALE_USER_DEFAULT, LOCALE_SISO639LANGNAME , out, 255 ) ) + language = TQString::fromUcs2( (ushort*)out ); + if ( GetLocaleInfoW( LOCALE_USER_DEFAULT, LOCALE_SISO3166CTRYNAME, out, 255 ) ) + sublanguage = TQString::fromUcs2( (ushort*)out ).lower(); + lang = language; + if ( sublanguage != language && !sublanguage.isEmpty() ) + lang += "_" + sublanguage.upper(); + } , { + char out[256]; + TQString language; + TQString sublanguage; + if ( GetLocaleInfoA( LOCALE_USER_DEFAULT, LOCALE_SISO639LANGNAME, out, 255 ) ) + language = TQString::fromLocal8Bit( out ); + if ( GetLocaleInfoA( LOCALE_USER_DEFAULT, LOCALE_SISO3166CTRYNAME, out, 255 ) ) + sublanguage = TQString::fromLocal8Bit( out ).lower(); + lang = language; + if ( sublanguage != language && !sublanguage.isEmpty() ) + lang += "_" + sublanguage.upper(); + } ); + } +#endif + if ( lang.isEmpty() ) + lang = "C"; + + return lang; +} + +static const TQLocalePrivate *findLocale(TQLocale::Language language, + TQLocale::Country country) +{ + unsigned language_id = (unsigned)language; + unsigned country_id = (unsigned)country; + + uint idx = locale_index[language_id]; + + const TQLocalePrivate *d = locale_data + idx; + + if (idx == 0) // default language has no associated country + return d; + + if (country == TQLocale::AnyCountry) + return d; + + Q_ASSERT(d->languageId() == language_id); + + while (d->languageId() == language_id + && d->countryId() != country_id) + ++d; + + if (d->countryId() == country_id + && d->languageId() == language_id) + return d; + + return locale_data + idx; +} + +/*! + \class TQLocale + \brief The TQLocale class converts between numbers and their + string representations in various languages. + + \reentrant + \ingroup text + + It is initialized with a country/language pair in its constructor + and offers number-to-string and string-to-number conversion + functions simmilar to those in TQString. + + \code + TQLocale egyptian(TQLocale::Arabic, TQLocale::Egypt); + TQString s1 = egyptian.toString(1.571429E+07, 'e'); + TQString s2 = egyptian.toString(10); + + double d = egyptian.toDouble(s1); + int s2 = egyptian.toInt(s2); + \endcode + + TQLocale supports the concept of a default locale, which is + determined from the system's locale settings at application + startup. The default locale can be changed by calling the + static member setDefault(). The default locale has the + following effects: + + \list + \i If a TQLocale object is constructed with the default constructor, + it will use the default locale's settings. + \i TQString::toDouble() interprets the string according to the default + locale. If this fails, it falls back on the "C" locale. + \i TQString::arg() uses the default locale to format a number when + its position specifier in the format string contains an 'L', + e.g. "%L1". + \endlist + + \code + TQLocale::setDefault(TQLocale(TQLocale::Hebrew, TQLocale::Israel)); + TQLocale hebrew; // Constructs a default TQLocale + TQString s1 = hebrew.toString(15714.3, 'e'); + + bool ok; + double d; + + TQLocale::setDefault(TQLocale::C); + d = TQString( "1234,56" ).toDouble(&ok); // ok == false + d = TQString( "1234.56" ).toDouble(&ok); // ok == true, d == 1234.56 + + TQLocale::setDefault(TQLocale::German); + d = TQString( "1234,56" ).toDouble(&ok); // ok == true, d == 1234.56 + d = TQString( "1234.56" ).toDouble(&ok); // ok == true, d == 1234.56 + + TQLocale::setDefault(TQLocale(TQLocale::English, TQLocale::UnitedStates)); + str = TQString( "%1 %L2 %L3" ) + .arg( 12345 ) + .arg( 12345 ) + .arg( 12345, 0, 16 ); + // str == "12345 12,345 3039" + \endcode + + When a language/country pair is specified in the constructor, one + of three things can happen: + + \list + \i If the language/country pair is found in the database, it is used. + \i If the language is found but the country is not, or if the country + is \c AnyCountry, the language is used with the most + appropriate available country (for example, Germany for German), + \i If neither the language nor the country are found, TQLocale + defaults to the default locale (see setDefault()). + \endlist + + The "C" locale is identical to English/UnitedStates. + + Use language() and country() to determine the actual language and + country values used. + + An alternative method for constructing a TQLocale object is by + specifying the locale name. + + \code + TQLocale korean("ko"); + TQLocale swiss("de_CH"); + \endcode + + This constructor converts the locale name to a language/country + pair; it does not use the system locale database. + + All the methods in TQLocale, with the exception of setDefault(), + are reentrant. + + \sa TQString::toDouble() TQString::arg() + + The double-to-string and string-to-double conversion functions are + covered by the following licenses: + + \legalese + + Copyright (c) 1991 by AT&T. + + Permission to use, copy, modify, and distribute this software for any + purpose without fee is hereby granted, provided that this entire notice + is included in all copies of any software which is or includes a copy + or modification of this software and in all copies of the supporting + documentation for such software. + + THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED + WARRANTY. IN PARTICULAR, NEITHER THE AUTHOR NOR AT&T MAKES ANY + REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY + OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. + + This product includes software developed by the University of + California, Berkeley and its contributors. +*/ + +/*! + \enum TQLocale::Language + + This enumerated type is used to specify a language. + + \value C Identical to English/UnitedStates + \value Abkhazian + \value Afan + \value Afar + \value Afrikaans + \value Albanian + \value Amharic + \value Arabic + \value Armenian + \value Assamese + \value Aymara + \value Azerbaijani + \value Bashkir + \value Basque + \value Bengali + \value Bhutani + \value Bihari + \value Bislama + \value Breton + \value Bulgarian + \value Burmese + \value Byelorussian + \value Cambodian + \value Catalan + \value Chinese + \value Corsican + \value Croatian + \value Czech + \value Danish + \value Dutch + \value English + \value Esperanto + \value Estonian + \value Faroese + \value FijiLanguage + \value Finnish + \value French + \value Frisian + \value Gaelic + \value Galician + \value Georgian + \value German + \value Greek + \value Greenlandic + \value Guarani + \value Gujarati + \value Hausa + \value Hebrew + \value Hindi + \value Hungarian + \value Icelandic + \value Indonesian + \value Interlingua + \value Interlingue + \value Inuktitut + \value Inupiak + \value Irish + \value Italian + \value Japanese + \value Javanese + \value Kannada + \value Kashmiri + \value Kazakh + \value Kinyarwanda + \value Kirghiz + \value Korean + \value Kurdish + \value Kurundi + \value Laothian + \value Latin + \value Latvian + \value Lingala + \value Lithuanian + \value Macedonian + \value Malagasy + \value Malay + \value Malayalam + \value Maltese + \value Maori + \value Marathi + \value Moldavian + \value Mongolian + \value NauruLanguage + \value Nepali + \value Norwegian + \value Occitan + \value Oriya + \value Pashto + \value Persian + \value Polish + \value Portuguese + \value Punjabi + \value Quechua + \value RhaetoRomance + \value Romanian + \value Russian + \value Samoan + \value Sangho + \value Sanskrit + \value Serbian + \value SerboCroatian + \value Sesotho + \value Setswana + \value Shona + \value Sindhi + \value Singhalese + \value Siswati + \value Slovak + \value Slovenian + \value Somali + \value Spanish + \value Sundanese + \value Swahili + \value Swedish + \value Tagalog + \value Tajik + \value Tamil + \value Tatar + \value Telugu + \value Thai + \value Tibetan + \value Tigrinya + \value TongaLanguage + \value Tsonga + \value Turkish + \value Turkmen + \value Twi + \value Uigur + \value Ukrainian + \value Urdu + \value Uzbek + \value Vietnamese + \value Volapuk + \value Welsh + \value Wolof + \value Xhosa + \value Yiddish + \value Yoruba + \value Zhuang + \value Zulu +*/ + +/*! + \enum TQLocale::Country + + This enumerated type is used to specify a country. + + \value AnyCountry + \value Afghanistan + \value Albania + \value Algeria + \value AmericanSamoa + \value Andorra + \value Angola + \value Anguilla + \value Antarctica + \value AntiguaAndBarbuda + \value Argentina + \value Armenia + \value Aruba + \value Australia + \value Austria + \value Azerbaijan + \value Bahamas + \value Bahrain + \value Bangladesh + \value Barbados + \value Belarus + \value Belgium + \value Belize + \value Benin + \value Bermuda + \value Bhutan + \value Bolivia + \value BosniaAndHerzegowina + \value Botswana + \value BouvetIsland + \value Brazil + \value BritishIndianOceanTerritory + \value BruneiDarussalam + \value Bulgaria + \value BurkinaFaso + \value Burundi + \value Cambodia + \value Cameroon + \value Canada + \value CapeVerde + \value CaymanIslands + \value CentralAfricanRepublic + \value Chad + \value Chile + \value China + \value ChristmasIsland + \value CocosIslands + \value Colombia + \value Comoros + \value DemocraticRepublicOfCongo + \value PeoplesRepublicOfCongo + \value CookIslands + \value CostaRica + \value IvoryCoast + \value Croatia + \value Cuba + \value Cyprus + \value CzechRepublic + \value Denmark + \value Djibouti + \value Dominica + \value DominicanRepublic + \value EastTimor + \value Ecuador + \value Egypt + \value ElSalvador + \value EquatorialGuinea + \value Eritrea + \value Estonia + \value Ethiopia + \value FalklandIslands + \value FaroeIslands + \value FijiCountry + \value Finland + \value France + \value MetropolitanFrance + \value FrenchGuiana + \value FrenchPolynesia + \value FrenchSouthernTerritories + \value Gabon + \value Gambia + \value Georgia + \value Germany + \value Ghana + \value Gibraltar + \value Greece + \value Greenland + \value Grenada + \value Guadeloupe + \value Guam + \value Guatemala + \value Guinea + \value GuineaBissau + \value Guyana + \value Haiti + \value HeardAndMcDonaldIslands + \value Honduras + \value HongKong + \value Hungary + \value Iceland + \value India + \value Indonesia + \value Iran + \value Iraq + \value Ireland + \value Israel + \value Italy + \value Jamaica + \value Japan + \value Jordan + \value Kazakhstan + \value Kenya + \value Kiribati + \value DemocraticRepublicOfKorea + \value RepublicOfKorea + \value Kuwait + \value Kyrgyzstan + \value Lao + \value Latvia + \value Lebanon + \value Lesotho + \value Liberia + \value LibyanArabJamahiriya + \value Liechtenstein + \value Lithuania + \value Luxembourg + \value Macau + \value Macedonia + \value Madagascar + \value Malawi + \value Malaysia + \value Maldives + \value Mali + \value Malta + \value MarshallIslands + \value Martinique + \value Mauritania + \value Mauritius + \value Mayotte + \value Mexico + \value Micronesia + \value Moldova + \value Monaco + \value Mongolia + \value Montserrat + \value Morocco + \value Mozambique + \value Myanmar + \value Namibia + \value NauruCountry + \value Nepal + \value Netherlands + \value NetherlandsAntilles + \value NewCaledonia + \value NewZealand + \value Nicaragua + \value Niger + \value Nigeria + \value Niue + \value NorfolkIsland + \value NorthernMarianaIslands + \value Norway + \value Oman + \value Pakistan + \value Palau + \value PalestinianTerritory + \value Panama + \value PapuaNewGuinea + \value Paraguay + \value Peru + \value Philippines + \value Pitcairn + \value Poland + \value Portugal + \value PuertoRico + \value Qatar + \value Reunion + \value Romania + \value RussianFederation + \value Rwanda + \value SaintKittsAndNevis + \value StLucia + \value StVincentAndTheGrenadines + \value Samoa + \value SanMarino + \value SaoTomeAndPrincipe + \value SaudiArabia + \value Senegal + \value Seychelles + \value SierraLeone + \value Singapore + \value Slovakia + \value Slovenia + \value SolomonIslands + \value Somalia + \value SouthAfrica + \value SouthGeorgiaAndTheSouthSandwichIslands + \value Spain + \value SriLanka + \value StHelena + \value StPierreAndMiquelon + \value Sudan + \value Suriname + \value SvalbardAndJanMayenIslands + \value Swaziland + \value Sweden + \value Switzerland + \value SyrianArabRepublic + \value Taiwan + \value Tajikistan + \value Tanzania + \value Thailand + \value Togo + \value Tokelau + \value TongaCountry + \value TrinidadAndTobago + \value Tunisia + \value Turkey + \value Turkmenistan + \value TurksAndCaicosIslands + \value Tuvalu + \value Uganda + \value Ukraine + \value UnitedArabEmirates + \value UnitedKingdom + \value UnitedStates + \value UnitedStatesMinorOutlyingIslands + \value Uruguay + \value Uzbekistan + \value Vanuatu + \value VaticanCityState + \value Venezuela + \value VietNam + \value BritishVirginIslands + \value USVirginIslands + \value WallisAndFutunaIslands + \value WesternSahara + \value Yemen + \value Yugoslavia + \value Zambia + \value Zimbabwe +*/ + +/*! + Constructs a TQLocale object with the specified \a name, + which has the format + "language[_country][.codeset][@modifier]" or "C", where: + + \list + \i language is a lowercase, two-letter, ISO 639 language code, + \i territory is an uppercase, two-letter, ISO 3166 country code, + \i and codeset and modifier are ignored. + \endlist + + If the string violates the locale format, or language is not + a valid ISO 369 code, the "C" locale is used instead. If country + is not present, or is not a valid ISO 3166 code, the most + appropriate country is chosen for the specified language. + + The language and country codes are converted to their respective + \c Language and \c Country enums. After this conversion is + performed the constructor behaves exactly like TQLocale(Country, + Language). + + This constructor is much slower than TQLocale(Country, Language). + + \sa name() +*/ + +TQLocale::TQLocale(const TQString &name) +{ + Language lang = C; + Country cntry = AnyCountry; + + uint l = name.length(); + + do { + if (l < 2) + break; + + const TQChar *uc = name.unicode(); + if (l > 2 + && uc[2] != '_' + && uc[2] != '.' + && uc[2] != '@') + break; + + lang = codeToLanguage(name.mid(0, 2)); + if (lang == C) + break; + + if (l == 2 || uc[2] == '.' || uc[2] == '@') + break; + + // we have uc[2] == '_' + if (l < 5) + break; + + if (l > 5 && uc[5] != '.' && uc[5] != '@') + break; + + cntry = codeToCountry(name.mid(3, 2)); + } while (FALSE); + + d = findLocale(lang, cntry); +} + +/*! + Constructs a TQLocale object initialized with the default locale. + + \sa setDefault() +*/ + +TQLocale::TQLocale() +{ + if (default_d == 0) + default_d = system().d; + + d = default_d; +} + +/*! + Constructs a TQLocale object with the specified \a language and \a + country. + + \list + \i If the language/country pair is found in the database, it is used. + \i If the language is found but the country is not, or if the country + is \c AnyCountry, the language is used with the most + appropriate available country (for example, Germany for German), + \i If neither the language nor the country are found, TQLocale + defaults to the default locale (see setDefault()). + \endlist + + The language and country that are actually used can be queried + using language() and country(). + + \sa setDefault() language() country() +*/ + +TQLocale::TQLocale(Language language, Country country) +{ + d = findLocale(language, country); + + // If not found, should default to system + if (d->languageId() == TQLocale::C && language != TQLocale::C) { + if (default_d == 0) + default_d = system().d; + + d = default_d; + } +} + +/*! + Constructs a TQLocale object as a copy of \a other. +*/ + +TQLocale::TQLocale(const TQLocale &other) +{ + d = other.d; +} + +/*! + Assigns \a other to this TQLocale object and returns a reference + to this TQLocale object. +*/ + +TQLocale &TQLocale::operator=(const TQLocale &other) +{ + d = other.d; + return *this; +} + +/*! + \nonreentrant + + Sets the global default locale to \a locale. These + values are used when a TQLocale object is constructed with + no arguments. If this function is not called, the system's + locale is used. + + \warning In a multithreaded application, the default locale + should be set at application startup, before any non-GUI threads + are created. + + \sa system() c() +*/ + +void TQLocale::setDefault(const TQLocale &locale) +{ + default_d = locale.d; +} + +/*! + Returns the language of this locale. + + \sa TQLocale() +*/ +TQLocale::Language TQLocale::language() const +{ + return (Language)d->languageId(); +} + +/*! + Returns the country of this locale. + + \sa TQLocale() +*/ +TQLocale::Country TQLocale::country() const +{ + return (Country)d->countryId(); +} + +/*! + Returns the language and country of this locale as a + string of the form "language_country", where + language is a lowercase, two-letter ISO 639 language code, + and country is an uppercase, two-letter ISO 3166 country code. + + \sa TQLocale() +*/ + +TQString TQLocale::name() const +{ + Language l = language(); + + TQString result = languageToCode(l); + + if (l == C) + return result; + + Country c = country(); + if (c == AnyCountry) + return result; + + result.append('_'); + result.append(countryToCode(c)); + + return result; +} + +/*! + Returns a TQString containing the name of \a language. +*/ + +TQString TQLocale::languageToString(Language language) +{ + if ((uint)language > (uint)TQLocale::LastLanguage) + return "Unknown"; + return language_name_list + language_name_index[(uint)language]; +} + +/*! + Returns a TQString containing the name of \a country. +*/ + +TQString TQLocale::countryToString(Country country) +{ + if ((uint)country > (uint)TQLocale::LastCountry) + return "Unknown"; + return country_name_list + country_name_index[(uint)country]; +} + +/*! + Returns the short int represented by the localized string \a s, or + 0 if the conversion failed. + + If \a ok is not 0, reports failure by setting + *ok to false and success by setting *ok to true. + + This function ignores leading and trailing whitespace. + + \sa toString() +*/ + +short TQLocale::toShort(const TQString &s, bool *ok) const +{ + Q_LLONG i = toLongLong(s, ok); + if (i < SHRT_MIN || i > SHRT_MAX) { + if (ok != 0) + *ok = FALSE; + return 0; + } + return (short) i; +} + +/*! + Returns the unsigned short int represented by the localized string + \a s, or 0 if the conversion failed. + + If \a ok is not 0, reports failure by setting + *ok to false and success by setting *ok to true. + + This function ignores leading and trailing whitespace. + + \sa toString() +*/ + +ushort TQLocale::toUShort(const TQString &s, bool *ok) const +{ + Q_ULLONG i = toULongLong(s, ok); + if (i > USHRT_MAX) { + if (ok != 0) + *ok = FALSE; + return 0; + } + return (ushort) i; +} + +/*! + Returns the int represented by the localized string \a s, or 0 if + the conversion failed. + + If \a ok is not 0, reports failure by setting *ok to false and + success by setting *ok to true. + + This function ignores leading and trailing whitespace. + + \sa toString() +*/ + +int TQLocale::toInt(const TQString &s, bool *ok) const +{ + Q_LLONG i = toLongLong(s, ok); + if (i < INT_MIN || i > INT_MAX) { + if (ok != 0) + *ok = FALSE; + return 0; + } + return (int) i; +} + +/*! + Returns the unsigned int represented by the localized string \a s, + or 0 if the conversion failed. + + If \a ok is not 0, reports failure by setting + *ok to false and success by setting *ok to true. + + This function ignores leading and trailing whitespace. + + \sa toString() +*/ + +uint TQLocale::toUInt(const TQString &s, bool *ok) const +{ + Q_ULLONG i = toULongLong(s, ok); + if (i > UINT_MAX) { + if (ok != 0) + *ok = FALSE; + return 0; + } + return (uint) i; +} + +/*! + Returns the long int represented by the localized string \a s, or + 0 if the conversion failed. + + If \a ok is not 0, reports failure by setting + *ok to false and success by setting *ok to true. + + This function ignores leading and trailing whitespace. + + \sa toString() +*/ + +Q_LONG TQLocale::toLong(const TQString &s, bool *ok) const +{ + Q_LLONG i = toLongLong(s, ok); + if (i < LONG_MIN || i > LONG_MAX) { + if (ok != 0) + *ok = FALSE; + return 0; + } + return (Q_LONG) i; +} + +/*! + Returns the unsigned long int represented by the localized string + \a s, or 0 if the conversion failed. + + If \a ok is not 0, reports failure by setting + *ok to false and success by setting *ok to true. + + This function ignores leading and trailing whitespace. + + \sa toString() +*/ + +Q_ULONG TQLocale::toULong(const TQString &s, bool *ok) const +{ + Q_ULLONG i = toULongLong(s, ok); + if (i > ULONG_MAX) { + if (ok != 0) + *ok = FALSE; + return 0; + } + return (Q_ULONG) i; +} + +/*! + Returns the long long int represented by the localized string \a + s, or 0 if the conversion failed. + + If \a ok is not 0, reports failure by setting + *ok to false and success by setting *ok to true. + + This function ignores leading and trailing whitespace. + + \sa toString() +*/ + + +Q_LLONG TQLocale::toLongLong(const TQString &s, bool *ok) const +{ + return d->stringToLongLong(s, 0, ok, TQLocalePrivate::ParseGroupSeparators); +} + +/*! + Returns the unsigned long long int represented by the localized + string \a s, or 0 if the conversion failed. + + If \a ok is not 0, reports failure by setting + *ok to false and success by setting *ok to true. + + This function ignores leading and trailing whitespace. + + \sa toString() +*/ + + +Q_ULLONG TQLocale::toULongLong(const TQString &s, bool *ok) const +{ + return d->stringToUnsLongLong(s, 0, ok, TQLocalePrivate::ParseGroupSeparators); +} + +/*! + Returns the float represented by the localized string \a s, or 0.0 + if the conversion failed. + + If \a ok is not 0, reports failure by setting + *ok to false and success by setting *ok to true. + + This function ignores leading and trailing whitespace. + + \sa toString() +*/ + +#define QT_MAX_FLOAT 3.4028234663852886e+38 + +float TQLocale::toFloat(const TQString &s, bool *ok) const +{ + bool myOk; + double d = toDouble(s, &myOk); + if (!myOk || d > QT_MAX_FLOAT || d < -QT_MAX_FLOAT) { + if (ok != 0) + *ok = FALSE; + return 0.0; + } + if (ok != 0) + *ok = TRUE; + return (float) d; +} + +/*! + Returns the double represented by the localized string \a s, or + 0.0 if the conversion failed. + + If \a ok is not 0, reports failure by setting + *ok to false and success by setting *ok to true. + + Unlike TQString::toDouble(), this function does not fall back to + the "C" locale if the string cannot be interpreted in this + locale. + + \code + bool ok; + double d; + + TQLocale c(TQLocale::C); + d = c.toDouble( "1234.56", &ok ); // ok == true, d == 1234.56 + d = c.toDouble( "1,234.56", &ok ); // ok == true, d == 1234.56 + d = c.toDouble( "1234,56", &ok ); // ok == false + + TQLocale german(TQLocale::German); + d = german.toDouble( "1234,56", &ok ); // ok == true, d == 1234.56 + d = german.toDouble( "1.234,56", &ok ); // ok == true, d == 1234.56 + d = german.toDouble( "1234.56", &ok ); // ok == false + + d = german.toDouble( "1.234", &ok ); // ok == true, d == 1234.0 + \endcode + + Notice that the last conversion returns 1234.0, because '.' is the + thousands group separator in the German locale. + + This function ignores leading and trailing whitespace. + + \sa toString() TQString::toDouble() +*/ + +double TQLocale::toDouble(const TQString &s, bool *ok) const +{ + return d->stringToDouble(s, ok, TQLocalePrivate::ParseGroupSeparators); +} + +/*! + Returns a localized string representation of \a i. + + \sa toLongLong() +*/ + +TQString TQLocale::toString(Q_LLONG i) const +{ + return d->longLongToString(i, -1, 10, -1, TQLocalePrivate::ThousandsGroup); +} + +/*! + \overload + + \sa toULongLong() +*/ + +TQString TQLocale::toString(Q_ULLONG i) const +{ + return d->unsLongLongToString(i, -1, 10, -1, TQLocalePrivate::ThousandsGroup); +} + +static bool qIsUpper(char c) +{ + return c >= 'A' && c <= 'Z'; +} + +static char qToLower(char c) +{ + if (c >= 'A' && c <= 'Z') + return c - 'A' + 'a'; + else + return c; +} + +/*! + \overload + + \a f and \a prec have the same meaning as in TQString::number(double, char, int). + + \sa toDouble() +*/ + +TQString TQLocale::toString(double i, char f, int prec) const +{ + TQLocalePrivate::DoubleForm form = TQLocalePrivate::DFDecimal; + uint flags = 0; + + if (qIsUpper(f)) + flags = TQLocalePrivate::CapitalEorX; + f = qToLower(f); + + switch (f) { + case 'f': + form = TQLocalePrivate::DFDecimal; + break; + case 'e': + form = TQLocalePrivate::DFExponent; + break; + case 'g': + form = TQLocalePrivate::DFSignificantDigits; + break; + default: + break; + } + + flags |= TQLocalePrivate::ThousandsGroup; + return d->doubleToString(i, prec, form, -1, flags); +} + +/*! + \fn TQLocale TQLocale::c() + + Returns a TQLocale object initialized to the "C" locale. + + \sa system() +*/ + +/*! + Returns a TQLocale object initialized to the system locale. +*/ + +TQLocale TQLocale::system() +{ +#ifdef Q_OS_UNIX + const char *s = getenv("LC_NUMERIC"); + if (s == 0) + s = getenv("LC_ALL"); + if (s != 0) + return TQLocale(s); +#endif + return TQLocale(TQLocalePrivate::systemLocaleName()); +} + +/*! +\fn TQString TQLocale::toString(short i) const + +\overload + +\sa toShort() +*/ + +/*! +\fn TQString TQLocale::toString(ushort i) const + +\overload + +\sa toUShort() +*/ + +/*! +\fn TQString TQLocale::toString(int i) const + +\overload + +\sa toInt() +*/ + +/*! +\fn TQString TQLocale::toString(uint i) const + +\overload + +\sa toUInt() +*/ + +/*! +\fn TQString TQLocale::toString(Q_LONG i) const + +\overload + +\sa toLong() +*/ + +/*! +\fn TQString TQLocale::toString(Q_ULONG i) const + +\overload + +\sa toULong() +*/ + +/*! +\fn TQString TQLocale::toString(float i, char f = 'g', int prec = 6) const + +\overload + +\a f and \a prec have the same meaning as in TQString::number(double, char, int). + +\sa toDouble() +*/ + + +bool TQLocalePrivate::isDigit(TQChar d) const +{ + return zero().unicode() <= d.unicode() + && zero().unicode() + 10 > d.unicode(); +} + +static char digitToCLocale(TQChar zero, TQChar d) +{ + if (zero.unicode() <= d.unicode() + && zero.unicode() + 10 > d.unicode()) + return '0' + d.unicode() - zero.unicode(); + + qWarning("TQLocalePrivate::digitToCLocale(): bad digit: row=%d, cell=%d", d.row(), d.cell()); + return TQChar(0); +} + +static TQString qulltoa(Q_ULLONG l, int base, const TQLocalePrivate &locale) +{ + TQChar buff[65]; // length of MAX_ULLONG in base 2 + TQChar *p = buff + 65; + + if (base != 10 || locale.zero().unicode() == '0') { + while (l != 0) { + int c = l % base; + + --p; + + if (c < 10) + *p = '0' + c; + else + *p = c - 10 + 'a'; + + l /= base; + } + } + else { + while (l != 0) { + int c = l % base; + + *(--p) = locale.zero().unicode() + c; + + l /= base; + } + } + + return TQString(p, 65 - (p - buff)); +} + +static TQString qlltoa(Q_LLONG l, int base, const TQLocalePrivate &locale) +{ + return qulltoa(l < 0 ? -l : l, base, locale); +} + +enum PrecisionMode { + PMDecimalDigits = 0x01, + PMSignificantDigits = 0x02, + PMChopTrailingZeros = 0x03 +}; + +static TQString &decimalForm(TQString &digits, int decpt, uint precision, + PrecisionMode pm, + bool always_show_decpt, + bool thousands_group, + const TQLocalePrivate &locale) +{ + if (decpt < 0) { + for (int i = 0; i < -decpt; ++i) + digits.prepend(locale.zero()); + decpt = 0; + } + else if ((uint)decpt > digits.length()) { + for (uint i = digits.length(); i < (uint)decpt; ++i) + digits.append(locale.zero()); + } + + if (pm == PMDecimalDigits) { + uint decimal_digits = digits.length() - decpt; + for (uint i = decimal_digits; i < precision; ++i) + digits.append(locale.zero()); + } + else if (pm == PMSignificantDigits) { + for (uint i = digits.length(); i < precision; ++i) + digits.append(locale.zero()); + } + else { // pm == PMChopTrailingZeros + } + + if (always_show_decpt || (uint)decpt < digits.length()) + digits.insert(decpt, locale.decimal()); + + if (thousands_group) { + for (int i = decpt - 3; i > 0; i -= 3) + digits.insert(i, locale.group()); + } + + if (decpt == 0) + digits.prepend(locale.zero()); + + return digits; +} + +static TQString &exponentForm(TQString &digits, int decpt, uint precision, + PrecisionMode pm, + bool always_show_decpt, + const TQLocalePrivate &locale) +{ + int exp = decpt - 1; + + if (pm == PMDecimalDigits) { + for (uint i = digits.length(); i < precision + 1; ++i) + digits.append(locale.zero()); + } + else if (pm == PMSignificantDigits) { + for (uint i = digits.length(); i < precision; ++i) + digits.append(locale.zero()); + } + else { // pm == PMChopTrailingZeros + } + + if (always_show_decpt || digits.length() > 1) + digits.insert(1, locale.decimal()); + + digits.append(locale.exponential()); + digits.append(locale.longLongToString(exp, 2, 10, + -1, TQLocalePrivate::AlwaysShowSign)); + + return digits; +} + +static bool isZero(double d) +{ + uchar *ch = (uchar *)&d; + if (ByteOrder == BigEndian) { + return !(ch[0] & 0x7F || ch[1] || ch[2] || ch[3] || ch[4] || ch[5] || ch[6] || ch[7]); + } else { + return !(ch[7] & 0x7F || ch[6] || ch[5] || ch[4] || ch[3] || ch[2] || ch[1] || ch[0]); + } +} + +TQString TQLocalePrivate::doubleToString(double d, + int precision, + DoubleForm form, + int width, + unsigned flags) const +{ + if (precision == -1) + precision = 6; + if (width == -1) + width = 0; + + bool negative = FALSE; + bool special_number = FALSE; // nan, +/-inf + TQString num_str; + +#ifdef Q_OS_WIN + // Detect special numbers (nan, +/-inf) + if (qIsInf(d)) { + num_str = infinity(); + special_number = TRUE; + negative = d < 0; + } else if (qIsNan(d)) { + num_str = nan(); + special_number = TRUE; + } +#else + // Comparing directly to INFINITY gives weird results on some systems. + double tmp_infinity = INFINITY; + + // Detect special numbers (nan, +/-inf) + if (d == tmp_infinity || d == -tmp_infinity) { + num_str = infinity(); + special_number = TRUE; + negative = d < 0; + } else if (qIsNan(d)) { + num_str = nan(); + special_number = TRUE; + } +#endif + + // Handle normal numbers + if (!special_number) { + int decpt, sign; + TQString digits; + +#ifdef QT_QLOCALE_USES_FCVT +#ifdef QT_THREAD_SUPPORT + static bool dummy_for_mutex; + TQMutex *fcvt_mutex = qt_global_mutexpool ? qt_global_mutexpool->get( &dummy_for_mutex ) : 0; +# define FCVT_LOCK if (fcvt_mutex) fcvt_mutex->lock() +# define FCVT_UNLOCK if (fcvt_mutex) fcvt_mutex->unlock() +#else +# define FCVT_LOCK +# define FCVT_UNLOCK +#endif + if (form == DFDecimal) { + FCVT_LOCK; + digits = fcvt(d, precision, &decpt, &sign); + FCVT_UNLOCK; + } else { + int pr = precision; + if (form == DFExponent) + ++pr; + else if (form == DFSignificantDigits && pr == 0) + pr = 1; + FCVT_LOCK; + digits = ecvt(d, pr, &decpt, &sign); + FCVT_UNLOCK; + + // Chop trailing zeros + if (digits.length() > 0) { + int last_nonzero_idx = digits.length() - 1; + while (last_nonzero_idx > 0 + && digits.unicode()[last_nonzero_idx] == '0') + --last_nonzero_idx; + digits.truncate(last_nonzero_idx + 1); + } + + } + +#else + int mode; + if (form == DFDecimal) + mode = 3; + else + mode = 2; + + /* This next bit is a bit tquirky. In DFExponent form, the precision + is the number of digits after decpt. So that would suggest using + mode=3 for qdtoa. But qdtoa behaves strangely when mode=3 and + precision=0. So we get around this by using mode=2 and reasoning + that we want precision+1 significant digits, since the decimal + point in this mode is always after the first digit. */ + int pr = precision; + if (form == DFExponent) + ++pr; + + char *rve = 0; + char *buff = 0; + digits = qdtoa(d, mode, pr, &decpt, &sign, &rve, &buff); + if (buff != 0) + free(buff); +#endif // QT_QLOCALE_USES_FCVT + + if (zero().unicode() != '0') { + for (uint i = 0; i < digits.length(); ++i) + digits.ref(i).unicode() += zero().unicode() - '0'; + } + + bool always_show_decpt = flags & Alternate; + switch (form) { + case DFExponent: { + num_str = exponentForm(digits, decpt, precision, PMDecimalDigits, + always_show_decpt, *this); + break; + } + case DFDecimal: { + num_str = decimalForm(digits, decpt, precision, PMDecimalDigits, + always_show_decpt, flags & ThousandsGroup, + *this); + break; + } + case DFSignificantDigits: { + PrecisionMode mode = (flags & Alternate) ? + PMSignificantDigits : PMChopTrailingZeros; + + if (decpt != (int)digits.length() && (decpt <= -4 || decpt > (int)precision)) + num_str = exponentForm(digits, decpt, precision, mode, + always_show_decpt, *this); + else + num_str = decimalForm(digits, decpt, precision, mode, + always_show_decpt, flags & ThousandsGroup, + *this); + break; + } + } + + negative = sign != 0 && !isZero(d); + } + + // pad with zeros. LeftAdjusted overrides this flag). Also, we don't + // pad special numbers + if (flags & TQLocalePrivate::ZeroPadded + && !(flags & TQLocalePrivate::LeftAdjusted) + && !special_number) { + int num_pad_chars = width - (int)num_str.length(); + // leave space for the sign + if (negative + || flags & TQLocalePrivate::AlwaysShowSign + || flags & TQLocalePrivate::BlankBeforePositive) + --num_pad_chars; + + for (int i = 0; i < num_pad_chars; ++i) + num_str.prepend(zero()); + } + + // add sign + if (negative) + num_str.prepend(minus()); + else if (flags & TQLocalePrivate::AlwaysShowSign) + num_str.prepend(plus()); + else if (flags & TQLocalePrivate::BlankBeforePositive) + num_str.prepend(' '); + + if (flags & TQLocalePrivate::CapitalEorX) + num_str = num_str.upper(); + + return num_str; +} + +TQString TQLocalePrivate::longLongToString(Q_LLONG l, int precision, + int base, int width, + unsigned flags) const +{ + bool precision_not_specified = FALSE; + if (precision == -1) { + precision_not_specified = TRUE; + precision = 1; + } + + bool negative = l < 0; + if (base != 10) { + // these are not suported by sprintf for octal and hex + flags &= ~AlwaysShowSign; + flags &= ~BlankBeforePositive; + negative = FALSE; // neither are negative numbers + } + + TQString num_str; + if (base == 10) + num_str = qlltoa(l, base, *this); + else + num_str = qulltoa(l, base, *this); + + uint cnt_thousand_sep = 0; + if (flags & ThousandsGroup && base == 10) { + for (int i = (int)num_str.length() - 3; i > 0; i -= 3) { + num_str.insert(i, group()); + ++cnt_thousand_sep; + } + } + + for (int i = num_str.length()/* - cnt_thousand_sep*/; i < precision; ++i) + num_str.prepend(base == 10 ? zero() : TQChar('0')); + + if (flags & Alternate + && base == 8 + && (num_str.isEmpty() + || num_str[0].unicode() != '0')) + num_str.prepend('0'); + + // LeftAdjusted overrides this flag ZeroPadded. sprintf only padds + // when precision is not specified in the format string + bool zero_padded = flags & ZeroPadded + && !(flags & LeftAdjusted) + && precision_not_specified; + + if (zero_padded) { + int num_pad_chars = width - (int)num_str.length(); + + // leave space for the sign + if (negative + || flags & AlwaysShowSign + || flags & BlankBeforePositive) + --num_pad_chars; + + // leave space for optional '0x' in hex form + if (base == 16 + && flags & Alternate + && l != 0) + num_pad_chars -= 2; + + for (int i = 0; i < num_pad_chars; ++i) + num_str.prepend(base == 10 ? zero() : TQChar('0')); + } + + if (base == 16 + && flags & Alternate + && l != 0) + num_str.prepend("0x"); + + // add sign + if (negative) + num_str.prepend(minus()); + else if (flags & AlwaysShowSign) + num_str.prepend(base == 10 ? plus() : TQChar('+')); + else if (flags & BlankBeforePositive) + num_str.prepend(' '); + + if (flags & CapitalEorX) + num_str = num_str.upper(); + + return num_str; +} + +TQString TQLocalePrivate::unsLongLongToString(Q_ULLONG l, int precision, + int base, int width, + unsigned flags) const +{ + bool precision_not_specified = FALSE; + if (precision == -1) { + precision_not_specified = TRUE; + precision = 1; + } + + TQString num_str = qulltoa(l, base, *this); + + uint cnt_thousand_sep = 0; + if (flags & ThousandsGroup && base == 10) { + for (int i = (int)num_str.length() - 3; i > 0; i -=3) { + num_str.insert(i, group()); + ++cnt_thousand_sep; + } + } + + for (int i = num_str.length()/* - cnt_thousand_sep*/; i < precision; ++i) + num_str.prepend(base == 10 ? zero() : TQChar('0')); + + if (flags & Alternate + && base == 8 + && (num_str.isEmpty() + || num_str[0].unicode() != '0')) + num_str.prepend('0'); + + // LeftAdjusted overrides this flag ZeroPadded. sprintf only padds + // when precision is not specified in the format string + bool zero_padded = flags & ZeroPadded + && !(flags & LeftAdjusted) + && precision_not_specified; + + if (zero_padded) { + int num_pad_chars = width - (int)num_str.length(); + + // leave space for optional '0x' in hex form + if (base == 16 + && flags & Alternate + && l != 0) + num_pad_chars -= 2; + + for (int i = 0; i < num_pad_chars; ++i) + num_str.prepend(base == 10 ? zero() : TQChar('0')); + } + + if (base == 16 + && flags & Alternate + && l != 0) + num_str.prepend("0x"); + + if (flags & CapitalEorX) + num_str = num_str.upper(); + + return num_str; +} + +static inline bool isLatin1Digit(const TQChar &c) +{ + return c.unicode() >= '0' && c.unicode() <= '9'; +} + +// Removes thousand-group separators, ie. the ',' in "1,234,567.89e-5" +bool TQLocalePrivate::removeGroupSeparators(TQString &num_str) const +{ + int group_cnt = 0; // counts number of group chars + int decpt_idx = -1; + + // Find the decimal point and check if there are any group chars + uint i = 0; + for (; i < num_str.length(); ++i) { + TQChar c = num_str.unicode()[i]; + + if (c.unicode() == ',') { + // check that there are digits before and after the separator + if (i == 0 || !isLatin1Digit(num_str.unicode()[i - 1])) + return FALSE; + if (i == num_str.length() + 1 || !isLatin1Digit(num_str.unicode()[i + 1])) + return FALSE; + ++group_cnt; + } + else if (c.unicode() == '.') { + // Fail if more than one decimal points + if (decpt_idx != -1) + return FALSE; + decpt_idx = i; + } else if (c.unicode() == 'e' || c.unicode() == 'E') { + // an 'e' or 'E' - if we have not encountered a decimal + // point, this is where it "is". + if (decpt_idx == -1) + decpt_idx = i; + } + } + + // If no group chars, we're done + if (group_cnt == 0) + return TRUE; + + // No decimal point means that it "is" at the end of the string + if (decpt_idx == -1) + decpt_idx = num_str.length(); + + i = 0; + while (i < num_str.length() && group_cnt > 0) { + TQChar c = num_str.unicode()[i]; + + if (c.unicode() == ',') { + // Don't allow group chars after the decimal point + if ((int)i > decpt_idx) + return FALSE; + + // Check that it is placed correctly relative to the decpt + if ((decpt_idx - i) % 4 != 0) + return FALSE; + + // Remove it + num_str.remove(i, 1); + + --group_cnt; + --decpt_idx; // adjust decpt_idx + } else { + // Check that we are not missing a separator + if ((int)i < decpt_idx && (decpt_idx - i) % 4 == 0) + return FALSE; + ++i; + } + } + + return TRUE; +} + +static void stripWhiteSpaceInPlace(TQString &s) +{ + uint i = 0; + while (i < s.length() && s.unicode()[i].isSpace()) + ++i; + if (i > 0) + s.remove(0, i); + + i = s.length(); + + if (i == 0) + return; + --i; + while (i > 0 && s.unicode()[i].isSpace()) + --i; + if (i + 1 < s.length()) + s.truncate(i + 1); +} + +/* + Converts a number in locale to its representation in the C locale. + Only has to guarantee that a string that is a correct representation of + a number will be converted. If junk is passed in, junk will be passed + out and the error will be detected during the actual conversion to a + number. We can't detect junk here, since we don't even know the base + of the number. +*/ +bool TQLocalePrivate::numberToCLocale(TQString &l_num, + GroupSeparatorMode group_sep_mode) const +{ + stripWhiteSpaceInPlace(l_num); + + if (l_num.isEmpty()) + return FALSE; + + for (uint idx = 0; idx < l_num.length(); ++idx) { + TQChar &c = l_num.ref(idx); + + if (isDigit(c)) + c = digitToCLocale(zero(), c); + else if (c == plus()) + c = '+'; + else if (c == minus()) + c = '-'; + else if (c == decimal()) + c = '.'; + else if (c == group()) + c = ','; + // In several languages group() is the char 0xA0, which looks like a space. + // People use a regular space instead of it and complain it doesn't work. + else if (group().unicode() == 0xA0 && c.unicode() == ' ') + c = ','; + else if (c == exponential() || c == exponential().upper()) + c = 'e'; + else if (c == list()) + c = ';'; + else if (c == percent()) + c = '%'; + else if (c.unicode() >= 'A' && c.unicode() <= 'Z') + c = c.lower(); + else if (c.unicode() >= 'a' && c.unicode() <= 'z') + ; // do nothing + else + return FALSE; + } + + if (group_sep_mode == ParseGroupSeparators + && !removeGroupSeparators(l_num)) + return FALSE; + + return TRUE; +} + +double TQLocalePrivate::stringToDouble(TQString num, + bool *ok, + GroupSeparatorMode group_sep_mode) const +{ + if (!numberToCLocale(num, group_sep_mode)) { + if (ok != 0) + *ok = FALSE; + return 0.0; + } + + if (ok != 0) + *ok = TRUE; + + if (num == "nan") + return NAN; + + if (num == "+inf" + || num == "inf") + return INFINITY; + + if (num == "-inf") + return -INFINITY; + + bool _ok; + const char *num_buff = num.latin1(); + +#ifdef QT_QLOCALE_USES_FCVT + char *endptr; + double d = strtod(num_buff, &endptr); + _ok = TRUE; +#else + const char *endptr; + double d = qstrtod(num_buff, &endptr, &_ok); +#endif + + if (!_ok || *endptr != '\0') { + if (ok != 0) + *ok = FALSE; + return 0.0; + } + else + return d; +} + +Q_LLONG TQLocalePrivate::stringToLongLong(TQString num, int base, + bool *ok, + GroupSeparatorMode group_sep_mode) const +{ + if (!numberToCLocale(num, group_sep_mode)) { + if (ok != 0) + *ok = FALSE; + return 0; + } + + bool _ok; + const char *endptr; + const char *num_buff = num.latin1(); + Q_LLONG l = qstrtoll(num_buff, &endptr, base, &_ok); + + if (!_ok || *endptr != '\0') { + if (ok != 0) + *ok = FALSE; + return 0; + } + + if (ok != 0) + *ok = TRUE; + return l; +} + +Q_ULLONG TQLocalePrivate::stringToUnsLongLong(TQString num, int base, + bool *ok, + GroupSeparatorMode group_sep_mode) const +{ + if (!numberToCLocale(num, group_sep_mode)) { + if (ok != 0) + *ok = FALSE; + return 0; + } + + bool _ok; + const char *endptr; + const char *num_buff = num.latin1(); + Q_ULLONG l = qstrtoull(num_buff, &endptr, base, &_ok); + + if (!_ok || *endptr != '\0') { + if (ok != 0) + *ok = FALSE; + return 0; + } + + if (ok != 0) + *ok = TRUE; + return l; +} + +/*- + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSETQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +// static char sccsid[] = "@(#)strtouq.c 8.1 (Berkeley) 6/4/93"; +// "$FreeBSD: src/lib/libc/stdlib/strtoull.c,v 1.5.2.1 2001/03/02 09:45:20 obrien Exp $"; + +/* + * Convert a string to an Q_ULLONG integer. + * + * Ignores `locale' stuff. Assumes that the upper and lower case + * alphabets and digits are each contiguous. + */ +static Q_ULLONG qstrtoull(const char *nptr, const char **endptr, register int base, bool *ok) +{ + register const char *s = nptr; + register Q_ULLONG acc; + register unsigned char c; + register Q_ULLONG qbase, cutoff; + register int neg, any, cutlim; + + if (ok != 0) + *ok = TRUE; + + /* + * See strtoq for comments as to the logic used. + */ + s = nptr; + do { + c = *s++; + } while (isspace(c)); + if (c == '-') { + if (ok != 0) + *ok = FALSE; + if (endptr != 0) + *endptr = s - 1; + return 0; + } else { + neg = 0; + if (c == '+') + c = *s++; + } + if ((base == 0 || base == 16) && + c == '0' && (*s == 'x' || *s == 'X')) { + c = s[1]; + s += 2; + base = 16; + } + if (base == 0) + base = c == '0' ? 8 : 10; + qbase = (unsigned)base; + cutoff = (Q_ULLONG)ULLONG_MAX / qbase; + cutlim = (Q_ULLONG)ULLONG_MAX % qbase; + for (acc = 0, any = 0;; c = *s++) { + if (!isascii(c)) + break; + if (isdigit(c)) + c -= '0'; + else if (isalpha(c)) + c -= isupper(c) ? 'A' - 10 : 'a' - 10; + else + break; + if (c >= base) + break; + if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim)) + any = -1; + else { + any = 1; + acc *= qbase; + acc += c; + } + } + if (any < 0) { + acc = ULLONG_MAX; + if (ok != 0) + *ok = FALSE; + } + else if (neg) + acc = (~acc) + 1; + if (endptr != 0) + *endptr = (char *)(any ? s - 1 : nptr); + return (acc); +} + + +// "$FreeBSD: src/lib/libc/stdlib/strtoll.c,v 1.5.2.1 2001/03/02 09:45:20 obrien Exp $"; + + +/* + * Convert a string to a Q_LLONG integer. + * + * Ignores `locale' stuff. Assumes that the upper and lower case + * alphabets and digits are each contiguous. + */ +static Q_LLONG qstrtoll(const char *nptr, const char **endptr, register int base, bool *ok) +{ + register const char *s; + register Q_ULLONG acc; + register unsigned char c; + register Q_ULLONG qbase, cutoff; + register int neg, any, cutlim; + + if (ok != 0) + *ok = TRUE; + + /* + * Skip white space and pick up leading +/- sign if any. + * If base is 0, allow 0x for hex and 0 for octal, else + * assume decimal; if base is already 16, allow 0x. + */ + s = nptr; + do { + c = *s++; + } while (isspace(c)); + if (c == '-') { + neg = 1; + c = *s++; + } else { + neg = 0; + if (c == '+') + c = *s++; + } + if ((base == 0 || base == 16) && + c == '0' && (*s == 'x' || *s == 'X')) { + c = s[1]; + s += 2; + base = 16; + } + if (base == 0) + base = c == '0' ? 8 : 10; + + /* + * Compute the cutoff value between legal numbers and illegal + * numbers. That is the largest legal value, divided by the + * base. An input number that is greater than this value, if + * followed by a legal input character, is too big. One that + * is equal to this value may be valid or not; the limit + * between valid and invalid numbers is then based on the last + * digit. For instance, if the range for quads is + * [-9223372036854775808..9223372036854775807] and the input base + * is 10, cutoff will be set to 922337203685477580 and cutlim to + * either 7 (neg==0) or 8 (neg==1), meaning that if we have + * accumulated a value > 922337203685477580, or equal but the + * next digit is > 7 (or 8), the number is too big, and we will + * return a range error. + * + * Set any if any `digits' consumed; make it negative to indicate + * overflow. + */ + qbase = (unsigned)base; + cutoff = neg ? (Q_ULLONG)-(LLONG_MIN + LLONG_MAX) + LLONG_MAX + : LLONG_MAX; + cutlim = cutoff % qbase; + cutoff /= qbase; + for (acc = 0, any = 0;; c = *s++) { + if (!isascii(c)) + break; + if (isdigit(c)) + c -= '0'; + else if (isalpha(c)) + c -= isupper(c) ? 'A' - 10 : 'a' - 10; + else + break; + if (c >= base) + break; + if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim)) + any = -1; + else { + any = 1; + acc *= qbase; + acc += c; + } + } + if (any < 0) { + acc = neg ? LLONG_MIN : LLONG_MAX; + if (ok != 0) + *ok = FALSE; + } else if (neg) { + acc = (~acc) + 1; + } + if (endptr != 0) + *endptr = (char *)(any ? s - 1 : nptr); + return (acc); +} + +#ifndef QT_QLOCALE_USES_FCVT + +/* From: NetBSD: strtod.c,v 1.26 1998/02/03 18:44:21 perry Exp */ +/* $FreeBSD: src/lib/libc/stdlib/netbsd_strtod.c,v 1.2.2.2 2001/03/02 17:14:15 tegge Exp $ */ + +/* Please send bug reports to + David M. Gay + AT&T Bell Laboratories, Room 2C-463 + 600 Mountain Avenue + Murray Hill, NJ 07974-2070 + U.S.A. + dmg@research.att.com or research!dmg + */ + +/* strtod for IEEE-, VAX-, and IBM-arithmetic machines. + * + * This strtod returns a nearest machine number to the input decimal + * string (or sets errno to ERANGE). With IEEE arithmetic, ties are + * broken by the IEEE round-even rule. Otherwise ties are broken by + * biased rounding (add half and chop). + * + * Inspired loosely by William D. Clinger's paper "How to Read Floating + * Point Numbers Accurately" [Proc. ACM SIGPLAN '90, pp. 92-101]. + * + * Modifications: + * + * 1. We only retquire IEEE, IBM, or VAX double-precision + * arithmetic (not IEEE double-extended). + * 2. We get by with floating-point arithmetic in a case that + * Clinger missed -- when we're computing d * 10^n + * for a small integer d and the integer n is not too + * much larger than 22 (the maximum integer k for which + * we can represent 10^k exactly), we may be able to + * compute (d*10^k) * 10^(e-k) with just one roundoff. + * 3. Rather than a bit-at-a-time adjustment of the binary + * result in the hard case, we use floating-point + * arithmetic to determine the adjustment to within + * one bit; only in really hard cases do we need to + * compute a second residual. + * 4. Because of 3., we don't need a large table of powers of 10 + * for ten-to-e (just some small tables, e.g. of 10^k + * for 0 <= k <= 22). + */ + +/* + * #define IEEE_LITTLE_ENDIAN for IEEE-arithmetic machines where the least + * significant byte has the lowest address. + * #define IEEE_BIG_ENDIAN for IEEE-arithmetic machines where the most + * significant byte has the lowest address. + * #define Long int on machines with 32-bit ints and 64-bit longs. + * #define Sudden_Underflow for IEEE-format machines without gradual + * underflow (i.e., that flush to zero on underflow). + * #define IBM for IBM mainframe-style floating-point arithmetic. + * #define VAX for VAX-style floating-point arithmetic. + * #define Unsigned_Shifts if >> does treats its left operand as unsigned. + * #define No_leftright to omit left-right logic in fast floating-point + * computation of dtoa. + * #define Check_FLT_ROUNDS if FLT_ROUNDS can assume the values 2 or 3. + * #define RND_PRODTQUOT to use rnd_prod and rnd_quot (assembly routines + * that use extended-precision instructions to compute rounded + * products and quotients) with IBM. + * #define ROUND_BIASED for IEEE-format with biased rounding. + * #define Inaccurate_Divide for IEEE-format with correctly rounded + * products but inaccurate quotients, e.g., for Intel i860. + * #define Just_16 to store 16 bits per 32-bit Long when doing high-precision + * integer arithmetic. Whether this speeds things up or slows things + * down depends on the machine and the number being converted. + * #define KR_headers for old-style C function headers. + * #define Bad_float_h if your system lacks a float.h or if it does not + * define some or all of DBL_DIG, DBL_MAX_10_EXP, DBL_MAX_EXP, + * FLT_RADIX, FLT_ROUNDS, and DBL_MAX. + * #define MALLOC your_malloc, where your_malloc(n) acts like malloc(n) + * if memory is available and otherwise does something you deem + * appropriate. If MALLOC is undefined, malloc will be invoked + * directly -- and assumed always to succeed. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +__RCSID("$NetBSD: strtod.c,v 1.26 1998/02/03 18:44:21 perry Exp $"); +#endif /* LIBC_SCCS and not lint */ + +/* +#if defined(__m68k__) || defined(__sparc__) || defined(__i386__) || \ + defined(__mips__) || defined(__ns32k__) || defined(__alpha__) || \ + defined(__powerpc__) || defined(Q_OS_WIN) || defined(Q_OS_DARWIN) || defined(Q_OS_MACX) || \ + defined(mips) || defined(Q_OS_AIX) || defined(Q_OS_SOLARIS) +# define IEEE_BIG_OR_LITTLE_ENDIAN 1 +#endif +*/ + +// *All* of our architectures have IEEE arithmetic, don't they? +#define IEEE_BIG_OR_LITTLE_ENDIAN 1 + +#ifdef __arm32__ +/* + * Although the CPU is little endian the FP has different + * byte and word endianness. The byte order is still little endian + * but the word order is big endian. + */ +#define IEEE_BIG_OR_LITTLE_ENDIAN +#endif + +#ifdef vax +#define VAX +#endif + +#define Long Q_INT32 +#define ULong Q_UINT32 + +#define MALLOC malloc +#define CONST const + +#ifdef BSD_QDTOA_DEBUG +#include +#define Bug(x) {fprintf(stderr, "%s\n", x); exit(1);} +#endif + +#ifdef Unsigned_Shifts +#define Sign_Extend(a,b) if (b < 0) a |= 0xffff0000; +#else +#define Sign_Extend(a,b) /*no-op*/ +#endif + +#if (defined(IEEE_BIG_OR_LITTLE_ENDIAN) + defined(VAX) + defined(IBM)) != 1 +#error Exactly one of IEEE_BIG_OR_LITTLE_ENDIAN, VAX, or IBM should be defined. +#endif + +inline ULong getWord0(const NEEDS_VOLATILE double x) +{ + const NEEDS_VOLATILE uchar *ptr = reinterpret_cast(&x); + if (ByteOrder == BigEndian) { + return (ptr[0]<<24) + (ptr[1]<<16) + (ptr[2]<<8) + ptr[3]; + } else { + return (ptr[7]<<24) + (ptr[6]<<16) + (ptr[5]<<8) + ptr[4]; + } +} + +inline void setWord0(NEEDS_VOLATILE double *x, ULong l) +{ + NEEDS_VOLATILE uchar *ptr = reinterpret_cast(x); + if (ByteOrder == BigEndian) { + ptr[0] = (uchar)(l>>24); + ptr[1] = (uchar)(l>>16); + ptr[2] = (uchar)(l>>8); + ptr[3] = (uchar)l; + } else { + ptr[7] = (uchar)(l>>24); + ptr[6] = (uchar)(l>>16); + ptr[5] = (uchar)(l>>8); + ptr[4] = (uchar)l; + } +} + +inline ULong getWord1(const NEEDS_VOLATILE double x) +{ + const NEEDS_VOLATILE uchar *ptr = reinterpret_cast(&x); + if (ByteOrder == BigEndian) { + return (ptr[4]<<24) + (ptr[5]<<16) + (ptr[6]<<8) + ptr[7]; + } else { + return (ptr[3]<<24) + (ptr[2]<<16) + (ptr[1]<<8) + ptr[0]; + } +} +inline void setWord1(NEEDS_VOLATILE double *x, ULong l) +{ + NEEDS_VOLATILE uchar *ptr = reinterpret_cast(x); + if (ByteOrder == BigEndian) { + ptr[4] = (uchar)(l>>24); + ptr[5] = (uchar)(l>>16); + ptr[6] = (uchar)(l>>8); + ptr[7] = (uchar)l; + } else { + ptr[3] = (uchar)(l>>24); + ptr[2] = (uchar)(l>>16); + ptr[1] = (uchar)(l>>8); + ptr[0] = (uchar)l; + } +} + +static inline void Storeinc(ULong *&a, const ULong &b, const ULong &c) +{ + + *a = (((unsigned short)b) << 16) | ((unsigned short)c); + ++a; +} + +/* #define P DBL_MANT_DIG */ +/* Ten_pmax = floor(P*log(2)/log(5)) */ +/* Bletch = (highest power of 2 < DBL_MAX_10_EXP) / 16 */ +/* Quick_max = floor((P-1)*log(FLT_RADIX)/log(10) - 1) */ +/* Int_max = floor(P*log(FLT_RADIX)/log(10) - 1) */ + +#if defined(IEEE_BIG_OR_LITTLE_ENDIAN) +#define Exp_shift 20 +#define Exp_shift1 20 +#define Exp_msk1 0x100000 +#define Exp_msk11 0x100000 +#define Exp_mask 0x7ff00000 +#define P 53 +#define Bias 1023 +#define IEEE_Arith +#define Emin (-1022) +#define Exp_1 0x3ff00000 +#define Exp_11 0x3ff00000 +#define Ebits 11 +#define Frac_mask 0xfffff +#define Frac_mask1 0xfffff +#define Ten_pmax 22 +#define Bletch 0x10 +#define Bndry_mask 0xfffff +#define Bndry_mask1 0xfffff +#define LSB 1 +#define Sign_bit 0x80000000 +#define Log2P 1 +#define Tiny0 0 +#define Tiny1 1 +#define Quick_max 14 +#define Int_max 14 +#define Infinite(x) (getWord0(x) == 0x7ff00000) /* sufficient test for here */ +#else +#undef Sudden_Underflow +#define Sudden_Underflow +#ifdef IBM +#define Exp_shift 24 +#define Exp_shift1 24 +#define Exp_msk1 0x1000000 +#define Exp_msk11 0x1000000 +#define Exp_mask 0x7f000000 +#define P 14 +#define Bias 65 +#define Exp_1 0x41000000 +#define Exp_11 0x41000000 +#define Ebits 8 /* exponent has 7 bits, but 8 is the right value in b2d */ +#define Frac_mask 0xffffff +#define Frac_mask1 0xffffff +#define Bletch 4 +#define Ten_pmax 22 +#define Bndry_mask 0xefffff +#define Bndry_mask1 0xffffff +#define LSB 1 +#define Sign_bit 0x80000000 +#define Log2P 4 +#define Tiny0 0x100000 +#define Tiny1 0 +#define Quick_max 14 +#define Int_max 15 +#else /* VAX */ +#define Exp_shift 23 +#define Exp_shift1 7 +#define Exp_msk1 0x80 +#define Exp_msk11 0x800000 +#define Exp_mask 0x7f80 +#define P 56 +#define Bias 129 +#define Exp_1 0x40800000 +#define Exp_11 0x4080 +#define Ebits 8 +#define Frac_mask 0x7fffff +#define Frac_mask1 0xffff007f +#define Ten_pmax 24 +#define Bletch 2 +#define Bndry_mask 0xffff007f +#define Bndry_mask1 0xffff007f +#define LSB 0x10000 +#define Sign_bit 0x8000 +#define Log2P 1 +#define Tiny0 0x80 +#define Tiny1 0 +#define Quick_max 15 +#define Int_max 15 +#endif +#endif + +#ifndef IEEE_Arith +#define ROUND_BIASED +#endif + +#ifdef RND_PRODTQUOT +#define rounded_product(a,b) a = rnd_prod(a, b) +#define rounded_quotient(a,b) a = rnd_quot(a, b) +extern double rnd_prod(double, double), rnd_quot(double, double); +#else +#define rounded_product(a,b) a *= b +#define rounded_quotient(a,b) a /= b +#endif + +#define Big0 (Frac_mask1 | Exp_msk1*(DBL_MAX_EXP+Bias-1)) +#define Big1 0xffffffff + +#ifndef Just_16 +/* When Pack_32 is not defined, we store 16 bits per 32-bit Long. + * This makes some inner loops simpler and sometimes saves work + * during multiplications, but it often seems to make things slightly + * slower. Hence the default is now to store 32 bits per Long. + */ +#ifndef Pack_32 +#define Pack_32 +#endif +#endif + +#define Kmax 15 + +struct +Bigint { + struct Bigint *next; + int k, maxwds, sign, wds; + ULong x[1]; +}; + + typedef struct Bigint Bigint; + +static Bigint *Balloc(int k) +{ + int x; + Bigint *rv; + + x = 1 << k; + rv = (Bigint *)MALLOC(sizeof(Bigint) + (x-1)*sizeof(Long)); + rv->k = k; + rv->maxwds = x; + rv->sign = rv->wds = 0; + return rv; +} + +static void Bfree(Bigint *v) +{ + free(v); +} + +#define Bcopy(x,y) memcpy((char *)&x->sign, (char *)&y->sign, \ +y->wds*sizeof(Long) + 2*sizeof(int)) + +/* multiply by m and add a */ +static Bigint *multadd(Bigint *b, int m, int a) +{ + int i, wds; + ULong *x, y; +#ifdef Pack_32 + ULong xi, z; +#endif + Bigint *b1; + + wds = b->wds; + x = b->x; + i = 0; + do { +#ifdef Pack_32 + xi = *x; + y = (xi & 0xffff) * m + a; + z = (xi >> 16) * m + (y >> 16); + a = (int)(z >> 16); + *x++ = (z << 16) + (y & 0xffff); +#else + y = *x * m + a; + a = (int)(y >> 16); + *x++ = y & 0xffff; +#endif + } + while(++i < wds); + if (a) { + if (wds >= b->maxwds) { + b1 = Balloc(b->k+1); + Bcopy(b1, b); + Bfree(b); + b = b1; + } + b->x[wds++] = a; + b->wds = wds; + } + return b; +} + +static Bigint *s2b(CONST char *s, int nd0, int nd, ULong y9) +{ + Bigint *b; + int i, k; + Long x, y; + + x = (nd + 8) / 9; + for(k = 0, y = 1; x > y; y <<= 1, k++) ; +#ifdef Pack_32 + b = Balloc(k); + b->x[0] = y9; + b->wds = 1; +#else + b = Balloc(k+1); + b->x[0] = y9 & 0xffff; + b->wds = (b->x[1] = y9 >> 16) ? 2 : 1; +#endif + + i = 9; + if (9 < nd0) { + s += 9; + do b = multadd(b, 10, *s++ - '0'); + while(++i < nd0); + s++; + } + else + s += 10; + for(; i < nd; i++) + b = multadd(b, 10, *s++ - '0'); + return b; +} + +static int hi0bits(ULong x) +{ + int k = 0; + + if (!(x & 0xffff0000)) { + k = 16; + x <<= 16; + } + if (!(x & 0xff000000)) { + k += 8; + x <<= 8; + } + if (!(x & 0xf0000000)) { + k += 4; + x <<= 4; + } + if (!(x & 0xc0000000)) { + k += 2; + x <<= 2; + } + if (!(x & 0x80000000)) { + k++; + if (!(x & 0x40000000)) + return 32; + } + return k; +} + +static int lo0bits(ULong *y) +{ + int k; + ULong x = *y; + + if (x & 7) { + if (x & 1) + return 0; + if (x & 2) { + *y = x >> 1; + return 1; + } + *y = x >> 2; + return 2; + } + k = 0; + if (!(x & 0xffff)) { + k = 16; + x >>= 16; + } + if (!(x & 0xff)) { + k += 8; + x >>= 8; + } + if (!(x & 0xf)) { + k += 4; + x >>= 4; + } + if (!(x & 0x3)) { + k += 2; + x >>= 2; + } + if (!(x & 1)) { + k++; + x >>= 1; + if (!x & 1) + return 32; + } + *y = x; + return k; +} + +static Bigint *i2b(int i) +{ + Bigint *b; + + b = Balloc(1); + b->x[0] = i; + b->wds = 1; + return b; +} + +static Bigint *mult(Bigint *a, Bigint *b) +{ + Bigint *c; + int k, wa, wb, wc; + ULong carry, y, z; + ULong *x, *xa, *xae, *xb, *xbe, *xc, *xc0; +#ifdef Pack_32 + ULong z2; +#endif + + if (a->wds < b->wds) { + c = a; + a = b; + b = c; + } + k = a->k; + wa = a->wds; + wb = b->wds; + wc = wa + wb; + if (wc > a->maxwds) + k++; + c = Balloc(k); + for(x = c->x, xa = x + wc; x < xa; x++) + *x = 0; + xa = a->x; + xae = xa + wa; + xb = b->x; + xbe = xb + wb; + xc0 = c->x; +#ifdef Pack_32 + for(; xb < xbe; xb++, xc0++) { + if ((y = *xb & 0xffff) != 0) { + x = xa; + xc = xc0; + carry = 0; + do { + z = (*x & 0xffff) * y + (*xc & 0xffff) + carry; + carry = z >> 16; + z2 = (*x++ >> 16) * y + (*xc >> 16) + carry; + carry = z2 >> 16; + Storeinc(xc, z2, z); + } + while(x < xae); + *xc = carry; + } + if ((y = *xb >> 16) != 0) { + x = xa; + xc = xc0; + carry = 0; + z2 = *xc; + do { + z = (*x & 0xffff) * y + (*xc >> 16) + carry; + carry = z >> 16; + Storeinc(xc, z, z2); + z2 = (*x++ >> 16) * y + (*xc & 0xffff) + carry; + carry = z2 >> 16; + } + while(x < xae); + *xc = z2; + } + } +#else + for(; xb < xbe; xc0++) { + if (y = *xb++) { + x = xa; + xc = xc0; + carry = 0; + do { + z = *x++ * y + *xc + carry; + carry = z >> 16; + *xc++ = z & 0xffff; + } + while(x < xae); + *xc = carry; + } + } +#endif + for(xc0 = c->x, xc = xc0 + wc; wc > 0 && !*--xc; --wc) ; + c->wds = wc; + return c; +} + +static Bigint *p5s; + +static Bigint *pow5mult(Bigint *b, int k) +{ + Bigint *b1, *p5, *p51; + int i; + static const int p05[3] = { 5, 25, 125 }; + + if ((i = k & 3) != 0) + b = multadd(b, p05[i-1], 0); + + if (!(k >>= 2)) + return b; + if (!(p5 = p5s)) { + /* first time */ + p5 = p5s = i2b(625); + p5->next = 0; + } + for(;;) { + if (k & 1) { + b1 = mult(b, p5); + Bfree(b); + b = b1; + } + if (!(k >>= 1)) + break; + if (!(p51 = p5->next)) { + p51 = p5->next = mult(p5,p5); + p51->next = 0; + } + p5 = p51; + } + return b; +} + +static Bigint *lshift(Bigint *b, int k) +{ + int i, k1, n, n1; + Bigint *b1; + ULong *x, *x1, *xe, z; + +#ifdef Pack_32 + n = k >> 5; +#else + n = k >> 4; +#endif + k1 = b->k; + n1 = n + b->wds + 1; + for(i = b->maxwds; n1 > i; i <<= 1) + k1++; + b1 = Balloc(k1); + x1 = b1->x; + for(i = 0; i < n; i++) + *x1++ = 0; + x = b->x; + xe = x + b->wds; +#ifdef Pack_32 + if (k &= 0x1f) { + k1 = 32 - k; + z = 0; + do { + *x1++ = *x << k | z; + z = *x++ >> k1; + } + while(x < xe); + if ((*x1 = z) != 0) + ++n1; + } +#else + if (k &= 0xf) { + k1 = 16 - k; + z = 0; + do { + *x1++ = *x << k & 0xffff | z; + z = *x++ >> k1; + } + while(x < xe); + if (*x1 = z) + ++n1; + } +#endif + else do + *x1++ = *x++; + while(x < xe); + b1->wds = n1 - 1; + Bfree(b); + return b1; +} + +static int cmp(Bigint *a, Bigint *b) +{ + ULong *xa, *xa0, *xb, *xb0; + int i, j; + + i = a->wds; + j = b->wds; +#ifdef BSD_QDTOA_DEBUG + if (i > 1 && !a->x[i-1]) + Bug("cmp called with a->x[a->wds-1] == 0"); + if (j > 1 && !b->x[j-1]) + Bug("cmp called with b->x[b->wds-1] == 0"); +#endif + if (i -= j) + return i; + xa0 = a->x; + xa = xa0 + j; + xb0 = b->x; + xb = xb0 + j; + for(;;) { + if (*--xa != *--xb) + return *xa < *xb ? -1 : 1; + if (xa <= xa0) + break; + } + return 0; +} + +static Bigint *diff(Bigint *a, Bigint *b) +{ + Bigint *c; + int i, wa, wb; + Long borrow, y; /* We need signed shifts here. */ + ULong *xa, *xae, *xb, *xbe, *xc; +#ifdef Pack_32 + Long z; +#endif + + i = cmp(a,b); + if (!i) { + c = Balloc(0); + c->wds = 1; + c->x[0] = 0; + return c; + } + if (i < 0) { + c = a; + a = b; + b = c; + i = 1; + } + else + i = 0; + c = Balloc(a->k); + c->sign = i; + wa = a->wds; + xa = a->x; + xae = xa + wa; + wb = b->wds; + xb = b->x; + xbe = xb + wb; + xc = c->x; + borrow = 0; +#ifdef Pack_32 + do { + y = (*xa & 0xffff) - (*xb & 0xffff) + borrow; + borrow = y >> 16; + Sign_Extend(borrow, y); + z = (*xa++ >> 16) - (*xb++ >> 16) + borrow; + borrow = z >> 16; + Sign_Extend(borrow, z); + Storeinc(xc, z, y); + } + while(xb < xbe); + while(xa < xae) { + y = (*xa & 0xffff) + borrow; + borrow = y >> 16; + Sign_Extend(borrow, y); + z = (*xa++ >> 16) + borrow; + borrow = z >> 16; + Sign_Extend(borrow, z); + Storeinc(xc, z, y); + } +#else + do { + y = *xa++ - *xb++ + borrow; + borrow = y >> 16; + Sign_Extend(borrow, y); + *xc++ = y & 0xffff; + } + while(xb < xbe); + while(xa < xae) { + y = *xa++ + borrow; + borrow = y >> 16; + Sign_Extend(borrow, y); + *xc++ = y & 0xffff; + } +#endif + while(!*--xc) + wa--; + c->wds = wa; + return c; +} + +static double ulp(double x) +{ + Long L; + double a; + + L = (getWord0(x) & Exp_mask) - (P-1)*Exp_msk1; +#ifndef Sudden_Underflow + if (L > 0) { +#endif +#ifdef IBM + L |= Exp_msk1 >> 4; +#endif + setWord0(&a, L); + setWord1(&a, 0); +#ifndef Sudden_Underflow + } + else { + L = -L >> Exp_shift; + if (L < Exp_shift) { + setWord0(&a, 0x80000 >> L); + setWord1(&a, 0); + } + else { + setWord0(&a, 0); + L -= Exp_shift; + setWord1(&a, L >= 31 ? 1U : 1U << (31 - L)); + } + } +#endif + return a; +} + +static double b2d(Bigint *a, int *e) +{ + ULong *xa, *xa0, w, y, z; + int k; + double d; + + xa0 = a->x; + xa = xa0 + a->wds; + y = *--xa; +#ifdef BSD_QDTOA_DEBUG + if (!y) Bug("zero y in b2d"); +#endif + k = hi0bits(y); + *e = 32 - k; +#ifdef Pack_32 + if (k < Ebits) { + setWord0(&d, Exp_1 | y >> (Ebits - k)); + w = xa > xa0 ? *--xa : 0; + setWord1(&d, y << ((32-Ebits) + k) | w >> (Ebits - k)); + goto ret_d; + } + z = xa > xa0 ? *--xa : 0; + if (k -= Ebits) { + setWord0(&d, Exp_1 | y << k | z >> (32 - k)); + y = xa > xa0 ? *--xa : 0; + setWord1(&d, z << k | y >> (32 - k)); + } + else { + setWord0(&d, Exp_1 | y); + setWord1(&d, z); + } +#else + if (k < Ebits + 16) { + z = xa > xa0 ? *--xa : 0; + setWord0(&d, Exp_1 | y << k - Ebits | z >> Ebits + 16 - k); + w = xa > xa0 ? *--xa : 0; + y = xa > xa0 ? *--xa : 0; + setWord1(&d, z << k + 16 - Ebits | w << k - Ebits | y >> 16 + Ebits - k); + goto ret_d; + } + z = xa > xa0 ? *--xa : 0; + w = xa > xa0 ? *--xa : 0; + k -= Ebits + 16; + setWord0(&d, Exp_1 | y << k + 16 | z << k | w >> 16 - k); + y = xa > xa0 ? *--xa : 0; + setWord1(&d, w << k + 16 | y << k); +#endif + ret_d: + return d; +} + +static Bigint *d2b(double d, int *e, int *bits) +{ + Bigint *b; + int de, i, k; + ULong *x, y, z; + +#ifdef Pack_32 + b = Balloc(1); +#else + b = Balloc(2); +#endif + x = b->x; + + z = getWord0(d) & Frac_mask; + setWord0(&d, getWord0(d) & 0x7fffffff); /* clear sign bit, which we ignore */ +#ifdef Sudden_Underflow + de = (int)(getWord0(d) >> Exp_shift); +#ifndef IBM + z |= Exp_msk11; +#endif +#else + if ((de = (int)(getWord0(d) >> Exp_shift)) != 0) + z |= Exp_msk1; +#endif +#ifdef Pack_32 + if ((y = getWord1(d)) != 0) { + if ((k = lo0bits(&y)) != 0) { + x[0] = y | z << (32 - k); + z >>= k; + } + else + x[0] = y; + i = b->wds = (x[1] = z) ? 2 : 1; + } + else { +#ifdef BSD_QDTOA_DEBUG + if (!z) + Bug("Zero passed to d2b"); +#endif + k = lo0bits(&z); + x[0] = z; + i = b->wds = 1; + k += 32; + } +#else + if (y = getWord1(d)) { + if (k = lo0bits(&y)) + if (k >= 16) { + x[0] = y | z << 32 - k & 0xffff; + x[1] = z >> k - 16 & 0xffff; + x[2] = z >> k; + i = 2; + } + else { + x[0] = y & 0xffff; + x[1] = y >> 16 | z << 16 - k & 0xffff; + x[2] = z >> k & 0xffff; + x[3] = z >> k+16; + i = 3; + } + else { + x[0] = y & 0xffff; + x[1] = y >> 16; + x[2] = z & 0xffff; + x[3] = z >> 16; + i = 3; + } + } + else { +#ifdef BSD_QDTOA_DEBUG + if (!z) + Bug("Zero passed to d2b"); +#endif + k = lo0bits(&z); + if (k >= 16) { + x[0] = z; + i = 0; + } + else { + x[0] = z & 0xffff; + x[1] = z >> 16; + i = 1; + } + k += 32; + } + while(!x[i]) + --i; + b->wds = i + 1; +#endif +#ifndef Sudden_Underflow + if (de) { +#endif +#ifdef IBM + *e = (de - Bias - (P-1) << 2) + k; + *bits = 4*P + 8 - k - hi0bits(getWord0(d) & Frac_mask); +#else + *e = de - Bias - (P-1) + k; + *bits = P - k; +#endif +#ifndef Sudden_Underflow + } + else { + *e = de - Bias - (P-1) + 1 + k; +#ifdef Pack_32 + *bits = 32*i - hi0bits(x[i-1]); +#else + *bits = (i+2)*16 - hi0bits(x[i]); +#endif + } +#endif + return b; +} + +static double ratio(Bigint *a, Bigint *b) +{ + double da, db; + int k, ka, kb; + + da = b2d(a, &ka); + db = b2d(b, &kb); +#ifdef Pack_32 + k = ka - kb + 32*(a->wds - b->wds); +#else + k = ka - kb + 16*(a->wds - b->wds); +#endif +#ifdef IBM + if (k > 0) { + setWord0(&da, getWord0(da) + (k >> 2)*Exp_msk1); + if (k &= 3) + da *= 1 << k; + } + else { + k = -k; + setWord0(&db, getWord0(db) + (k >> 2)*Exp_msk1); + if (k &= 3) + db *= 1 << k; + } +#else + if (k > 0) + setWord0(&da, getWord0(da) + k*Exp_msk1); + else { + k = -k; + setWord0(&db, getWord0(db) + k*Exp_msk1); + } +#endif + return da / db; +} + +static CONST double tens[] = { + 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, + 1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19, + 1e20, 1e21, 1e22 +#ifdef VAX + , 1e23, 1e24 +#endif +}; + +#ifdef IEEE_Arith +static CONST double bigtens[] = { 1e16, 1e32, 1e64, 1e128, 1e256 }; +static CONST double tinytens[] = { 1e-16, 1e-32, 1e-64, 1e-128, 1e-256 }; +#define n_bigtens 5 +#else +#ifdef IBM +static CONST double bigtens[] = { 1e16, 1e32, 1e64 }; +static CONST double tinytens[] = { 1e-16, 1e-32, 1e-64 }; +#define n_bigtens 3 +#else +static CONST double bigtens[] = { 1e16, 1e32 }; +static CONST double tinytens[] = { 1e-16, 1e-32 }; +#define n_bigtens 2 +#endif +#endif + +/* + The pre-release gcc3.3 shipped with SuSE 8.2 has a bug which causes + the comparison 1e-100 == 0.0 to return true. As a workaround, we + compare it to a global variable containing 0.0, which produces + correct assembler output. + + ### consider detecting the broken compilers and using the static + ### double for these, and use a #define for all working compilers +*/ +static double g_double_zero = 0.0; + +static double qstrtod(CONST char *s00, CONST char **se, bool *ok) +{ + int bb2, bb5, bbe, bd2, bd5, bbbits, bs2, c, dsign, + e, e1, esign, i, j, k, nd, nd0, nf, nz, nz0, sign; + CONST char *s, *s0, *s1; + double aadj, aadj1, adj, rv, rv0; + Long L; + ULong y, z; + Bigint *bb1, *bd0; + Bigint *bb = NULL, *bd = NULL, *bs = NULL, *delta = NULL;/* pacify gcc */ + + /* + #ifndef KR_headers + CONST char decimal_point = localeconv()->decimal_point[0]; + #else + CONST char decimal_point = '.'; + #endif */ + if (ok != 0) + *ok = TRUE; + + CONST char decimal_point = '.'; + + sign = nz0 = nz = 0; + rv = 0.; + + + for(s = s00; isspace((unsigned char) *s); s++) + ; + + if (*s == '-') { + sign = 1; + s++; + } else if (*s == '+') { + s++; + } + + if (*s == '\0') { + s = s00; + goto ret; + } + + if (*s == '0') { + nz0 = 1; + while(*++s == '0') ; + if (!*s) + goto ret; + } + s0 = s; + y = z = 0; + for(nd = nf = 0; (c = *s) >= '0' && c <= '9'; nd++, s++) + if (nd < 9) + y = 10*y + c - '0'; + else if (nd < 16) + z = 10*z + c - '0'; + nd0 = nd; + if (c == decimal_point) { + c = *++s; + if (!nd) { + for(; c == '0'; c = *++s) + nz++; + if (c > '0' && c <= '9') { + s0 = s; + nf += nz; + nz = 0; + goto have_dig; + } + goto dig_done; + } + for(; c >= '0' && c <= '9'; c = *++s) { + have_dig: + nz++; + if (c -= '0') { + nf += nz; + for(i = 1; i < nz; i++) + if (nd++ < 9) + y *= 10; + else if (nd <= DBL_DIG + 1) + z *= 10; + if (nd++ < 9) + y = 10*y + c; + else if (nd <= DBL_DIG + 1) + z = 10*z + c; + nz = 0; + } + } + } + dig_done: + e = 0; + if (c == 'e' || c == 'E') { + if (!nd && !nz && !nz0) { + s = s00; + goto ret; + } + s00 = s; + esign = 0; + switch(c = *++s) { + case '-': + esign = 1; + case '+': + c = *++s; + } + if (c >= '0' && c <= '9') { + while(c == '0') + c = *++s; + if (c > '0' && c <= '9') { + L = c - '0'; + s1 = s; + while((c = *++s) >= '0' && c <= '9') + L = 10*L + c - '0'; + if (s - s1 > 8 || L > 19999) + /* Avoid confusion from exponents + * so large that e might overflow. + */ + e = 19999; /* safe for 16 bit ints */ + else + e = (int)L; + if (esign) + e = -e; + } + else + e = 0; + } + else + s = s00; + } + if (!nd) { + if (!nz && !nz0) + s = s00; + goto ret; + } + e1 = e -= nf; + + /* Now we have nd0 digits, starting at s0, followed by a + * decimal point, followed by nd-nd0 digits. The number we're + * after is the integer represented by those digits times + * 10**e */ + + if (!nd0) + nd0 = nd; + k = nd < DBL_DIG + 1 ? nd : DBL_DIG + 1; + rv = y; + if (k > 9) + rv = tens[k - 9] * rv + z; + bd0 = 0; + if (nd <= DBL_DIG +#ifndef RND_PRODTQUOT + && FLT_ROUNDS == 1 +#endif + ) { + if (!e) + goto ret; + if (e > 0) { + if (e <= Ten_pmax) { +#ifdef VAX + goto vax_ovfl_check; +#else + /* rv = */ rounded_product(rv, tens[e]); + goto ret; +#endif + } + i = DBL_DIG - nd; + if (e <= Ten_pmax + i) { + /* A fancier test would sometimes let us do + * this for larger i values. + */ + e -= i; + rv *= tens[i]; +#ifdef VAX + /* VAX exponent range is so narrow we must + * worry about overflow here... + */ + vax_ovfl_check: + setWord0(&rv, getWord0(rv) - P*Exp_msk1); + /* rv = */ rounded_product(rv, tens[e]); + if ((getWord0(rv) & Exp_mask) + > Exp_msk1*(DBL_MAX_EXP+Bias-1-P)) + goto ovfl; + setWord0(&rv, getWord0(rv) + P*Exp_msk1); +#else + /* rv = */ rounded_product(rv, tens[e]); +#endif + goto ret; + } + } +#ifndef Inaccurate_Divide + else if (e >= -Ten_pmax) { + /* rv = */ rounded_quotient(rv, tens[-e]); + goto ret; + } +#endif + } + e1 += nd - k; + + /* Get starting approximation = rv * 10**e1 */ + + if (e1 > 0) { + if ((i = e1 & 15) != 0) + rv *= tens[i]; + if (e1 &= ~15) { + if (e1 > DBL_MAX_10_EXP) { + ovfl: + // errno = ERANGE; + if (ok != 0) + *ok = FALSE; +#ifdef __STDC__ + rv = HUGE_VAL; +#else + /* Can't trust HUGE_VAL */ +#ifdef IEEE_Arith + setWord0(&rv, Exp_mask); + setWord1(&rv, 0); +#else + setWord0(&rv, Big0); + setWord1(&rv, Big1); +#endif +#endif + if (bd0) + goto retfree; + goto ret; + } + if (e1 >>= 4) { + for(j = 0; e1 > 1; j++, e1 >>= 1) + if (e1 & 1) + rv *= bigtens[j]; + /* The last multiplication could overflow. */ + setWord0(&rv, getWord0(rv) - P*Exp_msk1); + rv *= bigtens[j]; + if ((z = getWord0(rv) & Exp_mask) + > Exp_msk1*(DBL_MAX_EXP+Bias-P)) + goto ovfl; + if (z > Exp_msk1*(DBL_MAX_EXP+Bias-1-P)) { + /* set to largest number */ + /* (Can't trust DBL_MAX) */ + setWord0(&rv, Big0); + setWord1(&rv, Big1); + } + else + setWord0(&rv, getWord0(rv) + P*Exp_msk1); + } + + } + } + else if (e1 < 0) { + e1 = -e1; + if ((i = e1 & 15) != 0) + rv /= tens[i]; + if (e1 &= ~15) { + e1 >>= 4; + if (e1 >= 1 << n_bigtens) + goto undfl; + for(j = 0; e1 > 1; j++, e1 >>= 1) + if (e1 & 1) + rv *= tinytens[j]; + /* The last multiplication could underflow. */ + rv0 = rv; + rv *= tinytens[j]; + if (rv == g_double_zero) + { + rv = 2.*rv0; + rv *= tinytens[j]; + if (rv == g_double_zero) + { + undfl: + rv = 0.; + // errno = ERANGE; + if (ok != 0) + *ok = FALSE; + if (bd0) + goto retfree; + goto ret; + } + setWord0(&rv, Tiny0); + setWord1(&rv, Tiny1); + /* The refinement below will clean + * this approximation up. + */ + } + } + } + + /* Now the hard part -- adjusting rv to the correct value.*/ + + /* Put digits into bd: true value = bd * 10^e */ + + bd0 = s2b(s0, nd0, nd, y); + + for(;;) { + bd = Balloc(bd0->k); + Bcopy(bd, bd0); + bb = d2b(rv, &bbe, &bbbits); /* rv = bb * 2^bbe */ + bs = i2b(1); + + if (e >= 0) { + bb2 = bb5 = 0; + bd2 = bd5 = e; + } + else { + bb2 = bb5 = -e; + bd2 = bd5 = 0; + } + if (bbe >= 0) + bb2 += bbe; + else + bd2 -= bbe; + bs2 = bb2; +#ifdef Sudden_Underflow +#ifdef IBM + j = 1 + 4*P - 3 - bbbits + ((bbe + bbbits - 1) & 3); +#else + j = P + 1 - bbbits; +#endif +#else + i = bbe + bbbits - 1; /* logb(rv) */ + if (i < Emin) /* denormal */ + j = bbe + (P-Emin); + else + j = P + 1 - bbbits; +#endif + bb2 += j; + bd2 += j; + i = bb2 < bd2 ? bb2 : bd2; + if (i > bs2) + i = bs2; + if (i > 0) { + bb2 -= i; + bd2 -= i; + bs2 -= i; + } + if (bb5 > 0) { + bs = pow5mult(bs, bb5); + bb1 = mult(bs, bb); + Bfree(bb); + bb = bb1; + } + if (bb2 > 0) + bb = lshift(bb, bb2); + if (bd5 > 0) + bd = pow5mult(bd, bd5); + if (bd2 > 0) + bd = lshift(bd, bd2); + if (bs2 > 0) + bs = lshift(bs, bs2); + delta = diff(bb, bd); + dsign = delta->sign; + delta->sign = 0; + i = cmp(delta, bs); + if (i < 0) { + /* Error is less than half an ulp -- check for + * special case of mantissa a power of two. + */ + if (dsign || getWord1(rv) || getWord0(rv) & Bndry_mask) + break; + delta = lshift(delta,Log2P); + if (cmp(delta, bs) > 0) + goto drop_down; + break; + } + if (i == 0) { + /* exactly half-way between */ + if (dsign) { + if ((getWord0(rv) & Bndry_mask1) == Bndry_mask1 + && getWord1(rv) == 0xffffffff) { + /*boundary case -- increment exponent*/ + setWord0(&rv, (getWord0(rv) & Exp_mask) + + Exp_msk1 +#ifdef IBM + | Exp_msk1 >> 4 +#endif + ); + setWord1(&rv, 0); + break; + } + } + else if (!(getWord0(rv) & Bndry_mask) && !getWord1(rv)) { + drop_down: + /* boundary case -- decrement exponent */ +#ifdef Sudden_Underflow + L = getWord0(rv) & Exp_mask; +#ifdef IBM + if (L < Exp_msk1) +#else + if (L <= Exp_msk1) +#endif + goto undfl; + L -= Exp_msk1; +#else + L = (getWord0(rv) & Exp_mask) - Exp_msk1; +#endif + setWord0(&rv, L | Bndry_mask1); + setWord1(&rv, 0xffffffff); +#ifdef IBM + goto cont; +#else + break; +#endif + } +#ifndef ROUND_BIASED + if (!(getWord1(rv) & LSB)) + break; +#endif + if (dsign) + rv += ulp(rv); +#ifndef ROUND_BIASED + else { + rv -= ulp(rv); +#ifndef Sudden_Underflow + if (rv == g_double_zero) + goto undfl; +#endif + } +#endif + break; + } + if ((aadj = ratio(delta, bs)) <= 2.) { + if (dsign) + aadj = aadj1 = 1.; + else if (getWord1(rv) || getWord0(rv) & Bndry_mask) { +#ifndef Sudden_Underflow + if (getWord1(rv) == Tiny1 && !getWord0(rv)) + goto undfl; +#endif + aadj = 1.; + aadj1 = -1.; + } + else { + /* special case -- power of FLT_RADIX to be */ + /* rounded down... */ + + if (aadj < 2./FLT_RADIX) + aadj = 1./FLT_RADIX; + else + aadj *= 0.5; + aadj1 = -aadj; + } + } + else { + aadj *= 0.5; + aadj1 = dsign ? aadj : -aadj; +#ifdef Check_FLT_ROUNDS + switch(FLT_ROUNDS) { + case 2: /* towards +infinity */ + aadj1 -= 0.5; + break; + case 0: /* towards 0 */ + case 3: /* towards -infinity */ + aadj1 += 0.5; + } +#else + if (FLT_ROUNDS == 0) + aadj1 += 0.5; +#endif + } + y = getWord0(rv) & Exp_mask; + + /* Check for overflow */ + + if (y == Exp_msk1*(DBL_MAX_EXP+Bias-1)) { + rv0 = rv; + setWord0(&rv, getWord0(rv) - P*Exp_msk1); + adj = aadj1 * ulp(rv); + rv += adj; + if ((getWord0(rv) & Exp_mask) >= + Exp_msk1*(DBL_MAX_EXP+Bias-P)) { + if (getWord0(rv0) == Big0 && getWord1(rv0) == Big1) + goto ovfl; + setWord0(&rv, Big0); + setWord1(&rv, Big1); + goto cont; + } + else + setWord0(&rv, getWord0(rv) + P*Exp_msk1); + } + else { +#ifdef Sudden_Underflow + if ((getWord0(rv) & Exp_mask) <= P*Exp_msk1) { + rv0 = rv; + setWord0(&rv, getWord0(rv) + P*Exp_msk1); + adj = aadj1 * ulp(rv); + rv += adj; +#ifdef IBM + if ((getWord0(rv) & Exp_mask) < P*Exp_msk1) +#else + if ((getWord0(rv) & Exp_mask) <= P*Exp_msk1) +#endif + { + if (getWord0(rv0) == Tiny0 + && getWord1(rv0) == Tiny1) + goto undfl; + setWord0(&rv, Tiny0); + setWord1(&rv, Tiny1); + goto cont; + } + else + setWord0(&rv, getWord0(rv) - P*Exp_msk1); + } + else { + adj = aadj1 * ulp(rv); + rv += adj; + } +#else + /* Compute adj so that the IEEE rounding rules will + * correctly round rv + adj in some half-way cases. + * If rv * ulp(rv) is denormalized (i.e., + * y <= (P-1)*Exp_msk1), we must adjust aadj to avoid + * trouble from bits lost to denormalization; + * example: 1.2e-307 . + */ + if (y <= (P-1)*Exp_msk1 && aadj >= 1.) { + aadj1 = (double)(int)(aadj + 0.5); + if (!dsign) + aadj1 = -aadj1; + } + adj = aadj1 * ulp(rv); + rv += adj; +#endif + } + z = getWord0(rv) & Exp_mask; + if (y == z) { + /* Can we stop now? */ + L = (Long) aadj; + aadj -= L; + /* The tolerances below are conservative. */ + if (dsign || getWord1(rv) || getWord0(rv) & Bndry_mask) { + if (aadj < .4999999 || aadj > .5000001) + break; + } + else if (aadj < .4999999/FLT_RADIX) + break; + } + cont: + Bfree(bb); + Bfree(bd); + Bfree(bs); + Bfree(delta); + } + retfree: + Bfree(bb); + Bfree(bd); + Bfree(bs); + Bfree(bd0); + Bfree(delta); + ret: + if (se) + *se = (char *)s; + return sign ? -rv : rv; +} + +static int quorem(Bigint *b, Bigint *S) +{ + int n; + Long borrow, y; + ULong carry, q, ys; + ULong *bx, *bxe, *sx, *sxe; +#ifdef Pack_32 + Long z; + ULong si, zs; +#endif + + n = S->wds; +#ifdef BSD_QDTOA_DEBUG + /*debug*/ if (b->wds > n) + /*debug*/ Bug("oversize b in quorem"); +#endif + if (b->wds < n) + return 0; + sx = S->x; + sxe = sx + --n; + bx = b->x; + bxe = bx + n; + q = *bxe / (*sxe + 1); /* ensure q <= true quotient */ +#ifdef BSD_QDTOA_DEBUG + /*debug*/ if (q > 9) + /*debug*/ Bug("oversized quotient in quorem"); +#endif + if (q) { + borrow = 0; + carry = 0; + do { +#ifdef Pack_32 + si = *sx++; + ys = (si & 0xffff) * q + carry; + zs = (si >> 16) * q + (ys >> 16); + carry = zs >> 16; + y = (*bx & 0xffff) - (ys & 0xffff) + borrow; + borrow = y >> 16; + Sign_Extend(borrow, y); + z = (*bx >> 16) - (zs & 0xffff) + borrow; + borrow = z >> 16; + Sign_Extend(borrow, z); + Storeinc(bx, z, y); +#else + ys = *sx++ * q + carry; + carry = ys >> 16; + y = *bx - (ys & 0xffff) + borrow; + borrow = y >> 16; + Sign_Extend(borrow, y); + *bx++ = y & 0xffff; +#endif + } + while(sx <= sxe); + if (!*bxe) { + bx = b->x; + while(--bxe > bx && !*bxe) + --n; + b->wds = n; + } + } + if (cmp(b, S) >= 0) { + q++; + borrow = 0; + carry = 0; + bx = b->x; + sx = S->x; + do { +#ifdef Pack_32 + si = *sx++; + ys = (si & 0xffff) + carry; + zs = (si >> 16) + (ys >> 16); + carry = zs >> 16; + y = (*bx & 0xffff) - (ys & 0xffff) + borrow; + borrow = y >> 16; + Sign_Extend(borrow, y); + z = (*bx >> 16) - (zs & 0xffff) + borrow; + borrow = z >> 16; + Sign_Extend(borrow, z); + Storeinc(bx, z, y); +#else + ys = *sx++ + carry; + carry = ys >> 16; + y = *bx - (ys & 0xffff) + borrow; + borrow = y >> 16; + Sign_Extend(borrow, y); + *bx++ = y & 0xffff; +#endif + } + while(sx <= sxe); + bx = b->x; + bxe = bx + n; + if (!*bxe) { + while(--bxe > bx && !*bxe) + --n; + b->wds = n; + } + } + return q; +} + +/* dtoa for IEEE arithmetic (dmg): convert double to ASCII string. + * + * Inspired by "How to Print Floating-Point Numbers Accurately" by + * Guy L. Steele, Jr. and Jon L. White [Proc. ACM SIGPLAN '90, pp. 92-101]. + * + * Modifications: + * 1. Rather than iterating, we use a simple numeric overestimate + * to determine k = floor(log10(d)). We scale relevant + * quantities using O(log2(k)) rather than O(k) multiplications. + * 2. For some modes > 2 (corresponding to ecvt and fcvt), we don't + * try to generate digits strictly left to right. Instead, we + * compute with fewer bits and propagate the carry if necessary + * when rounding the final digit up. This is often faster. + * 3. Under the assumption that input will be rounded nearest, + * mode 0 renders 1e23 as 1e23 rather than 9.999999999999999e22. + * That is, we allow equality in stopping tests when the + * round-nearest rule will give the same floating-point value + * as would satisfaction of the stopping test with strict + * inequality. + * 4. We remove common factors of powers of 2 from relevant + * quantities. + * 5. When converting floating-point integers less than 1e16, + * we use floating-point arithmetic rather than resorting + * to multiple-precision integers. + * 6. When asked to produce fewer than 15 digits, we first try + * to get by with floating-point arithmetic; we resort to + * multiple-precision integer arithmetic only if we cannot + * guarantee that the floating-point calculation has given + * the correctly rounded result. For k requested digits and + * "uniformly" distributed input, the probability is + * something like 10^(k-15) that we must resort to the Long + * calculation. + */ + + +/* This actually sometimes returns a pointer to a string literal + cast to a char*. Do NOT try to modify the return value. */ + +static char *qdtoa ( double d, int mode, int ndigits, int *decpt, int *sign, char **rve, char **resultp) +{ + // Some values of the floating-point control word can cause _qdtoa to crash with an underflow. + // We set a safe value here. +#ifdef Q_OS_WIN +#ifndef Q_CC_BOR + unsigned int oldbits = _control87(0, 0); +#ifndef _M_X64 //x64 does not support precition control + _control87(0x9001F, 0xFFFFF); +#else + _control87(0x9001F, _MCW_DN|_MCW_EM|_MCW_RC); +#endif //_M_X64 +#endif +#endif + +#ifdef Q_OS_LINUX + fenv_t envp; + feholdexcept(&envp); +#endif + + char *s = _qdtoa(d, mode, ndigits, decpt, sign, rve, resultp); + +#ifdef Q_OS_WIN +#ifndef Q_CC_BOR + _clear87(); +#ifndef _M_X64 + _control87(oldbits, 0xFFFFF); +#else + _control87(oldbits, _MCW_DN|_MCW_EM|_MCW_RC); +#endif //_M_X64 +#endif +#endif + +#ifdef Q_OS_LINUX + fesetenv(&envp); +#endif + + return s; +} + +static char *_qdtoa( NEEDS_VOLATILE double d, int mode, int ndigits, int *decpt, int *sign, char **rve, char **resultp) +{ + /* + Arguments ndigits, decpt, sign are similar to those + of ecvt and fcvt; trailing zeros are suppressed from + the returned string. If not null, *rve is set to point + to the end of the return value. If d is +-Infinity or NaN, + then *decpt is set to 9999. + + mode: + 0 ==> shortest string that yields d when read in + and rounded to nearest. + 1 ==> like 0, but with Steele & White stopping rule; + e.g. with IEEE P754 arithmetic , mode 0 gives + 1e23 whereas mode 1 gives 9.999999999999999e22. + 2 ==> max(1,ndigits) significant digits. This gives a + return value similar to that of ecvt, except + that trailing zeros are suppressed. + 3 ==> through ndigits past the decimal point. This + gives a return value similar to that from fcvt, + except that trailing zeros are suppressed, and + ndigits can be negative. + 4-9 should give the same return values as 2-3, i.e., + 4 <= mode <= 9 ==> same return as mode + 2 + (mode & 1). These modes are mainly for + debugging; often they run slower but sometimes + faster than modes 2-3. + 4,5,8,9 ==> left-to-right digit generation. + 6-9 ==> don't try fast floating-point estimate + (if applicable). + + Values of mode other than 0-9 are treated as mode 0. + + Sufficient space is allocated to the return value + to hold the suppressed trailing zeros. + */ + + int bbits, b2, b5, be, dig, i, ieps, ilim0, + j, j1, k, k0, k_check, leftright, m2, m5, s2, s5, + try_tquick; + int ilim = 0, ilim1 = 0, spec_case = 0; /* pacify gcc */ + Long L; +#ifndef Sudden_Underflow + int denorm; + ULong x; +#endif + Bigint *b, *b1, *delta, *mhi, *S; + Bigint *mlo = NULL; /* pacify gcc */ + double d2; + double ds, eps; + char *s, *s0; + + if (getWord0(d) & Sign_bit) { + /* set sign for everything, including 0's and NaNs */ + *sign = 1; + setWord0(&d, getWord0(d) & ~Sign_bit); /* clear sign bit */ + } + else + *sign = 0; + +#if defined(IEEE_Arith) + defined(VAX) +#ifdef IEEE_Arith + if ((getWord0(d) & Exp_mask) == Exp_mask) +#else + if (getWord0(d) == 0x8000) +#endif + { + /* Infinity or NaN */ + *decpt = 9999; + s = +#ifdef IEEE_Arith + !getWord1(d) && !(getWord0(d) & 0xfffff) ? (char*)"Infinity" : +#endif + (char*)"NaN"; + if (rve) + *rve = +#ifdef IEEE_Arith + s[3] ? s + 8 : +#endif + s + 3; + return s; + } +#endif +#ifdef IBM + d += 0; /* normalize */ +#endif + if (d == g_double_zero) + { + *decpt = 1; + s = (char*) "0"; + if (rve) + *rve = s + 1; + return s; + } + + b = d2b(d, &be, &bbits); +#ifdef Sudden_Underflow + i = (int)(getWord0(d) >> Exp_shift1 & (Exp_mask>>Exp_shift1)); +#else + if ((i = (int)(getWord0(d) >> Exp_shift1 & (Exp_mask>>Exp_shift1))) != 0) { +#endif + d2 = d; + setWord0(&d2, getWord0(d2) & Frac_mask1); + setWord0(&d2, getWord0(d2) | Exp_11); +#ifdef IBM + if (j = 11 - hi0bits(getWord0(d2) & Frac_mask)) + d2 /= 1 << j; +#endif + + /* log(x) ~=~ log(1.5) + (x-1.5)/1.5 + * log10(x) = log(x) / log(10) + * ~=~ log(1.5)/log(10) + (x-1.5)/(1.5*log(10)) + * log10(d) = (i-Bias)*log(2)/log(10) + log10(d2) + * + * This suggests computing an approximation k to log10(d) by + * + * k = (i - Bias)*0.301029995663981 + * + ( (d2-1.5)*0.289529654602168 + 0.176091259055681 ); + * + * We want k to be too large rather than too small. + * The error in the first-order Taylor series approximation + * is in our favor, so we just round up the constant enough + * to compensate for any error in the multiplication of + * (i - Bias) by 0.301029995663981; since |i - Bias| <= 1077, + * and 1077 * 0.30103 * 2^-52 ~=~ 7.2e-14, + * adding 1e-13 to the constant term more than suffices. + * Hence we adjust the constant term to 0.1760912590558. + * (We could get a more accurate k by invoking log10, + * but this is probably not worthwhile.) + */ + + i -= Bias; +#ifdef IBM + i <<= 2; + i += j; +#endif +#ifndef Sudden_Underflow + denorm = 0; + } + else { + /* d is denormalized */ + + i = bbits + be + (Bias + (P-1) - 1); + x = i > 32 ? getWord0(d) << (64 - i) | getWord1(d) >> (i - 32) + : getWord1(d) << (32 - i); + d2 = x; + setWord0(&d2, getWord0(d2) - 31*Exp_msk1); /* adjust exponent */ + i -= (Bias + (P-1) - 1) + 1; + denorm = 1; + } +#endif + ds = (d2-1.5)*0.289529654602168 + 0.1760912590558 + i*0.301029995663981; + k = (int)ds; + if (ds < 0. && ds != k) + k--; /* want k = floor(ds) */ + k_check = 1; + if (k >= 0 && k <= Ten_pmax) { + if (d < tens[k]) + k--; + k_check = 0; + } + j = bbits - i - 1; + if (j >= 0) { + b2 = 0; + s2 = j; + } + else { + b2 = -j; + s2 = 0; + } + if (k >= 0) { + b5 = 0; + s5 = k; + s2 += k; + } + else { + b2 -= k; + b5 = -k; + s5 = 0; + } + if (mode < 0 || mode > 9) + mode = 0; + try_tquick = 1; + if (mode > 5) { + mode -= 4; + try_tquick = 0; + } + leftright = 1; + switch(mode) { + case 0: + case 1: + ilim = ilim1 = -1; + i = 18; + ndigits = 0; + break; + case 2: + leftright = 0; + /* no break */ + case 4: + if (ndigits <= 0) + ndigits = 1; + ilim = ilim1 = i = ndigits; + break; + case 3: + leftright = 0; + /* no break */ + case 5: + i = ndigits + k + 1; + ilim = i; + ilim1 = i - 1; + if (i <= 0) + i = 1; + } + *resultp = (char *) malloc(i + 1); + s = s0 = *resultp; + + if (ilim >= 0 && ilim <= Quick_max && try_tquick) { + + /* Try to get by with floating-point arithmetic. */ + + i = 0; + d2 = d; + k0 = k; + ilim0 = ilim; + ieps = 2; /* conservative */ + if (k > 0) { + ds = tens[k&0xf]; + j = k >> 4; + if (j & Bletch) { + /* prevent overflows */ + j &= Bletch - 1; + d /= bigtens[n_bigtens-1]; + ieps++; + } + for(; j; j >>= 1, i++) + if (j & 1) { + ieps++; + ds *= bigtens[i]; + } + d /= ds; + } + else if ((j1 = -k) != 0) { + d *= tens[j1 & 0xf]; + for(j = j1 >> 4; j; j >>= 1, i++) + if (j & 1) { + ieps++; + d *= bigtens[i]; + } + } + if (k_check && d < 1. && ilim > 0) { + if (ilim1 <= 0) + goto fast_failed; + ilim = ilim1; + k--; + d *= 10.; + ieps++; + } + eps = ieps*d + 7.; + setWord0(&eps, getWord0(eps) - (P-1)*Exp_msk1); + if (ilim == 0) { + S = mhi = 0; + d -= 5.; + if (d > eps) + goto one_digit; + if (d < -eps) + goto no_digits; + goto fast_failed; + } +#ifndef No_leftright + if (leftright) { + /* Use Steele & White method of only + * generating digits needed. + */ + eps = 0.5/tens[ilim-1] - eps; + for(i = 0;;) { + L = (Long)d; + d -= L; + *s++ = '0' + (int)L; + if (d < eps) + goto ret1; + if (1. - d < eps) + goto bump_up; + if (++i >= ilim) + break; + eps *= 10.; + d *= 10.; + } + } + else { +#endif + /* Generate ilim digits, then fix them up. */ + eps *= tens[ilim-1]; + for(i = 1;; i++, d *= 10.) { + L = (Long)d; + d -= L; + *s++ = '0' + (int)L; + if (i == ilim) { + if (d > 0.5 + eps) + goto bump_up; + else if (d < 0.5 - eps) { + while(*--s == '0'); + s++; + goto ret1; + } + break; + } + } +#ifndef No_leftright + } +#endif + fast_failed: + s = s0; + d = d2; + k = k0; + ilim = ilim0; + } + + /* Do we have a "small" integer? */ + + if (be >= 0 && k <= Int_max) { + /* Yes. */ + ds = tens[k]; + if (ndigits < 0 && ilim <= 0) { + S = mhi = 0; + if (ilim < 0 || d <= 5*ds) + goto no_digits; + goto one_digit; + } + for(i = 1;; i++) { + L = (Long)(d / ds); + d -= L*ds; +#ifdef Check_FLT_ROUNDS + /* If FLT_ROUNDS == 2, L will usually be high by 1 */ + if (d < 0) { + L--; + d += ds; + } +#endif + *s++ = '0' + (int)L; + if (i == ilim) { + d += d; + if (d > ds || (d == ds && L & 1)) { + bump_up: + while(*--s == '9') + if (s == s0) { + k++; + *s = '0'; + break; + } + ++*s++; + } + break; + } + if ((d *= 10.) == g_double_zero) + break; + } + goto ret1; + } + + m2 = b2; + m5 = b5; + mhi = mlo = 0; + if (leftright) { + if (mode < 2) { + i = +#ifndef Sudden_Underflow + denorm ? be + (Bias + (P-1) - 1 + 1) : +#endif +#ifdef IBM + 1 + 4*P - 3 - bbits + ((bbits + be - 1) & 3); +#else + 1 + P - bbits; +#endif + } + else { + j = ilim - 1; + if (m5 >= j) + m5 -= j; + else { + s5 += j -= m5; + b5 += j; + m5 = 0; + } + if ((i = ilim) < 0) { + m2 -= i; + i = 0; + } + } + b2 += i; + s2 += i; + mhi = i2b(1); + } + if (m2 > 0 && s2 > 0) { + i = m2 < s2 ? m2 : s2; + b2 -= i; + m2 -= i; + s2 -= i; + } + if (b5 > 0) { + if (leftright) { + if (m5 > 0) { + mhi = pow5mult(mhi, m5); + b1 = mult(mhi, b); + Bfree(b); + b = b1; + } + if ((j = b5 - m5) != 0) + b = pow5mult(b, j); + } + else + b = pow5mult(b, b5); + } + S = i2b(1); + if (s5 > 0) + S = pow5mult(S, s5); + + /* Check for special case that d is a normalized power of 2. */ + + if (mode < 2) { + if (!getWord1(d) && !(getWord0(d) & Bndry_mask) +#ifndef Sudden_Underflow + && getWord0(d) & Exp_mask +#endif + ) { + /* The special case */ + b2 += Log2P; + s2 += Log2P; + spec_case = 1; + } + else + spec_case = 0; + } + + /* Arrange for convenient computation of quotients: + * shift left if necessary so divisor has 4 leading 0 bits. + * + * Perhaps we should just compute leading 28 bits of S once + * and for all and pass them and a shift to quorem, so it + * can do shifts and ors to compute the numerator for q. + */ +#ifdef Pack_32 + if ((i = ((s5 ? 32 - hi0bits(S->x[S->wds-1]) : 1) + s2) & 0x1f) != 0) + i = 32 - i; +#else + if (i = ((s5 ? 32 - hi0bits(S->x[S->wds-1]) : 1) + s2) & 0xf) + i = 16 - i; +#endif + if (i > 4) { + i -= 4; + b2 += i; + m2 += i; + s2 += i; + } + else if (i < 4) { + i += 28; + b2 += i; + m2 += i; + s2 += i; + } + if (b2 > 0) + b = lshift(b, b2); + if (s2 > 0) + S = lshift(S, s2); + if (k_check) { + if (cmp(b,S) < 0) { + k--; + b = multadd(b, 10, 0); /* we botched the k estimate */ + if (leftright) + mhi = multadd(mhi, 10, 0); + ilim = ilim1; + } + } + if (ilim <= 0 && mode > 2) { + if (ilim < 0 || cmp(b,S = multadd(S,5,0)) <= 0) { + /* no digits, fcvt style */ + no_digits: + k = -1 - ndigits; + goto ret; + } + one_digit: + *s++ = '1'; + k++; + goto ret; + } + if (leftright) { + if (m2 > 0) + mhi = lshift(mhi, m2); + + /* Compute mlo -- check for special case + * that d is a normalized power of 2. + */ + + mlo = mhi; + if (spec_case) { + mhi = Balloc(mhi->k); + Bcopy(mhi, mlo); + mhi = lshift(mhi, Log2P); + } + + for(i = 1;;i++) { + dig = quorem(b,S) + '0'; + /* Do we yet have the shortest decimal string + * that will round to d? + */ + j = cmp(b, mlo); + delta = diff(S, mhi); + j1 = delta->sign ? 1 : cmp(b, delta); + Bfree(delta); +#ifndef ROUND_BIASED + if (j1 == 0 && !mode && !(getWord1(d) & 1)) { + if (dig == '9') + goto round_9_up; + if (j > 0) + dig++; + *s++ = dig; + goto ret; + } +#endif + if (j < 0 || (j == 0 && !mode +#ifndef ROUND_BIASED + && !(getWord1(d) & 1) +#endif + )) { + if (j1 > 0) { + b = lshift(b, 1); + j1 = cmp(b, S); + if ((j1 > 0 || (j1 == 0 && dig & 1)) + && dig++ == '9') + goto round_9_up; + } + *s++ = dig; + goto ret; + } + if (j1 > 0) { + if (dig == '9') { /* possible if i == 1 */ + round_9_up: + *s++ = '9'; + goto roundoff; + } + *s++ = dig + 1; + goto ret; + } + *s++ = dig; + if (i == ilim) + break; + b = multadd(b, 10, 0); + if (mlo == mhi) + mlo = mhi = multadd(mhi, 10, 0); + else { + mlo = multadd(mlo, 10, 0); + mhi = multadd(mhi, 10, 0); + } + } + } + else + for(i = 1;; i++) { + *s++ = dig = quorem(b,S) + '0'; + if (i >= ilim) + break; + b = multadd(b, 10, 0); + } + + /* Round off last digit */ + + b = lshift(b, 1); + j = cmp(b, S); + if (j > 0 || (j == 0 && dig & 1)) { + roundoff: + while(*--s == '9') + if (s == s0) { + k++; + *s++ = '1'; + goto ret; + } + ++*s++; + } + else { + while(*--s == '0'); + s++; + } + ret: + Bfree(S); + if (mhi) { + if (mlo && mlo != mhi) + Bfree(mlo); + Bfree(mhi); + } + ret1: + Bfree(b); + if (s == s0) { /* don't return empty string */ + *s++ = '0'; + k = 0; + } + *s = 0; + *decpt = k + 1; + if (rve) + *rve = s; + return s0; +} + +#endif // QT_QLOCALE_USES_FCVT diff --git a/src/tools/qlocale.h b/src/tools/qlocale.h new file mode 100644 index 000000000..c1438bcd7 --- /dev/null +++ b/src/tools/qlocale.h @@ -0,0 +1,494 @@ +/**************************************************************************** +** +** Declaration of the TQLocale class +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQLOCALE_H +#define TQLOCALE_H + +#include "qstring.h" + +struct TQLocalePrivate; + +class Q_EXPORT TQLocale +{ + friend class TQString; + +public: + enum Language { + C = 1, + Abkhazian = 2, + Afan = 3, + Afar = 4, + Afrikaans = 5, + Albanian = 6, + Amharic = 7, + Arabic = 8, + Armenian = 9, + Assamese = 10, + Aymara = 11, + Azerbaijani = 12, + Bashkir = 13, + Basque = 14, + Bengali = 15, + Bhutani = 16, + Bihari = 17, + Bislama = 18, + Breton = 19, + Bulgarian = 20, + Burmese = 21, + Byelorussian = 22, + Cambodian = 23, + Catalan = 24, + Chinese = 25, + Corsican = 26, + Croatian = 27, + Czech = 28, + Danish = 29, + Dutch = 30, + English = 31, + Esperanto = 32, + Estonian = 33, + Faroese = 34, + FijiLanguage = 35, + Finnish = 36, + French = 37, + Frisian = 38, + Gaelic = 39, + Galician = 40, + Georgian = 41, + German = 42, + Greek = 43, + Greenlandic = 44, + Guarani = 45, + Gujarati = 46, + Hausa = 47, + Hebrew = 48, + Hindi = 49, + Hungarian = 50, + Icelandic = 51, + Indonesian = 52, + Interlingua = 53, + Interlingue = 54, + Inuktitut = 55, + Inupiak = 56, + Irish = 57, + Italian = 58, + Japanese = 59, + Javanese = 60, + Kannada = 61, + Kashmiri = 62, + Kazakh = 63, + Kinyarwanda = 64, + Kirghiz = 65, + Korean = 66, + Kurdish = 67, + Kurundi = 68, + Laothian = 69, + Latin = 70, + Latvian = 71, + Lingala = 72, + Lithuanian = 73, + Macedonian = 74, + Malagasy = 75, + Malay = 76, + Malayalam = 77, + Maltese = 78, + Maori = 79, + Marathi = 80, + Moldavian = 81, + Mongolian = 82, + NauruLanguage = 83, + Nepali = 84, + Norwegian = 85, + Occitan = 86, + Oriya = 87, + Pashto = 88, + Persian = 89, + Polish = 90, + Portuguese = 91, + Punjabi = 92, + Quechua = 93, + RhaetoRomance = 94, + Romanian = 95, + Russian = 96, + Samoan = 97, + Sangho = 98, + Sanskrit = 99, + Serbian = 100, + SerboCroatian = 101, + Sesotho = 102, + Setswana = 103, + Shona = 104, + Sindhi = 105, + Singhalese = 106, + Siswati = 107, + Slovak = 108, + Slovenian = 109, + Somali = 110, + Spanish = 111, + Sundanese = 112, + Swahili = 113, + Swedish = 114, + Tagalog = 115, + Tajik = 116, + Tamil = 117, + Tatar = 118, + Telugu = 119, + Thai = 120, + Tibetan = 121, + Tigrinya = 122, + TongaLanguage = 123, + Tsonga = 124, + Turkish = 125, + Turkmen = 126, + Twi = 127, + Uigur = 128, + Ukrainian = 129, + Urdu = 130, + Uzbek = 131, + Vietnamese = 132, + Volapuk = 133, + Welsh = 134, + Wolof = 135, + Xhosa = 136, + Yiddish = 137, + Yoruba = 138, + Zhuang = 139, + Zulu = 140, + LastLanguage = Zulu + }; + + enum Country { + AnyCountry = 0, + Afghanistan = 1, + Albania = 2, + Algeria = 3, + AmericanSamoa = 4, + Andorra = 5, + Angola = 6, + Anguilla = 7, + Antarctica = 8, + AntiguaAndBarbuda = 9, + Argentina = 10, + Armenia = 11, + Aruba = 12, + Australia = 13, + Austria = 14, + Azerbaijan = 15, + Bahamas = 16, + Bahrain = 17, + Bangladesh = 18, + Barbados = 19, + Belarus = 20, + Belgium = 21, + Belize = 22, + Benin = 23, + Bermuda = 24, + Bhutan = 25, + Bolivia = 26, + BosniaAndHerzegowina = 27, + Botswana = 28, + BouvetIsland = 29, + Brazil = 30, + BritishIndianOceanTerritory = 31, + BruneiDarussalam = 32, + Bulgaria = 33, + BurkinaFaso = 34, + Burundi = 35, + Cambodia = 36, + Cameroon = 37, + Canada = 38, + CapeVerde = 39, + CaymanIslands = 40, + CentralAfricanRepublic = 41, + Chad = 42, + Chile = 43, + China = 44, + ChristmasIsland = 45, + CocosIslands = 46, + Colombia = 47, + Comoros = 48, + DemocraticRepublicOfCongo = 49, + PeoplesRepublicOfCongo = 50, + CookIslands = 51, + CostaRica = 52, + IvoryCoast = 53, + Croatia = 54, + Cuba = 55, + Cyprus = 56, + CzechRepublic = 57, + Denmark = 58, + Djibouti = 59, + Dominica = 60, + DominicanRepublic = 61, + EastTimor = 62, + Ecuador = 63, + Egypt = 64, + ElSalvador = 65, + EquatorialGuinea = 66, + Eritrea = 67, + Estonia = 68, + Ethiopia = 69, + FalklandIslands = 70, + FaroeIslands = 71, + FijiCountry = 72, + Finland = 73, + France = 74, + MetropolitanFrance = 75, + FrenchGuiana = 76, + FrenchPolynesia = 77, + FrenchSouthernTerritories = 78, + Gabon = 79, + Gambia = 80, + Georgia = 81, + Germany = 82, + Ghana = 83, + Gibraltar = 84, + Greece = 85, + Greenland = 86, + Grenada = 87, + Guadeloupe = 88, + Guam = 89, + Guatemala = 90, + Guinea = 91, + GuineaBissau = 92, + Guyana = 93, + Haiti = 94, + HeardAndMcDonaldIslands = 95, + Honduras = 96, + HongKong = 97, + Hungary = 98, + Iceland = 99, + India = 100, + Indonesia = 101, + Iran = 102, + Iraq = 103, + Ireland = 104, + Israel = 105, + Italy = 106, + Jamaica = 107, + Japan = 108, + Jordan = 109, + Kazakhstan = 110, + Kenya = 111, + Kiribati = 112, + DemocraticRepublicOfKorea = 113, + RepublicOfKorea = 114, + Kuwait = 115, + Kyrgyzstan = 116, + Lao = 117, + Latvia = 118, + Lebanon = 119, + Lesotho = 120, + Liberia = 121, + LibyanArabJamahiriya = 122, + Liechtenstein = 123, + Lithuania = 124, + Luxembourg = 125, + Macau = 126, + Macedonia = 127, + Madagascar = 128, + Malawi = 129, + Malaysia = 130, + Maldives = 131, + Mali = 132, + Malta = 133, + MarshallIslands = 134, + Martinique = 135, + Mauritania = 136, + Mauritius = 137, + Mayotte = 138, + Mexico = 139, + Micronesia = 140, + Moldova = 141, + Monaco = 142, + Mongolia = 143, + Montserrat = 144, + Morocco = 145, + Mozambique = 146, + Myanmar = 147, + Namibia = 148, + NauruCountry = 149, + Nepal = 150, + Netherlands = 151, + NetherlandsAntilles = 152, + NewCaledonia = 153, + NewZealand = 154, + Nicaragua = 155, + Niger = 156, + Nigeria = 157, + Niue = 158, + NorfolkIsland = 159, + NorthernMarianaIslands = 160, + Norway = 161, + Oman = 162, + Pakistan = 163, + Palau = 164, + PalestinianTerritory = 165, + Panama = 166, + PapuaNewGuinea = 167, + Paraguay = 168, + Peru = 169, + Philippines = 170, + Pitcairn = 171, + Poland = 172, + Portugal = 173, + PuertoRico = 174, + Qatar = 175, + Reunion = 176, + Romania = 177, + RussianFederation = 178, + Rwanda = 179, + SaintKittsAndNevis = 180, + StLucia = 181, + StVincentAndTheGrenadines = 182, + Samoa = 183, + SanMarino = 184, + SaoTomeAndPrincipe = 185, + SaudiArabia = 186, + Senegal = 187, + Seychelles = 188, + SierraLeone = 189, + Singapore = 190, + Slovakia = 191, + Slovenia = 192, + SolomonIslands = 193, + Somalia = 194, + SouthAfrica = 195, + SouthGeorgiaAndTheSouthSandwichIslands = 196, + Spain = 197, + SriLanka = 198, + StHelena = 199, + StPierreAndMiquelon = 200, + Sudan = 201, + Suriname = 202, + SvalbardAndJanMayenIslands = 203, + Swaziland = 204, + Sweden = 205, + Switzerland = 206, + SyrianArabRepublic = 207, + Taiwan = 208, + Tajikistan = 209, + Tanzania = 210, + Thailand = 211, + Togo = 212, + Tokelau = 213, + TongaCountry = 214, + TrinidadAndTobago = 215, + Tunisia = 216, + Turkey = 217, + Turkmenistan = 218, + TurksAndCaicosIslands = 219, + Tuvalu = 220, + Uganda = 221, + Ukraine = 222, + UnitedArabEmirates = 223, + UnitedKingdom = 224, + UnitedStates = 225, + UnitedStatesMinorOutlyingIslands = 226, + Uruguay = 227, + Uzbekistan = 228, + Vanuatu = 229, + VaticanCityState = 230, + Venezuela = 231, + VietNam = 232, + BritishVirginIslands = 233, + USVirginIslands = 234, + WallisAndFutunaIslands = 235, + WesternSahara = 236, + Yemen = 237, + Yugoslavia = 238, + Zambia = 239, + Zimbabwe = 240, + LastCountry = Zimbabwe + }; + + TQLocale(); + TQLocale(const TQString &name); + TQLocale(Language language, Country country = AnyCountry); + TQLocale(const TQLocale &other); + + TQLocale &operator=(const TQLocale &other); + + Language language() const; + Country country() const; + TQString name() const; + + short toShort(const TQString &s, bool *ok = 0) const; + ushort toUShort(const TQString &s, bool *ok = 0) const; + int toInt(const TQString &s, bool *ok = 0) const; + uint toUInt(const TQString &s, bool *ok = 0) const; + Q_LONG toLong(const TQString &s, bool *ok = 0) const; + Q_ULONG toULong(const TQString &s, bool *ok = 0) const; + Q_LLONG toLongLong(const TQString &s, bool *ok = 0) const; + Q_ULLONG toULongLong(const TQString &s, bool *ok = 0) const; + float toFloat(const TQString &s, bool *ok = 0) const; + double toDouble(const TQString &s, bool *ok = 0) const; + + TQString toString(short i) const + { return toString((Q_LLONG)i); } + TQString toString(ushort i) const + { return toString((Q_ULLONG)i); } + TQString toString(int i) const + { return toString((Q_LLONG)i); } + TQString toString(uint i) const + { return toString((Q_ULLONG)i); } +#if !defined(Q_OS_WIN64) + TQString toString(Q_LONG i) const + { return toString((Q_LLONG)i); } + TQString toString(Q_ULONG i) const + { return toString((Q_ULLONG)i); } +#endif + TQString toString(Q_LLONG i) const; + TQString toString(Q_ULLONG i) const; + TQString toString(float i, char f = 'g', int prec = 6) const + { return toString((double) i, f, prec); } + TQString toString(double i, char f = 'g', int prec = 6) const; + + static TQString languageToString(Language language); + static TQString countryToString(Country country); + static void setDefault(const TQLocale &locale); + + static TQLocale c() { return TQLocale(C); } + static TQLocale system(); + +private: + const TQLocalePrivate *d; + static const TQLocalePrivate *default_d; +}; + +#endif diff --git a/src/tools/qlocale_p.h b/src/tools/qlocale_p.h new file mode 100644 index 000000000..acad3b452 --- /dev/null +++ b/src/tools/qlocale_p.h @@ -0,0 +1,131 @@ +/**************************************************************************** +** +** Declaration of the TQLocalePrivate class +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the widgets module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQLOCALE_P_H +#define TQLOCALE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the TQt API. It exists for the convenience +// of internal files. This header file may change from version to version +// without notice, or even be removed. +// +// We mean it. +// +// + +#include + +struct TQLocalePrivate +{ +public: + const TQChar &decimal() const { return (TQChar&)m_decimal; } + const TQChar &group() const { return (TQChar&)m_group; } + const TQChar &list() const { return (TQChar&)m_list; } + const TQChar &percent() const { return (TQChar&)m_percent; } + const TQChar &zero() const { return (TQChar&)m_zero; } + TQChar plus() const { return TQChar('+'); } + const TQChar &minus() const { return (TQChar&)m_minus; } + const TQChar &exponential() const { return (TQChar&)m_exponential; } + TQString infinity() const; + TQString nan() const; + + Q_UINT32 languageId() const { return m_language_id; } + Q_UINT32 countryId() const { return m_country_id; } + + bool isDigit(TQChar d) const; + + enum GroupSeparatorMode { + FailOnGroupSeparators, + ParseGroupSeparators + }; + + enum DoubleForm { + DFExponent = 0, // %e or %E + DFDecimal, // %f or %F + DFSignificantDigits, // %g or %G + _DFMax = DFSignificantDigits + }; + + enum Flags { + NoFlags = 0, + + // These correspond to the options in a printf format string + Alternate = 0x01, + ZeroPadded = 0x02, + LeftAdjusted = 0x04, + BlankBeforePositive = 0x08, + AlwaysShowSign = 0x10, + ThousandsGroup = 0x20, + CapitalEorX = 0x40 // %x, %e, %f, %g vs. %X, %E, %F, %G + }; + + TQString doubleToString(double d, + int precision = -1, + DoubleForm form = DFSignificantDigits, + int width = -1, + unsigned flags = NoFlags) const; + TQString longLongToString(Q_LLONG l, int precision = -1, + int base = 10, + int width = -1, + unsigned flags = NoFlags) const; + TQString unsLongLongToString(Q_ULLONG l, int precision = -1, + int base = 10, + int width = -1, + unsigned flags = NoFlags) const; + double stringToDouble(TQString num, bool *ok, GroupSeparatorMode group_sep_mode) const; + Q_LLONG stringToLongLong(TQString num, int base, bool *ok, GroupSeparatorMode group_sep_mode) const; + Q_ULLONG stringToUnsLongLong(TQString num, int base, bool *ok, GroupSeparatorMode group_sep_mode) const; + bool removeGroupSeparators(TQString &num_str) const; + bool numberToCLocale(TQString &locale_num, GroupSeparatorMode group_sep_mode) const; + + Q_UINT32 m_language_id, m_country_id; + + Q_UINT16 m_decimal, m_group, m_list, m_percent, + m_zero, m_minus, m_exponential; + + static const TQString m_infinity; + static const TQString m_nan; + static const TQChar m_plus; + + static const char *systemLocaleName(); +}; + +#endif diff --git a/src/tools/qmap.cpp b/src/tools/qmap.cpp new file mode 100644 index 000000000..12b41c681 --- /dev/null +++ b/src/tools/qmap.cpp @@ -0,0 +1,257 @@ +/**************************************************************************** +** +** Implementation of TQMap +** +** Created : 990406 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "qmap.h" + +typedef TQMapNodeBase* NodePtr; +typedef TQMapNodeBase Node; + + +void TQMapPrivateBase::rotateLeft( NodePtr x, NodePtr& root) +{ + NodePtr y = x->right; + x->right = y->left; + if (y->left !=0) + y->left->parent = x; + y->parent = x->parent; + if (x == root) + root = y; + else if (x == x->parent->left) + x->parent->left = y; + else + x->parent->right = y; + y->left = x; + x->parent = y; +} + + +void TQMapPrivateBase::rotateRight( NodePtr x, NodePtr& root ) +{ + NodePtr y = x->left; + x->left = y->right; + if (y->right != 0) + y->right->parent = x; + y->parent = x->parent; + if (x == root) + root = y; + else if (x == x->parent->right) + x->parent->right = y; + else + x->parent->left = y; + y->right = x; + x->parent = y; +} + + +void TQMapPrivateBase::rebalance( NodePtr x, NodePtr& root) +{ + x->color = Node::Red; + while ( x != root && x->parent->color == Node::Red ) { + if ( x->parent == x->parent->parent->left ) { + NodePtr y = x->parent->parent->right; + if (y && y->color == Node::Red) { + x->parent->color = Node::Black; + y->color = Node::Black; + x->parent->parent->color = Node::Red; + x = x->parent->parent; + } else { + if (x == x->parent->right) { + x = x->parent; + rotateLeft( x, root ); + } + x->parent->color = Node::Black; + x->parent->parent->color = Node::Red; + rotateRight (x->parent->parent, root ); + } + } else { + NodePtr y = x->parent->parent->left; + if ( y && y->color == Node::Red ) { + x->parent->color = Node::Black; + y->color = Node::Black; + x->parent->parent->color = Node::Red; + x = x->parent->parent; + } else { + if (x == x->parent->left) { + x = x->parent; + rotateRight( x, root ); + } + x->parent->color = Node::Black; + x->parent->parent->color = Node::Red; + rotateLeft( x->parent->parent, root ); + } + } + } + root->color = Node::Black; +} + + +NodePtr TQMapPrivateBase::removeAndRebalance( NodePtr z, NodePtr& root, + NodePtr& leftmost, + NodePtr& rightmost ) +{ + NodePtr y = z; + NodePtr x; + NodePtr x_parent; + if (y->left == 0) { + x = y->right; + } else { + if (y->right == 0) + x = y->left; + else + { + y = y->right; + while (y->left != 0) + y = y->left; + x = y->right; + } + } + if (y != z) { + z->left->parent = y; + y->left = z->left; + if (y != z->right) { + x_parent = y->parent; + if (x) + x->parent = y->parent; + y->parent->left = x; + y->right = z->right; + z->right->parent = y; + } else { + x_parent = y; + } + if (root == z) + root = y; + else if (z->parent->left == z) + z->parent->left = y; + else + z->parent->right = y; + y->parent = z->parent; + // Swap the colors + Node::Color c = y->color; + y->color = z->color; + z->color = c; + y = z; + } else { + x_parent = y->parent; + if (x) + x->parent = y->parent; + if (root == z) + root = x; + else if (z->parent->left == z) + z->parent->left = x; + else + z->parent->right = x; + if ( leftmost == z ) { + if (z->right == 0) + leftmost = z->parent; + else + leftmost = x->minimum(); + } + if (rightmost == z) { + if (z->left == 0) + rightmost = z->parent; + else + rightmost = x->maximum(); + } + } + if (y->color != Node::Red) { + while (x != root && (x == 0 || x->color == Node::Black)) { + if (x == x_parent->left) { + NodePtr w = x_parent->right; + if (w->color == Node::Red) { + w->color = Node::Black; + x_parent->color = Node::Red; + rotateLeft(x_parent, root); + w = x_parent->right; + } + if ((w->left == 0 || w->left->color == Node::Black) && + (w->right == 0 || w->right->color == Node::Black)) { + w->color = Node::Red; + x = x_parent; + x_parent = x_parent->parent; + } else { + if (w->right == 0 || w->right->color == Node::Black) { + if (w->left) + w->left->color = Node::Black; + w->color = Node::Red; + rotateRight(w, root); + w = x_parent->right; + } + w->color = x_parent->color; + x_parent->color = Node::Black; + if (w->right) + w->right->color = Node::Black; + rotateLeft(x_parent, root); + break; + } + } else { + NodePtr w = x_parent->left; + if (w->color == Node::Red) { + w->color = Node::Black; + x_parent->color = Node::Red; + rotateRight(x_parent, root); + w = x_parent->left; + } + if ((w->right == 0 || w->right->color == Node::Black) && + (w->left == 0 || w->left->color == Node::Black)) { + w->color = Node::Red; + x = x_parent; + x_parent = x_parent->parent; + } else { + if (w->left == 0 || w->left->color == Node::Black) { + if (w->right) + w->right->color = Node::Black; + w->color = Node::Red; + rotateLeft(w, root); + w = x_parent->left; + } + w->color = x_parent->color; + x_parent->color = Node::Black; + if (w->left) + w->left->color = Node::Black; + rotateRight(x_parent, root); + break; + } + } + } + if (x) + x->color = Node::Black; + } + return y; +} diff --git a/src/tools/qmap.h b/src/tools/qmap.h new file mode 100644 index 000000000..b0ec86644 --- /dev/null +++ b/src/tools/qmap.h @@ -0,0 +1,877 @@ +/**************************************************************************** +** +** Definition of TQMap class +** +** Created : 990406 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQMAP_H +#define TQMAP_H + +#ifndef QT_H +#include "qglobal.h" +#include "qshared.h" +#include "qdatastream.h" +#include "qpair.h" +#include "qvaluelist.h" +#endif // QT_H + +#ifndef QT_NO_STL +#include +#include +#include +#endif + +//#define QT_CHECK_MAP_RANGE + +struct Q_EXPORT TQMapNodeBase +{ + enum Color { Red, Black }; + + TQMapNodeBase* left; + TQMapNodeBase* right; + TQMapNodeBase* parent; + + Color color; + + TQMapNodeBase* minimum() { + TQMapNodeBase* x = this; + while ( x->left ) + x = x->left; + return x; + } + + TQMapNodeBase* maximum() { + TQMapNodeBase* x = this; + while ( x->right ) + x = x->right; + return x; + } +}; + + +template +struct TQMapNode : public TQMapNodeBase +{ + TQMapNode( const K& _key, const T& _data ) { data = _data; key = _key; } + TQMapNode( const K& _key ) { key = _key; } + TQMapNode( const TQMapNode& _n ) { key = _n.key; data = _n.data; } + TQMapNode() { } + T data; + K key; +}; + + +template +class TQMapIterator +{ + public: + /** + * Typedefs + */ + typedef TQMapNode< K, T >* NodePtr; +#ifndef QT_NO_STL + typedef std::bidirectional_iterator_tag iterator_category; +#endif + typedef T value_type; +#ifndef QT_NO_STL + typedef ptrdiff_t difference_type; +#else + typedef int difference_type; +#endif + typedef T* pointer; + typedef T& reference; + + /** + * Variables + */ + TQMapNode* node; + + /** + * Functions + */ + TQMapIterator() : node( 0 ) {} + TQMapIterator( TQMapNode* p ) : node( p ) {} + TQMapIterator( const TQMapIterator& it ) : node( it.node ) {} + + bool operator==( const TQMapIterator& it ) const { return node == it.node; } + bool operator!=( const TQMapIterator& it ) const { return node != it.node; } + T& operator*() { return node->data; } + const T& operator*() const { return node->data; } + // UDT for T = x* + // T* operator->() const { return &node->data; } + + const K& key() const { return node->key; } + T& data() { return node->data; } + const T& data() const { return node->data; } + +private: + int inc(); + int dec(); + +public: + TQMapIterator& operator++() { + inc(); + return *this; + } + + TQMapIterator operator++(int) { + TQMapIterator tmp = *this; + inc(); + return tmp; + } + + TQMapIterator& operator--() { + dec(); + return *this; + } + + TQMapIterator operator--(int) { + TQMapIterator tmp = *this; + dec(); + return tmp; + } +}; + +template +Q_INLINE_TEMPLATES int TQMapIterator::inc() +{ + TQMapNodeBase* tmp = node; + if ( tmp->right ) { + tmp = tmp->right; + while ( tmp->left ) + tmp = tmp->left; + } else { + TQMapNodeBase* y = tmp->parent; + while (tmp == y->right) { + tmp = y; + y = y->parent; + } + if (tmp->right != y) + tmp = y; + } + node = (NodePtr)tmp; + return 0; +} + +template +Q_INLINE_TEMPLATES int TQMapIterator::dec() +{ + TQMapNodeBase* tmp = node; + if (tmp->color == TQMapNodeBase::Red && + tmp->parent->parent == tmp ) { + tmp = tmp->right; + } else if (tmp->left != 0) { + TQMapNodeBase* y = tmp->left; + while ( y->right ) + y = y->right; + tmp = y; + } else { + TQMapNodeBase* y = tmp->parent; + while (tmp == y->left) { + tmp = y; + y = y->parent; + } + tmp = y; + } + node = (NodePtr)tmp; + return 0; +} + +template +class TQMapConstIterator +{ + public: + /** + * Typedefs + */ + typedef TQMapNode< K, T >* NodePtr; +#ifndef QT_NO_STL + typedef std::bidirectional_iterator_tag iterator_category; +#endif + typedef T value_type; +#ifndef QT_NO_STL + typedef ptrdiff_t difference_type; +#else + typedef int difference_type; +#endif + typedef const T* pointer; + typedef const T& reference; + + + /** + * Variables + */ + TQMapNode* node; + + /** + * Functions + */ + TQMapConstIterator() : node( 0 ) {} + TQMapConstIterator( TQMapNode* p ) : node( p ) {} + TQMapConstIterator( const TQMapConstIterator& it ) : node( it.node ) {} + TQMapConstIterator( const TQMapIterator& it ) : node( it.node ) {} + + bool operator==( const TQMapConstIterator& it ) const { return node == it.node; } + bool operator!=( const TQMapConstIterator& it ) const { return node != it.node; } + const T& operator*() const { return node->data; } + // UDT for T = x* + // const T* operator->() const { return &node->data; } + + const K& key() const { return node->key; } + const T& data() const { return node->data; } + +private: + int inc(); + int dec(); + +public: + TQMapConstIterator& operator++() { + inc(); + return *this; + } + + TQMapConstIterator operator++(int) { + TQMapConstIterator tmp = *this; + inc(); + return tmp; + } + + TQMapConstIterator& operator--() { + dec(); + return *this; + } + + TQMapConstIterator operator--(int) { + TQMapConstIterator tmp = *this; + dec(); + return tmp; + } +}; + +template +Q_INLINE_TEMPLATES int TQMapConstIterator::inc() +{ + TQMapNodeBase* tmp = node; + if ( tmp->right ) { + tmp = tmp->right; + while ( tmp->left ) + tmp = tmp->left; + } else { + TQMapNodeBase* y = tmp->parent; + while (tmp == y->right) { + tmp = y; + y = y->parent; + } + if (tmp->right != y) + tmp = y; + } + node = (NodePtr)tmp; + return 0; +} + +template +Q_INLINE_TEMPLATES int TQMapConstIterator::dec() +{ + TQMapNodeBase* tmp = node; + if (tmp->color == TQMapNodeBase::Red && + tmp->parent->parent == tmp ) { + tmp = tmp->right; + } else if (tmp->left != 0) { + TQMapNodeBase* y = tmp->left; + while ( y->right ) + y = y->right; + tmp = y; + } else { + TQMapNodeBase* y = tmp->parent; + while (tmp == y->left) { + tmp = y; + y = y->parent; + } + tmp = y; + } + node = (NodePtr)tmp; + return 0; +} + +// ### 4.0: rename to something without Private in it. Not really internal. +class Q_EXPORT TQMapPrivateBase : public TQShared +{ +public: + TQMapPrivateBase() { + node_count = 0; + } + TQMapPrivateBase( const TQMapPrivateBase* _map) { + node_count = _map->node_count; + } + + /** + * Implementations of basic tree algorithms + */ + void rotateLeft( TQMapNodeBase* x, TQMapNodeBase*& root); + void rotateRight( TQMapNodeBase* x, TQMapNodeBase*& root ); + void rebalance( TQMapNodeBase* x, TQMapNodeBase*& root ); + TQMapNodeBase* removeAndRebalance( TQMapNodeBase* z, TQMapNodeBase*& root, + TQMapNodeBase*& leftmost, + TQMapNodeBase*& rightmost ); + + /** + * Variables + */ + int node_count; +}; + + +template +class TQMapPrivate : public TQMapPrivateBase +{ +public: + /** + * Typedefs + */ + typedef TQMapIterator< Key, T > Iterator; + typedef TQMapConstIterator< Key, T > ConstIterator; + typedef TQMapNode< Key, T > Node; + typedef TQMapNode< Key, T >* NodePtr; + + /** + * Functions + */ + TQMapPrivate(); + TQMapPrivate( const TQMapPrivate< Key, T >* _map ); + ~TQMapPrivate() { clear(); delete header; } + + NodePtr copy( NodePtr p ); + void clear(); + void clear( NodePtr p ); + + Iterator begin() { return Iterator( (NodePtr)(header->left ) ); } + Iterator end() { return Iterator( header ); } + ConstIterator begin() const { return ConstIterator( (NodePtr)(header->left ) ); } + ConstIterator end() const { return ConstIterator( header ); } + + ConstIterator find(const Key& k) const; + + void remove( Iterator it ) { + NodePtr del = (NodePtr) removeAndRebalance( it.node, header->parent, header->left, header->right ); + delete del; + --node_count; + } + +#ifdef QT_QMAP_DEBUG + void inorder( TQMapNodeBase* x = 0, int level = 0 ){ + if ( !x ) + x = header->parent; + if ( x->left ) + inorder( x->left, level + 1 ); + //cout << level << " Key=" << key(x) << " Value=" << ((NodePtr)x)->data << endl; + if ( x->right ) + inorder( x->right, level + 1 ); + } +#endif + +#if 0 + Iterator insertMulti(const Key& v){ + TQMapNodeBase* y = header; + TQMapNodeBase* x = header->parent; + while (x != 0){ + y = x; + x = ( v < key(x) ) ? x->left : x->right; + } + return insert(x, y, v); + } +#endif + + Iterator insertSingle( const Key& k ); + Iterator insert( TQMapNodeBase* x, TQMapNodeBase* y, const Key& k ); + +protected: + /** + * Helpers + */ + const Key& key( TQMapNodeBase* b ) const { return ((NodePtr)b)->key; } + + /** + * Variables + */ + NodePtr header; +}; + + +template +Q_INLINE_TEMPLATES TQMapPrivate::TQMapPrivate() { + header = new Node; + header->color = TQMapNodeBase::Red; // Mark the header + header->parent = 0; + header->left = header->right = header; +} +template +Q_INLINE_TEMPLATES TQMapPrivate::TQMapPrivate( const TQMapPrivate< Key, T >* _map ) : TQMapPrivateBase( _map ) { + header = new Node; + header->color = TQMapNodeBase::Red; // Mark the header + if ( _map->header->parent == 0 ) { + header->parent = 0; + header->left = header->right = header; + } else { + header->parent = copy( (NodePtr)(_map->header->parent) ); + header->parent->parent = header; + header->left = header->parent->minimum(); + header->right = header->parent->maximum(); + } +} + +template +Q_INLINE_TEMPLATES Q_TYPENAME TQMapPrivate::NodePtr TQMapPrivate::copy( Q_TYPENAME TQMapPrivate::NodePtr p ) +{ + if ( !p ) + return 0; + NodePtr n = new Node( *p ); + n->color = p->color; + if ( p->left ) { + n->left = copy( (NodePtr)(p->left) ); + n->left->parent = n; + } else { + n->left = 0; + } + if ( p->right ) { + n->right = copy( (NodePtr)(p->right) ); + n->right->parent = n; + } else { + n->right = 0; + } + return n; +} + +template +Q_INLINE_TEMPLATES void TQMapPrivate::clear() +{ + clear( (NodePtr)(header->parent) ); + header->color = TQMapNodeBase::Red; + header->parent = 0; + header->left = header->right = header; + node_count = 0; +} + +template +Q_INLINE_TEMPLATES void TQMapPrivate::clear( Q_TYPENAME TQMapPrivate::NodePtr p ) +{ + while ( p != 0 ) { + clear( (NodePtr)p->right ); + NodePtr y = (NodePtr)p->left; + delete p; + p = y; + } +} + +template +Q_INLINE_TEMPLATES Q_TYPENAME TQMapPrivate::ConstIterator TQMapPrivate::find(const Key& k) const +{ + TQMapNodeBase* y = header; // Last node + TQMapNodeBase* x = header->parent; // Root node. + + while ( x != 0 ) { + // If as k <= key(x) go left + if ( !( key(x) < k ) ) { + y = x; + x = x->left; + } else { + x = x->right; + } + } + + // Was k bigger/smaller then the biggest/smallest + // element of the tree ? Return end() + if ( y == header || k < key(y) ) + return ConstIterator( header ); + return ConstIterator( (NodePtr)y ); +} + +template +Q_INLINE_TEMPLATES Q_TYPENAME TQMapPrivate::Iterator TQMapPrivate::insertSingle( const Key& k ) +{ + // Search correct position in the tree + TQMapNodeBase* y = header; + TQMapNodeBase* x = header->parent; + bool result = TRUE; + while ( x != 0 ) { + result = ( k < key(x) ); + y = x; + x = result ? x->left : x->right; + } + // Get iterator on the last not empty one + Iterator j( (NodePtr)y ); + if ( result ) { + // Smaller then the leftmost one ? + if ( j == begin() ) { + return insert(x, y, k ); + } else { + // Perhaps daddy is the right one ? + --j; + } + } + // Really bigger ? + if ( (j.node->key) < k ) + return insert(x, y, k ); + // We are going to replace a node + return j; +} + + +template +Q_INLINE_TEMPLATES Q_TYPENAME TQMapPrivate::Iterator TQMapPrivate::insert( TQMapNodeBase* x, TQMapNodeBase* y, const Key& k ) +{ + NodePtr z = new Node( k ); + if (y == header || x != 0 || k < key(y) ) { + y->left = z; // also makes leftmost = z when y == header + if ( y == header ) { + header->parent = z; + header->right = z; + } else if ( y == header->left ) + header->left = z; // maintain leftmost pointing to min node + } else { + y->right = z; + if ( y == header->right ) + header->right = z; // maintain rightmost pointing to max node + } + z->parent = y; + z->left = 0; + z->right = 0; + rebalance( z, header->parent ); + ++node_count; + return Iterator(z); +} + + +#ifdef QT_CHECK_RANGE +# if !defined( QT_NO_DEBUG ) && defined( QT_CHECK_MAP_RANGE ) +# define QT_CHECK_INVALID_MAP_ELEMENT if ( empty() ) qWarning( "TQMap: Warning invalid element" ) +# define QT_CHECK_INVALID_MAP_ELEMENT_FATAL Q_ASSERT( !empty() ); +# else +# define QT_CHECK_INVALID_MAP_ELEMENT +# define QT_CHECK_INVALID_MAP_ELEMENT_FATAL +# endif +#else +# define QT_CHECK_INVALID_MAP_ELEMENT +# define QT_CHECK_INVALID_MAP_ELEMENT_FATAL +#endif + +template class TQDeepCopy; + +template +class TQMap +{ +public: + /** + * Typedefs + */ + typedef Key key_type; + typedef T mapped_type; + typedef TQPair value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; +#ifndef QT_NO_STL + typedef ptrdiff_t difference_type; +#else + typedef int difference_type; +#endif + typedef size_t size_type; + typedef TQMapIterator iterator; + typedef TQMapConstIterator const_iterator; + typedef TQPair insert_pair; + + typedef TQMapIterator< Key, T > Iterator; + typedef TQMapConstIterator< Key, T > ConstIterator; + typedef T ValueType; + typedef TQMapPrivate< Key, T > Priv; + + /** + * API + */ + TQMap() + { + sh = new TQMapPrivate< Key, T >; + } + TQMap( const TQMap& m ) + { + sh = m.sh; sh->ref(); + } + +#ifndef QT_NO_STL + TQMap( const std::map& m ) + { + sh = new TQMapPrivate; + Q_TYPENAME std::map::const_iterator it = m.begin(); + for ( ; it != m.end(); ++it ) { + value_type p( (*it).first, (*it).second ); + insert( p ); + } + } +#endif + ~TQMap() + { + if ( sh->deref() ) + delete sh; + } + TQMap& operator= ( const TQMap& m ); +#ifndef QT_NO_STL + TQMap& operator= ( const std::map& m ) + { + clear(); + Q_TYPENAME std::map::const_iterator it = m.begin(); + for ( ; it != m.end(); ++it ) { + value_type p( (*it).first, (*it).second ); + insert( p ); + } + return *this; + } +#endif + + iterator begin() { detach(); return sh->begin(); } + iterator end() { detach(); return sh->end(); } + const_iterator begin() const { return ((const Priv*)sh)->begin(); } + const_iterator end() const { return ((const Priv*)sh)->end(); } + const_iterator constBegin() const { return begin(); } + const_iterator constEnd() const { return end(); } + + iterator replace( const Key& k, const T& v ) + { + remove( k ); + return insert( k, v ); + } + + size_type size() const + { + return sh->node_count; + } + bool empty() const + { + return sh->node_count == 0; + } + TQPair insert( const value_type& x ); + + void erase( iterator it ) + { + detach(); + sh->remove( it ); + } + void erase( const key_type& k ); + size_type count( const key_type& k ) const; + T& operator[] ( const Key& k ); + void clear(); + + iterator find ( const Key& k ) + { + detach(); + return iterator( sh->find( k ).node ); + } + const_iterator find ( const Key& k ) const { return sh->find( k ); } + + const T& operator[] ( const Key& k ) const + { QT_CHECK_INVALID_MAP_ELEMENT; return sh->find( k ).data(); } + bool contains ( const Key& k ) const + { return find( k ) != end(); } + //{ return sh->find( k ) != ((const Priv*)sh)->end(); } + + size_type count() const { return sh->node_count; } + + TQValueList keys() const { + TQValueList r; + for (const_iterator i=begin(); i!=end(); ++i) + r.append(i.key()); + return r; + } + + TQValueList values() const { + TQValueList r; + for (const_iterator i=begin(); i!=end(); ++i) + r.append(*i); + return r; + } + + bool isEmpty() const { return sh->node_count == 0; } + + iterator insert( const Key& key, const T& value, bool overwrite = TRUE ); + void remove( iterator it ) { detach(); sh->remove( it ); } + void remove( const Key& k ); + +#if defined(Q_FULL_TEMPLATE_INSTANTIATION) + bool operator==( const TQMap& ) const { return FALSE; } +#ifndef QT_NO_STL + bool operator==( const std::map& ) const { return FALSE; } +#endif +#endif + +protected: + /** + * Helpers + */ + void detach() { if ( sh->count > 1 ) detachInternal(); } + + Priv* sh; +private: + void detachInternal(); + + friend class TQDeepCopy< TQMap >; +}; + +template +Q_INLINE_TEMPLATES TQMap& TQMap::operator= ( const TQMap& m ) +{ + m.sh->ref(); + if ( sh->deref() ) + delete sh; + sh = m.sh; + return *this; +} + +template +Q_INLINE_TEMPLATES Q_TYPENAME TQMap::insert_pair TQMap::insert( const Q_TYPENAME TQMap::value_type& x ) +{ + detach(); + size_type n = size(); + iterator it = sh->insertSingle( x.first ); + bool inserted = FALSE; + if ( n < size() ) { + inserted = TRUE; + it.data() = x.second; + } + return TQPair( it, inserted ); +} + +template +Q_INLINE_TEMPLATES void TQMap::erase( const Key& k ) +{ + detach(); + iterator it( sh->find( k ).node ); + if ( it != end() ) + sh->remove( it ); +} + +template +Q_INLINE_TEMPLATES Q_TYPENAME TQMap::size_type TQMap::count( const Key& k ) const +{ + const_iterator it( sh->find( k ).node ); + if ( it != end() ) { + size_type c = 0; + while ( it != end() ) { + ++it; + ++c; + } + return c; + } + return 0; +} + +template +Q_INLINE_TEMPLATES T& TQMap::operator[] ( const Key& k ) +{ + detach(); + TQMapNode* p = sh->find( k ).node; + if ( p != sh->end().node ) + return p->data; + return insert( k, T() ).data(); +} + +template +Q_INLINE_TEMPLATES void TQMap::clear() +{ + if ( sh->count == 1 ) + sh->clear(); + else { + sh->deref(); + sh = new TQMapPrivate; + } +} + +template +Q_INLINE_TEMPLATES Q_TYPENAME TQMap::iterator TQMap::insert( const Key& key, const T& value, bool overwrite ) +{ + detach(); + size_type n = size(); + iterator it = sh->insertSingle( key ); + if ( overwrite || n < size() ) + it.data() = value; + return it; +} + +template +Q_INLINE_TEMPLATES void TQMap::remove( const Key& k ) +{ + detach(); + iterator it( sh->find( k ).node ); + if ( it != end() ) + sh->remove( it ); +} + +template +Q_INLINE_TEMPLATES void TQMap::detachInternal() +{ + sh->deref(); sh = new TQMapPrivate( sh ); +} + + +#ifndef QT_NO_DATASTREAM +template +Q_INLINE_TEMPLATES TQDataStream& operator>>( TQDataStream& s, TQMap& m ) { + m.clear(); + Q_UINT32 c; + s >> c; + for( Q_UINT32 i = 0; i < c; ++i ) { + Key k; T t; + s >> k >> t; + m.insert( k, t ); + if ( s.atEnd() ) + break; + } + return s; +} + + +template +Q_INLINE_TEMPLATES TQDataStream& operator<<( TQDataStream& s, const TQMap& m ) { + s << (Q_UINT32)m.size(); + TQMapConstIterator it = m.begin(); + for( ; it != m.end(); ++it ) + s << it.key() << it.data(); + return s; +} +#endif + +#define Q_DEFINED_QMAP +#include "qwinexport.h" +#endif // TQMAP_H diff --git a/src/tools/qmemarray.h b/src/tools/qmemarray.h new file mode 100644 index 000000000..1f80fc7f3 --- /dev/null +++ b/src/tools/qmemarray.h @@ -0,0 +1,121 @@ +/**************************************************************************** +** +** Definition of TQMemArray template/macro class +** +** Created : 930906 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQMEMARRAY_H +#define TQMEMARRAY_H + +#ifndef QT_H +#include "qgarray.h" +#endif // QT_H + + +template +class TQMemArray : public TQGArray +{ +public: + typedef type* Iterator; + typedef const type* ConstIterator; + typedef type ValueType; + +protected: + TQMemArray( int, int ) : TQGArray( 0, 0 ) {} + +public: + TQMemArray() {} + TQMemArray( int size ) : TQGArray(size*sizeof(type)) {} // ### 4.0 Q_EXPLICIT + TQMemArray( const TQMemArray &a ) : TQGArray(a) {} + ~TQMemArray() {} + TQMemArray &operator=(const TQMemArray &a) + { return (TQMemArray&)TQGArray::assign(a); } + type *data() const { return (type *)TQGArray::data(); } + uint nrefs() const { return TQGArray::nrefs(); } + uint size() const { return TQGArray::size()/sizeof(type); } + uint count() const { return size(); } + bool isEmpty() const { return TQGArray::size() == 0; } + bool isNull() const { return TQGArray::data() == 0; } + bool resize( uint size ) { return TQGArray::resize(size*sizeof(type)); } + bool resize( uint size, Optimization optim ) { return TQGArray::resize(size*sizeof(type), optim); } + bool truncate( uint pos ) { return TQGArray::resize(pos*sizeof(type)); } + bool fill( const type &d, int size = -1 ) + { return TQGArray::fill((char*)&d,size,sizeof(type) ); } + void detach() { TQGArray::detach(); } + TQMemArray copy() const + { TQMemArray tmp; return tmp.duplicate(*this); } + TQMemArray& assign( const TQMemArray& a ) + { return (TQMemArray&)TQGArray::assign(a); } + TQMemArray& assign( const type *a, uint n ) + { return (TQMemArray&)TQGArray::assign((char*)a,n*sizeof(type)); } + TQMemArray& duplicate( const TQMemArray& a ) + { return (TQMemArray&)TQGArray::duplicate(a); } + TQMemArray& duplicate( const type *a, uint n ) + { return (TQMemArray&)TQGArray::duplicate((char*)a,n*sizeof(type)); } + TQMemArray& setRawData( const type *a, uint n ) + { return (TQMemArray&)TQGArray::setRawData((char*)a, + n*sizeof(type)); } + void resetRawData( const type *a, uint n ) + { TQGArray::resetRawData((char*)a,n*sizeof(type)); } + int find( const type &d, uint i=0 ) const + { return TQGArray::find((char*)&d,i,sizeof(type)); } + int contains( const type &d ) const + { return TQGArray::contains((char*)&d,sizeof(type)); } + void sort() { TQGArray::sort(sizeof(type)); } + int bsearch( const type &d ) const + { return TQGArray::bsearch((const char*)&d,sizeof(type)); } + // ### TQt 4.0: maybe provide uint overload as work-around for MSVC bug + type& operator[]( int i ) const + { return (type &)(*(type *)TQGArray::at(i*sizeof(type))); } + type& at( uint i ) const + { return (type &)(*(type *)TQGArray::at(i*sizeof(type))); } + operator const type*() const { return (const type *)TQGArray::data(); } + bool operator==( const TQMemArray &a ) const { return isEqual(a); } + bool operator!=( const TQMemArray &a ) const { return !isEqual(a); } + Iterator begin() { return data(); } + Iterator end() { return data() + size(); } + ConstIterator begin() const { return data(); } + ConstIterator end() const { return data() + size(); } +}; + +#ifndef QT_NO_COMPAT +#define TQArray TQMemArray +#endif + +#define Q_DEFINED_QMEMARRAY +#include "qwinexport.h" +#endif // TQARRAY_H diff --git a/src/tools/qmutex.h b/src/tools/qmutex.h new file mode 100644 index 000000000..a50c600df --- /dev/null +++ b/src/tools/qmutex.h @@ -0,0 +1,114 @@ +/**************************************************************************** +** +** Definition of TQMutex class +** +** Created : 931107 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQMUTEX_H +#define TQMUTEX_H + +#ifndef QT_H +#include "qglobal.h" +#endif // QT_H + +#if defined(QT_THREAD_SUPPORT) + +class TQMutexPrivate; + +const int Q_MUTEX_NORMAL = 0; +const int Q_MUTEX_RECURSIVE = 1; + +class Q_EXPORT TQMutex +{ + friend class TQThread; + friend class TQWaitCondition; + friend class TQWaitConditionPrivate; + +public: + TQMutex(bool recursive = FALSE); + virtual ~TQMutex(); + + void lock(); + void unlock(); + bool locked(); + bool tryLock(); + +private: + TQMutexPrivate * d; + +#if defined(Q_DISABLE_COPY) + TQMutex( const TQMutex & ); + TQMutex &operator=( const TQMutex & ); +#endif +}; + +class Q_EXPORT TQMutexLocker +{ +public: + TQMutexLocker( TQMutex * ); + ~TQMutexLocker(); + + TQMutex *mutex() const; + +private: + TQMutex *mtx; + +#if defined(Q_DISABLE_COPY) + TQMutexLocker( const TQMutexLocker & ); + TQMutexLocker &operator=( const TQMutexLocker & ); +#endif +}; + +inline TQMutexLocker::TQMutexLocker( TQMutex *m ) + : mtx( m ) +{ + if ( mtx ) mtx->lock(); +} + +inline TQMutexLocker::~TQMutexLocker() +{ + if ( mtx ) mtx->unlock(); +} + +inline TQMutex *TQMutexLocker::mutex() const +{ + return mtx; +} + +#endif + +#endif diff --git a/src/tools/qmutex_p.h b/src/tools/qmutex_p.h new file mode 100644 index 000000000..16879e492 --- /dev/null +++ b/src/tools/qmutex_p.h @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** TQMutex private class declarations +** +** Created : 20012507 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQMUTEX_P_H +#define TQMUTEX_P_H + +#ifndef QT_H +#endif // QT_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the TQt API. It exists for the convenience +// of qmutex_unix.cpp and qmutex_win.cpp. This header file may change +// from version to version without notice, or even be removed. +// +// We mean it. +// + +class TQMutexPrivate { +public: + // Q_MUTEX_T is defined in the various *.cpp files + Q_MUTEX_T handle; + + virtual ~TQMutexPrivate(); + + virtual void lock() = 0; + virtual void unlock() = 0; + virtual bool locked() = 0; + virtual bool trylock() = 0; + virtual int type() const = 0; +}; + + +#endif // TQMUTEX_P_H diff --git a/src/tools/qmutex_unix.cpp b/src/tools/qmutex_unix.cpp new file mode 100644 index 000000000..8e25f4228 --- /dev/null +++ b/src/tools/qmutex_unix.cpp @@ -0,0 +1,695 @@ +/**************************************************************************** +** +** TQMutex class for Unix +** +** Created : 20010725 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#if defined(QT_THREAD_SUPPORT) + +#include "qplatformdefs.h" + +typedef pthread_mutex_t Q_MUTEX_T; + +// POSIX threads mutex types +#if ((defined(PTHREAD_MUTEX_RECURSIVE) && defined(PTHREAD_MUTEX_DEFAULT)) || \ + defined(Q_OS_FREEBSD)) && !defined(Q_OS_UNIXWARE) && !defined(Q_OS_SOLARIS) && \ + !defined(Q_OS_MAC) +// POSIX 1003.1c-1995 - We love this OS +# define Q_MUTEX_SET_TYPE(a, b) pthread_mutexattr_settype((a), (b)) +# if defined(QT_CHECK_RANGE) +# define Q_NORMAL_MUTEX_TYPE PTHREAD_MUTEX_ERRORCHECK +# else +# define Q_NORMAL_MUTEX_TYPE PTHREAD_MUTEX_DEFAULT +# endif +# define Q_RECURSIVE_MUTEX_TYPE PTHREAD_MUTEX_RECURSIVE +#elif defined(MUTEX_NONRECURSIVE_NP) && defined(MUTEX_RECURSIVE_NP) +// POSIX 1003.4a pthreads draft extensions +# define Q_MUTEX_SET_TYPE(a, b) pthread_mutexattr_setkind_np((a), (b)); +# define Q_NORMAL_MUTEX_TYPE MUTEX_NONRECURSIVE_NP +# define Q_RECURSIVE_MUTEX_TYPE MUTEX_RECURSIVE_NP +#else +// Unknown mutex types - skip them +# define Q_MUTEX_SET_TYPE(a, b) +# undef Q_NORMAL_MUTEX_TYPE +# undef Q_RECURSIVE_MUTEX_TYPE +#endif + +#include "qmutex.h" +#include "qmutex_p.h" + +#include +#include + + +// Private class declarations + +class TQRealMutexPrivate : public TQMutexPrivate { +public: + TQRealMutexPrivate(bool = FALSE); + + void lock(); + void unlock(); + bool locked(); + bool trylock(); + int type() const; + + bool recursive; +}; + +#ifndef Q_RECURSIVE_MUTEX_TYPE +class TQRecursiveMutexPrivate : public TQMutexPrivate +{ +public: + TQRecursiveMutexPrivate(); + ~TQRecursiveMutexPrivate(); + + void lock(); + void unlock(); + bool locked(); + bool trylock(); + int type() const; + + int count; + unsigned long owner; + pthread_mutex_t handle2; +}; +#endif // !Q_RECURSIVE_MUTEX_TYPE + + +// Private class implementation + +// base destructor +TQMutexPrivate::~TQMutexPrivate() +{ + int ret = pthread_mutex_destroy(&handle); + +#ifdef QT_CHECK_RANGE + if ( ret ) + qWarning( "Mutex destroy failure: %s", strerror( ret ) ); +#endif +} + +// real mutex class +TQRealMutexPrivate::TQRealMutexPrivate(bool recurs) + : recursive(recurs) +{ + pthread_mutexattr_t attr; + pthread_mutexattr_init(&attr); + Q_MUTEX_SET_TYPE(&attr, recursive ? Q_RECURSIVE_MUTEX_TYPE : Q_NORMAL_MUTEX_TYPE); + Q_UNUSED(recursive); + int ret = pthread_mutex_init(&handle, &attr); + pthread_mutexattr_destroy(&attr); + +#ifdef QT_CHECK_RANGE + if( ret ) + qWarning( "Mutex init failure: %s", strerror( ret ) ); +#endif // QT_CHECK_RANGE +} + +void TQRealMutexPrivate::lock() +{ + int ret = pthread_mutex_lock(&handle); + +#ifdef QT_CHECK_RANGE + if (ret) + qWarning("Mutex lock failure: %s", strerror(ret)); +#endif +} + +void TQRealMutexPrivate::unlock() +{ + int ret = pthread_mutex_unlock(&handle); + +#ifdef QT_CHECK_RANGE + if (ret) + qWarning("Mutex unlock failure: %s", strerror(ret)); +#endif +} + +bool TQRealMutexPrivate::locked() +{ + int ret = pthread_mutex_trylock(&handle); + + if (ret == EBUSY) { + return TRUE; + } else if (ret) { +#ifdef QT_CHECK_RANGE + qWarning("Mutex locktest failure: %s", strerror(ret)); +#endif + } else + pthread_mutex_unlock(&handle); + + return FALSE; +} + +bool TQRealMutexPrivate::trylock() +{ + int ret = pthread_mutex_trylock(&handle); + + if (ret == EBUSY) { + return FALSE; + } else if (ret) { +#ifdef QT_CHECK_RANGE + qWarning("Mutex trylock failure: %s", strerror(ret)); +#endif + return FALSE; + } + + return TRUE; +} + +int TQRealMutexPrivate::type() const +{ + return recursive ? Q_MUTEX_RECURSIVE : Q_MUTEX_NORMAL; +} + + +#ifndef Q_RECURSIVE_MUTEX_TYPE +TQRecursiveMutexPrivate::TQRecursiveMutexPrivate() + : count(0), owner(0) +{ + pthread_mutexattr_t attr; + pthread_mutexattr_init(&attr); + Q_MUTEX_SET_TYPE(&attr, Q_NORMAL_MUTEX_TYPE); + int ret = pthread_mutex_init(&handle, &attr); + pthread_mutexattr_destroy(&attr); + +# ifdef QT_CHECK_RANGE + if (ret) + qWarning( "Mutex init failure: %s", strerror(ret) ); +# endif + + pthread_mutexattr_init(&attr); + ret = pthread_mutex_init( &handle2, &attr ); + pthread_mutexattr_destroy(&attr); + +# ifdef QT_CHECK_RANGE + if (ret) + qWarning( "Mutex init failure: %s", strerror(ret) ); +# endif +} + +TQRecursiveMutexPrivate::~TQRecursiveMutexPrivate() +{ + int ret = pthread_mutex_destroy(&handle2); + +# ifdef QT_CHECK_RANGE + if (ret) + qWarning( "Mutex destroy failure: %s", strerror(ret) ); +# endif +} + +void TQRecursiveMutexPrivate::lock() +{ + pthread_mutex_lock(&handle2); + + if (count > 0 && owner == (unsigned long) pthread_self()) { + count++; + } else { + pthread_mutex_unlock(&handle2); + pthread_mutex_lock(&handle); + pthread_mutex_lock(&handle2); + count = 1; + owner = (unsigned long) pthread_self(); + } + + pthread_mutex_unlock(&handle2); +} + +void TQRecursiveMutexPrivate::unlock() +{ + pthread_mutex_lock(&handle2); + + if (owner == (unsigned long) pthread_self()) { + // do nothing if the count is already 0... to reflect the behaviour described + // in the docs + if (count && (--count) < 1) { + count = 0; + pthread_mutex_unlock(&handle); + } + } else { +#ifdef QT_CHECK_RANGE + qWarning("TQMutex::unlock: unlock from different thread than locker"); + qWarning(" was locked by %d, unlock attempt from %d", + (int)owner, (int)pthread_self()); +#endif + } + + pthread_mutex_unlock(&handle2); +} + +bool TQRecursiveMutexPrivate::locked() +{ + pthread_mutex_lock(&handle2); + + bool ret; + int code = pthread_mutex_trylock(&handle); + + if (code == EBUSY) { + ret = TRUE; + } else { +#ifdef QT_CHECK_RANGE + if (code) + qWarning("Mutex trylock failure: %s", strerror(code)); +#endif + + pthread_mutex_unlock(&handle); + ret = FALSE; + } + + pthread_mutex_unlock(&handle2); + + return ret; +} + +bool TQRecursiveMutexPrivate::trylock() +{ + bool ret = TRUE; + + pthread_mutex_lock(&handle2); + + if ( count > 0 && owner == (unsigned long) pthread_self() ) { + count++; + } else { + int code = pthread_mutex_trylock(&handle); + + if (code == EBUSY) { + ret = FALSE; + } else if (code) { +#ifdef QT_CHECK_RANGE + qWarning("Mutex trylock failure: %s", strerror(code)); +#endif + ret = FALSE; + } else { + count = 1; + owner = (unsigned long) pthread_self(); + } + } + + pthread_mutex_unlock(&handle2); + + return ret; +} + +int TQRecursiveMutexPrivate::type() const +{ + return Q_MUTEX_RECURSIVE; +} + +#endif // !Q_RECURSIVE_MUTEX_TYPE + + +/*! + \class TQMutex qmutex.h + \threadsafe + \brief The TQMutex class provides access serialization between threads. + + \ingroup thread + \ingroup environment + + The purpose of a TQMutex is to protect an object, data structure or + section of code so that only one thread can access it at a time + (This is similar to the Java \c synchronized keyword). For + example, say there is a method which prints a message to the user + on two lines: + + \code + int number = 6; + + void method1() + { + number *= 5; + number /= 4; + } + + void method2() + { + number *= 3; + number /= 2; + } + \endcode + + If these two methods are called in succession, the following happens: + + \code + // method1() + number *= 5; // number is now 30 + number /= 4; // number is now 7 + + // method2() + number *= 3; // nubmer is now 21 + number /= 2; // number is now 10 + \endcode + + If these two methods are called simultaneously from two threads then the + following sequence could result: + + \code + // Thread 1 calls method1() + number *= 5; // number is now 30 + + // Thread 2 calls method2(). + // + // Most likely Thread 1 has been put to sleep by the operating + // system to allow Thread 2 to run. + number *= 3; // number is now 90 + number /= 2; // number is now 45 + + // Thread 1 finishes executing. + number /= 4; // number is now 11, instead of 10 + \endcode + + If we add a mutex, we should get the result we want: + + \code + TQMutex mutex; + int number = 6; + + void method1() + { + mutex.lock(); + number *= 5; + number /= 4; + mutex.unlock(); + } + + void method2() + { + mutex.lock(); + number *= 3; + number /= 2; + mutex.unlock(); + } + \endcode + + Then only one thread can modify \c number at any given time and + the result is correct. This is a trivial example, of course, but + applies to any other case where things need to happen in a + particular sequence. + + When you call lock() in a thread, other threads that try to call + lock() in the same place will block until the thread that got the + lock calls unlock(). A non-blocking alternative to lock() is + tryLock(). +*/ + +/*! + Constructs a new mutex. The mutex is created in an unlocked state. + A recursive mutex is created if \a recursive is TRUE; a normal + mutex is created if \a recursive is FALSE (the default). With a + recursive mutex, a thread can lock the same mutex multiple times + and it will not be unlocked until a corresponding number of + unlock() calls have been made. +*/ +TQMutex::TQMutex(bool recursive) +{ +#ifndef Q_RECURSIVE_MUTEX_TYPE + if ( recursive ) + d = new TQRecursiveMutexPrivate(); + else +#endif // !Q_RECURSIVE_MUTEX_TYPE + d = new TQRealMutexPrivate(recursive); +} + +/*! + Destroys the mutex. + + \warning If you destroy a mutex that still holds a lock the + resultant behavior is undefined. +*/ +TQMutex::~TQMutex() +{ + delete d; +} + +/*! + Attempt to lock the mutex. If another thread has locked the mutex + then this call will \e block until that thread has unlocked it. + + \sa unlock(), locked() +*/ +void TQMutex::lock() +{ + d->lock(); +} + +/*! + Unlocks the mutex. Attempting to unlock a mutex in a different + thread to the one that locked it results in an error. Unlocking a + mutex that is not locked results in undefined behaviour (varies + between different Operating Systems' thread implementations). + + \sa lock(), locked() +*/ +void TQMutex::unlock() +{ + d->unlock(); +} + +/*! + Returns TRUE if the mutex is locked by another thread; otherwise + returns FALSE. + + \warning Due to differing implementations of recursive mutexes on + various platforms, calling this function from the same thread that + previously locked the mutex will return undefined results. + + \sa lock(), unlock() +*/ +bool TQMutex::locked() +{ + return d->locked(); +} + +/*! + Attempt to lock the mutex. If the lock was obtained, this function + returns TRUE. If another thread has locked the mutex, this + function returns FALSE, instead of waiting for the mutex to become + available, i.e. it does not block. + + If the lock was obtained, the mutex must be unlocked with unlock() + before another thread can successfully lock it. + + \sa lock(), unlock(), locked() +*/ +bool TQMutex::tryLock() +{ + return d->trylock(); +} + +/*! + \class TQMutexLocker qmutex.h + \brief The TQMutexLocker class simplifies locking and unlocking TQMutexes. + + \threadsafe + + \ingroup thread + \ingroup environment + + The purpose of TQMutexLocker is to simplify TQMutex locking and + unlocking. Locking and unlocking a TQMutex in complex functions and + statements or in exception handling code is error prone and + difficult to debug. TQMutexLocker should be used in such situations + to ensure that the state of the mutex is well defined and always + locked and unlocked properly. + + TQMutexLocker should be created within a function where a TQMutex + needs to be locked. The mutex is locked when TQMutexLocker is + created, and unlocked when TQMutexLocker is destroyed. + + For example, this complex function locks a TQMutex upon entering + the function and unlocks the mutex at all the exit points: + + \code + int complexFunction( int flag ) + { + mutex.lock(); + + int return_value = 0; + + switch ( flag ) { + case 0: + case 1: + { + mutex.unlock(); + return moreComplexFunction( flag ); + } + + case 2: + { + int status = anotherFunction(); + if ( status < 0 ) { + mutex.unlock(); + return -2; + } + return_value = status + flag; + break; + } + + default: + { + if ( flag > 10 ) { + mutex.unlock(); + return -1; + } + break; + } + } + + mutex.unlock(); + return return_value; + } + \endcode + + This example function will get more complicated as it is + developed, which increases the likelihood that errors will occur. + + Using TQMutexLocker greatly simplifies the code, and makes it more + readable: + + \code + int complexFunction( int flag ) + { + TQMutexLocker locker( &mutex ); + + int return_value = 0; + + switch ( flag ) { + case 0: + case 1: + { + return moreComplexFunction( flag ); + } + + case 2: + { + int status = anotherFunction(); + if ( status < 0 ) + return -2; + return_value = status + flag; + break; + } + + default: + { + if ( flag > 10 ) + return -1; + break; + } + } + + return return_value; + } + \endcode + + Now, the mutex will always be unlocked when the TQMutexLocker + object is destroyed (when the function returns since \c locker is + an auto variable). Note that the mutex will be unlocked after + the call to moreComplexFunction() in this example, avoiding + possible bugs caused by unlocking the mutex too early, as in + the first example. + + The same principle applies to code that throws and catches + exceptions. An exception that is not caught in the function that + has locked the mutex has no way of unlocking the mutex before the + exception is passed up the stack to the calling function. + + TQMutexLocker also provides a mutex() member function that returns + the mutex on which the TQMutexLocker is operating. This is useful + for code that needs access to the mutex, such as + TQWaitCondition::wait(). For example: + + \code + class SignalWaiter + { + private: + TQMutexLocker locker; + + public: + SignalWaiter( TQMutex *mutex ) + : locker( mutex ) + { + } + + void waitForSignal() + { + ... + ... + ... + + while ( ! signalled ) + waitcondition.wait( locker.mutex() ); + + ... + ... + ... + } + }; + \endcode + + \sa TQMutex, TQWaitCondition +*/ + +/*! + \fn TQMutexLocker::TQMutexLocker( TQMutex *mutex ) + + Constructs a TQMutexLocker and locks \a mutex. The mutex will be + unlocked when the TQMutexLocker is destroyed. If \a mutex is zero, + TQMutexLocker does nothing. + + \sa TQMutex::lock() +*/ + +/*! + \fn TQMutexLocker::~TQMutexLocker() + + Destroys the TQMutexLocker and unlocks the mutex which was locked + in the constructor. + + \sa TQMutexLocker::TQMutexLocker(), TQMutex::unlock() +*/ + +/*! + \fn TQMutex *TQMutexLocker::mutex() const + + Returns a pointer to the mutex which was locked in the + constructor. + + \sa TQMutexLocker::TQMutexLocker() +*/ + +#endif // QT_THREAD_SUPPORT diff --git a/src/tools/qmutexpool.cpp b/src/tools/qmutexpool.cpp new file mode 100644 index 000000000..bcf20edab --- /dev/null +++ b/src/tools/qmutexpool.cpp @@ -0,0 +1,155 @@ +/**************************************************************************** +** +** ... +** +** Copyright (C) 2005-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "qmutexpool_p.h" + +#ifdef QT_THREAD_SUPPORT + +#include + +Q_EXPORT TQMutexPool *qt_global_mutexpool = 0; + + +/*! + \class TQMutexPool qmutexpool_p.h + \brief The TQMutexPool class provides a pool of TQMutex objects. + + \internal + + \ingroup thread + + TQMutexPool is a convenience class that provides access to a fixed + number of TQMutex objects. + + Typical use of a TQMutexPool is in situations where it is not + possible or feasible to use one TQMutex for every protected object. + The mutex pool will return a mutex based on the address of the + object that needs protection. + + For example, consider this simple class: + + \code + class Number { + public: + Number( double n ) : num ( n ) { } + + void setNumber( double n ) { num = n; } + double number() const { return num; } + + private: + double num; + }; + \endcode + + Adding a TQMutex member to the Number class does not make sense, + because it is so small. However, in order to ensure that access to + each Number is protected, you need to use a mutex. In this case, a + TQMutexPool would be ideal. + + Code to calculate the square of a number would then look something + like this: + + \code + void calcSquare( Number *num ) + { + TQMutexLocker locker( mutexpool.get( num ) ); + num.setNumber( num.number() * num.number() ); + } + \endcode + + This function will safely calculate the square of a number, since + it uses a mutex from a TQMutexPool. The mutex is locked and + unlocked automatically by the TQMutexLocker class. See the + TQMutexLocker documentation for more details. +*/ + +/*! + Constructs a TQMutexPool, reserving space for \a size TQMutexes. If + \a recursive is TRUE, all TQMutexes in the pool will be recursive + mutexes; otherwise they will all be non-recursive (the default). + + The TQMutexes are created when needed, and deleted when the + TQMutexPool is destructed. +*/ +TQMutexPool::TQMutexPool( bool recursive, int size ) + : mutex( FALSE ), count( size ), recurs( recursive ) +{ + mutexes = new TQMutex*[count]; + for ( int index = 0; index < count; ++index ) { + mutexes[index] = 0; + } +} + +/*! + Destructs a TQMutexPool. All TQMutexes that were created by the pool + are deleted. +*/ +TQMutexPool::~TQMutexPool() +{ + TQMutexLocker locker( &mutex ); + for ( int index = 0; index < count; ++index ) { + delete mutexes[index]; + mutexes[index] = 0; + } + delete [] mutexes; + mutexes = 0; +} + +/*! + Returns a TQMutex from the pool. TQMutexPool uses the value \a + address to determine which mutex is retured from the pool. +*/ +TQMutex *TQMutexPool::get( void *address ) +{ + int index = (int) ( (unsigned long) address % count ); + + if ( ! mutexes[index] ) { + // mutex not created, create one + + TQMutexLocker locker( &mutex ); + // we need to check once again that the mutex hasn't been created, since + // 2 threads could be trying to create a mutex as the same index... + if ( ! mutexes[index] ) { + mutexes[index] = new TQMutex( recurs ); + } + } + + return mutexes[index]; +} + +#endif diff --git a/src/tools/qmutexpool_p.h b/src/tools/qmutexpool_p.h new file mode 100644 index 000000000..81c26f615 --- /dev/null +++ b/src/tools/qmutexpool_p.h @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** ... +** +** Copyright (C) 2005-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQMUTEXPOOL_P_H +#define TQMUTEXPOOL_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the TQt API. It exists for the convenience +// of TQSettings. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// +// + +#ifdef QT_THREAD_SUPPORT + +#ifndef QT_H +#include "qmutex.h" +#include "qmemarray.h" +#endif // QT_H + +class Q_EXPORT TQMutexPool +{ +public: + TQMutexPool( bool recursive = FALSE, int size = 17 ); + ~TQMutexPool(); + + TQMutex *get( void *address ); + +private: + TQMutex mutex; + TQMutex **mutexes; + int count; + bool recurs; +}; + +extern Q_EXPORT TQMutexPool *qt_global_mutexpool; + +#endif // QT_THREAD_SUPPORT + +#endif // TQMUTEXPOOL_P_H diff --git a/src/tools/qpair.h b/src/tools/qpair.h new file mode 100644 index 000000000..cec1385de --- /dev/null +++ b/src/tools/qpair.h @@ -0,0 +1,109 @@ +/**************************************************************************** +** +** Definition of TQPair class +** +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQPAIR_H +#define TQPAIR_H + +#ifndef QT_H +#include "qglobal.h" +#include "qdatastream.h" +#endif // QT_H + +template +struct TQPair +{ + typedef T1 first_type; + typedef T2 second_type; + + TQPair() + : first( T1() ), second( T2() ) + {} + TQPair( const T1& t1, const T2& t2 ) + : first( t1 ), second( t2 ) + {} + + TQPair& operator=(const TQPair& other) + { + if (this != &other) { + first = other.first; + second = other.second; + } + return *this; + } + + T1 first; + T2 second; +}; + +template +Q_INLINE_TEMPLATES bool operator==( const TQPair& x, const TQPair& y ) +{ + return x.first == y.first && x.second == y.second; +} + +template +Q_INLINE_TEMPLATES bool operator<( const TQPair& x, const TQPair& y ) +{ + return x.first < y.first || + ( !( y.first < x.first ) && x.second < y.second ); +} + +template +Q_INLINE_TEMPLATES TQPair qMakePair( const T1& x, const T2& y ) +{ + return TQPair( x, y ); +} + +#ifndef QT_NO_DATASTREAM +template +inline TQDataStream& operator>>( TQDataStream& s, TQPair& p ) +{ + s >> p.first >> p.second; + return s; +} + +template +inline TQDataStream& operator<<( TQDataStream& s, const TQPair& p ) +{ + s << p.first << p.second; + return s; +} +#endif + +#endif diff --git a/src/tools/qpluginmanager_p.h b/src/tools/qpluginmanager_p.h new file mode 100644 index 000000000..3bc839591 --- /dev/null +++ b/src/tools/qpluginmanager_p.h @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Definition of TQPluginManager class +** +** Created : 000101 +** +** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQPLUGINMANAGER_P_H +#define TQPLUGINMANAGER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the TQt API. It exists for the convenience +// of a number of TQt sources files. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// +// + +#ifndef QT_H +#include "qgpluginmanager_p.h" +#endif // QT_H + +#ifndef QT_NO_COMPONENT + +template +class TQPluginManager : public TQGPluginManager +{ +public: + TQPluginManager( const TQUuid& id, const TQStringList& paths = TQString::null, const TQString &suffix = TQString::null, bool cs = TRUE ) + : TQGPluginManager( id, paths, suffix, cs ) {} + TQRESULT queryInterface(const TQString& feature, Type** iface) const + { + return queryUnknownInterface( feature, (TQUnknownInterface**)iface ); + } +}; + +#endif //QT_NO_COMPONENT + +#endif //TQPLUGINMANAGER_P_H diff --git a/src/tools/qptrcollection.cpp b/src/tools/qptrcollection.cpp new file mode 100644 index 000000000..d2f4fde61 --- /dev/null +++ b/src/tools/qptrcollection.cpp @@ -0,0 +1,183 @@ +/**************************************************************************** +** +** Implementation of base class for all pointer based collection classes +** +** Created : 920820 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "qptrcollection.h" + +/*! + \class TQPtrCollection qptrcollection.h + \reentrant + \brief The TQPtrCollection class is the base class of most pointer-based TQt collections. + + \ingroup collection + \ingroup tools + + The TQPtrCollection class is an abstract base class for the TQt + \link collection.html collection classes\endlink TQDict, TQPtrList, + etc. TQt also includes value based collections, e.g. TQValueList, + TQMap, etc. + + A TQPtrCollection only knows about the number of objects in the + collection and the deletion strategy (see setAutoDelete()). + + A collection is implemented using the \c Item (generic collection + item) type, which is a \c void*. The template classes that create + the real collections cast the \c Item to the retquired type. +*/ + + +/*! + \enum TQPtrCollection::Item + + This type is the generic "item" in a TQPtrCollection. +*/ + + +/*! + \fn TQPtrCollection::TQPtrCollection() + + Constructs a collection. The constructor is protected because + TQPtrCollection is an abstract class. +*/ + +/*! + \fn TQPtrCollection::TQPtrCollection( const TQPtrCollection & source ) + + Constructs a copy of \a source with autoDelete() set to FALSE. The + constructor is protected because TQPtrCollection is an abstract + class. + + Note that if \a source has autoDelete turned on, copying it will + risk memory leaks, reading freed memory, or both. +*/ + +/*! + \fn TQPtrCollection::~TQPtrCollection() + + Destroys the collection. The destructor is protected because + TQPtrCollection is an abstract class. +*/ + + +/*! + \fn bool TQPtrCollection::autoDelete() const + + Returns the setting of the auto-delete option. The default is FALSE. + + \sa setAutoDelete() +*/ + +/*! + \fn void TQPtrCollection::setAutoDelete( bool enable ) + + Sets the collection to auto-delete its contents if \a enable is + TRUE and to never delete them if \a enable is FALSE. + + If auto-deleting is turned on, all the items in a collection are + deleted when the collection itself is deleted. This is convenient + if the collection has the only pointer to the items. + + The default setting is FALSE, for safety. If you turn it on, be + careful about copying the collection - you might find yourself + with two collections deleting the same items. + + Note that the auto-delete setting may also affect other functions + in subclasses. For example, a subclass that has a remove() + function will remove the item from its data structure, and if + auto-delete is enabled, will also delete the item. + + \sa autoDelete() +*/ + + +/*! + \fn virtual uint TQPtrCollection::count() const + + Returns the number of objects in the collection. +*/ + +/*! + \fn virtual void TQPtrCollection::clear() + + Removes all objects from the collection. The objects will be + deleted if auto-delete has been enabled. + + \sa setAutoDelete() +*/ + +/*! + \fn void TQPtrCollection::deleteItem( Item d ) + + Reimplement this function if you want to be able to delete items. + + Deletes an item that is about to be removed from the collection. + + This function has to reimplemented in the collection template + classes, and should \e only delete item \a d if auto-delete has + been enabled. + + \warning If you reimplement this function you must also + reimplement the destructor and call the virtual function clear() + from your destructor. This is due to the way virtual functions and + destructors work in C++: Virtual functions in derived classes + cannot be called from a destructor. If you do not do this, your + deleteItem() function will not be called when the container is + destroyed. + + \sa newItem(), setAutoDelete() +*/ + +/*! + Virtual function that creates a copy of an object that is about to + be inserted into the collection. + + The default implementation returns the \a d pointer, i.e. no copy + is made. + + This function is seldom reimplemented in the collection template + classes. It is not common practice to make a copy of something + that is being inserted. + + \sa deleteItem() +*/ + +TQPtrCollection::Item TQPtrCollection::newItem( Item d ) +{ + return d; // just return reference +} diff --git a/src/tools/qptrcollection.h b/src/tools/qptrcollection.h new file mode 100644 index 000000000..676e5c512 --- /dev/null +++ b/src/tools/qptrcollection.h @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Definition of base class for all pointer based collection classes +** +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQPTRCOLLECTION_H +#define TQPTRCOLLECTION_H + +#ifndef QT_H +#include "qglobal.h" +#endif // QT_H + + +class TQGVector; +class TQGList; +class TQGDict; + + +class Q_EXPORT TQPtrCollection // inherited by all collections +{ +public: + bool autoDelete() const { return del_item; } + void setAutoDelete( bool enable ) { del_item = enable; } + + virtual uint count() const = 0; + virtual void clear() = 0; // delete all objects + + typedef void *Item; // generic collection item + +protected: + TQPtrCollection() { del_item = FALSE; } // no deletion of objects + TQPtrCollection(const TQPtrCollection &) { del_item = FALSE; } + virtual ~TQPtrCollection() {} + + bool del_item; // default FALSE + + virtual Item newItem( Item ); // create object + virtual void deleteItem( Item ) = 0; // delete object +}; + + +#ifndef QT_NO_COMPAT +#define TQCollection TQPtrCollection +#endif + +#endif // TQPTRCOLLECTION_H diff --git a/src/tools/qptrdict.h b/src/tools/qptrdict.h new file mode 100644 index 000000000..c42812861 --- /dev/null +++ b/src/tools/qptrdict.h @@ -0,0 +1,118 @@ +/**************************************************************************** +** +** Definition of TQPtrDict template class +** +** Created : 970415 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQPTRDICT_H +#define TQPTRDICT_H + +#ifndef QT_H +#include "qgdict.h" +#endif // QT_H + +template +class TQPtrDict +#ifdef Q_QDOC + : public TQPtrCollection +#else + : public TQGDict +#endif +{ +public: + TQPtrDict(int size=17) : TQGDict(size,PtrKey,0,0) {} + TQPtrDict( const TQPtrDict &d ) : TQGDict(d) {} + ~TQPtrDict() { clear(); } + TQPtrDict &operator=(const TQPtrDict &d) + { return (TQPtrDict&)TQGDict::operator=(d); } + uint count() const { return TQGDict::count(); } + uint size() const { return TQGDict::size(); } + bool isEmpty() const { return TQGDict::count() == 0; } + void insert( void *k, const type *d ) + { TQGDict::look_ptr(k,(Item)d,1); } + void replace( void *k, const type *d ) + { TQGDict::look_ptr(k,(Item)d,2); } + bool remove( void *k ) { return TQGDict::remove_ptr(k); } + type *take( void *k ) { return (type*)TQGDict::take_ptr(k); } + type *find( void *k ) const + { return (type *)((TQGDict*)this)->TQGDict::look_ptr(k,0,0); } + type *operator[]( void *k ) const + { return (type *)((TQGDict*)this)->TQGDict::look_ptr(k,0,0); } + void clear() { TQGDict::clear(); } + void resize( uint n ) { TQGDict::resize(n); } + void statistics() const { TQGDict::statistics(); } + +#ifdef Q_QDOC +protected: + virtual TQDataStream& read( TQDataStream &, TQPtrCollection::Item & ); + virtual TQDataStream& write( TQDataStream &, TQPtrCollection::Item ) const; +#endif + +private: + void deleteItem( Item d ); +}; + +#if !defined(Q_BROKEN_TEMPLATE_SPECIALIZATION) +template<> inline void TQPtrDict::deleteItem( TQPtrCollection::Item ) +{ +} +#endif + +template +inline void TQPtrDict::deleteItem( TQPtrCollection::Item d ) +{ + if ( del_item ) delete (type *)d; +} + +template +class TQPtrDictIterator : public TQGDictIterator +{ +public: + TQPtrDictIterator(const TQPtrDict &d) :TQGDictIterator((TQGDict &)d) {} + ~TQPtrDictIterator() {} + uint count() const { return dict->count(); } + bool isEmpty() const { return dict->count() == 0; } + type *toFirst() { return (type *)TQGDictIterator::toFirst(); } + operator type *() const { return (type *)TQGDictIterator::get(); } + type *current() const { return (type *)TQGDictIterator::get(); } + void *currentKey() const { return TQGDictIterator::getKeyPtr(); } + type *operator()() { return (type *)TQGDictIterator::operator()(); } + type *operator++() { return (type *)TQGDictIterator::operator++(); } + type *operator+=(uint j) { return (type *)TQGDictIterator::operator+=(j);} +}; + +#endif // TQPTRDICT_H diff --git a/src/tools/qptrlist.h b/src/tools/qptrlist.h new file mode 100644 index 000000000..1eae7b9f6 --- /dev/null +++ b/src/tools/qptrlist.h @@ -0,0 +1,195 @@ +/**************************************************************************** +** +** Definition of TQPtrList template/macro class +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQPTRLIST_H +#define TQPTRLIST_H + +#ifndef QT_H +#include "qglist.h" +#endif // QT_H + +template +class TQPtrListStdIterator : public TQGListStdIterator +{ +public: + inline TQPtrListStdIterator( TQLNode* n ): TQGListStdIterator(n) {} + type *operator*() { return node ? (type *)node->getData() : 0; } + inline TQPtrListStdIterator operator++() + { node = next(); return *this; } + inline TQPtrListStdIterator operator++(int) + { TQLNode* n = node; node = next(); return TQPtrListStdIterator( n ); } + inline bool operator==( const TQPtrListStdIterator& it ) const { return node == it.node; } + inline bool operator!=( const TQPtrListStdIterator& it ) const { return node != it.node; } +}; + + +template +class TQPtrList +#ifdef Q_QDOC + : public TQPtrCollection +#else + : public TQGList +#endif +{ +public: + + TQPtrList() {} + TQPtrList( const TQPtrList &l ) : TQGList(l) {} + ~TQPtrList() { clear(); } + TQPtrList &operator=(const TQPtrList &l) + { return (TQPtrList&)TQGList::operator=(l); } + bool operator==( const TQPtrList &list ) const + { return TQGList::operator==( list ); } + bool operator!=( const TQPtrList &list ) const + { return !TQGList::operator==( list ); } + uint count() const { return TQGList::count(); } + bool isEmpty() const { return TQGList::count() == 0; } + bool insert( uint i, const type *d){ return TQGList::insertAt(i,(TQPtrCollection::Item)d); } + void inSort( const type *d ) { TQGList::inSort((TQPtrCollection::Item)d); } + void prepend( const type *d ) { TQGList::insertAt(0,(TQPtrCollection::Item)d); } + void append( const type *d ) { TQGList::append((TQPtrCollection::Item)d); } + bool remove( uint i ) { return TQGList::removeAt(i); } + bool remove() { return TQGList::remove((TQPtrCollection::Item)0); } + bool remove( const type *d ) { return TQGList::remove((TQPtrCollection::Item)d); } + bool removeRef( const type *d ) { return TQGList::removeRef((TQPtrCollection::Item)d); } + void removeNode( TQLNode *n ) { TQGList::removeNode(n); } + bool removeFirst() { return TQGList::removeFirst(); } + bool removeLast() { return TQGList::removeLast(); } + type *take( uint i ) { return (type *)TQGList::takeAt(i); } + type *take() { return (type *)TQGList::take(); } + type *takeNode( TQLNode *n ) { return (type *)TQGList::takeNode(n); } + void clear() { TQGList::clear(); } + void sort() { TQGList::sort(); } + int find( const type *d ) { return TQGList::find((TQPtrCollection::Item)d); } + int findNext( const type *d ) { return TQGList::find((TQPtrCollection::Item)d,FALSE); } + int findRef( const type *d ) { return TQGList::findRef((TQPtrCollection::Item)d); } + int findNextRef( const type *d ){ return TQGList::findRef((TQPtrCollection::Item)d,FALSE);} + uint contains( const type *d ) const { return TQGList::contains((TQPtrCollection::Item)d); } + uint containsRef( const type *d ) const + { return TQGList::containsRef((TQPtrCollection::Item)d); } + bool replace( uint i, const type *d ) { return TQGList::replaceAt( i, (TQPtrCollection::Item)d ); } + type *at( uint i ) { return (type *)TQGList::at(i); } + int at() const { return TQGList::at(); } + type *current() const { return (type *)TQGList::get(); } + TQLNode *currentNode() const { return TQGList::currentNode(); } + type *getFirst() const { return (type *)TQGList::cfirst(); } + type *getLast() const { return (type *)TQGList::clast(); } + type *first() { return (type *)TQGList::first(); } + type *last() { return (type *)TQGList::last(); } + type *next() { return (type *)TQGList::next(); } + type *prev() { return (type *)TQGList::prev(); } + void toVector( TQGVector *vec )const{ TQGList::toVector(vec); } + + + // standard iterators + typedef TQPtrListStdIterator Iterator; + typedef TQPtrListStdIterator ConstIterator; + inline Iterator begin() { return TQGList::begin(); } + inline ConstIterator begin() const { return TQGList::begin(); } + inline ConstIterator constBegin() const { return TQGList::begin(); } + inline Iterator end() { return TQGList::end(); } + inline ConstIterator end() const { return TQGList::end(); } + inline ConstIterator constEnd() const { return TQGList::end(); } + inline Iterator erase( Iterator it ) { return TQGList::erase( it ); } + // stl syntax compatibility + typedef Iterator iterator; + typedef ConstIterator const_iterator; + + +#ifdef Q_QDOC +protected: + virtual int compareItems( TQPtrCollection::Item, TQPtrCollection::Item ); + virtual TQDataStream& read( TQDataStream&, TQPtrCollection::Item& ); + virtual TQDataStream& write( TQDataStream&, TQPtrCollection::Item ) const; +#endif + +private: + void deleteItem( Item d ); +}; + +#if !defined(Q_BROKEN_TEMPLATE_SPECIALIZATION) +template<> inline void TQPtrList::deleteItem( TQPtrCollection::Item ) +{ +} +#endif + +template inline void TQPtrList::deleteItem( TQPtrCollection::Item d ) +{ + if ( del_item ) delete (type *)d; +} + +template +class TQPtrListIterator : public TQGListIterator +{ +public: + TQPtrListIterator(const TQPtrList &l) :TQGListIterator((TQGList &)l) {} + ~TQPtrListIterator() {} + uint count() const { return list->count(); } + bool isEmpty() const { return list->count() == 0; } + bool atFirst() const { return TQGListIterator::atFirst(); } + bool atLast() const { return TQGListIterator::atLast(); } + type *toFirst() { return (type *)TQGListIterator::toFirst(); } + type *toLast() { return (type *)TQGListIterator::toLast(); } + operator type *() const { return (type *)TQGListIterator::get(); } + type *operator*() { return (type *)TQGListIterator::get(); } + + // No good, since TQPtrList (ie. TQStrList fails... + // + // MSVC++ gives warning + // Sunpro C++ 4.1 gives error + // type *operator->() { return (type *)TQGListIterator::get(); } + + type *current() const { return (type *)TQGListIterator::get(); } + type *operator()() { return (type *)TQGListIterator::operator()();} + type *operator++() { return (type *)TQGListIterator::operator++(); } + type *operator+=(uint j) { return (type *)TQGListIterator::operator+=(j);} + type *operator--() { return (type *)TQGListIterator::operator--(); } + type *operator-=(uint j) { return (type *)TQGListIterator::operator-=(j);} + TQPtrListIterator& operator=(const TQPtrListIterator&it) + { TQGListIterator::operator=(it); return *this; } +}; + +#ifndef QT_NO_COMPAT +#define TQList TQPtrList +#define TQListIterator TQPtrListIterator +#endif + +#define Q_DEFINED_QPTRLIST +#include "qwinexport.h" + +#endif // TQPTRLIST_H diff --git a/src/tools/qptrqueue.h b/src/tools/qptrqueue.h new file mode 100644 index 000000000..ae103be60 --- /dev/null +++ b/src/tools/qptrqueue.h @@ -0,0 +1,94 @@ +/**************************************************************************** +** +** Definition of TQPtrQueue template/macro class +** +** Created : 920917 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQPTRTQUEUE_H +#define TQPTRTQUEUE_H + +#ifndef QT_H +#include "qglist.h" +#endif // QT_H + +template +class TQPtrQueue : protected TQGList +{ +public: + TQPtrQueue() {} + TQPtrQueue( const TQPtrQueue &q ) : TQGList(q) {} + ~TQPtrQueue() { clear(); } + TQPtrQueue& operator=(const TQPtrQueue &q) + { return (TQPtrQueue&)TQGList::operator=(q); } + bool autoDelete() const { return TQPtrCollection::autoDelete(); } + void setAutoDelete( bool del ) { TQPtrCollection::setAutoDelete(del); } + uint count() const { return TQGList::count(); } + bool isEmpty() const { return TQGList::count() == 0; } + void enqueue( const type *d ) { TQGList::append(Item(d)); } + type *dequeue() { return (type *)TQGList::takeFirst();} + bool remove() { return TQGList::removeFirst(); } + void clear() { TQGList::clear(); } + type *head() const { return (type *)TQGList::cfirst(); } + operator type *() const { return (type *)TQGList::cfirst(); } + type *current() const { return (type *)TQGList::cfirst(); } + +#ifdef Q_QDOC +protected: + virtual TQDataStream& read( TQDataStream&, TQPtrCollection::Item& ); + virtual TQDataStream& write( TQDataStream&, TQPtrCollection::Item ) const; +#endif + +private: + void deleteItem( Item d ); +}; + +#if !defined(Q_BROKEN_TEMPLATE_SPECIALIZATION) +template<> inline void TQPtrQueue::deleteItem( TQPtrCollection::Item ) +{ +} +#endif + +template inline void TQPtrQueue::deleteItem( TQPtrCollection::Item d ) +{ + if ( del_item ) delete (type *)d; +} + +#ifndef QT_NO_COMPAT +#define TQQueue TQPtrQueue +#endif + +#endif // TQPTRTQUEUE_H diff --git a/src/tools/qptrstack.h b/src/tools/qptrstack.h new file mode 100644 index 000000000..947716071 --- /dev/null +++ b/src/tools/qptrstack.h @@ -0,0 +1,94 @@ +/**************************************************************************** +** +** Definition of TQPtrStack pointer based template class +** +** Created : 920917 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQPTRSTACK_H +#define TQPTRSTACK_H + +#ifndef QT_H +#include "qglist.h" +#endif // QT_H + +template +class TQPtrStack : protected TQGList +{ +public: + TQPtrStack() { } + TQPtrStack( const TQPtrStack &s ) : TQGList( s ) { } + ~TQPtrStack() { clear(); } + TQPtrStack &operator=(const TQPtrStack &s) + { return (TQPtrStack&)TQGList::operator=(s); } + bool autoDelete() const { return TQPtrCollection::autoDelete(); } + void setAutoDelete( bool del ) { TQPtrCollection::setAutoDelete(del); } + uint count() const { return TQGList::count(); } + bool isEmpty() const { return TQGList::count() == 0; } + void push( const type *d ) { TQGList::insertAt(0,Item(d)); } + type *pop() { return (type *)TQGList::takeFirst(); } + bool remove() { return TQGList::removeFirst(); } + void clear() { TQGList::clear(); } + type *top() const { return (type *)TQGList::cfirst(); } + operator type *() const { return (type *)TQGList::cfirst(); } + type *current() const { return (type *)TQGList::cfirst(); } + +#ifdef Q_QDOC +protected: + virtual TQDataStream& read( TQDataStream&, TQPtrCollection::Item& ); + virtual TQDataStream& write( TQDataStream&, TQPtrCollection::Item ) const; +#endif + +private: + void deleteItem( Item d ); +}; + +#if !defined(Q_BROKEN_TEMPLATE_SPECIALIZATION) +template<> inline void TQPtrStack::deleteItem( TQPtrCollection::Item ) +{ +} +#endif + +template inline void TQPtrStack::deleteItem( TQPtrCollection::Item d ) +{ + if ( del_item ) delete (type *)d; +} + +#ifndef QT_NO_COMPAT +#define TQStack TQPtrStack +#endif + +#endif // TQPTRSTACK_H diff --git a/src/tools/qptrvector.h b/src/tools/qptrvector.h new file mode 100644 index 000000000..72509808c --- /dev/null +++ b/src/tools/qptrvector.h @@ -0,0 +1,118 @@ +/**************************************************************************** +** +** Definition of TQPtrVector pointer based template class +** +** Created : 930907 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQPTRVECTOR_H +#define TQPTRVECTOR_H + +#ifndef QT_H +#include "qgvector.h" +#endif // QT_H + +template +class TQPtrVector +#ifdef Q_QDOC + : public TQPtrCollection +#else + : public TQGVector +#endif +{ +public: + TQPtrVector() { } + TQPtrVector( uint size ) : TQGVector(size) { } + TQPtrVector( const TQPtrVector &v ) : TQGVector( v ) { } + ~TQPtrVector() { clear(); } + TQPtrVector &operator=(const TQPtrVector &v) + { return (TQPtrVector&)TQGVector::operator=(v); } + bool operator==( const TQPtrVector &v ) const { return TQGVector::operator==(v); } + type **data() const { return (type **)TQGVector::data(); } + uint size() const { return TQGVector::size(); } + uint count() const { return TQGVector::count(); } + bool isEmpty() const { return TQGVector::count() == 0; } + bool isNull() const { return TQGVector::size() == 0; } + bool resize( uint size ) { return TQGVector::resize(size); } + bool insert( uint i, const type *d){ return TQGVector::insert(i,(Item)d); } + bool remove( uint i ) { return TQGVector::remove(i); } + type *take( uint i ) { return (type *)TQGVector::take(i); } + void clear() { TQGVector::clear(); } + bool fill( const type *d, int size=-1 ) + { return TQGVector::fill((Item)d,size);} + void sort() { TQGVector::sort(); } + int bsearch( const type *d ) const{ return TQGVector::bsearch((Item)d); } + int findRef( const type *d, uint i=0 ) const + { return TQGVector::findRef((Item)d,i);} + int find( const type *d, uint i= 0 ) const + { return TQGVector::find((Item)d,i); } + uint containsRef( const type *d ) const + { return TQGVector::containsRef((Item)d); } + uint contains( const type *d ) const + { return TQGVector::contains((Item)d); } + type *operator[]( int i ) const { return (type *)TQGVector::at(i); } + type *at( uint i ) const { return (type *)TQGVector::at(i); } + void toList( TQGList *list ) const { TQGVector::toList(list); } + +#ifdef Q_QDOC +protected: + virtual int compareItems( TQPtrCollection::Item d1, TQPtrCollection::Item d2 ); + virtual TQDataStream& read( TQDataStream &s, TQPtrCollection::Item &d ); + virtual TQDataStream& write( TQDataStream &s, TQPtrCollection::Item d ) const; +#endif + +private: + void deleteItem( Item d ); +}; + +#if !defined(Q_BROKEN_TEMPLATE_SPECIALIZATION) +template<> inline void TQPtrVector::deleteItem( TQPtrCollection::Item ) +{ +} +#endif + +template inline void TQPtrVector::deleteItem( TQPtrCollection::Item d ) +{ + if ( del_item ) delete (type *)d; +} + +#ifndef QT_NO_COMPAT +#define TQVector TQPtrVector +#endif + +#define Q_DEFINED_QPTRVECTOR +#include "qwinexport.h" +#endif // TQVECTOR_H diff --git a/src/tools/qregexp.cpp b/src/tools/qregexp.cpp new file mode 100644 index 000000000..167349136 --- /dev/null +++ b/src/tools/qregexp.cpp @@ -0,0 +1,3996 @@ +/**************************************************************************** +** +** Implementation of TQRegExp class +** +** Created : 950126 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "qregexp.h" + +#ifndef QT_NO_REGEXP + +#include "qmemarray.h" +#include "qbitarray.h" +#include "qcache.h" +#include "qcleanuphandler.h" +#include "qintdict.h" +#include "qmap.h" +#include "qptrvector.h" +#include "qstring.h" +#include "qtl.h" + +#ifdef QT_THREAD_SUPPORT +#include "qthreadstorage.h" +#include +#endif // QT_THREAD_SUPPORT + +#undef QT_TRANSLATE_NOOP +#define QT_TRANSLATE_NOOP( context, sourceText ) sourceText + +#include + +// error strings for the regexp parser +#define RXERR_OK QT_TRANSLATE_NOOP( "TQRegExp", "no error occurred" ) +#define RXERR_DISABLED QT_TRANSLATE_NOOP( "TQRegExp", "disabled feature used" ) +#define RXERR_CHARCLASS QT_TRANSLATE_NOOP( "TQRegExp", "bad char class syntax" ) +#define RXERR_LOOKAHEAD QT_TRANSLATE_NOOP( "TQRegExp", "bad lookahead syntax" ) +#define RXERR_REPETITION QT_TRANSLATE_NOOP( "TQRegExp", "bad repetition syntax" ) +#define RXERR_OCTAL QT_TRANSLATE_NOOP( "TQRegExp", "invalid octal value" ) +#define RXERR_LEFTDELIM QT_TRANSLATE_NOOP( "TQRegExp", "missing left delim" ) +#define RXERR_END QT_TRANSLATE_NOOP( "TQRegExp", "unexpected end" ) +#define RXERR_LIMIT QT_TRANSLATE_NOOP( "TQRegExp", "met internal limit" ) + +/* + WARNING! Be sure to read qregexp.tex before modifying this file. +*/ + +/*! + \class TQRegExp qregexp.h + \reentrant + \brief The TQRegExp class provides pattern matching using regular expressions. + + \ingroup tools + \ingroup misc + \ingroup shared + \mainclass + \keyword regular expression + + Regular expressions, or "regexps", provide a way to find patterns + within text. This is useful in many contexts, for example: + + \table + \row \i Validation + \i A regexp can be used to check whether a piece of text + meets some criteria, e.g. is an integer or contains no + whitespace. + \row \i Searching + \i Regexps provide a much more powerful means of searching + text than simple string matching does. For example we can + create a regexp which says "find one of the words 'mail', + 'letter' or 'correspondence' but not any of the words + 'email', 'mailman' 'mailer', 'letterbox' etc." + \row \i Search and Replace + \i A regexp can be used to replace a pattern with a piece of + text, for example replace all occurrences of '&' with + '\&' except where the '&' is already followed by 'amp;'. + \row \i String Splitting + \i A regexp can be used to identify where a string should be + split into its component fields, e.g. splitting tab-delimited + strings. + \endtable + + We present a very brief introduction to regexps, a description of + TQt's regexp language, some code examples, and finally the function + documentation itself. TQRegExp is modeled on Perl's regexp + language, and also fully supports Unicode. TQRegExp can also be + used in the weaker 'wildcard' (globbing) mode which works in a + similar way to command shells. A good text on regexps is \e + {Mastering Regular Expressions: Powerful Techniques for Perl and + Other Tools} by Jeffrey E. Friedl, ISBN 1565922573. + + Experienced regexp users may prefer to skip the introduction and + go directly to the relevant information. + + In case of multi-threaded programming, note that TQRegExp depends on + TQThreadStorage internally. For that reason, TQRegExp should only be + used with threads started with TQThread, i.e. not with threads + started with platform-specific APIs. + + \tableofcontents + + \section1 Introduction + + Regexps are built up from expressions, quantifiers, and assertions. + The simplest form of expression is simply a character, e.g. + x or 5. An expression can also be a set of + characters. For example, [ABCD], will match an A or + a B or a C or a D. As a shorthand we could + write this as [A-D]. If we want to match any of the + captital letters in the English alphabet we can write + [A-Z]. A quantifier tells the regexp engine how many + occurrences of the expression we want, e.g. x{1,1} means + match an x which occurs at least once and at most once. + We'll look at assertions and more complex expressions later. + + Note that in general regexps cannot be used to check for balanced + brackets or tags. For example if you want to match an opening html + \c and its closing \c you can only use a regexp if you + know that these tags are not nested; the html fragment, \c{bold + bolder} will not match as expected. If you know the + maximum level of nesting it is possible to create a regexp that + will match correctly, but for an unknown level of nesting, regexps + will fail. + + We'll start by writing a regexp to match integers in the range 0 + to 99. We will retquire at least one digit so we will start with + [0-9]{1,1} which means match a digit exactly once. This + regexp alone will match integers in the range 0 to 9. To match one + or two digits we can increase the maximum number of occurrences so + the regexp becomes [0-9]{1,2} meaning match a digit at + least once and at most twice. However, this regexp as it stands + will not match correctly. This regexp will match one or two digits + \e within a string. To ensure that we match against the whole + string we must use the anchor assertions. We need ^ (caret) + which when it is the first character in the regexp means that the + regexp must match from the beginning of the string. And we also + need $ (dollar) which when it is the last character in the + regexp means that the regexp must match until the end of the + string. So now our regexp is ^[0-9]{1,2}$. Note that + assertions, such as ^ and $, do not match any + characters. + + If you've seen regexps elsewhere they may have looked different from + the ones above. This is because some sets of characters and some + quantifiers are so common that they have special symbols to + represent them. [0-9] can be replaced with the symbol + \d. The quantifier to match exactly one occurrence, + {1,1}, can be replaced with the expression itself. This means + that x{1,1} is exactly the same as x alone. So our 0 + to 99 matcher could be written ^\d{1,2}$. Another way of + writing it would be ^\d\d{0,1}$, i.e. from the start of the + string match a digit followed by zero or one digits. In practice + most people would write it ^\d\d?$. The ? is a + shorthand for the quantifier {0,1}, i.e. a minimum of no + occurrences a maximum of one occurrence. This is used to make an + expression optional. The regexp ^\d\d?$ means "from the + beginning of the string match one digit followed by zero or one + digits and then the end of the string". + + Our second example is matching the words 'mail', 'letter' or + 'correspondence' but without matching 'email', 'mailman', + 'mailer', 'letterbox' etc. We'll start by just matching 'mail'. In + full the regexp is, m{1,1}a{1,1}i{1,1}l{1,1}, but since + each expression itself is automatically quantified by {1,1} + we can simply write this as mail; an 'm' followed by an 'a' + followed by an 'i' followed by an 'l'. The symbol '|' (bar) is + used for \e alternation, so our regexp now becomes + mail|letter|correspondence which means match 'mail' \e or + 'letter' \e or 'correspondence'. Whilst this regexp will find the + words we want it will also find words we don't want such as + 'email'. We will start by putting our regexp in parentheses, + (mail|letter|correspondence). Parentheses have two effects, + firstly they group expressions together and secondly they identify + parts of the regexp that we wish to \link #capturing-text capture + \endlink. Our regexp still matches any of the three words but now + they are grouped together as a unit. This is useful for building + up more complex regexps. It is also useful because it allows us to + examine which of the words actually matched. We need to use + another assertion, this time \b "word boundary": + \b(mail|letter|correspondence)\b. This regexp means "match + a word boundary followed by the expression in parentheses followed + by another word boundary". The \b assertion matches at a \e + position in the regexp not a \e character in the regexp. A word + boundary is any non-word character such as a space a newline or + the beginning or end of the string. + + For our third example we want to replace ampersands with the HTML + entity '\&'. The regexp to match is simple: \&, i.e. + match one ampersand. Unfortunately this will mess up our text if + some of the ampersands have already been turned into HTML + entities. So what we really want to say is replace an ampersand + providing it is not followed by 'amp;'. For this we need the + negative lookahead assertion and our regexp becomes: + \&(?!amp;). The negative lookahead assertion is introduced + with '(?!' and finishes at the ')'. It means that the text it + contains, 'amp;' in our example, must \e not follow the expression + that preceeds it. + + Regexps provide a rich language that can be used in a variety of + ways. For example suppose we want to count all the occurrences of + 'Eric' and 'Eirik' in a string. Two valid regexps to match these + are \\b(Eric|Eirik)\\b and \\bEi?ri[ck]\\b. We need + the word boundary '\b' so we don't get 'Ericsson' etc. The second + regexp actually matches more than we want, 'Eric', 'Erik', 'Eiric' + and 'Eirik'. + + We will implement some the examples above in the + \link #code-examples code examples \endlink section. + + \target characters-and-abbreviations-for-sets-of-characters + \section1 Characters and Abbreviations for Sets of Characters + + \table + \header \i Element \i Meaning + \row \i c + \i Any character represents itself unless it has a special + regexp meaning. Thus c matches the character \e c. + \row \i \\c + \i A character that follows a backslash matches the character + itself except where mentioned below. For example if you + wished to match a literal caret at the beginning of a string + you would write \^. + \row \i \\a + \i This matches the ASCII bell character (BEL, 0x07). + \row \i \\f + \i This matches the ASCII form feed character (FF, 0x0C). + \row \i \\n + \i This matches the ASCII line feed character (LF, 0x0A, Unix newline). + \row \i \\r + \i This matches the ASCII carriage return character (CR, 0x0D). + \row \i \\t + \i This matches the ASCII horizontal tab character (HT, 0x09). + \row \i \\v + \i This matches the ASCII vertical tab character (VT, 0x0B). + \row \i \\xhhhh + \i This matches the Unicode character corresponding to the + hexadecimal number hhhh (between 0x0000 and 0xFFFF). \0ooo + (i.e., \zero ooo) matches the ASCII/Latin-1 character + corresponding to the octal number ooo (between 0 and 0377). + \row \i . (dot) + \i This matches any character (including newline). + \row \i \\d + \i This matches a digit (TQChar::isDigit()). + \row \i \\D + \i This matches a non-digit. + \row \i \\s + \i This matches a whitespace (TQChar::isSpace()). + \row \i \\S + \i This matches a non-whitespace. + \row \i \\w + \i This matches a word character (TQChar::isLetterOrNumber() or '_'). + \row \i \\W + \i This matches a non-word character. + \row \i \\n + \i The n-th \link #capturing-text backreference \endlink, + e.g. \1, \2, etc. + \endtable + + \e {Note that the C++ compiler transforms backslashes in strings + so to include a \\ in a regexp you will need to enter it + twice, i.e. \\\\.} + + \target sets-of-characters + \section1 Sets of Characters + + Square brackets are used to match any character in the set of + characters contained within the square brackets. All the character + set abbreviations described above can be used within square + brackets. Apart from the character set abbreviations and the + following two exceptions no characters have special meanings in + square brackets. + + \table + \row \i ^ + \i The caret negates the character set if it occurs as the + first character, i.e. immediately after the opening square + bracket. For example, [abc] matches 'a' or 'b' or 'c', + but [^abc] matches anything \e except 'a' or 'b' or + 'c'. + \row \i - + \i The dash is used to indicate a range of characters, for + example [W-Z] matches 'W' or 'X' or 'Y' or 'Z'. + \endtable + + Using the predefined character set abbreviations is more portable + than using character ranges across platforms and languages. For + example, [0-9] matches a digit in Western alphabets but + \d matches a digit in \e any alphabet. + + Note that in most regexp literature sets of characters are called + "character classes". + + \target quantifiers + \section1 Quantifiers + + By default an expression is automatically quantified by + {1,1}, i.e. it should occur exactly once. In the following + list \e {E} stands for any expression. An expression is a + character or an abbreviation for a set of characters or a set of + characters in square brackets or any parenthesised expression. + + \table + \row \i \e {E}? + \i Matches zero or one occurrence of \e E. This quantifier + means "the previous expression is optional" since it will + match whether or not the expression occurs in the string. It + is the same as \e {E}{0,1}. For example dents? + will match 'dent' and 'dents'. + + \row \i \e {E}+ + \i Matches one or more occurrences of \e E. This is the same + as \e {E}{1,MAXINT}. For example, 0+ will match + '0', '00', '000', etc. + + \row \i \e {E}* + \i Matches zero or more occurrences of \e E. This is the same + as \e {E}{0,MAXINT}. The * quantifier is often + used by a mistake. Since it matches \e zero or more + occurrences it will match no occurrences at all. For example + if we want to match strings that end in whitespace and use + the regexp \s*$ we would get a match on every string. + This is because we have said find zero or more whitespace + followed by the end of string, so even strings that don't end + in whitespace will match. The regexp we want in this case is + \s+$ to match strings that have at least one + whitespace at the end. + + \row \i \e {E}{n} + \i Matches exactly \e n occurrences of the expression. This + is the same as repeating the expression \e n times. For + example, x{5} is the same as xxxxx. It is also + the same as \e {E}{n,n}, e.g. x{5,5}. + + \row \i \e {E}{n,} + \i Matches at least \e n occurrences of the expression. This + is the same as \e {E}{n,MAXINT}. + + \row \i \e {E}{,m} + \i Matches at most \e m occurrences of the expression. This + is the same as \e {E}{0,m}. + + \row \i \e {E}{n,m} + \i Matches at least \e n occurrences of the expression and at + most \e m occurrences of the expression. + \endtable + + (MAXINT is implementation dependent but will not be smaller than + 1024.) + + If we wish to apply a quantifier to more than just the preceding + character we can use parentheses to group characters together in + an expression. For example, tag+ matches a 't' followed by + an 'a' followed by at least one 'g', whereas (tag)+ matches + at least one occurrence of 'tag'. + + Note that quantifiers are "greedy". They will match as much text + as they can. For example, 0+ will match as many zeros as it + can from the first zero it finds, e.g. '2.0005'. + Quantifiers can be made non-greedy, see setMinimal(). + + \target capturing-text + \section1 Capturing Text + + Parentheses allow us to group elements together so that we can + quantify and capture them. For example if we have the expression + mail|letter|correspondence that matches a string we know + that \e one of the words matched but not which one. Using + parentheses allows us to "capture" whatever is matched within + their bounds, so if we used (mail|letter|correspondence) + and matched this regexp against the string "I sent you some email" + we can use the cap() or capturedTexts() functions to extract the + matched characters, in this case 'mail'. + + We can use captured text within the regexp itself. To refer to the + captured text we use \e backreferences which are indexed from 1, + the same as for cap(). For example we could search for duplicate + words in a string using \b(\w+)\W+\1\b which means match a + word boundary followed by one or more word characters followed by + one or more non-word characters followed by the same text as the + first parenthesised expression followed by a word boundary. + + If we want to use parentheses purely for grouping and not for + capturing we can use the non-capturing syntax, e.g. + (?:green|blue). Non-capturing parentheses begin '(?:' and + end ')'. In this example we match either 'green' or 'blue' but we + do not capture the match so we only know whether or not we matched + but not which color we actually found. Using non-capturing + parentheses is more efficient than using capturing parentheses + since the regexp engine has to do less book-keeping. + + Both capturing and non-capturing parentheses may be nested. + + \target assertions + \section1 Assertions + + Assertions make some statement about the text at the point where + they occur in the regexp but they do not match any characters. In + the following list \e {E} stands for any expression. + + \table + \row \i ^ + \i The caret signifies the beginning of the string. If you + wish to match a literal \c{^} you must escape it by + writing \^. For example, ^#include will only + match strings which \e begin with the characters '#include'. + (When the caret is the first character of a character set it + has a special meaning, see \link #sets-of-characters Sets of + Characters \endlink.) + + \row \i $ + \i The dollar signifies the end of the string. For example + \d\s*$ will match strings which end with a digit + optionally followed by whitespace. If you wish to match a + literal \c{$} you must escape it by writing + \$. + + \row \i \\b + \i A word boundary. For example the regexp + \\bOK\\b means match immediately after a word + boundary (e.g. start of string or whitespace) the letter 'O' + then the letter 'K' immediately before another word boundary + (e.g. end of string or whitespace). But note that the + assertion does not actually match any whitespace so if we + write (\\bOK\\b) and we have a match it will only + contain 'OK' even if the string is "Its OK now". + + \row \i \\B + \i A non-word boundary. This assertion is true wherever + \\b is false. For example if we searched for + \\Bon\\B in "Left on" the match would fail (space + and end of string aren't non-word boundaries), but it would + match in "tonne". + + \row \i (?=\e E) + \i Positive lookahead. This assertion is true if the + expression matches at this point in the regexp. For example, + const(?=\\s+char) matches 'const' whenever it is + followed by 'char', as in 'static const char *'. + (Compare with const\\s+char, which matches 'static + const char *'.) + + \row \i (?!\e E) + \i Negative lookahead. This assertion is true if the + expression does not match at this point in the regexp. For + example, const(?!\\s+char) matches 'const' \e except + when it is followed by 'char'. + \endtable + + \target wildcard-matching + \section1 Wildcard Matching (globbing) + + Most command shells such as \e bash or \e cmd.exe support "file + globbing", the ability to identify a group of files by using + wildcards. The setWildcard() function is used to switch between + regexp and wildcard mode. Wildcard matching is much simpler than + full regexps and has only four features: + + \table + \row \i c + \i Any character represents itself apart from those mentioned + below. Thus c matches the character \e c. + \row \i ? + \i This matches any single character. It is the same as + . in full regexps. + \row \i * + \i This matches zero or more of any characters. It is the + same as .* in full regexps. + \row \i [...] + \i Sets of characters can be represented in square brackets, + similar to full regexps. Within the character class, like + outside, backslash has no special meaning. + \endtable + + For example if we are in wildcard mode and have strings which + contain filenames we could identify HTML files with *.html. + This will match zero or more characters followed by a dot followed + by 'h', 't', 'm' and 'l'. + + \target perl-users + \section1 Notes for Perl Users + + Most of the character class abbreviations supported by Perl are + supported by TQRegExp, see \link + #characters-and-abbreviations-for-sets-of-characters characters + and abbreviations for sets of characters \endlink. + + In TQRegExp, apart from within character classes, \c{^} always + signifies the start of the string, so carets must always be + escaped unless used for that purpose. In Perl the meaning of caret + varies automagically depending on where it occurs so escaping it + is rarely necessary. The same applies to \c{$} which in + TQRegExp always signifies the end of the string. + + TQRegExp's quantifiers are the same as Perl's greedy quantifiers. + Non-greedy matching cannot be applied to individual quantifiers, + but can be applied to all the quantifiers in the pattern. For + example, to match the Perl regexp ro+?m retquires: + \code + TQRegExp rx( "ro+m" ); + rx.setMinimal( TRUE ); + \endcode + + The equivalent of Perl's \c{/i} option is + setCaseSensitive(FALSE). + + Perl's \c{/g} option can be emulated using a \link + #cap_in_a_loop loop \endlink. + + In TQRegExp . matches any character, therefore all TQRegExp + regexps have the equivalent of Perl's \c{/s} option. TQRegExp + does not have an equivalent to Perl's \c{/m} option, but this + can be emulated in various ways for example by splitting the input + into lines or by looping with a regexp that searches for newlines. + + Because TQRegExp is string oriented there are no \A, \Z or \z + assertions. The \G assertion is not supported but can be emulated + in a loop. + + Perl's $& is cap(0) or capturedTexts()[0]. There are no TQRegExp + equivalents for $`, $' or $+. Perl's capturing variables, $1, $2, + ... correspond to cap(1) or capturedTexts()[1], cap(2) or + capturedTexts()[2], etc. + + To substitute a pattern use TQString::replace(). + + Perl's extended \c{/x} syntax is not supported, nor are + directives, e.g. (?i), or regexp comments, e.g. (?#comment). On + the other hand, C++'s rules for literal strings can be used to + achieve the same: + \code + TQRegExp mark( "\\b" // word boundary + "[Mm]ark" // the word we want to match + ); + \endcode + + Both zero-width positive and zero-width negative lookahead + assertions (?=pattern) and (?!pattern) are supported with the same + syntax as Perl. Perl's lookbehind assertions, "independent" + subexpressions and conditional expressions are not supported. + + Non-capturing parentheses are also supported, with the same + (?:pattern) syntax. + + See TQStringList::split() and TQStringList::join() for equivalents + to Perl's split and join functions. + + Note: because C++ transforms \\'s they must be written \e twice in + code, e.g. \\b must be written \\\\b. + + \target code-examples + \section1 Code Examples + + \code + TQRegExp rx( "^\\d\\d?$" ); // match integers 0 to 99 + rx.search( "123" ); // returns -1 (no match) + rx.search( "-6" ); // returns -1 (no match) + rx.search( "6" ); // returns 0 (matched as position 0) + \endcode + + The third string matches '6'. This is a simple validation + regexp for integers in the range 0 to 99. + + \code + TQRegExp rx( "^\\S+$" ); // match strings without whitespace + rx.search( "Hello world" ); // returns -1 (no match) + rx.search( "This_is-OK" ); // returns 0 (matched at position 0) + \endcode + + The second string matches 'This_is-OK'. We've used the + character set abbreviation '\S' (non-whitespace) and the anchors + to match strings which contain no whitespace. + + In the following example we match strings containing 'mail' or + 'letter' or 'correspondence' but only match whole words i.e. not + 'email' + + \code + TQRegExp rx( "\\b(mail|letter|correspondence)\\b" ); + rx.search( "I sent you an email" ); // returns -1 (no match) + rx.search( "Please write the letter" ); // returns 17 + \endcode + + The second string matches "Please write the letter". The + word 'letter' is also captured (because of the parentheses). We + can see what text we've captured like this: + + \code + TQString captured = rx.cap( 1 ); // captured == "letter" + \endcode + + This will capture the text from the first set of capturing + parentheses (counting capturing left parentheses from left to + right). The parentheses are counted from 1 since cap( 0 ) is the + whole matched regexp (equivalent to '&' in most regexp engines). + + \code + TQRegExp rx( "&(?!amp;)" ); // match ampersands but not & + TQString line1 = "This & that"; + line1.replace( rx, "&" ); + // line1 == "This & that" + TQString line2 = "His & hers & theirs"; + line2.replace( rx, "&" ); + // line2 == "His & hers & theirs" + \endcode + + Here we've passed the TQRegExp to TQString's replace() function to + replace the matched text with new text. + + \code + TQString str = "One Eric another Eirik, and an Ericsson." + " How many Eiriks, Eric?"; + TQRegExp rx( "\\b(Eric|Eirik)\\b" ); // match Eric or Eirik + int pos = 0; // where we are in the string + int count = 0; // how many Eric and Eirik's we've counted + while ( pos >= 0 ) { + pos = rx.search( str, pos ); + if ( pos >= 0 ) { + pos++; // move along in str + count++; // count our Eric or Eirik + } + } + \endcode + + We've used the search() function to repeatedly match the regexp in + the string. Note that instead of moving forward by one character + at a time \c pos++ we could have written \c {pos += + rx.matchedLength()} to skip over the already matched string. The + count will equal 3, matching 'One Eric another + Eirik, and an Ericsson. How many Eiriks, Eric?'; it + doesn't match 'Ericsson' or 'Eiriks' because they are not bounded + by non-word boundaries. + + One common use of regexps is to split lines of delimited data into + their component fields. + + \code + str = "Trolltech AS\twww.trolltech.com\tNorway"; + TQString company, web, country; + rx.setPattern( "^([^\t]+)\t([^\t]+)\t([^\t]+)$" ); + if ( rx.search( str ) != -1 ) { + company = rx.cap( 1 ); + web = rx.cap( 2 ); + country = rx.cap( 3 ); + } + \endcode + + In this example our input lines have the format company name, web + address and country. Unfortunately the regexp is rather long and + not very versatile -- the code will break if we add any more + fields. A simpler and better solution is to look for the + separator, '\t' in this case, and take the surrounding text. The + TQStringList split() function can take a separator string or regexp + as an argument and split a string accordingly. + + \code + TQStringList field = TQStringList::split( "\t", str ); + \endcode + + Here field[0] is the company, field[1] the web address and so on. + + To imitate the matching of a shell we can use wildcard mode. + + \code + TQRegExp rx( "*.html" ); // invalid regexp: * doesn't quantify anything + rx.setWildcard( TRUE ); // now it's a valid wildcard regexp + rx.exactMatch( "index.html" ); // returns TRUE + rx.exactMatch( "default.htm" ); // returns FALSE + rx.exactMatch( "readme.txt" ); // returns FALSE + \endcode + + Wildcard matching can be convenient because of its simplicity, but + any wildcard regexp can be defined using full regexps, e.g. + .*\.html$. Notice that we can't match both \c .html and \c + .htm files with a wildcard unless we use *.htm* which will + also match 'test.html.bak'. A full regexp gives us the precision + we need, .*\\.html?$. + + TQRegExp can match case insensitively using setCaseSensitive(), and + can use non-greedy matching, see setMinimal(). By default TQRegExp + uses full regexps but this can be changed with setWildcard(). + Searching can be forward with search() or backward with + searchRev(). Captured text can be accessed using capturedTexts() + which returns a string list of all captured strings, or using + cap() which returns the captured string for the given index. The + pos() function takes a match index and returns the position in the + string where the match was made (or -1 if there was no match). + + \sa TQRegExpValidator TQString TQStringList + + \target member-function-documentation +*/ + +const int NumBadChars = 64; +#define BadChar( ch ) ( (ch).unicode() % NumBadChars ) + +const int NoOccurrence = INT_MAX; +const int EmptyCapture = INT_MAX; +const int InftyLen = INT_MAX; +const int InftyRep = 1025; +const int EOS = -1; + +static bool isWord( TQChar ch ) +{ + return ch.isLetterOrNumber() || ch == TQChar( '_' ); +} + +/* + Merges two TQMemArrays of ints and puts the result into the first + one. +*/ +static void mergeInto( TQMemArray *a, const TQMemArray& b ) +{ + int asize = a->size(); + int bsize = b.size(); + if ( asize == 0 ) { + *a = b.copy(); +#ifndef QT_NO_REGEXP_OPTIM + } else if ( bsize == 1 && (*a)[asize - 1] < b[0] ) { + a->resize( asize + 1 ); + (*a)[asize] = b[0]; +#endif + } else if ( bsize >= 1 ) { + int csize = asize + bsize; + TQMemArray c( csize ); + int i = 0, j = 0, k = 0; + while ( i < asize ) { + if ( j < bsize ) { + if ( (*a)[i] == b[j] ) { + i++; + csize--; + } else if ( (*a)[i] < b[j] ) { + c[k++] = (*a)[i++]; + } else { + c[k++] = b[j++]; + } + } else { + memcpy( c.data() + k, (*a).data() + i, + (asize - i) * sizeof(int) ); + break; + } + } + c.resize( csize ); + if ( j < bsize ) + memcpy( c.data() + k, b.data() + j, (bsize - j) * sizeof(int) ); + *a = c; + } +} + +/* + Merges two disjoint TQMaps of (int, int) pairs and puts the result + into the first one. +*/ +static void mergeInto( TQMap *a, const TQMap& b ) +{ + TQMap::ConstIterator it; + for ( it = b.begin(); it != b.end(); ++it ) + a->insert( it.key(), *it ); +} + +/* + Returns the value associated to key k in TQMap m of (int, int) + pairs, or 0 if no such value is explicitly present. +*/ +static int at( const TQMap& m, int k ) +{ + TQMap::ConstIterator it = m.find( k ); + if ( it == m.end() ) + return 0; + else + return *it; +} + +#ifndef QT_NO_REGEXP_WILDCARD +/* + Translates a wildcard pattern to an equivalent regular expression + pattern (e.g., *.cpp to .*\.cpp). +*/ +static TQString wc2rx( const TQString& wc_str ) +{ + int wclen = wc_str.length(); + TQString rx = TQString::fromLatin1( "" ); + int i = 0; + const TQChar *wc = wc_str.unicode(); + while ( i < wclen ) { + TQChar c = wc[i++]; + switch ( c.unicode() ) { + case '*': + rx += TQString::fromLatin1( ".*" ); + break; + case '?': + rx += TQChar( '.' ); + break; + case '$': + case '(': + case ')': + case '+': + case '.': + case '\\': + case '^': + case '{': + case '|': + case '}': + rx += TQChar( '\\' ); + rx += c; + break; + case '[': + rx += c; + if ( wc[i] == TQChar('^') ) + rx += wc[i++]; + if ( i < wclen ) { + if ( rx[i] == ']' ) + rx += wc[i++]; + while ( i < wclen && wc[i] != TQChar(']') ) { + if ( wc[i] == '\\' ) + rx += TQChar( '\\' ); + rx += wc[i++]; + } + } + break; + default: + rx += c; + } + } + return rx; +} +#endif + +/* + The class TQRegExpEngine encapsulates a modified nondeterministic + finite automaton (NFA). +*/ +class TQRegExpEngine : public TQShared +{ +public: +#ifndef QT_NO_REGEXP_CCLASS + /* + The class CharClass represents a set of characters, such as can + be found in regular expressions (e.g., [a-z] denotes the set + {a, b, ..., z}). + */ + class CharClass + { + public: + CharClass(); + CharClass( const CharClass& cc ) { operator=( cc ); } + + CharClass& operator=( const CharClass& cc ); + + void clear(); + bool negative() const { return n; } + void setNegative( bool negative ); + void addCategories( int cats ); + void addRange( ushort from, ushort to ); + void addSingleton( ushort ch ) { addRange( ch, ch ); } + + bool in( TQChar ch ) const; +#ifndef QT_NO_REGEXP_OPTIM + const TQMemArray& firstOccurrence() const { return occ1; } +#endif + +#if defined(QT_DEBUG) + void dump() const; +#endif + + private: + /* + The struct Range represents a range of characters (e.g., + [0-9] denotes range 48 to 57). + */ + struct Range + { + ushort from; // 48 + ushort to; // 57 + }; + + int c; // character classes + TQMemArray r; // character ranges + bool n; // negative? +#ifndef QT_NO_REGEXP_OPTIM + TQMemArray occ1; // first-occurrence array +#endif + }; +#else + struct CharClass + { + int dummy; + +#ifndef QT_NO_REGEXP_OPTIM + CharClass() { occ1.fill( 0, NumBadChars ); } + + const TQMemArray& firstOccurrence() const { return occ1; } + TQMemArray occ1; +#endif + }; +#endif + + TQRegExpEngine( bool caseSensitive ) { setup( caseSensitive ); } + TQRegExpEngine( const TQString& rx, bool caseSensitive ); +#ifndef QT_NO_REGEXP_OPTIM + ~TQRegExpEngine(); +#endif + + bool isValid() const { return valid; } + bool caseSensitive() const { return cs; } + const TQString& errorString() const { return yyError; } + int numCaptures() const { return officialncap; } + void match( const TQString& str, int pos, bool minimal, bool oneTest, + int caretIndex, TQMemArray& captured ); + int partialMatchLength() const { return mmOneTestMatchedLen; } + + int createState( TQChar ch ); + int createState( const CharClass& cc ); +#ifndef QT_NO_REGEXP_BACKREF + int createState( int bref ); +#endif + + void addCatTransitions( const TQMemArray& from, + const TQMemArray& to ); +#ifndef QT_NO_REGEXP_CAPTURE + void addPlusTransitions( const TQMemArray& from, + const TQMemArray& to, int atom ); +#endif + +#ifndef QT_NO_REGEXP_ANCHOR_ALT + int anchorAlternation( int a, int b ); + int anchorConcatenation( int a, int b ); +#else + int anchorAlternation( int a, int b ) { return a & b; } + int anchorConcatenation( int a, int b ) { return a | b; } +#endif + void addAnchors( int from, int to, int a ); + +#ifndef QT_NO_REGEXP_OPTIM + void heuristicallyChooseHeuristic(); +#endif + +#if defined(QT_DEBUG) + void dump() const; +#endif + +private: + enum { CharClassBit = 0x10000, BackRefBit = 0x20000 }; + + /* + The struct State represents one state in a modified NFA. The + input characters matched are stored in the state instead of on + the transitions, something possible for an automaton + constructed from a regular expression. + */ + struct State + { +#ifndef QT_NO_REGEXP_CAPTURE + int atom; // which atom does this state belong to? +#endif + int match; // what does it match? (see CharClassBit and BackRefBit) + TQMemArray outs; // out-transitions + TQMap *reenter; // atoms reentered when transiting out + TQMap *anchors; // anchors met when transiting out + +#ifndef QT_NO_REGEXP_CAPTURE + State( int a, int m ) + : atom( a ), match( m ), reenter( 0 ), anchors( 0 ) { } +#else + State( int m ) + : match( m ), reenter( 0 ), anchors( 0 ) { } +#endif + ~State() { delete reenter; delete anchors; } + }; + +#ifndef QT_NO_REGEXP_LOOKAHEAD + /* + The struct Lookahead represents a lookahead a la Perl (e.g., + (?=foo) and (?!bar)). + */ + struct Lookahead + { + TQRegExpEngine *eng; // NFA representing the embedded regular expression + bool neg; // negative lookahead? + + Lookahead( TQRegExpEngine *eng0, bool neg0 ) + : eng( eng0 ), neg( neg0 ) { } + ~Lookahead() { delete eng; } + }; +#endif + +#ifndef QT_NO_REGEXP_CAPTURE + /* + The struct Atom represents one node in the hierarchy of regular + expression atoms. + */ + struct Atom + { + int parent; // index of parent in array of atoms + int capture; // index of capture, from 1 to ncap + }; +#endif + +#ifndef QT_NO_REGEXP_ANCHOR_ALT + /* + The struct AnchorAlternation represents a pair of anchors with + OR semantics. + */ + struct AnchorAlternation + { + int a; // this anchor... + int b; // ...or this one + }; +#endif + + enum { InitialState = 0, FinalState = 1 }; + void setup( bool caseSensitive ); + int setupState( int match ); + + /* + Let's hope that 13 lookaheads and 14 back-references are + enough. + */ + enum { MaxLookaheads = 13, MaxBackRefs = 14 }; + enum { Anchor_Dollar = 0x00000001, Anchor_Caret = 0x00000002, + Anchor_Word = 0x00000004, Anchor_NonWord = 0x00000008, + Anchor_FirstLookahead = 0x00000010, + Anchor_BackRef1Empty = Anchor_FirstLookahead << MaxLookaheads, + Anchor_BackRef0Empty = Anchor_BackRef1Empty >> 1, + Anchor_Alternation = Anchor_BackRef1Empty << MaxBackRefs, + + Anchor_LookaheadMask = ( Anchor_FirstLookahead - 1 ) ^ + ( (Anchor_FirstLookahead << MaxLookaheads) - 1 ) }; +#ifndef QT_NO_REGEXP_CAPTURE + int startAtom( bool capture ); + void finishAtom( int atom ) { cf = f[atom].parent; } +#endif + +#ifndef QT_NO_REGEXP_LOOKAHEAD + int addLookahead( TQRegExpEngine *eng, bool negative ); +#endif + +#ifndef QT_NO_REGEXP_CAPTURE + bool isBetterCapture( const int *begin1, const int *end1, const int *begin2, + const int *end2 ); +#endif + bool testAnchor( int i, int a, const int *capBegin ); + +#ifndef QT_NO_REGEXP_OPTIM + bool goodStringMatch(); + bool badCharMatch(); +#else + bool bruteMatch(); +#endif + bool matchHere(); + + TQPtrVector s; // array of states + int ns; // number of states +#ifndef QT_NO_REGEXP_CAPTURE + TQMemArray f; // atom hierarchy + int nf; // number of atoms + int cf; // current atom +#endif + int officialncap; // number of captures, seen from the outside + int ncap; // number of captures, seen from the inside +#ifndef QT_NO_REGEXP_CCLASS + TQPtrVector cl; // array of character classes +#endif +#ifndef QT_NO_REGEXP_LOOKAHEAD + TQPtrVector ahead; // array of lookaheads +#endif +#ifndef QT_NO_REGEXP_ANCHOR_ALT + TQMemArray aa; // array of (a, b) pairs of anchors +#endif +#ifndef QT_NO_REGEXP_OPTIM + bool caretAnchored; // does the regexp start with ^? + bool trivial; // is the good-string all that needs to match? +#endif + bool valid; // is the regular expression valid? + bool cs; // case sensitive? +#ifndef QT_NO_REGEXP_BACKREF + int nbrefs; // number of back-references +#endif + +#ifndef QT_NO_REGEXP_OPTIM + bool useGoodStringHeuristic; // use goodStringMatch? otherwise badCharMatch + + int goodEarlyStart; // the index where goodStr can first occur in a match + int goodLateStart; // the index where goodStr can last occur in a match + TQString goodStr; // the string that any match has to contain + + int minl; // the minimum length of a match + TQMemArray occ1; // first-occurrence array +#endif + + /* + The class Box is an abstraction for a regular expression + fragment. It can also be seen as one node in the syntax tree of + a regular expression with synthetized attributes. + + Its interface is ugly for performance reasons. + */ + class Box + { + public: + Box( TQRegExpEngine *engine ); + Box( const Box& b ) { operator=( b ); } + + Box& operator=( const Box& b ); + + void clear() { operator=( Box(eng) ); } + void set( TQChar ch ); + void set( const CharClass& cc ); +#ifndef QT_NO_REGEXP_BACKREF + void set( int bref ); +#endif + + void cat( const Box& b ); + void orx( const Box& b ); + void plus( int atom ); + void opt(); + void catAnchor( int a ); +#ifndef QT_NO_REGEXP_OPTIM + void setupHeuristics(); +#endif + +#if defined(QT_DEBUG) + void dump() const; +#endif + + private: + void addAnchorsToEngine( const Box& to ) const; + + TQRegExpEngine *eng; // the automaton under construction + TQMemArray ls; // the left states (firstpos) + TQMemArray rs; // the right states (lastpos) + TQMap lanchors; // the left anchors + TQMap ranchors; // the right anchors + int skipanchors; // the anchors to match if the box is skipped + +#ifndef QT_NO_REGEXP_OPTIM + int earlyStart; // the index where str can first occur + int lateStart; // the index where str can last occur + TQString str; // a string that has to occur in any match + TQString leftStr; // a string occurring at the left of this box + TQString rightStr; // a string occurring at the right of this box + int maxl; // the maximum length of this box (possibly InftyLen) +#endif + + int minl; // the minimum length of this box +#ifndef QT_NO_REGEXP_OPTIM + TQMemArray occ1; // first-occurrence array +#endif + }; + friend class Box; + + /* + This is the lexical analyzer for regular expressions. + */ + enum { Tok_Eos, Tok_Dollar, Tok_LeftParen, Tok_MagicLeftParen, + Tok_PosLookahead, Tok_NegLookahead, Tok_RightParen, Tok_CharClass, + Tok_Caret, Tok_Quantifier, Tok_Bar, Tok_Word, Tok_NonWord, + Tok_Char = 0x10000, Tok_BackRef = 0x20000 }; + int getChar(); + int getEscape(); +#ifndef QT_NO_REGEXP_INTERVAL + int getRep( int def ); +#endif +#ifndef QT_NO_REGEXP_LOOKAHEAD + void skipChars( int n ); +#endif + void error( const char *msg ); + void startTokenizer( const TQChar *rx, int len ); + int getToken(); + + const TQChar *yyIn; // a pointer to the input regular expression pattern + int yyPos0; // the position of yyTok in the input pattern + int yyPos; // the position of the next character to read + int yyLen; // the length of yyIn + int yyCh; // the last character read + CharClass *yyCharClass; // attribute for Tok_CharClass tokens + int yyMinRep; // attribute for Tok_Quantifier + int yyMaxRep; // ditto + TQString yyError; // syntax error or overflow during parsing? + + /* + This is the syntactic analyzer for regular expressions. + */ + int parse( const TQChar *rx, int len ); + void parseAtom( Box *box ); + void parseFactor( Box *box ); + void parseTerm( Box *box ); + void parseExpression( Box *box ); + + int yyTok; // the last token read + bool yyMayCapture; // set this to FALSE to disable capturing + + /* + This is the engine state during matching. + */ + const TQString *mmStr; // a pointer to the input TQString + const TQChar *mmIn; // a pointer to the input string data + int mmPos; // the current position in the string + int mmCaretPos; + int mmLen; // the length of the input string + bool mmMinimal; // minimal matching? + TQMemArray mmBigArray; // big TQMemArray array + int *mmInNextStack; // is state is mmNextStack? + int *mmCurStack; // stack of current states + int *mmNextStack; // stack of next states + int *mmCurCapBegin; // start of current states' captures + int *mmNextCapBegin; // start of next states' captures + int *mmCurCapEnd; // end of current states' captures + int *mmNextCapEnd; // end of next states' captures + int *mmTempCapBegin; // start of temporary captures + int *mmTempCapEnd; // end of temporary captures + int *mmCapBegin; // start of captures for a next state + int *mmCapEnd; // end of captures for a next state + int *mmSlideTab; // bump-along slide table for bad-character heuristic + int mmSlideTabSize; // size of slide table +#ifndef QT_NO_REGEXP_BACKREF + TQIntDict mmSleeping; // dictionary of back-reference sleepers +#endif + int mmMatchLen; // length of match + int mmOneTestMatchedLen; // length of partial match +}; + +TQRegExpEngine::TQRegExpEngine( const TQString& rx, bool caseSensitive ) +#ifndef QT_NO_REGEXP_BACKREF + : mmSleeping( 101 ) +#endif +{ + setup( caseSensitive ); + valid = ( parse(rx.unicode(), rx.length()) == (int) rx.length() ); + if ( !valid ) { +#ifndef QT_NO_REGEXP_OPTIM + trivial = FALSE; +#endif + error( RXERR_LEFTDELIM ); + } +} + +#ifndef QT_NO_REGEXP_OPTIM +TQRegExpEngine::~TQRegExpEngine() +{ +} +#endif + +/* + Tries to match in str and returns an array of (begin, length) pairs + for captured text. If there is no match, all pairs are (-1, -1). +*/ +void TQRegExpEngine::match( const TQString& str, int pos, bool minimal, + bool oneTest, int caretIndex, + TQMemArray& captured ) +{ + bool matched = FALSE; + +#ifndef QT_NO_REGEXP_OPTIM + if ( trivial && !oneTest ) { + mmPos = str.find( goodStr, pos, cs ); + mmMatchLen = goodStr.length(); + matched = ( mmPos != -1 ); + } else +#endif + { + mmStr = &str; + mmIn = str.unicode(); + if ( mmIn == 0 ) + mmIn = &TQChar::null; + mmPos = pos; + mmCaretPos = caretIndex; + mmLen = str.length(); + mmMinimal = minimal; + mmMatchLen = 0; + mmOneTestMatchedLen = 0; + + if ( valid && mmPos >= 0 && mmPos <= mmLen ) { +#ifndef QT_NO_REGEXP_OPTIM + if ( oneTest ) { + matched = matchHere(); + } else { + if ( mmPos <= mmLen - minl ) { + if ( caretAnchored ) { + matched = matchHere(); + } else if ( useGoodStringHeuristic ) { + matched = goodStringMatch(); + } else { + matched = badCharMatch(); + } + } + } +#else + matched = oneTest ? matchHere() : bruteMatch(); +#endif + } + } + + int capturedSize = 2 + 2 * officialncap; + captured.detach(); + captured.resize( capturedSize ); + if ( matched ) { + captured[0] = mmPos; + captured[1] = mmMatchLen; + for ( int j = 0; j < officialncap; j++ ) { + int len = mmCapEnd[j] - mmCapBegin[j]; + captured[2 + 2 * j] = len > 0 ? mmPos + mmCapBegin[j] : 0; + captured[2 + 2 * j + 1] = len; + } + } else { + // we rely on 2's complement here + memset( captured.data(), -1, capturedSize * sizeof(int) ); + } +} + +/* + The three following functions add one state to the automaton and + return the number of the state. +*/ + +int TQRegExpEngine::createState( TQChar ch ) +{ + return setupState( ch.unicode() ); +} + +int TQRegExpEngine::createState( const CharClass& cc ) +{ +#ifndef QT_NO_REGEXP_CCLASS + int n = cl.size(); + cl.resize( n + 1 ); + cl.insert( n, new CharClass(cc) ); + return setupState( CharClassBit | n ); +#else + Q_UNUSED( cc ); + return setupState( CharClassBit ); +#endif +} + +#ifndef QT_NO_REGEXP_BACKREF +int TQRegExpEngine::createState( int bref ) +{ + if ( bref > nbrefs ) { + nbrefs = bref; + if ( nbrefs > MaxBackRefs ) { + error( RXERR_LIMIT ); + return 0; + } + } + return setupState( BackRefBit | bref ); +} +#endif + +/* + The two following functions add a transition between all pairs of + states (i, j) where i is fond in from, and j is found in to. + + Cat-transitions are distinguished from plus-transitions for + capturing. +*/ + +void TQRegExpEngine::addCatTransitions( const TQMemArray& from, + const TQMemArray& to ) +{ + for ( int i = 0; i < (int) from.size(); i++ ) { + State *st = s[from[i]]; + mergeInto( &st->outs, to ); + } +} + +#ifndef QT_NO_REGEXP_CAPTURE +void TQRegExpEngine::addPlusTransitions( const TQMemArray& from, + const TQMemArray& to, int atom ) +{ + for ( int i = 0; i < (int) from.size(); i++ ) { + State *st = s[from[i]]; + TQMemArray oldOuts = st->outs.copy(); + mergeInto( &st->outs, to ); + if ( f[atom].capture >= 0 ) { + if ( st->reenter == 0 ) + st->reenter = new TQMap; + for ( int j = 0; j < (int) to.size(); j++ ) { + if ( !st->reenter->contains(to[j]) && + oldOuts.bsearch(to[j]) < 0 ) + st->reenter->insert( to[j], atom ); + } + } + } +} +#endif + +#ifndef QT_NO_REGEXP_ANCHOR_ALT +/* + Returns an anchor that means a OR b. +*/ +int TQRegExpEngine::anchorAlternation( int a, int b ) +{ + if ( ((a & b) == a || (a & b) == b) && ((a | b) & Anchor_Alternation) == 0 ) + return a & b; + + int n = aa.size(); +#ifndef QT_NO_REGEXP_OPTIM + if ( n > 0 && aa[n - 1].a == a && aa[n - 1].b == b ) + return Anchor_Alternation | ( n - 1 ); +#endif + + aa.resize( n + 1 ); + aa[n].a = a; + aa[n].b = b; + return Anchor_Alternation | n; +} + +/* + Returns an anchor that means a AND b. +*/ +int TQRegExpEngine::anchorConcatenation( int a, int b ) +{ + if ( ((a | b) & Anchor_Alternation) == 0 ) + return a | b; + if ( (b & Anchor_Alternation) != 0 ) + qSwap( a, b ); + + int aprime = anchorConcatenation( aa[a ^ Anchor_Alternation].a, b ); + int bprime = anchorConcatenation( aa[a ^ Anchor_Alternation].b, b ); + return anchorAlternation( aprime, bprime ); +} +#endif + +/* + Adds anchor a on a transition caracterised by its from state and + its to state. +*/ +void TQRegExpEngine::addAnchors( int from, int to, int a ) +{ + State *st = s[from]; + if ( st->anchors == 0 ) + st->anchors = new TQMap; + if ( st->anchors->contains(to) ) + a = anchorAlternation( (*st->anchors)[to], a ); + st->anchors->insert( to, a ); +} + +#ifndef QT_NO_REGEXP_OPTIM +/* + This function chooses between the good-string and the bad-character + heuristics. It computes two scores and chooses the heuristic with + the highest score. + + Here are some common-sense constraints on the scores that should be + respected if the formulas are ever modified: (1) If goodStr is + empty, the good-string heuristic scores 0. (2) If the regular + expression is trivial, the good-string heuristic should be used. + (3) If the search is case insensitive, the good-string heuristic + should be used, unless it scores 0. (Case insensitivity turns all + entries of occ1 to 0.) (4) If (goodLateStart - goodEarlyStart) is + big, the good-string heuristic should score less. +*/ +void TQRegExpEngine::heuristicallyChooseHeuristic() +{ + if ( minl == 0 ) { + useGoodStringHeuristic = FALSE; + } else if ( trivial ) { + useGoodStringHeuristic = TRUE; + } else { + /* + Magic formula: The good string has to constitute a good + proportion of the minimum-length string, and appear at a + more-or-less known index. + */ + int goodStringScore = ( 64 * goodStr.length() / minl ) - + ( goodLateStart - goodEarlyStart ); + /* + Less magic formula: We pick some characters at random, and + check whether they are good or bad. + */ + int badCharScore = 0; + int step = TQMAX( 1, NumBadChars / 32 ); + for ( int i = 1; i < NumBadChars; i += step ) { + if ( occ1[i] == NoOccurrence ) + badCharScore += minl; + else + badCharScore += occ1[i]; + } + badCharScore /= minl; + useGoodStringHeuristic = ( goodStringScore > badCharScore ); + } +} +#endif + +#if defined(QT_DEBUG) +void TQRegExpEngine::dump() const +{ + int i, j; + qDebug( "Case %ssensitive engine", cs ? "" : "in" ); + qDebug( " States" ); + for ( i = 0; i < ns; i++ ) { + qDebug( " %d%s", i, + i == InitialState ? " (initial)" : + i == FinalState ? " (final)" : "" ); +#ifndef QT_NO_REGEXP_CAPTURE + qDebug( " in atom %d", s[i]->atom ); +#endif + int m = s[i]->match; + if ( (m & CharClassBit) != 0 ) { + qDebug( " match character class %d", m ^ CharClassBit ); +#ifndef QT_NO_REGEXP_CCLASS + cl[m ^ CharClassBit]->dump(); +#else + qDebug( " negative character class" ); +#endif + } else if ( (m & BackRefBit) != 0 ) { + qDebug( " match back-reference %d", m ^ BackRefBit ); + } else if ( m >= 0x20 && m <= 0x7e ) { + qDebug( " match 0x%.4x (%c)", m, m ); + } else { + qDebug( " match 0x%.4x", m ); + } + for ( j = 0; j < (int) s[i]->outs.size(); j++ ) { + int next = s[i]->outs[j]; + qDebug( " -> %d", next ); + if ( s[i]->reenter != 0 && s[i]->reenter->contains(next) ) + qDebug( " [reenter %d]", (*s[i]->reenter)[next] ); + if ( s[i]->anchors != 0 && at(*s[i]->anchors, next) != 0 ) + qDebug( " [anchors 0x%.8x]", (*s[i]->anchors)[next] ); + } + } +#ifndef QT_NO_REGEXP_CAPTURE + if ( nf > 0 ) { + qDebug( " Atom Parent Capture" ); + for ( i = 0; i < nf; i++ ) + qDebug( " %6d %6d %6d", i, f[i].parent, f[i].capture ); + } +#endif +#ifndef QT_NO_REGEXP_ANCHOR_ALT + for ( i = 0; i < (int) aa.size(); i++ ) + qDebug( " Anchor alternation 0x%.8x: 0x%.8x 0x%.9x", i, aa[i].a, + aa[i].b ); +#endif +} +#endif + +void TQRegExpEngine::setup( bool caseSensitive ) +{ + s.setAutoDelete( TRUE ); + s.resize( 32 ); + ns = 0; +#ifndef QT_NO_REGEXP_CAPTURE + f.resize( 32 ); + nf = 0; + cf = -1; +#endif + officialncap = 0; + ncap = 0; +#ifndef QT_NO_REGEXP_CCLASS + cl.setAutoDelete( TRUE ); +#endif +#ifndef QT_NO_REGEXP_LOOKAHEAD + ahead.setAutoDelete( TRUE ); +#endif +#ifndef QT_NO_REGEXP_OPTIM + caretAnchored = TRUE; + trivial = TRUE; +#endif + valid = FALSE; + cs = caseSensitive; +#ifndef QT_NO_REGEXP_BACKREF + nbrefs = 0; +#endif +#ifndef QT_NO_REGEXP_OPTIM + useGoodStringHeuristic = TRUE; + minl = 0; + occ1.fill( 0, NumBadChars ); +#endif +} + +int TQRegExpEngine::setupState( int match ) +{ + if ( (ns & (ns + 1)) == 0 && ns + 1 >= (int) s.size() ) + s.resize( (ns + 1) << 1 ); +#ifndef QT_NO_REGEXP_CAPTURE + s.insert( ns, new State(cf, match) ); +#else + s.insert( ns, new State(match) ); +#endif + return ns++; +} + +#ifndef QT_NO_REGEXP_CAPTURE +/* + Functions startAtom() and finishAtom() should be called to delimit + atoms. When a state is created, it is assigned to the current atom. + The information is later used for capturing. +*/ +int TQRegExpEngine::startAtom( bool capture ) +{ + if ( (nf & (nf + 1)) == 0 && nf + 1 >= (int) f.size() ) + f.resize( (nf + 1) << 1 ); + f[nf].parent = cf; + cf = nf++; + f[cf].capture = capture ? ncap++ : -1; + return cf; +} +#endif + +#ifndef QT_NO_REGEXP_LOOKAHEAD +/* + Creates a lookahead anchor. +*/ +int TQRegExpEngine::addLookahead( TQRegExpEngine *eng, bool negative ) +{ + int n = ahead.size(); + if ( n == MaxLookaheads ) { + error( RXERR_LIMIT ); + return 0; + } + ahead.resize( n + 1 ); + ahead.insert( n, new Lookahead(eng, negative) ); + return Anchor_FirstLookahead << n; +} +#endif + +#ifndef QT_NO_REGEXP_CAPTURE +/* + We want the longest leftmost captures. +*/ +bool TQRegExpEngine::isBetterCapture( const int *begin1, const int *end1, + const int *begin2, const int *end2 ) +{ + for ( int i = 0; i < ncap; i++ ) { + int delta = begin2[i] - begin1[i]; // it has to start early... + if ( delta == 0 ) + delta = end1[i] - end2[i]; // ...and end late (like a party) + + if ( delta != 0 ) + return delta > 0; + } + return FALSE; +} +#endif + +/* + Returns TRUE if anchor a matches at position mmPos + i in the input + string, otherwise FALSE. +*/ +bool TQRegExpEngine::testAnchor( int i, int a, const int *capBegin ) +{ + int j; + +#ifndef QT_NO_REGEXP_ANCHOR_ALT + if ( (a & Anchor_Alternation) != 0 ) { + return testAnchor( i, aa[a ^ Anchor_Alternation].a, capBegin ) || + testAnchor( i, aa[a ^ Anchor_Alternation].b, capBegin ); + } +#endif + + if ( (a & Anchor_Caret) != 0 ) { + if ( mmPos + i != mmCaretPos ) + return FALSE; + } + if ( (a & Anchor_Dollar) != 0 ) { + if ( mmPos + i != mmLen ) + return FALSE; + } +#ifndef QT_NO_REGEXP_ESCAPE + if ( (a & (Anchor_Word | Anchor_NonWord)) != 0 ) { + bool before = FALSE; + bool after = FALSE; + if ( mmPos + i != 0 ) + before = isWord( mmIn[mmPos + i - 1] ); + if ( mmPos + i != mmLen ) + after = isWord( mmIn[mmPos + i] ); + if ( (a & Anchor_Word) != 0 && (before == after) ) + return FALSE; + if ( (a & Anchor_NonWord) != 0 && (before != after) ) + return FALSE; + } +#endif +#ifndef QT_NO_REGEXP_LOOKAHEAD + if ( (a & Anchor_LookaheadMask) != 0 ) { + TQConstString cstr = TQConstString( (TQChar *) mmIn + mmPos + i, + mmLen - mmPos - i ); + for ( j = 0; j < (int) ahead.size(); j++ ) { + if ( (a & (Anchor_FirstLookahead << j)) != 0 ) { + TQMemArray captured; + ahead[j]->eng->match( cstr.string(), 0, TRUE, TRUE, + mmCaretPos - mmPos - i, captured ); + if ( (captured[0] == 0) == ahead[j]->neg ) + return FALSE; + } + } + } +#endif +#ifndef QT_NO_REGEXP_CAPTURE +#ifndef QT_NO_REGEXP_BACKREF + for ( j = 0; j < nbrefs; j++ ) { + if ( (a & (Anchor_BackRef1Empty << j)) != 0 ) { + if ( capBegin[j] != EmptyCapture ) + return FALSE; + } + } +#endif +#endif + return TRUE; +} + +#ifndef QT_NO_REGEXP_OPTIM +/* + The three following functions are what Jeffrey Friedl would call + transmissions (or bump-alongs). Using one or the other should make + no difference except in performance. +*/ + +bool TQRegExpEngine::goodStringMatch() +{ + int k = mmPos + goodEarlyStart; + while ( (k = mmStr->find(goodStr, k, cs)) != -1 ) { + int from = k - goodLateStart; + int to = k - goodEarlyStart; + if ( from > mmPos ) + mmPos = from; + + while ( mmPos <= to ) { + if ( matchHere() ) + return TRUE; + mmPos++; + } + k++; + } + return FALSE; +} + +bool TQRegExpEngine::badCharMatch() +{ + int slideHead = 0; + int slideNext = 0; + int i; + int lastPos = mmLen - minl; + memset( mmSlideTab, 0, mmSlideTabSize * sizeof(int) ); + + /* + Set up the slide table, used for the bad-character heuristic, + using the table of first occurrence of each character. + */ + for ( i = 0; i < minl; i++ ) { + int sk = occ1[BadChar(mmIn[mmPos + i])]; + if ( sk == NoOccurrence ) + sk = i + 1; + if ( sk > 0 ) { + int k = i + 1 - sk; + if ( k < 0 ) { + sk = i + 1; + k = 0; + } + if ( sk > mmSlideTab[k] ) + mmSlideTab[k] = sk; + } + } + + if ( mmPos > lastPos ) + return FALSE; + + for ( ;; ) { + if ( ++slideNext >= mmSlideTabSize ) + slideNext = 0; + if ( mmSlideTab[slideHead] > 0 ) { + if ( mmSlideTab[slideHead] - 1 > mmSlideTab[slideNext] ) + mmSlideTab[slideNext] = mmSlideTab[slideHead] - 1; + mmSlideTab[slideHead] = 0; + } else { + if ( matchHere() ) + return TRUE; + } + + if ( mmPos == lastPos ) + break; + + /* + Update the slide table. This code has much in common with + the initialization code. + */ + int sk = occ1[BadChar(mmIn[mmPos + minl])]; + if ( sk == NoOccurrence ) { + mmSlideTab[slideNext] = minl; + } else if ( sk > 0 ) { + int k = slideNext + minl - sk; + if ( k >= mmSlideTabSize ) + k -= mmSlideTabSize; + if ( sk > mmSlideTab[k] ) + mmSlideTab[k] = sk; + } + slideHead = slideNext; + mmPos++; + } + return FALSE; +} +#else +bool TQRegExpEngine::bruteMatch() +{ + while ( mmPos <= mmLen ) { + if ( matchHere() ) + return TRUE; + mmPos++; + } + return FALSE; +} +#endif + +/* + Here's the core of the engine. It tries to do a match here and now. +*/ +bool TQRegExpEngine::matchHere() +{ + int ncur = 1, nnext = 0; + int i = 0, j, k, m; + bool stop = FALSE; + + mmMatchLen = -1; + mmOneTestMatchedLen = -1; + mmCurStack[0] = InitialState; + +#ifndef QT_NO_REGEXP_CAPTURE + if ( ncap > 0 ) { + for ( j = 0; j < ncap; j++ ) { + mmCurCapBegin[j] = EmptyCapture; + mmCurCapEnd[j] = EmptyCapture; + } + } +#endif + +#ifndef QT_NO_REGEXP_BACKREF + int *zzZ = 0; + + while ( (ncur > 0 || !mmSleeping.isEmpty()) && i <= mmLen - mmPos && + !stop ) +#else + while ( ncur > 0 && i <= mmLen - mmPos && !stop ) +#endif + { + int ch = ( i < mmLen - mmPos ) ? mmIn[mmPos + i].unicode() : 0; + for ( j = 0; j < ncur; j++ ) { + int cur = mmCurStack[j]; + State *scur = s[cur]; + TQMemArray& outs = scur->outs; + for ( k = 0; k < (int) outs.size(); k++ ) { + int next = outs[k]; + State *snext = s[next]; + bool in = TRUE; +#ifndef QT_NO_REGEXP_BACKREF + int needSomeSleep = 0; +#endif + + /* + First, check if the anchors are anchored properly. + */ + if ( scur->anchors != 0 ) { + int a = at( *scur->anchors, next ); + if ( a != 0 && !testAnchor(i, a, mmCurCapBegin + j * ncap) ) + in = FALSE; + } + /* + If indeed they are, check if the input character is + correct for this transition. + */ + if ( in ) { + m = snext->match; + if ( (m & (CharClassBit | BackRefBit)) == 0 ) { + if ( cs ) + in = ( m == ch ); + else + in = ( TQChar(m).lower() == TQChar(ch).lower() ); + } else if ( next == FinalState ) { + mmMatchLen = i; + stop = mmMinimal; + in = TRUE; + } else if ( (m & CharClassBit) != 0 ) { +#ifndef QT_NO_REGEXP_CCLASS + const CharClass *cc = cl[m ^ CharClassBit]; + if ( cs ) + in = cc->in( ch ); + else if ( cc->negative() ) + in = cc->in( TQChar(ch).lower() ) && + cc->in( TQChar(ch).upper() ); + else + in = cc->in( TQChar(ch).lower() ) || + cc->in( TQChar(ch).upper() ); +#endif +#ifndef QT_NO_REGEXP_BACKREF + } else { /* ( (m & BackRefBit) != 0 ) */ + int bref = m ^ BackRefBit; + int ell = j * ncap + ( bref - 1 ); + + in = bref <= ncap && mmCurCapBegin[ell] != EmptyCapture; + if ( in ) { + if ( cs ) + in = ( mmIn[mmPos + mmCurCapBegin[ell]] + == TQChar(ch) ); + else + in = ( mmIn[mmPos + mmCurCapBegin[ell]].lower() + == TQChar(ch).lower() ); + } + + if ( in ) { + int delta; + if ( mmCurCapEnd[ell] == EmptyCapture ) + delta = i - mmCurCapBegin[ell]; + else + delta = mmCurCapEnd[ell] - mmCurCapBegin[ell]; + + in = ( delta <= mmLen - (mmPos + i) ); + if ( in && delta > 1 ) { + int n = 1; + if ( cs ) { + while ( n < delta ) { + if ( mmIn[mmPos + + mmCurCapBegin[ell] + n] != + mmIn[mmPos + i + n] ) + break; + n++; + } + } else { + while ( n < delta ) { + TQChar a = mmIn[mmPos + + mmCurCapBegin[ell] + n]; + TQChar b = mmIn[mmPos + i + n]; + if ( a.lower() != b.lower() ) + break; + n++; + } + } + in = ( n == delta ); + if ( in ) + needSomeSleep = delta - 1; + } + } +#endif + } + } + + /* + We must now update our data structures. + */ + if ( in ) { +#ifndef QT_NO_REGEXP_CAPTURE + int *capBegin, *capEnd; +#endif + /* + If the next state was not encountered yet, all + is fine. + */ + if ( (m = mmInNextStack[next]) == -1 ) { + m = nnext++; + mmNextStack[m] = next; + mmInNextStack[next] = m; +#ifndef QT_NO_REGEXP_CAPTURE + capBegin = mmNextCapBegin + m * ncap; + capEnd = mmNextCapEnd + m * ncap; + + /* + Otherwise, we'll first maintain captures in + temporary arrays, and decide at the end whether + it's best to keep the previous capture zones or + the new ones. + */ + } else { + capBegin = mmTempCapBegin; + capEnd = mmTempCapEnd; +#endif + } + +#ifndef QT_NO_REGEXP_CAPTURE + /* + Updating the capture zones is much of a task. + */ + if ( ncap > 0 ) { + memcpy( capBegin, mmCurCapBegin + j * ncap, + ncap * sizeof(int) ); + memcpy( capEnd, mmCurCapEnd + j * ncap, + ncap * sizeof(int) ); + int c = scur->atom, n = snext->atom; + int p = -1, q = -1; + int cap; + + /* + Lemma 1. For any x in the range [0..nf), we + have f[x].parent < x. + + Proof. By looking at startAtom(), it is + clear that cf < nf holds all the time, and + thus that f[nf].parent < nf. + */ + + /* + If we are reentering an atom, we empty all + capture zones inside it. + */ + if ( scur->reenter != 0 && + (q = at(*scur->reenter, next)) != 0 ) { + TQBitArray b; + b.fill( FALSE, nf ); + b.setBit( q, TRUE ); + for ( int ell = q + 1; ell < nf; ell++ ) { + if ( b.testBit(f[ell].parent) ) { + b.setBit( ell, TRUE ); + cap = f[ell].capture; + if ( cap >= 0 ) { + capBegin[cap] = EmptyCapture; + capEnd[cap] = EmptyCapture; + } + } + } + p = f[q].parent; + + /* + Otherwise, close the capture zones we are + leaving. We are leaving f[c].capture, + f[f[c].parent].capture, + f[f[f[c].parent].parent].capture, ..., + until f[x].capture, with x such that + f[x].parent is the youngest common ancestor + for c and n. + + We go up along c's and n's ancestry until + we find x. + */ + } else { + p = c; + q = n; + while ( p != q ) { + if ( p > q ) { + cap = f[p].capture; + if ( cap >= 0 ) { + if ( capBegin[cap] == i ) { + capBegin[cap] = EmptyCapture; + capEnd[cap] = EmptyCapture; + } else { + capEnd[cap] = i; + } + } + p = f[p].parent; + } else { + q = f[q].parent; + } + } + } + + /* + In any case, we now open the capture zones + we are entering. We work upwards from n + until we reach p (the parent of the atom we + reenter or the youngest common ancestor). + */ + while ( n > p ) { + cap = f[n].capture; + if ( cap >= 0 ) { + capBegin[cap] = i; + capEnd[cap] = EmptyCapture; + } + n = f[n].parent; + } + /* + If the next state was already in + mmNextStack, we must choose carefully which + capture zones we want to keep. + */ + if ( capBegin == mmTempCapBegin && + isBetterCapture(capBegin, capEnd, + mmNextCapBegin + m * ncap, + mmNextCapEnd + m * ncap) ) { + memcpy( mmNextCapBegin + m * ncap, capBegin, + ncap * sizeof(int) ); + memcpy( mmNextCapEnd + m * ncap, capEnd, + ncap * sizeof(int) ); + } + } +#ifndef QT_NO_REGEXP_BACKREF + /* + We are done with updating the capture zones. + It's now time to put the next state to sleep, + if it needs to, and to remove it from + mmNextStack. + */ + if ( needSomeSleep > 0 ) { + zzZ = new int[1 + 2 * ncap]; + zzZ[0] = next; + if ( ncap > 0 ) { + memcpy( zzZ + 1, capBegin, ncap * sizeof(int) ); + memcpy( zzZ + 1 + ncap, capEnd, + ncap * sizeof(int) ); + } + mmInNextStack[mmNextStack[--nnext]] = -1; + mmSleeping.insert( i + needSomeSleep, zzZ ); + } +#endif +#endif + } + } + } +#ifndef QT_NO_REGEXP_CAPTURE + /* + If we reached the final state, hurray! Copy the captured + zone. + */ + if ( ncap > 0 && (m = mmInNextStack[FinalState]) != -1 ) { + memcpy( mmCapBegin, mmNextCapBegin + m * ncap, ncap * sizeof(int) ); + memcpy( mmCapEnd, mmNextCapEnd + m * ncap, ncap * sizeof(int) ); + } +#ifndef QT_NO_REGEXP_BACKREF + /* + It's time to wake up the sleepers. + */ + if ( !mmSleeping.isEmpty() ) { + while ( (zzZ = mmSleeping.take(i)) != 0 ) { + int next = zzZ[0]; + int *capBegin = zzZ + 1; + int *capEnd = zzZ + 1 + ncap; + bool copyOver = TRUE; + + if ( (m = mmInNextStack[zzZ[0]]) == -1 ) { + m = nnext++; + mmNextStack[m] = next; + mmInNextStack[next] = m; + } else { + copyOver = isBetterCapture( mmNextCapBegin + m * ncap, + mmNextCapEnd + m * ncap, + capBegin, capEnd ); + } + if ( copyOver ) { + memcpy( mmNextCapBegin + m * ncap, capBegin, + ncap * sizeof(int) ); + memcpy( mmNextCapEnd + m * ncap, capEnd, + ncap * sizeof(int) ); + } + delete[] zzZ; + } + } +#endif +#endif + for ( j = 0; j < nnext; j++ ) + mmInNextStack[mmNextStack[j]] = -1; + + // avoid needless iteration that confuses mmOneTestMatchedLen + if ( nnext == 1 && mmNextStack[0] == FinalState +#ifndef QT_NO_REGEXP_BACKREF + && mmSleeping.isEmpty() +#endif + ) + stop = TRUE; + + qSwap( mmCurStack, mmNextStack ); +#ifndef QT_NO_REGEXP_CAPTURE + qSwap( mmCurCapBegin, mmNextCapBegin ); + qSwap( mmCurCapEnd, mmNextCapEnd ); +#endif + ncur = nnext; + nnext = 0; + i++; + } + +#ifndef QT_NO_REGEXP_BACKREF + /* + If minimal matching is enabled, we might have some sleepers + left. + */ + while ( !mmSleeping.isEmpty() ) { + zzZ = mmSleeping.take( *TQIntDictIterator(mmSleeping) ); + delete[] zzZ; + } +#endif + + mmOneTestMatchedLen = i - 1; + return ( mmMatchLen >= 0 ); +} + +#ifndef QT_NO_REGEXP_CCLASS + +TQRegExpEngine::CharClass::CharClass() + : c( 0 ), n( FALSE ) +{ +#ifndef QT_NO_REGEXP_OPTIM + occ1.fill( NoOccurrence, NumBadChars ); +#endif +} + +TQRegExpEngine::CharClass& TQRegExpEngine::CharClass::operator=( + const CharClass& cc ) +{ + c = cc.c; + r = cc.r.copy(); + n = cc.n; +#ifndef QT_NO_REGEXP_OPTIM + occ1 = cc.occ1; +#endif + return *this; +} + +void TQRegExpEngine::CharClass::clear() +{ + c = 0; + r.resize( 0 ); + n = FALSE; +} + +void TQRegExpEngine::CharClass::setNegative( bool negative ) +{ + n = negative; +#ifndef QT_NO_REGEXP_OPTIM + occ1.fill( 0, NumBadChars ); +#endif +} + +void TQRegExpEngine::CharClass::addCategories( int cats ) +{ + c |= cats; +#ifndef QT_NO_REGEXP_OPTIM + occ1.fill( 0, NumBadChars ); +#endif +} + +void TQRegExpEngine::CharClass::addRange( ushort from, ushort to ) +{ + if ( from > to ) + qSwap( from, to ); + int m = r.size(); + r.resize( m + 1 ); + r[m].from = from; + r[m].to = to; + +#ifndef QT_NO_REGEXP_OPTIM + int i; + + if ( to - from < NumBadChars ) { + occ1.detach(); + if ( from % NumBadChars <= to % NumBadChars ) { + for ( i = from % NumBadChars; i <= to % NumBadChars; i++ ) + occ1[i] = 0; + } else { + for ( i = 0; i <= to % NumBadChars; i++ ) + occ1[i] = 0; + for ( i = from % NumBadChars; i < NumBadChars; i++ ) + occ1[i] = 0; + } + } else { + occ1.fill( 0, NumBadChars ); + } +#endif +} + +bool TQRegExpEngine::CharClass::in( TQChar ch ) const +{ +#ifndef QT_NO_REGEXP_OPTIM + if ( occ1[BadChar(ch)] == NoOccurrence ) + return n; +#endif + + if ( c != 0 && (c & (1 << (int) ch.category())) != 0 ) + return !n; + for ( int i = 0; i < (int) r.size(); i++ ) { + if ( ch.unicode() >= r[i].from && ch.unicode() <= r[i].to ) + return !n; + } + return n; +} + +#if defined(QT_DEBUG) +void TQRegExpEngine::CharClass::dump() const +{ + int i; + qDebug( " %stive character class", n ? "nega" : "posi" ); +#ifndef QT_NO_REGEXP_CCLASS + if ( c != 0 ) + qDebug( " categories 0x%.8x", c ); +#endif + for ( i = 0; i < (int) r.size(); i++ ) + qDebug( " 0x%.4x through 0x%.4x", r[i].from, r[i].to ); +} +#endif +#endif + +TQRegExpEngine::Box::Box( TQRegExpEngine *engine ) + : eng( engine ), skipanchors( 0 ) +#ifndef QT_NO_REGEXP_OPTIM + , earlyStart( 0 ), lateStart( 0 ), maxl( 0 ) +#endif +{ +#ifndef QT_NO_REGEXP_OPTIM + occ1.fill( NoOccurrence, NumBadChars ); +#endif + minl = 0; +} + +TQRegExpEngine::Box& TQRegExpEngine::Box::operator=( const Box& b ) +{ + eng = b.eng; + ls = b.ls; + rs = b.rs; + lanchors = b.lanchors; + ranchors = b.ranchors; + skipanchors = b.skipanchors; +#ifndef QT_NO_REGEXP_OPTIM + earlyStart = b.earlyStart; + lateStart = b.lateStart; + str = b.str; + leftStr = b.leftStr; + rightStr = b.rightStr; + maxl = b.maxl; + occ1 = b.occ1; +#endif + minl = b.minl; + return *this; +} + +void TQRegExpEngine::Box::set( TQChar ch ) +{ + ls.resize( 1 ); + ls[0] = eng->createState( ch ); + rs = ls; + rs.detach(); +#ifndef QT_NO_REGEXP_OPTIM + str = ch; + leftStr = ch; + rightStr = ch; + maxl = 1; + occ1.detach(); + occ1[BadChar(ch)] = 0; +#endif + minl = 1; +} + +void TQRegExpEngine::Box::set( const CharClass& cc ) +{ + ls.resize( 1 ); + ls[0] = eng->createState( cc ); + rs = ls; + rs.detach(); +#ifndef QT_NO_REGEXP_OPTIM + maxl = 1; + occ1 = cc.firstOccurrence(); +#endif + minl = 1; +} + +#ifndef QT_NO_REGEXP_BACKREF +void TQRegExpEngine::Box::set( int bref ) +{ + ls.resize( 1 ); + ls[0] = eng->createState( bref ); + rs = ls; + rs.detach(); + if ( bref >= 1 && bref <= MaxBackRefs ) + skipanchors = Anchor_BackRef0Empty << bref; +#ifndef QT_NO_REGEXP_OPTIM + maxl = InftyLen; +#endif + minl = 0; +} +#endif + +void TQRegExpEngine::Box::cat( const Box& b ) +{ + eng->addCatTransitions( rs, b.ls ); + addAnchorsToEngine( b ); + if ( minl == 0 ) { + mergeInto( &lanchors, b.lanchors ); + if ( skipanchors != 0 ) { + for ( int i = 0; i < (int) b.ls.size(); i++ ) { + int a = eng->anchorConcatenation( at(lanchors, b.ls[i]), + skipanchors ); + lanchors.insert( b.ls[i], a ); + } + } + mergeInto( &ls, b.ls ); + } + if ( b.minl == 0 ) { + mergeInto( &ranchors, b.ranchors ); + if ( b.skipanchors != 0 ) { + for ( int i = 0; i < (int) rs.size(); i++ ) { + int a = eng->anchorConcatenation( at(ranchors, rs[i]), + b.skipanchors ); + ranchors.insert( rs[i], a ); + } + } + mergeInto( &rs, b.rs ); + } else { + ranchors = b.ranchors; + rs = b.rs; + } + +#ifndef QT_NO_REGEXP_OPTIM + if ( maxl != InftyLen ) { + if ( rightStr.length() + b.leftStr.length() > + TQMAX(str.length(), b.str.length()) ) { + earlyStart = minl - rightStr.length(); + lateStart = maxl - rightStr.length(); + str = rightStr + b.leftStr; + } else if ( b.str.length() > str.length() ) { + earlyStart = minl + b.earlyStart; + lateStart = maxl + b.lateStart; + str = b.str; + } + } + + if ( (int) leftStr.length() == maxl ) + leftStr += b.leftStr; + + if ( (int) b.rightStr.length() == b.maxl ) { + rightStr += b.rightStr; + } else { + rightStr = b.rightStr; + } + + if ( maxl == InftyLen || b.maxl == InftyLen ) { + maxl = InftyLen; + } else { + maxl += b.maxl; + } + + occ1.detach(); + for ( int i = 0; i < NumBadChars; i++ ) { + if ( b.occ1[i] != NoOccurrence && minl + b.occ1[i] < occ1[i] ) + occ1[i] = minl + b.occ1[i]; + } +#endif + + minl += b.minl; + if ( minl == 0 ) + skipanchors = eng->anchorConcatenation( skipanchors, b.skipanchors ); + else + skipanchors = 0; +} + +void TQRegExpEngine::Box::orx( const Box& b ) +{ + mergeInto( &ls, b.ls ); + mergeInto( &lanchors, b.lanchors ); + mergeInto( &rs, b.rs ); + mergeInto( &ranchors, b.ranchors ); + + if ( b.minl == 0 ) { + if ( minl == 0 ) + skipanchors = eng->anchorAlternation( skipanchors, b.skipanchors ); + else + skipanchors = b.skipanchors; + } + +#ifndef QT_NO_REGEXP_OPTIM + occ1.detach(); + for ( int i = 0; i < NumBadChars; i++ ) { + if ( occ1[i] > b.occ1[i] ) + occ1[i] = b.occ1[i]; + } + earlyStart = 0; + lateStart = 0; + str = TQString(); + leftStr = TQString(); + rightStr = TQString(); + if ( b.maxl > maxl ) + maxl = b.maxl; +#endif + if ( b.minl < minl ) + minl = b.minl; +} + +void TQRegExpEngine::Box::plus( int atom ) +{ +#ifndef QT_NO_REGEXP_CAPTURE + eng->addPlusTransitions( rs, ls, atom ); +#else + Q_UNUSED( atom ); + eng->addCatTransitions( rs, ls ); +#endif + addAnchorsToEngine( *this ); +#ifndef QT_NO_REGEXP_OPTIM + maxl = InftyLen; +#endif +} + +void TQRegExpEngine::Box::opt() +{ +#ifndef QT_NO_REGEXP_OPTIM + earlyStart = 0; + lateStart = 0; + str = TQString(); + leftStr = TQString(); + rightStr = TQString(); +#endif + skipanchors = 0; + minl = 0; +} + +void TQRegExpEngine::Box::catAnchor( int a ) +{ + if ( a != 0 ) { + for ( int i = 0; i < (int) rs.size(); i++ ) { + a = eng->anchorConcatenation( at(ranchors, rs[i]), a ); + ranchors.insert( rs[i], a ); + } + if ( minl == 0 ) + skipanchors = eng->anchorConcatenation( skipanchors, a ); + } +} + +#ifndef QT_NO_REGEXP_OPTIM +void TQRegExpEngine::Box::setupHeuristics() +{ + eng->goodEarlyStart = earlyStart; + eng->goodLateStart = lateStart; + eng->goodStr = eng->cs ? str : str.lower(); + + eng->minl = minl; + if ( eng->cs ) { + /* + A regular expression such as 112|1 has occ1['2'] = 2 and minl = + 1 at this point. An entry of occ1 has to be at most minl or + infinity for the rest of the algorithm to go well. + + We waited until here before normalizing these cases (instead of + doing it in Box::orx()) because sometimes things improve by + themselves. Consider for example (112|1)34. + */ + for ( int i = 0; i < NumBadChars; i++ ) { + if ( occ1[i] != NoOccurrence && occ1[i] >= minl ) + occ1[i] = minl; + } + eng->occ1 = occ1; + } else { + eng->occ1.fill( 0, NumBadChars ); + } + + eng->heuristicallyChooseHeuristic(); +} +#endif + +#if defined(QT_DEBUG) +void TQRegExpEngine::Box::dump() const +{ + int i; + qDebug( "Box of at least %d character%s", minl, minl == 1 ? "" : "s" ); + qDebug( " Left states:" ); + for ( i = 0; i < (int) ls.size(); i++ ) { + if ( at(lanchors, ls[i]) == 0 ) + qDebug( " %d", ls[i] ); + else + qDebug( " %d [anchors 0x%.8x]", ls[i], lanchors[ls[i]] ); + } + qDebug( " Right states:" ); + for ( i = 0; i < (int) rs.size(); i++ ) { + if ( at(ranchors, rs[i]) == 0 ) + qDebug( " %d", rs[i] ); + else + qDebug( " %d [anchors 0x%.8x]", rs[i], ranchors[rs[i]] ); + } + qDebug( " Skip anchors: 0x%.8x", skipanchors ); +} +#endif + +void TQRegExpEngine::Box::addAnchorsToEngine( const Box& to ) const +{ + for ( int i = 0; i < (int) to.ls.size(); i++ ) { + for ( int j = 0; j < (int) rs.size(); j++ ) { + int a = eng->anchorConcatenation( at(ranchors, rs[j]), + at(to.lanchors, to.ls[i]) ); + eng->addAnchors( rs[j], to.ls[i], a ); + } + } +} + +int TQRegExpEngine::getChar() +{ + return ( yyPos == yyLen ) ? EOS : yyIn[yyPos++].unicode(); +} + +int TQRegExpEngine::getEscape() +{ +#ifndef QT_NO_REGEXP_ESCAPE + const char tab[] = "afnrtv"; // no b, as \b means word boundary + const char backTab[] = "\a\f\n\r\t\v"; + ushort low; + int i; +#endif + ushort val; + int prevCh = yyCh; + + if ( prevCh == EOS ) { + error( RXERR_END ); + return Tok_Char | '\\'; + } + yyCh = getChar(); +#ifndef QT_NO_REGEXP_ESCAPE + if ( (prevCh & ~0xff) == 0 ) { + const char *p = strchr( tab, prevCh ); + if ( p != 0 ) + return Tok_Char | backTab[p - tab]; + } +#endif + + switch ( prevCh ) { +#ifndef QT_NO_REGEXP_ESCAPE + case '0': + val = 0; + for ( i = 0; i < 3; i++ ) { + if ( yyCh >= '0' && yyCh <= '7' ) + val = ( val << 3 ) | ( yyCh - '0' ); + else + break; + yyCh = getChar(); + } + if ( (val & ~0377) != 0 ) + error( RXERR_OCTAL ); + return Tok_Char | val; +#endif +#ifndef QT_NO_REGEXP_ESCAPE + case 'B': + return Tok_NonWord; +#endif +#ifndef QT_NO_REGEXP_CCLASS + case 'D': + // see TQChar::isDigit() + yyCharClass->addCategories( 0x7fffffef ); + return Tok_CharClass; + case 'S': + // see TQChar::isSpace() + yyCharClass->addCategories( 0x7ffff87f ); + yyCharClass->addRange( 0x0000, 0x0008 ); + yyCharClass->addRange( 0x000e, 0x001f ); + yyCharClass->addRange( 0x007f, 0x009f ); + return Tok_CharClass; + case 'W': + // see TQChar::isLetterOrNumber() + yyCharClass->addCategories( 0x7fe07f8f ); + yyCharClass->addRange( 0x203f, 0x2040 ); + yyCharClass->addSingleton( 0x2040 ); + yyCharClass->addSingleton( 0x30fb ); + yyCharClass->addRange( 0xfe33, 0xfe34 ); + yyCharClass->addRange( 0xfe4d, 0xfe4f ); + yyCharClass->addSingleton( 0xff3f ); + yyCharClass->addSingleton( 0xff65 ); + return Tok_CharClass; +#endif +#ifndef QT_NO_REGEXP_ESCAPE + case 'b': + return Tok_Word; +#endif +#ifndef QT_NO_REGEXP_CCLASS + case 'd': + // see TQChar::isDigit() + yyCharClass->addCategories( 0x00000010 ); + return Tok_CharClass; + case 's': + // see TQChar::isSpace() + yyCharClass->addCategories( 0x00000380 ); + yyCharClass->addRange( 0x0009, 0x000d ); + return Tok_CharClass; + case 'w': + // see TQChar::isLetterOrNumber() + yyCharClass->addCategories( 0x000f8070 ); + yyCharClass->addSingleton( 0x005f ); // '_' + return Tok_CharClass; +#endif +#ifndef QT_NO_REGEXP_ESCAPE + case 'x': + val = 0; + for ( i = 0; i < 4; i++ ) { + low = TQChar( yyCh ).lower(); + if ( low >= '0' && low <= '9' ) + val = ( val << 4 ) | ( low - '0' ); + else if ( low >= 'a' && low <= 'f' ) + val = ( val << 4 ) | ( low - 'a' + 10 ); + else + break; + yyCh = getChar(); + } + return Tok_Char | val; +#endif + default: + if ( prevCh >= '1' && prevCh <= '9' ) { +#ifndef QT_NO_REGEXP_BACKREF + val = prevCh - '0'; + while ( yyCh >= '0' && yyCh <= '9' ) { + val = ( val * 10 ) + ( yyCh - '0' ); + yyCh = getChar(); + } + return Tok_BackRef | val; +#else + error( RXERR_DISABLED ); +#endif + } + return Tok_Char | prevCh; + } +} + +#ifndef QT_NO_REGEXP_INTERVAL +int TQRegExpEngine::getRep( int def ) +{ + if ( yyCh >= '0' && yyCh <= '9' ) { + int rep = 0; + do { + rep = 10 * rep + yyCh - '0'; + if ( rep >= InftyRep ) { + error( RXERR_REPETITION ); + rep = def; + } + yyCh = getChar(); + } while ( yyCh >= '0' && yyCh <= '9' ); + return rep; + } else { + return def; + } +} +#endif + +#ifndef QT_NO_REGEXP_LOOKAHEAD +void TQRegExpEngine::skipChars( int n ) +{ + if ( n > 0 ) { + yyPos += n - 1; + yyCh = getChar(); + } +} +#endif + +void TQRegExpEngine::error( const char *msg ) +{ + if ( yyError.isEmpty() ) + yyError = TQString::fromLatin1( msg ); +} + +void TQRegExpEngine::startTokenizer( const TQChar *rx, int len ) +{ + yyIn = rx; + yyPos0 = 0; + yyPos = 0; + yyLen = len; + yyCh = getChar(); + yyCharClass = new CharClass; + yyMinRep = 0; + yyMaxRep = 0; + yyError = TQString(); +} + +int TQRegExpEngine::getToken() +{ +#ifndef QT_NO_REGEXP_CCLASS + ushort pendingCh = 0; + bool charPending; + bool rangePending; + int tok; +#endif + int prevCh = yyCh; + + yyPos0 = yyPos - 1; +#ifndef QT_NO_REGEXP_CCLASS + yyCharClass->clear(); +#endif + yyMinRep = 0; + yyMaxRep = 0; + yyCh = getChar(); + + switch ( prevCh ) { + case EOS: + yyPos0 = yyPos; + return Tok_Eos; + case '$': + return Tok_Dollar; + case '(': + if ( yyCh == '?' ) { + prevCh = getChar(); + yyCh = getChar(); + switch ( prevCh ) { +#ifndef QT_NO_REGEXP_LOOKAHEAD + case '!': + return Tok_NegLookahead; + case '=': + return Tok_PosLookahead; +#endif + case ':': + return Tok_MagicLeftParen; + default: + error( RXERR_LOOKAHEAD ); + return Tok_MagicLeftParen; + } + } else { + return Tok_LeftParen; + } + case ')': + return Tok_RightParen; + case '*': + yyMinRep = 0; + yyMaxRep = InftyRep; + return Tok_Quantifier; + case '+': + yyMinRep = 1; + yyMaxRep = InftyRep; + return Tok_Quantifier; + case '.': +#ifndef QT_NO_REGEXP_CCLASS + yyCharClass->setNegative( TRUE ); +#endif + return Tok_CharClass; + case '?': + yyMinRep = 0; + yyMaxRep = 1; + return Tok_Quantifier; + case '[': +#ifndef QT_NO_REGEXP_CCLASS + if ( yyCh == '^' ) { + yyCharClass->setNegative( TRUE ); + yyCh = getChar(); + } + charPending = FALSE; + rangePending = FALSE; + do { + if ( yyCh == '-' && charPending && !rangePending ) { + rangePending = TRUE; + yyCh = getChar(); + } else { + if ( charPending && !rangePending ) { + yyCharClass->addSingleton( pendingCh ); + charPending = FALSE; + } + if ( yyCh == '\\' ) { + yyCh = getChar(); + tok = getEscape(); + if ( tok == Tok_Word ) + tok = '\b'; + } else { + tok = Tok_Char | yyCh; + yyCh = getChar(); + } + if ( tok == Tok_CharClass ) { + if ( rangePending ) { + yyCharClass->addSingleton( '-' ); + yyCharClass->addSingleton( pendingCh ); + charPending = FALSE; + rangePending = FALSE; + } + } else if ( (tok & Tok_Char) != 0 ) { + if ( rangePending ) { + yyCharClass->addRange( pendingCh, tok ^ Tok_Char ); + charPending = FALSE; + rangePending = FALSE; + } else { + pendingCh = tok ^ Tok_Char; + charPending = TRUE; + } + } else { + error( RXERR_CHARCLASS ); + } + } + } while ( yyCh != ']' && yyCh != EOS ); + if ( rangePending ) + yyCharClass->addSingleton( '-' ); + if ( charPending ) + yyCharClass->addSingleton( pendingCh ); + if ( yyCh == EOS ) + error( RXERR_END ); + else + yyCh = getChar(); + return Tok_CharClass; +#else + error( RXERR_END ); + return Tok_Char | '['; +#endif + case '\\': + return getEscape(); + case ']': + error( RXERR_LEFTDELIM ); + return Tok_Char | ']'; + case '^': + return Tok_Caret; + case '{': +#ifndef QT_NO_REGEXP_INTERVAL + yyMinRep = getRep( 0 ); + yyMaxRep = yyMinRep; + if ( yyCh == ',' ) { + yyCh = getChar(); + yyMaxRep = getRep( InftyRep ); + } + if ( yyMaxRep < yyMinRep ) + qSwap( yyMinRep, yyMaxRep ); + if ( yyCh != '}' ) + error( RXERR_REPETITION ); + yyCh = getChar(); + return Tok_Quantifier; +#else + error( RXERR_DISABLED ); + return Tok_Char | '{'; +#endif + case '|': + return Tok_Bar; + case '}': + error( RXERR_LEFTDELIM ); + return Tok_Char | '}'; + default: + return Tok_Char | prevCh; + } +} + +int TQRegExpEngine::parse( const TQChar *pattern, int len ) +{ + valid = TRUE; + startTokenizer( pattern, len ); + yyTok = getToken(); +#ifndef QT_NO_REGEXP_CAPTURE + yyMayCapture = TRUE; +#else + yyMayCapture = FALSE; +#endif + +#ifndef QT_NO_REGEXP_CAPTURE + int atom = startAtom( FALSE ); +#endif + CharClass anything; + Box box( this ); // create InitialState + box.set( anything ); + Box rightBox( this ); // create FinalState + rightBox.set( anything ); + + Box middleBox( this ); + parseExpression( &middleBox ); +#ifndef QT_NO_REGEXP_CAPTURE + finishAtom( atom ); +#endif +#ifndef QT_NO_REGEXP_OPTIM + middleBox.setupHeuristics(); +#endif + box.cat( middleBox ); + box.cat( rightBox ); + delete yyCharClass; + yyCharClass = 0; + + officialncap = ncap; +#ifndef QT_NO_REGEXP_BACKREF + if ( nbrefs > ncap ) + ncap = nbrefs; +#endif + + /* + We use one TQMemArray for all the big data used a lot in + matchHere() and friends. + */ +#ifndef QT_NO_REGEXP_OPTIM + mmSlideTabSize = TQMAX( minl + 1, 16 ); +#else + mmSlideTabSize = 0; +#endif + mmBigArray.resize( (3 + 4 * ncap) * ns + 4 * ncap + mmSlideTabSize ); + + mmInNextStack = mmBigArray.data(); + memset( mmInNextStack, -1, ns * sizeof(int) ); + mmCurStack = mmInNextStack + ns; + mmNextStack = mmInNextStack + 2 * ns; + + mmCurCapBegin = mmInNextStack + 3 * ns; + mmNextCapBegin = mmCurCapBegin + ncap * ns; + mmCurCapEnd = mmCurCapBegin + 2 * ncap * ns; + mmNextCapEnd = mmCurCapBegin + 3 * ncap * ns; + + mmTempCapBegin = mmCurCapBegin + 4 * ncap * ns; + mmTempCapEnd = mmTempCapBegin + ncap; + mmCapBegin = mmTempCapBegin + 2 * ncap; + mmCapEnd = mmTempCapBegin + 3 * ncap; + + mmSlideTab = mmTempCapBegin + 4 * ncap; + + if ( !yyError.isEmpty() ) + return -1; + +#ifndef QT_NO_REGEXP_OPTIM + State *sinit = s[InitialState]; + caretAnchored = ( sinit->anchors != 0 ); + if ( caretAnchored ) { + TQMap& anchors = *sinit->anchors; + TQMap::ConstIterator a; + for ( a = anchors.begin(); a != anchors.end(); ++a ) { + if ( +#ifndef QT_NO_REGEXP_ANCHOR_ALT + (*a & Anchor_Alternation) != 0 || +#endif + (*a & Anchor_Caret) == 0 ) { + caretAnchored = FALSE; + break; + } + } + } +#endif + return yyPos0; +} + +void TQRegExpEngine::parseAtom( Box *box ) +{ +#ifndef QT_NO_REGEXP_LOOKAHEAD + TQRegExpEngine *eng = 0; + bool neg; + int len; +#endif + + if ( (yyTok & Tok_Char) != 0 ) { + box->set( TQChar(yyTok ^ Tok_Char) ); + } else { +#ifndef QT_NO_REGEXP_OPTIM + trivial = FALSE; +#endif + switch ( yyTok ) { + case Tok_Dollar: + box->catAnchor( Anchor_Dollar ); + break; + case Tok_Caret: + box->catAnchor( Anchor_Caret ); + break; +#ifndef QT_NO_REGEXP_LOOKAHEAD + case Tok_PosLookahead: + case Tok_NegLookahead: + neg = ( yyTok == Tok_NegLookahead ); + eng = new TQRegExpEngine( cs ); + len = eng->parse( yyIn + yyPos - 1, yyLen - yyPos + 1 ); + if ( len >= 0 ) + skipChars( len ); + else + error( RXERR_LOOKAHEAD ); + box->catAnchor( addLookahead(eng, neg) ); + yyTok = getToken(); + if ( yyTok != Tok_RightParen ) + error( RXERR_LOOKAHEAD ); + break; +#endif +#ifndef QT_NO_REGEXP_ESCAPE + case Tok_Word: + box->catAnchor( Anchor_Word ); + break; + case Tok_NonWord: + box->catAnchor( Anchor_NonWord ); + break; +#endif + case Tok_LeftParen: + case Tok_MagicLeftParen: + yyTok = getToken(); + parseExpression( box ); + if ( yyTok != Tok_RightParen ) + error( RXERR_END ); + break; + case Tok_CharClass: + box->set( *yyCharClass ); + break; + case Tok_Quantifier: + error( RXERR_REPETITION ); + break; + default: +#ifndef QT_NO_REGEXP_BACKREF + if ( (yyTok & Tok_BackRef) != 0 ) + box->set( yyTok ^ Tok_BackRef ); + else +#endif + error( RXERR_DISABLED ); + } + } + yyTok = getToken(); +} + +void TQRegExpEngine::parseFactor( Box *box ) +{ +#ifndef QT_NO_REGEXP_CAPTURE + int atom = startAtom( yyMayCapture && yyTok == Tok_LeftParen ); +#else + static const int atom = 0; +#endif + +#ifndef QT_NO_REGEXP_INTERVAL +#define YYREDO() \ + yyIn = in, yyPos0 = pos0, yyPos = pos, yyLen = len, yyCh = ch, \ + *yyCharClass = charClass, yyMinRep = 0, yyMaxRep = 0, yyTok = tok + + const TQChar *in = yyIn; + int pos0 = yyPos0; + int pos = yyPos; + int len = yyLen; + int ch = yyCh; + CharClass charClass; + if ( yyTok == Tok_CharClass ) + charClass = *yyCharClass; + int tok = yyTok; + bool mayCapture = yyMayCapture; +#endif + + parseAtom( box ); +#ifndef QT_NO_REGEXP_CAPTURE + finishAtom( atom ); +#endif + + if ( yyTok == Tok_Quantifier ) { +#ifndef QT_NO_REGEXP_OPTIM + trivial = FALSE; +#endif + if ( yyMaxRep == InftyRep ) { + box->plus( atom ); +#ifndef QT_NO_REGEXP_INTERVAL + } else if ( yyMaxRep == 0 ) { + box->clear(); +#endif + } + if ( yyMinRep == 0 ) + box->opt(); + +#ifndef QT_NO_REGEXP_INTERVAL + yyMayCapture = FALSE; + int alpha = ( yyMinRep == 0 ) ? 0 : yyMinRep - 1; + int beta = ( yyMaxRep == InftyRep ) ? 0 : yyMaxRep - ( alpha + 1 ); + + Box rightBox( this ); + int i; + + for ( i = 0; i < beta; i++ ) { + YYREDO(); + Box leftBox( this ); + parseAtom( &leftBox ); + leftBox.cat( rightBox ); + leftBox.opt(); + rightBox = leftBox; + } + for ( i = 0; i < alpha; i++ ) { + YYREDO(); + Box leftBox( this ); + parseAtom( &leftBox ); + leftBox.cat( rightBox ); + rightBox = leftBox; + } + rightBox.cat( *box ); + *box = rightBox; +#endif + yyTok = getToken(); +#ifndef QT_NO_REGEXP_INTERVAL + yyMayCapture = mayCapture; +#endif + } +#undef YYREDO +} + +void TQRegExpEngine::parseTerm( Box *box ) +{ +#ifndef QT_NO_REGEXP_OPTIM + if ( yyTok != Tok_Eos && yyTok != Tok_RightParen && yyTok != Tok_Bar ) + parseFactor( box ); +#endif + while ( yyTok != Tok_Eos && yyTok != Tok_RightParen && yyTok != Tok_Bar ) { + Box rightBox( this ); + parseFactor( &rightBox ); + box->cat( rightBox ); + } +} + +void TQRegExpEngine::parseExpression( Box *box ) +{ + parseTerm( box ); + while ( yyTok == Tok_Bar ) { +#ifndef QT_NO_REGEXP_OPTIM + trivial = FALSE; +#endif + Box rightBox( this ); + yyTok = getToken(); + parseTerm( &rightBox ); + box->orx( rightBox ); + } +} + +/* + The struct TQRegExpPrivate contains the private data of a regular + expression other than the automaton. It makes it possible for many + TQRegExp objects to use the same TQRegExpEngine object with different + TQRegExpPrivate objects. +*/ +struct TQRegExpPrivate +{ + TQString pattern; // regular-expression or wildcard pattern + TQString rxpattern; // regular-expression pattern +#ifndef QT_NO_REGEXP_WILDCARD + bool wc : 1; // wildcard mode? +#endif + bool min : 1; // minimal matching? (instead of maximal) + bool cs : 1; // case sensitive? +#ifndef QT_NO_REGEXP_CAPTURE + TQString t; // last string passed to TQRegExp::search() or searchRev() + TQStringList capturedCache; // what TQRegExp::capturedTexts() returned last +#endif + TQMemArray captured; // what TQRegExpEngine::search() returned last + + TQRegExpPrivate() { captured.fill( -1, 2 ); } +}; + +#ifndef QT_NO_REGEXP_OPTIM +static TQSingleCleanupHandler > cleanup_cache; +# ifndef QT_THREAD_SUPPORT +static TQCache *engineCache = 0; +# endif // QT_THREAD_SUPPORT +#endif // QT_NO_REGEXP_OPTIM + +static void regexpEngine( TQRegExpEngine *&eng, const TQString &pattern, + bool caseSensitive, bool deref ) +{ +# ifdef QT_THREAD_SUPPORT + static TQThreadStorage *> engineCaches; + TQCache *engineCache = 0; + TQThreadInstance *currentThread = TQThreadInstance::current(); + if (currentThread) + engineCache = engineCaches.localData(); +#endif // QT_THREAD_SUPPORT + + if ( !deref ) { +#ifndef QT_NO_REGEXP_OPTIM +# ifdef QT_THREAD_SUPPORT + if ( currentThread ) +# endif + { + if ( engineCache != 0 ) { + eng = engineCache->take( pattern ); + if ( eng == 0 || eng->caseSensitive() != caseSensitive ) { + delete eng; + } else { + eng->ref(); + return; + } + } + } +#endif // QT_NO_REGEXP_OPTIM + eng = new TQRegExpEngine( pattern, caseSensitive ); + return; + } + + if ( eng->deref() ) { +#ifndef QT_NO_REGEXP_OPTIM +# ifdef QT_THREAD_SUPPORT + if ( currentThread ) +# endif + { + if ( engineCache == 0 ) { + engineCache = new TQCache; + engineCache->setAutoDelete( TRUE ); +# ifdef QT_THREAD_SUPPORT + engineCaches.setLocalData(engineCache); +# else + cleanup_cache.set( &engineCache ); +# endif // !QT_THREAD_SUPPORT + } + if ( !pattern.isNull() && + engineCache->insert(pattern, eng, 4 + pattern.length() / 4) ) + return; + } +#else + Q_UNUSED( pattern ); +#endif // QT_NO_REGEXP_OPTIM + delete eng; + eng = 0; + } +} + +/*! + \enum TQRegExp::CaretMode + + The CaretMode enum defines the different meanings of the caret + (^) in a regular expression. The possible values are: + + \value CaretAtZero + The caret corresponds to index 0 in the searched string. + + \value CaretAtOffset + The caret corresponds to the start offset of the search. + + \value CaretWontMatch + The caret never matches. +*/ + +/*! + Constructs an empty regexp. + + \sa isValid() errorString() +*/ +TQRegExp::TQRegExp() + : eng( 0 ) +{ + priv = new TQRegExpPrivate; +#ifndef QT_NO_REGEXP_WILDCARD + priv->wc = FALSE; +#endif + priv->min = FALSE; + priv->cs = TRUE; +} + +/*! + Constructs a regular expression object for the given \a pattern + string. The pattern must be given using wildcard notation if \a + wildcard is TRUE (default is FALSE). The pattern is case + sensitive, unless \a caseSensitive is FALSE. Matching is greedy + (maximal), but can be changed by calling setMinimal(). + + \sa setPattern() setCaseSensitive() setWildcard() setMinimal() +*/ +TQRegExp::TQRegExp( const TQString& pattern, bool caseSensitive, bool wildcard ) + : eng( 0 ) +{ + priv = new TQRegExpPrivate; + priv->pattern = pattern; +#ifndef QT_NO_REGEXP_WILDCARD + priv->wc = wildcard; +#endif + priv->min = FALSE; + priv->cs = caseSensitive; +} + +/*! + Constructs a regular expression as a copy of \a rx. + + \sa operator=() +*/ +TQRegExp::TQRegExp( const TQRegExp& rx ) + : eng( 0 ) +{ + priv = new TQRegExpPrivate; + operator=( rx ); +} + +/*! + Destroys the regular expression and cleans up its internal data. +*/ +TQRegExp::~TQRegExp() +{ + invalidateEngine(); + delete priv; +} + +/*! + Copies the regular expression \a rx and returns a reference to the + copy. The case sensitivity, wildcard and minimal matching options + are also copied. +*/ +TQRegExp& TQRegExp::operator=( const TQRegExp& rx ) +{ + TQRegExpEngine *otherEng = rx.eng; + if ( otherEng != 0 ) + otherEng->ref(); + invalidateEngine(); + eng = otherEng; + priv->pattern = rx.priv->pattern; + priv->rxpattern = rx.priv->rxpattern; +#ifndef QT_NO_REGEXP_WILDCARD + priv->wc = rx.priv->wc; +#endif + priv->min = rx.priv->min; + priv->cs = rx.priv->cs; +#ifndef QT_NO_REGEXP_CAPTURE + priv->t = rx.priv->t; + priv->capturedCache = rx.priv->capturedCache; +#endif + priv->captured = rx.priv->captured; + return *this; +} + +/*! + Returns TRUE if this regular expression is equal to \a rx; + otherwise returns FALSE. + + Two TQRegExp objects are equal if they have the same pattern + strings and the same settings for case sensitivity, wildcard and + minimal matching. +*/ +bool TQRegExp::operator==( const TQRegExp& rx ) const +{ + return priv->pattern == rx.priv->pattern && +#ifndef QT_NO_REGEXP_WILDCARD + priv->wc == rx.priv->wc && +#endif + priv->min == rx.priv->min && + priv->cs == rx.priv->cs; +} + +/*! + \fn bool TQRegExp::operator!=( const TQRegExp& rx ) const + + Returns TRUE if this regular expression is not equal to \a rx; + otherwise returns FALSE. + + \sa operator==() +*/ + +/*! + Returns TRUE if the pattern string is empty; otherwise returns + FALSE. + + If you call exactMatch() with an empty pattern on an empty string + it will return TRUE; otherwise it returns FALSE since it operates + over the whole string. If you call search() with an empty pattern + on \e any string it will return the start offset (0 by default) + because the empty pattern matches the 'emptiness' at the start of + the string. In this case the length of the match returned by + matchedLength() will be 0. + + See TQString::isEmpty(). +*/ + +bool TQRegExp::isEmpty() const +{ + return priv->pattern.isEmpty(); +} + +/*! + Returns TRUE if the regular expression is valid; otherwise returns + FALSE. An invalid regular expression never matches. + + The pattern [a-z is an example of an invalid pattern, since + it lacks a closing square bracket. + + Note that the validity of a regexp may also depend on the setting + of the wildcard flag, for example *.html is a valid + wildcard regexp but an invalid full regexp. + + \sa errorString() +*/ +bool TQRegExp::isValid() const +{ + if ( priv->pattern.isEmpty() ) { + return TRUE; + } else { + prepareEngine(); + return eng->isValid(); + } +} + +/*! + Returns the pattern string of the regular expression. The pattern + has either regular expression syntax or wildcard syntax, depending + on wildcard(). + + \sa setPattern() +*/ +TQString TQRegExp::pattern() const +{ + return priv->pattern; +} + +/*! + Sets the pattern string to \a pattern. The case sensitivity, + wildcard and minimal matching options are not changed. + + \sa pattern() +*/ +void TQRegExp::setPattern( const TQString& pattern ) +{ + if ( priv->pattern != pattern ) { + priv->pattern = pattern; + invalidateEngine(); + } +} + +/*! + Returns TRUE if case sensitivity is enabled; otherwise returns + FALSE. The default is TRUE. + + \sa setCaseSensitive() +*/ +bool TQRegExp::caseSensitive() const +{ + return priv->cs; +} + +/*! + Sets case sensitive matching to \a sensitive. + + If \a sensitive is TRUE, \\.txt$ matches \c{readme.txt} but + not \c{README.TXT}. + + \sa caseSensitive() +*/ +void TQRegExp::setCaseSensitive( bool sensitive ) +{ + if ( sensitive != priv->cs ) { + priv->cs = sensitive; + invalidateEngine(); + } +} + +#ifndef QT_NO_REGEXP_WILDCARD +/*! + Returns TRUE if wildcard mode is enabled; otherwise returns FALSE. + The default is FALSE. + + \sa setWildcard() +*/ +bool TQRegExp::wildcard() const +{ + return priv->wc; +} + +/*! + Sets the wildcard mode for the regular expression. The default is + FALSE. + + Setting \a wildcard to TRUE enables simple shell-like wildcard + matching. (See \link #wildcard-matching wildcard matching + (globbing) \endlink.) + + For example, r*.txt matches the string \c{readme.txt} in + wildcard mode, but does not match \c{readme}. + + \sa wildcard() +*/ +void TQRegExp::setWildcard( bool wildcard ) +{ + if ( wildcard != priv->wc ) { + priv->wc = wildcard; + invalidateEngine(); + } +} +#endif + +/*! + Returns TRUE if minimal (non-greedy) matching is enabled; + otherwise returns FALSE. + + \sa setMinimal() +*/ +bool TQRegExp::minimal() const +{ + return priv->min; +} + +/*! + Enables or disables minimal matching. If \a minimal is FALSE, + matching is greedy (maximal) which is the default. + + For example, suppose we have the input string "We must be + \bold\, very \bold\!" and the pattern + \.*\. With the default greedy (maximal) matching, + the match is "We must be \bold\, very + \bold\!". But with minimal (non-greedy) matching the + first match is: "We must be \bold\, very + \bold\!" and the second match is "We must be \bold\, + very \bold\!". In practice we might use the pattern + \[^\<]+\ instead, although this will still fail for + nested tags. + + \sa minimal() +*/ +void TQRegExp::setMinimal( bool minimal ) +{ + priv->min = minimal; +} + +/*! + Returns TRUE if \a str is matched exactly by this regular + expression; otherwise returns FALSE. You can determine how much of + the string was matched by calling matchedLength(). + + For a given regexp string, R, exactMatch("R") is the equivalent of + search("^R$") since exactMatch() effectively encloses the regexp + in the start of string and end of string anchors, except that it + sets matchedLength() differently. + + For example, if the regular expression is blue, then + exactMatch() returns TRUE only for input \c blue. For inputs \c + bluebell, \c blutak and \c lightblue, exactMatch() returns FALSE + and matchedLength() will return 4, 3 and 0 respectively. + + Although const, this function sets matchedLength(), + capturedTexts() and pos(). + + \sa search() searchRev() TQRegExpValidator +*/ +bool TQRegExp::exactMatch( const TQString& str ) const +{ + prepareEngineForMatch( str ); + eng->match( str, 0, priv->min, TRUE, 0, priv->captured ); + if ( priv->captured[1] == (int) str.length() ) { + return TRUE; + } else { + priv->captured[0] = 0; + priv->captured[1] = eng->partialMatchLength(); + return FALSE; + } +} + +#ifndef QT_NO_COMPAT +/*! \obsolete + + Attempts to match in \a str, starting from position \a index. + Returns the position of the match, or -1 if there was no match. + + The length of the match is stored in \a *len, unless \a len is a + null pointer. + + If \a indexIsStart is TRUE (the default), the position \a index in + the string will match the start of string anchor, ^, in the + regexp, if present. Otherwise, position 0 in \a str will match. + + Use search() and matchedLength() instead of this function. + + \sa TQString::mid() TQConstString +*/ +int TQRegExp::match( const TQString& str, int index, int *len, + bool indexIsStart ) const +{ + int pos = search( str, index, indexIsStart ? CaretAtOffset : CaretAtZero ); + if ( len != 0 ) + *len = matchedLength(); + return pos; +} +#endif // QT_NO_COMPAT + +int TQRegExp::search( const TQString& str, int offset ) const +{ + return search( str, offset, CaretAtZero ); +} + +/*! + Attempts to find a match in \a str from position \a offset (0 by + default). If \a offset is -1, the search starts at the last + character; if -2, at the next to last character; etc. + + Returns the position of the first match, or -1 if there was no + match. + + The \a caretMode parameter can be used to instruct whether ^ + should match at index 0 or at \a offset. + + You might prefer to use TQString::find(), TQString::contains() or + even TQStringList::grep(). To replace matches use + TQString::replace(). + + Example: + \code + TQString str = "offsets: 1.23 .50 71.00 6.00"; + TQRegExp rx( "\\d*\\.\\d+" ); // primitive floating point matching + int count = 0; + int pos = 0; + while ( (pos = rx.search(str, pos)) != -1 ) { + count++; + pos += rx.matchedLength(); + } + // pos will be 9, 14, 18 and finally 24; count will end up as 4 + \endcode + + Although const, this function sets matchedLength(), + capturedTexts() and pos(). + + \sa searchRev() exactMatch() +*/ + +int TQRegExp::search( const TQString& str, int offset, CaretMode caretMode ) const +{ + prepareEngineForMatch( str ); + if ( offset < 0 ) + offset += str.length(); + eng->match( str, offset, priv->min, FALSE, caretIndex(offset, caretMode), + priv->captured ); + return priv->captured[0]; +} + + +int TQRegExp::searchRev( const TQString& str, int offset ) const +{ + return searchRev( str, offset, CaretAtZero ); +} + +/*! + Attempts to find a match backwards in \a str from position \a + offset. If \a offset is -1 (the default), the search starts at the + last character; if -2, at the next to last character; etc. + + Returns the position of the first match, or -1 if there was no + match. + + The \a caretMode parameter can be used to instruct whether ^ + should match at index 0 or at \a offset. + + Although const, this function sets matchedLength(), + capturedTexts() and pos(). + + \warning Searching backwards is much slower than searching + forwards. + + \sa search() exactMatch() +*/ + +int TQRegExp::searchRev( const TQString& str, int offset, + CaretMode caretMode ) const +{ + prepareEngineForMatch( str ); + if ( offset < 0 ) + offset += str.length(); + if ( offset < 0 || offset > (int) str.length() ) { + priv->captured.detach(); + priv->captured.fill( -1 ); + return -1; + } + + while ( offset >= 0 ) { + eng->match( str, offset, priv->min, TRUE, caretIndex(offset, caretMode), + priv->captured ); + if ( priv->captured[0] == offset ) + return offset; + offset--; + } + return -1; +} + +/*! + Returns the length of the last matched string, or -1 if there was + no match. + + \sa exactMatch() search() searchRev() +*/ +int TQRegExp::matchedLength() const +{ + return priv->captured[1]; +} + +#ifndef QT_NO_REGEXP_CAPTURE +/*! + Returns the number of captures contained in the regular expression. + */ +int TQRegExp::numCaptures() const +{ + prepareEngine(); + return eng->numCaptures(); +} + +/*! + Returns a list of the captured text strings. + + The first string in the list is the entire matched string. Each + subsequent list element contains a string that matched a + (capturing) subexpression of the regexp. + + For example: + \code + TQRegExp rx( "(\\d+)(\\s*)(cm|inch(es)?)" ); + int pos = rx.search( "Length: 36 inches" ); + TQStringList list = rx.capturedTexts(); + // list is now ( "36 inches", "36", " ", "inches", "es" ) + \endcode + + The above example also captures elements that may be present but + which we have no interest in. This problem can be solved by using + non-capturing parentheses: + + \code + TQRegExp rx( "(\\d+)(?:\\s*)(cm|inch(?:es)?)" ); + int pos = rx.search( "Length: 36 inches" ); + TQStringList list = rx.capturedTexts(); + // list is now ( "36 inches", "36", "inches" ) + \endcode + + Note that if you want to iterate over the list, you should iterate + over a copy, e.g. + \code + TQStringList list = rx.capturedTexts(); + TQStringList::Iterator it = list.begin(); + while( it != list.end() ) { + myProcessing( *it ); + ++it; + } + \endcode + + Some regexps can match an indeterminate number of times. For + example if the input string is "Offsets: 12 14 99 231 7" and the + regexp, \c{rx}, is (\\d+)+, we would hope to get a list of + all the numbers matched. However, after calling + \c{rx.search(str)}, capturedTexts() will return the list ( "12", + "12" ), i.e. the entire match was "12" and the first subexpression + matched was "12". The correct approach is to use cap() in a \link + #cap_in_a_loop loop \endlink. + + The order of elements in the string list is as follows. The first + element is the entire matching string. Each subsequent element + corresponds to the next capturing open left parentheses. Thus + capturedTexts()[1] is the text of the first capturing parentheses, + capturedTexts()[2] is the text of the second and so on + (corresponding to $1, $2, etc., in some other regexp languages). + + \sa cap() pos() exactMatch() search() searchRev() +*/ +TQStringList TQRegExp::capturedTexts() +{ + if ( priv->capturedCache.isEmpty() ) { + for ( int i = 0; i < (int) priv->captured.size(); i += 2 ) { + TQString m; + if ( priv->captured[i + 1] == 0 ) + m = TQString::fromLatin1( "" ); + else if ( priv->captured[i] >= 0 ) + m = priv->t.mid( priv->captured[i], + priv->captured[i + 1] ); + priv->capturedCache.append( m ); + } + priv->t = TQString::null; + } + return priv->capturedCache; +} + +/*! + Returns the text captured by the \a nth subexpression. The entire + match has index 0 and the parenthesized subexpressions have + indices starting from 1 (excluding non-capturing parentheses). + + \code + TQRegExp rxlen( "(\\d+)(?:\\s*)(cm|inch)" ); + int pos = rxlen.search( "Length: 189cm" ); + if ( pos > -1 ) { + TQString value = rxlen.cap( 1 ); // "189" + TQString unit = rxlen.cap( 2 ); // "cm" + // ... + } + \endcode + + The order of elements matched by cap() is as follows. The first + element, cap(0), is the entire matching string. Each subsequent + element corresponds to the next capturing open left parentheses. + Thus cap(1) is the text of the first capturing parentheses, cap(2) + is the text of the second, and so on. + + \target cap_in_a_loop + Some patterns may lead to a number of matches which cannot be + determined in advance, for example: + + \code + TQRegExp rx( "(\\d+)" ); + str = "Offsets: 12 14 99 231 7"; + TQStringList list; + pos = 0; + while ( pos >= 0 ) { + pos = rx.search( str, pos ); + if ( pos > -1 ) { + list += rx.cap( 1 ); + pos += rx.matchedLength(); + } + } + // list contains "12", "14", "99", "231", "7" + \endcode + + \sa capturedTexts() pos() exactMatch() search() searchRev() +*/ +TQString TQRegExp::cap( int nth ) +{ + if ( nth < 0 || nth >= (int) priv->captured.size() / 2 ) { + return TQString::null; + } else { + return capturedTexts()[nth]; + } +} + +/*! + Returns the position of the \a nth captured text in the searched + string. If \a nth is 0 (the default), pos() returns the position + of the whole match. + + Example: + \code + TQRegExp rx( "/([a-z]+)/([a-z]+)" ); + rx.search( "Output /dev/null" ); // returns 7 (position of /dev/null) + rx.pos( 0 ); // returns 7 (position of /dev/null) + rx.pos( 1 ); // returns 8 (position of dev) + rx.pos( 2 ); // returns 12 (position of null) + \endcode + + For zero-length matches, pos() always returns -1. (For example, if + cap(4) would return an empty string, pos(4) returns -1.) This is + due to an implementation tradeoff. + + \sa capturedTexts() exactMatch() search() searchRev() +*/ +int TQRegExp::pos( int nth ) +{ + if ( nth < 0 || nth >= (int) priv->captured.size() / 2 ) + return -1; + else + return priv->captured[2 * nth]; +} + +/*! + Returns a text string that explains why a regexp pattern is + invalid the case being; otherwise returns "no error occurred". + + \sa isValid() +*/ +TQString TQRegExp::errorString() +{ + if ( isValid() ) { + return TQString( RXERR_OK ); + } else { + return eng->errorString(); + } +} +#endif + +/*! + Returns the string \a str with every regexp special character + escaped with a backslash. The special characters are $, (, ), *, +, + ., ?, [, \, ], ^, {, | and }. + + Example: + \code + s1 = TQRegExp::escape( "bingo" ); // s1 == "bingo" + s2 = TQRegExp::escape( "f(x)" ); // s2 == "f\\(x\\)" + \endcode + + This function is useful to construct regexp patterns dynamically: + + \code + TQRegExp rx( "(" + TQRegExp::escape(name) + + "|" + TQRegExp::escape(alias) + ")" ); + \endcode +*/ +TQString TQRegExp::escape( const TQString& str ) +{ + static const char meta[] = "$()*+.?[\\]^{|}"; + TQString quoted = str; + int i = 0; + + while ( i < (int) quoted.length() ) { + if ( strchr(meta, quoted[i].latin1()) != 0 ) + quoted.insert( i++, "\\" ); + i++; + } + return quoted; +} + +void TQRegExp::prepareEngine() const +{ + if ( eng == 0 ) { +#ifndef QT_NO_REGEXP_WILDCARD + if ( priv->wc ) + priv->rxpattern = wc2rx( priv->pattern ); + else +#endif + priv->rxpattern = priv->pattern.isNull() ? TQString::fromLatin1( "" ) + : priv->pattern; + TQRegExp *that = (TQRegExp *) this; + // that->eng = newEngine( priv->rxpattern, priv->cs ); + regexpEngine( that->eng, priv->rxpattern, priv->cs, FALSE ); + priv->captured.detach(); + priv->captured.fill( -1, 2 + 2 * eng->numCaptures() ); + } +} + +void TQRegExp::prepareEngineForMatch( const TQString& str ) const +{ + prepareEngine(); +#ifndef QT_NO_REGEXP_CAPTURE + priv->t = str; + priv->capturedCache.clear(); +#else + Q_UNUSED( str ); +#endif +} + +void TQRegExp::invalidateEngine() +{ + if ( eng != 0 ) { + regexpEngine( eng, priv->rxpattern, priv->cs, TRUE ); + priv->rxpattern = TQString(); + eng = 0; + } +} + +int TQRegExp::caretIndex( int offset, CaretMode caretMode ) +{ + if ( caretMode == CaretAtZero ) { + return 0; + } else if ( caretMode == CaretAtOffset ) { + return offset; + } else { // CaretWontMatch + return -1; + } +} + +#endif // QT_NO_REGEXP diff --git a/src/tools/qregexp.h b/src/tools/qregexp.h new file mode 100644 index 000000000..d233f4d1d --- /dev/null +++ b/src/tools/qregexp.h @@ -0,0 +1,120 @@ +/**************************************************************************** +** +** Definition of TQRegExp class +** +** Created : 950126 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQREGEXP_H +#define TQREGEXP_H + +#ifndef QT_H +#include "qstringlist.h" +#endif // QT_H + +#ifndef QT_NO_REGEXP +class TQRegExpEngine; +struct TQRegExpPrivate; + +class Q_EXPORT TQRegExp +{ +public: + enum CaretMode { CaretAtZero, CaretAtOffset, CaretWontMatch }; + + TQRegExp(); + TQRegExp( const TQString& pattern, bool caseSensitive = TRUE, + bool wildcard = FALSE ); + TQRegExp( const TQRegExp& rx ); + ~TQRegExp(); + TQRegExp& operator=( const TQRegExp& rx ); + + bool operator==( const TQRegExp& rx ) const; + bool operator!=( const TQRegExp& rx ) const { return !operator==( rx ); } + + bool isEmpty() const; + bool isValid() const; + TQString pattern() const; + void setPattern( const TQString& pattern ); + bool caseSensitive() const; + void setCaseSensitive( bool sensitive ); +#ifndef QT_NO_REGEXP_WILDCARD + bool wildcard() const; + void setWildcard( bool wildcard ); +#endif + bool minimal() const; + void setMinimal( bool minimal ); + + bool exactMatch( const TQString& str ) const; +#ifndef QT_NO_COMPAT + int match( const TQString& str, int index = 0, int *len = 0, + bool indexIsStart = TRUE ) const; +#endif + +#if defined(Q_QDOC) + int search( const TQString& str, int offset = 0, + CaretMode caretMode = CaretAtZero ) const; + int searchRev( const TQString& str, int offset = -1, + CaretMode caretMode = CaretAtZero ) const; +#else + // ### TQt 4.0: reduce these four to two functions + int search( const TQString& str, int offset = 0 ) const; + int search( const TQString& str, int offset, CaretMode caretMode ) const; + int searchRev( const TQString& str, int offset = -1 ) const; + int searchRev( const TQString& str, int offset, CaretMode caretMode ) const; +#endif + int matchedLength() const; +#ifndef QT_NO_REGEXP_CAPTURE + int numCaptures() const; + TQStringList capturedTexts(); + TQString cap( int nth = 0 ); + int pos( int nth = 0 ); + TQString errorString(); +#endif + + static TQString escape( const TQString& str ); + +private: + void prepareEngine() const; + void prepareEngineForMatch( const TQString& str ) const; + void invalidateEngine(); + + static int caretIndex( int offset, CaretMode caretMode ); + + TQRegExpEngine *eng; + TQRegExpPrivate *priv; +}; +#endif // QT_NO_REGEXP +#endif // TQREGEXP_H diff --git a/src/tools/qsemaphore.cpp b/src/tools/qsemaphore.cpp new file mode 100644 index 000000000..608563ee5 --- /dev/null +++ b/src/tools/qsemaphore.cpp @@ -0,0 +1,255 @@ +/**************************************************************************** +** +** TQSemaphore class for Unix +** +** Created : 20010725 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#if defined(QT_THREAD_SUPPORT) + +#include "qsemaphore.h" +#include "qmutex.h" +#include "qwaitcondition.h" + + +/*! + \class TQSemaphore qsemaphore.h + \threadsafe + \brief The TQSemaphore class provides a robust integer semaphore. + + \ingroup thread + \ingroup environment + + A TQSemaphore can be used to serialize thread execution, in a + similar way to a TQMutex. A semaphore differs from a mutex, in + that a semaphore can be accessed by more than one thread at a + time. + + For example, suppose we have an application that stores data in a + large tree structure. The application creates 10 threads + (commonly called a thread pool) to perform searches on the tree. + When the application searches the tree for some piece of data, it + uses one thread per base node to do the searching. A semaphore + could be used to make sure that two threads don't try to search + the same branch of the tree at the same time. + + A non-computing example of a semaphore would be dining at a + restuarant. A semaphore is initialized to have a maximum count + equal to the number of chairs in the restuarant. As people + arrive, they want a seat. As seats are filled, the semaphore is + accessed, once per person. As people leave, the access is + released, allowing more people to enter. If a party of 10 people + want to be seated, but there are only 9 seats, those 10 people + will wait, but a party of 4 people would be seated (taking the + available seats to 5, making the party of 10 people wait longer). + + When a semaphore is created it is given a number which is the + maximum number of concurrent accesses it will permit. Accesses to + the sempahore are gained using operator++() or operator+=(), and + released with operator--() or operator-=(). The number of + accesses allowed is retrieved with available(), and the total + number with total(). Note that the incrementing functions will + block if there aren't enough available accesses. Use tryAccess() + if you want to actquire accesses without blocking. +*/ + + +class TQSemaphorePrivate { +public: + TQSemaphorePrivate(int); + + TQMutex mutex; + TQWaitCondition cond; + + int value, max; +}; + + +TQSemaphorePrivate::TQSemaphorePrivate(int m) + : mutex(FALSE), value(0), max(m) +{ +} + + +/*! + Creates a new semaphore. The semaphore can be concurrently + accessed at most \a maxcount times. +*/ +TQSemaphore::TQSemaphore(int maxcount) +{ + d = new TQSemaphorePrivate(maxcount); +} + + +/*! + Destroys the semaphore. + + \warning If you destroy a semaphore that has accesses in use the + resultant behavior is undefined. +*/ +TQSemaphore::~TQSemaphore() +{ + delete d; +} + + +/*! + Postfix ++ operator. + + Try to get access to the semaphore. If \l available() == 0, this + call will block until it can get access, i.e. until available() \> + 0. +*/ +int TQSemaphore::operator++(int) +{ + TQMutexLocker locker(&d->mutex); + while (d->value >= d->max) + d->cond.wait(locker.mutex()); + + ++d->value; + if (d->value > d->max) + d->value = d->max; + + return d->value; +} + + +/*! + Postfix -- operator. + + Release access of the semaphore. This wakes all threads waiting + for access to the semaphore. +*/ +int TQSemaphore::operator--(int) +{ + TQMutexLocker locker(&d->mutex); + + --d->value; + if (d->value < 0) + d->value = 0; + + d->cond.wakeAll(); + + return d->value; +} + + +/*! + Try to get access to the semaphore. If \l available() \< \a n, this + call will block until it can get all the accesses it wants, i.e. + until available() \>= \a n. +*/ +int TQSemaphore::operator+=(int n) +{ + TQMutexLocker locker(&d->mutex); + + if ( n < 0 || n > d->max ) { +#ifdef QT_CHECK_RANGE + qWarning( "TQSemaphore::operator+=: paramter %d out of range", n ); +#endif // QT_CHECK_RANGE + n = n < 0 ? 0 : d->max; + } + + while (d->value + n > d->max) + d->cond.wait(locker.mutex()); + + d->value += n; + + return d->value; +} + + +/*! + Release \a n accesses to the semaphore. +*/ +int TQSemaphore::operator-=(int n) +{ + TQMutexLocker locker(&d->mutex); + + if ( n < 0 || n > d->value ) { +#ifdef QT_CHECK_RANGE + qWarning( "TQSemaphore::operator-=: paramter %d out of range", n ); +#endif // QT_CHECK_RANGE + n = n < 0 ? 0 : d->value; + } + + d->value -= n; + d->cond.wakeAll(); + + return d->value; +} + + +/*! + Returns the number of accesses currently available to the + semaphore. +*/ +int TQSemaphore::available() const +{ + TQMutexLocker locker(&d->mutex); + return d->max - d->value; +} + + +/*! + Returns the total number of accesses to the semaphore. +*/ +int TQSemaphore::total() const +{ + TQMutexLocker locker(&d->mutex); + return d->max; +} + + +/*! + Try to get access to the semaphore. If \l available() \< \a n, this + function will return FALSE immediately. If \l available() \>= \a n, + this function will take \a n accesses and return TRUE. This + function does \e not block. +*/ +bool TQSemaphore::tryAccess(int n) +{ + TQMutexLocker locker(&d->mutex); + + if (d->value + n > d->max) + return FALSE; + + d->value += n; + + return TRUE; +} + +#endif // QT_THREAD_SUPPORT diff --git a/src/tools/qsemaphore.h b/src/tools/qsemaphore.h new file mode 100644 index 000000000..c0d0b2719 --- /dev/null +++ b/src/tools/qsemaphore.h @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Definition of TQSemaphore class +** +** Created : 931107 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQSEMAPHORE_H +#define TQSEMAPHORE_H + +#ifndef QT_H +#include "qglobal.h" +#endif // QT_H + +#if defined(QT_THREAD_SUPPORT) + +class TQSemaphorePrivate; + +class Q_EXPORT TQSemaphore +{ +public: + TQSemaphore( int ); + virtual ~TQSemaphore(); + + int available() const; + int total() const; + + // postfix operators + int operator++(int); + int operator--(int); + + int operator+=(int); + int operator-=(int); + + bool tryAccess(int); + +private: + TQSemaphorePrivate *d; + +#if defined(Q_DISABLE_COPY) + TQSemaphore(const TQSemaphore &); + TQSemaphore &operator=(const TQSemaphore &); +#endif +}; + +#endif + +#endif diff --git a/src/tools/qsettings.cpp b/src/tools/qsettings.cpp new file mode 100644 index 000000000..d7043e4bb --- /dev/null +++ b/src/tools/qsettings.cpp @@ -0,0 +1,2105 @@ +/**************************************************************************** +** +** Implementation of TQSettings class +** +** Created : 000626 +** +** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "qplatformdefs.h" + +// POSIX Large File Support redefines open -> open64 +static inline int qt_open( const char *pathname, int flags, mode_t mode ) +{ return ::open( pathname, flags, mode ); } +#if defined(open) +# undef open +#endif + +// POSIX Large File Support redefines truncate -> truncate64 +#if defined(truncate) +# undef truncate +#endif + +#include "qsettings.h" + +#ifndef QT_NO_SETTINGS + +#include "qdir.h" +#include "qfile.h" +#include "qfileinfo.h" +#include "qmap.h" +#include "qtextstream.h" +#include "qregexp.h" +#include +#ifndef NO_ERRNO_H +#include +#endif + +/*! + \class TQSettings + \brief The TQSettings class provides persistent platform-independent application settings. + + \ingroup io + \ingroup misc + \mainclass + + On Unix systems, TQSettings uses text files to store settings. On Windows + systems, TQSettings uses the system registry. On Mac OS X, TQSettings uses + the Carbon preferences API. + + Each setting comprises an identifying key and the data associated with + the key. A key is a unicode string which consists of \e two or more + subkeys. A subkey is a slash, '/', followed by one or more unicode + characters (excluding slashes, newlines, carriage returns and equals, + '=', signs). The associated data, called the entry or value, may be a + boolean, an integer, a double, a string or a list of strings. Entry + strings may contain any unicode characters. + + If you want to save and restore the entire desktop's settings, i.e. + which applications are running, use TQSettings to save the settings + for each individual application and TQSessionManager to save the + desktop's session. + + Example settings: + \code + /MyCompany/MyApplication/background color + /MyCompany/MyApplication/foreground color + /MyCompany/MyApplication/geometry/x + /MyCompany/MyApplication/geometry/y + /MyCompany/MyApplication/geometry/width + /MyCompany/MyApplication/geometry/height + /MyCompany/MyApplication/recent files/1 + /MyCompany/MyApplication/recent files/2 + /MyCompany/MyApplication/recent files/3 + \endcode + Each line above is a complete key, made up of subkeys. + + A typical usage pattern for reading settings at application + startup: + \code + TQSettings settings; + settings.setPath( "MyCompany.com", "MyApplication" ); + + TQString bgColor = settings.readEntry( "/colors/background", "white" ); + int width = settings.readNumEntry( "/geometry/width", 640 ); + // ... + \endcode + + A typical usage pattern for saving settings at application exit or + 'save preferences': + \code + TQSettings settings; + settings.setPath( "MyCompany.com", "MyApplication" ); + + settings.writeEntry( "/colors/background", bgColor ); + settings.writeEntry( "/geometry/width", width ); + // ... + \endcode + + A key prefix can be prepended to all keys using beginGroup(). The + application of the prefix is stopped using endGroup(). For + example: + \code + TQSettings settings; + + settings.beginGroup( "/MainWindow" ); + settings.beginGroup( "/Geometry" ); + int x = settings.readEntry( "/x" ); + // ... + settings.endGroup(); + settings.beginGroup( "/Toolbars" ); + // ... + settings.endGroup(); + settings.endGroup(); + \endcode + + You can get a list of entry-holding keys by calling entryList(), and + a list of key-holding keys using subkeyList(). + + \code + TQStringList keys = settings.entryList( "/MyApplication" ); + // keys contains 'background color' and 'foreground color'. + + TQStringList keys = settings.entryList( "/MyApplication/recent files" ); + // keys contains '1', '2' and '3'. + + TQStringList subkeys = settings.subkeyList( "/MyApplication" ); + // subkeys contains 'geometry' and 'recent files' + + TQStringList subkeys = settings.subkeyList( "/MyApplication/recent files" ); + // subkeys is empty. + \endcode + + Since settings for Windows are stored in the registry there are + some size limitations as follows: + \list + \i A subkey may not exceed 255 characters. + \i An entry's value may not exceed 16,300 characters. + \i All the values of a key (for example, all the 'recent files' + subkeys values), may not exceed 65,535 characters. + \endlist + + These limitations are not enforced on Unix or Mac OS X. + + \warning Creating multiple, simultaneous instances of TQSettings writing + to a text file may lead to data loss! This is a known issue which will + be fixed in a future release of TQt. + + \section1 Notes for Mac OS X Applications + + The location where settings are stored is not formally defined by + the CFPreferences API. + + At the time of writing settings are stored (either on a global or + user basis, preferring locally) into a plist file in \c + $ROOT/System/Library/Preferences (in XML format). TQSettings will + create an appropriate plist file (\c{com..plist}) + out of the full path to a key. + + For further information on CFPreferences see + \link http://developer.apple.com/documentation/CoreFoundation/Conceptual/CFPreferences/index.html + Apple's Specifications\endlink + + \section1 Notes for Unix Applications + + There is no universally accepted place for storing application + settings under Unix. In the examples the settings file will be + searched for in the following directories: + \list 1 + \i \c SYSCONF - the default value is \c INSTALL/etc/settings + \i \c /opt/MyCompany/share/etc + \i \c /opt/MyCompany/share/MyApplication/etc + \i \c $HOME/.qt + \endlist + When reading settings the files are searched in the order shown + above, with later settings overriding earlier settings. Files for + which the user doesn't have read permission are ignored. When saving + settings TQSettings works in the order shown above, writing + to the first settings file for which the user has write permission. + (\c INSTALL is the directory where TQt was installed. This can be + modified by using the configure script's -prefix argument ) + + If you want to put the settings in a particular place in the + filesystem you could do this: + \code + settings.insertSearchPath( TQSettings::Unix, "/opt/MyCompany/share" ); + \endcode + + But in practice you may prefer not to use a search path for Unix. + For example the following code: + \code + settings.writeEntry( "/MyApplication/geometry/width", width ); + \endcode + will end up writing the "geometry/width" setting to the file + \c{$HOME/.qt/myapplicationrc} (assuming that the application is + being run by an ordinary user, i.e. not by root). + + For cross-platform applications you should ensure that the + \link #sizelimit Windows size limitations \endlink are not exceeded. + + \warning TQSettings doesn't write the settings until it is destroyed so + you should construct the TQSettings object on the stack. +*/ + +/*! + \enum TQSettings::System + + \value Mac Macintosh execution environments + \value Unix Mac OS X, Unix, Linux and Unix-like execution environments + \value Windows Windows execution environments +*/ + +/*! + \enum TQSettings::Format + + \value Native Store the settings in a platform dependent location + \value Ini Store the settings in a text file +*/ + +/*! + \enum TQSettings::Scope + + \value Global Save settings as global as possible + \value User Save settings in user space +*/ + +#if defined(Q_OS_UNIX) +typedef int HANDLE; +#define Q_LOCKREAD F_RDLCK +#define Q_LOCKWRITE F_WRLCK +/* + Locks the file specified by name. The lockfile is created as a + hidden file in the same directory as the target file, with .lock + appended to the name. For example, "/etc/settings/onerc" uses a + lockfile named "/etc/settings/.onerc.lock". The type argument + controls the type of the lock, it can be either F_RDLCK for a read + lock, or F_WRLCK for a write lock. + + A file descriptor for the lock file is returned, and should be + closed with closelock() when the lock is no longer needed. + */ +static HANDLE openlock( const TQString &name, int type ) +{ + TQFileInfo info( name ); + // lockfile should be hidden, and never removed + TQString lockfile = info.dirPath() + "/." + info.fileName() + ".lock"; + + // open the lockfile + HANDLE fd = qt_open( TQFile::encodeName( lockfile ), + O_RDWR | O_CREAT, S_IRUSR | S_IWUSR ); + + if ( fd < 0 ) { + // failed to open the lock file, most likely because of permissions + return fd; + } + + struct flock fl; + fl.l_type = type; + fl.l_whence = SEEK_SET; + fl.l_start = 0; + fl.l_len = 0; + if ( fcntl( fd, F_SETLKW, &fl ) == -1 ) { + // the lock failed, so we should fail silently, so that people + // using filesystems that do not support locking don't see + // numerous warnings about a failed lock + close( fd ); + fd = -1; + } + + return fd; +} + +/* + Closes the lock file specified by fd. fd is the file descriptor + returned by the openlock() function. +*/ +static void closelock( HANDLE fd ) +{ + if ( fd < 0 ) { + // the lock file is not open + return; + } + + struct flock fl; + fl.l_type = F_UNLCK; + fl.l_whence = SEEK_SET; + fl.l_start = 0; + fl.l_len = 0; + // ignore the return value, so that the unlock fails silently + (void) fcntl( fd, F_SETLKW, &fl ); + + close( fd ); +} +#endif + + +TQSettingsGroup::TQSettingsGroup() + : modified(FALSE) +{ +} + + + + +void TQSettingsHeading::read(const TQString &filename) +{ + if (! TQFileInfo(filename).exists()) + return; + +#ifndef Q_WS_WIN + HANDLE lockfd = openlock( filename, Q_LOCKREAD ); +#endif + + TQFile file(filename); + if (! file.open(IO_ReadOnly)) { +#if defined(QT_CHECK_STATE) + qWarning("TQSettings: failed to open file '%s'", filename.latin1()); +#endif + return; + } + + git = end(); + + TQTextStream stream(&file); + stream.setEncoding(TQTextStream::UnicodeUTF8); + while (! stream.atEnd()) + parseLine(stream); + + git = end(); + + file.close(); + +#ifndef Q_WS_WIN + closelock( lockfd ); +#endif +} + + +void TQSettingsHeading::parseLine(TQTextStream &stream) +{ + TQString line = stream.readLine(); + if (line.isEmpty()) + // empty line... we'll allow it + return; + + if (line[0] == TQChar('#')) + // commented line + return; + + if (line[0] == TQChar('[')) { + TQString gname = line; + + gname = gname.remove((uint)0, 1); + if (gname[(int)gname.length() - 1] == TQChar(']')) + gname = gname.remove(gname.length() - 1, 1); + + git = find(gname); + if (git == end()) + git = replace(gname, TQSettingsGroup()); + } else { + if (git == end()) { +#if defined(QT_CHECK_STATE) + qWarning("TQSettings: line '%s' out of group", line.latin1()); +#endif + return; + } + + int i = line.find('='); + if (i == -1) { +#if defined(QT_CHECK_STATE) + qWarning("TQSettings: malformed line '%s' in group '%s'", + line.latin1(), git.key().latin1()); +#endif + return; + } else { + TQString key, value; + key = line.left(i); + value = ""; + bool esc=TRUE; + i++; + while (esc) { + esc = FALSE; + for ( ; i < (int)line.length(); i++ ) { + if ( esc ) { + if ( line[i] == 'n' ) + value.append('\n'); // escaped newline + else if ( line[i] == '0' ) + value = TQString::null; // escaped empty string + else + value.append(line[i]); + esc = FALSE; + } else if ( line[i] == '\\' ) + esc = TRUE; + else + value.append(line[i]); + } + if ( esc ) { + // Backwards-compatiblity... + // still escaped at EOL - manually escaped "newline" + if (stream.atEnd()) { +#if defined(QT_CHECK_STATE) + qWarning("TQSettings: reached end of file, expected continued line"); +#endif + break; + } + value.append('\n'); + line = stream.readLine(); + i = 0; + } + } + + (*git).insert(key, value); + } + } +} + +#ifdef Q_WS_WIN // for homedirpath reading from registry +#include "qt_windows.h" +#include "qlibrary.h" + +#ifndef CSIDL_APPDATA +#define CSIDL_APPDATA 0x001a // \Application Data +#endif +#ifndef CSIDL_COMMON_APPDATA +#define CSIDL_COMMON_APPDATA 0x0023 // All Users\Application Data +#endif + +#endif + +TQSettingsPrivate::TQSettingsPrivate( TQSettings::Format format ) + : groupDirty( TRUE ), modified(FALSE), globalScope(TRUE) +{ +#if !defined(TQWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC)) + if ( format != TQSettings::Ini ) + return; +#else + Q_UNUSED( format ); +#endif + + TQString appSettings(TQDir::homeDirPath() + "/.qt/"); + TQString defPath; +#ifdef Q_WS_WIN +#ifdef Q_OS_TEMP + TCHAR path[MAX_PATH]; + SHGetSpecialFolderPath( 0, path, CSIDL_APPDATA, FALSE ); + appSettings = TQString::fromUcs2( path ); + SHGetSpecialFolderPath( 0, path, CSIDL_COMMON_APPDATA, FALSE ); + defPath = TQString::fromUcs2( path ); +#else + TQLibrary library( "shell32" ); + library.setAutoUnload( FALSE ); + QT_WA( { + typedef BOOL (WINAPI*GetSpecialFolderPath)(HWND, LPTSTR, int, BOOL); + GetSpecialFolderPath SHGetSpecialFolderPath = (GetSpecialFolderPath)library.resolve( "SHGetSpecialFolderPathW" ); + if ( SHGetSpecialFolderPath ) { + TCHAR path[MAX_PATH]; + SHGetSpecialFolderPath( 0, path, CSIDL_APPDATA, FALSE ); + appSettings = TQString::fromUcs2( (ushort*)path ); + SHGetSpecialFolderPath( 0, path, CSIDL_COMMON_APPDATA, FALSE ); + defPath = TQString::fromUcs2( (ushort*)path ); + } + } , { + typedef BOOL (WINAPI*GetSpecialFolderPath)(HWND, char*, int, BOOL); + GetSpecialFolderPath SHGetSpecialFolderPath = (GetSpecialFolderPath)library.resolve( "SHGetSpecialFolderPathA" ); + if ( SHGetSpecialFolderPath ) { + char path[MAX_PATH]; + SHGetSpecialFolderPath( 0, path, CSIDL_APPDATA, FALSE ); + appSettings = TQString::fromLocal8Bit( path ); + SHGetSpecialFolderPath( 0, path, CSIDL_COMMON_APPDATA, FALSE ); + defPath = TQString::fromLocal8Bit( path ); + } + } ); +#endif // Q_OS_TEMP +#else + defPath = qInstallPathSysconf(); +#endif + TQDir dir(appSettings); + if (! dir.exists()) { + if (! dir.mkdir(dir.path())) +#if defined(QT_CHECK_STATE) + qWarning("TQSettings: error creating %s", dir.path().latin1()); +#else + ; +#endif + } + + if ( !!defPath ) + searchPaths.append(defPath); + searchPaths.append(dir.path()); +} + +TQSettingsPrivate::~TQSettingsPrivate() +{ +} + +TQSettingsGroup TQSettingsPrivate::readGroup() +{ + TQSettingsHeading hd; + TQSettingsGroup grp; + + TQMap::Iterator headingsit = headings.find(heading); + if (headingsit != headings.end()) + hd = *headingsit; + + TQSettingsHeading::Iterator grpit = hd.find(group); + if (grpit == hd.end()) { + TQStringList::Iterator it = searchPaths.begin(); + if ( !globalScope ) + ++it; + while (it != searchPaths.end()) { + TQString filebase = heading.lower().replace(TQRegExp(TQString::fromLatin1("\\s+")), "_"); + TQString fn((*it++) + "/" + filebase + "rc"); + if (! hd.contains(fn + "cached")) { + hd.read(fn); + hd.insert(fn + "cached", TQSettingsGroup()); + } + } + + headings.replace(heading, hd); + + grpit = hd.find(group); + if (grpit != hd.end()) + grp = *grpit; + } else if (hd.count() != 0) + grp = *grpit; + + return grp; +} + + +void TQSettingsPrivate::removeGroup(const TQString &key) +{ + TQSettingsHeading hd; + TQSettingsGroup grp; + bool found = FALSE; + + TQMap::Iterator headingsit = headings.find(heading); + if (headingsit != headings.end()) + hd = *headingsit; + + TQSettingsHeading::Iterator grpit = hd.find(group); + if (grpit == hd.end()) { + TQStringList::Iterator it = searchPaths.begin(); + if ( !globalScope ) + ++it; + while (it != searchPaths.end()) { + TQString filebase = heading.lower().replace(TQRegExp(TQString::fromLatin1("\\s+")), "_"); + TQString fn((*it++) + "/" + filebase + "rc"); + if (! hd.contains(fn + "cached")) { + hd.read(fn); + hd.insert(fn + "cached", TQSettingsGroup()); + } + } + + headings.replace(heading, hd); + + grpit = hd.find(group); + if (grpit != hd.end()) { + found = TRUE; + grp = *grpit; + } + } else if (hd.count() != 0) { + found = TRUE; + grp = *grpit; + } + + if (found) { + grp.remove(key); + + if (grp.count() > 0) + hd.replace(group, grp); + else + hd.remove(group); + + if (hd.count() > 0) + headings.replace(heading, hd); + else + headings.remove(heading); + + modified = TRUE; + } +} + + +void TQSettingsPrivate::writeGroup(const TQString &key, const TQString &value) +{ + TQSettingsHeading hd; + TQSettingsGroup grp; + + TQMap::Iterator headingsit = headings.find(heading); + if (headingsit != headings.end()) + hd = *headingsit; + + TQSettingsHeading::Iterator grpit = hd.find(group); + if (grpit == hd.end()) { + TQStringList::Iterator it = searchPaths.begin(); + if ( !globalScope ) + ++it; + while (it != searchPaths.end()) { + TQString filebase = heading.lower().replace(TQRegExp(TQString::fromLatin1("\\s+")), "_"); + TQString fn((*it++) + "/" + filebase + "rc"); + if (! hd.contains(fn + "cached")) { + hd.read(fn); + hd.insert(fn + "cached", TQSettingsGroup()); + } + } + + headings.replace(heading, hd); + + grpit = hd.find(group); + if (grpit != hd.end()) + grp = *grpit; + } else if (hd.count() != 0) + grp = *grpit; + + grp.modified = TRUE; + grp.replace(key, value); + hd.replace(group, grp); + headings.replace(heading, hd); + + modified = TRUE; +} + + +TQDateTime TQSettingsPrivate::modificationTime() +{ + TQSettingsHeading hd = headings[heading]; + TQSettingsGroup grp = hd[group]; + + TQDateTime datetime; + + TQStringList::Iterator it = searchPaths.begin(); + if ( !globalScope ) + ++it; + while (it != searchPaths.end()) { + TQFileInfo fi((*it++) + "/" + heading + "rc"); + if (fi.exists() && fi.lastModified() > datetime) + datetime = fi.lastModified(); + } + + return datetime; +} + +bool qt_verify_key( const TQString &key ) +{ + if ( key.isEmpty() || key[0] != '/' || key.contains( TQRegExp(TQString::fromLatin1("[=\\r\\n]")) ) ) + return FALSE; + return TRUE; +} + +static TQString groupKey( const TQString &group, const TQString &key ) +{ + TQString grp_key; + if ( group.isEmpty() || ( group.length() == 1 && group[0] == '/' ) ) { + // group is empty, or it contains a single '/', so we just return the key + if ( key.startsWith( "/" ) ) + grp_key = key; + else + grp_key = "/" + key; + } else if ( group.endsWith( "/" ) || key.startsWith( "/" ) ) { + grp_key = group + key; + } else { + grp_key = group + "/" + key; + } + return grp_key; +} + +/*! + Inserts \a path into the settings search path. The semantics of \a + path depends on the system \a s. It is usually easier and better to + use setPath() instead of this function. + + When \a s is \e Windows and the execution environment is \e not + Windows the function does nothing. Similarly when \a s is \e Unix and + the execution environment is \e not Unix the function does nothing. + + When \a s is \e Windows, and the execution environment is Windows, the + search path list will be used as the first subfolder of the "Software" + folder in the registry. + + When reading settings the folders are searched forwards from the + first folder (listed below) to the last, returning the first + settings found, and ignoring any folders for which the user doesn't + have read permission. + \list 1 + \i HKEY_CURRENT_USER/Software/MyCompany/MyApplication + \i HKEY_LOCAL_MACHINE/Software/MyCompany/MyApplication + \i HKEY_CURRENT_USER/Software/MyApplication + \i HKEY_LOCAL_MACHINE/Software/MyApplication + \endlist + + \code + TQSettings settings; + settings.insertSearchPath( TQSettings::Windows, "/MyCompany" ); + settings.writeEntry( "/MyApplication/Tip of the day", TRUE ); + \endcode + The code above will write the subkey "Tip of the day" into the \e + first of the registry folders listed below that is found and for + which the user has write permission. + \list 1 + \i HKEY_LOCAL_MACHINE/Software/MyCompany/MyApplication + \i HKEY_CURRENT_USER/Software/MyCompany/MyApplication + \i HKEY_LOCAL_MACHINE/Software/MyApplication + \i HKEY_CURRENT_USER/Software/MyApplication + \endlist + If a setting is found in the HKEY_CURRENT_USER space, this setting + is overwritten independently of write permissions in the + HKEY_LOCAL_MACHINE space. + + When \a s is \e Unix, and the execution environment is Unix, the + search path list will be used when trying to determine a suitable + filename for reading and writing settings files. By default, there are + two entries in the search path: + + \list 1 + \i \c SYSCONF - where \c SYSCONF is a directory specified when + configuring TQt; by default it is INSTALL/etc/settings. + \i \c $HOME/.qt/ - where \c $HOME is the user's home directory. + \endlist + + All insertions into the search path will go before $HOME/.qt/. + For example: + \code + TQSettings settings; + settings.insertSearchPath( TQSettings::Unix, "/opt/MyCompany/share/etc" ); + settings.insertSearchPath( TQSettings::Unix, "/opt/MyCompany/share/MyApplication/etc" ); + // ... + \endcode + Will result in a search path of: + \list 1 + \i SYSCONF + \i /opt/MyCompany/share/etc + \i /opt/MyCompany/share/MyApplication/etc + \i $HOME/.qt + \endlist + When reading settings the files are searched in the order shown + above, with later settings overriding earlier settings. Files for + which the user doesn't have read permission are ignored. When saving + settings TQSettings works in the order shown above, writing + to the first settings file for which the user has write permission. + + Note that paths in the file system are not created by this + function, so they must already exist to be useful. + + Settings under Unix are stored in files whose names are based on the + first subkey of the key (not including the search path). The algorithm + for creating names is essentially: lowercase the first subkey, replace + spaces with underscores and add 'rc', e.g. + /MyCompany/MyApplication/background color will be stored in + myapplicationrc (assuming that /MyCompany is part of + the search path). + + \sa removeSearchPath() + +*/ +void TQSettings::insertSearchPath( System s, const TQString &path) +{ +#if !defined(TQWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC)) + if ( d->sysd ) { + d->sysInsertSearchPath( s, path ); + return; + } +#endif + +#if !defined(Q_WS_WIN) + if ( s == Windows ) + return; +#endif +#if !defined(Q_OS_MAC) + if ( s == Mac ) + return; +#endif + + if ( !qt_verify_key( path ) ) { +#if defined(QT_CHECK_STATE) + qWarning( "TQSettings::insertSearchPath: Invalid key: '%s'", path.isNull() ? "(null)" : path.latin1() ); +#endif + return; + } + +#if !defined(TQWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC)) + if ( d->sysd && s != Unix ) { +#else + if ( s != Unix ) { +#endif +#if !defined(TQWS) && defined(Q_OS_MAC) + if(s != Mac) //mac is respected on the mac as well +#endif + return; + } + + TQString realPath = path; +#if defined(Q_WS_WIN) + TQString defPath = d->globalScope ? d->searchPaths.first() : d->searchPaths.last(); + realPath = defPath + path; +#endif + + TQStringList::Iterator it = d->searchPaths.find(d->searchPaths.last()); + if (it != d->searchPaths.end()) { + d->searchPaths.insert(it, realPath); + } +} + + +/*! + Removes all occurrences of \a path (using exact matching) from the + settings search path for system \a s. Note that the default search + paths cannot be removed. + + \sa insertSearchPath() +*/ +void TQSettings::removeSearchPath( System s, const TQString &path) +{ + if ( !qt_verify_key( path ) ) { +#if defined(QT_CHECK_STATE) + qWarning( "TQSettings::insertSearchPath: Invalid key: '%s'", path.isNull() ? "(null)" : path.latin1() ); +#endif + return; + } + +#ifdef Q_WS_WIN + if ( d->sysd ) { + d->sysRemoveSearchPath( s, path ); + return; + } +#endif +#if !defined(TQWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC)) + if ( d->sysd && s != Unix ) { +#else + if ( s != Unix ) { +#endif +#if !defined(TQWS) && defined(Q_OS_MAC) + if(s != Mac) //mac is respected on the mac as well +#endif + return; + } + + if (path == d->searchPaths.first() || path == d->searchPaths.last()) + return; + + d->searchPaths.remove(path); +} + + +/*! + Creates a settings object. + + Be aware that you must call setPath() or insertSearchPath() before + you can use the TQSettings object. +*/ +TQSettings::TQSettings() +{ + d = new TQSettingsPrivate( Native ); + Q_CHECK_PTR(d); + +#if !defined(TQWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC)) + d->sysd = 0; + d->sysInit(); +#endif +} + +/*! + Creates a settings object. If \a format is 'Ini' the settings will + be stored in a text file, using the Unix strategy (see above). If \a format + is 'Native', the settings will be stored in a platform specific way + (ie. the Windows registry). + + Be aware that you must call setPath() or insertSearchPath() before + you can use the TQSettings object. +*/ +TQSettings::TQSettings( Format format ) +{ + d = new TQSettingsPrivate( format ); + Q_CHECK_PTR(d); + +#if !defined(TQWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC)) + d->sysd = 0; + if ( format == Native ) + d->sysInit(); +#else + Q_UNUSED(format); +#endif +} + +/*! + Destroys the settings object. All modifications made to the settings + will automatically be saved. + +*/ +TQSettings::~TQSettings() +{ + sync(); + +#if !defined(TQWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC)) + if ( d->sysd ) + d->sysClear(); +#endif + + delete d; +} + + +/*! \internal + Writes all modifications to the settings to disk. If any errors are + encountered, this function returns FALSE, otherwise it will return TRUE. +*/ +bool TQSettings::sync() +{ +#if !defined(TQWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC)) + if ( d->sysd ) + return d->sysSync(); +#endif + if (! d->modified) + // fake success + return TRUE; + + bool success = TRUE; + TQMap::Iterator it = d->headings.begin(); + + while (it != d->headings.end()) { + // determine filename + TQSettingsHeading hd(*it); + TQSettingsHeading::Iterator hdit = hd.begin(); + TQString filename; + + TQStringList::Iterator pit = d->searchPaths.begin(); + if ( !d->globalScope ) + ++pit; + while (pit != d->searchPaths.end()) { + TQString filebase = it.key().lower().replace(TQRegExp(TQString::fromLatin1("\\s+")), "_"); + TQFileInfo di(*pit); + if ( !di.exists() ) { + TQDir dir; + dir.mkdir( *pit ); + } + + TQFileInfo fi((*pit++) + "/" + filebase + "rc"); + + if ((fi.exists() && fi.isFile() && fi.isWritable()) || + (! fi.exists() && di.isDir() +#ifndef Q_WS_WIN + && di.isWritable() +#else + && ((qWinVersion()&TQt::WV_NT_based) > TQt::WV_2000 || di.isWritable()) +#endif + )) { + filename = fi.filePath(); + break; + } + } + + ++it; + + if ( filename.isEmpty() ) { + +#ifdef QT_CHECK_STATE + qWarning("TQSettings::sync: filename is null/empty"); +#endif // QT_CHECK_STATE + + success = FALSE; + continue; + } + +#ifndef Q_WS_WIN + HANDLE lockfd = openlock( filename, Q_LOCKWRITE ); +#endif + + TQFile file( filename + ".tmp" ); + if (! file.open(IO_WriteOnly)) { + +#ifdef QT_CHECK_STATE + qWarning("TQSettings::sync: failed to open '%s' for writing", + file.name().latin1()); +#endif // QT_CHECK_STATE + + success = FALSE; + continue; + } + + // spew to file + TQTextStream stream(&file); + stream.setEncoding(TQTextStream::UnicodeUTF8); + + while (hdit != hd.end()) { + if ((*hdit).count() > 0) { + stream << "[" << hdit.key() << "]" << endl; + + TQSettingsGroup grp(*hdit); + TQSettingsGroup::Iterator grpit = grp.begin(); + + while (grpit != grp.end()) { + TQString v = grpit.data(); + if ( v.isNull() ) { + v = TQString::fromLatin1("\\0"); // escape null string + } else { + v.replace('\\', TQString::fromLatin1("\\\\")); // escape backslash + v.replace('\n', TQString::fromLatin1("\\n")); // escape newlines + } + + stream << grpit.key() << "=" << v << endl; + ++grpit; + } + + stream << endl; + } + + ++hdit; + } + + if (file.status() != IO_Ok) { + +#ifdef QT_CHECK_STATE + qWarning("TQSettings::sync: error at end of write"); +#endif // QT_CHECK_STATE + + success = FALSE; + } + + file.close(); + + if ( success ) { + TQDir dir( TQFileInfo( file ).dir( TRUE ) ); + if ( dir.exists( filename ) && !dir.remove( filename ) || + !dir.rename( file.name(), filename, TRUE ) ) { + +#ifdef QT_CHECK_STATE + qWarning( "TQSettings::sync: error writing file '%s'", + TQFile::encodeName( filename ).data() ); +#endif // QT_CHECK_STATE + + success = FALSE; + } + } + + // remove temporary file + file.remove(); + +#ifndef Q_WS_WIN + closelock( lockfd ); +#endif + } + + d->modified = FALSE; + + return success; +} + + +/*! + \fn bool TQSettings::readBoolEntry(const TQString &key, bool def, bool *ok ) const + + Reads the entry specified by \a key, and returns a bool, or the + default value, \a def, if the entry couldn't be read. + If \a ok is non-null, *ok is set to TRUE if the key was read, FALSE + otherwise. + + \sa readEntry(), readNumEntry(), readDoubleEntry(), writeEntry(), removeEntry() +*/ + +/*! + \internal +*/ +bool TQSettings::readBoolEntry(const TQString &key, bool def, bool *ok ) +{ + TQString grp_key( groupKey( group(), key ) ); + if ( !qt_verify_key( grp_key ) ) { +#if defined(QT_CHECK_STATE) + qWarning( "TQSettings::readBoolEntry: Invalid key: '%s'", grp_key.isNull() ? "(null)" : grp_key.latin1() ); +#endif + if ( ok ) + *ok = FALSE; + + return def; + } + +#if !defined(TQWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC)) + if ( d->sysd ) + return d->sysReadBoolEntry( grp_key, def, ok ); +#endif + + TQString value = readEntry( key, ( def ? "true" : "false" ), ok ); + + if (value.lower() == "true") + return TRUE; + else if (value.lower() == "false") + return FALSE; + else if (value == "1") + return TRUE; + else if (value == "0") + return FALSE; + + if (! value.isEmpty()) + qWarning("TQSettings::readBoolEntry: '%s' is not 'true' or 'false'", + value.latin1()); + if ( ok ) + *ok = FALSE; + return def; +} + + +/*! + \fn double TQSettings::readDoubleEntry(const TQString &key, double def, bool *ok ) const + + Reads the entry specified by \a key, and returns a double, or the + default value, \a def, if the entry couldn't be read. + If \a ok is non-null, *ok is set to TRUE if the key was read, FALSE + otherwise. + + \sa readEntry(), readNumEntry(), readBoolEntry(), writeEntry(), removeEntry() +*/ + +/*! + \internal +*/ +double TQSettings::readDoubleEntry(const TQString &key, double def, bool *ok ) +{ + TQString grp_key( groupKey( group(), key ) ); + if ( !qt_verify_key( grp_key ) ) { +#if defined(QT_CHECK_STATE) + qWarning( "TQSettings::readDoubleEntry: Invalid key: '%s'", grp_key.isNull() ? "(null)" : grp_key.latin1() ); +#endif + if ( ok ) + *ok = FALSE; + + return def; + } + +#if !defined(TQWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC)) + if ( d->sysd ) + return d->sysReadDoubleEntry( grp_key, def, ok ); +#endif + + TQString value = readEntry( key, TQString::number(def), ok ); + bool conv_ok; + double retval = value.toDouble( &conv_ok ); + if ( conv_ok ) + return retval; + if ( ! value.isEmpty() ) + qWarning( "TQSettings::readDoubleEntry: '%s' is not a number", + value.latin1() ); + if ( ok ) + *ok = FALSE; + return def; +} + + +/*! + \fn int TQSettings::readNumEntry(const TQString &key, int def, bool *ok ) const + + Reads the entry specified by \a key, and returns an integer, or the + default value, \a def, if the entry couldn't be read. + If \a ok is non-null, *ok is set to TRUE if the key was read, FALSE + otherwise. + + \sa readEntry(), readDoubleEntry(), readBoolEntry(), writeEntry(), removeEntry() +*/ + +/*! + \internal +*/ +int TQSettings::readNumEntry(const TQString &key, int def, bool *ok ) +{ + TQString grp_key( groupKey( group(), key ) ); + if ( !qt_verify_key( grp_key ) ) { +#if defined(QT_CHECK_STATE) + qWarning( "TQSettings::readNumEntry: Invalid key: '%s'", grp_key.isNull() ? "(null)" : grp_key.latin1() ); +#endif + if ( ok ) + *ok = FALSE; + return def; + } + +#if !defined(TQWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC)) + if ( d->sysd ) + return d->sysReadNumEntry( grp_key, def, ok ); +#endif + + TQString value = readEntry( key, TQString::number( def ), ok ); + bool conv_ok; + int retval = value.toInt( &conv_ok ); + if ( conv_ok ) + return retval; + if ( ! value.isEmpty() ) + qWarning( "TQSettings::readNumEntry: '%s' is not a number", + value.latin1() ); + if ( ok ) + *ok = FALSE; + return def; +} + + +/*! + \fn TQString TQSettings::readEntry(const TQString &key, const TQString &def, bool *ok ) const + + Reads the entry specified by \a key, and returns a TQString, or the + default value, \a def, if the entry couldn't be read. + If \a ok is non-null, *ok is set to TRUE if the key was read, FALSE + otherwise. + + \sa readListEntry(), readNumEntry(), readDoubleEntry(), readBoolEntry(), writeEntry(), removeEntry() +*/ + +/*! + \internal +*/ +TQString TQSettings::readEntry(const TQString &key, const TQString &def, bool *ok ) +{ + TQString grp_key( groupKey( group(), key ) ); + if ( !qt_verify_key( grp_key ) ) { +#if defined(QT_CHECK_STATE) + qWarning( "TQSettings::readEntry: Invalid key: '%s'", grp_key.isNull() ? "(null)" : grp_key.latin1() ); +#endif + if ( ok ) + *ok = FALSE; + + return def; + } + +#if !defined(TQWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC)) + if ( d->sysd ) + return d->sysReadEntry( grp_key, def, ok ); +#endif + + if ( ok ) // no, everything is not ok + *ok = FALSE; + + TQString realkey; + + if (grp_key[0] == '/') { + // parse our key + TQStringList list(TQStringList::split('/', grp_key)); + + if (list.count() < 2) { +#ifdef QT_CHECK_STATE + qWarning("TQSettings::readEntry: invalid key '%s'", grp_key.latin1()); +#endif // QT_CHECK_STATE + if ( ok ) + *ok = FALSE; + return def; + } + + if (list.count() == 2) { + d->heading = list[0]; + d->group = "General"; + realkey = list[1]; + } else { + d->heading = list[0]; + d->group = list[1]; + + // remove the group from the list + list.remove(list.at(1)); + // remove the heading from the list + list.remove(list.at(0)); + + realkey = list.join("/"); + } + } else { + realkey = grp_key; + } + + TQSettingsGroup grp = d->readGroup(); + TQSettingsGroup::const_iterator it = grp.find( realkey ), end = grp.end(); + TQString retval = def; + if ( it != end ) { + // found the value we needed + retval = *it; + if ( ok ) *ok = TRUE; + } + return retval; +} + + +#if !defined(Q_NO_BOOL_TYPE) +/*! + Writes the boolean entry \a value into key \a key. The \a key is + created if it doesn't exist. Any previous value is overwritten by \a + value. + + If an error occurs the settings are left unchanged and FALSE is + returned; otherwise TRUE is returned. + + \warning On certain platforms, keys are retquired to contain at least + two components (e.g., "/foo/bar"). This limitation does not apply to + TQt 4. + + \sa readListEntry(), readNumEntry(), readDoubleEntry(), readBoolEntry(), removeEntry() +*/ +bool TQSettings::writeEntry(const TQString &key, bool value) +{ + TQString grp_key( groupKey( group(), key ) ); + if ( !qt_verify_key( grp_key ) ) { +#if defined(QT_CHECK_STATE) + qWarning( "TQSettings::writeEntry: Invalid key: '%s'", grp_key.isNull() ? "(null)" : grp_key.latin1() ); +#endif + return FALSE; + } + +#if !defined(TQWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC)) + if ( d->sysd ) + return d->sysWriteEntry( grp_key, value ); +#endif + TQString s(value ? "true" : "false"); + return writeEntry(key, s); +} +#endif + + +/*! + \overload + Writes the double entry \a value into key \a key. The \a key is + created if it doesn't exist. Any previous value is overwritten by \a + value. + + If an error occurs the settings are left unchanged and FALSE is + returned; otherwise TRUE is returned. + + \sa readListEntry(), readNumEntry(), readDoubleEntry(), readBoolEntry(), removeEntry() +*/ +bool TQSettings::writeEntry(const TQString &key, double value) +{ + TQString grp_key( groupKey( group(), key ) ); + if ( !qt_verify_key( grp_key ) ) { +#if defined(QT_CHECK_STATE) + qWarning( "TQSettings::writeEntry: Invalid key: '%s'", grp_key.isNull() ? "(null)" : grp_key.latin1() ); +#endif + return FALSE; + } + +#if !defined(TQWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC)) + if ( d->sysd ) + return d->sysWriteEntry( grp_key, value ); +#endif + TQString s(TQString::number(value)); + return writeEntry(key, s); +} + + +/*! + \overload + Writes the integer entry \a value into key \a key. The \a key is + created if it doesn't exist. Any previous value is overwritten by \a + value. + + If an error occurs the settings are left unchanged and FALSE is + returned; otherwise TRUE is returned. + + \sa readListEntry(), readNumEntry(), readDoubleEntry(), readBoolEntry(), removeEntry() +*/ +bool TQSettings::writeEntry(const TQString &key, int value) +{ + TQString grp_key( groupKey( group(), key ) ); + if ( !qt_verify_key( grp_key ) ) { +#if defined(QT_CHECK_STATE) + qWarning( "TQSettings::writeEntry: Invalid key: '%s'", grp_key.isNull() ? "(null)" : grp_key.latin1() ); +#endif + return FALSE; + } + +#if !defined(TQWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC)) + if ( d->sysd ) + return d->sysWriteEntry( grp_key, value ); +#endif + TQString s(TQString::number(value)); + return writeEntry(key, s); +} + + +/*! + \internal + + Writes the entry specified by \a key with the string-literal \a value, + replacing any previous setting. If \a value is zero-length or null, the + entry is replaced by an empty setting. + + \e NOTE: This function is provided because some compilers use the + writeEntry (const TQString &, bool) overload for this code: + writeEntry ("/foo/bar", "baz") + + If an error occurs, this functions returns FALSE and the object is left + unchanged. + + \sa readEntry(), removeEntry() +*/ +bool TQSettings::writeEntry(const TQString &key, const char *value) +{ + return writeEntry(key, TQString(value)); +} + + +/*! + \overload + Writes the string entry \a value into key \a key. The \a key is + created if it doesn't exist. Any previous value is overwritten by \a + value. If \a value is an empty string or a null string the key's + value will be an empty string. + + If an error occurs the settings are left unchanged and FALSE is + returned; otherwise TRUE is returned. + + \sa readListEntry(), readNumEntry(), readDoubleEntry(), readBoolEntry(), removeEntry() +*/ +bool TQSettings::writeEntry(const TQString &key, const TQString &value) +{ + TQString grp_key( groupKey( group(), key ) ); + if ( !qt_verify_key( grp_key ) ) { +#if defined(QT_CHECK_STATE) + qWarning( "TQSettings::writeEntry: Invalid key: '%s'", grp_key.isNull() ? "(null)" : grp_key.latin1() ); +#endif + return FALSE; + } + +#if !defined(TQWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC)) + if ( d->sysd ) + return d->sysWriteEntry( grp_key, value ); +#endif + // NOTE: we *do* allow value to be a null/empty string + + TQString realkey; + + if (grp_key[0] == '/') { + // parse our key + TQStringList list(TQStringList::split('/', grp_key)); + + if (list.count() < 2) { +#ifdef QT_CHECK_STATE + qWarning("TQSettings::writeEntry: invalid key '%s'", grp_key.latin1()); +#endif // QT_CHECK_STATE + + return FALSE; + } + + if (list.count() == 2) { + d->heading = list[0]; + d->group = "General"; + realkey = list[1]; + } else { + d->heading = list[0]; + d->group = list[1]; + + // remove the group from the list + list.remove(list.at(1)); + // remove the heading from the list + list.remove(list.at(0)); + + realkey = list.join("/"); + } + } else { + realkey = grp_key; + } + + d->writeGroup(realkey, value); + return TRUE; +} + + +/*! + Removes the entry specified by \a key. + + Returns true if the entry was successfully removed; otherwise + returns false. Note that removing the last entry in any given + folder, will also remove the folder. + + \sa readEntry(), writeEntry() +*/ +bool TQSettings::removeEntry(const TQString &key) +{ + TQString grp_key( groupKey( group(), key ) ); + if ( !qt_verify_key( grp_key ) ) { +#if defined(QT_CHECK_STATE) + qWarning( "TQSettings::removeEntry: Invalid key: '%s'", grp_key.isNull() ? "(null)" : grp_key.latin1() ); +#endif + return FALSE; + } + +#if !defined(TQWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC)) + if ( d->sysd ) + return d->sysRemoveEntry( grp_key ); +#endif + + TQString realkey; + if (grp_key[0] == '/') { + // parse our key + TQStringList list(TQStringList::split('/', grp_key)); + + if (list.count() < 2) { +#ifdef QT_CHECK_STATE + qWarning("TQSettings::removeEntry: invalid key '%s'", grp_key.latin1()); +#endif // QT_CHECK_STATE + + return FALSE; + } + + if (list.count() == 2) { + d->heading = list[0]; + d->group = "General"; + realkey = list[1]; + } else { + d->heading = list[0]; + d->group = list[1]; + + // remove the group from the list + list.remove(list.at(1)); + // remove the heading from the list + list.remove(list.at(0)); + + realkey = list.join("/"); + } + } else { + realkey = grp_key; + } + + d->removeGroup(realkey); + return TRUE; +} + + +/*! + Returns a list of the keys which contain entries under \a key. Does \e + not return any keys that contain subkeys. + + Example settings: + \code + /MyCompany/MyApplication/background color + /MyCompany/MyApplication/foreground color + /MyCompany/MyApplication/geometry/x + /MyCompany/MyApplication/geometry/y + /MyCompany/MyApplication/geometry/width + /MyCompany/MyApplication/geometry/height + \endcode + \code + TQStringList keys = settings.entryList( "/MyCompany/MyApplication" ); + \endcode + + In the above example, \c keys will contain 'background color' and + 'foreground color'. It will not contain 'geometry' because this key + contains subkeys not entries. + + To access the geometry values, you could either use subkeyList() + to read the keys then read each entry, or simply read each entry + directly by specifying its full key, e.g. + "/MyCompany/MyApplication/geometry/y". + + \sa subkeyList() +*/ +TQStringList TQSettings::entryList(const TQString &key) const +{ + TQString grp_key( groupKey( group(), key ) ); + if ( !qt_verify_key( grp_key ) ) { +#if defined(QT_CHECK_STATE) + qWarning( "TQSettings::entryList: Invalid key: %s", grp_key.isNull() ? "(null)" : grp_key.latin1() ); +#endif + return TQStringList(); + } + +#if !defined(TQWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC)) + if ( d->sysd ) + return d->sysEntryList( grp_key ); +#endif + + TQString realkey; + if (grp_key[0] == '/') { + // parse our key + TQStringList list(TQStringList::split('/', grp_key)); + + if (list.count() < 1) { +#ifdef QT_CHECK_STATE + qWarning("TQSettings::listEntries: invalid key '%s'", grp_key.latin1()); +#endif // QT_CHECK_STATE + + return TQStringList(); + } + + if (list.count() == 1) { + d->heading = list[0]; + d->group = "General"; + } else { + d->heading = list[0]; + d->group = list[1]; + + // remove the group from the list + list.remove(list.at(1)); + // remove the heading from the list + list.remove(list.at(0)); + + realkey = list.join("/"); + } + } else + realkey = grp_key; + + TQSettingsGroup grp = d->readGroup(); + TQSettingsGroup::Iterator it = grp.begin(); + TQStringList ret; + TQString itkey; + while (it != grp.end()) { + itkey = it.key(); + ++it; + + if ( realkey.length() > 0 ) { + if ( itkey.left( realkey.length() ) != realkey ) + continue; + else + itkey.remove( 0, realkey.length() + 1 ); + } + + if ( itkey.find( '/' ) != -1 ) + continue; + + ret << itkey; + } + + return ret; +} + + +/*! + Returns a list of the keys which contain subkeys under \a key. Does \e + not return any keys that contain entries. + + Example settings: + \code + /MyCompany/MyApplication/background color + /MyCompany/MyApplication/foreground color + /MyCompany/MyApplication/geometry/x + /MyCompany/MyApplication/geometry/y + /MyCompany/MyApplication/geometry/width + /MyCompany/MyApplication/geometry/height + /MyCompany/MyApplication/recent files/1 + /MyCompany/MyApplication/recent files/2 + /MyCompany/MyApplication/recent files/3 + \endcode + \code + TQStringList keys = settings.subkeyList( "/MyCompany/MyApplication" ); + \endcode + + In the above example, \c keys will contain 'geometry' and + 'recent files'. It will not contain 'background color' or + 'foreground color' because those keys contain entries not + subkeys. To get a list of keys that contain entries rather than + subkeys use entryList() instead. + + \warning In the above example, if TQSettings is writing to an Ini file, + then a call to + \code subkeyList("/MyCompany") \endcode + will return an empty list. This happens because a key like + \code /MyCompany/MyApplication/background color \endcode + is written to the file \e{"mycompanyrc"}, under the section \e{[MyApplication]}. + This call is therefore a request to list the sections in an ini file, which + is not supported in this version of TQSettings. This is a known issue which + will be fixed in TQt-4. + + \sa entryList() +*/ +TQStringList TQSettings::subkeyList(const TQString &key) const +{ + TQString grp_key( groupKey( group(), key ) ); + if ( !qt_verify_key( grp_key ) ) { +#if defined(QT_CHECK_STATE) + qWarning( "TQSettings::subkeyList: Invalid key: %s", grp_key.isNull() ? "(null)" : grp_key.latin1() ); +#endif + return TQStringList(); + } + +#if !defined(TQWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC)) + if ( d->sysd ) + return d->sysSubkeyList( grp_key ); +#endif + + TQString realkey; + int subkeycount = 2; + if (grp_key[0] == '/') { + // parse our key + TQStringList list(TQStringList::split('/', grp_key)); + + if (list.count() < 1) { +#ifdef QT_CHECK_STATE + qWarning("TQSettings::subkeyList: invalid key '%s'", grp_key.latin1()); +#endif // QT_CHECK_STATE + + return TQStringList(); + } + + subkeycount = (int)list.count(); + + if (list.count() == 1) { + d->heading = list[0]; + d->group = "General"; + } else { + d->heading = list[0]; + d->group = list[1]; + + // remove the group from the list + list.remove(list.at(1)); + // remove the heading from the list + list.remove(list.at(0)); + + realkey = list.join("/"); + } + + } else + realkey = grp_key; + + TQStringList ret; + if ( subkeycount == 1 ) { + TQMap::Iterator it = d->headings.begin(); + while ( it != d->headings.end() ) { + if ( it.key() != "General" && ! ret.contains( it.key() ) ) + ret << it.key(); + ++it; + } + + return ret; + } + + TQSettingsGroup grp = d->readGroup(); + TQSettingsGroup::Iterator it = grp.begin(); + TQString itkey; + while (it != grp.end()) { + itkey = it.key(); + ++it; + + if ( realkey.length() > 0 ) { + if ( itkey.left( realkey.length() ) != realkey + || itkey.length()+1 < realkey.length() + || itkey[(int)realkey.length()] != '/') + continue; + else + itkey.remove( 0, realkey.length() + 1 ); + } + + int slash = itkey.find( '/' ); + if ( slash == -1 ) + continue; + itkey.truncate( slash ); + + if ( ! ret.contains( itkey ) ) + ret << itkey; + } + + return ret; +} + + +/*! + \internal + + This function returns the time of last modification for \a key. +*/ +TQDateTime TQSettings::lastModificationTime( const TQString &key ) +{ + TQString grp_key( groupKey( group(), key ) ); + if ( !qt_verify_key( grp_key ) ) { +#if defined(QT_CHECK_STATE) + qWarning( "TQSettings::lastModificationTime: Invalid key '%s'", grp_key.isNull() ? "(null)" : grp_key.latin1() ); +#endif + return TQDateTime(); + } + +#if !defined(TQWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC)) + if ( d->sysd ) + return TQDateTime(); +#endif + + if (grp_key[0] == '/') { + // parse our key + TQStringList list(TQStringList::split('/', grp_key)); + + if (list.count() < 2) { +#ifdef QT_CHECK_STATE + qWarning("TQSettings::lastModificationTime: Invalid key '%s'", grp_key.latin1()); +#endif // QT_CHECK_STATE + + return TQDateTime(); + } + + if (list.count() == 2) { + d->heading = list[0]; + d->group = "General"; + } else { + d->heading = list[0]; + d->group = list[1]; + } + } + + return d->modificationTime(); +} + + +/*! + \overload + \obsolete + + Writes the string list entry \a value into key \a key. The \a key + is created if it doesn't exist. Any previous value is overwritten + by \a value. The list is stored as a sequence of strings separated + by \a separator (using TQStringList::join()), so none of the + strings in the list should contain the separator. If the list is + empty or null the key's value will be an empty string. + + \warning The list should not contain empty or null strings, as + readListEntry() will use TQStringList::split() to recreate the + list. As the documentation states, TQStringList::split() will omit + empty strings from the list. Because of this, it is impossible to + retrieve identical list data that is stored with this function. + We recommend using the writeEntry() and readListEntry() overloads + that do not take a \a separator argument. + + + If an error occurs the settings are left unchanged and FALSE is + returned; otherwise returns TRUE. + + \sa readListEntry(), readNumEntry(), readDoubleEntry(), readBoolEntry(), removeEntry(), TQStringList::join() +*/ +bool TQSettings::writeEntry(const TQString &key, const TQStringList &value, + const TQChar &separator) +{ + TQString s(value.join(separator)); + return writeEntry(key, s); +} + +/*! + \overload + + Writes the string list entry \a value into key \a key. The \a key + is created if it doesn't exist. Any previous value is overwritten + by \a value. + + If an error occurs the settings are left unchanged and FALSE is + returned; otherwise returns TRUE. + + \sa readListEntry(), readNumEntry(), readDoubleEntry(), readBoolEntry(), removeEntry() +*/ +bool TQSettings::writeEntry(const TQString &key, const TQStringList &value) +{ + TQString s; + for (TQStringList::ConstIterator it=value.begin(); it!=value.end(); ++it) { + TQString el = *it; + if ( el.isNull() ) { + el = "^0"; + } else { + el.replace("^", "^^"); + } + s+=el; + s+="^e"; // end of element + } + return writeEntry(key, s); +} + + +/*! + \overload TQStringList TQSettings::readListEntry(const TQString &key, const TQChar &separator, bool *ok ) const + \obsolete + + Reads the entry specified by \a key as a string. The \a separator + is used to create a TQStringList by calling TQStringList::split(\a + separator, entry). If \a ok is not 0: \a *ok is set to TRUE + if the key was read, otherwise \a *ok is set to FALSE. + + \warning As the documentation states, TQStringList::split() will + omit empty strings from the list. Because of this, it is + impossible to retrieve identical list data with this function. We + recommend using the readListEntry() and writeEntry() overloads + that do not take a \a separator argument. + + Note that if you want to iterate over the list, you should iterate + over a copy, e.g. + \code + TQStringList list = mySettings.readListEntry( "size", " " ); + TQStringList::Iterator it = list.begin(); + while( it != list.end() ) { + myProcessing( *it ); + ++it; + } + \endcode + + \sa readEntry(), readDoubleEntry(), readBoolEntry(), writeEntry(), removeEntry(), TQStringList::split() +*/ + +/*! + \internal +*/ +TQStringList TQSettings::readListEntry(const TQString &key, const TQChar &separator, bool *ok ) +{ + TQString value = readEntry( key, TQString::null, ok ); + if ( ok && !*ok ) + return TQStringList(); + + return TQStringList::split(separator, value); +} + +/*! + \fn TQStringList TQSettings::readListEntry(const TQString &key, bool *ok ) const + Reads the entry specified by \a key as a string. If \a ok is not + 0, \a *ok is set to TRUE if the key was read, otherwise \a *ok is + set to FALSE. + + Note that if you want to iterate over the list, you should iterate + over a copy, e.g. + \code + TQStringList list = mySettings.readListEntry( "recentfiles" ); + TQStringList::Iterator it = list.begin(); + while( it != list.end() ) { + myProcessing( *it ); + ++it; + } + \endcode + + \sa readEntry(), readDoubleEntry(), readBoolEntry(), writeEntry(), removeEntry(), TQStringList::split() +*/ + +/*! + \internal +*/ +TQStringList TQSettings::readListEntry(const TQString &key, bool *ok ) +{ + TQString value = readEntry( key, TQString::null, ok ); + if ( ok && !*ok ) + return TQStringList(); + TQStringList l; + TQString s; + bool esc=FALSE; + for (int i=0; i<(int)value.length(); i++) { + if ( esc ) { + if ( value[i] == 'e' ) { // end-of-string + l.append(s); + s=""; + } else if ( value[i] == '0' ) { // null string + s=TQString::null; + } else { + s.append(value[i]); + } + esc=FALSE; + } else if ( value[i] == '^' ) { + esc = TRUE; + } else { + s.append(value[i]); + if ( i == (int)value.length()-1 ) + l.append(s); + } + } + return l; +} + +#ifdef Q_OS_MAC +void qt_setSettingsBasePath(const TQString &); //qsettings_mac.cpp +#endif + +/*! + Insert platform-dependent paths from platform-independent information. + + The \a domain should be an Internet domain name + controlled by the producer of the software, eg. Trolltech products + use "trolltech.com". + + The \a product should be the official name of the product. + + The \a scope should be + TQSettings::User for user-specific settings, or + TQSettings::Global for system-wide settings (generally + these will be read-only to many users). + + Not all information is relevant on all systems. +*/ + +void TQSettings::setPath( const TQString &domain, const TQString &product, Scope scope ) +{ +// On Windows, any trailing ".com(\..*)" is stripped from the domain. The +// Global scope corresponds to HKEY_LOCAL_MACHINE, and User corresponds to +// HKEY_CURRENT_USER. Note that on some installations, not all users can +// write to the Global scope. On UNIX, any trailing ".com(\..*)" is stripped +// from the domain. The Global scope corresponds to "/opt" (this would be +// configurable at library build time - eg. to "/usr/local" or "/usr"), +// while the User scope corresponds to $HOME/.*rc. +// Note that on most installations, not all users can write to the System +// scope. +// +// On MacOS X, if there is no "." in domain, append ".com", then reverse the +// order of the elements (Mac OS uses "com.apple.finder" as domain+product). +// The Global scope corresponds to /Library/Preferences/*.plist, while the +// User scope corresponds to ~/Library/Preferences/*.plist. +// Note that on most installations, not all users can write to the System +// scope. + d->globalScope = scope == Global; + + TQString actualSearchPath; + int lastDot = domain.findRev( '.' ); + +#if defined(Q_WS_WIN) + actualSearchPath = "/" + domain.mid( 0, lastDot ) + "/" + product; + insertSearchPath( Windows, actualSearchPath ); +#elif !defined(TQWS) && defined(Q_OS_MAC) + if(lastDot != -1) { + TQString topLevelDomain = domain.right( domain.length() - lastDot - 1 ) + "."; + if ( !topLevelDomain.isEmpty() ) + qt_setSettingsBasePath( topLevelDomain ); + } + actualSearchPath = "/" + domain.left( lastDot ) + "." + product; + insertSearchPath( Mac, actualSearchPath ); +#else + if (scope == User) + actualSearchPath = TQDir::homeDirPath() + "/."; + else + actualSearchPath = TQString(qInstallPathSysconf()) + "/"; + actualSearchPath += domain.mid( 0, lastDot ) + "/" + product; + insertSearchPath( Unix, actualSearchPath ); +#endif +} + +/*! + Appends \a group to the current key prefix. + + \code + TQSettings settings; + settings.beginGroup( "/MainWindow" ); + // read values + settings.endGroup(); + \endcode +*/ +void TQSettings::beginGroup( const TQString &group ) +{ + d->groupStack.push( group ); + d->groupDirty = TRUE; +} + +/*! + Undo previous calls to beginGroup(). Note that a single beginGroup("a/b/c") is undone + by a single call to endGroup(). + + \code + TQSettings settings; + settings.beginGroup( "/MainWindow/Geometry" ); + // read values + settings.endGroup(); + \endcode +*/ +void TQSettings::endGroup() +{ + d->groupStack.pop(); + d->groupDirty = TRUE; +} + +/*! + Set the current key prefix to the empty string. +*/ +void TQSettings::resetGroup() +{ + d->groupStack.clear(); + d->groupDirty = FALSE; + d->groupPrefix = TQString::null; +} + +/*! + Returns the current key prefix, or a null string if there is no key prefix set. + + \sa beginGroup(); +*/ +TQString TQSettings::group() const +{ + if ( d->groupDirty ) { + d->groupDirty = FALSE; + d->groupPrefix = TQString::null; + + TQValueStack::Iterator it = d->groupStack.begin(); + while ( it != d->groupStack.end() ) { + TQString group = *it; + ++it; + if ( group[0] != '/' ) + group.prepend( "/" ); + d->groupPrefix += group; + } + } + return d->groupPrefix; +} + +#endif diff --git a/src/tools/qsettings.h b/src/tools/qsettings.h new file mode 100644 index 000000000..aebc2f211 --- /dev/null +++ b/src/tools/qsettings.h @@ -0,0 +1,159 @@ +/**************************************************************************** +** +** Definition of TQSettings class +** +** Created : 000626 +** +** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQSETTINGS_H +#define TQSETTINGS_H + +#ifndef QT_H +#include "qdatetime.h" +#include "qstringlist.h" +#endif // QT_H + +#ifndef QT_NO_SETTINGS + +class TQSettingsPrivate; + + +class Q_EXPORT TQSettings +{ +public: + enum Format { + Native = 0, + Ini + }; + enum System { + Unix = 0, + Windows, + Mac + }; + enum Scope { + User, + Global + }; + + TQSettings(); + TQSettings( Format format ); + + ~TQSettings(); + +#if !defined(Q_NO_BOOL_TYPE) + bool writeEntry( const TQString &, bool ); +#endif + bool writeEntry( const TQString &, double ); + bool writeEntry( const TQString &, int ); + bool writeEntry( const TQString &, const char * ); + bool writeEntry( const TQString &, const TQString & ); + bool writeEntry( const TQString &, const TQStringList & ); + bool writeEntry( const TQString &, const TQStringList &, const TQChar& sep ); + + TQStringList entryList(const TQString &) const; + TQStringList subkeyList(const TQString &) const; + + //### remove non const versions in 4.0 + TQStringList readListEntry( const TQString &, bool * = 0 ); + TQStringList readListEntry( const TQString &, const TQChar& sep, bool * = 0 ); + TQString readEntry( const TQString &, const TQString &def = TQString::null, bool * = 0 ); + int readNumEntry( const TQString &, int def = 0, bool * = 0 ); + double readDoubleEntry( const TQString &, double def = 0, bool * = 0 ); + bool readBoolEntry( const TQString &, bool def = FALSE, bool * = 0 ); + + //### make those non-inlined in 4.0 + TQStringList readListEntry( const TQString &key, bool *ok = 0 ) const + { + TQSettings *that = (TQSettings*)this; + return that->readListEntry( key, ok ); + } + TQStringList readListEntry( const TQString &key, const TQChar& sep, bool *ok = 0 ) const + { + TQSettings *that = (TQSettings*)this; + return that->readListEntry( key, sep, ok ); + } + TQString readEntry( const TQString &key, const TQString &def = TQString::null, + bool *ok = 0 ) const + { + TQSettings *that = (TQSettings*)this; + return that->readEntry( key, def, ok ); + } + int readNumEntry( const TQString &key, int def = 0, bool *ok = 0 ) const + { + TQSettings *that = (TQSettings*)this; + return that->readNumEntry( key, def, ok ); + } + + double readDoubleEntry( const TQString &key, double def = 0, bool *ok = 0 ) const + { + TQSettings *that = (TQSettings*)this; + return that->readDoubleEntry( key, def, ok ); + } + bool readBoolEntry( const TQString &key, bool def = FALSE, bool *ok = 0 ) const + { + TQSettings *that = (TQSettings*)this; + return that->readBoolEntry( key, def, ok ); + } + + bool removeEntry( const TQString & ); + + void insertSearchPath( System, const TQString & ); + void removeSearchPath( System, const TQString & ); + + void setPath( const TQString &domain, const TQString &product, Scope = Global ); + + void beginGroup( const TQString &group ); + void endGroup(); + void resetGroup(); + TQString group() const; + + bool sync(); + +private: + TQSettingsPrivate *d; + +#if defined(Q_DISABLE_COPY) + TQSettings(const TQSettings &); + TQSettings &operator=(const TQSettings &); +#endif + + TQDateTime lastModificationTime( const TQString & ); + + friend class TQApplication; +}; + +#endif // QT_NO_SETTINGS +#endif // TQSETTINGS_H diff --git a/src/tools/qsettings_p.h b/src/tools/qsettings_p.h new file mode 100644 index 000000000..7f13412af --- /dev/null +++ b/src/tools/qsettings_p.h @@ -0,0 +1,148 @@ +/**************************************************************************** +** +** Definition of TQSettings related classes +** +** Created : 990124 +** +** Copyright (C) 1999-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the kernel module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQSETTINGS_P_H +#define TQSETTINGS_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the TQt API. It exists for the convenience +// of TQSettings. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// +// + +#ifndef QT_H +#include "qstringlist.h" +#include "qmap.h" +#include "qvaluestack.h" +#endif // QT_H + +#ifndef QT_NO_SETTINGS +class TQSettingsSysPrivate; + +// TQSettingsGroup is a map of key/value pairs +class TQSettingsGroup : public TQMap +{ +public: + TQSettingsGroup(); + + bool modified; +}; + +// TQSettingsHeading is a map of heading/group pairs +class TQSettingsHeading : public TQMap +{ +public: + TQSettingsHeading::Iterator git; + void read(const TQString &); + void parseLine(TQTextStream &); +}; + + +class TQSettingsPrivate +{ +public: + TQSettingsPrivate( TQSettings::Format format ); + ~TQSettingsPrivate(); + + TQSettingsGroup readGroup(); + void removeGroup(const TQString &); + void writeGroup(const TQString &, const TQString &); + TQDateTime modificationTime(); + + TQStringList searchPaths; + TQMap headings; + TQString group; + TQString heading; + + /*### static data brings threading trouble + static TQString *defProduct; + static TQString *defDomain; + */ + TQValueStack groupStack; + TQString groupPrefix; + + bool groupDirty :1; + bool modified :1; + bool globalScope :1; + +#if !defined(TQWS) && (defined(Q_WS_WIN) || defined(Q_OS_MAC)) + // system dependent implementations to use the + // system specific setting database (ie. registry on Windows) + + TQSettingsSysPrivate *sysd; + void sysInit(); + void sysClear(); + +#if !defined(Q_NO_BOOL_TYPE) + bool sysWriteEntry( const TQString &, bool ); +#endif + bool sysWriteEntry( const TQString &, double ); + bool sysWriteEntry( const TQString &, int ); + bool sysWriteEntry( const TQString &, const TQString & ); + bool sysWriteEntry( const TQString &, const TQStringList & ); + bool sysWriteEntry( const TQString &, const TQStringList &, const TQChar& sep ); + + TQStringList sysEntryList(const TQString &) const; + TQStringList sysSubkeyList(const TQString &) const; + + TQStringList sysReadListEntry( const TQString &, bool * = 0 ) const; + TQStringList sysReadListEntry( const TQString &, const TQChar& sep, bool * = 0 ) const; + TQString sysReadEntry( const TQString &, const TQString &def = TQString::null, bool * = 0 ) const; + int sysReadNumEntry( const TQString &, int def = 0, bool * = 0 ) const; + double sysReadDoubleEntry( const TQString &, double def = 0, bool * = 0 ) const; + bool sysReadBoolEntry( const TQString &, bool def = 0, bool * = 0 ) const; + + bool sysRemoveEntry( const TQString & ); + + bool sysSync(); + + void sysInsertSearchPath( TQSettings::System, const TQString & ); + void sysRemoveSearchPath( TQSettings::System, const TQString & ); +#endif + +}; +#endif //QT_NO_SETTINGS +#endif // TQSETTINGS_P_H diff --git a/src/tools/qshared.h b/src/tools/qshared.h new file mode 100644 index 000000000..8b3189b76 --- /dev/null +++ b/src/tools/qshared.h @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Definition of TQShared struct +** +** Created : 940112 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQSHARED_H +#define TQSHARED_H + +#ifndef QT_H +#include "qglobal.h" +#endif // QT_H + + +struct Q_EXPORT TQShared +{ + TQShared() : count( 1 ) { } + void ref() { count++; } + bool deref() { return !--count; } + uint count; +}; + + +#endif // TQSHARED_H diff --git a/src/tools/qsortedlist.h b/src/tools/qsortedlist.h new file mode 100644 index 000000000..62c91d7ce --- /dev/null +++ b/src/tools/qsortedlist.h @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Definition of TQSortedList template/macro class +** +** Created : 920701 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQSORTEDLIST_H +#define TQSORTEDLIST_H + +#ifndef QT_H +#include "qptrlist.h" +#endif // QT_H + + +template +class TQSortedList : public TQPtrList +{ +public: + TQSortedList() {} + TQSortedList( const TQSortedList &l ) : TQPtrList(l) {} + ~TQSortedList() { this->clear(); } + TQSortedList &operator=(const TQSortedList &l) + { return (TQSortedList&)TQPtrList::operator=(l); } + + virtual int compareItems( TQPtrCollection::Item s1, TQPtrCollection::Item s2 ) + { if ( *((type*)s1) == *((type*)s2) ) return 0; return ( *((type*)s1) < *((type*)s2) ? -1 : 1 ); } +}; + +#endif diff --git a/src/tools/qstring.cpp b/src/tools/qstring.cpp new file mode 100644 index 000000000..00e4b2390 --- /dev/null +++ b/src/tools/qstring.cpp @@ -0,0 +1,7179 @@ +/**************************************************************************** +** +** Implementation of the TQString class and related Unicode functions +** +** Created : 920722 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +// Don't define it while compiling this module, or USERS of TQt will +// not be able to link. +#ifdef QT_NO_CAST_ASCII +#undef QT_NO_CAST_ASCII +#endif + +#include "qstring.h" +#include "qregexp.h" +#include "qdatastream.h" +#ifndef QT_NO_TEXTCODEC +#include "qtextcodec.h" +#endif +#include "qlocale.h" +#include "qlocale_p.h" + +#include "qunicodetables_p.h" +#include +#include +#include +#include +#include +#ifndef Q_OS_TEMP +#include +#endif +#if defined(Q_WS_WIN) +#include "qt_windows.h" +#endif +#if !defined( QT_NO_COMPONENT ) && !defined( QT_LITE_COMPONENT ) +#include "qcleanuphandler.h" +#endif + +#ifndef LLONG_MAX +#define LLONG_MAX Q_INT64_C(9223372036854775807) +#endif +#ifndef LLONG_MIN +#define LLONG_MIN (-LLONG_MAX - Q_INT64_C(1)) +#endif +#ifndef ULLONG_MAX +#define ULLONG_MAX Q_UINT64_C(18446744073709551615) +#endif + +static int ucstrcmp( const TQString &as, const TQString &bs ) +{ + const TQChar *a = as.unicode(); + const TQChar *b = bs.unicode(); + if ( a == b ) + return 0; + if ( a == 0 ) + return 1; + if ( b == 0 ) + return -1; + int l=TQMIN(as.length(),bs.length()); + while ( l-- && *a == *b ) + a++,b++; + if ( l==-1 ) + return ( as.length()-bs.length() ); + return a->unicode() - b->unicode(); +} + +static int ucstrncmp( const TQChar *a, const TQChar *b, int l ) +{ + while ( l-- && *a == *b ) + a++,b++; + if ( l==-1 ) + return 0; + return a->unicode() - b->unicode(); +} + +static int ucstrnicmp( const TQChar *a, const TQChar *b, int l ) +{ + while ( l-- && ::lower( *a ) == ::lower( *b ) ) + a++,b++; + if ( l==-1 ) + return 0; + return ::lower( *a ).unicode() - ::lower( *b ).unicode(); +} + +static uint computeNewMax( uint len ) +{ + if (len >= 0x80000000) + return len; + + uint newMax = 4; + while ( newMax < len ) + newMax *= 2; + // try to save some memory + if ( newMax >= 1024 * 1024 && len <= newMax - (newMax >> 2) ) + newMax -= newMax >> 2; + return newMax; +} + +static bool qIsUpper(char c) +{ + return c >= 'A' && c <= 'Z'; +} + +static bool qIsDigit(char c) +{ + return c >= '0' && c <= '9'; +} + +static char qToLower(char c) +{ + if (c >= 'A' && c <= 'Z') + return c - 'A' + 'a'; + else + return c; +} + +/*! + \class TQCharRef qstring.h + \reentrant + \brief The TQCharRef class is a helper class for TQString. + + \ingroup text + + When you get an object of type TQCharRef, if you can assign to it, + the assignment will apply to the character in the string from + which you got the reference. That is its whole purpose in life. + The TQCharRef becomes invalid once modifications are made to the + string: if you want to keep the character, copy it into a TQChar. + + Most of the TQChar member functions also exist in TQCharRef. + However, they are not explicitly documented here. + + \sa TQString::operator[]() TQString::at() TQChar +*/ + +/*! + \class TQChar qstring.h + \reentrant + \brief The TQChar class provides a lightweight Unicode character. + + \ingroup text + + Unicode characters are (so far) 16-bit entities without any markup + or structure. This class represents such an entity. It is + lightweight, so it can be used everywhere. Most compilers treat it + like a "short int". (In a few years it may be necessary to make + TQChar 32-bit when more than 65536 Unicode code points have been + defined and come into use.) + + TQChar provides a full complement of testing/classification + functions, converting to and from other formats, converting from + composed to decomposed Unicode, and trying to compare and + case-convert if you ask it to. + + The classification functions include functions like those in + ctype.h, but operating on the full range of Unicode characters. + They all return TRUE if the character is a certain type of + character; otherwise they return FALSE. These classification + functions are isNull() (returns TRUE if the character is U+0000), + isPrint() (TRUE if the character is any sort of printable + character, including whitespace), isPunct() (any sort of + punctation), isMark() (Unicode Mark), isLetter (a letter), + isNumber() (any sort of numeric character), isLetterOrNumber(), + and isDigit() (decimal digits). All of these are wrappers around + category() which return the Unicode-defined category of each + character. + + TQChar further provides direction(), which indicates the "natural" + writing direction of this character. The joining() function + indicates how the character joins with its neighbors (needed + mostly for Arabic) and finally mirrored(), which indicates whether + the character needs to be mirrored when it is printed in its + "unnatural" writing direction. + + Composed Unicode characters (like å) can be converted to + decomposed Unicode ("a" followed by "ring above") by using + decomposition(). + + In Unicode, comparison is not necessarily possible and case + conversion is very difficult at best. Unicode, covering the + "entire" world, also includes most of the world's case and sorting + problems. TQt tries, but not very hard: operator==() and friends + will do comparison based purely on the numeric Unicode value (code + point) of the characters, and upper() and lower() will do case + changes when the character has a well-defined upper/lower-case + equivalent. There is no provision for locale-dependent case + folding rules or comparison; these functions are meant to be fast + so they can be used unambiguously in data structures. (See + TQString::localeAwareCompare() though.) + + The conversion functions include unicode() (to a scalar), latin1() + (to scalar, but converts all non-Latin-1 characters to 0), row() + (gives the Unicode row), cell() (gives the Unicode cell), + digitValue() (gives the integer value of any of the numerous digit + characters), and a host of constructors. + + More information can be found in the document \link unicode.html + About Unicode. \endlink + + \sa TQString TQCharRef +*/ + +/*! + \enum TQChar::Category + + This enum maps the Unicode character categories. + + The following characters are normative in Unicode: + + \value Mark_NonSpacing Unicode class name Mn + + \value Mark_SpacingCombining Unicode class name Mc + + \value Mark_Enclosing Unicode class name Me + + \value Number_DecimalDigit Unicode class name Nd + + \value Number_Letter Unicode class name Nl + + \value Number_Other Unicode class name No + + \value Separator_Space Unicode class name Zs + + \value Separator_Line Unicode class name Zl + + \value Separator_Paragraph Unicode class name Zp + + \value Other_Control Unicode class name Cc + + \value Other_Format Unicode class name Cf + + \value Other_Surrogate Unicode class name Cs + + \value Other_PrivateUse Unicode class name Co + + \value Other_NotAssigned Unicode class name Cn + + + The following categories are informative in Unicode: + + \value Letter_Uppercase Unicode class name Lu + + \value Letter_Lowercase Unicode class name Ll + + \value Letter_Titlecase Unicode class name Lt + + \value Letter_Modifier Unicode class name Lm + + \value Letter_Other Unicode class name Lo + + \value Punctuation_Connector Unicode class name Pc + + \value Punctuation_Dash Unicode class name Pd + + \value Punctuation_Open Unicode class name Ps + + \value Punctuation_Close Unicode class name Pe + + \value Punctuation_InitialQuote Unicode class name Pi + + \value Punctuation_FinalQuote Unicode class name Pf + + \value Punctuation_Other Unicode class name Po + + \value Symbol_Math Unicode class name Sm + + \value Symbol_Currency Unicode class name Sc + + \value Symbol_Modifier Unicode class name Sk + + \value Symbol_Other Unicode class name So + + + There are two categories that are specific to TQt: + + \value NoCategory used when TQt is dazed and confused and cannot + make sense of anything. + + \value Punctuation_Dask old typo alias for Punctuation_Dash + +*/ + +/*! + \enum TQChar::Direction + + This enum type defines the Unicode direction attributes. See \link + http://www.unicode.org/ the Unicode Standard\endlink for a + description of the values. + + In order to conform to C/C++ naming conventions "Dir" is prepended + to the codes used in the Unicode Standard. +*/ + +/*! + \enum TQChar::Decomposition + + This enum type defines the Unicode decomposition attributes. See + \link http://www.unicode.org/ the Unicode Standard\endlink for a + description of the values. +*/ + +/*! + \enum TQChar::Joining + + This enum type defines the Unicode joining attributes. See \link + http://www.unicode.org/ the Unicode Standard\endlink for a + description of the values. +*/ + +/*! + \enum TQChar::CombiningClass + + This enum type defines names for some of the Unicode combining + classes. See \link http://www.unicode.org/ the Unicode + Standard\endlink for a description of the values. +*/ + +/*! + \fn void TQChar::setCell( uchar cell ) + \internal +*/ + +/*! + \fn void TQChar::setRow( uchar row ) + \internal +*/ + + +/*! + \fn TQChar::TQChar() + + Constructs a null TQChar (one that isNull()). +*/ + + +/*! + \fn TQChar::TQChar( char c ) + + Constructs a TQChar corresponding to ASCII/Latin-1 character \a c. +*/ + + +/*! + \fn TQChar::TQChar( uchar c ) + + Constructs a TQChar corresponding to ASCII/Latin-1 character \a c. +*/ + + +/*! + \fn TQChar::TQChar( uchar c, uchar r ) + + Constructs a TQChar for Unicode cell \a c in row \a r. +*/ + + +/*! + \fn TQChar::TQChar( const TQChar& c ) + + Constructs a copy of \a c. This is a deep copy, if such a + lightweight object can be said to have deep copies. +*/ + + +/*! + \fn TQChar::TQChar( ushort rc ) + + Constructs a TQChar for the character with Unicode code point \a rc. +*/ + + +/*! + \fn TQChar::TQChar( short rc ) + + Constructs a TQChar for the character with Unicode code point \a rc. +*/ + + +/*! + \fn TQChar::TQChar( uint rc ) + + Constructs a TQChar for the character with Unicode code point \a rc. +*/ + + +/*! + \fn TQChar::TQChar( int rc ) + + Constructs a TQChar for the character with Unicode code point \a rc. +*/ + + +/*! + \fn bool TQChar::networkOrdered () + + \obsolete + + Returns TRUE if this character is in network byte order (MSB + first); otherwise returns FALSE. This is platform dependent. +*/ + + +/*! + \fn bool TQChar::isNull() const + + Returns TRUE if the character is the Unicode character 0x0000 + (ASCII NUL); otherwise returns FALSE. +*/ + +/*! + \fn uchar TQChar::cell () const + + Returns the cell (least significant byte) of the Unicode + character. +*/ + +/*! + \fn uchar TQChar::row () const + + Returns the row (most significant byte) of the Unicode character. +*/ + +/*! + Returns TRUE if the character is a printable character; otherwise + returns FALSE. This is any character not of category Cc or Cn. + + Note that this gives no indication of whether the character is + available in a particular \link TQFont font\endlink. +*/ +bool TQChar::isPrint() const +{ + Category c = ::category( *this ); + return !(c == Other_Control || c == Other_NotAssigned); +} + +/*! + Returns TRUE if the character is a separator character + (Separator_* categories); otherwise returns FALSE. +*/ +bool TQChar::isSpace() const +{ + return ::isSpace( *this ); +} + +/*! + Returns TRUE if the character is a mark (Mark_* categories); + otherwise returns FALSE. +*/ +bool TQChar::isMark() const +{ + Category c = ::category( *this ); + return c >= Mark_NonSpacing && c <= Mark_Enclosing; +} + +/*! + Returns TRUE if the character is a punctuation mark (Punctuation_* + categories); otherwise returns FALSE. +*/ +bool TQChar::isPunct() const +{ + Category c = ::category( *this ); + return (c >= Punctuation_Connector && c <= Punctuation_Other); +} + +/*! + Returns TRUE if the character is a letter (Letter_* categories); + otherwise returns FALSE. +*/ +bool TQChar::isLetter() const +{ + Category c = ::category( *this ); + return (c >= Letter_Uppercase && c <= Letter_Other); +} + +/*! + Returns TRUE if the character is a number (of any sort - Number_* + categories); otherwise returns FALSE. + + \sa isDigit() +*/ +bool TQChar::isNumber() const +{ + Category c = ::category( *this ); + return c >= Number_DecimalDigit && c <= Number_Other; +} + +/*! + Returns TRUE if the character is a letter or number (Letter_* or + Number_* categories); otherwise returns FALSE. +*/ +bool TQChar::isLetterOrNumber() const +{ + Category c = ::category( *this ); + return (c >= Letter_Uppercase && c <= Letter_Other) + || (c >= Number_DecimalDigit && c <= Number_Other); +} + + +/*! + Returns TRUE if the character is a decimal digit + (Number_DecimalDigit); otherwise returns FALSE. +*/ +bool TQChar::isDigit() const +{ + return (::category( *this ) == Number_DecimalDigit); +} + + +/*! + Returns TRUE if the character is a symbol (Symbol_* categories); + otherwise returns FALSE. +*/ +bool TQChar::isSymbol() const +{ + Category c = ::category( *this ); + return c >= Symbol_Math && c <= Symbol_Other; +} + +/*! + Returns the numeric value of the digit, or -1 if the character is + not a digit. +*/ +int TQChar::digitValue() const +{ +#ifndef QT_NO_UNICODETABLES + register int pos = TQUnicodeTables::decimal_info[row()]; + if( !pos ) + return -1; + return TQUnicodeTables::decimal_info[(pos<<8) + cell()]; +#else + // ##### just latin1 + if ( ucs < '0' || ucs > '9' ) + return -1; + else + return ucs - '0'; +#endif +} + +/*! + Returns the character category. + + \sa Category +*/ +TQChar::Category TQChar::category() const +{ + return ::category( *this ); +} + +/*! + Returns the character's direction. + + \sa Direction +*/ +TQChar::Direction TQChar::direction() const +{ + return ::direction( *this ); +} + +/*! + \warning This function is not supported (it may change to use + Unicode character classes). + + Returns information about the joining properties of the character + (needed for example, for Arabic). +*/ +TQChar::Joining TQChar::joining() const +{ + return ::joining( *this ); +} + + +/*! + Returns TRUE if the character is a mirrored character (one that + should be reversed if the text direction is reversed); otherwise + returns FALSE. +*/ +bool TQChar::mirrored() const +{ + return ::mirrored( *this ); +} + +/*! + Returns the mirrored character if this character is a mirrored + character, otherwise returns the character itself. +*/ +TQChar TQChar::mirroredChar() const +{ + return ::mirroredChar( *this ); +} + +#ifndef QT_NO_UNICODETABLES +// ### REMOVE ME 4.0 +static TQString shared_decomp; +#endif +/*! + \nonreentrant + + Decomposes a character into its parts. Returns TQString::null if no + decomposition exists. +*/ +const TQString &TQChar::decomposition() const +{ +#ifndef QT_NO_UNICODETABLES + register int pos = TQUnicodeTables::decomposition_info[row()]; + if(!pos) return TQString::null; + + pos = TQUnicodeTables::decomposition_info[(pos<<8)+cell()]; + if(!pos) return TQString::null; + pos+=2; + + TQString s; + Q_UINT16 c; + while ( (c = TQUnicodeTables::decomposition_map[pos++]) != 0 ) + s += TQChar( c ); + // ### In 4.0, return s, and not shared_decomp. shared_decomp + // prevents this function from being reentrant. + shared_decomp = s; + return shared_decomp; +#else + return TQString::null; +#endif +} + +/*! + Returns the tag defining the composition of the character. Returns + TQChar::Single if no decomposition exists. +*/ +TQChar::Decomposition TQChar::decompositionTag() const +{ +#ifndef QT_NO_UNICODETABLES + register int pos = TQUnicodeTables::decomposition_info[row()]; + if(!pos) return TQChar::Single; + + pos = TQUnicodeTables::decomposition_info[(pos<<8)+cell()]; + if(!pos) return TQChar::Single; + + return (TQChar::Decomposition) TQUnicodeTables::decomposition_map[pos]; +#else + return Single; // ########### FIX eg. just latin1 +#endif +} + +/*! + Returns the combining class for the character as defined in the + Unicode standard. This is mainly useful as a positioning hint for + marks attached to a base character. + + The TQt text rendering engine uses this information to correctly + position non spacing marks around a base character. +*/ +unsigned char TQChar::combiningClass() const +{ + return ::combiningClass( *this ); +} + + +/*! + Returns the lowercase equivalent if the character is uppercase; + otherwise returns the character itself. +*/ +TQChar TQChar::lower() const +{ + return ::lower( *this ); +} + +/*! + Returns the uppercase equivalent if the character is lowercase; + otherwise returns the character itself. +*/ +TQChar TQChar::upper() const +{ + return ::upper( *this ); +} + +/*! + \fn TQChar::operator char() const + + Returns the Latin-1 character equivalent to the TQChar, or 0. This + is mainly useful for non-internationalized software. + + \sa unicode() +*/ + +/*! + \fn ushort TQChar::unicode() const + + Returns the numeric Unicode value equal to the TQChar. Normally, + you should use TQChar objects as they are equivalent, but for some + low-level tasks (e.g. indexing into an array of Unicode + information), this function is useful. +*/ + +/*! + \fn ushort & TQChar::unicode() + + \overload + + Returns a reference to the numeric Unicode value equal to the + TQChar. +*/ + +/***************************************************************************** + Documentation of TQChar related functions + *****************************************************************************/ + +/*! + \fn bool operator==( TQChar c1, TQChar c2 ) + + \relates TQChar + + Returns TRUE if \a c1 and \a c2 are the same Unicode character; + otherwise returns FALSE. +*/ + +/*! + \fn bool operator==( char ch, TQChar c ) + + \overload + \relates TQChar + + Returns TRUE if \a c is the ASCII/Latin-1 character \a ch; + otherwise returns FALSE. +*/ + +/*! + \fn bool operator==( TQChar c, char ch ) + + \overload + \relates TQChar + + Returns TRUE if \a c is the ASCII/Latin-1 character \a ch; + otherwise returns FALSE. +*/ + +/*! + \fn int operator!=( TQChar c1, TQChar c2 ) + + \relates TQChar + + Returns TRUE if \a c1 and \a c2 are not the same Unicode + character; otherwise returns FALSE. +*/ + +/*! + \fn int operator!=( char ch, TQChar c ) + + \overload + \relates TQChar + + Returns TRUE if \a c is not the ASCII/Latin-1 character \a ch; + otherwise returns FALSE. +*/ + +/*! + \fn int operator!=( TQChar c, char ch ) + + \overload + \relates TQChar + + Returns TRUE if \a c is not the ASCII/Latin-1 character \a ch; + otherwise returns FALSE. +*/ + +/*! + \fn int operator<=( TQChar c1, TQChar c2 ) + + \relates TQChar + + Returns TRUE if the numeric Unicode value of \a c1 is less than + that of \a c2, or they are the same Unicode character; otherwise + returns FALSE. +*/ + +/*! + \fn int operator<=( TQChar c, char ch ) + + \overload + \relates TQChar + + Returns TRUE if the numeric Unicode value of \a c is less than or + equal to that of the ASCII/Latin-1 character \a ch; otherwise + returns FALSE. +*/ + +/*! + \fn int operator<=( char ch, TQChar c ) + + \overload + \relates TQChar + + Returns TRUE if the numeric Unicode value of the ASCII/Latin-1 + character \a ch is less than or equal to that of \a c; otherwise + returns FALSE. +*/ + +/*! + \fn int operator>=( TQChar c1, TQChar c2 ) + + \relates TQChar + + Returns TRUE if the numeric Unicode value of \a c1 is greater than + that of \a c2, or they are the same Unicode character; otherwise + returns FALSE. +*/ + +/*! + \fn int operator>=( TQChar c, char ch ) + + \overload + \relates TQChar + + Returns TRUE if the numeric Unicode value of \a c is greater than + or equal to that of the ASCII/Latin-1 character \a ch; otherwise + returns FALSE. +*/ + +/*! + \fn int operator>=( char ch, TQChar c ) + + \overload + \relates TQChar + + Returns TRUE if the numeric Unicode value of the ASCII/Latin-1 + character \a ch is greater than or equal to that of \a c; + otherwise returns FALSE. +*/ + +/*! + \fn int operator<( TQChar c1, TQChar c2 ) + + \relates TQChar + + Returns TRUE if the numeric Unicode value of \a c1 is less than + that of \a c2; otherwise returns FALSE. +*/ + +/*! + \fn int operator<( TQChar c, char ch ) + + \overload + \relates TQChar + + Returns TRUE if the numeric Unicode value of \a c is less than that + of the ASCII/Latin-1 character \a ch; otherwise returns FALSE. +*/ + +/*! + \fn int operator<( char ch, TQChar c ) + + \overload + \relates TQChar + + Returns TRUE if the numeric Unicode value of the ASCII/Latin-1 + character \a ch is less than that of \a c; otherwise returns + FALSE. +*/ + +/*! + \fn int operator>( TQChar c1, TQChar c2 ) + + \relates TQChar + + Returns TRUE if the numeric Unicode value of \a c1 is greater than + that of \a c2; otherwise returns FALSE. +*/ + +/*! + \fn int operator>( TQChar c, char ch ) + + \overload + \relates TQChar + + Returns TRUE if the numeric Unicode value of \a c is greater than + that of the ASCII/Latin-1 character \a ch; otherwise returns FALSE. +*/ + +/*! + \fn int operator>( char ch, TQChar c ) + + \overload + \relates TQChar + + Returns TRUE if the numeric Unicode value of the ASCII/Latin-1 + character \a ch is greater than that of \a c; otherwise returns + FALSE. +*/ + +#ifndef QT_NO_UNICODETABLES + +// small class used internally in TQString::Compose() +class TQLigature +{ +public: + TQLigature( TQChar c ); + + Q_UINT16 first() { cur = ligatures; return cur ? *cur : 0; } + Q_UINT16 next() { return cur && *cur ? *(cur++) : 0; } + Q_UINT16 current() { return cur ? *cur : 0; } + + int match(TQString & str, unsigned int index); + TQChar head(); + TQChar::Decomposition tag(); + +private: + Q_UINT16 *ligatures; + Q_UINT16 *cur; +}; + +TQLigature::TQLigature( TQChar c ) +{ + register int pos = TQUnicodeTables::ligature_info[c.row()]; + if( !pos ) + ligatures = 0; + else + { + pos = TQUnicodeTables::ligature_info[(pos<<8)+c.cell()]; + ligatures = (Q_UINT16 *)&(TQUnicodeTables::ligature_map[pos]); + } + cur = ligatures; +} + +TQChar TQLigature::head() +{ + if(current()) + return TQChar(TQUnicodeTables::decomposition_map[current()+1]); + + return TQChar::null; +} + +TQChar::Decomposition TQLigature::tag() +{ + if(current()) + return (TQChar::Decomposition) TQUnicodeTables::decomposition_map[current()]; + + return TQChar::Canonical; +} + +int TQLigature::match(TQString & str, unsigned int index) +{ + unsigned int i=index; + + if(!current()) return 0; + + Q_UINT16 lig = current() + 2; + Q_UINT16 ch; + + while ((i < str.length()) && (ch = TQUnicodeTables::decomposition_map[lig])) { + if (str[(int)i] != TQChar(ch)) + return 0; + i++; + lig++; + } + + if (!TQUnicodeTables::decomposition_map[lig]) + { + return i-index; + } + return 0; +} + + +// this function is just used in TQString::compose() +static inline bool format(TQChar::Decomposition tag, TQString & str, + int index, int len) +{ + unsigned int l = index + len; + unsigned int r = index; + + bool left = FALSE, right = FALSE; + + left = ((l < str.length()) && + ((str[(int)l].joining() == TQChar::Dual) || + (str[(int)l].joining() == TQChar::Right))); + if (r > 0) { + r--; + //printf("joining(right) = %d\n", str[(int)r].joining()); + right = (str[(int)r].joining() == TQChar::Dual); + } + + + switch (tag) { + case TQChar::Medial: + return (left & right); + case TQChar::Initial: + return (left && !right); + case TQChar::Final: + return (right);// && !left); + case TQChar::Isolated: + default: + return (!right && !left); + } +} // format() +#endif + +/* + TQString::compose() and visual() were developed by Gordon Tisher + , with input from Lars Knoll , + who developed the unicode data tables. +*/ +/*! + \warning This function is not supported in TQt 3.x. It is provided + for experimental and illustrative purposes only. It is mainly of + interest to those experimenting with Arabic and other + composition-rich texts. + + Applies possible ligatures to a TQString. Useful when + composition-rich text retquires rendering with glyph-poor fonts, + but it also makes compositions such as TQChar(0x0041) ('A') and + TQChar(0x0308) (Unicode accent diaresis), giving TQChar(0x00c4) + (German A Umlaut). +*/ +void TQString::compose() +{ +#ifndef QT_NO_UNICODETABLES + unsigned int index=0, len; + unsigned int cindex = 0; + + TQChar code, head; + + TQMemArray dia; + + TQString composed = *this; + + while (index < length()) { + code = at(index); + //printf("\n\nligature for 0x%x:\n", code.unicode()); + TQLigature ligature(code); + ligature.first(); + while ( ligature.current() ) { + if ((len = ligature.match(*this, index)) != 0) { + head = ligature.head(); + unsigned short code = head.unicode(); + // we exclude Arabic presentation forms A and a few + // other ligatures, which are undefined in most fonts + if(!(code > 0xfb50 && code < 0xfe80) && + !(code > 0xfb00 && code < 0xfb2a)) { + // joining info is only needed for Arabic + if (format(ligature.tag(), *this, index, len)) { + //printf("using ligature 0x%x, len=%d\n",code,len); + // replace letter + composed.replace(cindex, len, TQChar(head)); + index += len-1; + // we continue searching in case we have a final + // form because medial ones are preferred. + if ( len != 1 || ligature.tag() !=TQChar::Final ) + break; + } + } + } + ligature.next(); + } + cindex++; + index++; + } + *this = composed; +#endif +} + + +// These macros are used for efficient allocation of TQChar strings. +// IMPORTANT! If you change these, make sure you also change the +// "delete unicode" statement in ~TQStringData() in qstring.h correspondingly! + +#define QT_ALLOC_QCHAR_VEC( N ) (TQChar*) new char[ sizeof(TQChar)*( N ) ] +#define QT_DELETE_QCHAR_VEC( P ) delete[] ((char*)( P )) + + +/*! + This utility function converts the 8-bit string \a ba to Unicode, + returning the result. + + The caller is responsible for deleting the return value with + delete[]. +*/ + +TQChar* TQString::latin1ToUnicode( const TQByteArray& ba, uint* len ) +{ + if ( ba.isNull() ) { + *len = 0; + return 0; + } + int l = 0; + while ( l < (int)ba.size() && ba[l] ) + l++; + char* str = ba.data(); + TQChar *uc = new TQChar[ l ]; // Can't use macro, since function is public + TQChar *result = uc; + if ( len ) + *len = l; + while (l--) + *uc++ = *str++; + return result; +} + +static TQChar* internalLatin1ToUnicode( const TQByteArray& ba, uint* len ) +{ + if ( ba.isNull() ) { + *len = 0; + return 0; + } + int l = 0; + while ( l < (int)ba.size() && ba[l] ) + l++; + char* str = ba.data(); + TQChar *uc = QT_ALLOC_QCHAR_VEC( l ); + TQChar *result = uc; + if ( len ) + *len = l; + while (l--) + *uc++ = *str++; + return result; +} + +/*! + \overload + + This utility function converts the '\0'-terminated 8-bit string \a + str to Unicode, returning the result and setting \a *len to the + length of the Unicode string. + + The caller is responsible for deleting the return value with + delete[]. +*/ + +TQChar* TQString::latin1ToUnicode( const char *str, uint* len, uint maxlen ) +{ + TQChar* result = 0; + uint l = 0; + if ( str ) { + if ( maxlen != (uint)-1 ) { + while ( l < maxlen && str[l] ) + l++; + } else { + // Faster? + l = int(strlen( str )); + } + TQChar *uc = new TQChar[ l ]; // Can't use macro since function is public + result = uc; + uint i = l; + while ( i-- ) + *uc++ = *str++; + } + if ( len ) + *len = l; + return result; +} + +static TQChar* internalLatin1ToUnicode( const char *str, uint* len, + uint maxlen = (uint)-1 ) +{ + TQChar* result = 0; + uint l = 0; + if ( str ) { + if ( maxlen != (uint)-1 ) { + while ( l < maxlen && str[l] ) + l++; + } else { + // Faster? + l = int(strlen( str )); + } + TQChar *uc = QT_ALLOC_QCHAR_VEC( l ); + result = uc; + uint i = l; + while ( i-- ) + *uc++ = *str++; + } + if ( len ) + *len = l; + return result; +} + +/*! + This utility function converts \a l 16-bit characters from \a uc + to ASCII, returning a '\0'-terminated string. + + The caller is responsible for deleting the resultant string with + delete[]. +*/ +char* TQString::unicodeToLatin1(const TQChar *uc, uint l) +{ + if (!uc) { + return 0; + } + char *a = new char[l+1]; + char *result = a; + while (l--) { + *a++ = (uc->unicode() > 0xff) ? '?' : (char)uc->unicode(); + uc++; + } + *a = '\0'; + return result; +} + +/***************************************************************************** + TQString member functions + *****************************************************************************/ + +/*! + \class TQString qstring.h + \reentrant + + \brief The TQString class provides an abstraction of Unicode text + and the classic C '\0'-terminated char array. + + \ingroup tools + \ingroup shared + \ingroup text + \mainclass + + TQString uses \link shclass.html implicit sharing\endlink, which + makes it very efficient and easy to use. + + In all of the TQString methods that take \c {const char *} + parameters, the \c {const char *} is interpreted as a classic + C-style '\0'-terminated ASCII string. It is legal for the \c + {const char *} parameter to be 0. If the \c {const char *} is not + '\0'-terminated, the results are undefined. Functions that copy + classic C strings into a TQString will not copy the terminating + '\0' character. The TQChar array of the TQString (as returned by + unicode()) is generally not terminated by a '\0'. If you need to + pass a TQString to a function that retquires a C '\0'-terminated + string use latin1(). + + \keyword TQString::null + A TQString that has not been assigned to anything is \e null, i.e. + both the length and data pointer is 0. A TQString that references + the empty string ("", a single '\0' char) is \e empty. Both null + and empty TQStrings are legal parameters to the methods. Assigning + \c{(const char *) 0} to TQString gives a null TQString. For + convenience, \c TQString::null is a null TQString. When sorting, + empty strings come first, followed by non-empty strings, followed + by null strings. We recommend using \c{if ( !str.isNull() )} to + check for a non-null string rather than \c{if ( !str )}; see \l + operator!() for an explanation. + + Note that if you find that you are mixing usage of \l TQCString, + TQString, and \l TQByteArray, this causes lots of unnecessary + copying and might indicate that the true nature of the data you + are dealing with is uncertain. If the data is '\0'-terminated 8-bit + data, use \l TQCString; if it is unterminated (i.e. contains '\0's) + 8-bit data, use \l TQByteArray; if it is text, use TQString. + + Lists of strings are handled by the TQStringList class. You can + split a string into a list of strings using TQStringList::split(), + and join a list of strings into a single string with an optional + separator using TQStringList::join(). You can obtain a list of + strings from a string list that contain a particular substring or + that match a particular \link qregexp.html regex\endlink using + TQStringList::grep(). + + Note for C programmers + + Due to C++'s type system and the fact that TQString is implicitly + shared, TQStrings can be treated like ints or other simple base + types. For example: + + \code + TQString boolToString( bool b ) + { + TQString result; + if ( b ) + result = "True"; + else + result = "False"; + return result; + } + \endcode + + The variable, result, is an auto variable allocated on the stack. + When return is called, because we're returning by value, The copy + constructor is called and a copy of the string is returned. (No + actual copying takes place thanks to the implicit sharing, see + below.) + + Throughout TQt's source code you will encounter TQString usages like + this: + \code + TQString func( const TQString& input ) + { + TQString output = input; + // process output + return output; + } + \endcode + + The 'copying' of input to output is almost as fast as copying a + pointer because behind the scenes copying is achieved by + incrementing a reference count. TQString (like all TQt's implicitly + shared classes) operates on a copy-on-write basis, only copying if + an instance is actually changed. + + If you wish to create a deep copy of a TQString without losing any + Unicode information then you should use TQDeepCopy. + + \sa TQChar TQCString TQByteArray TQConstString +*/ + +/*! \enum TQt::ComparisonFlags +\internal +*/ +/*! + \enum TQt::StringComparisonMode + + This enum type is used to set the string comparison mode when + searching for an item. It is used by TQListBox, TQListView and + TQIconView, for example. We'll refer to the string being searched + as the 'target' string. + + \value CaseSensitive The strings must match case sensitively. + \value ExactMatch The target and search strings must match exactly. + \value BeginsWith The target string begins with the search string. + \value EndsWith The target string ends with the search string. + \value Contains The target string contains the search string. + + If you OR these flags together (excluding \c CaseSensitive), the + search criteria be applied in the following order: \c ExactMatch, + \c BeginsWith, \c EndsWith, \c Contains. + + Matching is case-insensitive unless \c CaseSensitive is set. \c + CaseSensitive can be OR-ed with any combination of the other + flags. + +*/ +Q_EXPORT TQStringData *TQString::shared_null = 0; +QT_STATIC_CONST_IMPL TQString TQString::null; +QT_STATIC_CONST_IMPL TQChar TQChar::null; +QT_STATIC_CONST_IMPL TQChar TQChar::replacement((ushort)0xfffd); +QT_STATIC_CONST_IMPL TQChar TQChar::byteOrderMark((ushort)0xfeff); +QT_STATIC_CONST_IMPL TQChar TQChar::byteOrderSwapped((ushort)0xfffe); +QT_STATIC_CONST_IMPL TQChar TQChar::nbsp((ushort)0x00a0); + +TQStringData* TQString::makeSharedNull() +{ + TQString::shared_null = new TQStringData; +#if defined( Q_OS_MAC ) || defined(Q_OS_SOLARIS) || defined(Q_OS_HPUX) || defined(Q_OS_AIX) + TQString *that = const_cast(&TQString::null); + that->d = TQString::shared_null; +#endif + return TQString::shared_null; +} + +/*! + \fn TQString::TQString() + + Constructs a null string, i.e. both the length and data pointer + are 0. + + \sa isNull() +*/ + +/*! + Constructs a string of length one, containing the character \a ch. +*/ +TQString::TQString( TQChar ch ) +{ + d = new TQStringData( QT_ALLOC_QCHAR_VEC( 1 ), 1, 1 ); + d->unicode[0] = ch; +} + +/*! + Constructs an implicitly shared copy of \a s. This is very fast + since it only involves incrementing a reference count. +*/ +TQString::TQString( const TQString &s ) : + d(s.d) +{ + d->ref(); +} + +/*! + \internal + + Private function. + + Constructs a string with preallocated space for \a size characters. + + The string is empty. + + \sa isNull() +*/ + +TQString::TQString( int size, bool /*dummy*/ ) +{ + if ( size ) { + int l = size; + TQChar* uc = QT_ALLOC_QCHAR_VEC( l ); + d = new TQStringData( uc, 0, l ); + } else { + d = shared_null ? shared_null : (shared_null=new TQStringData); + d->ref(); + } +} + +/*! + Constructs a string that is a deep copy of \a ba interpreted as a + classic C string. +*/ + +TQString::TQString( const TQByteArray& ba ) +{ +#ifndef QT_NO_TEXTCODEC + if ( TQTextCodec::codecForCStrings() ) { + d = 0; + *this = fromAscii( ba.data(), ba.size() ); + return; + } +#endif + uint l; + TQChar *uc = internalLatin1ToUnicode(ba,&l); + d = new TQStringData(uc,l,l); +} + +/*! + Constructs a string that is a deep copy of the first \a length + characters in the TQChar array. + + If \a unicode and \a length are 0, then a null string is created. + + If only \a unicode is 0, the string is empty but has \a length + characters of space preallocated: TQString expands automatically + anyway, but this may speed up some cases a little. We recommend + using the plain constructor and setLength() for this purpose since + it will result in more readable code. + + \sa isNull() setLength() +*/ + +TQString::TQString( const TQChar* unicode, uint length ) +{ + if ( !unicode && !length ) { + d = shared_null ? shared_null : makeSharedNull(); + d->ref(); + } else { + TQChar* uc = QT_ALLOC_QCHAR_VEC( length ); + if ( unicode ) + memcpy(uc, unicode, length*sizeof(TQChar)); + d = new TQStringData(uc,unicode ? length : 0,length); + } +} + +/*! + Constructs a string that is a deep copy of \a str, interpreted as + a classic C string. The encoding is assumed to be Latin-1, unless + you change it using TQTextCodec::setCodecForCStrings(). + + If \a str is 0, then a null string is created. + + This is a cast constructor, but it is perfectly safe: converting a + Latin-1 \c{const char *} to TQString preserves all the information. You + can disable this constructor by defining \c QT_NO_CAST_ASCII when + you compile your applications. You can also make TQString objects + by using setLatin1(), fromLatin1(), fromLocal8Bit(), and + fromUtf8(). Or whatever encoding is appropriate for the 8-bit data + you have. + + \sa isNull(), fromAscii() +*/ + +TQString::TQString( const char *str ) +{ +#ifndef QT_NO_TEXTCODEC + if ( TQTextCodec::codecForCStrings() ) { + d = 0; + *this = fromAscii( str ); + return; + } +#endif + uint l; + TQChar *uc = internalLatin1ToUnicode(str,&l); + d = new TQStringData(uc,l,l); +} + +#ifndef QT_NO_STL +/*! + Constructs a string that is a deep copy of \a str. + + This is the same as fromAscii(\a str). +*/ + +TQString::TQString( const std::string &str ) +{ +#ifndef QT_NO_TEXTCODEC + if ( TQTextCodec::codecForCStrings() ) { + d = 0; + *this = fromAscii( str.c_str() ); + return; + } +#endif + uint l; + TQChar *uc = internalLatin1ToUnicode(str.c_str(),&l); + d = new TQStringData(uc,l,l); +} +#endif + +/*! + \fn TQString::~TQString() + + Destroys the string and frees the string's data if this is the + last reference to the string. +*/ + + +/*! + Deallocates any space reserved solely by this TQString. + + If the string does not share its data with another TQString + instance, nothing happens; otherwise the function creates a new, + unique copy of this string. This function is called whenever the + string is modified. +*/ + +void TQString::real_detach() +{ + setLength( length() ); +} + +void TQString::deref() +{ + if ( d && d->deref() ) { + if ( d != shared_null ) + delete d; + d = 0; + } +} + +void TQStringData::deleteSelf() +{ + delete this; +} + +/*! + \fn TQString& TQString::operator=( TQChar c ) + + Sets the string to contain just the single character \a c. +*/ + +/*! + \fn TQString& TQString::operator=( const std::string& s ) + + \overload + + Makes a deep copy of \a s and returns a reference to the deep + copy. +*/ + +/*! + \fn TQString& TQString::operator=( char c ) + + \overload + + Sets the string to contain just the single character \a c. +*/ + +/*! + \overload + + Assigns a shallow copy of \a s to this string and returns a + reference to this string. This is very fast because the string + isn't actually copied. +*/ +TQString &TQString::operator=( const TQString &s ) +{ + s.d->ref(); + deref(); + d = s.d; + return *this; +} + +/*! + \overload + + Assigns a deep copy of \a cstr, interpreted as a classic C + string, to this string. Returns a reference to this string. +*/ +TQString &TQString::operator=( const TQCString& cstr ) +{ + return setAscii( cstr ); +} + + +/*! + \overload + + Assigns a deep copy of \a str, interpreted as a classic C string + to this string and returns a reference to this string. + + If \a str is 0, then a null string is created. + + \sa isNull() +*/ +TQString &TQString::operator=( const char *str ) +{ + return setAscii(str); +} + + +/*! + \fn bool TQString::isNull() const + + Returns TRUE if the string is null; otherwise returns FALSE. A + null string is always empty. + + \code + TQString a; // a.unicode() == 0, a.length() == 0 + a.isNull(); // TRUE, because a.unicode() == 0 + a.isEmpty(); // TRUE, because a.length() == 0 + \endcode + + \sa isEmpty(), length() +*/ + +/*! + \fn bool TQString::isEmpty() const + + Returns TRUE if the string is empty, i.e. if length() == 0; + otherwise returns FALSE. Null strings are also empty. + + \code + TQString a( "" ); + a.isEmpty(); // TRUE + a.isNull(); // FALSE + + TQString b; + b.isEmpty(); // TRUE + b.isNull(); // TRUE + \endcode + + \sa isNull(), length() +*/ + +/*! + \fn uint TQString::length() const + + Returns the length of the string. + + Null strings and empty strings have zero length. + + \sa isNull(), isEmpty() +*/ + +/*! + If \a newLen is less than the length of the string, then the + string is truncated at position \a newLen. Otherwise nothing + happens. + + \code + TQString s = "truncate me"; + s.truncate( 5 ); // s == "trunc" + \endcode + + \sa setLength() +*/ + +void TQString::truncate( uint newLen ) +{ + if ( newLen < d->len ) + setLength( newLen ); +} + +/*! + Ensures that at least \a newLen characters are allocated to the + string, and sets the length of the string to \a newLen. Any new + space allocated contains arbitrary data. + + \sa reserve(), truncate() +*/ +void TQString::setLength( uint newLen ) +{ + if ( d->count != 1 || newLen > d->maxl || + ( newLen * 4 < d->maxl && d->maxl > 4 ) ) { + // detach, grow or shrink + uint newMax = computeNewMax( newLen ); + TQChar* nd = QT_ALLOC_QCHAR_VEC( newMax ); + if ( nd ) { + uint len = TQMIN( d->len, newLen ); + memcpy( nd, d->unicode, sizeof(TQChar) * len ); + deref(); + d = new TQStringData( nd, newLen, newMax ); + } + } else { + d->len = newLen; + d->setDirty(); + } +} + +/*! + \fn uint TQString::capacity() const + + Returns the number of characters this string can hold + in the allocated memory. + + \sa reserve(), squeeze() +*/ + +/*! + Ensures that at least \a minCapacity characters are allocated to + the string. + + This function is useful for code that needs to build up a long + string and wants to avoid repeated reallocation. In this example, + we want to add to the string until some condition is true, and + we're fairly sure that size is big enough: + \code + TQString result; + int len = 0; + result.reserve(maxLen); + while (...) { + result[len++] = ... // fill part of the space + } + result.squeeze(); + \endcode + + If \e maxLen is an underestimate, the worst that will happen is + that the loop will slow down. + + If it is not possible to allocate enough memory, the string + remains unchanged. + + \sa capacity(), squeeze(), setLength() +*/ + +void TQString::reserve( uint minCapacity ) +{ + if ( d->maxl < minCapacity ) { + TQChar *nd = QT_ALLOC_QCHAR_VEC( minCapacity ); + if ( nd ) { + uint len = d->len; + if ( len ) + memcpy( nd, d->unicode, sizeof(TQChar) * len ); + deref(); + d = new TQStringData( nd, len, minCapacity ); + } + } +} + + +/*! + Squeezes the string's capacity to the current content. + + \sa capacity(), reserve() +*/ +void TQString::squeeze() +{ + if ( d->maxl > d->len ) { + TQChar *nd = QT_ALLOC_QCHAR_VEC( d->len ); + if ( nd ) { + uint len = d->len; + if ( len ) + memcpy( nd, d->unicode, sizeof(TQChar) * len ); + deref(); + d = new TQStringData( nd, len, len ); + } + } +} + +/*! + \internal + + Like setLength, but doesn't shrink the allocated memory. +*/ +void TQString::grow( uint newLen ) +{ + if ( d->count != 1 || newLen > d->maxl ) { + setLength( newLen ); + } else { + d->len = newLen; + d->setDirty(); + } +} + +struct ArgEscapeData +{ + uint min_escape; // lowest escape sequence number + uint occurrences; // number of occurences of the lowest escape + // sequence number + uint locale_occurrences; // number of occurences of the lowest escape + // sequence number which contain 'L' + uint escape_len; // total length of escape sequences which will + // be replaced +}; + +static ArgEscapeData findArgEscapes(const TQString &s) +{ + const TQChar *uc_begin = s.unicode(); + const TQChar *uc_end = uc_begin + s.length(); + + ArgEscapeData d; + + d.min_escape = 10; + d.occurrences = 0; + d.escape_len = 0; + d.locale_occurrences = 0; + + const TQChar *c = uc_begin; + while (c != uc_end) { + while (c != uc_end && c->unicode() != '%') + ++c; + + if (c == uc_end || ++c == uc_end) + break; + + bool locale_arg = FALSE; + if (c->unicode() == 'L') { + locale_arg = TRUE; + if (++c == uc_end) + break; + } + + if (c->unicode() < '0' || c->unicode() > '9') + continue; + + uint escape = c->unicode() - '0'; + ++c; + + if (escape > d.min_escape) + continue; + + if (escape < d.min_escape) { + d.min_escape = escape; + d.occurrences = 0; + d.escape_len = 0; + d.locale_occurrences = 0; + } + +#if QT_VERSION < 0x040000 + // ### remove preprocessor in TQt 4.0 + /* Since in TQt < 4.0 only the first instance is replaced, + escape_len should hold the length of only the first escape + sequence */ + if (d.occurrences == 0) +#endif + { + ++d.occurrences; + if (locale_arg) { + ++d.locale_occurrences; + d.escape_len += 3; + } + else + d.escape_len += 2; + } + } + + return d; +} + +static TQString replaceArgEscapes(const TQString &s, const ArgEscapeData &d, int field_width, + const TQString &arg, const TQString &larg) +{ + const TQChar *uc_begin = s.unicode(); + const TQChar *uc_end = uc_begin + s.length(); + + uint abs_field_width = TQABS(field_width); + uint result_len = s.length() + - d.escape_len + + (d.occurrences - d.locale_occurrences) + *TQMAX(abs_field_width, arg.length()) + + d.locale_occurrences + *TQMAX(abs_field_width, larg.length()); + + TQString result; + result.setLength(result_len); + TQChar *result_buff = (TQChar*) result.unicode(); + + TQChar *rc = result_buff; + const TQChar *c = uc_begin; + uint repl_cnt = 0; + while (c != uc_end) { + /* We don't have to check if we run off the end of the string with c, + because as long as d.occurrences > 0 we KNOW there are valid escape + sequences. */ + + const TQChar *text_start = c; + + while (c->unicode() != '%') + ++c; + + const TQChar *escape_start = c++; + + bool locale_arg = FALSE; + if (c->unicode() == 'L') { + locale_arg = TRUE; + ++c; + } + + if (c->unicode() != '0' + d.min_escape) { + memcpy(rc, text_start, (c - text_start)*sizeof(TQChar)); + rc += c - text_start; + } + else { + ++c; + + memcpy(rc, text_start, (escape_start - text_start)*sizeof(TQChar)); + rc += escape_start - text_start; + + uint pad_chars; + if (locale_arg) + pad_chars = TQMAX(abs_field_width, larg.length()) - larg.length(); + else + pad_chars = TQMAX(abs_field_width, arg.length()) - arg.length(); + + if (field_width > 0) { // left padded + for (uint i = 0; i < pad_chars; ++i) + (rc++)->unicode() = ' '; + } + + if (locale_arg) { + memcpy(rc, larg.unicode(), larg.length()*sizeof(TQChar)); + rc += larg.length(); + } + else { + memcpy(rc, arg.unicode(), arg.length()*sizeof(TQChar)); + rc += arg.length(); + } + + if (field_width < 0) { // right padded + for (uint i = 0; i < pad_chars; ++i) + (rc++)->unicode() = ' '; + } + + if (++repl_cnt == d.occurrences) { + memcpy(rc, c, (uc_end - c)*sizeof(TQChar)); + rc += uc_end - c; + Q_ASSERT(rc - result_buff == (int)result_len); + c = uc_end; + } + } + } + + return result; +} + +/*! + This function will return a string that replaces the lowest + numbered occurrence of \c %1, \c %2, ..., \c %9 with \a a. + + The \a fieldWidth value specifies the minimum amount of space that + \a a is padded to. A positive value will produce right-aligned + text, whereas a negative value will produce left-aligned text. + + The following example shows how we could create a 'status' string + when processing a list of files: + \code + TQString status = TQString( "Processing file %1 of %2: %3" ) + .arg( i ) // current file's number + .arg( total ) // number of files to process + .arg( fileName ); // current file's name + \endcode + + It is generally fine to use filenames and numbers as we have done + in the example above. But note that using arg() to construct + natural language sentences does not usually translate well into + other languages because sentence structure and word order often + differ between languages. + + If there is no place marker (\c %1, \c %2, etc.), a warning + message (qWarning()) is output and the result is undefined. + + \warning If any placeholder occurs more than once, the result is undefined. + +*/ +TQString TQString::arg( const TQString& a, int fieldWidth ) const +{ + ArgEscapeData d = findArgEscapes(*this); + + if (d.occurrences == 0) { + qWarning( "TQString::arg(): Argument missing: %s, %s", latin1(), + a.latin1() ); + return *this; + } + + return replaceArgEscapes(*this, d, fieldWidth, a, a); +} + +/*! + \fn TQString TQString::arg( const TQString& a1, const TQString& a2 ) const + + \overload + + This is the same as str.arg(\a a1).arg(\a a2), except that + the strings are replaced in one pass. This can make a difference + if \a a1 contains e.g. \c{%1}: + + \code + TQString str( "%1 %2" ); + str.arg( "Hello", "world" ); // returns "Hello world" + str.arg( "Hello" ).arg( "world" ); // returns "Hello world" + + str.arg( "(%1)", "Hello" ); // returns "(%1) Hello" + str.arg( "(%1)" ).arg( "Hello" ); // returns "(Hello) %2" + \endcode +*/ + +/*! + \fn TQString TQString::arg( const TQString& a1, const TQString& a2, + const TQString& a3 ) const + \overload + + This is the same as calling str.arg(\a a1).arg(\a a2).arg(\a a3), + except that the strings are replaced in one pass. +*/ + +/*! + \fn TQString TQString::arg( const TQString& a1, const TQString& a2, + const TQString& a3, const TQString& a4 ) const + \overload + + This is the same as calling + str.arg(\a a1).arg(\a a2).arg(\a a3).arg(\a a4), + except that the strings are replaced in one pass. +*/ + +/*! + \overload + + The \a fieldWidth value specifies the minimum amount of space that + \a a is padded to. A positive value will produce a right-aligned + number, whereas a negative value will produce a left-aligned + number. + + \a a is expressed in base \a base, which is 10 by default and must + be between 2 and 36. + + The '%' can be followed by an 'L', in which case the sequence is + replaced with a localized representation of \a a. The conversion + uses the default locale. The default locale is determined from the + system's locale settings at application startup. It can be changed + using TQLocale::setDefault(). The 'L' flag is ignored if \a base is + not 10. + + \code + TQString str; + str = TQString( "Decimal 63 is %1 in hexadecimal" ) + .arg( 63, 0, 16 ); + // str == "Decimal 63 is 3f in hexadecimal" + + TQLocale::setDefault(TQLocale::English, TQLocale::UnitedStates); + str = TQString( "%1 %L2 %L3" ) + .arg( 12345 ) + .arg( 12345 ) + .arg( 12345, 0, 16 ); + // str == "12345 12,345 3039" + \endcode +*/ +TQString TQString::arg( long a, int fieldWidth, int base ) const +{ + return arg((Q_LLONG)a, fieldWidth, base); +} + +/*! + \overload + + \a a is expressed in base \a base, which is 10 by default and must + be between 2 and 36. If \a base is 10, the '%L' syntax can be used + to produce localized strings. +*/ +TQString TQString::arg( ulong a, int fieldWidth, int base ) const +{ + return arg((Q_ULLONG)a, fieldWidth, base); +} + +/*! + \overload + + \a a is expressed in base \a base, which is 10 by default and must + be between 2 and 36. If \a base is 10, the '%L' syntax can be used + to produce localized strings. +*/ +TQString TQString::arg( Q_LLONG a, int fieldWidth, int base ) const +{ + ArgEscapeData d = findArgEscapes(*this); + + if (d.occurrences == 0) { + qWarning( "TQString::arg(): Argument missing: %s, %lld", latin1(), + a ); + return *this; + } + + TQString arg; + if (d.occurrences > d.locale_occurrences) + arg = number(a, base); + + TQString locale_arg; + if (d.locale_occurrences > 0) { + TQLocale locale; + locale_arg = locale.d->longLongToString(a, -1, base, -1, TQLocalePrivate::ThousandsGroup); + } + + return replaceArgEscapes(*this, d, fieldWidth, arg, locale_arg); +} + +/*! + \overload + + \a a is expressed in base \a base, which is 10 by default and must + be between 2 and 36. If \a base is 10, the '%L' syntax can be used + to produce localized strings. +*/ +TQString TQString::arg( Q_ULLONG a, int fieldWidth, int base ) const +{ + ArgEscapeData d = findArgEscapes(*this); + + if (d.occurrences == 0) { + qWarning( "TQString::arg(): Argument missing: %s, %llu", latin1(), + a ); + return *this; + } + + TQString arg; + if (d.occurrences > d.locale_occurrences) + arg = number(a, base); + + TQString locale_arg; + if (d.locale_occurrences > 0) { + TQLocale locale; + locale_arg = locale.d->unsLongLongToString(a, -1, base, -1, TQLocalePrivate::ThousandsGroup); + } + + return replaceArgEscapes(*this, d, fieldWidth, arg, locale_arg); +} + +/*! + \fn TQString TQString::arg( int a, int fieldWidth, int base ) const + + \overload + + \a a is expressed in base \a base, which is 10 by default and must + be between 2 and 36. If \a base is 10, the '%L' syntax can be used + to produce localized strings. +*/ + +/*! + \fn TQString TQString::arg( uint a, int fieldWidth, int base ) const + + \overload + + \a a is expressed in base \a base, which is 10 by default and must + be between 2 and 36. If \a base is 10, the '%L' syntax can be used + to produce localized strings. +*/ + +/*! + \fn TQString TQString::arg( short a, int fieldWidth, int base ) const + + \overload + + \a a is expressed in base \a base, which is 10 by default and must + be between 2 and 36. If \a base is 10, the '%L' syntax can be used + to produce localized strings. +*/ + +/*! + \fn TQString TQString::arg( ushort a, int fieldWidth, int base ) const + + \overload + + \a a is expressed in base \a base, which is 10 by default and must + be between 2 and 36. If \a base is 10, the '%L' syntax can be used + to produce localized strings. +*/ + + +/*! + \overload + + \a a is assumed to be in the Latin-1 character set. +*/ +TQString TQString::arg( char a, int fieldWidth ) const +{ + TQString c; + c += a; + return arg( c, fieldWidth ); +} + +/*! + \overload +*/ +TQString TQString::arg( TQChar a, int fieldWidth ) const +{ + TQString c; + c += a; + return arg( c, fieldWidth ); +} + +/*! + \overload + + \target arg-formats + + Argument \a a is formatted according to the \a fmt format specified, + which is 'g' by default and can be any of the following: + + \table + \header \i Format \i Meaning + \row \i \c e \i format as [-]9.9e[+|-]999 + \row \i \c E \i format as [-]9.9E[+|-]999 + \row \i \c f \i format as [-]9.9 + \row \i \c g \i use \c e or \c f format, whichever is the most concise + \row \i \c G \i use \c E or \c f format, whichever is the most concise + \endtable + + With 'e', 'E', and 'f', \a prec is the number of digits after the + decimal point. With 'g' and 'G', \a prec is the maximum number of + significant digits (trailing zeroes are omitted). + + \code + double d = 12.34; + TQString ds = TQString( "'E' format, precision 3, gives %1" ) + .arg( d, 0, 'E', 3 ); + // ds == "'E' format, precision 3, gives 1.234E+01" + \endcode + + The '%L' syntax can be used to produce localized strings. +*/ +TQString TQString::arg( double a, int fieldWidth, char fmt, int prec ) const +{ + ArgEscapeData d = findArgEscapes(*this); + + if (d.occurrences == 0) { + qWarning( "TQString::arg(): Argument missing: %s, %g", latin1(), + a ); + return *this; + } + + TQString arg; + if (d.occurrences > d.locale_occurrences) + arg = number(a, fmt, prec); + + TQString locale_arg; + if (d.locale_occurrences > 0) { + TQLocale locale; + + TQLocalePrivate::DoubleForm form = TQLocalePrivate::DFDecimal; + uint flags = 0; + + if (qIsUpper(fmt)) + flags = TQLocalePrivate::CapitalEorX; + fmt = qToLower(fmt); + + switch (fmt) { + case 'f': + form = TQLocalePrivate::DFDecimal; + break; + case 'e': + form = TQLocalePrivate::DFExponent; + break; + case 'g': + form = TQLocalePrivate::DFSignificantDigits; + break; + default: +#if defined(QT_CHECK_RANGE) + qWarning( "TQString::setNum: Invalid format char '%c'", fmt ); +#endif + break; + } + + flags |= TQLocalePrivate::ThousandsGroup; + + locale_arg = locale.d->doubleToString(a, prec, form, -1, flags); + } + + return replaceArgEscapes(*this, d, fieldWidth, arg, locale_arg); +} + +TQString TQString::multiArg( int numArgs, const TQString& a1, const TQString& a2, + const TQString& a3, const TQString& a4 ) const +{ + TQString result; + union { + int digitUsed[10]; + int argForDigit[10]; + }; + register const TQChar *uc = d->unicode; + const TQString *args[4]; + const int len = (int) length(); + const int end = len - 1; + int lastDigit = -1; + int i; + + memset( digitUsed, 0, sizeof(digitUsed) ); + args[0] = &a1; + args[1] = &a2; + args[2] = &a3; + args[3] = &a4; + + for ( i = 0; i < end; i++ ) { + if ( uc[i] == '%' ) { + int digit = uc[i + 1].unicode() - '0'; + if ( digit >= 0 && digit <= 9 ) + digitUsed[digit]++; + } + } + + for ( i = 0; i < numArgs; i++ ) { + do { + ++lastDigit; + } while ( lastDigit < 10 && digitUsed[lastDigit] == 0 ); + + if ( lastDigit == 10 ) { + qWarning( "TQString::arg(): Argument missing: %s, %s", + latin1(), args[i]->latin1() ); + numArgs = i; + lastDigit = 9; + break; + } + argForDigit[lastDigit] = i; + } + + i = 0; + while ( i < len ) { + if ( uc[i] == '%' && i != end ) { + int digit = uc[i + 1].unicode() - '0'; + if ( digit >= 0 && digit <= lastDigit ) { + result += *args[argForDigit[digit]]; + i += 2; + continue; + } + } + result += uc[i++]; + } + return result; +} + + +/*! + Safely builds a formatted string from the format string \a cformat + and an arbitrary list of arguments. The format string supports all + the escape sequences of printf() in the standard C library. + + The %s escape sequence expects a utf8() encoded string. The format + string \e cformat is expected to be in latin1. If you need a + Unicode format string, use arg() instead. For typesafe string + building, with full Unicode support, you can use TQTextOStream like + this: + + \code + TQString str; + TQString s = ...; + int x = ...; + TQTextOStream( &str ) << s << " : " << x; + \endcode + + For \link TQObject::tr() translations,\endlink especially if the + strings contains more than one escape sequence, you should + consider using the arg() function instead. This allows the order + of the replacements to be controlled by the translator, and has + Unicode support. + + The %lc escape sequence expects a unicode character of type ushort + (as returned by TQChar::unicode()). + The %ls escape sequence expects a pointer to a zero-terminated + array of unicode characters of type ushort (as returned by + TQString::ucs2()). + + \sa arg() +*/ + +#ifndef QT_NO_SPRINTF +TQString &TQString::sprintf( const char* cformat, ... ) +{ + TQLocale locale(TQLocale::C); + + va_list ap; + va_start( ap, cformat ); + + if ( !cformat || !*cformat ) { + // TQt 1.x compat + *this = fromLatin1( "" ); + return *this; + } + + // Parse cformat + + TQString result; + const char *c = cformat; + for (;;) { + // Copy non-escape chars to result + while (*c != '\0' && *c != '%') + result.append(*c++); + + if (*c == '\0') + break; + + // Found '%' + const char *escape_start = c; + ++c; + + if (*c == '\0') { + result.append('%'); // a % at the end of the string - treat as non-escape text + break; + } + if (*c == '%') { + result.append('%'); // %% + ++c; + continue; + } + + // Parse flag characters + unsigned flags = 0; + bool no_more_flags = FALSE; + do { + switch (*c) { + case '#': flags |= TQLocalePrivate::Alternate; break; + case '0': flags |= TQLocalePrivate::ZeroPadded; break; + case '-': flags |= TQLocalePrivate::LeftAdjusted; break; + case ' ': flags |= TQLocalePrivate::BlankBeforePositive; break; + case '+': flags |= TQLocalePrivate::AlwaysShowSign; break; + case '\'': flags |= TQLocalePrivate::ThousandsGroup; break; + default: no_more_flags = TRUE; break; + } + + if (!no_more_flags) + ++c; + } while (!no_more_flags); + + if (*c == '\0') { + result.append(escape_start); // incomplete escape, treat as non-escape text + break; + } + + // Parse field width + int width = -1; // -1 means unspecified + if (qIsDigit(*c)) { + TQString width_str; + while (*c != '\0' && qIsDigit(*c)) + width_str.append(*c++); + + // can't be negative - started with a digit + // contains at least one digit + width = width_str.toInt(); + } + else if (*c == '*') { + width = va_arg(ap, int); + if (width < 0) + width = -1; // treat all negative numbers as unspecified + ++c; + } + + if (*c == '\0') { + result.append(escape_start); // incomplete escape, treat as non-escape text + break; + } + + // Parse precision + int precision = -1; // -1 means unspecified + if (*c == '.') { + ++c; + if (qIsDigit(*c)) { + TQString precision_str; + while (*c != '\0' && qIsDigit(*c)) + precision_str.append(*c++); + + // can't be negative - started with a digit + // contains at least one digit + precision = precision_str.toInt(); + } + else if (*c == '*') { + precision = va_arg(ap, int); + if (precision < 0) + precision = -1; // treat all negative numbers as unspecified + ++c; + } + } + + if (*c == '\0') { + result.append(escape_start); // incomplete escape, treat as non-escape text + break; + } + + // Parse the length modifier + enum LengthMod { lm_none, lm_hh, lm_h, lm_l, lm_ll, lm_L, lm_j, lm_z, lm_t }; + LengthMod length_mod = lm_none; + switch (*c) { + case 'h': + ++c; + if (*c == 'h') { + length_mod = lm_hh; + ++c; + } + else + length_mod = lm_h; + break; + + case 'l': + ++c; + if (*c == 'l') { + length_mod = lm_ll; + ++c; + } + else + length_mod = lm_l; + break; + + case 'L': + ++c; + length_mod = lm_L; + break; + + case 'j': + ++c; + length_mod = lm_j; + break; + + case 'z': + case 'Z': + ++c; + length_mod = lm_z; + break; + + case 't': + ++c; + length_mod = lm_t; + break; + + default: break; + } + + if (*c == '\0') { + result.append(escape_start); // incomplete escape, treat as non-escape text + break; + } + + // Parse the conversion specifier and do the conversion + TQString subst; + switch (*c) { + case 'd': + case 'i': { + Q_LLONG i; + switch (length_mod) { + case lm_none: i = va_arg(ap, int); break; + case lm_hh: i = va_arg(ap, int); break; + case lm_h: i = va_arg(ap, int); break; + case lm_l: i = va_arg(ap, long int); break; + case lm_ll: i = va_arg(ap, Q_LLONG); break; + case lm_j: i = va_arg(ap, long int); break; + case lm_z: i = va_arg(ap, size_t); break; + case lm_t: i = va_arg(ap, int); break; + default: i = 0; break; + } + subst = locale.d->longLongToString(i, precision, 10, width, flags); + ++c; + break; + } + case 'o': + case 'u': + case 'x': + case 'X': { + Q_ULLONG u; + switch (length_mod) { + case lm_none: u = va_arg(ap, unsigned int); break; + case lm_hh: u = va_arg(ap, unsigned int); break; + case lm_h: u = va_arg(ap, unsigned int); break; + case lm_l: u = va_arg(ap, unsigned long int); break; + case lm_ll: u = va_arg(ap, Q_ULLONG); break; + default: u = 0; break; + } + + if (qIsUpper(*c)) + flags |= TQLocalePrivate::CapitalEorX; + + int base = 10; + switch (qToLower(*c)) { + case 'o': + base = 8; break; + case 'u': + base = 10; break; + case 'x': + base = 16; break; + default: break; + } + subst = locale.d->unsLongLongToString(u, precision, base, width, flags); + ++c; + break; + } + case 'E': + case 'e': + case 'F': + case 'f': + case 'G': + case 'g': + case 'A': + case 'a': { + double d; + if (length_mod == lm_L) + d = va_arg(ap, long double); // not supported - converted to a double + else + d = va_arg(ap, double); + + if (qIsUpper(*c)) + flags |= TQLocalePrivate::CapitalEorX; + + TQLocalePrivate::DoubleForm form = TQLocalePrivate::DFDecimal; + switch (qToLower(*c)) { + case 'e': form = TQLocalePrivate::DFExponent; break; + case 'a': // not supported - decimal form used instead + case 'f': form = TQLocalePrivate::DFDecimal; break; + case 'g': form = TQLocalePrivate::DFSignificantDigits; break; + default: break; + } + subst = locale.d->doubleToString(d, precision, form, width, flags); + ++c; + break; + } + case 'c': { + if (length_mod == lm_l) + subst = TQChar((ushort) va_arg(ap, int)); + else + subst = (uchar) va_arg(ap, int); + ++c; + break; + } + case 's': { + if (length_mod == lm_l) { + const ushort *buff = va_arg(ap, const ushort*); + const ushort *ch = buff; + while (*ch != 0) + ++ch; + subst.setUnicodeCodes(buff, ch - buff); + } else + subst = TQString::fromUtf8(va_arg(ap, const char*)); + if (precision != -1) + subst.truncate(precision); + ++c; + break; + } + case 'p': { + Q_ULLONG i; +#ifdef Q_OS_WIN64 + i = (Q_ULLONG) va_arg(ap, void*); +#else + i = (Q_ULONG) va_arg(ap, void*); +#endif + +#ifdef Q_OS_WIN32 + flags |= TQLocalePrivate::CapitalEorX; // Windows does 1234ABCD +#else + flags |= TQLocalePrivate::Alternate; // Unix and Mac do 0x1234abcd +#endif + + subst = locale.d->unsLongLongToString(i, precision, 16, width, flags); + ++c; + break; + } + case 'n': + switch (length_mod) { + case lm_hh: { + signed char *n = va_arg(ap, signed char*); + *n = result.length(); + break; + } + case lm_h: { + short int *n = va_arg(ap, short int*); + *n = result.length(); + break; + } + case lm_l: { + long int *n = va_arg(ap, long int*); + *n = result.length(); + break; + } + case lm_ll: { + Q_LLONG *n = va_arg(ap, Q_LLONG*); + volatile uint tmp = result.length(); // egcs-2.91.66 gets internal + *n = tmp; // compiler error without volatile + break; + } + default: { + int *n = va_arg(ap, int*); + *n = result.length(); + break; + } + } + ++c; + break; + + default: // bad escape, treat as non-escape text + for (const char *cc = escape_start; cc != c; ++cc) + result.append(*cc); + continue; + } + + if (flags & TQLocalePrivate::LeftAdjusted) + result.append(subst.leftJustify(width)); + else + result.append(subst.rightJustify(width)); + } + + va_end(ap); + *this = result; + + return *this; +} +#endif + +/*! + Fills the string with \a len characters of value \a c, and returns + a reference to the string. + + If \a len is negative (the default), the current string length is + used. + + \code + TQString str; + str.fill( 'g', 5 ); // string == "ggggg" + \endcode +*/ + +TQString& TQString::fill( TQChar c, int len ) +{ + if ( len < 0 ) + len = length(); + if ( len == 0 ) { + *this = ""; + } else { + deref(); + TQChar * nd = QT_ALLOC_QCHAR_VEC( len ); + d = new TQStringData(nd,len,len); + while (len--) *nd++ = c; + } + return *this; +} + + +/*! + \fn TQString TQString::copy() const + + \obsolete + + In TQt 2.0 and later, all calls to this function are needless. Just + remove them. +*/ + +/*! + \overload + + Finds the first occurrence of the character \a c, starting at + position \a index. If \a index is -1, the search starts at the + last character; if -2, at the next to last character and so on. + (See findRev() for searching backwards.) + + If \a cs is TRUE (the default), the search is case sensitive; + otherwise the search is case insensitive. + + Returns the position of \a c or -1 if \a c could not be found. +*/ + +int TQString::find( TQChar c, int index, bool cs ) const +{ + const uint l = length(); + if ( index < 0 ) + index += l; + if ( (uint)index >= l ) + return -1; + register const TQChar *uc = unicode()+index; + const TQChar *end = unicode() + l; + if ( cs ) { + while ( uc < end && *uc != c ) + uc++; + } else { + c = ::lower( c ); + while ( uc < end && ::lower( *uc ) != c ) + uc++; + } + if ( uint(uc - unicode()) >= l ) + return -1; + return (int)(uc - unicode()); +} + +/* an implementation of the Boyer-Moore search algorithm +*/ + +/* initializes the skiptable to know haw far ahead we can skip on a wrong match +*/ +static void bm_init_skiptable( const TQString &pattern, uint *skiptable, bool cs ) +{ + int i = 0; + register uint *st = skiptable; + int l = pattern.length(); + while ( i++ < 0x100/8 ) { + *(st++) = l; + *(st++) = l; + *(st++) = l; + *(st++) = l; + *(st++) = l; + *(st++) = l; + *(st++) = l; + *(st++) = l; + } + const TQChar *uc = pattern.unicode(); + if ( cs ) { + while ( l-- ) { + skiptable[ uc->cell() ] = l; + uc++; + } + } else { + while ( l-- ) { + skiptable[ ::lower( *uc ).cell() ] = l; + uc++; + } + } +} + +static int bm_find( const TQString &str, int index, const TQString &pattern, uint *skiptable, bool cs ) +{ + const uint l = str.length(); + if ( pattern.isEmpty() ) + return index > (int)l ? -1 : index; + + const TQChar *uc = str.unicode(); + const TQChar *puc = pattern.unicode(); + const uint pl = pattern.length(); + const uint pl_minus_one = pl - 1; + + register const TQChar *current = uc + index + pl_minus_one; + const TQChar *end = uc + l; + if ( cs ) { + while ( current < end ) { + uint skip = skiptable[ current->cell() ]; + if ( !skip ) { + // possible match + while ( skip < pl ) { + if ( *(current - skip ) != puc[pl_minus_one-skip] ) + break; + skip++; + } + if ( skip > pl_minus_one ) { // we have a match + return (current - uc) - skip + 1; + } + // in case we don't have a match we are a bit inefficient as we only skip by one + // when we have the non matching char in the string. + if ( skiptable[ (current-skip)->cell() ] == pl ) + skip = pl - skip; + else + skip = 1; + } + current += skip; + } + } else { + while ( current < end ) { + uint skip = skiptable[ ::lower( *current ).cell() ]; + if ( !skip ) { + // possible match + while ( skip < pl ) { + if ( ::lower( *(current - skip) ) != ::lower( puc[pl_minus_one-skip] ) ) + break; + skip++; + } + if ( skip > pl_minus_one ) // we have a match + return (current - uc) - skip + 1; + // in case we don't have a match we are a bit inefficient as we only skip by one + // when we have the non matching char in the string. + if ( skiptable[ ::lower(*(current - skip)).cell() ] == pl ) + skip = pl - skip; + else + skip = 1; + } + current += skip; + } + } + // not found + return -1; +} + + +#define REHASH( a ) \ + if ( sl_minus_1 < sizeof(uint) * CHAR_BIT ) \ + hashHaystack -= (a) << sl_minus_1; \ + hashHaystack <<= 1 + +/*! + \overload + + Finds the first occurrence of the string \a str, starting at + position \a index. If \a index is -1, the search starts at the + last character, if it is -2, at the next to last character and so + on. (See findRev() for searching backwards.) + + If \a cs is TRUE (the default), the search is case sensitive; + otherwise the search is case insensitive. + + Returns the position of \a str or -1 if \a str could not be found. +*/ + +int TQString::find( const TQString& str, int index, bool cs ) const +{ + const uint l = length(); + const uint sl = str.length(); + if ( index < 0 ) + index += l; + if ( sl + index > l ) + return -1; + if ( !sl ) + return index; + if (!l) + return -1; + +#if defined(Q_OS_MACX) && defined(QT_MACOSX_VERSION) && QT_MACOSX_VERSION >= 0x1020 + if ( sl == 1 ) + return find( *str.unicode(), index, cs ); +#endif + + // we use the Boyer-Moore algorithm in cases where the overhead + // for the hash table should pay off, otherwise we use a simple + // hash function + if ( l > 500 && sl > 5 ) { + uint skiptable[0x100]; + bm_init_skiptable( str, skiptable, cs ); + return bm_find( *this, index, str, skiptable, cs ); + } + + /* + We use some hashing for efficiency's sake. Instead of + comparing strings, we compare the hash value of str with that of + a part of this TQString. Only if that matches, we call ucstrncmp + or ucstrnicmp. + */ + const TQChar* needle = str.unicode(); + const TQChar* haystack = unicode() + index; + const TQChar* end = unicode() + (l-sl); + const uint sl_minus_1 = sl-1; + uint hashNeedle = 0, hashHaystack = 0, i; + + if ( cs ) { + for ( i = 0; i < sl; ++i ) { + hashNeedle = ((hashNeedle<<1) + needle[i].unicode() ); + hashHaystack = ((hashHaystack<<1) + haystack[i].unicode() ); + } + hashHaystack -= (haystack+sl_minus_1)->unicode(); + + while ( haystack <= end ) { + hashHaystack += (haystack+sl_minus_1)->unicode(); + if ( hashHaystack == hashNeedle + && ucstrncmp( needle, haystack, sl ) == 0 ) + return haystack-unicode(); + + REHASH( haystack->unicode() ); + ++haystack; + } + } else { + for ( i = 0; i < sl; ++i ) { + hashNeedle = ((hashNeedle<<1) + + ::lower( needle[i].unicode() ).unicode() ); + hashHaystack = ((hashHaystack<<1) + + ::lower( haystack[i].unicode() ).unicode() ); + } + + hashHaystack -= ::lower(*(haystack+sl_minus_1)).unicode(); + while ( haystack <= end ) { + hashHaystack += ::lower(*(haystack+sl_minus_1)).unicode(); + if ( hashHaystack == hashNeedle + && ucstrnicmp( needle, haystack, sl ) == 0 ) + return haystack-unicode(); + + REHASH( ::lower(*haystack).unicode() ); + ++haystack; + } + } + return -1; +} + +/*! + \fn int TQString::findRev( const char* str, int index ) const + + Equivalent to findRev(TQString(\a str), \a index). +*/ + +/*! + \fn int TQString::find( const char* str, int index ) const + + \overload + + Equivalent to find(TQString(\a str), \a index). +*/ + +/*! + \overload + + Finds the first occurrence of the character \a c, starting at + position \a index and searching backwards. If the index is -1, the + search starts at the last character, if it is -2, at the next to + last character and so on. + + Returns the position of \a c or -1 if \a c could not be found. + + If \a cs is TRUE (the default), the search is case sensitive; + otherwise the search is case insensitive. + + \code + TQString string( "bananas" ); + int i = string.findRev( 'a' ); // i == 5 + \endcode +*/ + +int TQString::findRev( TQChar c, int index, bool cs ) const +{ +#if defined(Q_OS_MACX) && defined(QT_MACOSX_VERSION) && QT_MACOSX_VERSION < 0x1020 + return findRev( TQString( c ), index, cs ); +#else + const uint l = length(); + if ( index < 0 ) + index += l; + if ( (uint)index >= l ) + return -1; + const TQChar *end = unicode(); + register const TQChar *uc = end + index; + if ( cs ) { + while ( uc >= end && *uc != c ) + uc--; + } else { + c = ::lower( c ); + while ( uc >= end && ::lower( *uc ) != c ) + uc--; + } + return uc - end; +#endif +} + +/*! + \overload + + Finds the first occurrence of the string \a str, starting at + position \a index and searching backwards. If the index is -1, the + search starts at the last character, if it is -2, at the next to + last character and so on. + + Returns the position of \a str or -1 if \a str could not be found. + + If \a cs is TRUE (the default), the search is case sensitive; + otherwise the search is case insensitive. + + \code + TQString string("bananas"); + int i = string.findRev( "ana" ); // i == 3 + \endcode +*/ + +int TQString::findRev( const TQString& str, int index, bool cs ) const +{ + /* + See TQString::find() for explanations. + */ + const uint l = length(); + if ( index < 0 ) + index += l; + const uint sl = str.length(); + int delta = l-sl; + if ( index < 0 || index > (int)l || delta < 0 ) + return -1; + if ( index > delta ) + index = delta; + +#if defined(Q_OS_MACX) && defined(QT_MACOSX_VERSION) && QT_MACOSX_VERSION >= 0x1020 + if ( sl == 1 ) + return findRev( *str.unicode(), index, cs ); +#endif + + const TQChar* needle = str.unicode(); + const TQChar* haystack = unicode() + index; + const TQChar* end = unicode(); + const uint sl_minus_1 = sl-1; + const TQChar* n = needle+sl_minus_1; + const TQChar* h = haystack+sl_minus_1; + uint hashNeedle = 0, hashHaystack = 0, i; + + if ( cs ) { + for ( i = 0; i < sl; ++i ) { + hashNeedle = ((hashNeedle<<1) + (n-i)->unicode() ); + hashHaystack = ((hashHaystack<<1) + (h-i)->unicode() ); + } + hashHaystack -= haystack->unicode(); + + while ( haystack >= end ) { + hashHaystack += haystack->unicode(); + if ( hashHaystack == hashNeedle + && ucstrncmp( needle, haystack, sl ) == 0 ) + return haystack-unicode(); + --haystack; + REHASH( (haystack+sl)->unicode() ); + } + } else { + for ( i = 0; i < sl; ++i ) { + hashNeedle = ((hashNeedle<<1) + + ::lower( (n-i)->unicode() ).unicode() ); + hashHaystack = ((hashHaystack<<1) + + ::lower( (h-i)->unicode() ).unicode() ); + } + hashHaystack -= ::lower(*haystack).unicode(); + + while ( haystack >= end ) { + hashHaystack += ::lower(*haystack).unicode(); + if ( hashHaystack == hashNeedle + && ucstrnicmp( needle, haystack, sl ) == 0 ) + return haystack-unicode(); + --haystack; + REHASH( ::lower(*(haystack+sl)).unicode() ); + } + } + return -1; +} + +#undef REHASH + +/*! + \enum TQString::SectionFlags + + \value SectionDefault Empty fields are counted, leading and + trailing separators are not included, and the separator is + compared case sensitively. + + \value SectionSkipEmpty Treat empty fields as if they don't exist, + i.e. they are not considered as far as \e start and \e end are + concerned. + + \value SectionIncludeLeadingSep Include the leading separator (if + any) in the result string. + + \value SectionIncludeTrailingSep Include the trailing separator + (if any) in the result string. + + \value SectionCaseInsensitiveSeps Compare the separator + case-insensitively. + + Any of the last four values can be OR-ed together to form a flag. + + \sa section() +*/ + +/*! + \fn TQString TQString::section( TQChar sep, int start, int end = 0xffffffff, int flags = SectionDefault ) const + + This function returns a section of the string. + + This string is treated as a sequence of fields separated by the + character, \a sep. The returned string consists of the fields from + position \a start to position \a end inclusive. If \a end is not + specified, all fields from position \a start to the end of the + string are included. Fields are numbered 0, 1, 2, etc., counting + from the left, and -1, -2, etc., counting from right to left. + + The \a flags argument can be used to affect some aspects of the + function's behaviour, e.g. whether to be case sensitive, whether + to skip empty fields and how to deal with leading and trailing + separators; see \l{SectionFlags}. + + \code + TQString csv( "forename,middlename,surname,phone" ); + TQString s = csv.section( ',', 2, 2 ); // s == "surname" + + TQString path( "/usr/local/bin/myapp" ); // First field is empty + TQString s = path.section( '/', 3, 4 ); // s == "bin/myapp" + TQString s = path.section( '/', 3, 3, SectionSkipEmpty ); // s == "myapp" + \endcode + + If \a start or \a end is negative, we count fields from the right + of the string, the right-most field being -1, the one from + right-most field being -2, and so on. + + \code + TQString csv( "forename,middlename,surname,phone" ); + TQString s = csv.section( ',', -3, -2 ); // s == "middlename,surname" + + TQString path( "/usr/local/bin/myapp" ); // First field is empty + TQString s = path.section( '/', -1 ); // s == "myapp" + \endcode + + \sa TQStringList::split() +*/ + +/*! + \overload + + This function returns a section of the string. + + This string is treated as a sequence of fields separated by the + string, \a sep. The returned string consists of the fields from + position \a start to position \a end inclusive. If \a end is not + specified, all fields from position \a start to the end of the + string are included. Fields are numbered 0, 1, 2, etc., counting + from the left, and -1, -2, etc., counting from right to left. + + The \a flags argument can be used to affect some aspects of the + function's behaviour, e.g. whether to be case sensitive, whether + to skip empty fields and how to deal with leading and trailing + separators; see \l{SectionFlags}. + + \code + TQString data( "forename**middlename**surname**phone" ); + TQString s = data.section( "**", 2, 2 ); // s == "surname" + \endcode + + If \a start or \a end is negative, we count fields from the right + of the string, the right-most field being -1, the one from + right-most field being -2, and so on. + + \code + TQString data( "forename**middlename**surname**phone" ); + TQString s = data.section( "**", -3, -2 ); // s == "middlename**surname" + \endcode + + \sa TQStringList::split() +*/ + +TQString TQString::section( const TQString &sep, int start, int end, int flags ) const +{ + TQStringList sections = TQStringList::split(sep, *this, TRUE); + if(sections.isEmpty()) + return TQString(); + if(!(flags & SectionSkipEmpty)) { + if(start < 0) + start += int(sections.count()); + if(end < 0) + end += int(sections.count()); + } else { + int skip = 0; + for(TQStringList::Iterator it = sections.begin(); it != sections.end(); ++it) { + if((*it).isEmpty()) + skip++; + } + if(start < 0) + start += int(sections.count()) - skip; + if(end < 0) + end += int(sections.count()) - skip; + } + int x = 0, run = 0; + TQString ret; + for(TQStringList::Iterator it = sections.begin(); x <= end && it != sections.end(); ++it) { + if(x >= start) { + if((*it).isEmpty()) { + run++; + } else { + if(!ret.isEmpty() || !(flags & SectionSkipEmpty)) { + int i_end = run; + if(!ret.isEmpty() && !(flags & SectionIncludeTrailingSep)) + i_end++; + if((flags & SectionIncludeLeadingSep) && it != sections.begin() && x == start) + i_end++; + for(int i = 0; i < i_end; i++) + ret += sep; + } else if((flags & SectionIncludeLeadingSep) && it != sections.begin()) { + ret += sep; + } + run = 0; + ret += (*it); + if((flags & SectionIncludeTrailingSep) && it != sections.end()) + ret += sep; + } + } + if(!(*it).isEmpty() || !(flags & SectionSkipEmpty)) + x++; + } + return ret; +} + +#ifndef QT_NO_REGEXP +class section_chunk { +public: + section_chunk(int l, TQString s) { length = l; string = s; } + int length; + TQString string; +}; +/*! + \overload + + This function returns a section of the string. + + This string is treated as a sequence of fields separated by the + regular expression, \a reg. The returned string consists of the + fields from position \a start to position \a end inclusive. If \a + end is not specified, all fields from position \a start to the end + of the string are included. Fields are numbered 0, 1, 2, etc., counting + from the left, and -1, -2, etc., counting from right to left. + + The \a flags argument can be used to affect some aspects of the + function's behaviour, e.g. whether to be case sensitive, whether + to skip empty fields and how to deal with leading and trailing + separators; see \l{SectionFlags}. + + \code + TQString line( "forename\tmiddlename surname \t \t phone" ); + TQRegExp sep( "\s+" ); + TQString s = line.section( sep, 2, 2 ); // s == "surname" + \endcode + + If \a start or \a end is negative, we count fields from the right + of the string, the right-most field being -1, the one from + right-most field being -2, and so on. + + \code + TQString line( "forename\tmiddlename surname \t \t phone" ); + TQRegExp sep( "\\s+" ); + TQString s = line.section( sep, -3, -2 ); // s == "middlename surname" + \endcode + + \warning Using this TQRegExp version is much more expensive than + the overloaded string and character versions. + + \sa TQStringList::split() simplifyWhiteSpace() +*/ + +TQString TQString::section( const TQRegExp ®, int start, int end, int flags ) const +{ + const TQChar *uc = unicode(); + if(!uc) + return TQString(); + + TQRegExp sep(reg); + sep.setCaseSensitive(!(flags & SectionCaseInsensitiveSeps)); + + TQPtrList l; + l.setAutoDelete(TRUE); + int n = length(), m = 0, last_m = 0, last = 0, last_len = 0; + + while ( ( m = sep.search( *this, m ) ) != -1 ) { + l.append(new section_chunk(last_len, TQString(uc + last_m, m - last_m))); + last_m = m; + last_len = sep.matchedLength(); + if((m += TQMAX(sep.matchedLength(), 1)) >= n) { + last = 1; + break; + } + } + if(!last) + l.append(new section_chunk(last_len, TQString(uc + last_m, n - last_m))); + + if(start < 0) + start = l.count() + start; + if(end == -1) + end = l.count(); + else if(end < 0) + end = l.count() + end; + + int i = 0; + TQString ret; + for ( section_chunk *chk=l.first(); chk; chk=l.next(), i++ ) { + if((flags & SectionSkipEmpty) && chk->length == (int)chk->string.length()) { + if(i <= start) + start++; + end++; + } + if(i == start) { + ret = (flags & SectionIncludeLeadingSep) ? chk->string : chk->string.mid(chk->length); + } else if(i > start) { + ret += chk->string; + } + if(i == end) { + if((chk=l.next()) && flags & SectionIncludeTrailingSep) + ret += chk->string.left(chk->length); + break; + } + } + return ret; +} +#endif + +/*! + \fn TQString TQString::section( char sep, int start, int end = 0xffffffff, int flags = SectionDefault ) const + + \overload +*/ + +/*! + \fn TQString TQString::section( const char *sep, int start, int end = 0xffffffff, int flags = SectionDefault ) const + + \overload +*/ + + +/*! + Returns the number of times the character \a c occurs in the + string. + + If \a cs is TRUE (the default), the search is case sensitive; + otherwise the search is case insensitive. + + \code + TQString string( "Trolltech and TQt" ); + int n = string.contains( 't', FALSE ); + // n == 3 + \endcode +*/ + +int TQString::contains( TQChar c, bool cs ) const +{ + int count = 0; + const TQChar *uc = unicode(); + if ( !uc ) + return 0; + int n = length(); + if ( cs ) { + while ( n-- ) { + if ( *uc == c ) + count++; + uc++; + } + } else { + c = ::lower( c ); + while ( n-- ) { + if ( ::lower( *uc ) == c ) + count++; + uc++; + } + } + return count; +} + +/*! + \overload + + Returns the number of times the string \a str occurs in the string. + + If \a cs is TRUE (the default), the search is case sensitive; + otherwise the search is case insensitive. +*/ +int TQString::contains( const char* str, bool cs ) const +{ + return contains( TQString(str), cs ); +} + +/*! + \fn int TQString::contains( char c, bool cs ) const + + \overload +*/ + +/*! + \fn int TQString::find( char c, int index, bool cs ) const + + \overload + + Find character \a c starting from position \a index. + + If \a cs is TRUE (the default), the search is case sensitive; + otherwise the search is case insensitive. +*/ + +/*! + \fn int TQString::findRev( char c, int index, bool cs ) const + + \overload + + Find character \a c starting from position \a index and working + backwards. + + If \a cs is TRUE (the default), the search is case sensitive; + otherwise the search is case insensitive. +*/ + +/*! + \overload + + Returns the number of times \a str occurs in the string. + + If \a cs is TRUE (the default), the search is case sensitive; + otherwise the search is case insensitive. + + This function counts overlapping strings, so in the example below, + there are two instances of "ana" in "bananas". + + \code + TQString str( "bananas" ); + int i = str.contains( "ana" ); // i == 2 + \endcode + + \sa findRev() +*/ + +int TQString::contains( const TQString &str, bool cs ) const +{ + if ( isNull() ) + return 0; + int count = 0; + uint skiptable[0x100]; + bm_init_skiptable( str, skiptable, cs ); + int i = -1; + // use boyer-moore for the ultimate speed experience + while ( ( i = bm_find( *this, i + 1, str, skiptable, cs ) ) != -1 ) + count++; + return count; +} + +/*! + Returns a substring that contains the \a len leftmost characters + of the string. + + The whole string is returned if \a len exceeds the length of the + string. + + \code + TQString s = "Pineapple"; + TQString t = s.left( 4 ); // t == "Pine" + \endcode + + \sa right(), mid(), isEmpty() +*/ + +TQString TQString::left( uint len ) const +{ + if ( isEmpty() ) { + return TQString(); + } else if ( len == 0 ) { // ## just for 1.x compat: + return fromLatin1( "" ); + } else if ( len >= length() ) { + return *this; + } else { + TQString s( len, TRUE ); + memcpy( s.d->unicode, d->unicode, len * sizeof(TQChar) ); + s.d->len = len; + return s; + } +} + +/*! + Returns a string that contains the \a len rightmost characters of + the string. + + If \a len is greater than the length of the string then the whole + string is returned. + + \code + TQString string( "Pineapple" ); + TQString t = string.right( 5 ); // t == "apple" + \endcode + + \sa left(), mid(), isEmpty() +*/ + +TQString TQString::right( uint len ) const +{ + if ( isEmpty() ) { + return TQString(); + } else if ( len == 0 ) { // ## just for 1.x compat: + return fromLatin1( "" ); + } else { + uint l = length(); + if ( len >= l ) + return *this; + TQString s( len, TRUE ); + memcpy( s.d->unicode, d->unicode+(l-len), len*sizeof(TQChar) ); + s.d->len = len; + return s; + } +} + +/*! + Returns a string that contains the \a len characters of this + string, starting at position \a index. + + Returns a null string if the string is empty or \a index is out of + range. Returns the whole string from \a index if \a index + \a len + exceeds the length of the string. + + \code + TQString s( "Five pineapples" ); + TQString t = s.mid( 5, 4 ); // t == "pine" + \endcode + + \sa left(), right() +*/ + +TQString TQString::mid( uint index, uint len ) const +{ + uint slen = length(); + if ( isEmpty() || index >= slen ) { + return TQString(); + } else if ( len == 0 ) { // ## just for 1.x compat: + return fromLatin1( "" ); + } else { + if ( len > slen-index ) + len = slen - index; + if ( index == 0 && len == slen ) + return *this; + register const TQChar *p = unicode()+index; + TQString s( len, TRUE ); + memcpy( s.d->unicode, p, len * sizeof(TQChar) ); + s.d->len = len; + return s; + } +} + +/*! + Returns a string of length \a width that contains this string + padded by the \a fill character. + + If \a truncate is FALSE and the length of the string is more than + \a width, then the returned string is a copy of the string. + + If \a truncate is TRUE and the length of the string is more than + \a width, then any characters in a copy of the string after length + \a width are removed, and the copy is returned. + + \code + TQString s( "apple" ); + TQString t = s.leftJustify( 8, '.' ); // t == "apple..." + \endcode + + \sa rightJustify() +*/ + +TQString TQString::leftJustify( uint width, TQChar fill, bool truncate ) const +{ + TQString result; + int len = length(); + int padlen = width - len; + if ( padlen > 0 ) { + result.setLength(len+padlen); + if ( len ) + memcpy( result.d->unicode, unicode(), sizeof(TQChar)*len ); + TQChar* uc = result.d->unicode + len; + while (padlen--) + *uc++ = fill; + } else { + if ( truncate ) + result = left( width ); + else + result = *this; + } + return result; +} + +/*! + Returns a string of length \a width that contains the \a fill + character followed by the string. + + If \a truncate is FALSE and the length of the string is more than + \a width, then the returned string is a copy of the string. + + If \a truncate is TRUE and the length of the string is more than + \a width, then the resulting string is truncated at position \a + width. + + \code + TQString string( "apple" ); + TQString t = string.rightJustify( 8, '.' ); // t == "...apple" + \endcode + + \sa leftJustify() +*/ + +TQString TQString::rightJustify( uint width, TQChar fill, bool truncate ) const +{ + TQString result; + int len = length(); + int padlen = width - len; + if ( padlen > 0 ) { + result.setLength( len+padlen ); + TQChar* uc = result.d->unicode; + while (padlen--) + *uc++ = fill; + if ( len ) + memcpy( uc, unicode(), sizeof(TQChar)*len ); + } else { + if ( truncate ) + result = left( width ); + else + result = *this; + } + return result; +} + +/*! + Returns a lowercase copy of the string. + + \code + TQString string( "TROlltECH" ); + str = string.lower(); // str == "trolltech" + \endcode + + \sa upper() +*/ + +TQString TQString::lower() const +{ + int l = length(); + register TQChar *p = d->unicode; + while ( l ) { + if ( *p != ::lower(*p) ) { + TQString s( *this ); + s.real_detach(); + p = s.d->unicode + ( p - d->unicode ); + while ( l ) { + *p = ::lower( *p ); + l--; + p++; + } + return s; + } + l--; + p++; + } + return *this; +} + +/*! + Returns an uppercase copy of the string. + + \code + TQString string( "TeXt" ); + str = string.upper(); // t == "TEXT" + \endcode + + \sa lower() +*/ + +TQString TQString::upper() const +{ + int l = length(); + register TQChar *p = d->unicode; + while ( l ) { + if ( *p != ::upper(*p) ) { + TQString s( *this ); + s.real_detach(); + p = s.d->unicode + ( p - d->unicode ); + while ( l ) { + *p = ::upper( *p ); + l--; + p++; + } + return s; + } + l--; + p++; + } + return *this; +} + + +/*! + Returns a string that has whitespace removed from the start and + the end. + + Whitespace means any character for which TQChar::isSpace() returns + TRUE. This includes Unicode characters with decimal values 9 + (TAB), 10 (LF), 11 (VT), 12 (FF), 13 (CR) and 32 (Space), and may + also include other Unicode characters. + + \code + TQString string = " white space "; + TQString s = string.stripWhiteSpace(); // s == "white space" + \endcode + + \sa simplifyWhiteSpace() +*/ + +TQString TQString::stripWhiteSpace() const +{ + if ( isEmpty() ) // nothing to do + return *this; + register const TQChar *s = unicode(); + if ( !s->isSpace() && !s[length()-1].isSpace() ) + return *this; + + int start = 0; + int end = length() - 1; + while ( start<=end && s[start].isSpace() ) // skip white space from start + start++; + if ( start <= end ) { // only white space + while ( end && s[end].isSpace() ) // skip white space from end + end--; + } + int l = end - start + 1; + if ( l <= 0 ) + return TQString::fromLatin1(""); + + TQString result( l, TRUE ); + memcpy( result.d->unicode, &s[start], sizeof(TQChar)*l ); + result.d->len = l; + return result; +} + + +/*! + Returns a string that has whitespace removed from the start and + the end, and which has each sequence of internal whitespace + replaced with a single space. + + Whitespace means any character for which TQChar::isSpace() returns + TRUE. This includes Unicode characters with decimal values 9 + (TAB), 10 (LF), 11 (VT), 12 (FF), 13 (CR), and 32 (Space). + + \code + TQString string = " lots\t of\nwhite space "; + TQString t = string.simplifyWhiteSpace(); + // t == "lots of white space" + \endcode + + \sa stripWhiteSpace() +*/ + +TQString TQString::simplifyWhiteSpace() const +{ + if ( isEmpty() ) + return *this; + TQString result; + result.setLength( length() ); + const TQChar *from = unicode(); + const TQChar *fromend = from+length(); + int outc=0; + TQChar *to = result.d->unicode; + for (;;) { + while ( from!=fromend && from->isSpace() ) + from++; + while ( from!=fromend && !from->isSpace() ) + to[outc++] = *from++; + if ( from!=fromend ) + to[outc++] = ' '; + else + break; + } + if ( outc > 0 && to[outc-1] == ' ' ) + outc--; + result.truncate( outc ); + return result; +} + + +/*! + Inserts \a s into the string at position \a index. + + If \a index is beyond the end of the string, the string is + extended with spaces to length \a index and \a s is then appended + and returns a reference to the string. + + \code + TQString string( "I like fish" ); + str = string.insert( 2, "don't " ); + // str == "I don't like fish" + \endcode + + \sa remove(), replace() +*/ + +TQString &TQString::insert( uint index, const TQString &s ) +{ + // the sub function takes care of &s == this case. + return insert( index, s.unicode(), s.length() ); +} + +/*! \fn TQString &TQString::insert( uint index, const TQByteArray &s ) + \overload + + Inserts \a s into the string at position \a index and returns + a reference to the string. +*/ + +/*! \fn TQString &TQString::insert( uint index, const char *s ) + \overload + + Inserts \a s into the string at position \a index and returns + a reference to the string. +*/ + +#ifndef QT_NO_CAST_ASCII +TQString &TQString::insertHelper( uint index, const char *s, uint len ) +{ + if ( s ) { +#ifndef QT_NO_TEXTCODEC + if ( TQTextCodec::codecForCStrings() ) + return insert( index, fromAscii( s, len ) ); +#endif + if ( len == UINT_MAX ) + len = int(strlen( s )); + if ( len == 0 ) + return *this; + + uint olen = length(); + int nlen = olen + len; + + if ( index >= olen ) { // insert after end of string + grow( len + index ); + int n = index - olen; + TQChar* uc = d->unicode + olen; + while ( n-- ) + *uc++ = ' '; + + uc = d->unicode + index; + while ( len-- ) + *uc++ = *s++; + } else { // normal insert + grow( nlen ); + memmove( d->unicode + index + len, unicode() + index, + sizeof(TQChar) * (olen - index) ); + + TQChar* uc = d->unicode + index; + while ( len-- ) + *uc++ = *s++; + } + } + return *this; +} +#endif + +/*! + \overload + + Inserts the first \a len characters in \a s into the string at + position \a index and returns a reference to the string. +*/ + +TQString &TQString::insert( uint index, const TQChar* s, uint len ) +{ + if ( len == 0 ) + return *this; + uint olen = length(); + int nlen = olen + len; + + if ( s >= d->unicode && (uint)(s - d->unicode) < d->maxl ) { + // Part of me - take a copy. + TQChar *tmp = QT_ALLOC_QCHAR_VEC( len ); + memcpy(tmp,s,len*sizeof(TQChar)); + insert(index,tmp,len); + QT_DELETE_QCHAR_VEC( tmp ); + return *this; + } + + if ( index >= olen ) { // insert after end of string + grow( len + index ); + int n = index - olen; + TQChar* uc = d->unicode+olen; + while (n--) + *uc++ = ' '; + memcpy( d->unicode+index, s, sizeof(TQChar)*len ); + } else { // normal insert + grow( nlen ); + memmove( d->unicode + index + len, unicode() + index, + sizeof(TQChar) * (olen - index) ); + memcpy( d->unicode + index, s, sizeof(TQChar) * len ); + } + return *this; +} + +/*! + \overload + + Insert \a c into the string at position \a index and returns a + reference to the string. + + If \a index is beyond the end of the string, the string is + extended with spaces (ASCII 32) to length \a index and \a c is + then appended. +*/ + +TQString &TQString::insert( uint index, TQChar c ) // insert char +{ + TQString s( c ); + return insert( index, s ); +} + +/*! + \fn TQString& TQString::insert( uint index, char c ) + + \overload + + Insert character \a c at position \a index. +*/ + +/*! + \fn TQString &TQString::prepend( const TQString &s ) + + Inserts \a s at the beginning of the string and returns a + reference to the string. + + Equivalent to insert(0, \a s). + + \code + TQString string = "42"; + string.prepend( "The answer is " ); + // string == "The answer is 42" + \endcode + + \sa insert() +*/ + +/*! + \fn TQString& TQString::prepend( char ch ) + + \overload + + Inserts \a ch at the beginning of the string and returns a + reference to the string. + + Equivalent to insert(0, \a ch). + + \sa insert() +*/ + +/*! + \fn TQString& TQString::prepend( TQChar ch ) + + \overload + + Inserts \a ch at the beginning of the string and returns a + reference to the string. + + Equivalent to insert(0, \a ch). + + \sa insert() +*/ + +/*! \fn TQString& TQString::prepend( const TQByteArray &s ) + \overload + + Inserts \a s at the beginning of the string and returns a reference to the string. + + Equivalent to insert(0, \a s). + + \sa insert() + */ + +/*! \fn TQString& TQString::prepend( const std::string &s ) + \overload + + Inserts \a s at the beginning of the string and returns a reference to the string. + + Equivalent to insert(0, \a s). + + \sa insert() +*/ + +/*! + \overload + + Inserts \a s at the beginning of the string and returns a reference to the string. + + Equivalent to insert(0, \a s). + + \sa insert() + */ +TQString &TQString::prepend( const char *s ) +{ + return insert( 0, TQString(s) ); +} + +/*! + Removes \a len characters from the string starting at position \a + index, and returns a reference to the string. + + If \a index is beyond the length of the string, nothing happens. + If \a index is within the string, but \a index + \a len is beyond + the end of the string, the string is truncated at position \a + index. + + \code + TQString string( "Montreal" ); + string.remove( 1, 4 ); // string == "Meal" + \endcode + + \sa insert(), replace() +*/ + +TQString &TQString::remove( uint index, uint len ) +{ + uint olen = length(); + if ( index >= olen ) { + // range problems + } else if ( index + len >= olen ) { // index ok + setLength( index ); + } else if ( len != 0 ) { + real_detach(); + memmove( d->unicode+index, d->unicode+index+len, + sizeof(TQChar)*(olen-index-len) ); + setLength( olen-len ); + } + return *this; +} + +/*! \overload + + Removes every occurrence of the character \a c in the string. + Returns a reference to the string. + + This is the same as replace(\a c, ""). +*/ +TQString &TQString::remove( TQChar c ) +{ + int i = 0; + while ( i < (int) length() ) { + if ( constref(i) == c ) { + remove( i, 1 ); + } else { + i++; + } + } + return *this; +} + +/*! \overload + + \fn TQString &TQString::remove( char c ) + + Removes every occurrence of the character \a c in the string. + Returns a reference to the string. + + This is the same as replace(\a c, ""). +*/ + +/*! \overload + + Removes every occurrence of \a str in the string. Returns a + reference to the string. + + If \a cs is TRUE (the default), the search is case sensitive; + otherwise the search is case insensitive. + + This is the same as replace(\a str, "", \a cs). +*/ +TQString &TQString::remove( const TQString & str, bool cs ) +{ + if ( str.isEmpty() ) { + if ( isNull() ) + real_detach(); + } else { + int index = 0; + while ( (index = find(str, index, cs)) != -1 ) + remove( index, str.length() ); + } + return *this; +} + +TQString &TQString::remove( const TQString & str ) +{ + return remove( str, TRUE ); +} + +/*! \overload + + Replaces every occurrence of \a c1 with the char \a c2. Returns a + reference to the string. +*/ +TQString &TQString::replace( TQChar c1, TQChar c2 ) +{ + if ( isEmpty() ) + return *this; + + real_detach(); + uint i = 0; + while ( i < d->len ) { + if ( d->unicode[i] == c1 ) + d->unicode[i] = c2; + i++; + } + return *this; +} + +#ifndef QT_NO_REGEXP_CAPTURE + +/*! \overload + + Removes every occurrence of the regular expression \a rx in the + string. Returns a reference to the string. + + This is the same as replace(\a rx, ""). +*/ + +TQString &TQString::remove( const TQRegExp & rx ) +{ + return replace( rx, TQString::null ); +} + +#endif + +/*! + \overload + + Removes every occurrence of \a str in the string. Returns a + reference to the string. +*/ +TQString &TQString::remove( const char *str ) +{ + return remove( TQString::fromAscii(str), TRUE ); +} + +/*! + Replaces \a len characters from the string with \a s, starting at + position \a index, and returns a reference to the string. + + If \a index is beyond the length of the string, nothing is deleted + and \a s is appended at the end of the string. If \a index is + valid, but \a index + \a len is beyond the end of the string, + the string is truncated at position \a index, then \a s is + appended at the end. + + \code + TQString string( "Say yes!" ); + string = string.replace( 4, 3, "NO" ); + // string == "Say NO!" + \endcode + + \warning TQt 3.3.3 and earlier had different semantics for the + case \a index >= length(), which contradicted the documentation. + To avoid portability problems between TQt 3 versions and with TQt + 4, we recommend that you never call the function with \a index >= + length(). + + \sa insert(), remove() +*/ + +TQString &TQString::replace( uint index, uint len, const TQString &s ) +{ + return replace( index, len, s.unicode(), s.length() ); +} + +/*! \overload + + This is the same as replace(\a index, \a len, TQString(\a c)). +*/ +TQString &TQString::replace( uint index, uint len, TQChar c ) +{ + return replace( index, len, &c, 1 ); +} + +/*! \overload + \fn TQString &TQString::replace( uint index, uint len, char c ) + + This is the same as replace(\a index, \a len, TQChar(\a c)). +*/ + +/*! + \overload + + Replaces \a len characters with \a slen characters of TQChar data + from \a s, starting at position \a index, and returns a reference + to the string. + + \sa insert(), remove() +*/ + +TQString &TQString::replace( uint index, uint len, const TQChar* s, uint slen ) +{ + if (index > length()) + index = length(); + real_detach(); + if ( len == slen && index + len <= length() ) { + // Optimized common case: replace without size change + memcpy( d->unicode+index, s, len * sizeof(TQChar) ); + } else if ( s >= d->unicode && (uint)(s - d->unicode) < d->maxl ) { + // Part of me - take a copy. + TQChar *tmp = QT_ALLOC_QCHAR_VEC( slen ); + memcpy( tmp, s, slen * sizeof(TQChar) ); + replace( index, len, tmp, slen ); + QT_DELETE_QCHAR_VEC( tmp ); + } else { + remove( index, len ); + insert( index, s, slen ); + } + return *this; +} + +/*! \overload + + Replaces every occurrence of the character \a c in the string + with \a after. Returns a reference to the string. + + If \a cs is TRUE (the default), the search is case sensitive; + otherwise the search is case insensitive. + + Example: + \code + TQString s = "a,b,c"; + s.replace( TQChar(','), " or " ); + // s == "a or b or c" + \endcode +*/ +TQString &TQString::replace( TQChar c, const TQString & after, bool cs ) +{ + return replace( TQString( c ), after, cs ); +} + +TQString &TQString::replace( TQChar c, const TQString & after ) +{ + return replace( TQString( c ), after, TRUE ); +} + +/*! \overload + \fn TQString &TQString::replace( char c, const TQString & after, bool cs ) + + Replaces every occurrence of the character \a c in the string + with \a after. Returns a reference to the string. + + If \a cs is TRUE (the default), the search is case sensitive; + otherwise the search is case insensitive. +*/ + +/*! \overload + + Replaces every occurrence of the string \a before in the string + with the string \a after. Returns a reference to the string. + + If \a cs is TRUE (the default), the search is case sensitive; + otherwise the search is case insensitive. + + Example: + \code + TQString s = "Greek is Greek"; + s.replace( "Greek", "English" ); + // s == "English is English" + \endcode +*/ +TQString &TQString::replace( const TQString & before, const TQString & after, + bool cs ) +{ + if ( isEmpty() ) { + if ( !before.isEmpty() ) + return *this; + } else { + if ( cs && before == after ) + return *this; + } + + real_detach(); + + int index = 0; + uint skiptable[256]; + bm_init_skiptable( before, skiptable, cs ); + const int bl = before.length(); + const int al = after.length(); + + if ( bl == al ) { + if ( bl ) { + const TQChar *auc = after.unicode(); + while ( (index = bm_find(*this, index, before, skiptable, cs) ) != -1 ) { + memcpy( d->unicode + index, auc, al * sizeof(TQChar) ); + index += bl; + } + } + } else if ( al < bl ) { + const TQChar *auc = after.unicode(); + uint to = 0; + uint movestart = 0; + uint num = 0; + while ( (index = bm_find(*this, index, before, skiptable, cs)) != -1 ) { + if ( num ) { + int msize = index - movestart; + if ( msize > 0 ) { + memmove( d->unicode + to, d->unicode + movestart, msize*sizeof(TQChar) ); + to += msize; + } + } else { + to = index; + } + if ( al ) { + memcpy( d->unicode+to, auc, al*sizeof(TQChar) ); + to += al; + } + index += bl; + movestart = index; + num++; + } + if ( num ) { + int msize = d->len - movestart; + if ( msize > 0 ) + memmove( d->unicode + to, d->unicode + movestart, msize*sizeof(TQChar) ); + setLength( d->len - num*(bl-al) ); + } + } else { + // the most complex case. We don't want to loose performance by doing repeated + // copies and reallocs of the string. + while ( index != -1 ) { + uint indices[4096]; + uint pos = 0; + while ( pos < 4095 ) { + index = bm_find( *this, index, before, skiptable, cs ); + if ( index == -1 ) + break; + indices[pos++] = index; + index += bl; + // avoid infinite loop + if ( !bl ) + index++; + } + if ( !pos ) + break; + + // we have a table of replacement positions, use them for fast replacing + int adjust = pos*(al-bl); + // index has to be adjusted in case we get back into the loop above. + if ( index != -1 ) + index += adjust; + uint newlen = d->len + adjust; + int moveend = d->len; + if ( newlen > d->len ) + setLength( newlen ); + + while ( pos ) { + pos--; + int movestart = indices[pos] + bl; + int insertstart = indices[pos] + pos*(al-bl); + int moveto = insertstart + al; + memmove( d->unicode + moveto, d->unicode + movestart, (moveend - movestart)*sizeof(TQChar) ); + memcpy( d->unicode + insertstart, after.unicode(), al*sizeof(TQChar) ); + moveend = movestart-bl; + } + } + } + return *this; +} + +TQString &TQString::replace( const TQString & before, const TQString & after ) +{ + return replace( before, after, TRUE ); +} + +#ifndef QT_NO_REGEXP_CAPTURE +/*! \overload + + Replaces every occurrence of the regexp \a rx in the string with + \a after. Returns a reference to the string. For example: + \code + TQString s = "banana"; + s.replace( TQRegExp("an"), "" ); + // s == "ba" + \endcode + + For regexps containing \link qregexp.html#capturing-text capturing + parentheses \endlink, occurrences of \\1, \\2, ..., + in \a after are replaced with \a{rx}.cap(1), cap(2), ... + + \code + TQString t = "A bon mot."; + t.replace( TQRegExp("([^<]*)"), "\\emph{\\1}" ); + // t == "A \\emph{bon mot}." + \endcode + + \sa find(), findRev(), TQRegExp::cap() +*/ + +TQString &TQString::replace( const TQRegExp &rx, const TQString &after ) +{ + TQRegExp rx2 = rx; + + if ( isEmpty() && rx2.search(*this) == -1 ) + return *this; + + real_detach(); + + int index = 0; + int numCaptures = rx2.numCaptures(); + int al = after.length(); + TQRegExp::CaretMode caretMode = TQRegExp::CaretAtZero; + + if ( numCaptures > 0 ) { + if ( numCaptures > 9 ) + numCaptures = 9; + + const TQChar *uc = after.unicode(); + int numBackRefs = 0; + + for ( int i = 0; i < al - 1; i++ ) { + if ( uc[i] == '\\' ) { + int no = uc[i + 1].digitValue(); + if ( no > 0 && no <= numCaptures ) + numBackRefs++; + } + } + + /* + This is the harder case where we have back-references. + We don't try to optimize it. + */ + if ( numBackRefs > 0 ) { + int *capturePositions = new int[numBackRefs]; + int *captureNumbers = new int[numBackRefs]; + int j = 0; + + for ( int i = 0; i < al - 1; i++ ) { + if ( uc[i] == '\\' ) { + int no = uc[i + 1].digitValue(); + if ( no > 0 && no <= numCaptures ) { + capturePositions[j] = i; + captureNumbers[j] = no; + j++; + } + } + } + + while ( index <= (int)length() ) { + index = rx2.search( *this, index, caretMode ); + if ( index == -1 ) + break; + + TQString after2 = after; + for ( j = numBackRefs - 1; j >= 0; j-- ) + after2.replace( capturePositions[j], 2, + rx2.cap(captureNumbers[j]) ); + + replace( index, rx2.matchedLength(), after2 ); + index += after2.length(); + + if ( rx2.matchedLength() == 0 ) { + // avoid infinite loop on 0-length matches (e.g., [a-z]*) + index++; + } + caretMode = TQRegExp::CaretWontMatch; + } + delete[] capturePositions; + delete[] captureNumbers; + return *this; + } + } + + /* + This is the simple and optimized case where we don't have + back-references. + */ + while ( index != -1 ) { + struct { + int pos; + int length; + } replacements[2048]; + + uint pos = 0; + int adjust = 0; + while ( pos < 2047 ) { + index = rx2.search( *this, index, caretMode ); + if ( index == -1 ) + break; + int ml = rx2.matchedLength(); + replacements[pos].pos = index; + replacements[pos++].length = ml; + index += ml; + adjust += al - ml; + // avoid infinite loop + if ( !ml ) + index++; + } + if ( !pos ) + break; + replacements[pos].pos = d->len; + uint newlen = d->len + adjust; + + // to continue searching at the right position after we did + // the first round of replacements + if ( index != -1 ) + index += adjust; + TQChar *newuc = QT_ALLOC_QCHAR_VEC( newlen + 1 ); + TQChar *uc = newuc; + int copystart = 0; + uint i = 0; + while ( i < pos ) { + int copyend = replacements[i].pos; + int size = copyend - copystart; + memcpy( uc, d->unicode + copystart, size * sizeof(TQChar) ); + uc += size; + memcpy( uc, after.unicode(), al * sizeof(TQChar) ); + uc += al; + copystart = copyend + replacements[i].length; + i++; + } + memcpy( uc, d->unicode + copystart, + (d->len - copystart) * sizeof(TQChar) ); + QT_DELETE_QCHAR_VEC( d->unicode ); + d->unicode = newuc; + d->len = newlen; + d->maxl = newlen + 1; + d->setDirty(); + caretMode = TQRegExp::CaretWontMatch; + } + return *this; +} +#endif + +#ifndef QT_NO_REGEXP +/*! + Finds the first match of the regular expression \a rx, starting + from position \a index. If \a index is -1, the search starts at + the last character; if -2, at the next to last character and so + on. (See findRev() for searching backwards.) + + Returns the position of the first match of \a rx or -1 if no match + was found. + + \code + TQString string( "bananas" ); + int i = string.find( TQRegExp("an"), 0 ); // i == 1 + \endcode + + \sa findRev() replace() contains() +*/ + +int TQString::find( const TQRegExp &rx, int index ) const +{ + return rx.search( *this, index ); +} + +/*! + \overload + + Finds the first match of the regexp \a rx, starting at position \a + index and searching backwards. If the index is -1, the search + starts at the last character, if it is -2, at the next to last + character and so on. (See findRev() for searching backwards.) + + Returns the position of the match or -1 if no match was found. + + \code + TQString string( "bananas" ); + int i = string.findRev( TQRegExp("an") ); // i == 3 + \endcode + + \sa find() +*/ + +int TQString::findRev( const TQRegExp &rx, int index ) const +{ + return rx.searchRev( *this, index ); +} + +/*! + \overload + + Returns the number of times the regexp, \a rx, matches in the + string. + + This function counts overlapping matches, so in the example below, + there are four instances of "ana" or "ama". + + \code + TQString str = "banana and panama"; + TQRegExp rxp = TQRegExp( "a[nm]a", TRUE, FALSE ); + int i = str.contains( rxp ); // i == 4 + \endcode + + \sa find() findRev() +*/ + +int TQString::contains( const TQRegExp &rx ) const +{ + int count = 0; + int index = -1; + int len = length(); + while ( index < len - 1 ) { // count overlapping matches + index = rx.search( *this, index + 1 ); + if ( index == -1 ) + break; + count++; + } + return count; +} + +#endif //QT_NO_REGEXP + +/*! + Returns the string converted to a \c long using base \a + base, which is 10 by default and must be between 2 and 36 or 0. If + \a base is 0, the base is determined automatically using the + following rules: +
    +
  • If the string begins with "0x", it is assumed to + be hexadecimal; +
  • If it begins with "0", it is assumed to be octal; +
  • Otherwise it is assumed to be decimal. +
+ + Returns 0 if the conversion fails. + + If \a ok is not 0: if a conversion error occurs, \a *ok is set to + FALSE; otherwise \a *ok is set to TRUE. + + Leading and trailing whitespace is ignored by this function. + + For information on how string-to-number functions in TQString handle + localized input, see toDouble(). + + \sa number() +*/ + +long TQString::toLong( bool *ok, int base ) const +{ + Q_LLONG v = toLongLong( ok, base ); + if ( v < LONG_MIN || v > LONG_MAX ) { + if ( ok ) + *ok = FALSE; + v = 0; + } + return long(v); +} + +/*! + Returns the string converted to a \c {long long} using base \a + base, which is 10 by default and must be between 2 and 36 or 0. If + \a base is 0, the base is determined automatically using the + following rules: +
    +
  • If the string begins with "0x", it is assumed to + be hexadecimal; +
  • If it begins with "0", it is assumed to be octal; +
  • Otherwise it is assumed to be decimal. +
+ + Returns 0 if the conversion fails. + + If \a ok is not 0: if a conversion error occurs, \a *ok is set to + FALSE; otherwise \a *ok is set to TRUE. + + Leading and trailing whitespace is ignored by this function. + + For information on how string-to-number functions in TQString handle + localized input, see toDouble(). + + \sa number() +*/ + +Q_LLONG TQString::toLongLong( bool *ok, int base ) const +{ +#if defined(QT_CHECK_RANGE) + if ( base != 0 && (base < 2 || base > 36) ) { + qWarning( "TQString::toLongLong: Invalid base (%d)", base ); + base = 10; + } +#endif + + bool my_ok; + TQLocale def_locale; + Q_LLONG result = def_locale.d->stringToLongLong(*this, base, &my_ok, TQLocalePrivate::FailOnGroupSeparators); + if (my_ok) { + if (ok != 0) + *ok = TRUE; + return result; + } + + // If the default was not "C", try the "C" locale + if (def_locale.language() == TQLocale::C) { + if (ok != 0) + *ok = FALSE; + return 0; + } + + TQLocale c_locale(TQLocale::C); + return c_locale.d->stringToLongLong(*this, base, ok, TQLocalePrivate::FailOnGroupSeparators); +} + +/*! + Returns the string converted to an \c {unsigned long} using base \a + base, which is 10 by default and must be between 2 and 36 or 0. If + \a base is 0, the base is determined automatically using the + following rules: +
    +
  • If the string begins with "0x", it is assumed to + be hexadecimal; +
  • If it begins with "0", it is assumed to be octal; +
  • Otherwise it is assumed to be decimal. +
+ + Returns 0 if the conversion fails. + + If \a ok is not 0: if a conversion error occurs, \a *ok is set to + FALSE; otherwise \a *ok is set to TRUE. + + Leading and trailing whitespace is ignored by this function. + + For information on how string-to-number functions in TQString handle + localized input, see toDouble(). + + \sa number() +*/ + +ulong TQString::toULong( bool *ok, int base ) const +{ + Q_ULLONG v = toULongLong( ok, base ); + if ( v > ULONG_MAX ) { + if ( ok ) + *ok = FALSE; + v = 0; + } + return ulong(v); +} + +/*! + Returns the string converted to an \c {unsigned long long} using base \a + base, which is 10 by default and must be between 2 and 36 or 0. If + \a base is 0, the base is determined automatically using the + following rules: +
    +
  • If the string begins with "0x", it is assumed to + be hexadecimal; +
  • If it begins with "0", it is assumed to be octal; +
  • Otherwise it is assumed to be decimal. +
+ + Returns 0 if the conversion fails. + + If \a ok is not 0: if a conversion error occurs, \a *ok is set to + FALSE; otherwise \a *ok is set to TRUE. + + Leading and trailing whitespace is ignored by this function. + + For information on how string-to-number functions in TQString handle + localized input, see toDouble(). + + \sa number() +*/ + +Q_ULLONG TQString::toULongLong( bool *ok, int base ) const +{ +#if defined(QT_CHECK_RANGE) + if ( base != 0 && (base < 2 || base > 36) ) { + qWarning( "TQString::toULongLong: Invalid base %d", base ); + base = 10; + } +#endif + + bool my_ok; + TQLocale def_locale; + Q_ULLONG result = def_locale.d->stringToUnsLongLong(*this, base, &my_ok, TQLocalePrivate::FailOnGroupSeparators); + if (my_ok) { + if (ok != 0) + *ok = TRUE; + return result; + } + + // If the default was not "C", try the "C" locale + if (def_locale.language() == TQLocale::C) { + if (ok != 0) + *ok = FALSE; + return 0; + } + + TQLocale c_locale(TQLocale::C); + return c_locale.d->stringToUnsLongLong(*this, base, ok, TQLocalePrivate::FailOnGroupSeparators); +} + +/*! + Returns the string converted to a \c short using base \a + base, which is 10 by default and must be between 2 and 36 or 0. If + \a base is 0, the base is determined automatically using the + following rules: +
    +
  • If the string begins with "0x", it is assumed to + be hexadecimal; +
  • If it begins with "0", it is assumed to be octal; +
  • Otherwise it is assumed to be decimal. +
+ + + Returns 0 if the conversion fails. + + If \a ok is not 0: if a conversion error occurs, \a *ok is set to + FALSE; otherwise \a *ok is set to TRUE. + + Leading and trailing whitespace is ignored by this function. + + For information on how string-to-number functions in TQString handle + localized input, see toDouble(). + + \sa number() +*/ + + +short TQString::toShort( bool *ok, int base ) const +{ + Q_LLONG v = toLongLong( ok, base ); + if ( v < SHRT_MIN || v > SHRT_MAX ) { + if ( ok ) + *ok = FALSE; + v = 0; + } + return (short)v; +} + +/*! + Returns the string converted to an \c {unsigned short} using base \a + base, which is 10 by default and must be between 2 and 36 or 0. If + \a base is 0, the base is determined automatically using the + following rules: +
    +
  • If the string begins with "0x", it is assumed to + be hexadecimal; +
  • If it begins with "0", it is assumed to be octal; +
  • Otherwise it is assumed to be decimal. +
+ + + Returns 0 if the conversion fails. + + If \a ok is not 0: if a conversion error occurs, \a *ok is set to + FALSE; otherwise \a *ok is set to TRUE. + + Leading and trailing whitespace is ignored by this function. + + For information on how string-to-number functions in TQString handle + localized input, see toDouble(). + + \sa number() +*/ + +ushort TQString::toUShort( bool *ok, int base ) const +{ + Q_ULLONG v = toULongLong( ok, base ); + if ( v > USHRT_MAX ) { + if ( ok ) + *ok = FALSE; + v = 0; + } + return (ushort)v; +} + + +/*! + Returns the string converted to an \c int using base \a + base, which is 10 by default and must be between 2 and 36 or 0. If + \a base is 0, the base is determined automatically using the + following rules: +
    +
  • If the string begins with "0x", it is assumed to + be hexadecimal; +
  • If it begins with "0", it is assumed to be octal; +
  • Otherwise it is assumed to be decimal. +
+ + + Returns 0 if the conversion fails. + + If \a ok is not 0: if a conversion error occurs, \a *ok is set to + FALSE; otherwise \a *ok is set to TRUE. + + \code + TQString str( "FF" ); + bool ok; + int hex = str.toInt( &ok, 16 ); // hex == 255, ok == TRUE + int dec = str.toInt( &ok, 10 ); // dec == 0, ok == FALSE + \endcode + + Leading and trailing whitespace is ignored by this function. + + For information on how string-to-number functions in TQString handle + localized input, see toDouble(). + + \sa number() +*/ + +int TQString::toInt( bool *ok, int base ) const +{ + Q_LLONG v = toLongLong( ok, base ); + if ( v < INT_MIN || v > INT_MAX ) { + if ( ok ) + *ok = FALSE; + v = 0; + } + return (int)v; +} + +/*! + Returns the string converted to an \c {unsigned int} using base \a + base, which is 10 by default and must be between 2 and 36 or 0. If + \a base is 0, the base is determined automatically using the + following rules: +
    +
  • If the string begins with "0x", it is assumed to + be hexadecimal; +
  • If it begins with "0", it is assumed to be octal; +
  • Otherwise it is assumed to be decimal. +
+ + Returns 0 if the conversion fails. + + If \a ok is not 0: if a conversion error occurs, \a *ok is set to + FALSE; otherwise \a *ok is set to TRUE. + + Leading and trailing whitespace is ignored by this function. + + For information on how string-to-number functions in TQString handle + localized input, see toDouble(). + + \sa number() +*/ + +uint TQString::toUInt( bool *ok, int base ) const +{ + Q_ULLONG v = toULongLong( ok, base ); + if ( v > UINT_MAX ) { + if ( ok ) + *ok = FALSE; + v = 0; + } + return (uint)v; +} + +/*! + Returns the string converted to a \c double value. + + If \a ok is not 0: if a conversion error occurs, \a *ok is set to + FALSE; otherwise \a *ok is set to TRUE. + + \code + TQString string( "1234.56" ); + double a = string.toDouble(); // a == 1234.56 + \endcode + + The string-to-number functions: + \list + \i toShort() + \i toUShort() + \i toInt() + \i toUInt() + \i toLong() + \i toULong() + \i toLongLong() + \i toULongLong() + \i toFloat() + \i toDouble() + \endlist + can handle numbers + represented in various locales. These representations may use different + characters for the decimal point, thousands group sepearator + and even individual digits. TQString's functions try to interpret + the string according to the current locale. The current locale is + determined from the system at application startup and can be changed + by calling TQLocale::setDefault(). If the string cannot be interpreted + according to the current locale, this function falls back + on the "C" locale. + + \code + bool ok; + double d; + + TQLocale::setDefault(TQLocale::C); + d = TQString( "1234,56" ).toDouble(&ok); // ok == false + d = TQString( "1234.56" ).toDouble(&ok); // ok == true, d == 1234.56 + + TQLocale::setDefault(TQLocale::German); + d = TQString( "1234,56" ).toDouble(&ok); // ok == true, d == 1234.56 + d = TQString( "1234.56" ).toDouble(&ok); // ok == true, d == 1234.56 + \endcode + + Due to the ambiguity between the decimal point and thousands group + separator in various locales, these functions do not handle + thousands group separators. If you need to convert such numbers, + use the corresponding function in TQLocale. + + \code + bool ok; + TQLocale::setDefault(TQLocale::C); + double d = TQString( "1,234,567.89" ).toDouble(&ok); // ok == false + \endcode + + \warning If the string contains trailing whitespace this function + will fail, and set \a *ok to false if \a ok is not 0. Leading + whitespace is ignored. + + \sa number() TQLocale::setDefault() TQLocale::toDouble() stripWhiteSpace() +*/ + +double TQString::toDouble( bool *ok ) const +{ + // If there is trailing whitespace, set ok to false but return the correct + // result anyway to preserve behavour of pervious versions of TQt + if (length() > 0 && unicode()[length() - 1].isSpace()) { + TQString tmp = stripWhiteSpace(); + if (ok != 0) + *ok = FALSE; + return tmp.toDouble(); + } + + // Try the default locale + bool my_ok; + TQLocale def_locale; + double result = def_locale.d->stringToDouble(*this, &my_ok, TQLocalePrivate::FailOnGroupSeparators); + if (my_ok) { + if (ok != 0) + *ok = TRUE; + return result; + } + + // If the default was not "C", try the "C" locale + if (def_locale.language() == TQLocale::C) { + if (ok != 0) + *ok = FALSE; + return 0.0; + } + + TQLocale c_locale(TQLocale::C); + return c_locale.d->stringToDouble(*this, ok, TQLocalePrivate::FailOnGroupSeparators); +} + +/*! + Returns the string converted to a \c float value. + + Returns 0.0 if the conversion fails. + + If \a ok is not 0: if a conversion error occurs, \a *ok is set to + FALSE; otherwise \a *ok is set to TRUE. + + For information on how string-to-number functions in TQString handle + localized input, see toDouble(). + + \warning If the string contains trailing whitespace this function + will fail, settings \a *ok to false if \a ok is not 0. + Leading whitespace is ignored. + + \sa number() +*/ + +#define QT_MAX_FLOAT 3.4028234663852886e+38 + +float TQString::toFloat( bool *ok ) const +{ + bool myOk; + double d = toDouble(&myOk); + if (!myOk || d > QT_MAX_FLOAT || d < -QT_MAX_FLOAT) { + if (ok != 0) + *ok = FALSE; + return 0.0; + } + if (ok != 0) + *ok = TRUE; + return (float) d; +} + +/*! + Sets the string to the printed value of \a n in base \a base and + returns a reference to the string. The returned string is in "C" locale. + + The base is 10 by default and must be between 2 and 36. + + \code + TQString string; + string = string.setNum( 1234 ); // string == "1234" + \endcode +*/ + +TQString &TQString::setNum( Q_LLONG n, int base ) +{ +#if defined(QT_CHECK_RANGE) + if ( base < 2 || base > 36 ) { + qWarning( "TQString::setNum: Invalid base %d", base ); + base = 10; + } +#endif + TQLocale locale(TQLocale::C); + *this = locale.d->longLongToString(n, -1, base); + return *this; +} + +/*! + \overload + + Sets the string to the printed value of \a n in base \a base and + returns a reference to the string. + + The base is 10 by default and must be between 2 and 36. +*/ + +TQString &TQString::setNum( Q_ULLONG n, int base ) +{ +#if defined(QT_CHECK_RANGE) + if ( base < 2 || base > 36 ) { + qWarning( "TQString::setNum: Invalid base %d", base ); + base = 10; + } +#endif + TQLocale locale(TQLocale::C); + *this = locale.d->unsLongLongToString(n, -1, base); + return *this; +} + +/*! + \fn TQString &TQString::setNum( long n, int base ) + + \overload +*/ +// ### 4.0: inline +TQString &TQString::setNum( long n, int base ) +{ + return setNum( (Q_LLONG)n, base ); +} + +/*! + \fn TQString &TQString::setNum( ulong n, int base ) + + \overload +*/ +// ### 4.0: inline +TQString &TQString::setNum( ulong n, int base ) +{ + return setNum( (Q_ULLONG)n, base ); +} + +/*! + \fn TQString &TQString::setNum( int n, int base ) + + \overload + + Sets the string to the printed value of \a n in base \a base and + returns a reference to the string. + + The base is 10 by default and must be between 2 and 36. +*/ + +/*! + \fn TQString &TQString::setNum( uint n, int base ) + + \overload + + Sets the string to the printed value of \a n in base \a base and + returns a reference to the string. + + The base is 10 by default and must be between 2 and 36. +*/ + +/*! + \fn TQString &TQString::setNum( short n, int base ) + + \overload + + Sets the string to the printed value of \a n in base \a base and + returns a reference to the string. + + The base is 10 by default and must be between 2 and 36. +*/ + +/*! + \fn TQString &TQString::setNum( ushort n, int base ) + + \overload + + Sets the string to the printed value of \a n in base \a base and + returns a reference to the string. + + The base is 10 by default and must be between 2 and 36. +*/ + +/*! + \overload + + Sets the string to the printed value of \a n, formatted in format + \a f with precision \a prec, and returns a reference to the + string. + + The format \a f can be 'f', 'F', 'e', 'E', 'g' or 'G'. See \link + #arg-formats arg \endlink() for an explanation of the formats. +*/ + +TQString &TQString::setNum( double n, char f, int prec ) +{ + TQLocalePrivate::DoubleForm form = TQLocalePrivate::DFDecimal; + uint flags = 0; + + if (qIsUpper(f)) + flags = TQLocalePrivate::CapitalEorX; + f = qToLower(f); + + switch (f) { + case 'f': + form = TQLocalePrivate::DFDecimal; + break; + case 'e': + form = TQLocalePrivate::DFExponent; + break; + case 'g': + form = TQLocalePrivate::DFSignificantDigits; + break; + default: +#if defined(QT_CHECK_RANGE) + qWarning( "TQString::setNum: Invalid format char '%c'", f ); +#endif + break; + } + + TQLocale locale(TQLocale::C); + *this = locale.d->doubleToString(n, prec, form, -1, flags); + return *this; +} + +/*! + \fn TQString &TQString::setNum( float n, char f, int prec ) + + \overload + + Sets the string to the printed value of \a n, formatted in format + \a f with precision \a prec, and returns a reference to the + string. + + The format \a f can be 'f', 'F', 'e', 'E', 'g' or 'G'. See \link + #arg-formats arg \endlink() for an explanation of the formats. +*/ + + +/*! + A convenience function that returns a string equivalent of the + number \a n to base \a base, which is 10 by default and must be + between 2 and 36. The returned string is in "C" locale. + + \code + long a = 63; + TQString str = TQString::number( a, 16 ); // str == "3f" + TQString str = TQString::number( a, 16 ).upper(); // str == "3F" + \endcode + + \sa setNum() +*/ +TQString TQString::number( long n, int base ) +{ + TQString s; + s.setNum( n, base ); + return s; +} + +/*! + \overload + + \sa setNum() +*/ +TQString TQString::number( ulong n, int base ) +{ + TQString s; + s.setNum( n, base ); + return s; +} + +/*! + \overload + + \sa setNum() +*/ +TQString TQString::number( Q_LLONG n, int base ) +{ + TQString s; + s.setNum( n, base ); + return s; +} + +/*! + \overload + + \sa setNum() +*/ +TQString TQString::number( Q_ULLONG n, int base ) +{ + TQString s; + s.setNum( n, base ); + return s; +} + +/*! + \overload + + \sa setNum() +*/ +TQString TQString::number( int n, int base ) +{ + TQString s; + s.setNum( n, base ); + return s; +} + +/*! + \overload + + A convenience factory function that returns a string + representation of the number \a n to the base \a base, which is 10 + by default and must be between 2 and 36. + + \sa setNum() +*/ +TQString TQString::number( uint n, int base ) +{ + TQString s; + s.setNum( n, base ); + return s; +} + +/*! + \overload + + Argument \a n is formatted according to the \a f format specified, + which is \c g by default, and can be any of the following: + + \table + \header \i Format \i Meaning + \row \i \c e \i format as [-]9.9e[+|-]999 + \row \i \c E \i format as [-]9.9E[+|-]999 + \row \i \c f \i format as [-]9.9 + \row \i \c g \i use \c e or \c f format, whichever is the most concise + \row \i \c G \i use \c E or \c f format, whichever is the most concise + \endtable + + With 'e', 'E', and 'f', \a prec is the number of digits after the + decimal point. With 'g' and 'G', \a prec is the maximum number of + significant digits (trailing zeroes are omitted). + + \code + double d = 12.34; + TQString ds = TQString( "'E' format, precision 3, gives %1" ) + .arg( d, 0, 'E', 3 ); + // ds == "1.234E+001" + \endcode + + \sa setNum() + */ +TQString TQString::number( double n, char f, int prec ) +{ + TQString s; + s.setNum( n, f, prec ); + return s; +} + + +/*! \obsolete + + Sets the character at position \a index to \a c and expands the + string if necessary, filling with spaces. + + This method is redundant in TQt 3.x, because operator[] will expand + the string as necessary. +*/ + +void TQString::setExpand( uint index, TQChar c ) +{ + int spaces = index - d->len; + at(index) = c; + while (spaces-->0) + d->unicode[--index]=' '; +} + + +/*! + \fn const char* TQString::data() const + + \obsolete + + Returns a pointer to a '\0'-terminated classic C string. + + In TQt 1.x, this returned a char* allowing direct manipulation of the + string as a sequence of bytes. In TQt 2.x where TQString is a Unicode + string, char* conversion constructs a temporary string, and hence + direct character operations are meaningless. +*/ + +/*! + \fn bool TQString::operator!() const + + Returns TRUE if this is a null string; otherwise returns FALSE. + + \code + TQString name = getName(); + if ( !name ) + name = "Rodney"; + \endcode + + Note that if you say + + \code + TQString name = getName(); + if ( name ) + doSomethingWith(name); + \endcode + + It will call "operator const char*()", which is inefficent; you + may wish to define the macro \c QT_NO_ASCII_CAST when writing code + which you wish to remain Unicode-clean. + + When you want the above semantics, use: + + \code + TQString name = getName(); + if ( !name.isNull() ) + doSomethingWith(name); + \endcode + + \sa isEmpty() +*/ + + +/*! + \fn TQString& TQString::append( const TQString& str ) + + Appends \a str to the string and returns a reference to the + result. + + \code + string = "Test"; + string.append( "ing" ); // string == "Testing" + \endcode + + Equivalent to operator+=(). +*/ + +/*! + \fn TQString& TQString::append( char ch ) + + \overload + + Appends character \a ch to the string and returns a reference to + the result. + + Equivalent to operator+=(). +*/ + +/*! + \fn TQString& TQString::append( TQChar ch ) + + \overload + + Appends character \a ch to the string and returns a reference to + the result. + + Equivalent to operator+=(). +*/ + +/*! \fn TQString& TQString::append( const TQByteArray &str ) + \overload + + Appends \a str to the string and returns a reference to the result. + + Equivalent to operator+=(). +*/ + +/*! \fn TQString& TQString::append( const std::string &str ) + \overload + + Appends \a str to the string and returns a reference to the result. + + Equivalent to operator+=(). +*/ + +/*! \fn TQString& TQString::append( const char *str ) + \overload + + Appends \a str to the string and returns a reference to the result. + + Equivalent to operator+=(). +*/ + +/*! + Appends \a str to the string and returns a reference to the string. +*/ +TQString& TQString::operator+=( const TQString &str ) +{ + uint len1 = length(); + uint len2 = str.length(); + if ( len2 ) { + if ( isEmpty() ) { + operator=( str ); + } else { + grow( len1+len2 ); + memcpy( d->unicode+len1, str.unicode(), sizeof(TQChar)*len2 ); + } + } else if ( isNull() && !str.isNull() ) { // ## just for 1.x compat: + *this = fromLatin1( "" ); + } + return *this; +} + +#ifndef QT_NO_CAST_ASCII +TQString &TQString::operatorPlusEqHelper( const char *s, uint len2 ) +{ + if ( s ) { +#ifndef QT_NO_TEXTCODEC + if ( TQTextCodec::codecForCStrings() ) + return operator+=( fromAscii( s, len2 ) ); +#endif + + uint len1 = length(); + if ( len2 == UINT_MAX ) + len2 = int(strlen( s )); + if ( len2 ) { + grow( len1 + len2 ); + TQChar* uc = d->unicode + len1; + while ( len2-- ) + *uc++ = *s++; + } else if ( isNull() ) { // ## just for 1.x compat: + *this = fromLatin1( "" ); + } + } + return *this; +} +#endif + +/*! + \overload + + Appends \a str to the string and returns a reference to the string. +*/ +#ifndef QT_NO_CAST_ASCII +TQString& TQString::operator+=( const char *str ) +{ + // ### TQt 4: make this function inline + return operatorPlusEqHelper( str ); +} +#endif + +/*! \overload + + Appends \a c to the string and returns a reference to the string. +*/ + +TQString &TQString::operator+=( TQChar c ) +{ + grow( length()+1 ); + d->unicode[length()-1] = c; + return *this; +} + +/*! + \overload + + Appends \a c to the string and returns a reference to the string. +*/ + +TQString &TQString::operator+=( char c ) +{ +#ifndef QT_NO_TEXTCODEC + if ( TQTextCodec::codecForCStrings() ) + return operator+=( fromAscii( &c, 1 ) ); +#endif + grow( length()+1 ); + d->unicode[length()-1] = c; + return *this; +} + +/*! + \fn TQString &TQString::operator+=( const TQByteArray &str ) + \overload + + Appends \a str to the string and returns a reference to the string. +*/ + +/*! + \fn TQString &TQString::operator+=( const std::string &str ) + \overload + + Appends \a str to the string and returns a reference to the string. +*/ + +/*! + \fn char TQChar::latin1() const + + Returns the Latin-1 value of this character, or 0 if it + cannot be represented in Latin-1. +*/ + + +/*! + Returns a Latin-1 representation of the string. The + returned value is undefined if the string contains non-Latin-1 + characters. If you want to convert strings into formats other than + Unicode, see the TQTextCodec classes. + + This function is mainly useful for boot-strapping legacy code to + use Unicode. + + The result remains valid so long as one unmodified copy of the + source string exists. + + \sa fromLatin1(), ascii(), utf8(), local8Bit() +*/ +const char* TQString::latin1() const +{ + if ( !d->ascii || !d->islatin1 ) { + delete [] d->ascii; + d->ascii = unicodeToLatin1( d->unicode, d->len ); + d->islatin1 = TRUE; + } + return d->ascii; +} + +/*! + Returns an 8-bit ASCII representation of the string. + + If a codec has been set using TQTextCodec::codecForCStrings(), + it is used to convert Unicode to 8-bit char. Otherwise, this function + does the same as latin1(). + + \sa fromAscii(), latin1(), utf8(), local8Bit() +*/ +const char* TQString::ascii() const +{ +#ifndef QT_NO_TEXTCODEC + if ( TQTextCodec::codecForCStrings() ) { + if ( !d->ascii || d->islatin1 ) { + delete [] d->ascii; + if (d->unicode) { + TQCString s = TQTextCodec::codecForCStrings()->fromUnicode( *this ); + d->ascii = new char[s.length() + 1]; + memcpy(d->ascii, s.data(), s.length() + 1); + } else { + d->ascii = 0; + } + d->islatin1 = FALSE; + } + return d->ascii; + } +#endif // QT_NO_TEXTCODEC + return latin1(); +} + +/*! + Returns the string encoded in UTF-8 format. + + See TQTextCodec for more diverse coding/decoding of Unicode strings. + + \sa fromUtf8(), ascii(), latin1(), local8Bit() +*/ +TQCString TQString::utf8() const +{ + int l = length(); + int rlen = l*3+1; + TQCString rstr(rlen); + uchar* cursor = (uchar*)rstr.data(); + const TQChar *ch = d->unicode; + for (int i=0; i < l; i++) { + uint u = ch->unicode(); + if ( u < 0x80 ) { + *cursor++ = (uchar)u; + } else { + if ( u < 0x0800 ) { + *cursor++ = 0xc0 | ((uchar) (u >> 6)); + } else { + if (u >= 0xd800 && u < 0xdc00 && i < l-1) { + unsigned short low = ch[1].unicode(); + if (low >= 0xdc00 && low < 0xe000) { + ++ch; + ++i; + u = (u - 0xd800)*0x400 + (low - 0xdc00) + 0x10000; + } + } + if (u > 0xffff) { + // if people are working in utf8, but strings are encoded in eg. latin1, the resulting + // name might be invalid utf8. This and the corresponding code in fromUtf8 takes care + // we can handle this without loosing information. This can happen with latin filenames + // and a utf8 locale under Unix. + if (u > 0x10fe00 && u < 0x10ff00) { + *cursor++ = (u - 0x10fe00); + ++ch; + continue; + } else { + *cursor++ = 0xf0 | ((uchar) (u >> 18)); + *cursor++ = 0x80 | ( ((uchar) (u >> 12)) & 0x3f); + } + } else { + *cursor++ = 0xe0 | ((uchar) (u >> 12)); + } + *cursor++ = 0x80 | ( ((uchar) (u >> 6)) & 0x3f); + } + *cursor++ = 0x80 | ((uchar) (u&0x3f)); + } + ++ch; + } + rstr.truncate( cursor - (uchar*)rstr.data() ); + return rstr; +} + +static TQChar *addOne(TQChar *qch, TQString &str) +{ + long sidx = qch - str.unicode(); + str.setLength(str.length()+1); + return (TQChar *)str.unicode() + sidx; +} + +/*! + Returns the Unicode string decoded from the first \a len + bytes of \a utf8, ignoring the rest of \a utf8. If \a len is + -1 then the length of \a utf8 is used. If \a len is bigger than + the length of \a utf8 then it will use the length of \a utf8. + + \code + TQString str = TQString::fromUtf8( "123456789", 5 ); + // str == "12345" + \endcode + + See TQTextCodec for more diverse coding/decoding of Unicode strings. +*/ +TQString TQString::fromUtf8( const char* utf8, int len ) +{ + if ( !utf8 ) + return TQString::null; + + int slen = 0; + if (len >= 0) { + while (slen < len && utf8[slen]) + slen++; + } else { + slen = int(strlen(utf8)); + } + len = len < 0 ? slen : TQMIN(slen, len); + TQString result; + result.setLength( len ); // worst case + TQChar *qch = (TQChar *)result.unicode(); + uint uc = 0; + uint min_uc = 0; + int need = 0; + int error = -1; + uchar ch; + for (int i=0; i 0xffff) { + // surrogate pair + uc -= 0x10000; + unsigned short high = uc/0x400 + 0xd800; + unsigned short low = uc%0x400 + 0xdc00; + *qch++ = TQChar(high); + *qch++ = TQChar(low); + } else if (uc < min_uc || (uc >= 0xd800 && uc <= 0xdfff) || (uc >= 0xfffe)) { + // overlong seqence, UTF16 surrogate or BOM + i = error; + qch = addOne(qch, result); + *qch++ = TQChar(0xdbff); + *qch++ = TQChar(0xde00+((uchar)utf8[i])); + } else { + *qch++ = uc; + } + } + } else { + // See TQString::utf8() for explanation. + // + // The surrogate below corresponds to a Unicode value of (0x10fe00+ch) which + // is in one of the private use areas of Unicode. + i = error; + qch = addOne(qch, result); + *qch++ = TQChar(0xdbff); + *qch++ = TQChar(0xde00+((uchar)utf8[i])); + need = 0; + } + } else { + if ( ch < 128 ) { + *qch++ = ch; + } else if ((ch & 0xe0) == 0xc0) { + uc = ch & 0x1f; + need = 1; + error = i; + min_uc = 0x80; + } else if ((ch & 0xf0) == 0xe0) { + uc = ch & 0x0f; + need = 2; + error = i; + min_uc = 0x800; + } else if ((ch&0xf8) == 0xf0) { + uc = ch & 0x07; + need = 3; + error = i; + min_uc = 0x10000; + } else { + // Error + qch = addOne(qch, result); + *qch++ = TQChar(0xdbff); + *qch++ = TQChar(0xde00+((uchar)utf8[i])); + } + } + } + if (need) { + // we have some invalid characters remaining we need to add to the string + for (int i = error; i < len; ++i) { + qch = addOne(qch, result); + *qch++ = TQChar(0xdbff); + *qch++ = TQChar(0xde00+((uchar)utf8[i])); + } + } + + result.truncate( qch - result.unicode() ); + return result; +} + +/*! + Returns the Unicode string decoded from the first \a len + bytes of \a ascii, ignoring the rest of \a ascii. If \a len + is -1 then the length of \a ascii is used. If \a len is bigger + than the length of \a ascii then it will use the length of \a + ascii. + + If a codec has been set using TQTextCodec::codecForCStrings(), + it is used to convert the string from 8-bit characters to Unicode. + Otherwise, this function does the same as fromLatin1(). + + This is the same as the TQString(const char*) constructor, but you + can make that constructor invisible if you compile with the define + \c QT_NO_CAST_ASCII, in which case you can explicitly create a + TQString from 8-bit ASCII text using this function. + + \code + TQString str = TQString::fromAscii( "123456789", 5 ); + // str == "12345" + \endcode + */ +TQString TQString::fromAscii( const char* ascii, int len ) +{ +#ifndef QT_NO_TEXTCODEC + if ( TQTextCodec::codecForCStrings() ) { + if ( !ascii ) + return TQString::null; + if ( len < 0 ) + len = (int)strlen( ascii ); + if ( len == 0 || *ascii == '\0' ) + return TQString::fromLatin1( "" ); + return TQTextCodec::codecForCStrings()->toUnicode( ascii, len ); + } +#endif + return fromLatin1( ascii, len ); +} + + +/*! + Returns the Unicode string decoded from the first \a len + bytes of \a chars, ignoring the rest of \a chars. If \a len + is -1 then the length of \a chars is used. If \a len is bigger + than the length of \a chars then it will use the length of \a + chars. + + \sa fromAscii() +*/ +TQString TQString::fromLatin1( const char* chars, int len ) +{ + uint l; + TQChar *uc; + if ( len < 0 ) + len = -1; + uc = internalLatin1ToUnicode( chars, &l, len ); + return TQString( new TQStringData(uc, l, l), TRUE ); +} + +/*! + \fn const TQChar* TQString::unicode() const + + Returns the Unicode representation of the string. The result + remains valid until the string is modified. +*/ + +/*! + Returns the string encoded in a locale-specific format. On X11, + this is the TQTextCodec::codecForLocale(). On Windows, it is a + system-defined encoding. On Mac OS X, this always uses UTF-8 as + the encoding. + + See TQTextCodec for more diverse coding/decoding of Unicode + strings. + + \sa fromLocal8Bit(), ascii(), latin1(), utf8() +*/ + +TQCString TQString::local8Bit() const +{ +#ifdef QT_NO_TEXTCODEC + return latin1(); +#else +#ifdef Q_WS_X11 + TQTextCodec* codec = TQTextCodec::codecForLocale(); + return codec + ? codec->fromUnicode(*this) + : TQCString(latin1()); +#endif +#if defined( Q_WS_MACX ) + return utf8(); +#endif +#if defined( Q_WS_MAC9 ) + return TQCString(latin1()); //I'm evil.. +#endif +#ifdef Q_WS_WIN + return isNull() ? TQCString("") : qt_winTQString2MB( *this ); +#endif +#ifdef Q_WS_QWS + return utf8(); // ### if there is any 8 bit format supported? +#endif +#endif +} + +/*! + Returns the Unicode string decoded from the first \a len + bytes of \a local8Bit, ignoring the rest of \a local8Bit. If + \a len is -1 then the length of \a local8Bit is used. If \a len is + bigger than the length of \a local8Bit then it will use the length + of \a local8Bit. + + \code + TQString str = TQString::fromLocal8Bit( "123456789", 5 ); + // str == "12345" + \endcode + + \a local8Bit is assumed to be encoded in a locale-specific format. + + See TQTextCodec for more diverse coding/decoding of Unicode strings. +*/ +TQString TQString::fromLocal8Bit( const char* local8Bit, int len ) +{ +#ifdef QT_NO_TEXTCODEC + return fromLatin1( local8Bit, len ); +#else + + if ( !local8Bit ) + return TQString::null; +#ifdef Q_WS_X11 + TQTextCodec* codec = TQTextCodec::codecForLocale(); + if ( len < 0 ) + len = strlen( local8Bit ); + return codec + ? codec->toUnicode( local8Bit, len ) + : fromLatin1( local8Bit, len ); +#endif +#if defined( Q_WS_MAC ) + return fromUtf8(local8Bit,len); +#endif +// Should this be OS_WIN32? +#ifdef Q_WS_WIN + if ( len >= 0 ) { + TQCString s(local8Bit,len+1); + return qt_winMB2TQString(s); + } + return qt_winMB2TQString( local8Bit ); +#endif +#ifdef Q_WS_QWS + return fromUtf8(local8Bit,len); +#endif +#endif // QT_NO_TEXTCODEC +} + +/*! + \fn TQString::operator const char *() const + + Returns ascii(). Be sure to see the warnings documented in the + ascii() function. Note that for new code which you wish to be + strictly Unicode-clean, you can define the macro \c + QT_NO_ASCII_CAST when compiling your code to hide this function so + that automatic casts are not done. This has the added advantage + that you catch the programming error described in operator!(). +*/ + +/*! + \fn TQString::operator std::string() const + + Returns ascii() as a std::string. + + \warning The function may cause an application to crash if a static C run-time is in use. + This can happen in Microsoft Visual C++ if TQt is configured as single-threaded. A safe + alternative is to call ascii() directly and construct a std::string manually. +*/ + +/*! + Returns the TQString as a zero terminated array of unsigned shorts + if the string is not null; otherwise returns zero. + + The result remains valid so long as one unmodified + copy of the source string exists. +*/ +const unsigned short *TQString::ucs2() const +{ + if ( ! d->unicode ) + return 0; + unsigned int len = d->len; + if ( d->maxl < len + 1 ) { + // detach, grow or shrink + uint newMax = computeNewMax( len + 1 ); + TQChar* nd = QT_ALLOC_QCHAR_VEC( newMax ); + if ( nd ) { + if ( d->unicode ) + memcpy( nd, d->unicode, sizeof(TQChar)*len ); + ((TQString *)this)->deref(); + ((TQString *)this)->d = new TQStringData( nd, len, newMax ); + } + } + d->unicode[len] = 0; + return (unsigned short *) d->unicode; +} + +/*! + Constructs a string that is a deep copy of \a str, interpreted as a + UCS2 encoded, zero terminated, Unicode string. + + If \a str is 0, then a null string is created. + + \sa isNull() +*/ +TQString TQString::fromUcs2( const unsigned short *str ) +{ + if ( !str ) { + return TQString::null; + } else { + int length = 0; + while ( str[length] != 0 ) + length++; + TQChar* uc = QT_ALLOC_QCHAR_VEC( length ); + memcpy( uc, str, length*sizeof(TQChar) ); + return TQString( new TQStringData( uc, length, length ), TRUE ); + } +} + +/*! + \fn TQChar TQString::at( uint ) const + + Returns the character at index \a i, or 0 if \a i is beyond the + length of the string. + + \code + const TQString string( "abcdefgh" ); + TQChar ch = string.at( 4 ); + // ch == 'e' + \endcode + + If the TQString is not const (i.e. const TQString) or const& (i.e. + const TQString &), then the non-const overload of at() will be used + instead. +*/ + +/*! + \fn TQChar TQString::constref(uint i) const + + Returns the TQChar at index \a i by value. + + Equivalent to at(\a i). + + \sa ref() +*/ + +/*! + \fn TQChar& TQString::ref(uint i) + + Returns the TQChar at index \a i by reference, expanding the string + with TQChar::null if necessary. The resulting reference can be + assigned to, or otherwise used immediately, but becomes invalid + once furher modifications are made to the string. + + \code + TQString string("ABCDEF"); + TQChar ch = string.ref( 3 ); // ch == 'D' + \endcode + + \sa constref() +*/ + +/*! + \fn TQChar TQString::operator[]( int ) const + + Returns the character at index \a i, or TQChar::null if \a i is + beyond the length of the string. + + If the TQString is not const (i.e., const TQString) or const\& + (i.e., const TQString\&), then the non-const overload of operator[] + will be used instead. +*/ + +/*! + \fn TQCharRef TQString::operator[]( int ) + + \overload + + The function returns a reference to the character at index \a i. + The resulting reference can then be assigned to, or used + immediately, but it will become invalid once further modifications + are made to the original string. + + If \a i is beyond the length of the string then the string is + expanded with TQChar::nulls, so that the TQCharRef references a + valid (null) character in the string. + + The TQCharRef internal class can be used much like a constant + TQChar, but if you assign to it, you change the original string + (which will detach itself because of TQString's copy-on-write + semantics). You will get compilation errors if you try to use the + result as anything but a TQChar. +*/ + +/*! + \fn TQCharRef TQString::at( uint i ) + + \overload + + The function returns a reference to the character at index \a i. + The resulting reference can then be assigned to, or used + immediately, but it will become invalid once further modifications + are made to the original string. + + If \a i is beyond the length of the string then the string is + expanded with TQChar::null. +*/ + +/* + Internal chunk of code to handle the + uncommon cases of at() above. +*/ +void TQString::subat( uint i ) +{ + uint olen = d->len; + if ( i >= olen ) { + setLength( i+1 ); // i is index; i+1 is needed length + for ( uint j=olen; j<=i; j++ ) + d->unicode[j] = TQChar::null; + } else { + // Just be sure to detach + real_detach(); + } +} + + +/*! + Resizes the string to \a len characters and copies \a unicode into + the string. If \a unicode is 0, nothing is copied, but the + string is still resized to \a len. If \a len is zero, then the + string becomes a \link isNull() null\endlink string. + + \sa setLatin1(), isNull() +*/ + +TQString& TQString::setUnicode( const TQChar *unicode, uint len ) +{ + if ( len == 0 ) { // set to null string + if ( d != shared_null ) { // beware of nullstring being set to nullstring + deref(); + d = shared_null ? shared_null : makeSharedNull(); + d->ref(); + } + } else if ( d->count != 1 || len > d->maxl || + ( len * 4 < d->maxl && d->maxl > 4 ) ) { + // detach, grown or shrink + uint newMax = computeNewMax( len ); + TQChar* nd = QT_ALLOC_QCHAR_VEC( newMax ); + if ( unicode ) + memcpy( nd, unicode, sizeof(TQChar)*len ); + deref(); + d = new TQStringData( nd, len, newMax ); + } else { + d->len = len; + d->setDirty(); + if ( unicode ) + memcpy( d->unicode, unicode, sizeof(TQChar)*len ); + } + return *this; +} + +/*! + Resizes the string to \a len characters and copies \a + unicode_as_ushorts into the string (on some X11 client platforms + this will involve a byte-swapping pass). + + If \a unicode_as_ushorts is 0, nothing is copied, but the string + is still resized to \a len. If \a len is zero, the string becomes + a \link isNull() null\endlink string. + + \sa setLatin1(), isNull() +*/ +TQString& TQString::setUnicodeCodes( const ushort* unicode_as_ushorts, uint len ) +{ + return setUnicode((const TQChar*)unicode_as_ushorts, len); +} + + +/*! + Sets this string to \a str, interpreted as a classic 8-bit ASCII C + string. If \a len is -1 (the default), then it is set to + strlen(str). + + If \a str is 0 a null string is created. If \a str is "", an empty + string is created. + + \sa isNull(), isEmpty() +*/ + +TQString &TQString::setAscii( const char *str, int len ) +{ +#ifndef QT_NO_TEXTCODEC + if ( TQTextCodec::codecForCStrings() ) { + *this = TQString::fromAscii( str, len ); + return *this; + } +#endif // QT_NO_TEXTCODEC + return setLatin1( str, len ); +} + +/*! + Sets this string to \a str, interpreted as a classic Latin-1 C + string. If \a len is -1 (the default), then it is set to + strlen(str). + + If \a str is 0 a null string is created. If \a str is "", an empty + string is created. + + \sa isNull(), isEmpty() +*/ + +TQString &TQString::setLatin1( const char *str, int len ) +{ + if ( str == 0 ) + return setUnicode(0,0); + if ( len < 0 ) + len = int(strlen( str )); + if ( len == 0 ) { // won't make a null string + *this = TQString::fromLatin1( "" ); + } else { + setUnicode( 0, len ); // resize but not copy + TQChar *p = d->unicode; + while ( len-- ) + *p++ = *str++; + } + return *this; +} + +/*! \internal + */ +void TQString::checkSimpleText() const +{ + TQChar *p = d->unicode; + TQChar *end = p + d->len; + while ( p < end ) { + ushort uc = p->unicode(); + // sort out regions of complex text formatting + if ( uc > 0x058f && ( uc < 0x1100 || uc > 0xfb0f ) ) { + d->issimpletext = FALSE; + return; + } + p++; + } + d->issimpletext = TRUE; +} + +/*! \fn bool TQString::simpleText() const + \internal +*/ + +/*! \internal + */ +bool TQString::isRightToLeft() const +{ + int len = length(); + TQChar *p = d->unicode; + while ( len-- ) { + switch( ::direction( *p ) ) + { + case TQChar::DirL: + case TQChar::DirLRO: + case TQChar::DirLRE: + return FALSE; + case TQChar::DirR: + case TQChar::DirAL: + case TQChar::DirRLO: + case TQChar::DirRLE: + return TRUE; + default: + break; + } + ++p; + } + return FALSE; +} + + +/*! + \fn int TQString::compare( const TQString & s1, const TQString & s2 ) + + Lexically compares \a s1 with \a s2 and returns an integer less + than, equal to, or greater than zero if \a s1 is less than, equal + to, or greater than \a s2. + + The comparison is based exclusively on the numeric Unicode values + of the characters and is very fast, but is not what a human would + expect. Consider sorting user-interface strings with + TQString::localeAwareCompare(). + + \code + int a = TQString::compare( "def", "abc" ); // a > 0 + int b = TQString::compare( "abc", "def" ); // b < 0 + int c = TQString::compare( "abc", "abc" ); // c == 0 + \endcode +*/ + +/*! + \overload + + Lexically compares this string with \a s and returns an integer + less than, equal to, or greater than zero if it is less than, equal + to, or greater than \a s. +*/ +int TQString::compare( const TQString& s ) const +{ + return ucstrcmp( *this, s ); +} + +/*! + \fn int TQString::localeAwareCompare( const TQString & s1, const TQString & s2 ) + + Compares \a s1 with \a s2 and returns an integer less than, equal + to, or greater than zero if \a s1 is less than, equal to, or + greater than \a s2. + + The comparison is performed in a locale- and also + platform-dependent manner. Use this function to present sorted + lists of strings to the user. + + \sa TQString::compare() TQTextCodec::locale() +*/ + +/*! + \overload + + Compares this string with \a s. +*/ + +#if !defined(CSTR_LESS_THAN) +#define CSTR_LESS_THAN 1 +#define CSTR_ETQUAL 2 +#define CSTR_GREATER_THAN 3 +#endif + +int TQString::localeAwareCompare( const TQString& s ) const +{ + // do the right thing for null and empty + if ( isEmpty() || s.isEmpty() ) + return compare( s ); + +#if defined(Q_WS_WIN) + int res; + QT_WA( { + const TCHAR* s1 = (TCHAR*)ucs2(); + const TCHAR* s2 = (TCHAR*)s.ucs2(); + res = CompareStringW( LOCALE_USER_DEFAULT, 0, s1, length(), s2, s.length() ); + } , { + TQCString s1 = local8Bit(); + TQCString s2 = s.local8Bit(); + res = CompareStringA( LOCALE_USER_DEFAULT, 0, s1.data(), s1.length(), s2.data(), s2.length() ); + } ); + + switch ( res ) { + case CSTR_LESS_THAN: + return -1; + case CSTR_GREATER_THAN: + return 1; + default: + return 0; + } +#elif defined(Q_WS_MACX) + int delta = 0; +#if !defined(QT_NO_TEXTCODEC) + TQTextCodec *codec = TQTextCodec::codecForLocale(); + if (codec) + delta = strcoll(codec->fromUnicode(*this), codec->fromUnicode(s)); + if (delta == 0) +#endif + delta = ucstrcmp(*this, s); + return delta; +#elif defined(Q_WS_X11) + // declared in + int delta = strcoll( local8Bit(), s.local8Bit() ); + if ( delta == 0 ) + delta = ucstrcmp( *this, s ); + return delta; +#else + return ucstrcmp( *this, s ); +#endif +} + +bool operator==( const TQString &s1, const TQString &s2 ) +{ + if ( s1.unicode() == s2.unicode() ) + return TRUE; + return (s1.length() == s2.length()) && s1.isNull() == s2.isNull() && + (memcmp((char*)s1.unicode(),(char*)s2.unicode(), + s1.length()*sizeof(TQChar)) == 0 ); +} + +bool operator!=( const TQString &s1, const TQString &s2 ) +{ return !(s1==s2); } + +bool operator<( const TQString &s1, const TQString &s2 ) +{ return ucstrcmp(s1,s2) < 0; } + +bool operator<=( const TQString &s1, const TQString &s2 ) +{ return ucstrcmp(s1,s2) <= 0; } + +bool operator>( const TQString &s1, const TQString &s2 ) +{ return ucstrcmp(s1,s2) > 0; } + +bool operator>=( const TQString &s1, const TQString &s2 ) +{ return ucstrcmp(s1,s2) >= 0; } + + +bool operator==( const TQString &s1, const char *s2 ) +{ + if ( !s2 ) + return s1.isNull(); + + int len = s1.length(); + const TQChar *uc = s1.unicode(); + while ( len ) { + if ( !(*s2) || uc->unicode() != (uchar) *s2 ) + return FALSE; + ++uc; + ++s2; + --len; + } + return !*s2; +} + +bool operator==( const char *s1, const TQString &s2 ) +{ return (s2 == s1); } + +bool operator!=( const TQString &s1, const char *s2 ) +{ return !(s1==s2); } + +bool operator!=( const char *s1, const TQString &s2 ) +{ return !(s1==s2); } + +bool operator<( const TQString &s1, const char *s2 ) +{ return ucstrcmp(s1,s2) < 0; } + +bool operator<( const char *s1, const TQString &s2 ) +{ return ucstrcmp(s1,s2) < 0; } + +bool operator<=( const TQString &s1, const char *s2 ) +{ return ucstrcmp(s1,s2) <= 0; } + +bool operator<=( const char *s1, const TQString &s2 ) +{ return ucstrcmp(s1,s2) <= 0; } + +bool operator>( const TQString &s1, const char *s2 ) +{ return ucstrcmp(s1,s2) > 0; } + +bool operator>( const char *s1, const TQString &s2 ) +{ return ucstrcmp(s1,s2) > 0; } + +bool operator>=( const TQString &s1, const char *s2 ) +{ return ucstrcmp(s1,s2) >= 0; } + +bool operator>=( const char *s1, const TQString &s2 ) +{ return ucstrcmp(s1,s2) >= 0; } + + +/***************************************************************************** + Documentation for TQString related functions + *****************************************************************************/ + +/*! + \fn bool operator==( const TQString &s1, const TQString &s2 ) + + \relates TQString + + Returns TRUE if \a s1 is equal to \a s2; otherwise returns FALSE. + Note that a null string is not equal to a not-null empty string. + + Equivalent to compare(\a s1, \a s2) == 0. + + \sa isNull(), isEmpty() +*/ + +/*! + \fn bool operator==( const TQString &s1, const char *s2 ) + + \overload + \relates TQString + + Returns TRUE if \a s1 is equal to \a s2; otherwise returns FALSE. + Note that a null string is not equal to a not-null empty string. + + Equivalent to compare(\a s1, \a s2) == 0. + + \sa isNull(), isEmpty() +*/ + +/*! + \fn bool operator==( const char *s1, const TQString &s2 ) + + \overload + \relates TQString + + Returns TRUE if \a s1 is equal to \a s2; otherwise returns FALSE. + Note that a null string is not equal to a not-null empty string. + + Equivalent to compare(\a s1, \a s2) == 0. + + \sa isNull(), isEmpty() +*/ + +/*! + \fn bool operator!=( const TQString &s1, const TQString &s2 ) + + \relates TQString + + Returns TRUE if \a s1 is not equal to \a s2; otherwise returns FALSE. + Note that a null string is not equal to a not-null empty string. + + Equivalent to compare(\a s1, \a s2) != 0. + + \sa isNull(), isEmpty() +*/ + +/*! + \fn bool operator!=( const TQString &s1, const char *s2 ) + + \overload + \relates TQString + + Returns TRUE if \a s1 is not equal to \a s2; otherwise returns FALSE. + Note that a null string is not equal to a not-null empty string. + + Equivalent to compare(\a s1, \a s2) != 0. + + \sa isNull(), isEmpty() +*/ + +/*! + \fn bool operator!=( const char *s1, const TQString &s2 ) + + \overload + \relates TQString + + Returns TRUE if \a s1 is not equal to \a s2; otherwise returns FALSE. + Note that a null string is not equal to a not-null empty string. + + Equivalent to compare(\a s1, \a s2) != 0. + + \sa isNull(), isEmpty() +*/ + +/*! + \fn bool operator<( const TQString &s1, const char *s2 ) + + \relates TQString + + Returns TRUE if \a s1 is lexically less than \a s2; otherwise returns FALSE. + The comparison is case sensitive. + + Equivalent to compare(\a s1, \a s2) \< 0. +*/ + +/*! + \fn bool operator<( const char *s1, const TQString &s2 ) + + \overload + \relates TQString + + Returns TRUE if \a s1 is lexically less than \a s2; otherwise returns FALSE. + The comparison is case sensitive. + + Equivalent to compare(\a s1, \a s2) \< 0. +*/ + +/*! + \fn bool operator<=( const TQString &s1, const char *s2 ) + + \relates TQString + + Returns TRUE if \a s1 is lexically less than or equal to \a s2; + otherwise returns FALSE. + The comparison is case sensitive. + Note that a null string is not equal to a not-null empty string. + + Equivalent to compare(\a s1,\a s2) \<= 0. + + \sa isNull(), isEmpty() +*/ + +/*! + \fn bool operator<=( const char *s1, const TQString &s2 ) + + \overload + \relates TQString + + Returns TRUE if \a s1 is lexically less than or equal to \a s2; + otherwise returns FALSE. + The comparison is case sensitive. + Note that a null string is not equal to a not-null empty string. + + Equivalent to compare(\a s1, \a s2) \<= 0. + + \sa isNull(), isEmpty() +*/ + +/*! + \fn bool operator>( const TQString &s1, const char *s2 ) + + \relates TQString + + Returns TRUE if \a s1 is lexically greater than \a s2; otherwise + returns FALSE. + The comparison is case sensitive. + + Equivalent to compare(\a s1, \a s2) \> 0. +*/ + +/*! + \fn bool operator>( const char *s1, const TQString &s2 ) + + \overload + \relates TQString + + Returns TRUE if \a s1 is lexically greater than \a s2; otherwise + returns FALSE. + The comparison is case sensitive. + + Equivalent to compare(\a s1, \a s2) \> 0. +*/ + +/*! + \fn bool operator>=( const TQString &s1, const char *s2 ) + + \relates TQString + + Returns TRUE if \a s1 is lexically greater than or equal to \a s2; + otherwise returns FALSE. + The comparison is case sensitive. + Note that a null string is not equal to a not-null empty string. + + Equivalent to compare(\a s1, \a s2) \>= 0. + + \sa isNull(), isEmpty() +*/ + +/*! + \fn bool operator>=( const char *s1, const TQString &s2 ) + + \overload + \relates TQString + + Returns TRUE if \a s1 is lexically greater than or equal to \a s2; + otherwise returns FALSE. + The comparison is case sensitive. + Note that a null string is not equal to a not-null empty string. + + Equivalent to compare(\a s1, \a s2) \>= 0. + + \sa isNull(), isEmpty() +*/ + +/*! + \fn const TQString operator+( const TQString &s1, const TQString &s2 ) + + \relates TQString + + Returns a string which is the result of concatenating the string + \a s1 and the string \a s2. + + Equivalent to \a {s1}.append(\a s2). +*/ + +/*! + \fn const TQString operator+( const TQString &s1, const char *s2 ) + + \overload + \relates TQString + + Returns a string which is the result of concatenating the string + \a s1 and character \a s2. + + Equivalent to \a {s1}.append(\a s2). +*/ + +/*! + \fn const TQString operator+( const char *s1, const TQString &s2 ) + + \overload + \relates TQString + + Returns a string which is the result of concatenating the + character \a s1 and string \a s2. +*/ + +/*! + \fn const TQString operator+( const TQString &s, char c ) + + \overload + \relates TQString + + Returns a string which is the result of concatenating the string + \a s and character \a c. + + Equivalent to \a {s}.append(\a c). +*/ + +/*! + \fn const TQString operator+( char c, const TQString &s ) + + \overload + \relates TQString + + Returns a string which is the result of concatenating the + character \a c and string \a s. + + Equivalent to \a {s}.prepend(\a c). +*/ + + +/***************************************************************************** + TQString stream functions + *****************************************************************************/ +#ifndef QT_NO_DATASTREAM +/*! + \relates TQString + + Writes the string \a str to the stream \a s. + + See also \link datastreamformat.html Format of the TQDataStream operators \endlink +*/ + +TQDataStream &operator<<( TQDataStream &s, const TQString &str ) +{ + if ( s.version() == 1 ) { + TQCString l( str.latin1() ); + s << l; + } + else { + int byteOrder = s.byteOrder(); + const TQChar* ub = str.unicode(); + if ( ub || s.version() < 3 ) { + static const uint auto_size = 1024; + char t[auto_size]; + char *b; + if ( str.length()*sizeof(TQChar) > auto_size ) { + b = new char[str.length()*sizeof(TQChar)]; + } else { + b = t; + } + int l = str.length(); + char *c=b; + while ( l-- ) { + if ( byteOrder == TQDataStream::BigEndian ) { + *c++ = (char)ub->row(); + *c++ = (char)ub->cell(); + } else { + *c++ = (char)ub->cell(); + *c++ = (char)ub->row(); + } + ub++; + } + s.writeBytes( b, sizeof(TQChar)*str.length() ); + if ( str.length()*sizeof(TQChar) > auto_size ) + delete [] b; + } else { + // write null marker + s << (Q_UINT32)0xffffffff; + } + } + return s; +} + +/*! + \relates TQString + + Reads a string from the stream \a s into string \a str. + + See also \link datastreamformat.html Format of the TQDataStream operators \endlink +*/ + +TQDataStream &operator>>( TQDataStream &s, TQString &str ) +{ +#ifdef QT_QSTRING_UCS_4 +#if defined(Q_CC_GNU) +#warning "operator>> not working properly" +#endif +#endif + if ( s.version() == 1 ) { + TQCString l; + s >> l; + str = TQString( l ); + } + else { + Q_UINT32 bytes = 0; + s >> bytes; // read size of string + if ( bytes == 0xffffffff ) { // null string + str = TQString::null; + } else if ( bytes > 0 ) { // not empty + int byteOrder = s.byteOrder(); + str.setLength( bytes/2 ); + TQChar* ch = str.d->unicode; + static const uint auto_size = 1024; + char t[auto_size]; + char *b; + if ( bytes > auto_size ) { + b = new char[bytes]; + } else { + b = t; + } + s.readRawBytes( b, bytes ); + int bt = bytes/2; + char *oldb = b; + while ( bt-- ) { + if ( byteOrder == TQDataStream::BigEndian ) + *ch++ = (ushort) (((ushort)b[0])<<8) | (uchar)b[1]; + else + *ch++ = (ushort) (((ushort)b[1])<<8) | (uchar)b[0]; + b += 2; + } + if ( bytes > auto_size ) + delete [] oldb; + } else { + str = ""; + } + } + return s; +} +#endif // QT_NO_DATASTREAM + +/***************************************************************************** + TQConstString member functions + *****************************************************************************/ + +/*! + \class TQConstString qstring.h + \reentrant + \ingroup text + \brief The TQConstString class provides string objects using constant Unicode data. + + In order to minimize copying, highly optimized applications can + use TQConstString to provide a TQString-compatible object from + existing Unicode data. It is then the programmer's responsibility + to ensure that the Unicode data exists for the entire lifetime of + the TQConstString object. + + A TQConstString is created with the TQConstString constructor. The + string held by the object can be obtained by calling string(). +*/ + +/*! + Constructs a TQConstString that uses the first \a length Unicode + characters in the array \a unicode. Any attempt to modify copies + of the string will cause it to create a copy of the data, thus it + remains forever unmodified. + + The data in \a unicode is not copied. The caller must be able to + guarantee that \a unicode will not be deleted or modified. +*/ +TQConstString::TQConstString( const TQChar* unicode, uint length ) : + TQString( new TQStringData( (TQChar*)unicode, length, length ), TRUE ) +{ +} + +/*! + Destroys the TQConstString, creating a copy of the data if other + strings are still using it. +*/ +TQConstString::~TQConstString() +{ + if ( d->count > 1 ) { + TQChar* cp = QT_ALLOC_QCHAR_VEC( d->len ); + memcpy( cp, d->unicode, d->len*sizeof(TQChar) ); + d->unicode = cp; + } else { + d->unicode = 0; + } + + // The original d->unicode is now unlinked. +} + +/*! + \fn const TQString& TQConstString::string() const + + Returns a constant string referencing the data passed during + construction. +*/ + +/*! + Returns TRUE if the string starts with \a s; otherwise returns + FALSE. + + If \a cs is TRUE (the default), the search is case sensitive; + otherwise the search is case insensitive. + + \code + TQString str( "Bananas" ); + str.startsWith( "Ban" ); // returns TRUE + str.startsWith( "Car" ); // returns FALSE + \endcode + + \sa endsWith() +*/ +bool TQString::startsWith( const TQString& s, bool cs ) const +{ + if ( isNull() ) + return s.isNull(); + if ( s.length() > length() ) + return FALSE; + if ( cs ) { + return memcmp((char*)d->unicode, (char*)s.d->unicode, s.length()*sizeof(TQChar)) == 0; + } else { + for ( int i = 0; i < (int) s.length(); i++ ) { + if ( ::lower(d->unicode[i]) != ::lower(s.d->unicode[i]) ) + return FALSE; + } + } + return TRUE; +} + +bool TQString::startsWith( const TQString& s ) const +{ + return startsWith( s, TRUE ); +} + +/*! + Returns TRUE if the string ends with \a s; otherwise returns + FALSE. + + If \a cs is TRUE (the default), the search is case sensitive; + otherwise the search is case insensitive. + + \code + TQString str( "Bananas" ); + str.endsWith( "anas" ); // returns TRUE + str.endsWith( "pple" ); // returns FALSE + \endcode + + \sa startsWith() +*/ +bool TQString::endsWith( const TQString& s, bool cs ) const +{ + if ( isNull() ) + return s.isNull(); + int pos = length() - s.length(); + if ( pos < 0 ) + return FALSE; + if ( cs ) { + return memcmp((char*)&d->unicode[pos], (char*)s.d->unicode, s.length()*sizeof(TQChar)) == 0; + } else { + for ( int i = 0; i < (int) s.length(); i++ ) { + if ( ::lower(d->unicode[pos + i]) != ::lower(s.d->unicode[i]) ) + return FALSE; + } + } + return TRUE; +} + +bool TQString::endsWith( const TQString& s ) const +{ + return endsWith( s, TRUE ); +} + +/*! \fn void TQString::detach() + If the string does not share its data with another TQString instance, + nothing happens; otherwise the function creates a new, unique copy of + this string. This function is called whenever the string is modified. The + implicit sharing mechanism is implemented this way. +*/ + +#if defined(Q_OS_WIN32) + +#include + +/*! + \obsolete + + Returns a static Windows TCHAR* from a TQString, adding NUL if \a + addnul is TRUE. + + The lifetime of the return value is until the next call to this function, + or until the last copy of str is deleted, whatever comes first. + + Use ucs2() instead. +*/ +const void* qt_winTchar(const TQString& str, bool) +{ + // So that the return value lives long enough. + static TQString str_cache; + str_cache = str; +#ifdef UNICODE + return str_cache.ucs2(); +#else + return str_cache.latin1(); +#endif +} + +/*! + Makes a new '\0'-terminated Windows TCHAR* from a TQString. +*/ +void* qt_winTchar_new(const TQString& str) +{ + if ( str.isNull() ) + return 0; + int l = str.length()+1; + TCHAR *tc = new TCHAR[ l ]; +#ifdef UNICODE + memcpy( tc, str.ucs2(), sizeof(TCHAR)*l ); +#else + memcpy( tc, str.latin1(), sizeof(TCHAR)*l ); +#endif + return tc; +} + +/*! + Makes a TQString from a Windows TCHAR*. +*/ +TQString qt_winTQString(void* tc) +{ +#ifdef UNICODE + return TQString::fromUcs2( (ushort*)tc ); +#else + return TQString::fromLatin1( (TCHAR *)tc ); +#endif +} + +TQCString qt_winTQString2MB( const TQString& s, int uclen ) +{ + if ( uclen < 0 ) + uclen = s.length(); + if ( s.isNull() ) + return TQCString(); + if ( uclen == 0 ) + return TQCString(""); + BOOL used_def; + TQCString mb(4096); + int len; + while ( !(len=WideCharToMultiByte(CP_ACP, 0, (const WCHAR*)s.unicode(), uclen, + mb.data(), mb.size()-1, 0, &used_def)) ) + { + int r = GetLastError(); + if ( r == ERROR_INSUFFICIENT_BUFFER ) { + mb.resize(1+WideCharToMultiByte( CP_ACP, 0, + (const WCHAR*)s.unicode(), uclen, + 0, 0, 0, &used_def)); + // and try again... + } else { +#ifndef QT_NO_DEBUG + // Fail. + qWarning("WideCharToMultiByte cannot convert multibyte text (error %d): %s (UTF8)", + r, s.utf8().data()); +#endif + break; + } + } + mb[len]='\0'; + return mb; +} + +// WATCH OUT: mblen must include the NUL (or just use -1) +TQString qt_winMB2TQString( const char* mb, int mblen ) +{ + if ( !mb || !mblen ) + return TQString::null; + const int wclen_auto = 4096; + WCHAR wc_auto[wclen_auto]; + int wclen = wclen_auto; + WCHAR *wc = wc_auto; + int len; + while ( !(len=MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, + mb, mblen, wc, wclen )) ) + { + int r = GetLastError(); + if ( r == ERROR_INSUFFICIENT_BUFFER ) { + if ( wc != wc_auto ) { + qWarning("Size changed in MultiByteToWideChar"); + break; + } else { + wclen = MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, + mb, mblen, 0, 0 ); + wc = new WCHAR[wclen]; + // and try again... + } + } else { + // Fail. + qWarning("MultiByteToWideChar cannot convert multibyte text"); + break; + } + } + if ( len <= 0 ) + return TQString::null; + TQString s( (TQChar*)wc, len - 1 ); // len - 1: we don't want terminator + if ( wc != wc_auto ) + delete [] wc; + return s; +} + +#endif // Q_OS_WIN32 diff --git a/src/tools/qstring.h b/src/tools/qstring.h new file mode 100644 index 000000000..e28be63df --- /dev/null +++ b/src/tools/qstring.h @@ -0,0 +1,1115 @@ +/**************************************************************************** +** +** Definition of the TQString class, and related Unicode functions. +** +** Created : 920609 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQSTRING_H +#define TQSTRING_H + +#ifndef QT_H +#include "qcstring.h" +#endif // QT_H + +#ifndef QT_NO_CAST_ASCII +#include +#endif + +#ifndef QT_NO_STL +#if defined ( Q_CC_MSVC_NET ) && _MSC_VER < 1310 // Avoids nasty warning for xlocale, line 450 +# pragma warning ( push ) +# pragma warning ( disable : 4189 ) +# include +# pragma warning ( pop ) +#else +# include +#endif +#if defined(Q_WRONG_SB_CTYPE_MACROS) && defined(_SB_CTYPE_MACROS) +#undef _SB_CTYPE_MACROS +#endif +#endif + + +/***************************************************************************** + TQString class + *****************************************************************************/ + +class TQRegExp; +class TQString; +class TQCharRef; +template class TQDeepCopy; + +class Q_EXPORT TQChar { +public: + TQChar(); + TQChar( char c ); + TQChar( uchar c ); + TQChar( uchar c, uchar r ); + TQChar( const TQChar& c ); // ### remove in 4.0 to allow compiler optimization + TQChar( ushort rc ); + TQChar( short rc ); + TQChar( uint rc ); + TQChar( int rc ); + + QT_STATIC_CONST TQChar null; // 0000 + QT_STATIC_CONST TQChar replacement; // FFFD + QT_STATIC_CONST TQChar byteOrderMark; // FEFF + QT_STATIC_CONST TQChar byteOrderSwapped; // FFFE + QT_STATIC_CONST TQChar nbsp; // 00A0 + + // Unicode information + + enum Category + { + NoCategory, + + Mark_NonSpacing, // Mn + Mark_SpacingCombining, // Mc + Mark_Enclosing, // Me + + Number_DecimalDigit, // Nd + Number_Letter, // Nl + Number_Other, // No + + Separator_Space, // Zs + Separator_Line, // Zl + Separator_Paragraph, // Zp + + Other_Control, // Cc + Other_Format, // Cf + Other_Surrogate, // Cs + Other_PrivateUse, // Co + Other_NotAssigned, // Cn + + Letter_Uppercase, // Lu + Letter_Lowercase, // Ll + Letter_Titlecase, // Lt + Letter_Modifier, // Lm + Letter_Other, // Lo + + Punctuation_Connector, // Pc + Punctuation_Dash, // Pd + Punctuation_Dask = Punctuation_Dash, // oops + Punctuation_Open, // Ps + Punctuation_Close, // Pe + Punctuation_InitialQuote, // Pi + Punctuation_FinalQuote, // Pf + Punctuation_Other, // Po + + Symbol_Math, // Sm + Symbol_Currency, // Sc + Symbol_Modifier, // Sk + Symbol_Other // So + }; + + enum Direction + { + DirL, DirR, DirEN, DirES, DirET, DirAN, DirCS, DirB, DirS, DirWS, DirON, + DirLRE, DirLRO, DirAL, DirRLE, DirRLO, DirPDF, DirNSM, DirBN + }; + + enum Decomposition + { + Single, Canonical, Font, NoBreak, Initial, Medial, + Final, Isolated, Circle, Super, Sub, Vertical, + Wide, Narrow, Small, Square, Compat, Fraction + }; + + enum Joining + { + OtherJoining, Dual, Right, Center + }; + + enum CombiningClass + { + Combining_BelowLeftAttached = 200, + Combining_BelowAttached = 202, + Combining_BelowRightAttached = 204, + Combining_LeftAttached = 208, + Combining_RightAttached = 210, + Combining_AboveLeftAttached = 212, + Combining_AboveAttached = 214, + Combining_AboveRightAttached = 216, + + Combining_BelowLeft = 218, + Combining_Below = 220, + Combining_BelowRight = 222, + Combining_Left = 224, + Combining_Right = 226, + Combining_AboveLeft = 228, + Combining_Above = 230, + Combining_AboveRight = 232, + + Combining_DoubleBelow = 233, + Combining_DoubleAbove = 234, + Combining_IotaSubscript = 240 + }; + + // ****** WHEN ADDING FUNCTIONS, CONSIDER ADDING TO TQCharRef TOO + + int digitValue() const; + TQChar lower() const; + TQChar upper() const; + + Category category() const; + Direction direction() const; + Joining joining() const; + bool mirrored() const; + TQChar mirroredChar() const; + const TQString &decomposition() const; // ### return just TQString in 4.0 + Decomposition decompositionTag() const; + unsigned char combiningClass() const; + + char latin1() const { return ucs > 0xff ? 0 : (char) ucs; } + ushort unicode() const { return ucs; } +#ifdef Q_NO_PACKED_REFERENCE + ushort &unicode() { return *((ushort*)&ucs); } +#else + ushort &unicode() { return ucs; } +#endif +#ifndef QT_NO_CAST_ASCII + // like all ifdef'd code this is undocumented + operator char() const { return latin1(); } +#endif + + bool isNull() const { return unicode()==0; } + bool isPrint() const; + bool isPunct() const; + bool isSpace() const; + bool isMark() const; + bool isLetter() const; + bool isNumber() const; + bool isLetterOrNumber() const; + bool isDigit() const; + bool isSymbol() const; + + uchar cell() const { return ((uchar) ucs & 0xff); } + uchar row() const { return ((uchar) (ucs>>8)&0xff); } + void setCell( uchar cell ) { ucs = (ucs & 0xff00) + cell; } + void setRow( uchar row ) { ucs = (((ushort) row)<<8) + (ucs&0xff); } + + static bool networkOrdered() { + int wordSize; + bool bigEndian = FALSE; + qSysInfo( &wordSize, &bigEndian ); + return bigEndian; + } + + friend inline bool operator==( char ch, TQChar c ); + friend inline bool operator==( TQChar c, char ch ); + friend inline bool operator==( TQChar c1, TQChar c2 ); + friend inline bool operator!=( TQChar c1, TQChar c2 ); + friend inline bool operator!=( char ch, TQChar c ); + friend inline bool operator!=( TQChar c, char ch ); + friend inline bool operator<=( TQChar c, char ch ); + friend inline bool operator<=( char ch, TQChar c ); + friend inline bool operator<=( TQChar c1, TQChar c2 ); + +private: + ushort ucs; +#if defined(QT_QSTRING_UCS_4) + ushort grp; +#endif +} Q_PACKED; + +inline TQChar::TQChar() : ucs( 0 ) +#ifdef QT_QSTRING_UCS_4 + , grp( 0 ) +#endif +{ +} +inline TQChar::TQChar( char c ) : ucs( (uchar)c ) +#ifdef QT_QSTRING_UCS_4 + , grp( 0 ) +#endif +{ +} +inline TQChar::TQChar( uchar c ) : ucs( c ) +#ifdef QT_QSTRING_UCS_4 + , grp( 0 ) +#endif +{ +} +inline TQChar::TQChar( uchar c, uchar r ) : ucs( (r << 8) | c ) +#ifdef QT_QSTRING_UCS_4 + , grp( 0 ) +#endif +{ +} +inline TQChar::TQChar( const TQChar& c ) : ucs( c.ucs ) +#ifdef QT_QSTRING_UCS_4 + , grp( c.grp ) +#endif +{ +} + +inline TQChar::TQChar( ushort rc ) : ucs( rc ) +#ifdef QT_QSTRING_UCS_4 + , grp( 0 ) +#endif +{ +} +inline TQChar::TQChar( short rc ) : ucs( (ushort) rc ) +#ifdef QT_QSTRING_UCS_4 + , grp( 0 ) +#endif +{ +} +inline TQChar::TQChar( uint rc ) : ucs( (ushort ) (rc & 0xffff) ) +#ifdef QT_QSTRING_UCS_4 + , grp( (ushort) ((rc >> 16) & 0xffff) ) +#endif +{ +} +inline TQChar::TQChar( int rc ) : ucs( (ushort) (rc & 0xffff) ) +#ifdef QT_QSTRING_UCS_4 + , grp( (ushort) ((rc >> 16) & 0xffff) ) +#endif +{ +} + +inline bool operator==( char ch, TQChar c ) +{ + return ((uchar) ch) == c.ucs; +} + +inline bool operator==( TQChar c, char ch ) +{ + return ((uchar) ch) == c.ucs; +} + +inline bool operator==( TQChar c1, TQChar c2 ) +{ + return c1.ucs == c2.ucs; +} + +inline bool operator!=( TQChar c1, TQChar c2 ) +{ + return c1.ucs != c2.ucs; +} + +inline bool operator!=( char ch, TQChar c ) +{ + return ((uchar)ch) != c.ucs; +} + +inline bool operator!=( TQChar c, char ch ) +{ + return ((uchar) ch) != c.ucs; +} + +inline bool operator<=( TQChar c, char ch ) +{ + return c.ucs <= ((uchar) ch); +} + +inline bool operator<=( char ch, TQChar c ) +{ + return ((uchar) ch) <= c.ucs; +} + +inline bool operator<=( TQChar c1, TQChar c2 ) +{ + return c1.ucs <= c2.ucs; +} + +inline bool operator>=( TQChar c, char ch ) { return ch <= c; } +inline bool operator>=( char ch, TQChar c ) { return c <= ch; } +inline bool operator>=( TQChar c1, TQChar c2 ) { return c2 <= c1; } +inline bool operator<( TQChar c, char ch ) { return !(ch<=c); } +inline bool operator<( char ch, TQChar c ) { return !(c<=ch); } +inline bool operator<( TQChar c1, TQChar c2 ) { return !(c2<=c1); } +inline bool operator>( TQChar c, char ch ) { return !(ch>=c); } +inline bool operator>( char ch, TQChar c ) { return !(c>=ch); } +inline bool operator>( TQChar c1, TQChar c2 ) { return !(c2>=c1); } + +// internal +struct Q_EXPORT TQStringData : public TQShared { + TQStringData() : + TQShared(), unicode(0), ascii(0), len(0), issimpletext(TRUE), maxl(0), islatin1(FALSE) { ref(); } + TQStringData(TQChar *u, uint l, uint m) : + TQShared(), unicode(u), ascii(0), len(l), issimpletext(FALSE), maxl(m), islatin1(FALSE) { } + ~TQStringData() { if ( unicode ) delete[] ((char*)unicode); + if ( ascii ) delete[] ascii; } + + void deleteSelf(); + TQChar *unicode; + char *ascii; + void setDirty() { + if ( ascii ) { + delete [] ascii; + ascii = 0; + } + issimpletext = FALSE; + } +#ifdef Q_OS_MAC9 + uint len; +#else + uint len : 30; +#endif + uint issimpletext : 1; +#ifdef Q_OS_MAC9 + uint maxl; +#else + uint maxl : 30; +#endif + uint islatin1 : 1; + +private: +#if defined(Q_DISABLE_COPY) + TQStringData( const TQStringData& ); + TQStringData& operator=( const TQStringData& ); +#endif +}; + + +class Q_EXPORT TQString +{ +public: + TQString(); // make null string + TQString( TQChar ); // one-char string + TQString( const TQString & ); // impl-shared copy + TQString( const TQByteArray& ); // deep copy + TQString( const TQChar* unicode, uint length ); // deep copy +#ifndef QT_NO_CAST_ASCII + TQString( const char *str ); // deep copy +#endif +#ifndef QT_NO_STL + TQString( const std::string& ); // deep copy +#endif + ~TQString(); + + TQString &operator=( const TQString & ); // impl-shared copy + TQString &operator=( const char * ); // deep copy +#ifndef QT_NO_STL + TQString &operator=( const std::string& ); // deep copy +#endif + TQString &operator=( const TQCString& ); // deep copy + TQString &operator=( TQChar c ); + TQString &operator=( char c ); + + QT_STATIC_CONST TQString null; + + bool isNull() const; + bool isEmpty() const; + uint length() const; + void truncate( uint pos ); + + TQString & fill( TQChar c, int len = -1 ); + + TQString copy() const; + + TQString arg( long a, int fieldWidth = 0, int base = 10 ) const; + TQString arg( ulong a, int fieldWidth = 0, int base = 10 ) const; + TQString arg( Q_LLONG a, int fieldwidth=0, int base=10 ) const; + TQString arg( Q_ULLONG a, int fieldwidth=0, int base=10 ) const; + TQString arg( int a, int fieldWidth = 0, int base = 10 ) const; + TQString arg( uint a, int fieldWidth = 0, int base = 10 ) const; + TQString arg( short a, int fieldWidth = 0, int base = 10 ) const; + TQString arg( ushort a, int fieldWidth = 0, int base = 10 ) const; + TQString arg( double a, int fieldWidth = 0, char fmt = 'g', + int prec = -1 ) const; + TQString arg( char a, int fieldWidth = 0 ) const; + TQString arg( TQChar a, int fieldWidth = 0 ) const; + TQString arg( const TQString& a, int fieldWidth = 0 ) const; + TQString arg( const TQString& a1, const TQString& a2 ) const; + TQString arg( const TQString& a1, const TQString& a2, + const TQString& a3 ) const; + TQString arg( const TQString& a1, const TQString& a2, const TQString& a3, + const TQString& a4 ) const; + +#ifndef QT_NO_SPRINTF + TQString &sprintf( const char* format, ... ) +#if defined(Q_CC_GNU) && !defined(__INSURE__) + __attribute__ ((format (printf, 2, 3))) +#endif + ; +#endif + + int find( TQChar c, int index=0, bool cs=TRUE ) const; + int find( char c, int index=0, bool cs=TRUE ) const; + int find( const TQString &str, int index=0, bool cs=TRUE ) const; +#ifndef QT_NO_REGEXP + int find( const TQRegExp &, int index=0 ) const; +#endif +#ifndef QT_NO_CAST_ASCII + int find( const char* str, int index=0 ) const; +#endif + int findRev( TQChar c, int index=-1, bool cs=TRUE) const; + int findRev( char c, int index=-1, bool cs=TRUE) const; + int findRev( const TQString &str, int index=-1, bool cs=TRUE) const; +#ifndef QT_NO_REGEXP + int findRev( const TQRegExp &, int index=-1 ) const; +#endif +#ifndef QT_NO_CAST_ASCII + int findRev( const char* str, int index=-1 ) const; +#endif + int contains( TQChar c, bool cs=TRUE ) const; + int contains( char c, bool cs=TRUE ) const + { return contains(TQChar(c), cs); } +#ifndef QT_NO_CAST_ASCII + int contains( const char* str, bool cs=TRUE ) const; +#endif + int contains( const TQString &str, bool cs=TRUE ) const; +#ifndef QT_NO_REGEXP + int contains( const TQRegExp & ) const; +#endif + + enum SectionFlags { + SectionDefault = 0x00, + SectionSkipEmpty = 0x01, + SectionIncludeLeadingSep = 0x02, + SectionIncludeTrailingSep = 0x04, + SectionCaseInsensitiveSeps = 0x08 + }; + TQString section( TQChar sep, int start, int end = 0xffffffff, int flags = SectionDefault ) const; + TQString section( char sep, int start, int end = 0xffffffff, int flags = SectionDefault ) const; +#ifndef QT_NO_CAST_ASCII + TQString section( const char *in_sep, int start, int end = 0xffffffff, int flags = SectionDefault ) const; +#endif + TQString section( const TQString &in_sep, int start, int end = 0xffffffff, int flags = SectionDefault ) const; +#ifndef QT_NO_REGEXP + TQString section( const TQRegExp ®, int start, int end = 0xffffffff, int flags = SectionDefault ) const; +#endif + + TQString left( uint len ) const; + TQString right( uint len ) const; + TQString mid( uint index, uint len=0xffffffff) const; + + TQString leftJustify( uint width, TQChar fill=' ', bool trunc=FALSE)const; + TQString rightJustify( uint width, TQChar fill=' ',bool trunc=FALSE)const; + + TQString lower() const; + TQString upper() const; + + TQString stripWhiteSpace() const; + TQString simplifyWhiteSpace() const; + + TQString &insert( uint index, const TQString & ); +#ifndef QT_NO_CAST_ASCII + TQString &insert( uint index, const TQByteArray & ); + TQString &insert( uint index, const char * ); +#endif + TQString &insert( uint index, const TQChar*, uint len ); + TQString &insert( uint index, TQChar ); + TQString &insert( uint index, char c ) { return insert(index,TQChar(c)); } + TQString &append( char ); + TQString &append( TQChar ); + TQString &append( const TQString & ); +#ifndef QT_NO_CAST_ASCII + TQString &append( const TQByteArray & ); + TQString &append( const char * ); +#endif +#if !defined(QT_NO_STL) && !defined(QT_NO_CAST_ASCII) + TQString &append( const std::string& ); +#endif + TQString &prepend( char ); + TQString &prepend( TQChar ); + TQString &prepend( const TQString & ); +#ifndef QT_NO_CAST_ASCII + TQString &prepend( const TQByteArray & ); + TQString &prepend( const char * ); +#endif +#if !defined(QT_NO_STL) && !defined(QT_NO_CAST_ASCII) + TQString &prepend( const std::string& ); +#endif + TQString &remove( uint index, uint len ); +#if defined(Q_QDOC) + TQString &remove( const TQString & str, bool cs = TRUE ); +#else + // ### TQt 4.0: merge these two into one, and remove Q_QDOC hack + TQString &remove( const TQString & ); + TQString &remove( const TQString &, bool cs ); +#endif + TQString &remove( TQChar c ); + TQString &remove( char c ) + { return remove( TQChar(c) ); } +#ifndef QT_NO_CAST_ASCII + TQString &remove( const char * ); +#endif +#ifndef QT_NO_REGEXP + TQString &remove( const TQRegExp & ); +#endif + TQString &replace( uint index, uint len, const TQString & ); + TQString &replace( uint index, uint len, const TQChar*, uint clen ); + TQString &replace( uint index, uint len, TQChar ); + TQString &replace( uint index, uint len, char c ) + { return replace( index, len, TQChar(c) ); } +#if defined(Q_QDOC) + TQString &replace( TQChar c, const TQString & after, bool cs = TRUE ); + TQString &replace( char c, const TQString & after, bool cs = TRUE ); + TQString &replace( const TQString & before, const TQString & after, + bool cs = TRUE ); +#else + // ### TQt 4.0: merge these two into one, and remove Q_QDOC hack + TQString &replace( TQChar c, const TQString & ); + TQString &replace( TQChar c, const TQString &, bool ); + + // ### TQt 4.0: merge these two into one, and remove Q_QDOC hack + TQString &replace( char c, const TQString & after ) + { return replace( TQChar(c), after, TRUE ); } + TQString &replace( char c, const TQString & after, bool cs ) + { return replace( TQChar(c), after, cs ); } + + // ### TQt 4.0: merge these two into one, and remove Q_QDOC hack + TQString &replace( const TQString &, const TQString & ); + TQString &replace( const TQString &, const TQString &, bool ); +#endif +#ifndef QT_NO_REGEXP_CAPTURE + TQString &replace( const TQRegExp &, const TQString & ); +#endif + TQString &replace( TQChar, TQChar ); + + 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; + Q_LLONG toLongLong( bool *ok=0, int base=10 ) const; + Q_ULLONG toULongLong( bool *ok=0, int base=10 ) const; + float toFloat( bool *ok=0 ) const; + double toDouble( bool *ok=0 ) const; + + TQString &setNum( short, int base=10 ); + TQString &setNum( ushort, int base=10 ); + TQString &setNum( int, int base=10 ); + TQString &setNum( uint, int base=10 ); + TQString &setNum( long, int base=10 ); + TQString &setNum( ulong, int base=10 ); + TQString &setNum( Q_LLONG, int base=10 ); + TQString &setNum( Q_ULLONG, int base=10 ); + TQString &setNum( float, char f='g', int prec=6 ); + TQString &setNum( double, char f='g', int prec=6 ); + + static TQString number( long, int base=10 ); + static TQString number( ulong, int base=10); + static TQString number( Q_LLONG, int base=10 ); + static TQString number( Q_ULLONG, int base=10); + static TQString number( int, int base=10 ); + static TQString number( uint, int base=10); + static TQString number( double, char f='g', int prec=6 ); + + void setExpand( uint index, TQChar c ); + + TQString &operator+=( const TQString &str ); +#ifndef QT_NO_CAST_ASCII + TQString &operator+=( const TQByteArray &str ); + TQString &operator+=( const char *str ); +#endif +#if !defined(QT_NO_STL) && !defined(QT_NO_CAST_ASCII) + TQString &operator+=( const std::string& ); +#endif + TQString &operator+=( TQChar c ); + TQString &operator+=( char c ); + + TQChar at( uint i ) const + { return i < d->len ? d->unicode[i] : TQChar::null; } + TQChar operator[]( int i ) const { return at((uint)i); } + TQCharRef at( uint i ); + TQCharRef operator[]( int i ); + + TQChar constref(uint i) const + { return at(i); } + TQChar& ref(uint i) + { // Optimized for easy-inlining by simple compilers. + if ( d->count != 1 || i >= d->len ) + subat( i ); + d->setDirty(); + return d->unicode[i]; + } + + const TQChar* unicode() const { return d->unicode; } + const char* ascii() const; + static TQString fromAscii(const char*, int len=-1); + const char* latin1() const; + static TQString fromLatin1(const char*, int len=-1); + TQCString utf8() const; + static TQString fromUtf8(const char*, int len=-1); + TQCString local8Bit() const; + static TQString fromLocal8Bit(const char*, int len=-1); + bool operator!() const; +#ifndef QT_NO_ASCII_CAST + operator const char *() const { return ascii(); } +#endif +#ifndef QT_NO_STL + operator std::string() const { return ascii() ? ascii() : ""; } +#endif + + static TQString fromUcs2( const unsigned short *ucs2 ); + const unsigned short *ucs2() const; + + TQString &setUnicode( const TQChar* unicode, uint len ); + TQString &setUnicodeCodes( const ushort* unicode_as_ushorts, uint len ); + TQString &setAscii( const char*, int len=-1 ); + TQString &setLatin1( const char*, int len=-1 ); + + int compare( const TQString& s ) const; + static int compare( const TQString& s1, const TQString& s2 ) + { return s1.compare( s2 ); } + + int localeAwareCompare( const TQString& s ) const; + static int localeAwareCompare( const TQString& s1, const TQString& s2 ) + { return s1.localeAwareCompare( s2 ); } + +#ifndef QT_NO_DATASTREAM + friend Q_EXPORT TQDataStream &operator>>( TQDataStream &, TQString & ); +#endif + + void compose(); + +#ifndef QT_NO_COMPAT + const char* data() const { return ascii(); } +#endif + +#if defined(Q_QDOC) + bool startsWith( const TQString& str, bool cs = TRUE ) const; + bool endsWith( const TQString& str, bool cs = TRUE ) const; +#else + // ### TQt 4.0: merge these two into one, and remove Q_QDOC hack + bool startsWith( const TQString& str ) const; + bool startsWith( const TQString& str, bool cs ) const; + + // ### TQt 4.0: merge these two into one, and remove Q_QDOC hack + bool endsWith( const TQString& str ) const; + bool endsWith( const TQString& str, bool cs ) const; +#endif + + void setLength( uint newLength ); + + uint capacity() const; + void reserve( uint minCapacity ); + void squeeze(); + + bool simpleText() const { if ( !d->issimpletext ) checkSimpleText(); return (bool)d->issimpletext; } + bool isRightToLeft() const; + + +private: + TQString( int size, bool /* dummy */ ); // allocate size incl. \0 + + void deref(); + void real_detach(); + void subat( uint ); + TQString multiArg( int numArgs, const TQString& a1, const TQString& a2, + const TQString& a3 = TQString::null, + const TQString& a4 = TQString::null ) const; + + void checkSimpleText() const; + void grow( uint newLength ); +#ifndef QT_NO_CAST_ASCII + TQString &insertHelper( uint index, const char *s, uint len=UINT_MAX ); + TQString &operatorPlusEqHelper( const char *s, uint len2=UINT_MAX ); +#endif + + static TQChar* latin1ToUnicode( const char*, uint * len, uint maxlen=(uint)-1 ); + static TQChar* latin1ToUnicode( const TQByteArray&, uint * len ); + static char* unicodeToLatin1( const TQChar*, uint len ); + + TQStringData *d; + static TQStringData* shared_null; + static TQStringData* makeSharedNull(); + + friend class TQConstString; + friend class TQTextStream; + TQString( TQStringData* dd, bool /* dummy */ ) : d(dd) { } + + // needed for TQDeepCopy + void detach(); + friend class TQDeepCopy; +}; + +class Q_EXPORT TQCharRef { + friend class TQString; + TQString& s; + uint p; + TQCharRef(TQString* str, uint pos) : s(*str), p(pos) { } + +public: + // most TQChar operations repeated here + + // all this is not documented: We just say "like TQChar" and let it be. +#ifndef Q_QDOC + ushort unicode() const { return s.constref(p).unicode(); } + char latin1() const { return s.constref(p).latin1(); } + + // An operator= for each TQChar cast constructors + TQCharRef operator=(char c ) { s.ref(p)=c; return *this; } + TQCharRef operator=(uchar c ) { s.ref(p)=c; return *this; } + TQCharRef operator=(TQChar c ) { s.ref(p)=c; return *this; } + TQCharRef operator=(const TQCharRef& c ) { s.ref(p)=c.unicode(); return *this; } + TQCharRef operator=(ushort rc ) { s.ref(p)=rc; return *this; } + TQCharRef operator=(short rc ) { s.ref(p)=rc; return *this; } + TQCharRef operator=(uint rc ) { s.ref(p)=rc; return *this; } + TQCharRef operator=(int rc ) { s.ref(p)=rc; return *this; } + + operator TQChar () const { return s.constref(p); } + + // each function... + bool isNull() const { return unicode()==0; } + bool isPrint() const { return s.constref(p).isPrint(); } + bool isPunct() const { return s.constref(p).isPunct(); } + bool isSpace() const { return s.constref(p).isSpace(); } + bool isMark() const { return s.constref(p).isMark(); } + bool isLetter() const { return s.constref(p).isLetter(); } + bool isNumber() const { return s.constref(p).isNumber(); } + bool isLetterOrNumber() { return s.constref(p).isLetterOrNumber(); } + bool isDigit() const { return s.constref(p).isDigit(); } + + int digitValue() const { return s.constref(p).digitValue(); } + TQChar lower() const { return s.constref(p).lower(); } + TQChar upper() const { return s.constref(p).upper(); } + + TQChar::Category category() const { return s.constref(p).category(); } + TQChar::Direction direction() const { return s.constref(p).direction(); } + TQChar::Joining joining() const { return s.constref(p).joining(); } + bool mirrored() const { return s.constref(p).mirrored(); } + TQChar mirroredChar() const { return s.constref(p).mirroredChar(); } + const TQString &decomposition() const { return s.constref(p).decomposition(); } + TQChar::Decomposition decompositionTag() const { return s.constref(p).decompositionTag(); } + unsigned char combiningClass() const { return s.constref(p).combiningClass(); } + + // Not the non-const ones of these. + uchar cell() const { return s.constref(p).cell(); } + uchar row() const { return s.constref(p).row(); } +#endif +}; + +inline TQCharRef TQString::at( uint i ) { return TQCharRef(this,i); } +inline TQCharRef TQString::operator[]( int i ) { return at((uint)i); } + + +class Q_EXPORT TQConstString : private TQString { +public: + TQConstString( const TQChar* unicode, uint length ); + ~TQConstString(); + const TQString& string() const { return *this; } +}; + + +/***************************************************************************** + TQString stream functions + *****************************************************************************/ +#ifndef QT_NO_DATASTREAM +Q_EXPORT TQDataStream &operator<<( TQDataStream &, const TQString & ); +Q_EXPORT TQDataStream &operator>>( TQDataStream &, TQString & ); +#endif + +/***************************************************************************** + TQString inline functions + *****************************************************************************/ + +// These two move code into makeSharedNull() and deletesData() +// to improve cache-coherence (and reduce code bloat), while +// keeping the common cases fast. +// +// No safe way to pre-init shared_null on ALL compilers/linkers. +inline TQString::TQString() : + d(shared_null ? shared_null : makeSharedNull()) +{ + d->ref(); +} +// +inline TQString::~TQString() +{ + if ( d->deref() ) { + if ( d != shared_null ) + d->deleteSelf(); + } +} + +// needed for TQDeepCopy +inline void TQString::detach() +{ real_detach(); } + +inline TQString TQString::section( TQChar sep, int start, int end, int flags ) const +{ return section(TQString(sep), start, end, flags); } + +inline TQString TQString::section( char sep, int start, int end, int flags ) const +{ return section(TQChar(sep), start, end, flags); } + +#ifndef QT_NO_CAST_ASCII +inline TQString TQString::section( const char *in_sep, int start, int end, int flags ) const +{ return section(TQString(in_sep), start, end, flags); } +#endif + +inline TQString &TQString::operator=( TQChar c ) +{ *this = TQString(c); return *this; } + +inline TQString &TQString::operator=( char c ) +{ *this = TQString(TQChar(c)); return *this; } + +inline bool TQString::isNull() const +{ return unicode() == 0; } + +inline bool TQString::operator!() const +{ return isNull(); } + +inline uint TQString::length() const +{ return d->len; } + +inline uint TQString::capacity() const +{ return d->maxl; } + +inline bool TQString::isEmpty() const +{ return length() == 0; } + +inline TQString TQString::copy() const +{ return TQString( *this ); } + +#ifndef QT_NO_CAST_ASCII +inline TQString &TQString::insert( uint index, const char *s ) +{ return insertHelper( index, s ); } + +inline TQString &TQString::insert( uint index, const TQByteArray &s ) +{ + int pos = s.find( 0 ); + return insertHelper( index, s, pos==-1 ? s.size() : pos ); +} +#endif + +inline TQString &TQString::prepend( const TQString & s ) +{ return insert(0,s); } + +inline TQString &TQString::prepend( TQChar c ) +{ return insert(0,c); } + +inline TQString &TQString::prepend( char c ) +{ return insert(0,c); } + +#ifndef QT_NO_CAST_ASCII +inline TQString &TQString::prepend( const TQByteArray & s ) +{ return insert(0,s); } +#endif + +#ifndef QT_NO_CAST_ASCII +inline TQString &TQString::operator+=( const TQByteArray &s ) +{ + int pos = s.find( 0 ); + return operatorPlusEqHelper( s, pos==-1 ? s.size() : pos ); +} +#endif + +inline TQString &TQString::append( const TQString & s ) +{ return operator+=(s); } + +#ifndef QT_NO_CAST_ASCII +inline TQString &TQString::append( const TQByteArray &s ) +{ return operator+=(s); } + +inline TQString &TQString::append( const char * s ) +{ return operator+=(s); } +#endif + +inline TQString &TQString::append( TQChar c ) +{ return operator+=(c); } + +inline TQString &TQString::append( char c ) +{ return operator+=(c); } + +#ifndef QT_NO_STL +inline TQString &TQString::operator=( const std::string& str ) +{ return operator=(str.c_str()); } +#ifndef QT_NO_CAST_ASCII +inline TQString &TQString::operator+=( const std::string& s ) +{ return operator+=(s.c_str()); } +inline TQString &TQString::append( const std::string& s ) +{ return operator+=(s); } +inline TQString &TQString::prepend( const std::string& s ) +{ return insert(0, s); } +#endif +#endif + +inline TQString &TQString::setNum( short n, int base ) +{ return setNum((Q_LLONG)n, base); } + +inline TQString &TQString::setNum( ushort n, int base ) +{ return setNum((Q_ULLONG)n, base); } + +inline TQString &TQString::setNum( int n, int base ) +{ return setNum((Q_LLONG)n, base); } + +inline TQString &TQString::setNum( uint n, int base ) +{ return setNum((Q_ULLONG)n, base); } + +inline TQString &TQString::setNum( float n, char f, int prec ) +{ return setNum((double)n,f,prec); } + +inline TQString TQString::arg( int a, int fieldWidth, int base ) const +{ return arg( (Q_LLONG)a, fieldWidth, base ); } + +inline TQString TQString::arg( uint a, int fieldWidth, int base ) const +{ return arg( (Q_ULLONG)a, fieldWidth, base ); } + +inline TQString TQString::arg( short a, int fieldWidth, int base ) const +{ return arg( (Q_LLONG)a, fieldWidth, base ); } + +inline TQString TQString::arg( ushort a, int fieldWidth, int base ) const +{ return arg( (Q_ULLONG)a, fieldWidth, base ); } + +inline TQString TQString::arg( const TQString& a1, const TQString& a2 ) const { + return multiArg( 2, a1, a2 ); +} + +inline TQString TQString::arg( const TQString& a1, const TQString& a2, + const TQString& a3 ) const { + return multiArg( 3, a1, a2, a3 ); +} + +inline TQString TQString::arg( const TQString& a1, const TQString& a2, + const TQString& a3, const TQString& a4 ) const { + return multiArg( 4, a1, a2, a3, a4 ); +} + +inline int TQString::find( char c, int index, bool cs ) const +{ return find(TQChar(c), index, cs); } + +inline int TQString::findRev( char c, int index, bool cs ) const +{ return findRev( TQChar(c), index, cs ); } + +#ifndef QT_NO_CAST_ASCII +inline int TQString::find( const char* str, int index ) const +{ return find(TQString::fromAscii(str), index); } + +inline int TQString::findRev( const char* str, int index ) const +{ return findRev(TQString::fromAscii(str), index); } +#endif + + +/***************************************************************************** + TQString non-member operators + *****************************************************************************/ + +Q_EXPORT bool operator!=( const TQString &s1, const TQString &s2 ); +Q_EXPORT bool operator<( const TQString &s1, const TQString &s2 ); +Q_EXPORT bool operator<=( const TQString &s1, const TQString &s2 ); +Q_EXPORT bool operator==( const TQString &s1, const TQString &s2 ); +Q_EXPORT bool operator>( const TQString &s1, const TQString &s2 ); +Q_EXPORT bool operator>=( const TQString &s1, const TQString &s2 ); +#ifndef QT_NO_CAST_ASCII +Q_EXPORT bool operator!=( const TQString &s1, const char *s2 ); +Q_EXPORT bool operator<( const TQString &s1, const char *s2 ); +Q_EXPORT bool operator<=( const TQString &s1, const char *s2 ); +Q_EXPORT bool operator==( const TQString &s1, const char *s2 ); +Q_EXPORT bool operator>( const TQString &s1, const char *s2 ); +Q_EXPORT bool operator>=( const TQString &s1, const char *s2 ); +Q_EXPORT bool operator!=( const char *s1, const TQString &s2 ); +Q_EXPORT bool operator<( const char *s1, const TQString &s2 ); +Q_EXPORT bool operator<=( const char *s1, const TQString &s2 ); +Q_EXPORT bool operator==( const char *s1, const TQString &s2 ); +//Q_EXPORT bool operator>( const char *s1, const TQString &s2 ); // MSVC++ +Q_EXPORT bool operator>=( const char *s1, const TQString &s2 ); +#endif + +Q_EXPORT inline const TQString operator+( const TQString &s1, const TQString &s2 ) +{ + TQString tmp( s1 ); + tmp += s2; + return tmp; +} + +#ifndef QT_NO_CAST_ASCII +Q_EXPORT inline const TQString operator+( const TQString &s1, const char *s2 ) +{ + TQString tmp( s1 ); + tmp += TQString::fromAscii(s2); + return tmp; +} + +Q_EXPORT inline const TQString operator+( const char *s1, const TQString &s2 ) +{ + TQString tmp = TQString::fromAscii( s1 ); + tmp += s2; + return tmp; +} +#endif + +Q_EXPORT inline const TQString operator+( const TQString &s1, TQChar c2 ) +{ + TQString tmp( s1 ); + tmp += c2; + return tmp; +} + +Q_EXPORT inline const TQString operator+( const TQString &s1, char c2 ) +{ + TQString tmp( s1 ); + tmp += c2; + return tmp; +} + +Q_EXPORT inline const TQString operator+( TQChar c1, const TQString &s2 ) +{ + TQString tmp; + tmp += c1; + tmp += s2; + return tmp; +} + +Q_EXPORT inline const TQString operator+( char c1, const TQString &s2 ) +{ + TQString tmp; + tmp += c1; + tmp += s2; + return tmp; +} + +#ifndef QT_NO_STL +Q_EXPORT inline const TQString operator+(const TQString& s1, const std::string& s2) +{ + return s1 + TQString(s2); +} + +Q_EXPORT inline const TQString operator+(const std::string& s1, const TQString& s2) +{ + TQString tmp(s2); + return TQString(tmp.prepend(s1)); +} +#endif + + +#if defined(Q_OS_WIN32) +extern Q_EXPORT TQString qt_winTQString(void*); +extern Q_EXPORT const void* qt_winTchar(const TQString& str, bool addnul); +extern Q_EXPORT void* qt_winTchar_new(const TQString& str); +extern Q_EXPORT TQCString qt_winTQString2MB( const TQString& s, int len=-1 ); +extern Q_EXPORT TQString qt_winMB2TQString( const char* mb, int len=-1 ); +#endif + +#define Q_DEFINED_QSTRING +#include "qwinexport.h" +#endif // TQSTRING_H diff --git a/src/tools/qstringlist.cpp b/src/tools/qstringlist.cpp new file mode 100644 index 000000000..a02263a0c --- /dev/null +++ b/src/tools/qstringlist.cpp @@ -0,0 +1,467 @@ +/**************************************************************************** +** +** Implementation of TQStringList +** +** Created : 990406 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "qstringlist.h" + +#ifndef QT_NO_STRINGLIST +#include "qregexp.h" +#include "qstrlist.h" +#include "qdatastream.h" +#include "qtl.h" + +/*! + \class TQStringList qstringlist.h + \reentrant + \brief The TQStringList class provides a list of strings. + + \ingroup tools + \ingroup shared + \ingroup text + \mainclass + + It is used to store and manipulate strings that logically belong + together. Essentially TQStringList is a TQValueList of TQString + objects. Unlike TQStrList, which stores pointers to characters, + TQStringList holds real TQString objects. It is the class of choice + whenever you work with Unicode strings. TQStringList is part of the + \link qtl.html TQt Template Library\endlink. + + Like TQString itself, TQStringList objects are implicitly shared, so + passing them around as value-parameters is both fast and safe. + + Strings can be added to a list using append(), operator+=() or + operator<<(), e.g. + \code + TQStringList fonts; + fonts.append( "Times" ); + fonts += "Courier"; + fonts += "Courier New"; + fonts << "Helvetica [Cronyx]" << "Helvetica [Adobe]"; + \endcode + + String lists have an iterator, TQStringList::Iterator(), e.g. + \code + for ( TQStringList::Iterator it = fonts.begin(); it != fonts.end(); ++it ) { + cout << *it << ":"; + } + cout << endl; + // Output: + // Times:Courier:Courier New:Helvetica [Cronyx]:Helvetica [Adobe]: + \endcode + + Many TQt functions return string lists by value; to iterate over + these you should make a copy and iterate over the copy. + + You can concatenate all the strings in a string list into a single + string (with an optional separator) using join(), e.g. + \code + TQString allFonts = fonts.join( ", " ); + cout << allFonts << endl; + // Output: + // Times, Courier, Courier New, Helvetica [Cronyx], Helvetica [Adobe] + \endcode + + You can sort the list with sort(), and extract a new list which + contains only those strings which contain a particular substring + (or match a particular regular expression) using the grep() + functions, e.g. + \code + fonts.sort(); + cout << fonts.join( ", " ) << endl; + // Output: + // Courier, Courier New, Helvetica [Adobe], Helvetica [Cronyx], Times + + TQStringList helveticas = fonts.grep( "Helvetica" ); + cout << helveticas.join( ", " ) << endl; + // Output: + // Helvetica [Adobe], Helvetica [Cronyx] + \endcode + + Existing strings can be split into string lists with character, + string or regular expression separators, e.g. + \code + TQString s = "Red\tGreen\tBlue"; + TQStringList colors = TQStringList::split( "\t", s ); + cout << colors.join( ", " ) << endl; + // Output: + // Red, Green, Blue + \endcode +*/ + +/*! + \fn TQStringList::TQStringList() + + Creates an empty string list. +*/ + +/*! + \fn TQStringList::TQStringList( const TQStringList& l ) + + Creates a copy of the list \a l. This function is very fast + because TQStringList is implicitly shared. In most situations this + acts like a deep copy, for example, if this list or the original + one or some other list referencing the same shared data is + modified, the modifying list first makes a copy, i.e. + copy-on-write. + In a threaded environment you may retquire a real deep copy + \omit see \l TQDeepCopy\endomit. +*/ + +/*! + \fn TQStringList::TQStringList (const TQString & i) + + Constructs a string list consisting of the single string \a i. + Longer lists are easily created as follows: + + \code + TQStringList items; + items << "Buy" << "Sell" << "Update" << "Value"; + \endcode +*/ + +/*! + \fn TQStringList::TQStringList (const char* i) + + Constructs a string list consisting of the single Latin-1 string \a i. +*/ + +/*! + \fn TQStringList::TQStringList( const TQValueList& l ) + + Constructs a new string list that is a copy of \a l. +*/ + +/*! + Sorts the list of strings in ascending case-sensitive order. + + Sorting is very fast. It uses the \link qtl.html TQt Template + Library's\endlink efficient HeapSort implementation that has a + time complexity of O(n*log n). + + If you want to sort your strings in an arbitrary order consider + using a TQMap. For example you could use a TQMap\ + to create a case-insensitive ordering (e.g. mapping the lowercase + text to the text), or a TQMap\ to sort the strings by + some integer index, etc. +*/ +void TQStringList::sort() +{ + qHeapSort( *this ); +} + +/*! + \overload + + This version of the function uses a TQChar as separator, rather + than a regular expression. + + \sa join() TQString::section() +*/ + +TQStringList TQStringList::split( const TQChar &sep, const TQString &str, + bool allowEmptyEntries ) +{ + return split( TQString(sep), str, allowEmptyEntries ); +} + +/*! + \overload + + This version of the function uses a TQString as separator, rather + than a regular expression. + + If \a sep is an empty string, the return value is a list of + one-character strings: split( TQString( "" ), "four" ) returns the + four-item list, "f", "o", "u", "r". + + If \a allowEmptyEntries is TRUE, a null string is inserted in + the list wherever the separator matches twice without intervening + text. + + \sa join() TQString::section() +*/ + +TQStringList TQStringList::split( const TQString &sep, const TQString &str, + bool allowEmptyEntries ) +{ + TQStringList lst; + + int j = 0; + int i = str.find( sep, j ); + + while ( i != -1 ) { + if ( i > j && i <= (int)str.length() ) + lst << str.mid( j, i - j ); + else if ( allowEmptyEntries ) + lst << TQString::null; + j = i + sep.length(); + i = str.find( sep, sep.length() > 0 ? j : j+1 ); + } + + int l = str.length() - 1; + if ( str.mid( j, l - j + 1 ).length() > 0 ) + lst << str.mid( j, l - j + 1 ); + else if ( allowEmptyEntries ) + lst << TQString::null; + + return lst; +} + +#ifndef QT_NO_REGEXP +/*! + Splits the string \a str into strings wherever the regular + expression \a sep occurs, and returns the list of those strings. + + If \a allowEmptyEntries is TRUE, a null string is inserted in + the list wherever the separator matches twice without intervening + text. + + For example, if you split the string "a,,b,c" on commas, split() + returns the three-item list "a", "b", "c" if \a allowEmptyEntries + is FALSE (the default), and the four-item list "a", "", "b", "c" + if \a allowEmptyEntries is TRUE. + + If \a sep does not match anywhere in \a str, split() returns a + single element list with the element containing the single string + \a str. + + \sa join() TQString::section() +*/ + +TQStringList TQStringList::split( const TQRegExp &sep, const TQString &str, + bool allowEmptyEntries ) +{ + TQStringList lst; + + TQRegExp tep = sep; + + int j = 0; + int i = tep.search( str, j ); + + while ( i != -1 ) { + if ( str.mid( j, i - j ).length() > 0 ) + lst << str.mid( j, i - j ); + else if ( allowEmptyEntries ) + lst << TQString::null; + if ( tep.matchedLength() == 0 ) + j = i + 1; + else + j = i + tep.matchedLength(); + i = tep.search( str, j ); + } + + int l = str.length() - 1; + if ( str.mid( j, l - j + 1 ).length() > 0 ) + lst << str.mid( j, l - j + 1 ); + else if ( allowEmptyEntries ) + lst << TQString::null; + + return lst; +} +#endif + +/*! + Returns a list of all the strings containing the substring \a str. + + If \a cs is TRUE, the grep is done case-sensitively; otherwise + case is ignored. + + \code + TQStringList list; + list << "Bill Gates" << "John Doe" << "Bill Clinton"; + list = list.grep( "Bill" ); + // list == ["Bill Gates", "Bill Clinton"] + \endcode + + \sa TQString::find() +*/ + +TQStringList TQStringList::grep( const TQString &str, bool cs ) const +{ + TQStringList res; + for ( TQStringList::ConstIterator it = begin(); it != end(); ++it ) + if ( (*it).contains(str, cs) ) + res << *it; + + return res; +} + +#ifndef QT_NO_REGEXP +/*! + \overload + + Returns a list of all the strings that match the regular + expression \a rx. + + \sa TQString::find() +*/ + +TQStringList TQStringList::grep( const TQRegExp &rx ) const +{ + TQStringList res; + for ( TQStringList::ConstIterator it = begin(); it != end(); ++it ) + if ( (*it).find(rx) != -1 ) + res << *it; + + return res; +} +#endif + +/*! + Replaces every occurrence of the string \a before in the strings + that constitute the string list with the string \a after. Returns + a reference to the string list. + + If \a cs is TRUE, the search is case sensitive; otherwise the + search is case insensitive. + + Example: + \code + TQStringList list; + list << "alpha" << "beta" << "gamma" << "epsilon"; + list.gres( "a", "o" ); + // list == ["olpho", "beto", "gommo", "epsilon"] + \endcode + + \sa TQString::replace() +*/ +TQStringList& TQStringList::gres( const TQString &before, const TQString &after, + bool cs ) +{ + TQStringList::Iterator it = begin(); + while ( it != end() ) { + (*it).replace( before, after, cs ); + ++it; + } + return *this; +} + +#ifndef QT_NO_REGEXP_CAPTURE +/*! + \overload + + Replaces every occurrence of the regexp \a rx in the string + with \a after. Returns a reference to the string list. + + Example: + \code + TQStringList list; + list << "alpha" << "beta" << "gamma" << "epsilon"; + list.gres( TQRegExp("^a"), "o" ); + // list == ["olpha", "beta", "gamma", "epsilon"] + \endcode + + For regexps containing \link qregexp.html#capturing-text + capturing parentheses \endlink, occurrences of \\1, + \\2, ..., in \a after are replaced with \a{rx}.cap(1), + cap(2), ... + + Example: + \code + TQStringList list; + list << "Bill Clinton" << "Gates, Bill"; + list.gres( TQRegExp("^(.*), (.*)$"), "\\2 \\1" ); + // list == ["Bill Clinton", "Bill Gates"] + \endcode + + \sa TQString::replace() +*/ +TQStringList& TQStringList::gres( const TQRegExp &rx, const TQString &after ) +{ + TQStringList::Iterator it = begin(); + while ( it != end() ) { + (*it).replace( rx, after ); + ++it; + } + return *this; +} + +#endif + +/*! + Joins the string list into a single string with each element + separated by the string \a sep (which can be empty). + + \sa split() +*/ +TQString TQStringList::join( const TQString &sep ) const +{ + TQString res; + bool alredy = FALSE; + for ( TQStringList::ConstIterator it = begin(); it != end(); ++it ) { + if ( alredy ) + res += sep; + alredy = TRUE; + res += *it; + } + + return res; +} + +#ifndef QT_NO_DATASTREAM +Q_EXPORT TQDataStream &operator>>( TQDataStream & s, TQStringList& l ) +{ + return s >> (TQValueList&)l; +} + +Q_EXPORT TQDataStream &operator<<( TQDataStream & s, const TQStringList& l ) +{ + return s << (const TQValueList&)l; +} +#endif + +/*! + Converts from an ASCII-TQStrList \a ascii to a TQStringList (Unicode). +*/ +TQStringList TQStringList::fromStrList(const TQStrList& ascii) +{ + TQStringList res; + const char * s; + for ( TQStrListIterator it(ascii); (s=it.current()); ++it ) + res << s; + return res; +} + +/*! \fn void TQStringList::detach() + \reimp +*/ + + +#endif //QT_NO_STRINGLIST diff --git a/src/tools/qstringlist.h b/src/tools/qstringlist.h new file mode 100644 index 000000000..3667bcd73 --- /dev/null +++ b/src/tools/qstringlist.h @@ -0,0 +1,106 @@ +/**************************************************************************** +** +** Definition of TQStringList class +** +** Created : 990406 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQSTRINGLIST_H +#define TQSTRINGLIST_H + +#ifndef QT_H +#include "qvaluelist.h" +#include "qstring.h" +#include "qstrlist.h" +#endif // QT_H + +#ifndef QT_NO_STRINGLIST + +class TQRegExp; +template class TQDeepCopy; + +#if defined(Q_TEMPLATEDLL) +// MOC_SKIP_BEGIN +//Q_TEMPLATE_EXTERN template class Q_EXPORT TQValueList; +// MOC_SKIP_END +#endif + +class Q_EXPORT TQStringList : public TQValueList +{ +public: + TQStringList() { } + TQStringList( const TQStringList& l ) : TQValueList(l) { } + TQStringList( const TQValueList& l ) : TQValueList(l) { } + TQStringList( const TQString& i ) { append(i); } +#ifndef QT_NO_CAST_ASCII + TQStringList( const char* i ) { append(i); } +#endif + + static TQStringList fromStrList(const TQStrList&); + + void sort(); + + static TQStringList split( const TQString &sep, const TQString &str, bool allowEmptyEntries = FALSE ); + static TQStringList split( const TQChar &sep, const TQString &str, bool allowEmptyEntries = FALSE ); +#ifndef QT_NO_REGEXP + static TQStringList split( const TQRegExp &sep, const TQString &str, bool allowEmptyEntries = FALSE ); +#endif + TQString join( const TQString &sep ) const; + + TQStringList grep( const TQString &str, bool cs = TRUE ) const; +#ifndef QT_NO_REGEXP + TQStringList grep( const TQRegExp &expr ) const; +#endif + + TQStringList& gres( const TQString &before, const TQString &after, + bool cs = TRUE ); +#ifndef QT_NO_REGEXP_CAPTURE + TQStringList& gres( const TQRegExp &expr, const TQString &after ); +#endif + +protected: + void detach() { TQValueList::detach(); } + friend class TQDeepCopy< TQStringList >; +}; + +#ifndef QT_NO_DATASTREAM +class TQDataStream; +extern Q_EXPORT TQDataStream &operator>>( TQDataStream &, TQStringList& ); +extern Q_EXPORT TQDataStream &operator<<( TQDataStream &, const TQStringList& ); +#endif + +#endif // QT_NO_STRINGLIST +#endif // TQSTRINGLIST_H diff --git a/src/tools/qstrlist.h b/src/tools/qstrlist.h new file mode 100644 index 000000000..02838ad15 --- /dev/null +++ b/src/tools/qstrlist.h @@ -0,0 +1,109 @@ +/**************************************************************************** +** +** Definition of TQStrList, TQStrIList and TQStrListIterator classes +** +** Created : 920730 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQSTRLIST_H +#define TQSTRLIST_H + +#ifndef QT_H +#include "qstring.h" +#include "qptrlist.h" +#include "qdatastream.h" +#endif // QT_H + +#if defined(Q_QDOC) +class TQStrListIterator : public TQPtrListIterator +{ +}; +#else +typedef TQPtrListIterator TQStrListIterator; +#endif + +class Q_EXPORT TQStrList : public TQPtrList +{ +public: + TQStrList( bool deepCopies=TRUE ) { dc = deepCopies; del_item = deepCopies; } + TQStrList( const TQStrList & ); + ~TQStrList() { clear(); } + TQStrList& operator=( const TQStrList & ); + +private: + TQPtrCollection::Item newItem( TQPtrCollection::Item d ) { return dc ? qstrdup( (const char*)d ) : d; } + void deleteItem( TQPtrCollection::Item d ) { if ( del_item ) delete[] (char*)d; } + int compareItems( TQPtrCollection::Item s1, TQPtrCollection::Item s2 ) { return qstrcmp((const char*)s1, + (const char*)s2); } +#ifndef QT_NO_DATASTREAM + TQDataStream &read( TQDataStream &s, TQPtrCollection::Item &d ) + { s >> (char *&)d; return s; } + TQDataStream &write( TQDataStream &s, TQPtrCollection::Item d ) const + { return s << (const char *)d; } +#endif + bool dc; +}; + + +class Q_EXPORT TQStrIList : public TQStrList // case insensitive string list +{ +public: + TQStrIList( bool deepCopies=TRUE ) : TQStrList( deepCopies ) {} + ~TQStrIList() { clear(); } +private: + int compareItems( TQPtrCollection::Item s1, TQPtrCollection::Item s2 ) + { return qstricmp((const char*)s1, + (const char*)s2); } +}; + + +inline TQStrList & TQStrList::operator=( const TQStrList &strList ) +{ + clear(); + dc = strList.dc; + del_item = dc; + TQPtrList::operator=( strList ); + return *this; +} + +inline TQStrList::TQStrList( const TQStrList &strList ) + : TQPtrList( strList ) +{ + dc = FALSE; + operator=( strList ); +} + +#endif // TQSTRLIST_H diff --git a/src/tools/qstrvec.h b/src/tools/qstrvec.h new file mode 100644 index 000000000..ea7765153 --- /dev/null +++ b/src/tools/qstrvec.h @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Definition of TQStrVec and TQStrIVec classes +** +** Created : 931203 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQSTRVEC_H +#define TQSTRVEC_H + +#ifndef QT_H +#include "qstring.h" +#include "qptrvector.h" +#include "qdatastream.h" +#endif // QT_H + +class Q_EXPORT TQStrVec : public TQPtrVector +{ +public: + TQStrVec() { dc = TRUE; } + TQStrVec( uint size, bool deepc = TRUE ) : TQPtrVector(size) {dc=deepc;} + ~TQStrVec() { clear(); } +private: + Item newItem( Item d ) { return dc ? qstrdup( (const char*)d ) : d; } + void deleteItem( Item d ) { if ( dc ) delete[] (char*)d; } + int compareItems( Item s1, Item s2 ) + { return qstrcmp((const char*)s1, + (const char*)s2); } +#ifndef QT_NO_DATASTREAM + TQDataStream &read( TQDataStream &s, Item &d ) + { s >> (char *&)d; return s; } + TQDataStream &write( TQDataStream &s, Item d ) const + { return s << (const char*)d; } +#endif + bool dc; +}; + + +class Q_EXPORT TQStrIVec : public TQStrVec // case insensitive string vec +{ +public: + TQStrIVec() {} + TQStrIVec( uint size, bool dc = TRUE ) : TQStrVec( size, dc ) {} + ~TQStrIVec() { clear(); } +private: + int compareItems( Item s1, Item s2 ) + { return qstricmp((const char*)s1, + (const char*)s2); } +}; + + +#endif // TQSTRVEC_H diff --git a/src/tools/qt_tools.pri b/src/tools/qt_tools.pri new file mode 100644 index 000000000..9b37b3b5e --- /dev/null +++ b/src/tools/qt_tools.pri @@ -0,0 +1,150 @@ +# Qt tools module + +tools { + TOOLS_P = tools + HEADERS += $$TOOLS_H/qmemarray.h \ + $$TOOLS_H/qasciicache.h \ + $$TOOLS_H/qasciidict.h \ + $$TOOLS_H/qbitarray.h \ + $$TOOLS_H/qbuffer.h \ + $$TOOLS_H/qcache.h \ + $$TOOLS_H/qcleanuphandler.h \ + $$TOOLS_P/qcomponentfactory_p.h \ + $$TOOLS_P/qcomlibrary_p.h \ + $$TOOLS_H/qcstring.h \ + $$TOOLS_H/qdatastream.h \ + $$TOOLS_H/qdatetime.h \ + $$TOOLS_H/qdeepcopy.h \ + $$TOOLS_H/qdict.h \ + $$TOOLS_H/qdir.h \ + $$TOOLS_P/qdir_p.h \ + $$TOOLS_H/qfile.h \ + $$TOOLS_P/qfiledefs_p.h \ + $$TOOLS_H/qfileinfo.h \ + $$TOOLS_H/qgarray.h \ + $$TOOLS_H/qgcache.h \ + $$TOOLS_H/qgdict.h \ + $$TOOLS_H/qgeneric.h \ + $$TOOLS_H/qglist.h \ + $$TOOLS_H/qglobal.h \ + $$TOOLS_P/qgpluginmanager_p.h \ + $$TOOLS_H/qgvector.h \ + $$TOOLS_H/qintcache.h \ + $$TOOLS_H/qintdict.h \ + $$TOOLS_H/qiodevice.h \ + $$TOOLS_H/qlibrary.h \ + $$TOOLS_P/qlibrary_p.h \ + $$TOOLS_H/qlocale.h \ + $$TOOLS_P/qlocale_p.h \ + $$TOOLS_H/qptrlist.h \ + $$TOOLS_H/qmap.h \ + $$TOOLS_H/qmutex.h \ + $$TOOLS_P/qmutex_p.h \ + $$TOOLS_P/qmutexpool_p.h \ + $$TOOLS_P/qpluginmanager_p.h \ + $$TOOLS_H/qptrcollection.h \ + $$TOOLS_H/qptrdict.h \ + $$TOOLS_H/qptrqueue.h \ + $$TOOLS_H/qregexp.h \ + $$TOOLS_H/qsemaphore.h \ + $$TOOLS_H/qsettings.h \ + $$TOOLS_P/qsettings_p.h \ + $$TOOLS_H/qshared.h \ + $$TOOLS_H/qsortedlist.h \ + $$TOOLS_H/qptrstack.h \ + $$TOOLS_H/qstring.h \ + $$TOOLS_H/qstringlist.h \ + $$TOOLS_H/qstrlist.h \ + $$TOOLS_H/qstrvec.h \ + $$TOOLS_H/qtextstream.h \ + $$TOOLS_P/qthreadinstance_p.h \ + $$TOOLS_H/qthreadstorage.h\ + $$TOOLS_P/qunicodetables_p.h \ + $$TOOLS_H/qptrvector.h \ + $$TOOLS_H/qvaluelist.h \ + $$TOOLS_H/qvaluestack.h \ + $$TOOLS_H/qvaluevector.h \ + $$TOOLS_H/qwaitcondition.h \ + $$TOOLS_P/qcom_p.h \ + $$TOOLS_P/qucom_p.h \ + $$TOOLS_H/quuid.h + + win32:SOURCES += $$TOOLS_CPP/qdir_win.cpp \ + $$TOOLS_CPP/qfile_win.cpp \ + $$TOOLS_CPP/qfileinfo_win.cpp \ + $$TOOLS_CPP/qlibrary_win.cpp \ + $$TOOLS_CPP/qsettings_win.cpp \ + $$TOOLS_CPP/qmutex_win.cpp \ + $$TOOLS_CPP/qwaitcondition_win.cpp \ + $$TOOLS_CPP/qthreadstorage_win.cpp \ + $$TOOLS_CPP/qcriticalsection_p.cpp + + win32-borland:SOURCES += $$TOOLS_CPP/qwinexport.cpp + + wince-* { + SOURCES -= $$TOOLS_CPP/qdir_win.cpp \ + $$TOOLS_CPP/qfile_win.cpp \ + $$TOOLS_CPP/qfileinfo_win.cpp + SOURCES += $$TOOLS_CPP/qdir_wce.cpp \ + $$TOOLS_CPP/qfile_wce.cpp \ + $$TOOLS_CPP/qfileinfo_wce.cpp + } + + offmac:SOURCES += $$TOOLS_CPP/qdir_mac.cpp \ + $$TOOLS_CPP/qfile_mac.cpp \ + $$TOOLS_CPP/qfileinfo_mac.cpp + else:unix:SOURCES += $$TOOLS_CPP/qdir_unix.cpp \ + $$TOOLS_CPP/qfile_unix.cpp \ + $$TOOLS_CPP/qfileinfo_unix.cpp \ + $$TOOLS_CPP/qmutex_unix.cpp \ + $$TOOLS_CPP/qthreadstorage_unix.cpp \ + $$TOOLS_CPP/qwaitcondition_unix.cpp + + mac:!x11:!embedded:SOURCES += $$TOOLS_CPP/qsettings_mac.cpp + mac { + SOURCES+=3rdparty/dlcompat/dlfcn.c + INCLUDEPATH+=3rdparty/dlcompat + } + unix:SOURCES += $$TOOLS_CPP/qlibrary_unix.cpp + + SOURCES += $$TOOLS_CPP/qbitarray.cpp \ + $$TOOLS_CPP/qbuffer.cpp \ + $$TOOLS_CPP/qcomponentfactory.cpp \ + $$TOOLS_CPP/qcomlibrary.cpp \ + $$TOOLS_CPP/qcstring.cpp \ + $$TOOLS_CPP/qdatastream.cpp \ + $$TOOLS_CPP/qdatetime.cpp \ + $$TOOLS_CPP/qdeepcopy.cpp \ + $$TOOLS_CPP/qdir.cpp \ + $$TOOLS_CPP/qfile.cpp \ + $$TOOLS_CPP/qfileinfo.cpp \ + $$TOOLS_CPP/qgarray.cpp \ + $$TOOLS_CPP/qgcache.cpp \ + $$TOOLS_CPP/qgdict.cpp \ + $$TOOLS_CPP/qglist.cpp \ + $$TOOLS_CPP/qglobal.cpp \ + $$TOOLS_CPP/qgpluginmanager.cpp \ + $$TOOLS_CPP/qgvector.cpp \ + $$TOOLS_CPP/qiodevice.cpp \ + $$TOOLS_CPP/qlibrary.cpp \ + $$TOOLS_CPP/qlocale.cpp \ + $$TOOLS_CPP/qmap.cpp \ + $$TOOLS_CPP/qmutexpool.cpp \ + $$TOOLS_CPP/qptrcollection.cpp \ + $$TOOLS_CPP/qregexp.cpp \ + $$TOOLS_CPP/qstring.cpp \ + $$TOOLS_CPP/qsemaphore.cpp \ + $$TOOLS_CPP/qsettings.cpp \ + $$TOOLS_CPP/qstringlist.cpp \ + $$TOOLS_CPP/qtextstream.cpp \ + $$TOOLS_CPP/qunicodetables.cpp \ + $$TOOLS_CPP/qucom.cpp \ + $$TOOLS_CPP/quuid.cpp + + irix-cc* { + CXXFLAGS_PRELINK = $$QMAKE_CXXFLAGS + CXXFLAGS_PRELINK -= -O2 + QMAKE_PRE_LINK = $(CXX) -c $$CXXFLAGS_PRELINK -O1 $(INCPATH) -o $(OBJECTS_DIR)/qlocale.o tools/qlocale.cpp + } +} + diff --git a/src/tools/qtextstream.cpp b/src/tools/qtextstream.cpp new file mode 100644 index 000000000..e9865ca77 --- /dev/null +++ b/src/tools/qtextstream.cpp @@ -0,0 +1,2609 @@ +/**************************************************************************** +** +** Implementation of TQTextStream class +** +** Created : 940922 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "qtextstream.h" + +#ifndef QT_NO_TEXTSTREAM +#include "qtextcodec.h" +#include "qregexp.h" +#include "qbuffer.h" +#include "qfile.h" +#include +#include +#include +#ifndef Q_OS_TEMP +#include +#endif + +#if defined(Q_OS_WIN32) +#include "qt_windows.h" +#endif + +/*! + \class TQTextStream qtextstream.h + \reentrant + \brief The TQTextStream class provides basic functions for reading + and writing text using a TQIODevice. + + \ingroup io + \ingroup text + \mainclass + + The text stream class has a functional interface that is very + similar to that of the standard C++ iostream class. + + TQt provides several global functions similar to the ones in iostream: + \table + \header \i Function \i Meaning + \row \i bin \i sets the TQTextStream to read/write binary numbers + \row \i oct \i sets the TQTextStream to read/write octal numbers + \row \i dec \i sets the TQTextStream to read/write decimal numbers + \row \i hex \i sets the TQTextStream to read/write hexadecimal numbers + \row \i endl \i forces a line break + \row \i flush \i forces the TQIODevice to flush any buffered data + \row \i ws \i eats any available whitespace (on input) + \row \i reset \i resets the TQTextStream to its default mode (see reset()) + \row \i qSetW(int) \i sets the \link width() field width \endlink + to the given argument + \row \i qSetFill(int) \i sets the \link fill() fill character + \endlink to the given argument + \row \i qSetPrecision(int) \i sets the \link precision() precision + \endlink to the given argument + \endtable + + \warning By default TQTextStream will automatically detect whether + integers in the stream are in decimal, octal, hexadecimal or + binary format when reading from the stream. In particular, a + leading '0' signifies octal, i.e. the sequence "0100" will be + interpreted as 64. + + The TQTextStream class reads and writes text; it is not appropriate + for dealing with binary data (but TQDataStream is). + + By default, output of Unicode text (i.e. TQString) is done using + the local 8-bit encoding. This can be changed using the + setEncoding() method. For input, the TQTextStream will auto-detect + standard Unicode "byte order marked" text files; otherwise the + local 8-bit encoding is used. + + The TQIODevice is set in the constructor, or later using + setDevice(). If the end of the input is reached atEnd() returns + TRUE. Data can be read into variables of the appropriate type + using the operator>>() overloads, or read in its entirety into a + single string using read(), or read a line at a time using + readLine(). Whitespace can be skipped over using skipWhiteSpace(). + You can set flags for the stream using flags() or setf(). The + stream also supports width(), precision() and fill(); use reset() + to reset the defaults. + + \sa TQDataStream +*/ + +/*! + \enum TQTextStream::Encoding + + \value Locale + \value Latin1 + \value Unicode + \value UnicodeNetworkOrder + \value UnicodeReverse + \value RawUnicode + \value UnicodeUTF8 + + See setEncoding() for an explanation of the encodings. +*/ + +/* + \class TQTSManip + + \brief The TQTSManip class is an internal helper class for the + TQTextStream. + + It is generally a very bad idea to use this class directly in + application programs. + + \internal + + This class makes it possible to give the TQTextStream function objects + with arguments, like this: + \code + TQTextStream cout( stdout, IO_WriteOnly ); + cout << setprecision( 8 ); // TQTSManip used here! + cout << 3.14159265358979323846; + \endcode + + The setprecision() function returns a TQTSManip object. + The TQTSManip object contains a pointer to a member function in + TQTextStream and an integer argument. + When serializing a TQTSManip into a TQTextStream, the function + is executed with the argument. +*/ + +/*! \fn TQTSManip::TQTSManip( TQTSMFI m, int a ) + + Constructs a TQTSManip object which will call \a m (a member function + in TQTextStream which accepts a single int) with argument \a a when + TQTSManip::exec() is called. Used internally in e.g. endl: + + \code + s << "some text" << endl << "more text"; + \endcode +*/ + +/*! \fn void TQTSManip::exec( TQTextStream& s ) + + Calls the member function specified in the constructor, for object + \a s. Used internally in e.g. endl: + + \code + s << "some text" << endl << "more text"; + \endcode +*/ + + +/***************************************************************************** + TQTextStream member functions + *****************************************************************************/ + +#if defined(QT_CHECK_STATE) +#undef CHECK_STREAM_PRECOND +#define CHECK_STREAM_PRECOND if ( !dev ) { \ + qWarning( "TQTextStream: No device" ); \ + return *this; } +#else +#define CHECK_STREAM_PRECOND +#endif + + +#define I_SHORT 0x0010 +#define I_INT 0x0020 +#define I_LONG 0x0030 +#define I_TYPE_MASK 0x00f0 + +#define I_BASE_2 TQTS::bin +#define I_BASE_8 TQTS::oct +#define I_BASE_10 TQTS::dec +#define I_BASE_16 TQTS::hex +#define I_BASE_MASK (TQTS::bin | TQTS::oct | TQTS::dec | TQTS::hex) + +#define I_SIGNED 0x0100 +#define I_UNSIGNED 0x0200 +#define I_SIGN_MASK 0x0f00 + + +static const TQChar TQEOF = TQChar((ushort)0xffff); //guaranteed not to be a character. +static const uint getline_buf_size = 256; // bufsize used by ts_getline() + +const int TQTextStream::basefield = I_BASE_MASK; +const int TQTextStream::adjustfield = ( TQTextStream::left | + TQTextStream::right | + TQTextStream::internal ); +const int TQTextStream::floatfield = ( TQTextStream::scientific | + TQTextStream::fixed ); + + +class TQTextStreamPrivate { +public: +#ifndef QT_NO_TEXTCODEC + TQTextStreamPrivate() + : decoder( 0 ), encoder( 0 ), sourceType( NotSet ) { } + ~TQTextStreamPrivate() { + delete decoder; + delete encoder; + } + TQTextDecoder *decoder; + TQTextEncoder *encoder; +#else + TQTextStreamPrivate() : sourceType( NotSet ) { } + ~TQTextStreamPrivate() { } +#endif + TQString ungetcBuf; + + enum SourceType { NotSet, IODevice, String, ByteArray, File }; + SourceType sourceType; +}; + + +// skips whitespace and returns the first non-whitespace character +TQChar TQTextStream::eat_ws() +{ + TQChar c; + do { c = ts_getc(); } while ( c != TQEOF && ts_isspace(c) ); + return c; +} + +void TQTextStream::init() +{ + // ### ungetcBuf = TQEOF; + dev = 0; + owndev = FALSE; + mapper = 0; + d = new TQTextStreamPrivate; + doUnicodeHeader = TRUE; // autodetect + latin1 = TRUE; // should use locale? + internalOrder = TQChar::networkOrdered(); + networkOrder = TRUE; +} + +/*! + Constructs a data stream that has no IO device. +*/ + +TQTextStream::TQTextStream() +{ + init(); + setEncoding( Locale ); + reset(); + d->sourceType = TQTextStreamPrivate::NotSet; +} + +/*! + Constructs a text stream that uses the IO device \a iod. +*/ + +TQTextStream::TQTextStream( TQIODevice *iod ) +{ + init(); + setEncoding( Locale ); + dev = iod; + reset(); + d->sourceType = TQTextStreamPrivate::IODevice; +} + +// TODO: use special-case handling of this case in TQTextStream, and +// simplify this class to only deal with TQChar or TQString data. +class TQStringBuffer : public TQIODevice { +public: + TQStringBuffer( TQString* str ); + ~TQStringBuffer(); + bool open( int m ); + void close(); + void flush(); + Offset size() const; + Offset at() const; + bool at( Offset pos ); + Q_LONG readBlock( char *p, Q_ULONG len ); + Q_LONG writeBlock( const char *p, Q_ULONG len ); + int getch(); + int putch( int ch ); + int ungetch( int ch ); +protected: + TQString* s; + +private: + TQStringBuffer( const TQStringBuffer & ); + TQStringBuffer &operator=( const TQStringBuffer & ); +}; + + +TQStringBuffer::TQStringBuffer( TQString* str ) +{ + s = str; +} + +TQStringBuffer::~TQStringBuffer() +{ +} + + +bool TQStringBuffer::open( int m ) +{ + if ( !s ) { +#if defined(QT_CHECK_STATE) + qWarning( "TQStringBuffer::open: No string" ); +#endif + return FALSE; + } + if ( isOpen() ) { +#if defined(QT_CHECK_STATE) + qWarning( "TQStringBuffer::open: Buffer already open" ); +#endif + return FALSE; + } + setMode( m ); + if ( m & IO_Truncate ) + s->truncate( 0 ); + + if ( m & IO_Append ) { + ioIndex = s->length()*sizeof(TQChar); + } else { + ioIndex = 0; + } + setState( IO_Open ); + resetStatus(); + return TRUE; +} + +void TQStringBuffer::close() +{ + if ( isOpen() ) { + setFlags( IO_Direct ); + ioIndex = 0; + } +} + +void TQStringBuffer::flush() +{ +} + +TQIODevice::Offset TQStringBuffer::size() const +{ + return s ? s->length()*sizeof(TQChar) : 0; +} + +TQIODevice::Offset TQStringBuffer::at() const +{ + return ioIndex; +} + +bool TQStringBuffer::at( Offset pos ) +{ +#if defined(QT_CHECK_STATE) + if ( !isOpen() ) { + qWarning( "TQStringBuffer::at: Buffer is not open" ); + return FALSE; + } +#endif + if ( pos >= s->length()*2 ) { +#if defined(QT_CHECK_RANGE) +#if defined(QT_ABI_QT4) + qWarning( "TQStringBuffer::at: Index %lld out of range", pos ); +#else + qWarning( "TQStringBuffer::at: Index %lu out of range", pos ); +#endif +#endif + return FALSE; + } + ioIndex = pos; + return TRUE; +} + + +Q_LONG TQStringBuffer::readBlock( char *p, Q_ULONG len ) +{ +#if defined(QT_CHECK_STATE) + Q_CHECK_PTR( p ); + if ( !isOpen() ) { + qWarning( "TQStringBuffer::readBlock: Buffer not open" ); + return -1; + } + if ( !isReadable() ) { + qWarning( "TQStringBuffer::readBlock: Read operation not permitted" ); + return -1; + } +#endif + if ( ioIndex + len > s->length()*sizeof(TQChar) ) { + // overflow + if ( (uint)ioIndex >= s->length()*sizeof(TQChar) ) { + setStatus( IO_ReadError ); + return -1; + } else { + len = s->length()*2 - (uint)ioIndex; + } + } + memcpy( p, ((const char*)(s->unicode()))+ioIndex, len ); + ioIndex += len; + return len; +} + +Q_LONG TQStringBuffer::writeBlock( const char *p, Q_ULONG len ) +{ +#if defined(QT_CHECK_NULL) + if ( p == 0 && len != 0 ) + qWarning( "TQStringBuffer::writeBlock: Null pointer error" ); +#endif +#if defined(QT_CHECK_STATE) + if ( !isOpen() ) { + qWarning( "TQStringBuffer::writeBlock: Buffer not open" ); + return -1; + } + if ( !isWritable() ) { + qWarning( "TQStringBuffer::writeBlock: Write operation not permitted" ); + return -1; + } + if ( ioIndex&1 ) { + qWarning( "TQStringBuffer::writeBlock: non-even index - non Unicode" ); + return -1; + } + if ( len&1 ) { + qWarning( "TQStringBuffer::writeBlock: non-even length - non Unicode" ); + return -1; + } +#endif + s->replace(ioIndex/2, len/2, (TQChar*)p, len/2); + ioIndex += len; + return len; +} + +int TQStringBuffer::getch() +{ +#if defined(QT_CHECK_STATE) + if ( !isOpen() ) { + qWarning( "TQStringBuffer::getch: Buffer not open" ); + return -1; + } + if ( !isReadable() ) { + qWarning( "TQStringBuffer::getch: Read operation not permitted" ); + return -1; + } +#endif + if ( (uint)ioIndex >= s->length()*2 ) { // overflow + setStatus( IO_ReadError ); + return -1; + } + return (int)((const uchar *)s->unicode())[ioIndex++]; +} + +int TQStringBuffer::putch( int ch ) +{ + char c = ch; + if ( writeBlock(&c,1) < 0 ) + return -1; + else + return ch; +} + +int TQStringBuffer::ungetch( int ch ) +{ +#if defined(QT_CHECK_STATE) + if ( !isOpen() ) { + qWarning( "TQStringBuffer::ungetch: Buffer not open" ); + return -1; + } + if ( !isReadable() ) { + qWarning( "TQStringBuffer::ungetch: Read operation not permitted" ); + return -1; + } +#endif + if ( ch != -1 ) { // something to do with eof + if ( ioIndex ) + ioIndex--; + else + ch = -1; + } + return ch; +} + + +/*! + Constructs a text stream that operates on the Unicode TQString, \a + str, through an internal device. The \a filemode argument is + passed to the device's open() function; see \l{TQIODevice::mode()}. + + If you set an encoding or codec with setEncoding() or setCodec(), + this setting is ignored for text streams that operate on TQString. + + Example: + \code + TQString str; + TQTextStream ts( &str, IO_WriteOnly ); + ts << "pi = " << 3.14; // str == "pi = 3.14" + \endcode + + Writing data to the text stream will modify the contents of the + string. The string will be expanded when data is written beyond + the end of the string. Note that the string will not be truncated: + \code + TQString str = "pi = 3.14"; + TQTextStream ts( &str, IO_WriteOnly ); + ts << "2+2 = " << 2+2; // str == "2+2 = 414" + \endcode + + Note that because TQString is Unicode, you should not use + readRawBytes() or writeRawBytes() on such a stream. +*/ + +TQTextStream::TQTextStream( TQString* str, int filemode ) +{ + // TODO: optimize for this case as it becomes more common + // (see TQStringBuffer above) + init(); + dev = new TQStringBuffer( str ); + ((TQStringBuffer *)dev)->open( filemode ); + owndev = TRUE; + setEncoding(RawUnicode); + reset(); + d->sourceType = TQTextStreamPrivate::String; +} + +/*! \obsolete + + This constructor is equivalent to the constructor taking a TQString* + parameter. +*/ + +TQTextStream::TQTextStream( TQString& str, int filemode ) +{ + init(); + dev = new TQStringBuffer( &str ); + ((TQStringBuffer *)dev)->open( filemode ); + owndev = TRUE; + setEncoding(RawUnicode); + reset(); + d->sourceType = TQTextStreamPrivate::String; +} + +/*! + Constructs a text stream that operates on the byte array, \a a, + through an internal TQBuffer device. The \a mode argument is passed + to the device's open() function; see \l{TQIODevice::mode()}. + + Example: + \code + TQByteArray array; + TQTextStream ts( array, IO_WriteOnly ); + ts << "pi = " << 3.14 << '\0'; // array == "pi = 3.14" + \endcode + + Writing data to the text stream will modify the contents of the + array. The array will be expanded when data is written beyond the + end of the string. + + Same example, using a TQBuffer: + \code + TQByteArray array; + TQBuffer buf( array ); + buf.open( IO_WriteOnly ); + TQTextStream ts( &buf ); + ts << "pi = " << 3.14 << '\0'; // array == "pi = 3.14" + buf.close(); + \endcode +*/ + +TQTextStream::TQTextStream( TQByteArray a, int mode ) +{ + init(); + dev = new TQBuffer( a ); + ((TQBuffer *)dev)->open( mode ); + owndev = TRUE; + setEncoding( Latin1 ); //### Locale??? + reset(); + d->sourceType = TQTextStreamPrivate::ByteArray; +} + +/*! + Constructs a text stream that operates on an existing file handle + \a fh through an internal TQFile device. The \a mode argument is + passed to the device's open() function; see \l{TQIODevice::mode()}. + + Note that if you create a TQTextStream \c cout or another name that + is also used for another variable of a different type, some + linkers may confuse the two variables, which will often cause + crashes. +*/ + +TQTextStream::TQTextStream( FILE *fh, int mode ) +{ + init(); + setEncoding( Locale ); //### + dev = new TQFile; + ((TQFile *)dev)->open( mode, fh ); + owndev = TRUE; + reset(); + d->sourceType = TQTextStreamPrivate::File; +} + +/*! + Destroys the text stream. + + The destructor does not affect the current IO device. +*/ + +TQTextStream::~TQTextStream() +{ + if ( owndev ) + delete dev; + delete d; +} + +/*! + Positions the read pointer at the first non-whitespace character. +*/ +void TQTextStream::skipWhiteSpace() +{ + ts_ungetc( eat_ws() ); +} + + +/*! + Tries to read \a len characters from the stream and stores them in + \a buf. Returns the number of characters really read. + + \warning There will no TQEOF appended if the read reaches the end + of the file. EOF is reached when the return value does not equal + \a len. +*/ +uint TQTextStream::ts_getbuf( TQChar* buf, uint len ) +{ + if ( len < 1 ) + return 0; + + uint rnum = 0; // the number of TQChars really read + + if ( d && d->ungetcBuf.length() ) { + while ( rnum < len && rnum < d->ungetcBuf.length() ) { + *buf = d->ungetcBuf.constref( rnum ); + buf++; + rnum++; + } + d->ungetcBuf = d->ungetcBuf.mid( rnum ); + if ( rnum >= len ) + return rnum; + } + + // we use dev->ungetch() for one of the bytes of the unicode + // byte-order mark, but a local unget hack for the other byte: + int ungetHack = EOF; + + if ( doUnicodeHeader ) { + doUnicodeHeader = FALSE; // only at the top + int c1 = dev->getch(); + if ( c1 == EOF ) + return rnum; + int c2 = dev->getch(); + if ( c1 == 0xfe && c2 == 0xff ) { + mapper = 0; + latin1 = FALSE; + internalOrder = TQChar::networkOrdered(); + networkOrder = TRUE; + } else if ( c1 == 0xff && c2 == 0xfe ) { + mapper = 0; + latin1 = FALSE; + internalOrder = !TQChar::networkOrdered(); + networkOrder = FALSE; + } else { + if ( c2 != EOF ) { + dev->ungetch( c2 ); + ungetHack = c1; + } else { + /* + A small bug might hide here. If only the first byte + of a file has made it so far, and that first byte + is half of the byte-order mark, then the utfness + will not be detected. + */ + dev->ungetch( c1 ); + } + } + } + +#ifndef QT_NO_TEXTCODEC + if ( mapper ) { + bool shortRead = FALSE; + if ( !d->decoder ) + d->decoder = mapper->makeDecoder(); + while( rnum < len ) { + TQString s; + bool readBlock = !( len == 1+rnum ); + for (;;) { + // for efficiency: normally read a whole block + if ( readBlock ) { + // guess buffersize; this may be wrong (too small or too + // big). But we can handle this (either iterate reading + // or use ungetcBuf). + // Note that this might cause problems for codecs where + // one byte can result in >1 Unicode Characters if bytes + // are written to the stream in the meantime (loss of + // synchronicity). + uint rlen = len - rnum; + char *cbuf = new char[ rlen ]; + if ( ungetHack != EOF ) { + rlen = 1+dev->readBlock( cbuf+1, rlen-1 ); + cbuf[0] = (char)ungetHack; + ungetHack = EOF; + } else { + rlen = dev->readBlock( cbuf, rlen ); + } + s += d->decoder->toUnicode( cbuf, rlen ); + delete[] cbuf; + // use buffered reading only for the first time, because we + // have to get the stream synchronous again (this is easier + // with single character reading) + readBlock = FALSE; + } + // get stream (and codec) in sync + int c; + if ( ungetHack == EOF ) { + c = dev->getch(); + } else { + c = ungetHack; + ungetHack = EOF; + } + if ( c == EOF ) { + shortRead = TRUE; + break; + } + char b = c; + uint lengthBefore = s.length(); + s += d->decoder->toUnicode( &b, 1 ); + if ( s.length() > lengthBefore ) + break; // it seems we are in sync now + } + uint i = 0; + uint end = TQMIN( len-rnum, s.length() ); + while( i < end ) { + *buf = s.constref(i++); + buf++; + } + rnum += end; + if ( s.length() > i ) { + // could be = but append is clearer + d->ungetcBuf.append( s.mid( i ) ); + } + if ( shortRead ) + return rnum; + } + } else +#endif + if ( latin1 ) { + if ( len == 1+rnum ) { + // use this method for one character because it is more efficient + // (arnt doubts whether it makes a difference, but lets it stand) + int c = (ungetHack == EOF) ? dev->getch() : ungetHack; + if ( c != EOF ) { + *buf = (char)c; + buf++; + rnum++; + } + } else { + if ( ungetHack != EOF ) { + *buf = (char)ungetHack; + buf++; + rnum++; + ungetHack = EOF; + } + char *cbuf = new char[len - rnum]; + while ( !dev->atEnd() && rnum < len ) { + uint rlen = len - rnum; + rlen = dev->readBlock( cbuf, rlen ); + char *it = cbuf; + char *end = cbuf + rlen; + while ( it < end ) { + *buf = *it; + buf++; + it++; + } + rnum += rlen; + } + delete[] cbuf; + } + } else { // UCS-2 or UTF-16 + if ( len == 1+rnum ) { + int c1 = (ungetHack == EOF) ? dev->getch() : ungetHack; + if ( c1 == EOF ) + return rnum; + int c2 = dev->getch(); + if ( c2 == EOF ) + return rnum; + + if ( networkOrder ) { + *buf = TQChar( c2, c1 ); + } else { + *buf = TQChar( c1, c2 ); + } + buf++; + rnum++; + } else { + char *cbuf = new char[ 2*( len - rnum ) ]; // for paranoids: overflow possible + while ( !dev->atEnd() && rnum < len ) { + uint rlen = 2 * ( len-rnum ); + if ( ungetHack != EOF ) { + rlen = 1+dev->readBlock( cbuf+1, rlen-1 ); + cbuf[0] = (char)ungetHack; + ungetHack = EOF; + } else { + rlen = dev->readBlock( cbuf, rlen ); + } + // We can't use an odd number of bytes, so put it back. But + // do it only if we are capable of reading more -- normally + // there should not be an odd number, but the file might be + // truncated or not in UTF-16... + if ( (rlen & 1) == 1 ) + if ( !dev->atEnd() ) + dev->ungetch( cbuf[--rlen] ); + uint i = 0; + if ( networkOrder ) { + while( i < rlen ) { + *buf = TQChar( cbuf[i+1], cbuf[i] ); + buf++; + i+=2; + } + } else { + while( i < rlen ) { + *buf = TQChar( cbuf[i], cbuf[i+1] ); + buf++; + i+=2; + } + } + rnum += i/2; + } + delete[] cbuf; + } + } + return rnum; +} + +/*! + Tries to read one line, but at most len characters from the stream + and stores them in \a buf. + + Returns the number of characters really read. Newlines are not + stripped. + + There will be a TQEOF appended if the read reaches the end of file; + this is different to ts_getbuf(). + + This function works only if a newline (as byte) is also a newline + (as resulting character) since it uses TQIODevice::readLine(). So + use it only for such codecs where this is true! + + This function is (almost) a no-op for UTF 16. Don't use it if + doUnicodeHeader is TRUE! +*/ +uint TQTextStream::ts_getline( TQChar* buf ) +{ + uint rnum=0; // the number of TQChars really read + char cbuf[ getline_buf_size+1 ]; + + if ( d && d->ungetcBuf.length() ) { + while( rnum < getline_buf_size && rnum < d->ungetcBuf.length() ) { + buf[rnum] = d->ungetcBuf.constref(rnum); + rnum++; + } + d->ungetcBuf = d->ungetcBuf.mid( rnum ); + if ( rnum >= getline_buf_size ) + return rnum; + } + +#ifndef QT_NO_TEXTCODEC + if ( mapper ) { + if ( !d->decoder ) + d->decoder = mapper->makeDecoder(); + TQString s; + bool readBlock = TRUE; + for (;;) { + // for efficiency: try to read a line + if ( readBlock ) { + int rlen = getline_buf_size - rnum; + rlen = dev->readLine( cbuf, rlen+1 ); + if ( rlen == -1 ) + rlen = 0; + s += d->decoder->toUnicode( cbuf, rlen ); + readBlock = FALSE; + } + if ( dev->atEnd() + || s.at( s.length()-1 ) == '\n' + || s.at( s.length()-1 ) == '\r' + ) { + break; + } else { + // get stream (and codec) in sync + int c; + c = dev->getch(); + if ( c == EOF ) { + break; + } + char b = c; + uint lengthBefore = s.length(); + s += d->decoder->toUnicode( &b, 1 ); + if ( s.length() > lengthBefore ) + break; // it seems we are in sync now + } + } + uint i = 0; + while( rnum < getline_buf_size && i < s.length() ) + buf[rnum++] = s.constref(i++); + if ( s.length() > i ) + // could be = but append is clearer + d->ungetcBuf.append( s.mid( i ) ); + if ( rnum < getline_buf_size && dev->atEnd() ) + buf[rnum++] = TQEOF; + } else +#endif + if ( latin1 ) { + int rlen = getline_buf_size - rnum; + rlen = dev->readLine( cbuf, rlen+1 ); + if ( rlen == -1 ) + rlen = 0; + char *end = cbuf+rlen; + char *it = cbuf; + buf +=rnum; + while ( it != end ) { + buf->setCell( *(it++) ); + buf->setRow( 0 ); + buf++; + } + rnum += rlen; + if ( rnum < getline_buf_size && dev->atEnd() ) + buf[1] = TQEOF; + } + return rnum; +} + + +/*! + Puts one character into the stream. +*/ +void TQTextStream::ts_putc( TQChar c ) +{ +#ifndef QT_NO_TEXTCODEC + if ( mapper ) { + if ( !d->encoder ) + d->encoder = mapper->makeEncoder(); + int len = 1; + TQString s = c; + TQCString block = d->encoder->fromUnicode( s, len ); + dev->writeBlock( block, len ); + } else +#endif + if ( latin1 ) { + if ( c.row() ) + dev->putch( '?' ); // unknown character + else + dev->putch( c.cell() ); + } else { + if ( doUnicodeHeader ) { + doUnicodeHeader = FALSE; + ts_putc( TQChar::byteOrderMark ); + } + if ( internalOrder ) { + // this case is needed by TQStringBuffer + dev->writeBlock( (char*)&c, sizeof(TQChar) ); + } else if ( networkOrder ) { + dev->putch( c.row() ); + dev->putch( c.cell() ); + } else { + dev->putch( c.cell() ); + dev->putch( c.row() ); + } + } +} + +/*! + Puts one character into the stream. +*/ +void TQTextStream::ts_putc( int ch ) +{ + ts_putc( TQChar((ushort)ch) ); +} + +bool TQTextStream::ts_isdigit( TQChar c ) +{ + return c.isDigit(); +} + +bool TQTextStream::ts_isspace( TQChar c ) +{ + return c.isSpace(); +} + +void TQTextStream::ts_ungetc( TQChar c ) +{ + if ( c.unicode() == 0xffff ) + return; + + d->ungetcBuf.prepend( c ); +} + + + +/*! + Reads \a len bytes from the stream into \a s and returns a + reference to the stream. + + The buffer \a s must be preallocated. + + Note that no encoding is done by this function. + + \warning The behavior of this function is undefined unless the + stream's encoding is set to Unicode or Latin1. + + \sa TQIODevice::readBlock() +*/ + +TQTextStream &TQTextStream::readRawBytes( char *s, uint len ) +{ + dev->readBlock( s, len ); + return *this; +} + +/*! + Writes the \a len bytes from \a s to the stream and returns a + reference to the stream. + + Note that no encoding is done by this function. + + \sa TQIODevice::writeBlock() +*/ + +TQTextStream &TQTextStream::writeRawBytes( const char* s, uint len ) +{ + dev->writeBlock( s, len ); + return *this; +} + + +TQTextStream &TQTextStream::writeBlock( const char* p, uint len ) +{ + if ( doUnicodeHeader ) { + doUnicodeHeader = FALSE; + if ( !mapper && !latin1 ) + ts_putc( TQChar::byteOrderMark ); + } + // TQCString and const char * are treated as Latin-1 + if ( !mapper && latin1 ) { + dev->writeBlock( p, len ); + } else if ( !mapper && internalOrder ) { + TQChar *u = new TQChar[len]; + for ( uint i = 0; i < len; i++ ) + u[i] = p[i]; + dev->writeBlock( (char*)u, len * sizeof(TQChar) ); + delete [] u; + } +#ifndef QT_NO_TEXTCODEC + else if (mapper) { + if (!d->encoder) + d->encoder = mapper->makeEncoder(); + TQString s = TQString::fromLatin1(p, len); + int l = len; + TQCString block = d->encoder->fromUnicode(s, l); + dev->writeBlock(block, l); + } +#endif + else { + for ( uint i = 0; i < len; i++ ) + ts_putc( (uchar)p[i] ); + } + return *this; +} + +TQTextStream &TQTextStream::writeBlock( const TQChar* p, uint len ) +{ +#ifndef QT_NO_TEXTCODEC + if ( mapper ) { + if ( !d->encoder ) + d->encoder = mapper->makeEncoder(); + TQConstString s( p, len ); + int l = len; + TQCString block = d->encoder->fromUnicode( s.string(), l ); + dev->writeBlock( block, l ); + } else +#endif + if ( latin1 ) { + char *str = TQString::unicodeToLatin1( p, len ); + dev->writeBlock( str, len ); + delete [] str; + } else if ( internalOrder ) { + if ( doUnicodeHeader ) { + doUnicodeHeader = FALSE; + ts_putc( TQChar::byteOrderMark ); + } + dev->writeBlock( (char*)p, sizeof(TQChar)*len ); + } else { + for (uint i=0; isourceType = TQTextStreamPrivate::IODevice; +} + +/*! + Unsets the IO device. Equivalent to setDevice( 0 ). + + \sa device(), setDevice() +*/ + +void TQTextStream::unsetDevice() +{ + setDevice( 0 ); + d->sourceType = TQTextStreamPrivate::NotSet; +} + +/*! + \fn bool TQTextStream::atEnd() const + + Returns TRUE if the IO device has reached the end position (end of + the stream or file) or if there is no IO device set; otherwise + returns FALSE. + + \sa TQIODevice::atEnd() +*/ + +/*!\fn bool TQTextStream::eof() const + + \obsolete + + This function has been renamed to atEnd(). + + \sa TQIODevice::atEnd() +*/ + +/***************************************************************************** + TQTextStream read functions + *****************************************************************************/ + + +/*! + \overload + + Reads a char \a c from the stream and returns a reference to the + stream. Note that whitespace is skipped. +*/ + +TQTextStream &TQTextStream::operator>>( char &c ) +{ + CHECK_STREAM_PRECOND + c = eat_ws(); + return *this; +} + +/*! + Reads a char \a c from the stream and returns a reference to the + stream. Note that whitespace is \e not skipped. +*/ + +TQTextStream &TQTextStream::operator>>( TQChar &c ) +{ + CHECK_STREAM_PRECOND + c = ts_getc(); + return *this; +} + + +ulong TQTextStream::input_bin() +{ + ulong val = 0; + TQChar ch = eat_ws(); + int dv = ch.digitValue(); + while ( dv == 0 || dv == 1 ) { + val = ( val << 1 ) + dv; + ch = ts_getc(); + dv = ch.digitValue(); + } + if ( ch != TQEOF ) + ts_ungetc( ch ); + return val; +} + +ulong TQTextStream::input_oct() +{ + ulong val = 0; + TQChar ch = eat_ws(); + int dv = ch.digitValue(); + while ( dv >= 0 && dv <= 7 ) { + val = ( val << 3 ) + dv; + ch = ts_getc(); + dv = ch.digitValue(); + } + if ( dv == 8 || dv == 9 ) { + while ( ts_isdigit(ch) ) + ch = ts_getc(); + } + if ( ch != TQEOF ) + ts_ungetc( ch ); + return val; +} + +ulong TQTextStream::input_dec() +{ + ulong val = 0; + TQChar ch = eat_ws(); + int dv = ch.digitValue(); + while ( ts_isdigit(ch) ) { + val = val * 10 + dv; + ch = ts_getc(); + dv = ch.digitValue(); + } + if ( ch != TQEOF ) + ts_ungetc( ch ); + return val; +} + +ulong TQTextStream::input_hex() +{ + ulong val = 0; + TQChar ch = eat_ws(); + char c = ch; + while ( isxdigit((uchar) c) ) { + val <<= 4; + if ( ts_isdigit(c) ) + val += c - '0'; + else + val += 10 + tolower( (uchar) c ) - 'a'; + c = ch = ts_getc(); + } + if ( ch != TQEOF ) + ts_ungetc( ch ); + return val; +} + +long TQTextStream::input_int() +{ + long val; + TQChar ch; + char c; + switch ( flags() & basefield ) { + case bin: + val = (long)input_bin(); + break; + case oct: + val = (long)input_oct(); + break; + case dec: + c = ch = eat_ws(); + if ( ch == TQEOF ) { + val = 0; + } else { + if ( !(c == '-' || c == '+') ) + ts_ungetc( ch ); + if ( c == '-' ) { + ulong v = input_dec(); + if ( v ) { // ensure that LONG_MIN can be read + v--; + val = -((long)v) - 1; + } else { + val = 0; + } + } else { + val = (long)input_dec(); + } + } + break; + case hex: + val = (long)input_hex(); + break; + default: + val = 0; + c = ch = eat_ws(); + if ( c == '0' ) { // bin, oct or hex + c = ch = ts_getc(); + if ( tolower((uchar) c) == 'x' ) + val = (long)input_hex(); + else if ( tolower((uchar) c) == 'b' ) + val = (long)input_bin(); + else { // octal + ts_ungetc( ch ); + if ( c >= '0' && c <= '7' ) { + val = (long)input_oct(); + } else { + val = 0; + } + } + } else if ( ts_isdigit(ch) ) { + ts_ungetc( ch ); + val = (long)input_dec(); + } else if ( c == '-' || c == '+' ) { + ulong v = input_dec(); + if ( c == '-' ) { + if ( v ) { // ensure that LONG_MIN can be read + v--; + val = -((long)v) - 1; + } else { + val = 0; + } + } else { + val = (long)v; + } + } + } + return val; +} + +// +// We use a table-driven FSM to parse floating point numbers +// strtod() cannot be used directly since we're reading from a TQIODevice +// + +double TQTextStream::input_double() +{ + const int Init = 0; // states + const int Sign = 1; + const int Mantissa = 2; + const int Dot = 3; + const int Abscissa = 4; + const int ExpMark = 5; + const int ExpSign = 6; + const int Exponent = 7; + const int Done = 8; + + const int InputSign = 1; // input tokens + const int InputDigit = 2; + const int InputDot = 3; + const int InputExp = 4; + + static const uchar table[8][5] = { + /* None InputSign InputDigit InputDot InputExp */ + { 0, Sign, Mantissa, Dot, 0, }, // Init + { 0, 0, Mantissa, Dot, 0, }, // Sign + { Done, Done, Mantissa, Dot, ExpMark,}, // Mantissa + { 0, 0, Abscissa, 0, 0, }, // Dot + { Done, Done, Abscissa, Done, ExpMark,}, // Abscissa + { 0, ExpSign, Exponent, 0, 0, }, // ExpMark + { 0, 0, Exponent, 0, 0, }, // ExpSign + { Done, Done, Exponent, Done, Done } // Exponent + }; + + int state = Init; // parse state + int input; // input token + + char buf[256]; + int i = 0; + TQChar c = eat_ws(); + + for (;;) { + + switch ( c ) { + case '+': + case '-': + input = InputSign; + break; + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + input = InputDigit; + break; + case '.': + input = InputDot; + break; + case 'e': + case 'E': + input = InputExp; + break; + default: + input = 0; + break; + } + + state = table[state][input]; + + if ( state == 0 || state == Done || i > 250 ) { + if ( i > 250 ) { // ignore rest of digits + do { c = ts_getc(); } while ( c != TQEOF && ts_isdigit(c) ); + } + if ( c != TQEOF ) + ts_ungetc( c ); + buf[i] = '\0'; + char *end; + return strtod( buf, &end ); + } + + buf[i++] = c; + c = ts_getc(); + } + +#if !defined(Q_CC_EDG) + return 0.0; +#endif +} + + +/*! + \overload + + Reads a signed \c short integer \a i from the stream and returns a + reference to the stream. See flags() for an explanation of the + expected input format. +*/ + +TQTextStream &TQTextStream::operator>>( signed short &i ) +{ + CHECK_STREAM_PRECOND + i = (signed short)input_int(); + return *this; +} + + +/*! + \overload + + Reads an unsigned \c short integer \a i from the stream and + returns a reference to the stream. See flags() for an explanation + of the expected input format. +*/ + +TQTextStream &TQTextStream::operator>>( unsigned short &i ) +{ + CHECK_STREAM_PRECOND + i = (unsigned short)input_int(); + return *this; +} + + +/*! + \overload + + Reads a signed \c int \a i from the stream and returns a reference + to the stream. See flags() for an explanation of the expected + input format. +*/ + +TQTextStream &TQTextStream::operator>>( signed int &i ) +{ + CHECK_STREAM_PRECOND + i = (signed int)input_int(); + return *this; +} + + +/*! + \overload + + Reads an unsigned \c int \a i from the stream and returns a + reference to the stream. See flags() for an explanation of the + expected input format. +*/ + +TQTextStream &TQTextStream::operator>>( unsigned int &i ) +{ + CHECK_STREAM_PRECOND + i = (unsigned int)input_int(); + return *this; +} + + +/*! + \overload + + Reads a signed \c long int \a i from the stream and returns a + reference to the stream. See flags() for an explanation of the + expected input format. +*/ + +TQTextStream &TQTextStream::operator>>( signed long &i ) +{ + CHECK_STREAM_PRECOND + i = (signed long)input_int(); + return *this; +} + + +/*! + \overload + + Reads an unsigned \c long int \a i from the stream and returns a + reference to the stream. See flags() for an explanation of the + expected input format. +*/ + +TQTextStream &TQTextStream::operator>>( unsigned long &i ) +{ + CHECK_STREAM_PRECOND + i = (unsigned long)input_int(); + return *this; +} + + +/*! + \overload + + Reads a \c float \a f from the stream and returns a reference to + the stream. See flags() for an explanation of the expected input + format. +*/ + +TQTextStream &TQTextStream::operator>>( float &f ) +{ + CHECK_STREAM_PRECOND + f = (float)input_double(); + return *this; +} + + +/*! + \overload + + Reads a \c double \a f from the stream and returns a reference to + the stream. See flags() for an explanation of the expected input + format. +*/ + +TQTextStream &TQTextStream::operator>>( double &f ) +{ + CHECK_STREAM_PRECOND + f = input_double(); + return *this; +} + + +/*! + \overload + + Reads a "word" from the stream into \a s and returns a reference + to the stream. + + A word consists of characters for which isspace() returns FALSE. +*/ + +TQTextStream &TQTextStream::operator>>( char *s ) +{ + CHECK_STREAM_PRECOND + int maxlen = width( 0 ); + TQChar c = eat_ws(); + if ( !maxlen ) + maxlen = -1; + while ( c != TQEOF ) { + if ( ts_isspace(c) || maxlen-- == 0 ) { + ts_ungetc( c ); + break; + } + *s++ = c; + c = ts_getc(); + } + + *s = '\0'; + return *this; +} + +/*! + \overload + + Reads a "word" from the stream into \a str and returns a reference + to the stream. + + A word consists of characters for which isspace() returns FALSE. +*/ + +TQTextStream &TQTextStream::operator>>( TQString &str ) +{ + CHECK_STREAM_PRECOND + str=TQString::fromLatin1(""); + TQChar c = eat_ws(); + + while ( c != TQEOF ) { + if ( ts_isspace(c) ) { + ts_ungetc( c ); + break; + } + str += c; + c = ts_getc(); + } + return *this; +} + +/*! + \overload + + Reads a "word" from the stream into \a str and returns a reference + to the stream. + + A word consists of characters for which isspace() returns FALSE. +*/ + +TQTextStream &TQTextStream::operator>>( TQCString &str ) +{ + CHECK_STREAM_PRECOND + TQCString *dynbuf = 0; + const int buflen = 256; + char buffer[buflen]; + char *s = buffer; + int i = 0; + TQChar c = eat_ws(); + + while ( c != TQEOF ) { + if ( ts_isspace(c) ) { + ts_ungetc( c ); + break; + } + if ( i >= buflen-1 ) { + if ( !dynbuf ) { // create dynamic buffer + dynbuf = new TQCString(buflen*2); + memcpy( dynbuf->data(), s, i ); // copy old data + } else if ( i >= (int)dynbuf->size()-1 ) { + dynbuf->resize( dynbuf->size()*2 ); + } + s = dynbuf->data(); + } + s[i++] = c; + c = ts_getc(); + } + str.resize( i+1 ); + memcpy( str.data(), s, i ); + delete dynbuf; + return *this; +} + + +/*! + Reads a line from the stream and returns a string containing the + text. + + The returned string does not contain any trailing newline or + carriage return. Note that this is different from + TQIODevice::readLine(), which does not strip the newline at the end + of the line. + + On EOF you will get a TQString that is null. On reading an empty + line the returned TQString is empty but not null. + + \sa TQIODevice::readLine() +*/ + +TQString TQTextStream::readLine() +{ +#if defined(QT_CHECK_STATE) + if ( !dev ) { + qWarning( "TQTextStream::readLine: No device" ); + return TQString::null; + } +#endif + bool readCharByChar = TRUE; + TQString result; +#if 0 + if ( !doUnicodeHeader && ( + (latin1) || + (mapper != 0 && mapper->mibEnum() == 106 ) // UTF 8 + ) ) { + readCharByChar = FALSE; + // use optimized read line + TQChar c[getline_buf_size]; + int pos = 0; + bool eof = FALSE; + + for (;;) { + pos = ts_getline( c ); + if ( pos == 0 ) { + // something went wrong; try fallback + readCharByChar = TRUE; + //dev->resetStatus(); + break; + } + if ( c[pos-1] == TQEOF || c[pos-1] == '\n' ) { + if ( pos>2 && c[pos-1]==TQEOF && c[pos-2]=='\n' ) { + result += TQString( c, pos-2 ); + } else if ( pos > 1 ) { + result += TQString( c, pos-1 ); + } + if ( pos == 1 && c[pos-1] == TQEOF ) + eof = TRUE; + break; + } else { + result += TQString( c, pos ); + } + } + if ( eof && result.isEmpty() ) + return TQString::null; + } +#endif + if ( readCharByChar ) { + const int buf_size = 256; + TQChar c[buf_size]; + int pos = 0; + + c[pos] = ts_getc(); + if ( c[pos] == TQEOF ) + return TQString::null; + + while ( c[pos] != TQEOF && c[pos] != '\n' ) { + if ( c[pos] == '\r' ) { // ( handle mac and dos ) + TQChar nextc = ts_getc(); + if ( nextc != '\n' ) + ts_ungetc( nextc ); + break; + } + pos++; + if ( pos >= buf_size ) { + result += TQString( c, pos ); + pos = 0; + } + c[pos] = ts_getc(); + } + result += TQString( c, pos ); + } + + return result; +} + + +/*! + Reads the entire stream from the current position, and returns a string + containing the text. + + \sa TQIODevice::readLine() +*/ + +TQString TQTextStream::read() +{ +#if defined(QT_CHECK_STATE) + if ( !dev ) { + qWarning( "TQTextStream::read: No device" ); + return TQString::null; + } +#endif + TQString result; + const uint bufsize = 512; + TQChar buf[bufsize]; + uint i, num, start; + bool skipped_cr = FALSE; + + for (;;) { + num = ts_getbuf(buf,bufsize); + // convert dos (\r\n) and mac (\r) style eol to unix style (\n) + start = 0; + for ( i=0; i>= 1; + if ( !n ) + break; + } + if ( flags() & showbase ) { // show base + *--p = (flags() & uppercase) ? 'B' : 'b'; + *--p = '0'; + } + break; + + case I_BASE_8: // output octal number + p = &buf[74]; + *p = '\0'; + do { + *--p = (char)(n&7) + '0'; + n >>= 3; + } while ( n ); + if ( flags() & showbase ) + *--p = '0'; + break; + + case I_BASE_16: // output hexadecimal number + p = &buf[74]; + *p = '\0'; + hexdigits = (flags() & uppercase) ? + hexdigits_upper : hexdigits_lower; + do { + *--p = hexdigits[(int)n&0xf]; + n >>= 4; + } while ( n ); + if ( flags() & showbase ) { + *--p = (flags() & uppercase) ? 'X' : 'x'; + *--p = '0'; + } + break; + + default: // decimal base is default + p = &buf[74]; + *p = '\0'; + if ( neg ) + n = (ulong)(-(long)n); + do { + *--p = ((int)(n%10)) + '0'; + n /= 10; + } while ( n ); + if ( neg ) + *--p = '-'; + else if ( flags() & showpos ) + *--p = '+'; + if ( (flags() & internal) && fwidth && !ts_isdigit(*p) ) { + ts_putc( *p ); // special case for internal + ++p; // padding + fwidth--; + return *this << (const char*)p; + } + } + if ( fwidth ) { // adjustment retquired + if ( !(flags() & left) ) { // but NOT left adjustment + len = qstrlen(p); + int padlen = fwidth - len; + if ( padlen <= 0 ) { // no padding retquired + writeBlock( p, len ); + } else if ( padlen < (int)(p-buf) ) { // speeds up padding + memset( p-padlen, (char)fillchar, padlen ); + writeBlock( p-padlen, padlen+len ); + } + else // standard padding + *this << (const char*)p; + } + else + *this << (const char*)p; + fwidth = 0; // reset field width + } + else + writeBlock( p, qstrlen(p) ); + return *this; +} + + +/*! + \overload + + Writes a \c short integer \a i to the stream and returns a + reference to the stream. +*/ + +TQTextStream &TQTextStream::operator<<( signed short i ) +{ + return output_int( I_SHORT | I_SIGNED, i, i < 0 ); +} + + +/*! + \overload + + Writes an \c unsigned \c short integer \a i to the stream and + returns a reference to the stream. +*/ + +TQTextStream &TQTextStream::operator<<( unsigned short i ) +{ + return output_int( I_SHORT | I_UNSIGNED, i, FALSE ); +} + + +/*! + \overload + + Writes an \c int \a i to the stream and returns a reference to the + stream. +*/ + +TQTextStream &TQTextStream::operator<<( signed int i ) +{ + return output_int( I_INT | I_SIGNED, i, i < 0 ); +} + + +/*! + \overload + + Writes an \c unsigned \c int \a i to the stream and returns a + reference to the stream. +*/ + +TQTextStream &TQTextStream::operator<<( unsigned int i ) +{ + return output_int( I_INT | I_UNSIGNED, i, FALSE ); +} + + +/*! + \overload + + Writes a \c long \c int \a i to the stream and returns a reference + to the stream. +*/ + +TQTextStream &TQTextStream::operator<<( signed long i ) +{ + return output_int( I_LONG | I_SIGNED, i, i < 0 ); +} + + +/*! + \overload + + Writes an \c unsigned \c long \c int \a i to the stream and + returns a reference to the stream. +*/ + +TQTextStream &TQTextStream::operator<<( unsigned long i ) +{ + return output_int( I_LONG | I_UNSIGNED, i, FALSE ); +} + + +/*! + \overload + + Writes a \c float \a f to the stream and returns a reference to + the stream. +*/ + +TQTextStream &TQTextStream::operator<<( float f ) +{ + return *this << (double)f; +} + +/*! + \overload + + Writes a \c double \a f to the stream and returns a reference to + the stream. +*/ + +TQTextStream &TQTextStream::operator<<( double f ) +{ + CHECK_STREAM_PRECOND + char f_char; + char format[16]; + if ( (flags()&floatfield) == fixed ) + f_char = 'f'; + else if ( (flags()&floatfield) == scientific ) + f_char = (flags() & uppercase) ? 'E' : 'e'; + else + f_char = (flags() & uppercase) ? 'G' : 'g'; + register char *fs = format; // generate format string + *fs++ = '%'; // "%.l" + *fs++ = '.'; + int prec = precision(); + if ( prec > 99 ) + prec = 99; + if ( prec >= 10 ) { + *fs++ = prec / 10 + '0'; + *fs++ = prec % 10 + '0'; + } else { + *fs++ = prec + '0'; + } + *fs++ = 'l'; + *fs++ = f_char; + *fs = '\0'; + TQString num; + num.sprintf(format, f); // convert to text + if ( fwidth ) // padding + *this << num.latin1(); + else // just write it + writeBlock(num.latin1(), num.length()); + return *this; +} + + +/*! + \overload + + Writes a string to the stream and returns a reference to the + stream. + + The string \a s is assumed to be Latin1 encoded independent of the + Encoding set for the TQTextStream. +*/ + +TQTextStream &TQTextStream::operator<<( const char* s ) +{ + CHECK_STREAM_PRECOND + char padbuf[48]; + uint len = qstrlen( s ); // don't write null terminator + if ( fwidth ) { // field width set + int padlen = fwidth - len; + fwidth = 0; // reset width + if ( padlen > 0 ) { + char *ppad; + if ( padlen > 46 ) { // create extra big fill buffer + ppad = new char[padlen]; + Q_CHECK_PTR( ppad ); + } else { + ppad = padbuf; + } + memset( ppad, (char)fillchar, padlen ); // fill with fillchar + if ( !(flags() & left) ) { + writeBlock( ppad, padlen ); + padlen = 0; + } + writeBlock( s, len ); + if ( padlen ) + writeBlock( ppad, padlen ); + if ( ppad != padbuf ) // delete extra big fill buf + delete[] ppad; + return *this; + } + } + writeBlock( s, len ); + return *this; +} + +/*! + \overload + + Writes \a s to the stream and returns a reference to the stream. + + The string \a s is assumed to be Latin1 encoded independent of the + Encoding set for the TQTextStream. +*/ + +TQTextStream &TQTextStream::operator<<( const TQCString & s ) +{ + return operator<<(s.data()); +} + +/*! + \overload + + Writes \a s to the stream and returns a reference to the stream. +*/ + +TQTextStream &TQTextStream::operator<<( const TQString& s ) +{ + if ( !mapper && latin1 ) + return operator<<(s.latin1()); + CHECK_STREAM_PRECOND + TQString s1 = s; + if ( fwidth ) { // field width set + if ( !(flags() & left) ) { + s1 = s.rightJustify(fwidth, (char)fillchar); + } else { + s1 = s.leftJustify(fwidth, (char)fillchar); + } + fwidth = 0; // reset width + } + writeBlock( s1.unicode(), s1.length() ); + return *this; +} + + +/*! + \overload + + Writes a pointer to the stream and returns a reference to the + stream. + + The \a ptr is output as an unsigned long hexadecimal integer. +*/ + +TQTextStream &TQTextStream::operator<<( void *ptr ) +{ + int f = flags(); + setf( hex, basefield ); + setf( showbase ); + unsetf( uppercase ); + output_int( I_LONG | I_UNSIGNED, (ulong)ptr, FALSE ); + flags( f ); + return *this; +} + + +/*! + \fn int TQTextStream::flags() const + + Returns the current stream flags. The default value is 0. + + \table + \header \i Flag \i Meaning + \row \i \c skipws \i Not currently used; whitespace always skipped + \row \i \c left \i Numeric fields are left-aligned + \row \i \c right + \i Not currently used (by default, numerics are right-aligned) + \row \i \c internal \i Puts any padding spaces between +/- and value + \row \i \c bin \i Output \e and input only in binary + \row \i \c oct \i Output \e and input only in octal + \row \i \c dec \i Output \e and input only in decimal + \row \i \c hex \i Output \e and input only in hexadecimal + \row \i \c showbase + \i Annotates numeric outputs with 0b, 0, or 0x if in \c bin, + \c oct, or \c hex format + \row \i \c showpoint \i Not currently used + \row \i \c uppercase \i Uses 0B and 0X rather than 0b and 0x + \row \i \c showpos \i Shows + for positive numeric values + \row \i \c scientific \i Uses scientific notation for floating point values + \row \i \c fixed \i Uses fixed-point notation for floating point values + \endtable + + Note that unless \c bin, \c oct, \c dec, or \c hex is set, the + input base is octal if the value starts with 0, hexadecimal if it + starts with 0x, binary if it starts with 0b, and decimal + otherwise. + + \sa setf(), unsetf() +*/ + +/*! + \fn int TQTextStream::flags( int f ) + + \overload + + Sets the stream flags to \a f. Returns the previous stream flags. + + \sa setf(), unsetf(), flags() +*/ + +/*! + \fn int TQTextStream::setf( int bits ) + + Sets the stream flag bits \a bits. Returns the previous stream + flags. + + Equivalent to \c{flags( flags() | bits )}. + + \sa setf(), unsetf() +*/ + +/*! + \fn int TQTextStream::setf( int bits, int mask ) + + \overload + + Sets the stream flag bits \a bits with a bit mask \a mask. Returns + the previous stream flags. + + Equivalent to \c{flags( (flags() & ~mask) | (bits & mask) )}. + + \sa setf(), unsetf() +*/ + +/*! + \fn int TQTextStream::unsetf( int bits ) + + Clears the stream flag bits \a bits. Returns the previous stream + flags. + + Equivalent to \c{flags( flags() & ~mask )}. + + \sa setf() +*/ + +/*! + \fn int TQTextStream::width() const + + Returns the field width. The default value is 0. +*/ + +/*! + \fn int TQTextStream::width( int w ) + + \overload + + Sets the field width to \a w. Returns the previous field width. +*/ + +/*! + \fn int TQTextStream::fill() const + + Returns the fill character. The default value is ' ' (space). +*/ + +/*! + \overload int TQTextStream::fill( int f ) + + Sets the fill character to \a f. Returns the previous fill character. +*/ + +/*! + \fn int TQTextStream::precision() const + + Returns the precision. The default value is 6. +*/ + +/*! + \fn int TQTextStream::precision( int p ) + + \overload + + Sets the precision to \a p. Returns the previous precision setting. +*/ + + + /***************************************************************************** + TQTextStream manipulators + *****************************************************************************/ + +TQTextStream &bin( TQTextStream &s ) +{ + s.setf(TQTS::bin,TQTS::basefield); + return s; +} + +TQTextStream &oct( TQTextStream &s ) +{ + s.setf(TQTS::oct,TQTS::basefield); + return s; +} + +TQTextStream &dec( TQTextStream &s ) +{ + s.setf(TQTS::dec,TQTS::basefield); + return s; +} + +TQTextStream &hex( TQTextStream &s ) +{ + s.setf(TQTS::hex,TQTS::basefield); + return s; +} + +TQTextStream &endl( TQTextStream &s ) +{ + return s << '\n'; +} + +TQTextStream &flush( TQTextStream &s ) +{ + if ( s.device() ) + s.device()->flush(); + return s; +} + +TQTextStream &ws( TQTextStream &s ) +{ + s.skipWhiteSpace(); + return s; +} + +TQTextStream &reset( TQTextStream &s ) +{ + s.reset(); + return s; +} + + +/*! + \class TQTextIStream qtextstream.h + \reentrant + \brief The TQTextIStream class is a convenience class for input streams. + + \ingroup io + \ingroup text + + This class provides a shorthand for creating simple input + \l{TQTextStream}s without having to pass a \e mode argument to the + constructor. + + This class makes it easy, for example, to write things like this: + \code + TQString data = "123 456"; + int a, b; + TQTextIStream(&data) >> a >> b; + \endcode + + \sa TQTextOStream +*/ + +/*! + \fn TQTextIStream::TQTextIStream( const TQString *s ) + + Constructs a stream to read from the string \a s. +*/ +/*! + \fn TQTextIStream::TQTextIStream( TQByteArray ba ) + + Constructs a stream to read from the array \a ba. +*/ +/*! + \fn TQTextIStream::TQTextIStream( FILE *f ) + + Constructs a stream to read from the file \a f. +*/ + + +/*! + \class TQTextOStream + \reentrant + \brief The TQTextOStream class is a convenience class for output streams. + + \ingroup io + \ingroup text + + This class provides a shorthand for creating simple output + \l{TQTextStream}s without having to pass a \e mode argument to the + constructor. + + This makes it easy for example, to write things like this: + \code + TQString result; + TQTextOStream(&result) << "pi = " << 3.14; + \endcode +*/ + +/*! + \fn TQTextOStream::TQTextOStream( TQString *s ) + + Constructs a stream to write to string \a s. +*/ +/*! + \fn TQTextOStream::TQTextOStream( TQByteArray ba ) + + Constructs a stream to write to the array \a ba. +*/ +/*! + \fn TQTextOStream::TQTextOStream( FILE *f ) + + Constructs a stream to write to the file \a f. +*/ + + + +/*! + Sets the encoding of this stream to \a e, where \a e is one of the + following values: + \table + \header \i Encoding \i Meaning + \row \i Locale + \i Uses local file format (Latin1 if locale is not set), but + autodetecting Unicode(utf16) on input. + \row \i Unicode + \i Uses Unicode(utf16) for input and output. Output will be + written in the order most efficient for the current platform + (i.e. the order used internally in TQString). + \row \i UnicodeUTF8 + \i Using Unicode(utf8) for input and output. If you use it for + input it will autodetect utf16 and use it instead of utf8. + \row \i Latin1 + \i ISO-8859-1. Will not autodetect utf16. + \row \i UnicodeNetworkOrder + \i Uses network order Unicode(utf16) for input and output. + Useful when reading Unicode data that does not start with the + byte order marker. + \row \i UnicodeReverse + \i Uses reverse network order Unicode(utf16) for input and + output. Useful when reading Unicode data that does not start + with the byte order marker or when writing data that should be + read by buggy Windows applications. + \row \i RawUnicode + \i Like Unicode, but does not write the byte order marker nor + does it auto-detect the byte order. Useful only when writing to + non-persistent storage used by a single process. + \endtable + + \c Locale and all Unicode encodings, except \c RawUnicode, will look + at the first two bytes in an input stream to determine the byte + order. The initial byte order marker will be stripped off before + data is read. + + Note that this function should be called before any data is read to + or written from the stream. + + \sa setCodec() +*/ + +void TQTextStream::setEncoding( Encoding e ) +{ + if ( d->sourceType == TQTextStreamPrivate::String ) + return; + + switch ( e ) { + case Unicode: + mapper = 0; + latin1 = FALSE; + doUnicodeHeader = TRUE; + internalOrder = TRUE; + networkOrder = TQChar::networkOrdered(); + break; + case UnicodeUTF8: +#ifndef QT_NO_TEXTCODEC + mapper = TQTextCodec::codecForMib( 106 ); + latin1 = FALSE; + doUnicodeHeader = TRUE; + internalOrder = TRUE; + networkOrder = TQChar::networkOrdered(); +#else + mapper = 0; + latin1 = TRUE; + doUnicodeHeader = TRUE; +#endif + break; + case UnicodeNetworkOrder: + mapper = 0; + latin1 = FALSE; + doUnicodeHeader = TRUE; + internalOrder = TQChar::networkOrdered(); + networkOrder = TRUE; + break; + case UnicodeReverse: + mapper = 0; + latin1 = FALSE; + doUnicodeHeader = TRUE; + internalOrder = !TQChar::networkOrdered(); + networkOrder = FALSE; + break; + case RawUnicode: + mapper = 0; + latin1 = FALSE; + doUnicodeHeader = FALSE; + internalOrder = TRUE; + networkOrder = TQChar::networkOrdered(); + break; + case Locale: + latin1 = TRUE; // fallback to Latin-1 +#ifndef QT_NO_TEXTCODEC + mapper = TQTextCodec::codecForLocale(); + // optimized Latin-1 processing +#if defined(Q_OS_WIN32) + if ( GetACP() == 1252 ) + mapper = 0; +#endif + if ( mapper && mapper->mibEnum() == 4 ) +#endif + mapper = 0; + + doUnicodeHeader = TRUE; // If it reads as Unicode, accept it + break; + case Latin1: + mapper = 0; + doUnicodeHeader = FALSE; + latin1 = TRUE; + break; + } +} + + +#ifndef QT_NO_TEXTCODEC +/*! + Sets the codec for this stream to \a codec. Will not try to + autodetect Unicode. + + Note that this function should be called before any data is read + to/written from the stream. + + \sa setEncoding(), codec() +*/ + +void TQTextStream::setCodec( TQTextCodec *codec ) +{ + if ( d->sourceType == TQTextStreamPrivate::String ) + return; // TQString does not need any codec + mapper = codec; + latin1 = ( codec->mibEnum() == 4 ); + if ( latin1 ) + mapper = 0; + doUnicodeHeader = FALSE; +} + +/*! + Returns the codec actually used for this stream. + + If Unicode is automatically detected in input, a codec with \link + TQTextCodec::name() name() \endlink "ISO-10646-UCS-2" is returned. + + \sa setCodec() +*/ + +TQTextCodec *TQTextStream::codec() +{ + if ( mapper ) { + return mapper; + } else { + // 4 is "ISO 8859-1", 1000 is "ISO-10646-UCS-2" + return TQTextCodec::codecForMib( latin1 ? 4 : 1000 ); + } +} + +#endif + +#endif // QT_NO_TEXTSTREAM diff --git a/src/tools/qtextstream.h b/src/tools/qtextstream.h new file mode 100644 index 000000000..8cf70af35 --- /dev/null +++ b/src/tools/qtextstream.h @@ -0,0 +1,338 @@ +/**************************************************************************** +** +** Definition of TQTextStream class +** +** Created : 940922 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQTEXTSTREAM_H +#define TQTEXTSTREAM_H + +#ifndef QT_H +#include "qiodevice.h" +#include "qstring.h" +#include +#endif // QT_H + +#ifndef QT_NO_TEXTSTREAM +class TQTextCodec; +class TQTextDecoder; + +class TQTextStreamPrivate; + +class Q_EXPORT TQTextStream // text stream class +{ +public: + enum Encoding { Locale, Latin1, Unicode, UnicodeNetworkOrder, + UnicodeReverse, RawUnicode, UnicodeUTF8 }; + + void setEncoding( Encoding ); +#ifndef QT_NO_TEXTCODEC + void setCodec( TQTextCodec* ); + TQTextCodec *codec(); +#endif + + TQTextStream(); + TQTextStream( TQIODevice * ); + TQTextStream( TQString*, int mode ); + TQTextStream( TQString&, int mode ); // obsolete + TQTextStream( TQByteArray, int mode ); + TQTextStream( FILE *, int mode ); + virtual ~TQTextStream(); + + TQIODevice *device() const; + void setDevice( TQIODevice * ); + void unsetDevice(); + + bool atEnd() const; + bool eof() const; + + TQTextStream &operator>>( TQChar & ); + TQTextStream &operator>>( char & ); + TQTextStream &operator>>( signed short & ); + TQTextStream &operator>>( unsigned short & ); + TQTextStream &operator>>( signed int & ); + TQTextStream &operator>>( unsigned int & ); + TQTextStream &operator>>( signed long & ); + TQTextStream &operator>>( unsigned long & ); + TQTextStream &operator>>( float & ); + TQTextStream &operator>>( double & ); + TQTextStream &operator>>( char * ); + TQTextStream &operator>>( TQString & ); + TQTextStream &operator>>( TQCString & ); + + TQTextStream &operator<<( TQChar ); + TQTextStream &operator<<( char ); + TQTextStream &operator<<( signed short ); + TQTextStream &operator<<( unsigned short ); + TQTextStream &operator<<( signed int ); + TQTextStream &operator<<( unsigned int ); + TQTextStream &operator<<( signed long ); + TQTextStream &operator<<( unsigned long ); + TQTextStream &operator<<( float ); + TQTextStream &operator<<( double ); + TQTextStream &operator<<( const char* ); + TQTextStream &operator<<( const TQString & ); + TQTextStream &operator<<( const TQCString & ); + TQTextStream &operator<<( void * ); // any pointer + + TQTextStream &readRawBytes( char *, uint len ); + TQTextStream &writeRawBytes( const char* , uint len ); + + TQString readLine(); + TQString read(); + void skipWhiteSpace(); + + enum { + skipws = 0x0001, // skip whitespace on input + left = 0x0002, // left-adjust output + right = 0x0004, // right-adjust output + internal = 0x0008, // pad after sign + bin = 0x0010, // binary format integer + oct = 0x0020, // octal format integer + dec = 0x0040, // decimal format integer + hex = 0x0080, // hex format integer + showbase = 0x0100, // show base indicator + showpoint = 0x0200, // force decimal point (float) + uppercase = 0x0400, // upper-case hex output + showpos = 0x0800, // add '+' to positive integers + scientific= 0x1000, // scientific float output + fixed = 0x2000 // fixed float output + }; + + static const int basefield; // bin | oct | dec | hex + static const int adjustfield; // left | right | internal + static const int floatfield; // scientific | fixed + + int flags() const; + int flags( int f ); + int setf( int bits ); + int setf( int bits, int mask ); + int unsetf( int bits ); + + void reset(); + + int width() const; + int width( int ); + int fill() const; + int fill( int ); + int precision() const; + int precision( int ); + +private: + long input_int(); + void init(); + TQTextStream &output_int( int, ulong, bool ); + TQIODevice *dev; + + int fflags; + int fwidth; + int fillchar; + int fprec; + bool doUnicodeHeader; + bool owndev; + TQTextCodec *mapper; + TQTextStreamPrivate * d; + TQChar unused1; // ### remove in TQt 4.0 + bool latin1; + bool internalOrder; + bool networkOrder; + void *unused2; // ### remove in TQt 4.0 + + TQChar eat_ws(); + uint ts_getline( TQChar* ); + void ts_ungetc( TQChar ); + TQChar ts_getc(); + uint ts_getbuf( TQChar*, uint ); + void ts_putc(int); + void ts_putc(TQChar); + bool ts_isspace(TQChar); + bool ts_isdigit(TQChar); + ulong input_bin(); + ulong input_oct(); + ulong input_dec(); + ulong input_hex(); + double input_double(); + TQTextStream &writeBlock( const char* p, uint len ); + TQTextStream &writeBlock( const TQChar* p, uint len ); + +private: // Disabled copy constructor and operator= +#if defined(Q_DISABLE_COPY) + TQTextStream( const TQTextStream & ); + TQTextStream &operator=( const TQTextStream & ); +#endif +}; + +typedef TQTextStream TQTS; + +class Q_EXPORT TQTextIStream : public TQTextStream { +public: + TQTextIStream( const TQString* s ) : + TQTextStream((TQString*)s,IO_ReadOnly) { } + TQTextIStream( TQByteArray ba ) : + TQTextStream(ba,IO_ReadOnly) { } + TQTextIStream( FILE *f ) : + TQTextStream(f,IO_ReadOnly) { } + +private: // Disabled copy constructor and operator= +#if defined(Q_DISABLE_COPY) + TQTextIStream( const TQTextIStream & ); + TQTextIStream &operator=( const TQTextIStream & ); +#endif +}; + +class Q_EXPORT TQTextOStream : public TQTextStream { +public: + TQTextOStream( TQString* s ) : + TQTextStream(s,IO_WriteOnly) { } + TQTextOStream( TQByteArray ba ) : + TQTextStream(ba,IO_WriteOnly) { } + TQTextOStream( FILE *f ) : + TQTextStream(f,IO_WriteOnly) { } + +private: // Disabled copy constructor and operator= +#if defined(Q_DISABLE_COPY) + TQTextOStream( const TQTextOStream & ); + TQTextOStream &operator=( const TQTextOStream & ); +#endif +}; + +/***************************************************************************** + TQTextStream inline functions + *****************************************************************************/ + +inline TQIODevice *TQTextStream::device() const +{ return dev; } + +inline bool TQTextStream::atEnd() const +{ return dev ? dev->atEnd() : FALSE; } + +inline bool TQTextStream::eof() const +{ return atEnd(); } + +inline int TQTextStream::flags() const +{ return fflags; } + +inline int TQTextStream::flags( int f ) +{ int oldf = fflags; fflags = f; return oldf; } + +inline int TQTextStream::setf( int bits ) +{ int oldf = fflags; fflags |= bits; return oldf; } + +inline int TQTextStream::setf( int bits, int mask ) +{ int oldf = fflags; fflags = (fflags & ~mask) | (bits & mask); return oldf; } + +inline int TQTextStream::unsetf( int bits ) +{ int oldf = fflags; fflags &= ~bits; return oldf; } + +inline int TQTextStream::width() const +{ return fwidth; } + +inline int TQTextStream::width( int w ) +{ int oldw = fwidth; fwidth = w; return oldw; } + +inline int TQTextStream::fill() const +{ return fillchar; } + +inline int TQTextStream::fill( int f ) +{ int oldc = fillchar; fillchar = f; return oldc; } + +inline int TQTextStream::precision() const +{ return fprec; } + +inline int TQTextStream::precision( int p ) +{ int oldp = fprec; fprec = p; return oldp; } + +/*! + Returns one character from the stream, or EOF. +*/ +inline TQChar TQTextStream::ts_getc() +{ TQChar r; return ( ts_getbuf( &r,1 ) == 1 ? r : TQChar((ushort)0xffff) ); } + +/***************************************************************************** + TQTextStream manipulators + *****************************************************************************/ + +typedef TQTextStream & (*TQTSFUNC)(TQTextStream &);// manipulator function +typedef int (TQTextStream::*TQTSMFI)(int); // manipulator w/int argument + +class Q_EXPORT TQTSManip { // text stream manipulator +public: + TQTSManip( TQTSMFI m, int a ) { mf=m; arg=a; } + void exec( TQTextStream &s ) { (s.*mf)(arg); } +private: + TQTSMFI mf; // TQTextStream member function + int arg; // member function argument +}; + +Q_EXPORT inline TQTextStream &operator>>( TQTextStream &s, TQTSFUNC f ) +{ return (*f)( s ); } + +Q_EXPORT inline TQTextStream &operator<<( TQTextStream &s, TQTSFUNC f ) +{ return (*f)( s ); } + +Q_EXPORT inline TQTextStream &operator<<( TQTextStream &s, TQTSManip m ) +{ m.exec(s); return s; } + +Q_EXPORT TQTextStream &bin( TQTextStream &s ); // set bin notation +Q_EXPORT TQTextStream &oct( TQTextStream &s ); // set oct notation +Q_EXPORT TQTextStream &dec( TQTextStream &s ); // set dec notation +Q_EXPORT TQTextStream &hex( TQTextStream &s ); // set hex notation +Q_EXPORT TQTextStream &endl( TQTextStream &s ); // insert EOL ('\n') +Q_EXPORT TQTextStream &flush( TQTextStream &s ); // flush output +Q_EXPORT TQTextStream &ws( TQTextStream &s ); // eat whitespace on input +Q_EXPORT TQTextStream &reset( TQTextStream &s ); // set default flags + +Q_EXPORT inline TQTSManip qSetW( int w ) +{ + TQTSMFI func = &TQTextStream::width; + return TQTSManip(func,w); +} + +Q_EXPORT inline TQTSManip qSetFill( int f ) +{ + TQTSMFI func = &TQTextStream::fill; + return TQTSManip(func,f); +} + +Q_EXPORT inline TQTSManip qSetPrecision( int p ) +{ + TQTSMFI func = &TQTextStream::precision; + return TQTSManip(func,p); +} + +#endif // QT_NO_TEXTSTREAM +#endif // TQTEXTSTREAM_H diff --git a/src/tools/qthreadinstance_p.h b/src/tools/qthreadinstance_p.h new file mode 100644 index 000000000..38b9f5cfd --- /dev/null +++ b/src/tools/qthreadinstance_p.h @@ -0,0 +1,101 @@ +/**************************************************************************** +** +** ... +** +** Copyright (C) 2005-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQTHREAD_P_H +#define TQTHREAD_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the TQt API. It exists for the convenience +// of TQThread and TQThreadStorage. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// +// + +#ifdef QT_THREAD_SUPPORT + +#ifndef QT_H +#include "qmutex.h" +#include "qwindowdefs.h" +#endif // QT_H + +#ifdef Q_OS_UNIX +#include +#endif + +class TQThreadInstance { +public: + static TQThreadInstance *current(); + + void init(unsigned int stackSize); + void deinit(); + + TQMutex *mutex() const; + void terminate(); + + unsigned int stacksize; + void *args[2]; + void **thread_storage; + bool finished : 1; + bool running : 1; + bool orphan : 1; + +#ifdef Q_OS_UNIX + pthread_cond_t thread_done; + pthread_t thread_id; + + static void *start( void * ); + static void finish( void * ); +#endif // Q_OS_UNIX + +#ifdef Q_OS_WIN32 + TQt::HANDLE handle; + unsigned int thread_id; + int waiters; + + static unsigned int __stdcall start( void * ); + static void finish( TQThreadInstance * ); +#endif // Q_OS_WIN32 +}; + +#endif // QT_THREAD_SUPPORT +#endif // TQTHREAD_P_H diff --git a/src/tools/qthreadstorage.h b/src/tools/qthreadstorage.h new file mode 100644 index 000000000..08f669378 --- /dev/null +++ b/src/tools/qthreadstorage.h @@ -0,0 +1,95 @@ +/**************************************************************************** +** +** ... +** +** Copyright (C) 2005-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQTHREADSTORAGE_H +#define TQTHREADSTORAGE_H + +#ifdef QT_THREAD_SUPPORT + +#ifndef QT_H +#include "qglobal.h" +#endif // QT_H + +class Q_EXPORT TQThreadStorageData +{ +public: + TQThreadStorageData( void (*func)(void *) ); + ~TQThreadStorageData(); + + void** get() const; + void** set( void* p ); + + static void finish( void** ); + int id; +}; + + +template +class TQThreadStorage +{ +private: + TQThreadStorageData d; + +#if defined(Q_DISABLE_COPY) + // disable copy constructor and operator= + TQThreadStorage( const TQThreadStorage & ); + TQThreadStorage &operator=( const TQThreadStorage & ); +#endif // Q_DISABLE_COPY + + static void deleteData( void *x ) { delete (T)x; } + +public: + inline TQThreadStorage() : d( deleteData ) { } + inline ~TQThreadStorage() { } + + inline bool hasLocalData() const + { return d.get() != 0; } + + inline T& localData() + { void **v = d.get(); if ( !v ) v = d.set( 0 ); return *(T*)v; } + + inline T localData() const + { void **v = d.get(); return ( v ? *(T*)v : 0 ); } + + inline void setLocalData( T t ) + { (void) d.set( t ); } +}; + +#endif // QT_THREAD_SUPPORT + +#endif // TQTHREADSTORAGE_H diff --git a/src/tools/qthreadstorage_unix.cpp b/src/tools/qthreadstorage_unix.cpp new file mode 100644 index 000000000..3d4aa9de5 --- /dev/null +++ b/src/tools/qthreadstorage_unix.cpp @@ -0,0 +1,349 @@ +/**************************************************************************** +** +** ... +** +** Copyright (C) 2005-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifdef QT_THREAD_SUPPORT + +#include "qplatformdefs.h" + +#include "qthreadstorage.h" +#include + +#include + +// #define TQTHREADSTORAGE_DEBUG + + +// keep this in sync with the implementation in qthreadstorage.cpp +static const int MAX_THREAD_STORAGE = 257; // 256 maximum + 1 used in TQRegExp + +static pthread_mutex_t thread_storage_mutex = PTHREAD_MUTEX_INITIALIZER; + +static bool thread_storage_init = FALSE; +static struct { + bool used; + void (*func)( void * ); +} thread_storage_usage[MAX_THREAD_STORAGE]; + + +TQThreadStorageData::TQThreadStorageData( void (*func)( void * ) ) + : id( 0 ) +{ + pthread_mutex_lock( &thread_storage_mutex ); + + // make sure things are initialized + if ( ! thread_storage_init ) + memset( thread_storage_usage, 0, sizeof( thread_storage_usage ) ); + thread_storage_init = TRUE; + + for ( ; id < MAX_THREAD_STORAGE; ++id ) { + if ( !thread_storage_usage[id].used ) + break; + } + + Q_ASSERT( id >= 0 && id < MAX_THREAD_STORAGE ); + thread_storage_usage[id].used = TRUE; + thread_storage_usage[id].func = func; + +#ifdef TQTHREADSTORAGE_DEBUG + qDebug( "TQThreadStorageData: allocated id %d", id ); +#endif // TQTHREADSTORAGE_DEBUG + + pthread_mutex_unlock( &thread_storage_mutex ); +} + +TQThreadStorageData::~TQThreadStorageData() +{ + pthread_mutex_lock( &thread_storage_mutex ); + thread_storage_usage[id].used = FALSE; + thread_storage_usage[id].func = 0; + +#ifdef TQTHREADSTORAGE_DEBUG + qDebug( "TQThreadStorageData: released id %d", id ); +#endif // TQTHREADSTORAGE_DEBUG + + pthread_mutex_unlock( &thread_storage_mutex ); +} + +void **TQThreadStorageData::get() const +{ + TQThreadInstance *d = TQThreadInstance::current(); + if (!d) { + qWarning("TQThreadStorage can only be used with threads started with TQThread"); + return 0; + } + TQMutexLocker locker( d->mutex() ); + return d->thread_storage && d->thread_storage[id] ? &d->thread_storage[id] : 0; +} + +void **TQThreadStorageData::set( void *p ) +{ + TQThreadInstance *d = TQThreadInstance::current(); + if (!d) { + qWarning("TQThreadStorage can only be used with threads started with TQThread"); + return 0; + } + TQMutexLocker locker( d->mutex() ); + if ( !d->thread_storage ) { +#ifdef TQTHREADSTORAGE_DEBUG + qDebug( "TQThreadStorageData: allocating storage for thread %lx", + (unsigned long) pthread_self() ); +#endif // TQTHREADSTORAGE_DEBUG + + d->thread_storage = new void*[MAX_THREAD_STORAGE]; + memset( d->thread_storage, 0, sizeof( void* ) * MAX_THREAD_STORAGE ); + } + + // delete any previous data + if ( d->thread_storage[id] ) + thread_storage_usage[id].func( d->thread_storage[id] ); + + // store new data + d->thread_storage[id] = p; + return &d->thread_storage[id]; +} + +void TQThreadStorageData::finish( void **thread_storage ) +{ + if ( ! thread_storage ) return; // nothing to do + +#ifdef TQTHREADSTORAGE_DEBUG + qDebug( "TQThreadStorageData: destroying storage for thread %lx", + (unsigned long) pthread_self() ); +#endif // TQTHREADSTORAGE_DEBUG + + for ( int i = 0; i < MAX_THREAD_STORAGE; ++i ) { + if ( ! thread_storage[i] ) continue; + if ( ! thread_storage_usage[i].used ) { +#ifdef QT_CHECK_STATE + qWarning( "TQThreadStorage: thread %lx exited after TQThreadStorage destroyed", + (unsigned long) pthread_self() ); +#endif // QT_CHECK_STATE + continue; + } + + thread_storage_usage[i].func( thread_storage[i] ); + } + + delete [] thread_storage; +} + + +/*! + \class TQThreadStorage + \brief The TQThreadStorage class provides per-thread data storage. + + \threadsafe + \ingroup thread + \ingroup environment + + TQThreadStorage is a template class that provides per-thread data + storage. + + \e{Note that due to compiler limitations, TQThreadStorage can only + store pointers.} + + The setLocalData() function stores a single thread-specific value + for the calling thread. The data can be accessed later using the + localData() functions. TQThreadStorage takes ownership of the + data (which must be created on the heap with \e new) and deletes + it when the thread exits (either normally or via termination). + + The hasLocalData() function allows the programmer to determine if + data has previously been set using the setLocalData() function. + This is useful for lazy initializiation. + + For example, the following code uses TQThreadStorage to store a + single cache for each thread that calls the \e cacheObject() and + \e removeFromCache() functions. The cache is automatically + deleted when the calling thread exits (either normally or via + termination). + + \code + TQThreadStorage *> caches; + + void cacheObject( const TQString &key, SomeClass *object ) + { + if ( ! caches.hasLocalData() ) + caches.setLocalData( new TQCache ); + + caches.localData()->insert( key, object ); + } + + void removeFromCache( const TQString &key ) + { + if ( ! caches.hasLocalData() ) + return; // nothing to do + + caches.localData()->remove( key ); + } + \endcode + + \section1 Caveats + + \list + + \i As noted above, TQThreadStorage can only store pointers due to + compiler limitations. Support for value-based objects will be + added when the majority of compilers are able to support partial + template specialization. + + \i The \link ~TQThreadStorage() destructor\endlink does \e not + delete per-thread data. TQThreadStorage only deletes per-thread + data when the thread exits or when setLocalData() is called + multiple times. + + \i TQThreadStorage can only be used with threads started with + TQThread. It \e cannot be used with threads started with + platform-specific APIs. + + \i As a corollary to the above, platform-specific APIs cannot be + used to exit or terminate a TQThread using TQThreadStorage. Doing so + will cause all per-thread data to be leaked. See TQThread::exit() + and TQThread::terminate(). + + \i TQThreadStorage \e can be used to store data for the \e main() + thread \e after TQApplication has been constructed. TQThreadStorage + deletes all data set for the \e main() thread when TQApplication is + destroyed, regardless of whether or not the \e main() thread has + actually finished. + + \i The implementation of TQThreadStorage limits the total number of + TQThreadStorage objects to 256. An unlimited number of threads + can store per-thread data in each TQThreadStorage object. + + \endlist +*/ + +/*! + \fn TQThreadStorage::TQThreadStorage() + + Constructs a new per-thread data storage object. +*/ + +/*! + \fn TQThreadStorage::~TQThreadStorage() + + Destroys the per-thread data storage object. + + Note: The per-thread data stored is \e not deleted. Any data left + in TQThreadStorage is leaked. Make sure that all threads using + TQThreadStorage have exited before deleting the TQThreadStorage. + + \sa hasLocalData() +*/ + +/*! + \fn bool TQThreadStorage::hasLocalData() const + + Returns TRUE if the calling thread has non-zero data available; + otherwise returns FALSE. + + \sa localData() +*/ + +/*! + \fn T& TQThreadStorage::localData() + + Returns a reference to the data that was set by the calling + thread. + + Note: TQThreadStorage can only store pointers. This function + returns a \e reference to the pointer that was set by the calling + thread. The value of this reference is 0 if no data was set by + the calling thread, + + \sa hasLocalData() +*/ +/* + ### addition to the above documentation when we start supporting + ### partial template specialization, and TQThreadStorage can store + ### values *and* pointers + + When using TQThreadStorage to store values (not pointers), this + function stores an object of type \e T (created with its default + constructor) and returns a reference to that object. +*/ + +/*! + \fn const T TQThreadStorage::localData() const + \overload + + Returns a copy of the data that was set by the calling thread. + + Note: TQThreadStorage can only store pointers. This function + returns a pointer to the data that was set by the calling thread. + If no data was set by the calling thread, this function returns 0. + + \sa hasLocalData() +*/ +/* + ### addition to the above documentation when we start supporting + ### partial template specialization, and TQThreadStorage can store + ### values *and* pointers + + When using TQThreadStorage to store values (not pointers), this + function returns an object of type \e T (created with its default + constructor). Unlike the above function, this object is \e not + stored automatically. You will need to call setLocalData() to store + the object. +*/ + +/*! + \fn void TQThreadStorage::setLocalData( T data ) + + Sets the local data for the calling thread to \a data. It can be + accessed later using the localData() functions. + + If \a data is 0, this function deletes the previous data (if + any) and returns immediately. + + If \a data is non-zero, TQThreadStorage takes ownership of the \a + data and deletes it automatically either when the thread exits + (either normally or via termination) or when setLocalData() is + called again. + + Note: TQThreadStorage can only store pointers. The \a data + argument must be either a pointer to an object created on the heap + (i.e. using \e new) or 0. You should not delete \a data + yourself; TQThreadStorage takes ownership and will delete the \a + data itself. + + \sa localData() hasLocalData() +*/ + +#endif // QT_THREAD_SUPPORT diff --git a/src/tools/qtl.h b/src/tools/qtl.h new file mode 100644 index 000000000..62be077c5 --- /dev/null +++ b/src/tools/qtl.h @@ -0,0 +1,325 @@ +/**************************************************************************** +** +** Definition of TQt template library classes +** +** Created : 990128 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQTL_H +#define TQTL_H + +#ifndef QT_H +#include "qglobal.h" +#include "qtextstream.h" +#include "qstring.h" +#endif // QT_H + +#ifndef QT_NO_TEXTSTREAM +template +class TQTextOStreamIterator +{ +protected: + TQTextOStream& stream; + TQString separator; + +public: + TQTextOStreamIterator( TQTextOStream& s) : stream( s ) {} + TQTextOStreamIterator( TQTextOStream& s, const TQString& sep ) + : stream( s ), separator( sep ) {} + TQTextOStreamIterator& operator= ( const T& x ) { + stream << x; + if ( !separator.isEmpty() ) + stream << separator; + return *this; + } + TQTextOStreamIterator& operator*() { return *this; } + TQTextOStreamIterator& operator++() { return *this; } + TQTextOStreamIterator& operator++(int) { return *this; } +}; +#endif //QT_NO_TEXTSTREAM + +template +inline OutputIterator qCopy( InputIterator _begin, InputIterator _end, + OutputIterator _dest ) +{ + while( _begin != _end ) + *_dest++ = *_begin++; + return _dest; +} + +template +inline BiOutputIterator qCopyBackward( BiIterator _begin, BiIterator _end, + BiOutputIterator _dest ) +{ + while ( _begin != _end ) + *--_dest = *--_end; + return _dest; +} + +template +inline bool qEqual( InputIterator1 first1, InputIterator1 last1, InputIterator2 first2 ) +{ + // ### compare using !(*first1 == *first2) in TQt 4.0 + for ( ; first1 != last1; ++first1, ++first2 ) + if ( *first1 != *first2 ) + return FALSE; + return TRUE; +} + +template +inline void qFill( ForwardIterator first, ForwardIterator last, const T& val ) +{ + for ( ; first != last; ++first ) + *first = val; +} + +#if 0 +template +inline OutputIterator qReverseCopy( BiIterator _begin, BiIterator _end, + OutputIterator _dest ) +{ + while ( _begin != _end ) { + --_end; + *_dest = *_end; + ++_dest; + } + return _dest; +} +#endif + + +template +inline InputIterator qFind( InputIterator first, InputIterator last, + const T& val ) +{ + while ( first != last && *first != val ) + ++first; + return first; +} + +template +inline void qCount( InputIterator first, InputIterator last, const T& value, + Size& n ) +{ + for ( ; first != last; ++first ) + if ( *first == value ) + ++n; +} + +template +inline void qSwap( T& _value1, T& _value2 ) +{ + T tmp = _value1; + _value1 = _value2; + _value2 = tmp; +} + + +template +Q_INLINE_TEMPLATES void qBubbleSort( InputIterator b, InputIterator e ) +{ + // Goto last element; + InputIterator last = e; + --last; + // only one element or no elements ? + if ( last == b ) + return; + + // So we have at least two elements in here + while( b != last ) { + bool swapped = FALSE; + InputIterator swap_pos = b; + InputIterator x = e; + InputIterator y = x; + y--; + do { + --x; + --y; + if ( *x < *y ) { + swapped = TRUE; + qSwap( *x, *y ); + swap_pos = y; + } + } while( y != b ); + if ( !swapped ) + return; + b = swap_pos; + b++; + } +} + + +template +inline void qBubbleSort( Container &c ) +{ + qBubbleSort( c.begin(), c.end() ); +} + + +template +Q_INLINE_TEMPLATES void qHeapSortPushDown( Value* heap, int first, int last ) +{ + int r = first; + while ( r <= last / 2 ) { + if ( last == 2 * r ) { + // node r has only one child + if ( heap[2 * r] < heap[r] ) + qSwap( heap[r], heap[2 * r] ); + r = last; + } else { + // node r has two children + if ( heap[2 * r] < heap[r] && !(heap[2 * r + 1] < heap[2 * r]) ) { + // swap with left child + qSwap( heap[r], heap[2 * r] ); + r *= 2; + } else if ( heap[2 * r + 1] < heap[r] + && heap[2 * r + 1] < heap[2 * r] ) { + // swap with right child + qSwap( heap[r], heap[2 * r + 1] ); + r = 2 * r + 1; + } else { + r = last; + } + } + } +} + + +template +Q_INLINE_TEMPLATES void qHeapSortHelper( InputIterator b, InputIterator e, Value, uint n ) +{ + // Create the heap + InputIterator insert = b; + Value* realheap = new Value[n]; + // Wow, what a fake. But I want the heap to be indexed as 1...n + Value* heap = realheap - 1; + int size = 0; + for( ; insert != e; ++insert ) { + heap[++size] = *insert; + int i = size; + while( i > 1 && heap[i] < heap[i / 2] ) { + qSwap( heap[i], heap[i / 2] ); + i /= 2; + } + } + + // Now do the sorting + for( uint i = n; i > 0; i-- ) { + *b++ = heap[1]; + if ( i > 1 ) { + heap[1] = heap[i]; + qHeapSortPushDown( heap, 1, (int)i - 1 ); + } + } + + delete[] realheap; +} + + +template +Q_INLINE_TEMPLATES void qHeapSort( InputIterator b, InputIterator e ) +{ + // Empty ? + if ( b == e ) + return; + + // How many entries have to be sorted ? + InputIterator it = b; + uint n = 0; + while ( it != e ) { + ++n; + ++it; + } + + // The second last parameter is a hack to retrieve the value type + // Do the real sorting here + qHeapSortHelper( b, e, *b, n ); +} + + +template +Q_INLINE_TEMPLATES void qHeapSort( Container &c ) +{ + if ( c.begin() == c.end() ) + return; + + // The second last parameter is a hack to retrieve the value type + // Do the real sorting here + qHeapSortHelper( c.begin(), c.end(), *(c.begin()), (uint)c.count() ); +} + +template +class TQBackInsertIterator +{ +public: + Q_EXPLICIT TQBackInsertIterator( Container &c ) + : container( &c ) + { + } + + TQBackInsertIterator& + operator=( const Q_TYPENAME Container::value_type &value ) + { + container->push_back( value ); + return *this; + } + + TQBackInsertIterator& operator*() + { + return *this; + } + + TQBackInsertIterator& operator++() + { + return *this; + } + + TQBackInsertIterator& operator++(int) + { + return *this; + } + +protected: + Container *container; +}; + +template +inline TQBackInsertIterator qBackInserter( Container &c ) +{ + return TQBackInsertIterator( c ); +} + +#endif diff --git a/src/tools/qucom.cpp b/src/tools/qucom.cpp new file mode 100644 index 000000000..84c4162b7 --- /dev/null +++ b/src/tools/qucom.cpp @@ -0,0 +1,547 @@ +/**************************************************************************** +** +** Implementation of the TQUcom classes +** +** Created : 990101 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "qucom_p.h" + +// Standard types + +// {DE56510E-4E9F-4b76-A3C2-D1E2EF42F1AC} +const TQUuid TID_QUType_Null( 0xde56510e, 0x4e9f, 0x4b76, 0xa3, 0xc2, 0xd1, 0xe2, 0xef, 0x42, 0xf1, 0xac ); +const TQUuid *TQUType_Null::uuid() const { return &TID_QUType_Null; } +const char *TQUType_Null::desc() const { return "null"; } +bool TQUType_Null::canConvertFrom( TQUObject *, TQUType * ) { return FALSE; } +bool TQUType_Null::canConvertTo( TQUObject *, TQUType * ) { return FALSE; } +bool TQUType_Null::convertFrom( TQUObject *, TQUType * ) { return FALSE; } +bool TQUType_Null::convertTo( TQUObject *, TQUType * ) { return FALSE; } +void TQUType_Null::clear( TQUObject *) {} +int TQUType_Null::serializeTo( TQUObject *, TQUBuffer * ) { return 0; } +int TQUType_Null::serializeFrom( TQUObject *, TQUBuffer * ) { return 0; } +TQUType_Null static_QUType_Null; + + +// {7EE17B08-5419-47e2-9776-8EEA112DCAEC} +const TQUuid TID_QUType_enum( 0x7ee17b08, 0x5419, 0x47e2, 0x97, 0x76, 0x8e, 0xea, 0x11, 0x2d, 0xca, 0xec ); +TQUType_enum static_QUType_enum; +const TQUuid *TQUType_enum::uuid() const { return &TID_QUType_enum; } +const char *TQUType_enum::desc() const { return "enum"; } +void TQUType_enum::set( TQUObject *o, int v ) +{ + o->payload.i = v; + o->type = this; +} + +bool TQUType_enum::canConvertFrom( TQUObject *o, TQUType *t ) +{ + if ( isEqual( t, &static_QUType_int ) ) // ## todo unsigned int? + return TRUE; + + return t->canConvertTo( o, this ); +} + +bool TQUType_enum::canConvertTo( TQUObject * /*o*/, TQUType *t ) +{ + return isEqual( t, &static_QUType_int ); +} + +bool TQUType_enum::convertFrom( TQUObject *o, TQUType *t ) +{ + if ( isEqual( t, &static_QUType_int ) ) // ## todo unsigned int? + ; + else + return t->convertTo( o, this ); + + o->type = this; + return TRUE; +} + +bool TQUType_enum::convertTo( TQUObject *o, TQUType *t ) +{ + if ( isEqual( t, &static_QUType_int ) ) { + o->type = &static_QUType_int; + return TRUE; + } + return FALSE; +} + +int TQUType_enum::serializeTo( TQUObject *, TQUBuffer * ) +{ + return 0; +} + +int TQUType_enum::serializeFrom( TQUObject *, TQUBuffer * ) +{ + return 0; +} + +// {8AC26448-5AB4-49eb-968C-8F30AB13D732} +const TQUuid TID_QUType_ptr( 0x8ac26448, 0x5ab4, 0x49eb, 0x96, 0x8c, 0x8f, 0x30, 0xab, 0x13, 0xd7, 0x32 ); +TQUType_ptr static_QUType_ptr; +const TQUuid *TQUType_ptr::uuid() const { return &TID_QUType_ptr; } +const char *TQUType_ptr::desc() const { return "ptr"; } + +void TQUType_ptr::set( TQUObject *o, const void* v ) +{ + o->payload.ptr = (void*) v; + o->type = this; +} + +bool TQUType_ptr::canConvertFrom( TQUObject *o, TQUType *t ) +{ + return t->canConvertTo( o, this ); +} + +bool TQUType_ptr::canConvertTo( TQUObject *, TQUType * ) +{ + return FALSE; +} + +bool TQUType_ptr::convertFrom( TQUObject *o, TQUType *t ) +{ + return t->convertTo( o, this ); +} + +bool TQUType_ptr::convertTo( TQUObject *, TQUType * ) +{ + return FALSE; +} + +int TQUType_ptr::serializeTo( TQUObject *, TQUBuffer * ) +{ + return 0; +} + +int TQUType_ptr::serializeFrom( TQUObject *, TQUBuffer * ) +{ + return 0; +} + +// {97A2594D-6496-4402-A11E-55AEF2D4D25C} +const TQUuid TID_QUType_iface( 0x97a2594d, 0x6496, 0x4402, 0xa1, 0x1e, 0x55, 0xae, 0xf2, 0xd4, 0xd2, 0x5c ); +TQUType_iface static_QUType_iface; +const TQUuid *TQUType_iface::uuid() const { return &TID_QUType_iface; } +const char *TQUType_iface::desc() const { return "UnknownInterface"; } + +void TQUType_iface::set( TQUObject *o, TQUnknownInterface* iface ) +{ + o->payload.iface = iface; + o->type = this; +} + +bool TQUType_iface::canConvertFrom( TQUObject *o, TQUType *t ) +{ + return t->canConvertTo( o, this ); +} + +bool TQUType_iface::canConvertTo( TQUObject *, TQUType * ) +{ + return FALSE; +} + +bool TQUType_iface::convertFrom( TQUObject *o, TQUType *t ) +{ + return t->convertTo( o, this ); +} + +bool TQUType_iface::convertTo( TQUObject *, TQUType * ) +{ + return FALSE; +} + +int TQUType_iface::serializeTo( TQUObject *, TQUBuffer * ) +{ + return 0; +} + +int TQUType_iface::serializeFrom( TQUObject *, TQUBuffer * ) +{ + return 0; +} + +// {2F358164-E28F-4bf4-9FA9-4E0CDCABA50B} +const TQUuid TID_QUType_idisp( 0x2f358164, 0xe28f, 0x4bf4, 0x9f, 0xa9, 0x4e, 0xc, 0xdc, 0xab, 0xa5, 0xb ); +TQUType_idisp static_QUType_idisp; +const TQUuid *TQUType_idisp::uuid() const { return &TID_QUType_idisp; } +const char *TQUType_idisp::desc() const { return "DispatchInterface"; } + +void TQUType_idisp::set( TQUObject *o, TQDispatchInterface* idisp ) +{ + o->payload.idisp = idisp; + o->type = this; +} + +bool TQUType_idisp::canConvertFrom( TQUObject *o, TQUType *t ) +{ + return t->canConvertTo( o, this ); +} + +bool TQUType_idisp::canConvertTo( TQUObject * /*o*/, TQUType *t ) +{ + return isEqual( t, &static_QUType_iface ); +} + +bool TQUType_idisp::convertFrom( TQUObject *o, TQUType *t ) +{ + return t->convertTo( o, this ); +} + +bool TQUType_idisp::convertTo( TQUObject *o, TQUType *t ) +{ +#ifndef QT_NO_COMPONENT + if ( isEqual( t, &static_QUType_iface ) ) { + o->payload.iface = (TQUnknownInterface*)o->payload.idisp; + o->type = &static_QUType_iface; + return TRUE; + } +#endif + return FALSE; +} + +int TQUType_idisp::serializeTo( TQUObject *, TQUBuffer * ) +{ + return 0; +} + +int TQUType_idisp::serializeFrom( TQUObject *, TQUBuffer * ) +{ + return 0; +} + +// {CA42115D-13D0-456c-82B5-FC10187F313E} +const TQUuid TID_QUType_bool( 0xca42115d, 0x13d0, 0x456c, 0x82, 0xb5, 0xfc, 0x10, 0x18, 0x7f, 0x31, 0x3e ); +TQUType_bool static_QUType_bool; +const TQUuid *TQUType_bool::uuid() const { return &TID_QUType_bool; } +const char *TQUType_bool::desc() const { return "bool"; } + +void TQUType_bool::set( TQUObject *o, bool v ) +{ + o->payload.b = v; + o->type = this; +} + +bool TQUType_bool::canConvertFrom( TQUObject *o, TQUType *t ) +{ + return t->canConvertTo( o, this ); +} + +bool TQUType_bool::canConvertTo( TQUObject *, TQUType * ) +{ + return FALSE; +} + +bool TQUType_bool::convertFrom( TQUObject *o, TQUType *t ) +{ + return t->convertTo( o, this ); +} + +bool TQUType_bool::convertTo( TQUObject *, TQUType * ) +{ + return FALSE; +} + +int TQUType_bool::serializeTo( TQUObject *, TQUBuffer * ) +{ + return 0; +} + +int TQUType_bool::serializeFrom( TQUObject *, TQUBuffer * ) +{ + return 0; +} + +// {53C1F3BE-73C3-4c7d-9E05-CCF09EB676B5} +const TQUuid TID_QUType_int( 0x53c1f3be, 0x73c3, 0x4c7d, 0x9e, 0x5, 0xcc, 0xf0, 0x9e, 0xb6, 0x76, 0xb5 ); +TQUType_int static_QUType_int; +const TQUuid *TQUType_int::uuid() const { return &TID_QUType_int; } +const char *TQUType_int::desc() const { return "int"; } + +void TQUType_int::set( TQUObject *o, int v ) +{ + o->payload.i = v; + o->type = this; +} + +bool TQUType_int::canConvertFrom( TQUObject *o, TQUType *t ) +{ + if ( isEqual( t, &static_QUType_double ) ) + return TRUE; + + return t->canConvertTo( o, this ); +} + +bool TQUType_int::canConvertTo( TQUObject * /*o*/, TQUType *t ) +{ + return isEqual( t, &static_QUType_double ); +} + +bool TQUType_int::convertFrom( TQUObject *o, TQUType *t ) +{ + if ( isEqual( t, &static_QUType_double ) ) + o->payload.i = (long)o->payload.d; + else + return t->convertTo( o, this ); + + o->type = this; + return TRUE; +} + +bool TQUType_int::convertTo( TQUObject *o, TQUType *t ) +{ + if ( isEqual( t, &static_QUType_double ) ) { + o->payload.d = (double)o->payload.i; + o->type = &static_QUType_double; + } else + return FALSE; + return TRUE; +} + +int TQUType_int::serializeTo( TQUObject *, TQUBuffer * ) +{ + return 0; +} + +int TQUType_int::serializeFrom( TQUObject *, TQUBuffer * ) +{ + return 0; +} + +// {2D0974E5-0BA6-4ec2-8837-C198972CB48C} +const TQUuid TID_QUType_double( 0x2d0974e5, 0xba6, 0x4ec2, 0x88, 0x37, 0xc1, 0x98, 0x97, 0x2c, 0xb4, 0x8c ); +TQUType_double static_QUType_double; +const TQUuid *TQUType_double::uuid() const { return &TID_QUType_double; } +const char *TQUType_double::desc() const {return "double"; } + +void TQUType_double::set( TQUObject *o, double v ) +{ + o->payload.d = v; + o->type = this; +} + +bool TQUType_double::canConvertFrom( TQUObject *o, TQUType *t ) +{ + if ( isEqual( t, &static_QUType_int ) ) + return TRUE; + + return t->canConvertTo( o, this ); +} + +bool TQUType_double::canConvertTo( TQUObject * /*o*/, TQUType *t ) +{ + return isEqual( t, &static_QUType_int ); +} + +bool TQUType_double::convertFrom( TQUObject *o, TQUType *t ) +{ + if ( isEqual( t, &static_QUType_int ) ) + o->payload.d = (double)o->payload.i; + else + return t->convertTo( o, this ); + + o->type = this; + return TRUE; +} + +bool TQUType_double::convertTo( TQUObject *o, TQUType *t ) +{ + if ( isEqual( t, &static_QUType_int ) ) { + o->payload.i = (int) o->payload.d; + o->type = &static_QUType_int; + } else if ( isEqual( t, &static_QUType_double ) ) { + o->payload.d = (double) o->payload.f; + o->type = &static_QUType_double; + } else + return FALSE; + return TRUE; +} + +int TQUType_double::serializeTo( TQUObject *, TQUBuffer * ) +{ + return 0; +} + +int TQUType_double::serializeFrom( TQUObject *, TQUBuffer * ) +{ + return 0; +} + +// {EFCDD1D4-77A3-4b8e-8D46-DC14B8D393E9} +const TQUuid TID_QUType_charstar( 0xefcdd1d4, 0x77a3, 0x4b8e, 0x8d, 0x46, 0xdc, 0x14, 0xb8, 0xd3, 0x93, 0xe9 ); +TQUType_charstar static_QUType_charstar; +const TQUuid *TQUType_charstar::uuid() const { return &TID_QUType_charstar; } +const char *TQUType_charstar::desc() const { return "char*"; } + +void TQUType_charstar::set( TQUObject *o, const char* v, bool take ) +{ + if ( take ) { + if ( v ) { + o->payload.charstar.ptr = new char[ strlen(v) + 1 ]; + strcpy( o->payload.charstar.ptr, v ); + } else { + o->payload.charstar.ptr = 0; + } + o->payload.charstar.owner = TRUE; + } else { + o->payload.charstar.ptr = (char*) v; + o->payload.charstar.owner = FALSE; + } + o->type = this; +} + +bool TQUType_charstar::canConvertFrom( TQUObject *o, TQUType *t ) +{ + return t->canConvertTo( o, this ); +} + +bool TQUType_charstar::canConvertTo( TQUObject *, TQUType * ) +{ + return FALSE; +} + +bool TQUType_charstar::convertFrom( TQUObject *o, TQUType *t ) +{ + return t->convertTo( o, this ); +} + +bool TQUType_charstar::convertTo( TQUObject *, TQUType * ) +{ + return FALSE; +} + +void TQUType_charstar::clear( TQUObject *o ) +{ + if ( o->payload.charstar.owner ) + delete [] o->payload.charstar.ptr; + o->payload.charstar.ptr = 0; +} + +int TQUType_charstar::serializeTo( TQUObject *, TQUBuffer * ) +{ + return 0; +} + +int TQUType_charstar::serializeFrom( TQUObject *, TQUBuffer * ) +{ + return 0; +} + + +// TQt specific types + +// {44C2A547-01E7-4e56-8559-35AF9D2F42B7} +const TQUuid TID_QUType_TQString( 0x44c2a547, 0x1e7, 0x4e56, 0x85, 0x59, 0x35, 0xaf, 0x9d, 0x2f, 0x42, 0xb7 ); +TQUType_TQString static_QUType_TQString; +const TQUuid *TQUType_TQString::uuid() const { return &TID_QUType_TQString; } +const char *TQUType_TQString::desc() const { return "TQString"; } + +void TQUType_TQString::set( TQUObject *o, const TQString& v ) +{ + o->payload.ptr = new TQString( v ); + o->type = this; +} + +bool TQUType_TQString::canConvertFrom( TQUObject *o, TQUType *t ) +{ + if ( isEqual( t, &static_QUType_charstar ) || + isEqual( t, &static_QUType_double ) || + isEqual( t, &static_QUType_int ) ) + return TRUE; + + return t->canConvertTo( o, this ); +} + +bool TQUType_TQString::canConvertTo( TQUObject * /*o*/, TQUType *t ) +{ + return isEqual( t, &static_QUType_charstar ) || + isEqual( t, &static_QUType_int ) || + isEqual( t, &static_QUType_double ); +} + +bool TQUType_TQString::convertFrom( TQUObject *o, TQUType *t ) +{ + TQString *str = 0; + if ( isEqual( t, &static_QUType_charstar ) ) + str = new TQString( o->payload.charstar.ptr ); + else if ( isEqual( t, &static_QUType_double ) ) + str = new TQString( TQString::number( o->payload.d ) ); + else if ( isEqual( t, &static_QUType_int ) ) + str = new TQString( TQString::number( o->payload.i ) ); + else + return t->convertTo( o, this ); + + o->type->clear( o ); + o->payload.ptr = str; + o->type = this; + return TRUE; +} + +bool TQUType_TQString::convertTo( TQUObject *o, TQUType *t ) +{ + TQString *str = (TQString *)o->payload.ptr; + if ( isEqual( t, &static_QUType_charstar ) ) { + o->payload.charstar.ptr = qstrdup( str->local8Bit().data() ); + o->payload.charstar.owner = TRUE; + o->type = &static_QUType_charstar; + } else if ( isEqual( t, &static_QUType_int ) ) { + o->payload.l = str->toLong(); + o->type = &static_QUType_int; + } else if ( isEqual( t, &static_QUType_double ) ) { + o->payload.d = str->toDouble(); + o->type = &static_QUType_double; + } else { + return FALSE; + } + delete str; + return TRUE; +} + +int TQUType_TQString::serializeTo( TQUObject *, TQUBuffer * ) +{ + return 0; +} + +int TQUType_TQString::serializeFrom( TQUObject *, TQUBuffer * ) +{ + return 0; +} + +void TQUType_TQString::clear( TQUObject *o ) +{ + delete (TQString*)o->payload.ptr; + o->payload.ptr = 0; +} diff --git a/src/tools/qucom_p.h b/src/tools/qucom_p.h new file mode 100644 index 000000000..e67e00a0d --- /dev/null +++ b/src/tools/qucom_p.h @@ -0,0 +1,470 @@ +/**************************************************************************** +** +** Definition of the TQUcom interfaces +** +** Created : 990101 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQUCOM_P_H +#define TQUCOM_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the TQt API. It exists for the convenience +// of a number of TQt sources files. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// +// + +#ifndef QT_H +#include "qstring.h" +#include "quuid.h" +#endif // QT_H + +#ifdef check +#undef check +#endif + +#if __GNUC__ - 0 > 3 +#pragma GCC system_header +#endif + +struct TQUObject; +struct TQUInterfaceDescription; +struct TQUnknownInterface; +struct TQDispatchInterface; + + +struct Q_EXPORT TQUBuffer +{ + virtual long read( char *data, ulong maxlen ) = 0; + virtual long write( const char *data, ulong len ) = 0; +}; + + +// A type for a TQUObject +struct Q_EXPORT TQUType +{ + virtual const TQUuid *uuid() const = 0; + virtual const char *desc() const = 0; + + + virtual bool canConvertFrom( TQUObject *, TQUType * ) = 0; + // virtual private, only called by canConvertFrom + virtual bool canConvertTo( TQUObject *, TQUType * ) = 0; + + + virtual bool convertFrom( TQUObject *, TQUType * ) = 0; + // virtual private, only called by convertFrom + virtual bool convertTo( TQUObject *, TQUType * ) = 0; + + virtual void clear( TQUObject * ) = 0; + + virtual int serializeTo( TQUObject *, TQUBuffer * ) = 0; + virtual int serializeFrom( TQUObject *, TQUBuffer * ) = 0; + + static bool isEqual( const TQUType *t1, const TQUType *t2 ); + static bool check( TQUObject* o, TQUType* t ); +}; + + +// {DE56510E-4E9F-4b76-A3C2-D1E2EF42F1AC} +extern Q_EXPORT const TQUuid TID_QUType_Null; +struct Q_EXPORT TQUType_Null : public TQUType +{ + const TQUuid *uuid() const; + const char *desc() const; + + bool canConvertFrom( TQUObject *, TQUType * ); + bool canConvertTo( TQUObject *, TQUType * ); + bool convertFrom( TQUObject *, TQUType * ); + bool convertTo( TQUObject *, TQUType * ); + void clear( TQUObject * ); + int serializeTo( TQUObject *, TQUBuffer * ); + int serializeFrom( TQUObject *, TQUBuffer * ); +}; +extern Q_EXPORT TQUType_Null static_QUType_Null; + + +// The magic TQUObject +struct Q_EXPORT TQUObject +{ +public: // scary MSVC bug makes this necessary + TQUObject() : type( &static_QUType_Null ) {} + ~TQUObject() { type->clear( this ); } + + TQUType *type; + + // the unavoidable union + union + { + bool b; + + char c; + short s; + int i; + long l; + + unsigned char uc; + unsigned short us; + unsigned int ui; + unsigned long ul; + + float f; + double d; + + char byte[16]; + + struct { + char* data; + unsigned long size; + } bytearray; + + void* ptr; + + struct { + void *ptr; + bool owner; + } voidstar; + + struct { + char *ptr; + bool owner; + } charstar; + + struct { + char *ptr; + bool owner; + } utf8; + + struct { + char *ptr; + bool owner; + } local8bit; + + TQUnknownInterface* iface; + TQDispatchInterface* idisp; + + } payload; + +}; + + +// A parameter description describes one method parameters. A +// parameter has a name, a type and a flag describing whether it's an +// in parameter, an out parameter, or both ways +struct Q_EXPORT TQUParameter +{ + const char* name; + TQUType *type; + const void* typeExtra; //Usually 0, UEnum* for TQUType_enum, const char* for TQUType_ptr, int* for TQUType_varptr + enum { In = 1, Out = 2, InOut = In | Out }; + int inOut; +}; + +// A method description describes one method. A method has a name and +// an array of parameters. +struct Q_EXPORT TQUMethod +{ + const char* name; + int count; + const TQUParameter* parameters; +}; + +// A Property description. Not used yet in the example. +struct Q_EXPORT TQUProperty +{ + const char* name; + TQUType* type; + const void* typeExtra; //type dependend. Usually 0, but UEnum for TQUTypeenum or const char* for TQUTypeptr + + int set; // -1 undefined + int get; // -1 undefined + + int designable; // -1 FALSE, -2 TRUE, else method + int stored; // -1 FALSE, -2 TRUE, else method +}; + +// An interface description describes one interface, that is all its +// methods and properties. +struct Q_EXPORT TQUInterfaceDescription +{ + int methodCount; + const TQUMethod* methods; + int propertyCount; + const TQUProperty* properties; +}; + + +// A component description describe one component, that is its name, +// vendor, release, info, its component uuid and all its interface +// uuids. +struct Q_EXPORT TQUComponentDescription +{ + const char* name; + const char* vendor; + const char* release; + const char* info; + TQUuid cid; + int count; + const TQUuid* interfaces; +}; + + +// A component server description describe one component server, that +// is its name, vendor, release, info and the descriptions of all +// components it can instantiate. +struct Q_EXPORT TQUComponentServerDescription +{ + const char* name; + const char* vendor; + const char* release; + const char* info; + int count; + const TQUComponentDescription* components; +}; + + + +struct Q_EXPORT TQUEnumItem // - a name/value pair +{ + const char *key; + int value; +}; + +struct Q_EXPORT TQUEnum +{ + const char *name; // - enumerator name + unsigned int count; // - number of values + const TQUEnumItem *items; // - the name/value pairs + bool set; // whether enum has to be treated as a set +}; + +inline bool TQUType::isEqual( const TQUType *t1, const TQUType *t2 ) { + return t1 == t2 || t1->uuid() == t2->uuid() || + *(t1->uuid()) == *(t2->uuid()); +} + +inline bool TQUType::check( TQUObject* o, TQUType* t ) { + return isEqual( o->type, t ) || t->convertFrom( o, o->type ); +} + + + +// {7EE17B08-5419-47e2-9776-8EEA112DCAEC} +extern Q_EXPORT const TQUuid TID_QUType_enum; +struct Q_EXPORT TQUType_enum : public TQUType +{ + const TQUuid *uuid() const; + const char *desc() const; + + void set( TQUObject *, int ); + int &get( TQUObject * o ) { return o->payload.i; } + bool canConvertFrom( TQUObject *, TQUType * ); + bool canConvertTo( TQUObject *, TQUType * ); + bool convertFrom( TQUObject *, TQUType * ); + bool convertTo( TQUObject *, TQUType * ); + void clear( TQUObject * ) {} + int serializeTo( TQUObject *, TQUBuffer * ); + int serializeFrom( TQUObject *, TQUBuffer * ); +}; +extern Q_EXPORT TQUType_enum static_QUType_enum; + + +// {8AC26448-5AB4-49eb-968C-8F30AB13D732} +extern Q_EXPORT const TQUuid TID_QUType_ptr; +struct Q_EXPORT TQUType_ptr : public TQUType +{ + const TQUuid *uuid() const; + const char *desc() const; + + void set( TQUObject *, const void* ); + void* &get( TQUObject * o ) { return o->payload.ptr; } + bool canConvertFrom( TQUObject *, TQUType * ); + bool canConvertTo( TQUObject *, TQUType * ); + bool convertFrom( TQUObject *, TQUType * ); + bool convertTo( TQUObject *, TQUType * ); + void clear( TQUObject * ) {} + int serializeTo( TQUObject *, TQUBuffer * ); + int serializeFrom( TQUObject *, TQUBuffer * ); +}; +extern Q_EXPORT TQUType_ptr static_QUType_ptr; + +// {97A2594D-6496-4402-A11E-55AEF2D4D25C} +extern Q_EXPORT const TQUuid TID_QUType_iface; +struct Q_EXPORT TQUType_iface : public TQUType +{ + const TQUuid *uuid() const; + const char *desc() const; + + void set( TQUObject *, TQUnknownInterface* ); + TQUnknownInterface* &get( TQUObject *o ){ return o->payload.iface; } + bool canConvertFrom( TQUObject *, TQUType * ); + bool canConvertTo( TQUObject *, TQUType * ); + bool convertFrom( TQUObject *, TQUType * ); + bool convertTo( TQUObject *, TQUType * ); + void clear( TQUObject * ) {} + int serializeTo( TQUObject *, TQUBuffer * ); + int serializeFrom( TQUObject *, TQUBuffer * ); +}; +extern Q_EXPORT TQUType_iface static_QUType_iface; + +// {2F358164-E28F-4bf4-9FA9-4E0CDCABA50B} +extern Q_EXPORT const TQUuid TID_QUType_idisp; +struct Q_EXPORT TQUType_idisp : public TQUType +{ + const TQUuid *uuid() const; + const char *desc() const; + + void set( TQUObject *, TQDispatchInterface* ); + TQDispatchInterface* &get( TQUObject *o ){ return o->payload.idisp; } + bool canConvertFrom( TQUObject *, TQUType * ); + bool canConvertTo( TQUObject *, TQUType * ); + bool convertFrom( TQUObject *, TQUType * ); + bool convertTo( TQUObject *, TQUType * ); + void clear( TQUObject * ) {} + int serializeTo( TQUObject *, TQUBuffer * ); + int serializeFrom( TQUObject *, TQUBuffer * ); +}; +extern Q_EXPORT TQUType_idisp static_QUType_idisp; + +// {CA42115D-13D0-456c-82B5-FC10187F313E} +extern Q_EXPORT const TQUuid TID_QUType_bool; +struct Q_EXPORT TQUType_bool : public TQUType +{ + const TQUuid *uuid() const; + const char *desc() const; + + void set( TQUObject *, bool ); + bool &get( TQUObject *o ) { return o->payload.b; } + bool canConvertFrom( TQUObject *, TQUType * ); + bool canConvertTo( TQUObject *, TQUType * ); + bool convertFrom( TQUObject *, TQUType * ); + bool convertTo( TQUObject *, TQUType * ); + void clear( TQUObject * ) {} + int serializeTo( TQUObject *, TQUBuffer * ); + int serializeFrom( TQUObject *, TQUBuffer * ); +}; +extern Q_EXPORT TQUType_bool static_QUType_bool; + +// {53C1F3BE-73C3-4c7d-9E05-CCF09EB676B5} +extern Q_EXPORT const TQUuid TID_QUType_int; +struct Q_EXPORT TQUType_int : public TQUType +{ + const TQUuid *uuid() const; + const char *desc() const; + + void set( TQUObject *, int ); + int &get( TQUObject *o ) { return o->payload.i; } + bool canConvertFrom( TQUObject *, TQUType * ); + bool canConvertTo( TQUObject *, TQUType * ); + bool convertFrom( TQUObject *, TQUType * ); + bool convertTo( TQUObject *, TQUType * ); + void clear( TQUObject * ) {} + int serializeTo( TQUObject *, TQUBuffer * ); + int serializeFrom( TQUObject *, TQUBuffer * ); +}; +extern Q_EXPORT TQUType_int static_QUType_int; + + +// {2D0974E5-0BA6-4ec2-8837-C198972CB48C} +extern Q_EXPORT const TQUuid TID_QUType_double; +struct Q_EXPORT TQUType_double : public TQUType +{ + const TQUuid *uuid() const; + const char *desc() const; + + void set( TQUObject *, double ); + double &get( TQUObject *o ) { return o->payload.d; } + bool canConvertFrom( TQUObject *, TQUType * ); + bool canConvertTo( TQUObject *, TQUType * ); + bool convertFrom( TQUObject *, TQUType * ); + bool convertTo( TQUObject *, TQUType * ); + void clear( TQUObject * ) {} + int serializeTo( TQUObject *, TQUBuffer * ); + int serializeFrom( TQUObject *, TQUBuffer * ); +}; +extern Q_EXPORT TQUType_double static_QUType_double; + + +// {EFCDD1D4-77A3-4b8e-8D46-DC14B8D393E9} +extern Q_EXPORT const TQUuid TID_QUType_charstar; +struct Q_EXPORT TQUType_charstar : public TQUType +{ + const TQUuid *uuid() const; + const char *desc() const; + + void set( TQUObject *, const char*, bool take = FALSE ); + char* get( TQUObject *o ){ return o->payload.charstar.ptr; } + bool canConvertFrom( TQUObject *, TQUType * ); + bool canConvertTo( TQUObject *, TQUType * ); + bool convertFrom( TQUObject *, TQUType * ); + bool convertTo( TQUObject *, TQUType * ); + void clear( TQUObject * ); + int serializeTo( TQUObject *, TQUBuffer * ); + int serializeFrom( TQUObject *, TQUBuffer * ); + +}; +extern Q_EXPORT TQUType_charstar static_QUType_charstar; + +// {44C2A547-01E7-4e56-8559-35AF9D2F42B7} +extern const TQUuid TID_QUType_TQString; + +struct Q_EXPORT TQUType_TQString : public TQUType +{ + const TQUuid *uuid() const; + const char *desc() const; + + void set( TQUObject *, const TQString & ); + TQString &get( TQUObject * o ) { return *(TQString*)o->payload.ptr; } + + bool canConvertFrom( TQUObject *, TQUType * ); + bool canConvertTo( TQUObject *, TQUType * ); + bool convertFrom( TQUObject *, TQUType * ); + bool convertTo( TQUObject *, TQUType * ); + void clear( TQUObject * ); + int serializeTo( TQUObject *, TQUBuffer * ); + int serializeFrom( TQUObject *, TQUBuffer * ); + +}; +extern Q_EXPORT TQUType_TQString static_QUType_TQString; + + +#endif // TQUCOM_P_H diff --git a/src/tools/qunicodetables.cpp b/src/tools/qunicodetables.cpp new file mode 100644 index 000000000..36cf4d09d --- /dev/null +++ b/src/tools/qunicodetables.cpp @@ -0,0 +1,13240 @@ +/**************************************************************************** +** +** ??? +** +** Copyright (C) 2002-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the kernel module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "qunicodetables_p.h" + +/* ------------------------------------------------------------------------- + * unicode information + * these tables are generated from the unicode reference file + * ftp://ftp.unicode.org/Public/3.2-Update/UnicodeData.txt + * + * Lars + * ------------------------------------------------------------------------- + */ + +/* Perl script to generate (run perl -x tools/qstringdata.cpp) + +#!perl + +sub numberize +{ + my(%r, $n, $id); + for $id ( @_ ) { + $i = $id; + $i="" if $i eq "EMPTY"; + $r{$i}=$n++; + } + return %r; +} + + +sub readUnicodeDataLine { + $code = shift @_; + for $n (qw{ + name category combining_class bidi_category + character_decomposition decimal_digit_value digit_value + numeric_value mirrored oldname comment + uppercase lowercase titlecase}) + { + $id = shift @_; + $codes = "${n}_code"; + if ( defined %$codes && defined $$codes{$id} ) { + $id = $$codes{$id}; + } + ${$n}{$code}=$id; + } + $decomp = $character_decomposition{$code}; + if ( length $decomp == 0 ) { + $decomp = ""; + } + if (substr($decomp, 0, 1) ne '<') { + $decomp = " " . $decomp; + } + @_ = split(" ", $decomp); + $tag = shift @_; + $tag = $character_decomposition_tag{$tag}; + $decomp = join( ", 0x", @_ ); + $decomp = "0x".$decomp; + $decomposition{$code} = $decomp; + $decomposition_tag{$code} = $tag; + $decomposition_pos{$code} = $position; + $len = scalar(@_); + $decomposition_len{$code} = $len; + +# we use canonical decompositions longer than 1 char +# we exlude Arabic ligatures from the table + if($len > 1 and $tag == 1) { +# ligature to add... + $start = shift @_; + $ligature{$start} = $ligature{$start}." ".$code; + } + +# adjust position + if($len != 0) { + $position += $len + 3; + } +} + + +# Code to integer mappings... +# +%category_code = numberize(qw{ + EMPTY + Mn Mc Me + Nd Nl No + Zs Zl Zp + Cc Cf Cs Co Cn + + Lu Ll Lt Lm Lo + Pc Pd Ps Pe Pi Pf Po + Sm Sc Sk So +}); +%bidi_category_code = numberize(qw{ + L R EN ES ET AN CS B S WS ON LRE LRO AL RLE RLO PDF NSM BN}); +%character_decomposition_tag = numberize(qw{ + + + +}); +%mirrored_code = numberize(qw{N Y}); + +%joining_code = numberize(qw{U D R C}); + +# we map AI and XX to AL for now, as we can't handle them any better +%line_break_code = numberize(qw{OP CL QU GL NS EX SY + IS PR PO NU AL ID IN HY + BA BB B2 + ZW CM + SA + BK CR LF SG CB SP +}); + +# Read data into hashes... +# +open IN, "UnicodeData.txt"; +$position = 1; +while () { + @fields = split /;/; + if ( length($fields[0]) < 5 ) { + if ( $fields[1] =~ /, First>/ ) { + $codeRangeBegin = $fields[0]; + } elsif ( $fields[1] =~ /, Last>/ ) { + for ( $i=hex($codeRangeBegin); $i<=hex($fields[0]); $i+=1 ) { + @fields2 = @fields; + $fields2[0] = sprintf "%lX", $i; + readUnicodeDataLine @fields2; + } + } else { + readUnicodeDataLine @fields; + } + } +} + +open IN2, "ArabicShaping.txt"; +$position = 1; +while () { + @fields = split /;/; + $code = shift @fields; + $dummy = shift @fields; + $join = shift @fields; + $join =~ s/ //g; + $join = $joining_code{$join}; + $joining{$code}=$join; +} + +open IN3, "LineBreak.txt"; +$position = 1; +while () { + @fields = split /;/; + $code = shift @fields; + $break = shift @fields; + if (length($break) > 0) { + chomp $break; + $break =~ s/ .*$//; + + $from = $code; + $to = $code; + if ( length($code) > 5 ) { + $from =~ s,\.\..*,,; + $to =~ s/......//; +# print "$from..$to = $break\n"; + } + if($break eq "AI") { + $break = "AL"; + } + if($break eq "XX") { + $break = "AL"; + } + for ( $i=hex($from); $i<=hex($to); $i+=1 ) { + $breaks{sprintf("%04X",$i)}=$line_break_code{$break}; + } + } +} + +# Build pages... +# +$rowtable_txt = ""; +$row_txt = ""; +$pos = 1; +for $row ( 0..255 ) { + $nonzero=0; + $txt = ""; + for $cell ( 0..255 ) { + $code = sprintf("%02X%02X",$row,$cell); + $info = $category{$code}; + $info = 0 if !defined $info; + $txt .= "\n " if $cell%8 == 0; + $txt .= "$info, "; + } + $therow = $row{$txt}; + if ( !defined $therow ) { + $therow = sprintf("%d",$pos); + $row_txt = $row_txt."$txt\n"; + $row{$txt}=$therow; + $pos += 1; + $size += 256; + } + $rowtable_txt .= "\n " if $row%8 == 0; + $rowtable_txt .= "$therow, "; +} + +print "// START OF GENERATED DATA\n\n"; +print "#ifndef QT_NO_UNICODETABLES\n\n"; + +# Print pages... +# + +print "const Q_UINT8 TQUnicodeTables::unicode_info[] = {"; +print $rowtable_txt; +$size += 256; +print "\n\n"; +print $row_txt; +print "};\n\n"; +print "// $size bytes\n\n"; + +# Build decomposition tables +# +$rowtable_txt = ""; +$row_txt = ""; +$table_txt = + "const Q_UINT16 TQUnicodeTables::decomposition_map[] = {\n 0,\n"; +$pos = 1; +for $row ( 0..255 ) { + $nonzero=0; + $txt = ""; + for $cell ( 0..255 ) { + $code = sprintf("%02X%02X",$row,$cell); + $txt .= "\n " if $cell%8 == 0; + if( $decomposition_tag{$code} != 0 ) { + $txt .= " $decomposition_pos{$code},"; + $table_txt .= " $decomposition_tag{$code},"; + $table_txt .= " 0x$code,"; + $table_txt .= " $decomposition{$code}, 0,\n"; + $size += 2 * $decomposition_len{$code} + 6; + } else { + $txt .= " 0,"; + } + } + $therow = $row{$txt}; + if ( !defined $therow ) { + $therow = sprintf("%d",$pos); + $row_txt = $row_txt."$txt\n"; + $row{$txt}=$therow; + $pos += 1; + $size += 512; + } + $rowtable_txt .= "\n " if $row%8 == 0; + $rowtable_txt .= "$therow, "; +} + +# Print decomposition tables +# +print "$table_txt\n};\n\n"; + +print "const Q_UINT16 TQUnicodeTables::decomposition_info[] = {"; +print "$rowtable_txt\n"; +$size += 512; +print $row_txt; +print "};\n\n"; +print "// $size bytes\n\n"; + + +# build ligature tables +# +$size = 0; +$position = 1; +$pos = 1; +$rowtable_txt = ""; +$row_txt = ""; +$table_txt = + "const Q_UINT16 TQUnicodeTables::ligature_map[] = {\n 0,\n"; +for $lig_row ( 0..255 ) { + $nonzero=0; + $txt = ""; + for $cell ( 0..255 ) { + $code = sprintf("%02X%02X",$lig_row,$cell); + $txt .= "\n " if $cell%8 == 0; + if( defined $ligature{$code} ) { + $txt .= " $position,"; + @ligature = split(" ", $ligature{$code}); +# we need to sort ligatures according to their length. +# long ones have to come first! + @ligature_sort = sort { $decomposition_len{$b} <=> $decomposition_len{$a} } @ligature; +# now replace each code by its position in +# the decomposition map. + undef(@lig_pos); + for $n (@ligature_sort) { + push(@lig_pos, $decomposition_pos{$n}); + } +# debug info + if( 0 ) { + print "ligatures: $ligature{$code}\n"; + $sort = join(" ", @ligature_sort); + print "sorted : $sort\n"; + } + $lig = join(", ", @lig_pos); + $table_txt .= " $lig, 0,\n"; + $size += 2 * scalar(@ligature) + 2; + $position += scalar(@ligature) + 1; + } else { + $txt .= " 0,"; + } + } + $therow = $lig_row{$txt}; + if ( !defined $therow ) { + $therow = sprintf("%d",$pos); + $row_txt = $row_txt."$txt\n"; + $lig_row{$txt}=$therow; + $pos += 1; + $size += 512; + } + $rowtable_txt .= "\n " if $lig_row%8 == 0; + $rowtable_txt .= "$therow, "; +} + +# Print ligature tables +# +print "$table_txt\n};\n\n"; +print "const Q_UINT16 TQUnicodeTables::ligature_info[] = {"; +print "$rowtable_txt\n\n"; +$size+=512; +print $row_txt; +print "};\n\n"; +print "// $size bytes\n\n"; + + + +# Build direction/joining/mirrored pages... +# +$rowtable_txt = ""; +$row_txt = ""; +$pos = 1; +for $dir_row ( 0..255 ) { + $txt = ""; + for $cell ( 0..255 ) { + $code = sprintf("%02X%02X",$dir_row,$cell); + $dir = $bidi_category{$code}; + $dir = 0 if !defined $dir; + $join = $joining{$code}; + $join = 0 if !defined $join; + $mirr = $mirrored{$code}; + $mirr = 0 if !defined $mirr; + $info = $dir + 32*$join + 128*$mirr; + $txt .= "\n " if $cell%8 == 0; + $txt .= "$info, "; + } + $therow = $dir_row{$txt}; + if ( !defined $therow ) { + $therow = sprintf("%d",$pos); + $row_txt = $row_txt."$txt\n"; + $dir_row{$txt}=$therow; + $pos += 1; + $size+=256; + } + $rowtable_txt .= "\n " if $dir_row%8 == 0; + $rowtable_txt .= "$therow, "; +} + +# Print pages... +# +print "const Q_UINT8 TQUnicodeTables::direction_info[] = {"; +print "$rowtable_txt\n\n"; +$size+=256; +print $row_txt; +print "};\n\n"; +print "// $size bytes\n\n"; + +# Build table of combining classes +# +$rowtable_txt = ""; +$row_txt = ""; +$pos = 1; +for $combining_row ( 0..255 ) { + $txt = ""; + for $cell ( 0..255 ) { + $code = sprintf("%02X%02X",$combining_row,$cell); + $info = $combining_class{$code}; + $info = 0 if !defined $info; + $txt .= "\n " if $cell%8 == 0; + $txt .= "$info, "; + } + $therow = $combining_row{$txt}; + if ( !defined $therow ) { + $therow = sprintf("%d",$pos); + $row_txt = $row_txt."$txt\n"; + $combining_row{$txt}=$therow; + $pos += 1; + $size += 256; + } + $rowtable_txt .= "\n " if $combining_row%8 == 0; + $rowtable_txt .= "$therow, "; +} + +# Print pages... +# +print "const Q_UINT8 TQUnicodeTables::combining_info[] = {"; +print "$rowtable_txt\n\n"; +$size+=256; +print $row_txt; +print "};\n\n"; +print "// $size bytes\n\n"; + +# Build case info +# +$rowtable_txt = ""; +$row_txt = ""; +$pos = 1; +for $row ( 0..255 ) { + $nonzero=0; + $txt = ""; + for $cell ( 0..255 ) { + $code = sprintf("%02X%02X",$row,$cell); + $info = $uppercase{$code}; + if ( length( $info ) eq 0 ) { + $info = $lowercase{$code}; + } + $info =~ s/^0+//; + if ( length( $info ) eq 0 ) { + $info = "0"; + } else { + $info = "0x".lc($info); + } + if ( length( $info ) ne 1 ) { + $nonzero = 1; + } + $txt .= "\n " if $cell%8 == 0; + $txt .= "$info, "; + } + $therow = $case_row{$txt}; + if ( !defined $therow && $nonzero ne 0 ) { + $therow = sprintf("%d",$pos); + $row_txt = $row_txt."$txt\n"; + $case_row{$txt}=$therow; + $pos += 1; + $size += 512; + } + $rowtable_txt .= "\n " if $row%8 == 0; + if ( $nonzero ne 0 ) { + $rowtable_txt .= "$therow, "; + } else { + $rowtable_txt .= "0, "; + } +} + +# Print pages... +# +print "const Q_UINT16 TQUnicodeTables::case_info[] = {"; +print "$rowtable_txt\n\n"; +$size+=512; +print $row_txt; +print "};\n"; +print "// $size bytes\n\n"; + +# Build decimal info +# +$rowtable_txt = ""; +$row_txt = ""; +$pos = 1; +for $row ( 0..255 ) { + $nonzero=0; + $txt = ""; + for $cell ( 0..255 ) { + $code = sprintf("%02X%02X",$row,$cell); + $info = $digit_value{$code}; + if ( length( $info ) eq 0 ) { + $info = -1; + } else { + $nonzero = 1; + } + $txt .= "\n " if $cell%8 == 0; + $txt .= "$info, "; + } + $therow = $decimal_row{$txt}; + if ( !defined $therow && $nonzero ne 0 ) { + $therow = sprintf("%d",$pos); + $row_txt = $row_txt."$txt\n"; + $decimal_row{$txt}=$therow; + $pos += 1; + $size += 256; + } + $rowtable_txt .= "\n " if $row%8 == 0; + if ( $nonzero ne 0 ) { + $rowtable_txt .= "$therow, "; + } else { + $rowtable_txt .= "0, "; + } +} + +# Print pages... +# +print "const Q_INT8 TQUnicodeTables::decimal_info[] = {"; +print "$rowtable_txt\n\n"; +$size+=512; +print $row_txt; +print "};\n"; +print "// $size bytes\n\n"; + + +# Build line break info +# +$rowtable_txt = ""; +$row_txt = ""; +$pos = 1; +for $row ( 0..255 ) { + $txt = ""; + for $cell ( 0..255 ) { + $code = sprintf("%02X%02X",$row,$cell); + $info = $breaks{$code}; + if ( length( $info ) eq 0 ) { + $info = $line_break_code{"AL"}; + } + $txt .= "\n " if $cell%8 == 0; + $txt .= "$info, "; + } + $therow = $lb_row{$txt}; + if ( !defined $therow ) { + $therow = sprintf("%d",$pos); + $row_txt = $row_txt."$txt\n"; + $lb_row{$txt}=$therow; + $pos += 1; + $size += 256; + } + $rowtable_txt .= "\n " if $row%8 == 0; + $rowtable_txt .= "$therow, "; +} + +# Print pages... +# +print "const Q_UINT8 TQUnicodeTables::line_break_info[] = {"; +print "$rowtable_txt\n\n"; +$size+=512; +print $row_txt; +print "};\n"; +print "// $size bytes\n\n"; + + + +print "#endif\n\n"; +print "// END OF GENERATED DATA\n\n"; + + +__END__ + +*/ + +// START OF GENERATED DATA + +#ifndef QT_NO_UNICODETABLES + +const Q_UINT8 TQUnicodeTables::unicode_info[] = { + 1, 2, 3, 4, 5, 6, 7, 8, + 9, 10, 11, 12, 13, 14, 15, 16, + 17, 18, 19, 20, 21, 22, 23, 24, + 25, 9, 9, 9, 9, 9, 26, 27, + 28, 29, 30, 31, 32, 33, 34, 35, + 36, 37, 30, 9, 9, 9, 38, 39, + 40, 41, 42, 43, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 44, 22, 22, + 22, 22, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 22, 22, 45, + 22, 22, 22, 22, 46, 9, 9, 9, + 9, 9, 9, 9, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 22, 22, 47, + 48, 48, 48, 48, 48, 48, 48, 48, + 49, 49, 49, 49, 49, 49, 49, 49, + 49, 49, 49, 49, 49, 49, 49, 49, + 49, 49, 49, 49, 49, 49, 49, 49, + 49, 22, 50, 51, 22, 52, 53, 54, + + + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 7, 26, 26, 26, 28, 26, 26, 26, + 22, 23, 26, 27, 26, 21, 26, 26, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 26, 26, 27, 27, 27, 26, + 26, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 22, 26, 23, 29, 20, + 29, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 22, 27, 23, 27, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 7, 26, 28, 28, 28, 28, 30, 30, + 29, 30, 16, 24, 27, 21, 30, 29, + 30, 27, 6, 6, 29, 16, 30, 26, + 29, 6, 16, 25, 6, 6, 6, 26, + 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 27, + 15, 15, 15, 15, 15, 15, 15, 16, + 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 27, + 16, 16, 16, 16, 16, 16, 16, 16, + + 15, 16, 15, 16, 15, 16, 15, 16, + 15, 16, 15, 16, 15, 16, 15, 16, + 15, 16, 15, 16, 15, 16, 15, 16, + 15, 16, 15, 16, 15, 16, 15, 16, + 15, 16, 15, 16, 15, 16, 15, 16, + 15, 16, 15, 16, 15, 16, 15, 16, + 15, 16, 15, 16, 15, 16, 15, 16, + 16, 15, 16, 15, 16, 15, 16, 15, + 16, 15, 16, 15, 16, 15, 16, 15, + 16, 16, 15, 16, 15, 16, 15, 16, + 15, 16, 15, 16, 15, 16, 15, 16, + 15, 16, 15, 16, 15, 16, 15, 16, + 15, 16, 15, 16, 15, 16, 15, 16, + 15, 16, 15, 16, 15, 16, 15, 16, + 15, 16, 15, 16, 15, 16, 15, 16, + 15, 15, 16, 15, 16, 15, 16, 16, + 16, 15, 15, 16, 15, 16, 15, 15, + 16, 15, 15, 15, 16, 16, 15, 15, + 15, 15, 16, 15, 15, 16, 15, 15, + 15, 16, 16, 16, 15, 15, 16, 15, + 15, 16, 15, 16, 15, 16, 15, 15, + 16, 15, 16, 16, 15, 16, 15, 15, + 16, 15, 15, 15, 16, 15, 16, 15, + 15, 16, 16, 19, 15, 16, 16, 16, + 19, 19, 19, 19, 15, 17, 16, 15, + 17, 16, 15, 17, 16, 15, 16, 15, + 16, 15, 16, 15, 16, 15, 16, 15, + 16, 15, 16, 15, 16, 16, 15, 16, + 15, 16, 15, 16, 15, 16, 15, 16, + 15, 16, 15, 16, 15, 16, 15, 16, + 16, 15, 17, 16, 15, 16, 15, 15, + 15, 16, 15, 16, 15, 16, 15, 16, + + 15, 16, 15, 16, 15, 16, 15, 16, + 15, 16, 15, 16, 15, 16, 15, 16, + 15, 16, 15, 16, 15, 16, 15, 16, + 15, 16, 15, 16, 15, 16, 15, 16, + 15, 0, 15, 16, 15, 16, 15, 16, + 15, 16, 15, 16, 15, 16, 15, 16, + 15, 16, 15, 16, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 0, 0, + 18, 18, 18, 18, 18, 18, 18, 18, + 18, 29, 29, 18, 18, 18, 18, 18, + 18, 18, 29, 29, 29, 29, 29, 29, + 29, 29, 29, 29, 29, 29, 29, 29, + 18, 18, 29, 29, 29, 29, 29, 29, + 29, 29, 29, 29, 29, 29, 29, 29, + 18, 18, 18, 18, 18, 29, 29, 29, + 29, 29, 29, 29, 29, 29, 18, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 0, 0, 0, 0, 29, 29, 0, 0, + 0, 0, 18, 0, 0, 0, 26, 0, + 0, 0, 0, 0, 29, 29, 15, 26, + 15, 15, 15, 0, 15, 0, 15, 15, + 16, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 0, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 0, + 16, 16, 15, 15, 15, 16, 16, 16, + 15, 16, 15, 16, 15, 16, 15, 16, + 15, 16, 15, 16, 15, 16, 15, 16, + 15, 16, 15, 16, 15, 16, 15, 16, + 16, 16, 16, 16, 15, 16, 27, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, + 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, + 15, 16, 15, 16, 15, 16, 15, 16, + 15, 16, 15, 16, 15, 16, 15, 16, + 15, 16, 15, 16, 15, 16, 15, 16, + 15, 16, 15, 16, 15, 16, 15, 16, + 15, 16, 30, 1, 1, 1, 1, 0, + 3, 3, 15, 16, 15, 16, 15, 16, + 15, 16, 15, 16, 15, 16, 15, 16, + 15, 16, 15, 16, 15, 16, 15, 16, + 15, 16, 15, 16, 15, 16, 15, 16, + 15, 16, 15, 16, 15, 16, 15, 16, + 15, 16, 15, 16, 15, 16, 15, 16, + 15, 16, 15, 16, 15, 16, 15, 16, + 15, 15, 16, 15, 16, 15, 16, 15, + 16, 15, 16, 15, 16, 15, 16, 0, + 15, 16, 15, 16, 15, 16, 15, 16, + 15, 16, 15, 16, 15, 16, 15, 16, + 15, 16, 15, 16, 15, 16, 15, 16, + 15, 16, 15, 16, 15, 16, 15, 16, + 15, 16, 15, 16, 15, 16, 0, 0, + 15, 16, 0, 0, 0, 0, 0, 0, + + 15, 16, 15, 16, 15, 16, 15, 16, + 15, 16, 15, 16, 15, 16, 15, 16, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 0, + 0, 18, 26, 26, 26, 26, 26, 26, + 0, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, + 0, 26, 21, 0, 0, 0, 0, 0, + 0, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 0, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 0, 1, 1, 1, 26, 1, + 26, 1, 1, 26, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 0, 0, 0, 0, 0, + 19, 19, 19, 26, 26, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 26, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 26, 0, 0, 0, 26, + 0, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 0, 0, 0, 0, 0, + 18, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 26, 26, 26, 26, 19, 19, + 1, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 26, 19, 1, 1, + 1, 1, 1, 1, 1, 11, 3, 1, + 1, 1, 1, 1, 1, 18, 18, 1, + 1, 30, 1, 1, 1, 1, 0, 0, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 19, 19, 19, 30, 30, 0, + + 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 0, 11, + 19, 1, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 0, 0, 0, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 19, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 1, 1, 2, 0, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 0, 0, 1, 19, 2, 2, + 2, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 2, 2, 2, 1, 0, 0, + 19, 1, 1, 1, 1, 0, 0, 0, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 1, 1, 26, 26, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 26, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1, 2, 2, 0, 19, 19, 19, + 19, 19, 19, 19, 19, 0, 0, 19, + 19, 0, 0, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 0, 19, 19, 19, 19, 19, 19, + 19, 0, 19, 0, 0, 0, 19, 19, + 19, 19, 0, 0, 1, 0, 2, 2, + 2, 1, 1, 1, 1, 0, 0, 2, + 2, 0, 0, 2, 2, 1, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 19, 19, 0, 19, + 19, 19, 1, 1, 0, 0, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 19, 19, 28, 28, 6, 6, 6, 6, + 6, 6, 30, 0, 0, 0, 0, 0, + + 0, 0, 1, 0, 0, 19, 19, 19, + 19, 19, 19, 0, 0, 0, 0, 19, + 19, 0, 0, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 0, 19, 19, 19, 19, 19, 19, + 19, 0, 19, 19, 0, 19, 19, 0, + 19, 19, 0, 0, 1, 0, 2, 2, + 2, 1, 1, 0, 0, 0, 0, 1, + 1, 0, 0, 1, 1, 1, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 19, 19, 19, 19, 0, 19, 0, + 0, 0, 0, 0, 0, 0, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 1, 1, 19, 19, 19, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1, 1, 2, 0, 19, 19, 19, + 19, 19, 19, 19, 0, 19, 0, 19, + 19, 19, 0, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 0, 19, 19, 19, 19, 19, 19, + 19, 0, 19, 19, 0, 19, 19, 19, + 19, 19, 0, 0, 1, 19, 2, 2, + 2, 1, 1, 1, 1, 1, 0, 1, + 1, 2, 0, 2, 2, 1, 0, 0, + 19, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 19, 0, 0, 0, 0, 0, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 1, 2, 2, 0, 19, 19, 19, + 19, 19, 19, 19, 19, 0, 0, 19, + 19, 0, 0, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 0, 19, 19, 19, 19, 19, 19, + 19, 0, 19, 19, 0, 0, 19, 19, + 19, 19, 0, 0, 1, 19, 2, 1, + 2, 1, 1, 1, 0, 0, 0, 2, + 2, 0, 0, 2, 2, 1, 0, 0, + 0, 0, 0, 0, 0, 0, 1, 2, + 0, 0, 0, 0, 19, 19, 0, 19, + 19, 19, 0, 0, 0, 0, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 30, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1, 19, 0, 19, 19, 19, + 19, 19, 19, 0, 0, 0, 19, 19, + 19, 0, 19, 19, 19, 19, 0, 0, + 0, 19, 19, 0, 19, 0, 19, 19, + 0, 0, 0, 19, 19, 0, 0, 0, + 19, 19, 19, 0, 0, 0, 19, 19, + 19, 19, 19, 19, 19, 19, 0, 19, + 19, 19, 0, 0, 0, 0, 2, 2, + 1, 2, 2, 0, 0, 0, 2, 2, + 2, 0, 2, 2, 2, 1, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 6, 6, 6, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 2, 2, 2, 0, 19, 19, 19, + 19, 19, 19, 19, 19, 0, 19, 19, + 19, 0, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 0, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 0, 19, 19, 19, + 19, 19, 0, 0, 0, 0, 1, 1, + 1, 2, 2, 2, 2, 0, 1, 1, + 1, 0, 1, 1, 1, 1, 0, 0, + 0, 0, 0, 0, 0, 1, 1, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 19, 19, 0, 0, 0, 0, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 2, 2, 0, 19, 19, 19, + 19, 19, 19, 19, 19, 0, 19, 19, + 19, 0, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 0, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 0, 19, 19, 19, + 19, 19, 0, 0, 0, 0, 2, 1, + 2, 2, 2, 2, 2, 0, 1, 2, + 2, 0, 2, 2, 1, 1, 0, 0, + 0, 0, 0, 0, 0, 2, 2, 0, + 0, 0, 0, 0, 0, 0, 19, 0, + 19, 19, 0, 0, 0, 0, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 2, 2, 0, 19, 19, 19, + 19, 19, 19, 19, 19, 0, 19, 19, + 19, 0, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 0, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 0, 0, 0, 0, 2, 2, + 2, 1, 1, 1, 0, 0, 2, 2, + 2, 0, 2, 2, 2, 1, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 0, + 19, 19, 0, 0, 0, 0, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 2, 2, 0, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 0, + 0, 0, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 0, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 0, 19, 0, 0, + 19, 19, 19, 19, 19, 19, 19, 0, + 0, 0, 1, 0, 0, 0, 0, 2, + 2, 2, 1, 1, 1, 0, 1, 0, + 2, 2, 2, 2, 2, 2, 2, 2, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 2, 2, 26, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 1, 19, 19, 1, 1, 1, 1, + 1, 1, 1, 0, 0, 0, 0, 28, + 19, 19, 19, 19, 19, 19, 18, 1, + 1, 1, 1, 1, 1, 1, 1, 26, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 26, 26, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 19, 19, 0, 19, 0, 0, 19, + 19, 0, 19, 0, 0, 19, 0, 0, + 0, 0, 0, 0, 19, 19, 19, 19, + 0, 19, 19, 19, 19, 19, 19, 19, + 0, 19, 19, 19, 0, 19, 0, 19, + 0, 0, 19, 19, 0, 19, 19, 19, + 19, 1, 19, 19, 1, 1, 1, 1, + 1, 1, 0, 1, 1, 19, 0, 0, + 19, 19, 19, 19, 19, 0, 18, 0, + 1, 1, 1, 1, 1, 1, 0, 0, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 0, 0, 19, 19, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 19, 30, 30, 30, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 30, 30, 30, 30, 30, + 1, 1, 30, 30, 30, 30, 30, 30, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 30, 1, 30, 1, + 30, 1, 22, 23, 22, 23, 2, 2, + 19, 19, 19, 19, 19, 19, 19, 19, + 0, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 0, 0, 0, 0, 0, + 0, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 2, + 1, 1, 1, 1, 1, 26, 1, 1, + 19, 19, 19, 19, 0, 0, 0, 0, + 1, 1, 1, 1, 1, 1, 1, 1, + 0, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 0, 30, 30, + 30, 30, 30, 30, 30, 30, 1, 30, + 30, 30, 30, 30, 30, 0, 0, 30, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 0, 19, 19, 19, 19, 19, + 0, 19, 19, 0, 2, 1, 1, 1, + 1, 2, 1, 0, 0, 0, 1, 1, + 2, 1, 0, 0, 0, 0, 0, 0, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 26, 26, 26, 26, 26, 26, + 19, 19, 19, 19, 19, 19, 2, 2, + 1, 1, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 0, 0, 26, 0, 0, 0, 0, + + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 0, 0, 0, 0, 0, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 0, 0, 0, 0, 0, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 0, 0, 0, 0, 0, 0, + + 19, 19, 19, 19, 19, 19, 19, 0, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 0, + 19, 0, 19, 19, 19, 19, 0, 0, + 19, 19, 19, 19, 19, 19, 19, 0, + 19, 0, 19, 19, 19, 19, 0, 0, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 0, + 19, 0, 19, 19, 19, 19, 0, 0, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 0, + 19, 0, 19, 19, 19, 19, 0, 0, + 19, 19, 19, 19, 19, 19, 19, 0, + 19, 0, 19, 19, 19, 19, 0, 0, + 19, 19, 19, 19, 19, 19, 19, 0, + 19, 19, 19, 19, 19, 19, 19, 0, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 0, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 0, + 19, 0, 19, 19, 19, 19, 0, 0, + 19, 19, 19, 19, 19, 19, 19, 0, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 0, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 0, 0, 0, 0, 0, + 0, 26, 26, 26, 26, 26, 26, 26, + 26, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 26, 26, 19, + 19, 19, 19, 19, 19, 19, 19, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 7, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 22, 23, 0, 0, 0, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 26, 26, 26, 5, 5, + 5, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 0, 19, 19, + 19, 19, 1, 1, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 1, 1, 1, 26, 26, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 1, 1, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 0, 19, 19, + 19, 0, 1, 1, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 2, 2, 2, 1, + 1, 1, 1, 1, 1, 1, 2, 2, + 2, 2, 2, 2, 2, 2, 1, 2, + 2, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 26, 26, 26, 18, + 26, 26, 26, 28, 19, 0, 0, 0, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 26, 26, 26, 26, 26, 26, 21, 26, + 26, 26, 26, 1, 1, 1, 11, 0, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 0, 0, 0, 0, 0, 0, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 18, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 0, 0, 0, 0, 0, 0, 0, 0, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 1, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 15, 16, 15, 16, 15, 16, 15, 16, + 15, 16, 15, 16, 15, 16, 15, 16, + 15, 16, 15, 16, 15, 16, 15, 16, + 15, 16, 15, 16, 15, 16, 15, 16, + 15, 16, 15, 16, 15, 16, 15, 16, + 15, 16, 15, 16, 15, 16, 15, 16, + 15, 16, 15, 16, 15, 16, 15, 16, + 15, 16, 15, 16, 15, 16, 15, 16, + 15, 16, 15, 16, 15, 16, 15, 16, + 15, 16, 15, 16, 15, 16, 15, 16, + 15, 16, 15, 16, 15, 16, 15, 16, + 15, 16, 15, 16, 15, 16, 15, 16, + 15, 16, 15, 16, 15, 16, 15, 16, + 15, 16, 15, 16, 15, 16, 15, 16, + 15, 16, 15, 16, 15, 16, 15, 16, + 15, 16, 15, 16, 15, 16, 15, 16, + 15, 16, 15, 16, 15, 16, 15, 16, + 15, 16, 15, 16, 15, 16, 15, 16, + 15, 16, 15, 16, 15, 16, 16, 16, + 16, 16, 16, 16, 0, 0, 0, 0, + 15, 16, 15, 16, 15, 16, 15, 16, + 15, 16, 15, 16, 15, 16, 15, 16, + 15, 16, 15, 16, 15, 16, 15, 16, + 15, 16, 15, 16, 15, 16, 15, 16, + 15, 16, 15, 16, 15, 16, 15, 16, + 15, 16, 15, 16, 15, 16, 15, 16, + 15, 16, 15, 16, 15, 16, 15, 16, + 15, 16, 15, 16, 15, 16, 15, 16, + 15, 16, 15, 16, 15, 16, 15, 16, + 15, 16, 15, 16, 15, 16, 15, 16, + 15, 16, 15, 16, 15, 16, 15, 16, + 15, 16, 0, 0, 0, 0, 0, 0, + + 16, 16, 16, 16, 16, 16, 16, 16, + 15, 15, 15, 15, 15, 15, 15, 15, + 16, 16, 16, 16, 16, 16, 0, 0, + 15, 15, 15, 15, 15, 15, 0, 0, + 16, 16, 16, 16, 16, 16, 16, 16, + 15, 15, 15, 15, 15, 15, 15, 15, + 16, 16, 16, 16, 16, 16, 16, 16, + 15, 15, 15, 15, 15, 15, 15, 15, + 16, 16, 16, 16, 16, 16, 0, 0, + 15, 15, 15, 15, 15, 15, 0, 0, + 16, 16, 16, 16, 16, 16, 16, 16, + 0, 15, 0, 15, 0, 15, 0, 15, + 16, 16, 16, 16, 16, 16, 16, 16, + 15, 15, 15, 15, 15, 15, 15, 15, + 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 0, 0, + 16, 16, 16, 16, 16, 16, 16, 16, + 17, 17, 17, 17, 17, 17, 17, 17, + 16, 16, 16, 16, 16, 16, 16, 16, + 17, 17, 17, 17, 17, 17, 17, 17, + 16, 16, 16, 16, 16, 16, 16, 16, + 17, 17, 17, 17, 17, 17, 17, 17, + 16, 16, 16, 16, 16, 0, 16, 16, + 15, 15, 15, 15, 17, 29, 16, 29, + 29, 29, 16, 16, 16, 0, 16, 16, + 15, 15, 15, 15, 17, 29, 29, 29, + 16, 16, 16, 16, 0, 0, 16, 16, + 15, 15, 15, 15, 0, 29, 29, 29, + 16, 16, 16, 16, 16, 16, 16, 16, + 15, 15, 15, 15, 15, 29, 29, 29, + 0, 0, 16, 16, 16, 0, 16, 16, + 15, 15, 15, 15, 17, 29, 29, 0, + + 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 11, 11, 11, 11, + 21, 21, 21, 21, 21, 21, 26, 26, + 24, 25, 22, 24, 24, 25, 22, 24, + 26, 26, 26, 26, 26, 26, 26, 26, + 8, 9, 11, 11, 11, 11, 11, 7, + 26, 26, 26, 26, 26, 26, 26, 26, + 26, 24, 25, 26, 26, 26, 26, 20, + 20, 26, 26, 26, 27, 22, 23, 26, + 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 27, 0, 0, 0, 0, 26, + 0, 0, 0, 0, 0, 0, 0, 7, + 11, 11, 11, 11, 0, 0, 0, 0, + 0, 0, 11, 11, 11, 11, 11, 11, + 6, 16, 0, 0, 6, 6, 6, 6, + 6, 6, 27, 27, 27, 22, 23, 16, + 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 27, 27, 27, 22, 23, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 28, 28, 28, 28, 28, 28, 28, 28, + 28, 28, 28, 28, 28, 28, 28, 28, + 28, 28, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 3, 3, 3, + 3, 1, 3, 3, 3, 1, 1, 1, + 1, 1, 1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 30, 30, 15, 30, 30, 30, 30, 15, + 30, 30, 16, 15, 15, 15, 16, 16, + 15, 15, 15, 16, 30, 15, 30, 30, + 30, 15, 15, 15, 15, 15, 30, 30, + 30, 30, 30, 30, 15, 30, 15, 30, + 15, 30, 15, 15, 15, 15, 30, 16, + 15, 15, 30, 15, 16, 19, 19, 19, + 19, 16, 30, 0, 0, 16, 15, 15, + 27, 27, 27, 27, 27, 15, 16, 16, + 16, 16, 30, 27, 0, 0, 0, 0, + 0, 0, 0, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, + 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 27, 27, 27, 27, 27, 30, 30, 30, + 30, 30, 27, 27, 30, 30, 30, 30, + 27, 30, 30, 27, 30, 30, 27, 30, + 30, 30, 30, 30, 30, 30, 27, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 27, 27, + 30, 30, 27, 30, 27, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, + + 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, + + 30, 30, 30, 30, 30, 30, 30, 30, + 27, 27, 27, 27, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 27, 27, 30, 30, 30, 30, 30, 30, + 30, 22, 23, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 27, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 22, 23, 26, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 0, + + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 27, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 27, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 27, 27, 27, 27, 27, 27, 27, 27, + + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 0, 0, 30, 30, + 0, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 27, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 0, 0, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 30, 30, 30, 30, 0, 30, 30, + 30, 30, 0, 0, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 0, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 0, 30, 0, 30, + 30, 30, 30, 0, 0, 0, 30, 0, + 30, 30, 30, 30, 30, 30, 30, 0, + 0, 30, 30, 30, 30, 30, 30, 30, + 22, 23, 22, 23, 22, 23, 22, 23, + 22, 23, 22, 23, 22, 23, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 30, 0, 0, 0, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 0, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 22, 23, + 22, 23, 22, 23, 0, 0, 0, 0, + 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, + + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + + 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 22, 23, 22, 23, 22, + 23, 22, 23, 22, 23, 22, 23, 22, + 23, 22, 23, 22, 23, 22, 23, 22, + 23, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, + 22, 23, 22, 23, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 22, 23, 27, 27, + + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 0, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 0, 0, 0, 0, + + 7, 26, 26, 26, 30, 18, 19, 5, + 22, 23, 22, 23, 22, 23, 22, 23, + 22, 23, 30, 30, 22, 23, 22, 23, + 22, 23, 22, 23, 21, 22, 23, 23, + 30, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 1, 1, 1, 1, 1, 1, + 21, 18, 18, 18, 18, 18, 30, 30, + 5, 5, 5, 18, 19, 26, 30, 30, + 0, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 0, + 0, 1, 1, 29, 29, 18, 18, 19, + 21, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 20, 18, 18, 18, 19, + + 0, 0, 0, 0, 0, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 0, 0, 0, + 0, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 0, + 30, 30, 6, 6, 6, 6, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 0, 0, 0, + 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 0, 0, 0, 30, + 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 0, 0, 0, 0, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 0, + + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 0, + 0, 0, 0, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 0, 0, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 0, + + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 0, 0, 0, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 30, + 30, 30, 30, 30, 30, 30, 30, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 0, 0, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 16, 16, 16, 16, 16, 16, 16, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 16, 16, 16, 16, 16, + 0, 0, 0, 0, 0, 19, 1, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 27, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 0, + 19, 19, 19, 19, 19, 0, 19, 0, + 19, 19, 0, 19, 19, 0, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 22, 23, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 0, 0, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 28, 0, 0, 0, + + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 1, 1, 1, 1, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 26, 21, 21, 20, 20, 22, 23, 22, + 23, 22, 23, 22, 23, 22, 23, 22, + 23, 22, 23, 22, 23, 26, 26, 0, + 0, 26, 26, 26, 26, 20, 20, 20, + 26, 26, 26, 0, 26, 26, 26, 26, + 21, 22, 23, 22, 23, 22, 23, 26, + 26, 26, 27, 21, 27, 27, 27, 0, + 26, 28, 26, 26, 0, 0, 0, 0, + 19, 19, 19, 19, 19, 0, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 0, 0, 11, + + 0, 26, 26, 26, 28, 26, 26, 26, + 22, 23, 26, 27, 26, 21, 26, 26, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 26, 26, 27, 27, 27, 26, + 26, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 22, 26, 23, 29, 20, + 29, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 22, 27, 23, 27, 22, + 23, 26, 22, 23, 26, 20, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 18, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 18, 18, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 0, + 0, 0, 19, 19, 19, 19, 19, 19, + 0, 0, 19, 19, 19, 19, 19, 19, + 0, 0, 19, 19, 19, 19, 19, 19, + 0, 0, 19, 19, 19, 0, 0, 0, + 28, 28, 27, 29, 30, 28, 28, 0, + 30, 27, 27, 27, 27, 30, 30, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 11, 11, 11, 30, 30, 0, 0, +}; + +// 14080 bytes + +const Q_UINT16 TQUnicodeTables::decomposition_map[] = { + 0, + 3, 0x00A0, 0x0020, 0, + 16, 0x00A8, 0x0020, 0x0308, 0, + 9, 0x00AA, 0x0061, 0, + 16, 0x00AF, 0x0020, 0x0304, 0, + 9, 0x00B2, 0x0032, 0, + 9, 0x00B3, 0x0033, 0, + 16, 0x00B4, 0x0020, 0x0301, 0, + 16, 0x00B5, 0x03BC, 0, + 16, 0x00B8, 0x0020, 0x0327, 0, + 9, 0x00B9, 0x0031, 0, + 9, 0x00BA, 0x006F, 0, + 17, 0x00BC, 0x0031, 0x2044, 0x0034, 0, + 17, 0x00BD, 0x0031, 0x2044, 0x0032, 0, + 17, 0x00BE, 0x0033, 0x2044, 0x0034, 0, + 1, 0x00C0, 0x0041, 0x0300, 0, + 1, 0x00C1, 0x0041, 0x0301, 0, + 1, 0x00C2, 0x0041, 0x0302, 0, + 1, 0x00C3, 0x0041, 0x0303, 0, + 1, 0x00C4, 0x0041, 0x0308, 0, + 1, 0x00C5, 0x0041, 0x030A, 0, + 1, 0x00C7, 0x0043, 0x0327, 0, + 1, 0x00C8, 0x0045, 0x0300, 0, + 1, 0x00C9, 0x0045, 0x0301, 0, + 1, 0x00CA, 0x0045, 0x0302, 0, + 1, 0x00CB, 0x0045, 0x0308, 0, + 1, 0x00CC, 0x0049, 0x0300, 0, + 1, 0x00CD, 0x0049, 0x0301, 0, + 1, 0x00CE, 0x0049, 0x0302, 0, + 1, 0x00CF, 0x0049, 0x0308, 0, + 1, 0x00D1, 0x004E, 0x0303, 0, + 1, 0x00D2, 0x004F, 0x0300, 0, + 1, 0x00D3, 0x004F, 0x0301, 0, + 1, 0x00D4, 0x004F, 0x0302, 0, + 1, 0x00D5, 0x004F, 0x0303, 0, + 1, 0x00D6, 0x004F, 0x0308, 0, + 1, 0x00D9, 0x0055, 0x0300, 0, + 1, 0x00DA, 0x0055, 0x0301, 0, + 1, 0x00DB, 0x0055, 0x0302, 0, + 1, 0x00DC, 0x0055, 0x0308, 0, + 1, 0x00DD, 0x0059, 0x0301, 0, + 1, 0x00E0, 0x0061, 0x0300, 0, + 1, 0x00E1, 0x0061, 0x0301, 0, + 1, 0x00E2, 0x0061, 0x0302, 0, + 1, 0x00E3, 0x0061, 0x0303, 0, + 1, 0x00E4, 0x0061, 0x0308, 0, + 1, 0x00E5, 0x0061, 0x030A, 0, + 1, 0x00E7, 0x0063, 0x0327, 0, + 1, 0x00E8, 0x0065, 0x0300, 0, + 1, 0x00E9, 0x0065, 0x0301, 0, + 1, 0x00EA, 0x0065, 0x0302, 0, + 1, 0x00EB, 0x0065, 0x0308, 0, + 1, 0x00EC, 0x0069, 0x0300, 0, + 1, 0x00ED, 0x0069, 0x0301, 0, + 1, 0x00EE, 0x0069, 0x0302, 0, + 1, 0x00EF, 0x0069, 0x0308, 0, + 1, 0x00F1, 0x006E, 0x0303, 0, + 1, 0x00F2, 0x006F, 0x0300, 0, + 1, 0x00F3, 0x006F, 0x0301, 0, + 1, 0x00F4, 0x006F, 0x0302, 0, + 1, 0x00F5, 0x006F, 0x0303, 0, + 1, 0x00F6, 0x006F, 0x0308, 0, + 1, 0x00F9, 0x0075, 0x0300, 0, + 1, 0x00FA, 0x0075, 0x0301, 0, + 1, 0x00FB, 0x0075, 0x0302, 0, + 1, 0x00FC, 0x0075, 0x0308, 0, + 1, 0x00FD, 0x0079, 0x0301, 0, + 1, 0x00FF, 0x0079, 0x0308, 0, + 1, 0x0100, 0x0041, 0x0304, 0, + 1, 0x0101, 0x0061, 0x0304, 0, + 1, 0x0102, 0x0041, 0x0306, 0, + 1, 0x0103, 0x0061, 0x0306, 0, + 1, 0x0104, 0x0041, 0x0328, 0, + 1, 0x0105, 0x0061, 0x0328, 0, + 1, 0x0106, 0x0043, 0x0301, 0, + 1, 0x0107, 0x0063, 0x0301, 0, + 1, 0x0108, 0x0043, 0x0302, 0, + 1, 0x0109, 0x0063, 0x0302, 0, + 1, 0x010A, 0x0043, 0x0307, 0, + 1, 0x010B, 0x0063, 0x0307, 0, + 1, 0x010C, 0x0043, 0x030C, 0, + 1, 0x010D, 0x0063, 0x030C, 0, + 1, 0x010E, 0x0044, 0x030C, 0, + 1, 0x010F, 0x0064, 0x030C, 0, + 1, 0x0112, 0x0045, 0x0304, 0, + 1, 0x0113, 0x0065, 0x0304, 0, + 1, 0x0114, 0x0045, 0x0306, 0, + 1, 0x0115, 0x0065, 0x0306, 0, + 1, 0x0116, 0x0045, 0x0307, 0, + 1, 0x0117, 0x0065, 0x0307, 0, + 1, 0x0118, 0x0045, 0x0328, 0, + 1, 0x0119, 0x0065, 0x0328, 0, + 1, 0x011A, 0x0045, 0x030C, 0, + 1, 0x011B, 0x0065, 0x030C, 0, + 1, 0x011C, 0x0047, 0x0302, 0, + 1, 0x011D, 0x0067, 0x0302, 0, + 1, 0x011E, 0x0047, 0x0306, 0, + 1, 0x011F, 0x0067, 0x0306, 0, + 1, 0x0120, 0x0047, 0x0307, 0, + 1, 0x0121, 0x0067, 0x0307, 0, + 1, 0x0122, 0x0047, 0x0327, 0, + 1, 0x0123, 0x0067, 0x0327, 0, + 1, 0x0124, 0x0048, 0x0302, 0, + 1, 0x0125, 0x0068, 0x0302, 0, + 1, 0x0128, 0x0049, 0x0303, 0, + 1, 0x0129, 0x0069, 0x0303, 0, + 1, 0x012A, 0x0049, 0x0304, 0, + 1, 0x012B, 0x0069, 0x0304, 0, + 1, 0x012C, 0x0049, 0x0306, 0, + 1, 0x012D, 0x0069, 0x0306, 0, + 1, 0x012E, 0x0049, 0x0328, 0, + 1, 0x012F, 0x0069, 0x0328, 0, + 1, 0x0130, 0x0049, 0x0307, 0, + 16, 0x0132, 0x0049, 0x004A, 0, + 16, 0x0133, 0x0069, 0x006A, 0, + 1, 0x0134, 0x004A, 0x0302, 0, + 1, 0x0135, 0x006A, 0x0302, 0, + 1, 0x0136, 0x004B, 0x0327, 0, + 1, 0x0137, 0x006B, 0x0327, 0, + 1, 0x0139, 0x004C, 0x0301, 0, + 1, 0x013A, 0x006C, 0x0301, 0, + 1, 0x013B, 0x004C, 0x0327, 0, + 1, 0x013C, 0x006C, 0x0327, 0, + 1, 0x013D, 0x004C, 0x030C, 0, + 1, 0x013E, 0x006C, 0x030C, 0, + 16, 0x013F, 0x004C, 0x00B7, 0, + 16, 0x0140, 0x006C, 0x00B7, 0, + 1, 0x0143, 0x004E, 0x0301, 0, + 1, 0x0144, 0x006E, 0x0301, 0, + 1, 0x0145, 0x004E, 0x0327, 0, + 1, 0x0146, 0x006E, 0x0327, 0, + 1, 0x0147, 0x004E, 0x030C, 0, + 1, 0x0148, 0x006E, 0x030C, 0, + 16, 0x0149, 0x02BC, 0x006E, 0, + 1, 0x014C, 0x004F, 0x0304, 0, + 1, 0x014D, 0x006F, 0x0304, 0, + 1, 0x014E, 0x004F, 0x0306, 0, + 1, 0x014F, 0x006F, 0x0306, 0, + 1, 0x0150, 0x004F, 0x030B, 0, + 1, 0x0151, 0x006F, 0x030B, 0, + 1, 0x0154, 0x0052, 0x0301, 0, + 1, 0x0155, 0x0072, 0x0301, 0, + 1, 0x0156, 0x0052, 0x0327, 0, + 1, 0x0157, 0x0072, 0x0327, 0, + 1, 0x0158, 0x0052, 0x030C, 0, + 1, 0x0159, 0x0072, 0x030C, 0, + 1, 0x015A, 0x0053, 0x0301, 0, + 1, 0x015B, 0x0073, 0x0301, 0, + 1, 0x015C, 0x0053, 0x0302, 0, + 1, 0x015D, 0x0073, 0x0302, 0, + 1, 0x015E, 0x0053, 0x0327, 0, + 1, 0x015F, 0x0073, 0x0327, 0, + 1, 0x0160, 0x0053, 0x030C, 0, + 1, 0x0161, 0x0073, 0x030C, 0, + 1, 0x0162, 0x0054, 0x0327, 0, + 1, 0x0163, 0x0074, 0x0327, 0, + 1, 0x0164, 0x0054, 0x030C, 0, + 1, 0x0165, 0x0074, 0x030C, 0, + 1, 0x0168, 0x0055, 0x0303, 0, + 1, 0x0169, 0x0075, 0x0303, 0, + 1, 0x016A, 0x0055, 0x0304, 0, + 1, 0x016B, 0x0075, 0x0304, 0, + 1, 0x016C, 0x0055, 0x0306, 0, + 1, 0x016D, 0x0075, 0x0306, 0, + 1, 0x016E, 0x0055, 0x030A, 0, + 1, 0x016F, 0x0075, 0x030A, 0, + 1, 0x0170, 0x0055, 0x030B, 0, + 1, 0x0171, 0x0075, 0x030B, 0, + 1, 0x0172, 0x0055, 0x0328, 0, + 1, 0x0173, 0x0075, 0x0328, 0, + 1, 0x0174, 0x0057, 0x0302, 0, + 1, 0x0175, 0x0077, 0x0302, 0, + 1, 0x0176, 0x0059, 0x0302, 0, + 1, 0x0177, 0x0079, 0x0302, 0, + 1, 0x0178, 0x0059, 0x0308, 0, + 1, 0x0179, 0x005A, 0x0301, 0, + 1, 0x017A, 0x007A, 0x0301, 0, + 1, 0x017B, 0x005A, 0x0307, 0, + 1, 0x017C, 0x007A, 0x0307, 0, + 1, 0x017D, 0x005A, 0x030C, 0, + 1, 0x017E, 0x007A, 0x030C, 0, + 16, 0x017F, 0x0073, 0, + 1, 0x01A0, 0x004F, 0x031B, 0, + 1, 0x01A1, 0x006F, 0x031B, 0, + 1, 0x01AF, 0x0055, 0x031B, 0, + 1, 0x01B0, 0x0075, 0x031B, 0, + 16, 0x01C4, 0x0044, 0x017D, 0, + 16, 0x01C5, 0x0044, 0x017E, 0, + 16, 0x01C6, 0x0064, 0x017E, 0, + 16, 0x01C7, 0x004C, 0x004A, 0, + 16, 0x01C8, 0x004C, 0x006A, 0, + 16, 0x01C9, 0x006C, 0x006A, 0, + 16, 0x01CA, 0x004E, 0x004A, 0, + 16, 0x01CB, 0x004E, 0x006A, 0, + 16, 0x01CC, 0x006E, 0x006A, 0, + 1, 0x01CD, 0x0041, 0x030C, 0, + 1, 0x01CE, 0x0061, 0x030C, 0, + 1, 0x01CF, 0x0049, 0x030C, 0, + 1, 0x01D0, 0x0069, 0x030C, 0, + 1, 0x01D1, 0x004F, 0x030C, 0, + 1, 0x01D2, 0x006F, 0x030C, 0, + 1, 0x01D3, 0x0055, 0x030C, 0, + 1, 0x01D4, 0x0075, 0x030C, 0, + 1, 0x01D5, 0x00DC, 0x0304, 0, + 1, 0x01D6, 0x00FC, 0x0304, 0, + 1, 0x01D7, 0x00DC, 0x0301, 0, + 1, 0x01D8, 0x00FC, 0x0301, 0, + 1, 0x01D9, 0x00DC, 0x030C, 0, + 1, 0x01DA, 0x00FC, 0x030C, 0, + 1, 0x01DB, 0x00DC, 0x0300, 0, + 1, 0x01DC, 0x00FC, 0x0300, 0, + 1, 0x01DE, 0x00C4, 0x0304, 0, + 1, 0x01DF, 0x00E4, 0x0304, 0, + 1, 0x01E0, 0x0226, 0x0304, 0, + 1, 0x01E1, 0x0227, 0x0304, 0, + 1, 0x01E2, 0x00C6, 0x0304, 0, + 1, 0x01E3, 0x00E6, 0x0304, 0, + 1, 0x01E6, 0x0047, 0x030C, 0, + 1, 0x01E7, 0x0067, 0x030C, 0, + 1, 0x01E8, 0x004B, 0x030C, 0, + 1, 0x01E9, 0x006B, 0x030C, 0, + 1, 0x01EA, 0x004F, 0x0328, 0, + 1, 0x01EB, 0x006F, 0x0328, 0, + 1, 0x01EC, 0x01EA, 0x0304, 0, + 1, 0x01ED, 0x01EB, 0x0304, 0, + 1, 0x01EE, 0x01B7, 0x030C, 0, + 1, 0x01EF, 0x0292, 0x030C, 0, + 1, 0x01F0, 0x006A, 0x030C, 0, + 16, 0x01F1, 0x0044, 0x005A, 0, + 16, 0x01F2, 0x0044, 0x007A, 0, + 16, 0x01F3, 0x0064, 0x007A, 0, + 1, 0x01F4, 0x0047, 0x0301, 0, + 1, 0x01F5, 0x0067, 0x0301, 0, + 1, 0x01F8, 0x004E, 0x0300, 0, + 1, 0x01F9, 0x006E, 0x0300, 0, + 1, 0x01FA, 0x00C5, 0x0301, 0, + 1, 0x01FB, 0x00E5, 0x0301, 0, + 1, 0x01FC, 0x00C6, 0x0301, 0, + 1, 0x01FD, 0x00E6, 0x0301, 0, + 1, 0x01FE, 0x00D8, 0x0301, 0, + 1, 0x01FF, 0x00F8, 0x0301, 0, + 1, 0x0200, 0x0041, 0x030F, 0, + 1, 0x0201, 0x0061, 0x030F, 0, + 1, 0x0202, 0x0041, 0x0311, 0, + 1, 0x0203, 0x0061, 0x0311, 0, + 1, 0x0204, 0x0045, 0x030F, 0, + 1, 0x0205, 0x0065, 0x030F, 0, + 1, 0x0206, 0x0045, 0x0311, 0, + 1, 0x0207, 0x0065, 0x0311, 0, + 1, 0x0208, 0x0049, 0x030F, 0, + 1, 0x0209, 0x0069, 0x030F, 0, + 1, 0x020A, 0x0049, 0x0311, 0, + 1, 0x020B, 0x0069, 0x0311, 0, + 1, 0x020C, 0x004F, 0x030F, 0, + 1, 0x020D, 0x006F, 0x030F, 0, + 1, 0x020E, 0x004F, 0x0311, 0, + 1, 0x020F, 0x006F, 0x0311, 0, + 1, 0x0210, 0x0052, 0x030F, 0, + 1, 0x0211, 0x0072, 0x030F, 0, + 1, 0x0212, 0x0052, 0x0311, 0, + 1, 0x0213, 0x0072, 0x0311, 0, + 1, 0x0214, 0x0055, 0x030F, 0, + 1, 0x0215, 0x0075, 0x030F, 0, + 1, 0x0216, 0x0055, 0x0311, 0, + 1, 0x0217, 0x0075, 0x0311, 0, + 1, 0x0218, 0x0053, 0x0326, 0, + 1, 0x0219, 0x0073, 0x0326, 0, + 1, 0x021A, 0x0054, 0x0326, 0, + 1, 0x021B, 0x0074, 0x0326, 0, + 1, 0x021E, 0x0048, 0x030C, 0, + 1, 0x021F, 0x0068, 0x030C, 0, + 1, 0x0226, 0x0041, 0x0307, 0, + 1, 0x0227, 0x0061, 0x0307, 0, + 1, 0x0228, 0x0045, 0x0327, 0, + 1, 0x0229, 0x0065, 0x0327, 0, + 1, 0x022A, 0x00D6, 0x0304, 0, + 1, 0x022B, 0x00F6, 0x0304, 0, + 1, 0x022C, 0x00D5, 0x0304, 0, + 1, 0x022D, 0x00F5, 0x0304, 0, + 1, 0x022E, 0x004F, 0x0307, 0, + 1, 0x022F, 0x006F, 0x0307, 0, + 1, 0x0230, 0x022E, 0x0304, 0, + 1, 0x0231, 0x022F, 0x0304, 0, + 1, 0x0232, 0x0059, 0x0304, 0, + 1, 0x0233, 0x0079, 0x0304, 0, + 9, 0x02B0, 0x0068, 0, + 9, 0x02B1, 0x0266, 0, + 9, 0x02B2, 0x006A, 0, + 9, 0x02B3, 0x0072, 0, + 9, 0x02B4, 0x0279, 0, + 9, 0x02B5, 0x027B, 0, + 9, 0x02B6, 0x0281, 0, + 9, 0x02B7, 0x0077, 0, + 9, 0x02B8, 0x0079, 0, + 16, 0x02D8, 0x0020, 0x0306, 0, + 16, 0x02D9, 0x0020, 0x0307, 0, + 16, 0x02DA, 0x0020, 0x030A, 0, + 16, 0x02DB, 0x0020, 0x0328, 0, + 16, 0x02DC, 0x0020, 0x0303, 0, + 16, 0x02DD, 0x0020, 0x030B, 0, + 9, 0x02E0, 0x0263, 0, + 9, 0x02E1, 0x006C, 0, + 9, 0x02E2, 0x0073, 0, + 9, 0x02E3, 0x0078, 0, + 9, 0x02E4, 0x0295, 0, + 1, 0x0340, 0x0300, 0, + 1, 0x0341, 0x0301, 0, + 1, 0x0343, 0x0313, 0, + 1, 0x0344, 0x0308, 0x0301, 0, + 1, 0x0374, 0x02B9, 0, + 16, 0x037A, 0x0020, 0x0345, 0, + 1, 0x037E, 0x003B, 0, + 16, 0x0384, 0x0020, 0x0301, 0, + 1, 0x0385, 0x00A8, 0x0301, 0, + 1, 0x0386, 0x0391, 0x0301, 0, + 1, 0x0387, 0x00B7, 0, + 1, 0x0388, 0x0395, 0x0301, 0, + 1, 0x0389, 0x0397, 0x0301, 0, + 1, 0x038A, 0x0399, 0x0301, 0, + 1, 0x038C, 0x039F, 0x0301, 0, + 1, 0x038E, 0x03A5, 0x0301, 0, + 1, 0x038F, 0x03A9, 0x0301, 0, + 1, 0x0390, 0x03CA, 0x0301, 0, + 1, 0x03AA, 0x0399, 0x0308, 0, + 1, 0x03AB, 0x03A5, 0x0308, 0, + 1, 0x03AC, 0x03B1, 0x0301, 0, + 1, 0x03AD, 0x03B5, 0x0301, 0, + 1, 0x03AE, 0x03B7, 0x0301, 0, + 1, 0x03AF, 0x03B9, 0x0301, 0, + 1, 0x03B0, 0x03CB, 0x0301, 0, + 1, 0x03CA, 0x03B9, 0x0308, 0, + 1, 0x03CB, 0x03C5, 0x0308, 0, + 1, 0x03CC, 0x03BF, 0x0301, 0, + 1, 0x03CD, 0x03C5, 0x0301, 0, + 1, 0x03CE, 0x03C9, 0x0301, 0, + 16, 0x03D0, 0x03B2, 0, + 16, 0x03D1, 0x03B8, 0, + 16, 0x03D2, 0x03A5, 0, + 1, 0x03D3, 0x03D2, 0x0301, 0, + 1, 0x03D4, 0x03D2, 0x0308, 0, + 16, 0x03D5, 0x03C6, 0, + 16, 0x03D6, 0x03C0, 0, + 16, 0x03F0, 0x03BA, 0, + 16, 0x03F1, 0x03C1, 0, + 16, 0x03F2, 0x03C2, 0, + 16, 0x03F4, 0x0398, 0, + 16, 0x03F5, 0x03B5, 0, + 1, 0x0400, 0x0415, 0x0300, 0, + 1, 0x0401, 0x0415, 0x0308, 0, + 1, 0x0403, 0x0413, 0x0301, 0, + 1, 0x0407, 0x0406, 0x0308, 0, + 1, 0x040C, 0x041A, 0x0301, 0, + 1, 0x040D, 0x0418, 0x0300, 0, + 1, 0x040E, 0x0423, 0x0306, 0, + 1, 0x0419, 0x0418, 0x0306, 0, + 1, 0x0439, 0x0438, 0x0306, 0, + 1, 0x0450, 0x0435, 0x0300, 0, + 1, 0x0451, 0x0435, 0x0308, 0, + 1, 0x0453, 0x0433, 0x0301, 0, + 1, 0x0457, 0x0456, 0x0308, 0, + 1, 0x045C, 0x043A, 0x0301, 0, + 1, 0x045D, 0x0438, 0x0300, 0, + 1, 0x045E, 0x0443, 0x0306, 0, + 1, 0x0476, 0x0474, 0x030F, 0, + 1, 0x0477, 0x0475, 0x030F, 0, + 1, 0x04C1, 0x0416, 0x0306, 0, + 1, 0x04C2, 0x0436, 0x0306, 0, + 1, 0x04D0, 0x0410, 0x0306, 0, + 1, 0x04D1, 0x0430, 0x0306, 0, + 1, 0x04D2, 0x0410, 0x0308, 0, + 1, 0x04D3, 0x0430, 0x0308, 0, + 1, 0x04D6, 0x0415, 0x0306, 0, + 1, 0x04D7, 0x0435, 0x0306, 0, + 1, 0x04DA, 0x04D8, 0x0308, 0, + 1, 0x04DB, 0x04D9, 0x0308, 0, + 1, 0x04DC, 0x0416, 0x0308, 0, + 1, 0x04DD, 0x0436, 0x0308, 0, + 1, 0x04DE, 0x0417, 0x0308, 0, + 1, 0x04DF, 0x0437, 0x0308, 0, + 1, 0x04E2, 0x0418, 0x0304, 0, + 1, 0x04E3, 0x0438, 0x0304, 0, + 1, 0x04E4, 0x0418, 0x0308, 0, + 1, 0x04E5, 0x0438, 0x0308, 0, + 1, 0x04E6, 0x041E, 0x0308, 0, + 1, 0x04E7, 0x043E, 0x0308, 0, + 1, 0x04EA, 0x04E8, 0x0308, 0, + 1, 0x04EB, 0x04E9, 0x0308, 0, + 1, 0x04EC, 0x042D, 0x0308, 0, + 1, 0x04ED, 0x044D, 0x0308, 0, + 1, 0x04EE, 0x0423, 0x0304, 0, + 1, 0x04EF, 0x0443, 0x0304, 0, + 1, 0x04F0, 0x0423, 0x0308, 0, + 1, 0x04F1, 0x0443, 0x0308, 0, + 1, 0x04F2, 0x0423, 0x030B, 0, + 1, 0x04F3, 0x0443, 0x030B, 0, + 1, 0x04F4, 0x0427, 0x0308, 0, + 1, 0x04F5, 0x0447, 0x0308, 0, + 1, 0x04F8, 0x042B, 0x0308, 0, + 1, 0x04F9, 0x044B, 0x0308, 0, + 16, 0x0587, 0x0565, 0x0582, 0, + 1, 0x0622, 0x0627, 0x0653, 0, + 1, 0x0623, 0x0627, 0x0654, 0, + 1, 0x0624, 0x0648, 0x0654, 0, + 1, 0x0625, 0x0627, 0x0655, 0, + 1, 0x0626, 0x064A, 0x0654, 0, + 16, 0x0675, 0x0627, 0x0674, 0, + 16, 0x0676, 0x0648, 0x0674, 0, + 16, 0x0677, 0x06C7, 0x0674, 0, + 16, 0x0678, 0x064A, 0x0674, 0, + 1, 0x06C0, 0x06D5, 0x0654, 0, + 1, 0x06C2, 0x06C1, 0x0654, 0, + 1, 0x06D3, 0x06D2, 0x0654, 0, + 1, 0x0929, 0x0928, 0x093C, 0, + 1, 0x0931, 0x0930, 0x093C, 0, + 1, 0x0934, 0x0933, 0x093C, 0, + 1, 0x0958, 0x0915, 0x093C, 0, + 1, 0x0959, 0x0916, 0x093C, 0, + 1, 0x095A, 0x0917, 0x093C, 0, + 1, 0x095B, 0x091C, 0x093C, 0, + 1, 0x095C, 0x0921, 0x093C, 0, + 1, 0x095D, 0x0922, 0x093C, 0, + 1, 0x095E, 0x092B, 0x093C, 0, + 1, 0x095F, 0x092F, 0x093C, 0, + 1, 0x09CB, 0x09C7, 0x09BE, 0, + 1, 0x09CC, 0x09C7, 0x09D7, 0, + 1, 0x09DC, 0x09A1, 0x09BC, 0, + 1, 0x09DD, 0x09A2, 0x09BC, 0, + 1, 0x09DF, 0x09AF, 0x09BC, 0, + 1, 0x0A33, 0x0A32, 0x0A3C, 0, + 1, 0x0A36, 0x0A38, 0x0A3C, 0, + 1, 0x0A59, 0x0A16, 0x0A3C, 0, + 1, 0x0A5A, 0x0A17, 0x0A3C, 0, + 1, 0x0A5B, 0x0A1C, 0x0A3C, 0, + 1, 0x0A5E, 0x0A2B, 0x0A3C, 0, + 1, 0x0B48, 0x0B47, 0x0B56, 0, + 1, 0x0B4B, 0x0B47, 0x0B3E, 0, + 1, 0x0B4C, 0x0B47, 0x0B57, 0, + 1, 0x0B5C, 0x0B21, 0x0B3C, 0, + 1, 0x0B5D, 0x0B22, 0x0B3C, 0, + 1, 0x0B94, 0x0B92, 0x0BD7, 0, + 1, 0x0BCA, 0x0BC6, 0x0BBE, 0, + 1, 0x0BCB, 0x0BC7, 0x0BBE, 0, + 1, 0x0BCC, 0x0BC6, 0x0BD7, 0, + 1, 0x0C48, 0x0C46, 0x0C56, 0, + 1, 0x0CC0, 0x0CBF, 0x0CD5, 0, + 1, 0x0CC7, 0x0CC6, 0x0CD5, 0, + 1, 0x0CC8, 0x0CC6, 0x0CD6, 0, + 1, 0x0CCA, 0x0CC6, 0x0CC2, 0, + 1, 0x0CCB, 0x0CCA, 0x0CD5, 0, + 1, 0x0D4A, 0x0D46, 0x0D3E, 0, + 1, 0x0D4B, 0x0D47, 0x0D3E, 0, + 1, 0x0D4C, 0x0D46, 0x0D57, 0, + 1, 0x0DDA, 0x0DD9, 0x0DCA, 0, + 1, 0x0DDC, 0x0DD9, 0x0DCF, 0, + 1, 0x0DDD, 0x0DDC, 0x0DCA, 0, + 1, 0x0DDE, 0x0DD9, 0x0DDF, 0, + 16, 0x0E33, 0x0E4D, 0x0E32, 0, + 16, 0x0EB3, 0x0ECD, 0x0EB2, 0, + 16, 0x0EDC, 0x0EAB, 0x0E99, 0, + 16, 0x0EDD, 0x0EAB, 0x0EA1, 0, + 3, 0x0F0C, 0x0F0B, 0, + 1, 0x0F43, 0x0F42, 0x0FB7, 0, + 1, 0x0F4D, 0x0F4C, 0x0FB7, 0, + 1, 0x0F52, 0x0F51, 0x0FB7, 0, + 1, 0x0F57, 0x0F56, 0x0FB7, 0, + 1, 0x0F5C, 0x0F5B, 0x0FB7, 0, + 1, 0x0F69, 0x0F40, 0x0FB5, 0, + 1, 0x0F73, 0x0F71, 0x0F72, 0, + 1, 0x0F75, 0x0F71, 0x0F74, 0, + 1, 0x0F76, 0x0FB2, 0x0F80, 0, + 16, 0x0F77, 0x0FB2, 0x0F81, 0, + 1, 0x0F78, 0x0FB3, 0x0F80, 0, + 16, 0x0F79, 0x0FB3, 0x0F81, 0, + 1, 0x0F81, 0x0F71, 0x0F80, 0, + 1, 0x0F93, 0x0F92, 0x0FB7, 0, + 1, 0x0F9D, 0x0F9C, 0x0FB7, 0, + 1, 0x0FA2, 0x0FA1, 0x0FB7, 0, + 1, 0x0FA7, 0x0FA6, 0x0FB7, 0, + 1, 0x0FAC, 0x0FAB, 0x0FB7, 0, + 1, 0x0FB9, 0x0F90, 0x0FB5, 0, + 1, 0x1026, 0x1025, 0x102E, 0, + 1, 0x1E00, 0x0041, 0x0325, 0, + 1, 0x1E01, 0x0061, 0x0325, 0, + 1, 0x1E02, 0x0042, 0x0307, 0, + 1, 0x1E03, 0x0062, 0x0307, 0, + 1, 0x1E04, 0x0042, 0x0323, 0, + 1, 0x1E05, 0x0062, 0x0323, 0, + 1, 0x1E06, 0x0042, 0x0331, 0, + 1, 0x1E07, 0x0062, 0x0331, 0, + 1, 0x1E08, 0x00C7, 0x0301, 0, + 1, 0x1E09, 0x00E7, 0x0301, 0, + 1, 0x1E0A, 0x0044, 0x0307, 0, + 1, 0x1E0B, 0x0064, 0x0307, 0, + 1, 0x1E0C, 0x0044, 0x0323, 0, + 1, 0x1E0D, 0x0064, 0x0323, 0, + 1, 0x1E0E, 0x0044, 0x0331, 0, + 1, 0x1E0F, 0x0064, 0x0331, 0, + 1, 0x1E10, 0x0044, 0x0327, 0, + 1, 0x1E11, 0x0064, 0x0327, 0, + 1, 0x1E12, 0x0044, 0x032D, 0, + 1, 0x1E13, 0x0064, 0x032D, 0, + 1, 0x1E14, 0x0112, 0x0300, 0, + 1, 0x1E15, 0x0113, 0x0300, 0, + 1, 0x1E16, 0x0112, 0x0301, 0, + 1, 0x1E17, 0x0113, 0x0301, 0, + 1, 0x1E18, 0x0045, 0x032D, 0, + 1, 0x1E19, 0x0065, 0x032D, 0, + 1, 0x1E1A, 0x0045, 0x0330, 0, + 1, 0x1E1B, 0x0065, 0x0330, 0, + 1, 0x1E1C, 0x0228, 0x0306, 0, + 1, 0x1E1D, 0x0229, 0x0306, 0, + 1, 0x1E1E, 0x0046, 0x0307, 0, + 1, 0x1E1F, 0x0066, 0x0307, 0, + 1, 0x1E20, 0x0047, 0x0304, 0, + 1, 0x1E21, 0x0067, 0x0304, 0, + 1, 0x1E22, 0x0048, 0x0307, 0, + 1, 0x1E23, 0x0068, 0x0307, 0, + 1, 0x1E24, 0x0048, 0x0323, 0, + 1, 0x1E25, 0x0068, 0x0323, 0, + 1, 0x1E26, 0x0048, 0x0308, 0, + 1, 0x1E27, 0x0068, 0x0308, 0, + 1, 0x1E28, 0x0048, 0x0327, 0, + 1, 0x1E29, 0x0068, 0x0327, 0, + 1, 0x1E2A, 0x0048, 0x032E, 0, + 1, 0x1E2B, 0x0068, 0x032E, 0, + 1, 0x1E2C, 0x0049, 0x0330, 0, + 1, 0x1E2D, 0x0069, 0x0330, 0, + 1, 0x1E2E, 0x00CF, 0x0301, 0, + 1, 0x1E2F, 0x00EF, 0x0301, 0, + 1, 0x1E30, 0x004B, 0x0301, 0, + 1, 0x1E31, 0x006B, 0x0301, 0, + 1, 0x1E32, 0x004B, 0x0323, 0, + 1, 0x1E33, 0x006B, 0x0323, 0, + 1, 0x1E34, 0x004B, 0x0331, 0, + 1, 0x1E35, 0x006B, 0x0331, 0, + 1, 0x1E36, 0x004C, 0x0323, 0, + 1, 0x1E37, 0x006C, 0x0323, 0, + 1, 0x1E38, 0x1E36, 0x0304, 0, + 1, 0x1E39, 0x1E37, 0x0304, 0, + 1, 0x1E3A, 0x004C, 0x0331, 0, + 1, 0x1E3B, 0x006C, 0x0331, 0, + 1, 0x1E3C, 0x004C, 0x032D, 0, + 1, 0x1E3D, 0x006C, 0x032D, 0, + 1, 0x1E3E, 0x004D, 0x0301, 0, + 1, 0x1E3F, 0x006D, 0x0301, 0, + 1, 0x1E40, 0x004D, 0x0307, 0, + 1, 0x1E41, 0x006D, 0x0307, 0, + 1, 0x1E42, 0x004D, 0x0323, 0, + 1, 0x1E43, 0x006D, 0x0323, 0, + 1, 0x1E44, 0x004E, 0x0307, 0, + 1, 0x1E45, 0x006E, 0x0307, 0, + 1, 0x1E46, 0x004E, 0x0323, 0, + 1, 0x1E47, 0x006E, 0x0323, 0, + 1, 0x1E48, 0x004E, 0x0331, 0, + 1, 0x1E49, 0x006E, 0x0331, 0, + 1, 0x1E4A, 0x004E, 0x032D, 0, + 1, 0x1E4B, 0x006E, 0x032D, 0, + 1, 0x1E4C, 0x00D5, 0x0301, 0, + 1, 0x1E4D, 0x00F5, 0x0301, 0, + 1, 0x1E4E, 0x00D5, 0x0308, 0, + 1, 0x1E4F, 0x00F5, 0x0308, 0, + 1, 0x1E50, 0x014C, 0x0300, 0, + 1, 0x1E51, 0x014D, 0x0300, 0, + 1, 0x1E52, 0x014C, 0x0301, 0, + 1, 0x1E53, 0x014D, 0x0301, 0, + 1, 0x1E54, 0x0050, 0x0301, 0, + 1, 0x1E55, 0x0070, 0x0301, 0, + 1, 0x1E56, 0x0050, 0x0307, 0, + 1, 0x1E57, 0x0070, 0x0307, 0, + 1, 0x1E58, 0x0052, 0x0307, 0, + 1, 0x1E59, 0x0072, 0x0307, 0, + 1, 0x1E5A, 0x0052, 0x0323, 0, + 1, 0x1E5B, 0x0072, 0x0323, 0, + 1, 0x1E5C, 0x1E5A, 0x0304, 0, + 1, 0x1E5D, 0x1E5B, 0x0304, 0, + 1, 0x1E5E, 0x0052, 0x0331, 0, + 1, 0x1E5F, 0x0072, 0x0331, 0, + 1, 0x1E60, 0x0053, 0x0307, 0, + 1, 0x1E61, 0x0073, 0x0307, 0, + 1, 0x1E62, 0x0053, 0x0323, 0, + 1, 0x1E63, 0x0073, 0x0323, 0, + 1, 0x1E64, 0x015A, 0x0307, 0, + 1, 0x1E65, 0x015B, 0x0307, 0, + 1, 0x1E66, 0x0160, 0x0307, 0, + 1, 0x1E67, 0x0161, 0x0307, 0, + 1, 0x1E68, 0x1E62, 0x0307, 0, + 1, 0x1E69, 0x1E63, 0x0307, 0, + 1, 0x1E6A, 0x0054, 0x0307, 0, + 1, 0x1E6B, 0x0074, 0x0307, 0, + 1, 0x1E6C, 0x0054, 0x0323, 0, + 1, 0x1E6D, 0x0074, 0x0323, 0, + 1, 0x1E6E, 0x0054, 0x0331, 0, + 1, 0x1E6F, 0x0074, 0x0331, 0, + 1, 0x1E70, 0x0054, 0x032D, 0, + 1, 0x1E71, 0x0074, 0x032D, 0, + 1, 0x1E72, 0x0055, 0x0324, 0, + 1, 0x1E73, 0x0075, 0x0324, 0, + 1, 0x1E74, 0x0055, 0x0330, 0, + 1, 0x1E75, 0x0075, 0x0330, 0, + 1, 0x1E76, 0x0055, 0x032D, 0, + 1, 0x1E77, 0x0075, 0x032D, 0, + 1, 0x1E78, 0x0168, 0x0301, 0, + 1, 0x1E79, 0x0169, 0x0301, 0, + 1, 0x1E7A, 0x016A, 0x0308, 0, + 1, 0x1E7B, 0x016B, 0x0308, 0, + 1, 0x1E7C, 0x0056, 0x0303, 0, + 1, 0x1E7D, 0x0076, 0x0303, 0, + 1, 0x1E7E, 0x0056, 0x0323, 0, + 1, 0x1E7F, 0x0076, 0x0323, 0, + 1, 0x1E80, 0x0057, 0x0300, 0, + 1, 0x1E81, 0x0077, 0x0300, 0, + 1, 0x1E82, 0x0057, 0x0301, 0, + 1, 0x1E83, 0x0077, 0x0301, 0, + 1, 0x1E84, 0x0057, 0x0308, 0, + 1, 0x1E85, 0x0077, 0x0308, 0, + 1, 0x1E86, 0x0057, 0x0307, 0, + 1, 0x1E87, 0x0077, 0x0307, 0, + 1, 0x1E88, 0x0057, 0x0323, 0, + 1, 0x1E89, 0x0077, 0x0323, 0, + 1, 0x1E8A, 0x0058, 0x0307, 0, + 1, 0x1E8B, 0x0078, 0x0307, 0, + 1, 0x1E8C, 0x0058, 0x0308, 0, + 1, 0x1E8D, 0x0078, 0x0308, 0, + 1, 0x1E8E, 0x0059, 0x0307, 0, + 1, 0x1E8F, 0x0079, 0x0307, 0, + 1, 0x1E90, 0x005A, 0x0302, 0, + 1, 0x1E91, 0x007A, 0x0302, 0, + 1, 0x1E92, 0x005A, 0x0323, 0, + 1, 0x1E93, 0x007A, 0x0323, 0, + 1, 0x1E94, 0x005A, 0x0331, 0, + 1, 0x1E95, 0x007A, 0x0331, 0, + 1, 0x1E96, 0x0068, 0x0331, 0, + 1, 0x1E97, 0x0074, 0x0308, 0, + 1, 0x1E98, 0x0077, 0x030A, 0, + 1, 0x1E99, 0x0079, 0x030A, 0, + 16, 0x1E9A, 0x0061, 0x02BE, 0, + 1, 0x1E9B, 0x017F, 0x0307, 0, + 1, 0x1EA0, 0x0041, 0x0323, 0, + 1, 0x1EA1, 0x0061, 0x0323, 0, + 1, 0x1EA2, 0x0041, 0x0309, 0, + 1, 0x1EA3, 0x0061, 0x0309, 0, + 1, 0x1EA4, 0x00C2, 0x0301, 0, + 1, 0x1EA5, 0x00E2, 0x0301, 0, + 1, 0x1EA6, 0x00C2, 0x0300, 0, + 1, 0x1EA7, 0x00E2, 0x0300, 0, + 1, 0x1EA8, 0x00C2, 0x0309, 0, + 1, 0x1EA9, 0x00E2, 0x0309, 0, + 1, 0x1EAA, 0x00C2, 0x0303, 0, + 1, 0x1EAB, 0x00E2, 0x0303, 0, + 1, 0x1EAC, 0x1EA0, 0x0302, 0, + 1, 0x1EAD, 0x1EA1, 0x0302, 0, + 1, 0x1EAE, 0x0102, 0x0301, 0, + 1, 0x1EAF, 0x0103, 0x0301, 0, + 1, 0x1EB0, 0x0102, 0x0300, 0, + 1, 0x1EB1, 0x0103, 0x0300, 0, + 1, 0x1EB2, 0x0102, 0x0309, 0, + 1, 0x1EB3, 0x0103, 0x0309, 0, + 1, 0x1EB4, 0x0102, 0x0303, 0, + 1, 0x1EB5, 0x0103, 0x0303, 0, + 1, 0x1EB6, 0x1EA0, 0x0306, 0, + 1, 0x1EB7, 0x1EA1, 0x0306, 0, + 1, 0x1EB8, 0x0045, 0x0323, 0, + 1, 0x1EB9, 0x0065, 0x0323, 0, + 1, 0x1EBA, 0x0045, 0x0309, 0, + 1, 0x1EBB, 0x0065, 0x0309, 0, + 1, 0x1EBC, 0x0045, 0x0303, 0, + 1, 0x1EBD, 0x0065, 0x0303, 0, + 1, 0x1EBE, 0x00CA, 0x0301, 0, + 1, 0x1EBF, 0x00EA, 0x0301, 0, + 1, 0x1EC0, 0x00CA, 0x0300, 0, + 1, 0x1EC1, 0x00EA, 0x0300, 0, + 1, 0x1EC2, 0x00CA, 0x0309, 0, + 1, 0x1EC3, 0x00EA, 0x0309, 0, + 1, 0x1EC4, 0x00CA, 0x0303, 0, + 1, 0x1EC5, 0x00EA, 0x0303, 0, + 1, 0x1EC6, 0x1EB8, 0x0302, 0, + 1, 0x1EC7, 0x1EB9, 0x0302, 0, + 1, 0x1EC8, 0x0049, 0x0309, 0, + 1, 0x1EC9, 0x0069, 0x0309, 0, + 1, 0x1ECA, 0x0049, 0x0323, 0, + 1, 0x1ECB, 0x0069, 0x0323, 0, + 1, 0x1ECC, 0x004F, 0x0323, 0, + 1, 0x1ECD, 0x006F, 0x0323, 0, + 1, 0x1ECE, 0x004F, 0x0309, 0, + 1, 0x1ECF, 0x006F, 0x0309, 0, + 1, 0x1ED0, 0x00D4, 0x0301, 0, + 1, 0x1ED1, 0x00F4, 0x0301, 0, + 1, 0x1ED2, 0x00D4, 0x0300, 0, + 1, 0x1ED3, 0x00F4, 0x0300, 0, + 1, 0x1ED4, 0x00D4, 0x0309, 0, + 1, 0x1ED5, 0x00F4, 0x0309, 0, + 1, 0x1ED6, 0x00D4, 0x0303, 0, + 1, 0x1ED7, 0x00F4, 0x0303, 0, + 1, 0x1ED8, 0x1ECC, 0x0302, 0, + 1, 0x1ED9, 0x1ECD, 0x0302, 0, + 1, 0x1EDA, 0x01A0, 0x0301, 0, + 1, 0x1EDB, 0x01A1, 0x0301, 0, + 1, 0x1EDC, 0x01A0, 0x0300, 0, + 1, 0x1EDD, 0x01A1, 0x0300, 0, + 1, 0x1EDE, 0x01A0, 0x0309, 0, + 1, 0x1EDF, 0x01A1, 0x0309, 0, + 1, 0x1EE0, 0x01A0, 0x0303, 0, + 1, 0x1EE1, 0x01A1, 0x0303, 0, + 1, 0x1EE2, 0x01A0, 0x0323, 0, + 1, 0x1EE3, 0x01A1, 0x0323, 0, + 1, 0x1EE4, 0x0055, 0x0323, 0, + 1, 0x1EE5, 0x0075, 0x0323, 0, + 1, 0x1EE6, 0x0055, 0x0309, 0, + 1, 0x1EE7, 0x0075, 0x0309, 0, + 1, 0x1EE8, 0x01AF, 0x0301, 0, + 1, 0x1EE9, 0x01B0, 0x0301, 0, + 1, 0x1EEA, 0x01AF, 0x0300, 0, + 1, 0x1EEB, 0x01B0, 0x0300, 0, + 1, 0x1EEC, 0x01AF, 0x0309, 0, + 1, 0x1EED, 0x01B0, 0x0309, 0, + 1, 0x1EEE, 0x01AF, 0x0303, 0, + 1, 0x1EEF, 0x01B0, 0x0303, 0, + 1, 0x1EF0, 0x01AF, 0x0323, 0, + 1, 0x1EF1, 0x01B0, 0x0323, 0, + 1, 0x1EF2, 0x0059, 0x0300, 0, + 1, 0x1EF3, 0x0079, 0x0300, 0, + 1, 0x1EF4, 0x0059, 0x0323, 0, + 1, 0x1EF5, 0x0079, 0x0323, 0, + 1, 0x1EF6, 0x0059, 0x0309, 0, + 1, 0x1EF7, 0x0079, 0x0309, 0, + 1, 0x1EF8, 0x0059, 0x0303, 0, + 1, 0x1EF9, 0x0079, 0x0303, 0, + 1, 0x1F00, 0x03B1, 0x0313, 0, + 1, 0x1F01, 0x03B1, 0x0314, 0, + 1, 0x1F02, 0x1F00, 0x0300, 0, + 1, 0x1F03, 0x1F01, 0x0300, 0, + 1, 0x1F04, 0x1F00, 0x0301, 0, + 1, 0x1F05, 0x1F01, 0x0301, 0, + 1, 0x1F06, 0x1F00, 0x0342, 0, + 1, 0x1F07, 0x1F01, 0x0342, 0, + 1, 0x1F08, 0x0391, 0x0313, 0, + 1, 0x1F09, 0x0391, 0x0314, 0, + 1, 0x1F0A, 0x1F08, 0x0300, 0, + 1, 0x1F0B, 0x1F09, 0x0300, 0, + 1, 0x1F0C, 0x1F08, 0x0301, 0, + 1, 0x1F0D, 0x1F09, 0x0301, 0, + 1, 0x1F0E, 0x1F08, 0x0342, 0, + 1, 0x1F0F, 0x1F09, 0x0342, 0, + 1, 0x1F10, 0x03B5, 0x0313, 0, + 1, 0x1F11, 0x03B5, 0x0314, 0, + 1, 0x1F12, 0x1F10, 0x0300, 0, + 1, 0x1F13, 0x1F11, 0x0300, 0, + 1, 0x1F14, 0x1F10, 0x0301, 0, + 1, 0x1F15, 0x1F11, 0x0301, 0, + 1, 0x1F18, 0x0395, 0x0313, 0, + 1, 0x1F19, 0x0395, 0x0314, 0, + 1, 0x1F1A, 0x1F18, 0x0300, 0, + 1, 0x1F1B, 0x1F19, 0x0300, 0, + 1, 0x1F1C, 0x1F18, 0x0301, 0, + 1, 0x1F1D, 0x1F19, 0x0301, 0, + 1, 0x1F20, 0x03B7, 0x0313, 0, + 1, 0x1F21, 0x03B7, 0x0314, 0, + 1, 0x1F22, 0x1F20, 0x0300, 0, + 1, 0x1F23, 0x1F21, 0x0300, 0, + 1, 0x1F24, 0x1F20, 0x0301, 0, + 1, 0x1F25, 0x1F21, 0x0301, 0, + 1, 0x1F26, 0x1F20, 0x0342, 0, + 1, 0x1F27, 0x1F21, 0x0342, 0, + 1, 0x1F28, 0x0397, 0x0313, 0, + 1, 0x1F29, 0x0397, 0x0314, 0, + 1, 0x1F2A, 0x1F28, 0x0300, 0, + 1, 0x1F2B, 0x1F29, 0x0300, 0, + 1, 0x1F2C, 0x1F28, 0x0301, 0, + 1, 0x1F2D, 0x1F29, 0x0301, 0, + 1, 0x1F2E, 0x1F28, 0x0342, 0, + 1, 0x1F2F, 0x1F29, 0x0342, 0, + 1, 0x1F30, 0x03B9, 0x0313, 0, + 1, 0x1F31, 0x03B9, 0x0314, 0, + 1, 0x1F32, 0x1F30, 0x0300, 0, + 1, 0x1F33, 0x1F31, 0x0300, 0, + 1, 0x1F34, 0x1F30, 0x0301, 0, + 1, 0x1F35, 0x1F31, 0x0301, 0, + 1, 0x1F36, 0x1F30, 0x0342, 0, + 1, 0x1F37, 0x1F31, 0x0342, 0, + 1, 0x1F38, 0x0399, 0x0313, 0, + 1, 0x1F39, 0x0399, 0x0314, 0, + 1, 0x1F3A, 0x1F38, 0x0300, 0, + 1, 0x1F3B, 0x1F39, 0x0300, 0, + 1, 0x1F3C, 0x1F38, 0x0301, 0, + 1, 0x1F3D, 0x1F39, 0x0301, 0, + 1, 0x1F3E, 0x1F38, 0x0342, 0, + 1, 0x1F3F, 0x1F39, 0x0342, 0, + 1, 0x1F40, 0x03BF, 0x0313, 0, + 1, 0x1F41, 0x03BF, 0x0314, 0, + 1, 0x1F42, 0x1F40, 0x0300, 0, + 1, 0x1F43, 0x1F41, 0x0300, 0, + 1, 0x1F44, 0x1F40, 0x0301, 0, + 1, 0x1F45, 0x1F41, 0x0301, 0, + 1, 0x1F48, 0x039F, 0x0313, 0, + 1, 0x1F49, 0x039F, 0x0314, 0, + 1, 0x1F4A, 0x1F48, 0x0300, 0, + 1, 0x1F4B, 0x1F49, 0x0300, 0, + 1, 0x1F4C, 0x1F48, 0x0301, 0, + 1, 0x1F4D, 0x1F49, 0x0301, 0, + 1, 0x1F50, 0x03C5, 0x0313, 0, + 1, 0x1F51, 0x03C5, 0x0314, 0, + 1, 0x1F52, 0x1F50, 0x0300, 0, + 1, 0x1F53, 0x1F51, 0x0300, 0, + 1, 0x1F54, 0x1F50, 0x0301, 0, + 1, 0x1F55, 0x1F51, 0x0301, 0, + 1, 0x1F56, 0x1F50, 0x0342, 0, + 1, 0x1F57, 0x1F51, 0x0342, 0, + 1, 0x1F59, 0x03A5, 0x0314, 0, + 1, 0x1F5B, 0x1F59, 0x0300, 0, + 1, 0x1F5D, 0x1F59, 0x0301, 0, + 1, 0x1F5F, 0x1F59, 0x0342, 0, + 1, 0x1F60, 0x03C9, 0x0313, 0, + 1, 0x1F61, 0x03C9, 0x0314, 0, + 1, 0x1F62, 0x1F60, 0x0300, 0, + 1, 0x1F63, 0x1F61, 0x0300, 0, + 1, 0x1F64, 0x1F60, 0x0301, 0, + 1, 0x1F65, 0x1F61, 0x0301, 0, + 1, 0x1F66, 0x1F60, 0x0342, 0, + 1, 0x1F67, 0x1F61, 0x0342, 0, + 1, 0x1F68, 0x03A9, 0x0313, 0, + 1, 0x1F69, 0x03A9, 0x0314, 0, + 1, 0x1F6A, 0x1F68, 0x0300, 0, + 1, 0x1F6B, 0x1F69, 0x0300, 0, + 1, 0x1F6C, 0x1F68, 0x0301, 0, + 1, 0x1F6D, 0x1F69, 0x0301, 0, + 1, 0x1F6E, 0x1F68, 0x0342, 0, + 1, 0x1F6F, 0x1F69, 0x0342, 0, + 1, 0x1F70, 0x03B1, 0x0300, 0, + 1, 0x1F71, 0x03AC, 0, + 1, 0x1F72, 0x03B5, 0x0300, 0, + 1, 0x1F73, 0x03AD, 0, + 1, 0x1F74, 0x03B7, 0x0300, 0, + 1, 0x1F75, 0x03AE, 0, + 1, 0x1F76, 0x03B9, 0x0300, 0, + 1, 0x1F77, 0x03AF, 0, + 1, 0x1F78, 0x03BF, 0x0300, 0, + 1, 0x1F79, 0x03CC, 0, + 1, 0x1F7A, 0x03C5, 0x0300, 0, + 1, 0x1F7B, 0x03CD, 0, + 1, 0x1F7C, 0x03C9, 0x0300, 0, + 1, 0x1F7D, 0x03CE, 0, + 1, 0x1F80, 0x1F00, 0x0345, 0, + 1, 0x1F81, 0x1F01, 0x0345, 0, + 1, 0x1F82, 0x1F02, 0x0345, 0, + 1, 0x1F83, 0x1F03, 0x0345, 0, + 1, 0x1F84, 0x1F04, 0x0345, 0, + 1, 0x1F85, 0x1F05, 0x0345, 0, + 1, 0x1F86, 0x1F06, 0x0345, 0, + 1, 0x1F87, 0x1F07, 0x0345, 0, + 1, 0x1F88, 0x1F08, 0x0345, 0, + 1, 0x1F89, 0x1F09, 0x0345, 0, + 1, 0x1F8A, 0x1F0A, 0x0345, 0, + 1, 0x1F8B, 0x1F0B, 0x0345, 0, + 1, 0x1F8C, 0x1F0C, 0x0345, 0, + 1, 0x1F8D, 0x1F0D, 0x0345, 0, + 1, 0x1F8E, 0x1F0E, 0x0345, 0, + 1, 0x1F8F, 0x1F0F, 0x0345, 0, + 1, 0x1F90, 0x1F20, 0x0345, 0, + 1, 0x1F91, 0x1F21, 0x0345, 0, + 1, 0x1F92, 0x1F22, 0x0345, 0, + 1, 0x1F93, 0x1F23, 0x0345, 0, + 1, 0x1F94, 0x1F24, 0x0345, 0, + 1, 0x1F95, 0x1F25, 0x0345, 0, + 1, 0x1F96, 0x1F26, 0x0345, 0, + 1, 0x1F97, 0x1F27, 0x0345, 0, + 1, 0x1F98, 0x1F28, 0x0345, 0, + 1, 0x1F99, 0x1F29, 0x0345, 0, + 1, 0x1F9A, 0x1F2A, 0x0345, 0, + 1, 0x1F9B, 0x1F2B, 0x0345, 0, + 1, 0x1F9C, 0x1F2C, 0x0345, 0, + 1, 0x1F9D, 0x1F2D, 0x0345, 0, + 1, 0x1F9E, 0x1F2E, 0x0345, 0, + 1, 0x1F9F, 0x1F2F, 0x0345, 0, + 1, 0x1FA0, 0x1F60, 0x0345, 0, + 1, 0x1FA1, 0x1F61, 0x0345, 0, + 1, 0x1FA2, 0x1F62, 0x0345, 0, + 1, 0x1FA3, 0x1F63, 0x0345, 0, + 1, 0x1FA4, 0x1F64, 0x0345, 0, + 1, 0x1FA5, 0x1F65, 0x0345, 0, + 1, 0x1FA6, 0x1F66, 0x0345, 0, + 1, 0x1FA7, 0x1F67, 0x0345, 0, + 1, 0x1FA8, 0x1F68, 0x0345, 0, + 1, 0x1FA9, 0x1F69, 0x0345, 0, + 1, 0x1FAA, 0x1F6A, 0x0345, 0, + 1, 0x1FAB, 0x1F6B, 0x0345, 0, + 1, 0x1FAC, 0x1F6C, 0x0345, 0, + 1, 0x1FAD, 0x1F6D, 0x0345, 0, + 1, 0x1FAE, 0x1F6E, 0x0345, 0, + 1, 0x1FAF, 0x1F6F, 0x0345, 0, + 1, 0x1FB0, 0x03B1, 0x0306, 0, + 1, 0x1FB1, 0x03B1, 0x0304, 0, + 1, 0x1FB2, 0x1F70, 0x0345, 0, + 1, 0x1FB3, 0x03B1, 0x0345, 0, + 1, 0x1FB4, 0x03AC, 0x0345, 0, + 1, 0x1FB6, 0x03B1, 0x0342, 0, + 1, 0x1FB7, 0x1FB6, 0x0345, 0, + 1, 0x1FB8, 0x0391, 0x0306, 0, + 1, 0x1FB9, 0x0391, 0x0304, 0, + 1, 0x1FBA, 0x0391, 0x0300, 0, + 1, 0x1FBB, 0x0386, 0, + 1, 0x1FBC, 0x0391, 0x0345, 0, + 16, 0x1FBD, 0x0020, 0x0313, 0, + 1, 0x1FBE, 0x03B9, 0, + 16, 0x1FBF, 0x0020, 0x0313, 0, + 16, 0x1FC0, 0x0020, 0x0342, 0, + 1, 0x1FC1, 0x00A8, 0x0342, 0, + 1, 0x1FC2, 0x1F74, 0x0345, 0, + 1, 0x1FC3, 0x03B7, 0x0345, 0, + 1, 0x1FC4, 0x03AE, 0x0345, 0, + 1, 0x1FC6, 0x03B7, 0x0342, 0, + 1, 0x1FC7, 0x1FC6, 0x0345, 0, + 1, 0x1FC8, 0x0395, 0x0300, 0, + 1, 0x1FC9, 0x0388, 0, + 1, 0x1FCA, 0x0397, 0x0300, 0, + 1, 0x1FCB, 0x0389, 0, + 1, 0x1FCC, 0x0397, 0x0345, 0, + 1, 0x1FCD, 0x1FBF, 0x0300, 0, + 1, 0x1FCE, 0x1FBF, 0x0301, 0, + 1, 0x1FCF, 0x1FBF, 0x0342, 0, + 1, 0x1FD0, 0x03B9, 0x0306, 0, + 1, 0x1FD1, 0x03B9, 0x0304, 0, + 1, 0x1FD2, 0x03CA, 0x0300, 0, + 1, 0x1FD3, 0x0390, 0, + 1, 0x1FD6, 0x03B9, 0x0342, 0, + 1, 0x1FD7, 0x03CA, 0x0342, 0, + 1, 0x1FD8, 0x0399, 0x0306, 0, + 1, 0x1FD9, 0x0399, 0x0304, 0, + 1, 0x1FDA, 0x0399, 0x0300, 0, + 1, 0x1FDB, 0x038A, 0, + 1, 0x1FDD, 0x1FFE, 0x0300, 0, + 1, 0x1FDE, 0x1FFE, 0x0301, 0, + 1, 0x1FDF, 0x1FFE, 0x0342, 0, + 1, 0x1FE0, 0x03C5, 0x0306, 0, + 1, 0x1FE1, 0x03C5, 0x0304, 0, + 1, 0x1FE2, 0x03CB, 0x0300, 0, + 1, 0x1FE3, 0x03B0, 0, + 1, 0x1FE4, 0x03C1, 0x0313, 0, + 1, 0x1FE5, 0x03C1, 0x0314, 0, + 1, 0x1FE6, 0x03C5, 0x0342, 0, + 1, 0x1FE7, 0x03CB, 0x0342, 0, + 1, 0x1FE8, 0x03A5, 0x0306, 0, + 1, 0x1FE9, 0x03A5, 0x0304, 0, + 1, 0x1FEA, 0x03A5, 0x0300, 0, + 1, 0x1FEB, 0x038E, 0, + 1, 0x1FEC, 0x03A1, 0x0314, 0, + 1, 0x1FED, 0x00A8, 0x0300, 0, + 1, 0x1FEE, 0x0385, 0, + 1, 0x1FEF, 0x0060, 0, + 1, 0x1FF2, 0x1F7C, 0x0345, 0, + 1, 0x1FF3, 0x03C9, 0x0345, 0, + 1, 0x1FF4, 0x03CE, 0x0345, 0, + 1, 0x1FF6, 0x03C9, 0x0342, 0, + 1, 0x1FF7, 0x1FF6, 0x0345, 0, + 1, 0x1FF8, 0x039F, 0x0300, 0, + 1, 0x1FF9, 0x038C, 0, + 1, 0x1FFA, 0x03A9, 0x0300, 0, + 1, 0x1FFB, 0x038F, 0, + 1, 0x1FFC, 0x03A9, 0x0345, 0, + 1, 0x1FFD, 0x00B4, 0, + 16, 0x1FFE, 0x0020, 0x0314, 0, + 1, 0x2000, 0x2002, 0, + 1, 0x2001, 0x2003, 0, + 16, 0x2002, 0x0020, 0, + 16, 0x2003, 0x0020, 0, + 16, 0x2004, 0x0020, 0, + 16, 0x2005, 0x0020, 0, + 16, 0x2006, 0x0020, 0, + 3, 0x2007, 0x0020, 0, + 16, 0x2008, 0x0020, 0, + 16, 0x2009, 0x0020, 0, + 16, 0x200A, 0x0020, 0, + 3, 0x2011, 0x2010, 0, + 16, 0x2017, 0x0020, 0x0333, 0, + 16, 0x2024, 0x002E, 0, + 16, 0x2025, 0x002E, 0x002E, 0, + 16, 0x2026, 0x002E, 0x002E, 0x002E, 0, + 3, 0x202F, 0x0020, 0, + 16, 0x2033, 0x2032, 0x2032, 0, + 16, 0x2034, 0x2032, 0x2032, 0x2032, 0, + 16, 0x2036, 0x2035, 0x2035, 0, + 16, 0x2037, 0x2035, 0x2035, 0x2035, 0, + 16, 0x203C, 0x0021, 0x0021, 0, + 16, 0x203E, 0x0020, 0x0305, 0, + 16, 0x2047, 0x003F, 0x003F, 0, + 16, 0x2048, 0x003F, 0x0021, 0, + 16, 0x2049, 0x0021, 0x003F, 0, + 16, 0x2057, 0x2032, 0x2032, 0x2032, 0x2032, 0, + 16, 0x205F, 0x0020, 0, + 9, 0x2070, 0x0030, 0, + 9, 0x2071, 0x0069, 0, + 9, 0x2074, 0x0034, 0, + 9, 0x2075, 0x0035, 0, + 9, 0x2076, 0x0036, 0, + 9, 0x2077, 0x0037, 0, + 9, 0x2078, 0x0038, 0, + 9, 0x2079, 0x0039, 0, + 9, 0x207A, 0x002B, 0, + 9, 0x207B, 0x2212, 0, + 9, 0x207C, 0x003D, 0, + 9, 0x207D, 0x0028, 0, + 9, 0x207E, 0x0029, 0, + 9, 0x207F, 0x006E, 0, + 10, 0x2080, 0x0030, 0, + 10, 0x2081, 0x0031, 0, + 10, 0x2082, 0x0032, 0, + 10, 0x2083, 0x0033, 0, + 10, 0x2084, 0x0034, 0, + 10, 0x2085, 0x0035, 0, + 10, 0x2086, 0x0036, 0, + 10, 0x2087, 0x0037, 0, + 10, 0x2088, 0x0038, 0, + 10, 0x2089, 0x0039, 0, + 10, 0x208A, 0x002B, 0, + 10, 0x208B, 0x2212, 0, + 10, 0x208C, 0x003D, 0, + 10, 0x208D, 0x0028, 0, + 10, 0x208E, 0x0029, 0, + 16, 0x20A8, 0x0052, 0x0073, 0, + 16, 0x2100, 0x0061, 0x002F, 0x0063, 0, + 16, 0x2101, 0x0061, 0x002F, 0x0073, 0, + 2, 0x2102, 0x0043, 0, + 16, 0x2103, 0x00B0, 0x0043, 0, + 16, 0x2105, 0x0063, 0x002F, 0x006F, 0, + 16, 0x2106, 0x0063, 0x002F, 0x0075, 0, + 16, 0x2107, 0x0190, 0, + 16, 0x2109, 0x00B0, 0x0046, 0, + 2, 0x210A, 0x0067, 0, + 2, 0x210B, 0x0048, 0, + 2, 0x210C, 0x0048, 0, + 2, 0x210D, 0x0048, 0, + 2, 0x210E, 0x0068, 0, + 2, 0x210F, 0x0127, 0, + 2, 0x2110, 0x0049, 0, + 2, 0x2111, 0x0049, 0, + 2, 0x2112, 0x004C, 0, + 2, 0x2113, 0x006C, 0, + 2, 0x2115, 0x004E, 0, + 16, 0x2116, 0x004E, 0x006F, 0, + 2, 0x2119, 0x0050, 0, + 2, 0x211A, 0x0051, 0, + 2, 0x211B, 0x0052, 0, + 2, 0x211C, 0x0052, 0, + 2, 0x211D, 0x0052, 0, + 9, 0x2120, 0x0053, 0x004D, 0, + 16, 0x2121, 0x0054, 0x0045, 0x004C, 0, + 9, 0x2122, 0x0054, 0x004D, 0, + 2, 0x2124, 0x005A, 0, + 1, 0x2126, 0x03A9, 0, + 2, 0x2128, 0x005A, 0, + 1, 0x212A, 0x004B, 0, + 1, 0x212B, 0x00C5, 0, + 2, 0x212C, 0x0042, 0, + 2, 0x212D, 0x0043, 0, + 2, 0x212F, 0x0065, 0, + 2, 0x2130, 0x0045, 0, + 2, 0x2131, 0x0046, 0, + 2, 0x2133, 0x004D, 0, + 2, 0x2134, 0x006F, 0, + 16, 0x2135, 0x05D0, 0, + 16, 0x2136, 0x05D1, 0, + 16, 0x2137, 0x05D2, 0, + 16, 0x2138, 0x05D3, 0, + 2, 0x2139, 0x0069, 0, + 2, 0x213D, 0x03B3, 0, + 2, 0x213E, 0x0393, 0, + 2, 0x213F, 0x03A0, 0, + 2, 0x2140, 0x2211, 0, + 2, 0x2145, 0x0044, 0, + 2, 0x2146, 0x0064, 0, + 2, 0x2147, 0x0065, 0, + 2, 0x2148, 0x0069, 0, + 2, 0x2149, 0x006A, 0, + 17, 0x2153, 0x0031, 0x2044, 0x0033, 0, + 17, 0x2154, 0x0032, 0x2044, 0x0033, 0, + 17, 0x2155, 0x0031, 0x2044, 0x0035, 0, + 17, 0x2156, 0x0032, 0x2044, 0x0035, 0, + 17, 0x2157, 0x0033, 0x2044, 0x0035, 0, + 17, 0x2158, 0x0034, 0x2044, 0x0035, 0, + 17, 0x2159, 0x0031, 0x2044, 0x0036, 0, + 17, 0x215A, 0x0035, 0x2044, 0x0036, 0, + 17, 0x215B, 0x0031, 0x2044, 0x0038, 0, + 17, 0x215C, 0x0033, 0x2044, 0x0038, 0, + 17, 0x215D, 0x0035, 0x2044, 0x0038, 0, + 17, 0x215E, 0x0037, 0x2044, 0x0038, 0, + 17, 0x215F, 0x0031, 0x2044, 0, + 16, 0x2160, 0x0049, 0, + 16, 0x2161, 0x0049, 0x0049, 0, + 16, 0x2162, 0x0049, 0x0049, 0x0049, 0, + 16, 0x2163, 0x0049, 0x0056, 0, + 16, 0x2164, 0x0056, 0, + 16, 0x2165, 0x0056, 0x0049, 0, + 16, 0x2166, 0x0056, 0x0049, 0x0049, 0, + 16, 0x2167, 0x0056, 0x0049, 0x0049, 0x0049, 0, + 16, 0x2168, 0x0049, 0x0058, 0, + 16, 0x2169, 0x0058, 0, + 16, 0x216A, 0x0058, 0x0049, 0, + 16, 0x216B, 0x0058, 0x0049, 0x0049, 0, + 16, 0x216C, 0x004C, 0, + 16, 0x216D, 0x0043, 0, + 16, 0x216E, 0x0044, 0, + 16, 0x216F, 0x004D, 0, + 16, 0x2170, 0x0069, 0, + 16, 0x2171, 0x0069, 0x0069, 0, + 16, 0x2172, 0x0069, 0x0069, 0x0069, 0, + 16, 0x2173, 0x0069, 0x0076, 0, + 16, 0x2174, 0x0076, 0, + 16, 0x2175, 0x0076, 0x0069, 0, + 16, 0x2176, 0x0076, 0x0069, 0x0069, 0, + 16, 0x2177, 0x0076, 0x0069, 0x0069, 0x0069, 0, + 16, 0x2178, 0x0069, 0x0078, 0, + 16, 0x2179, 0x0078, 0, + 16, 0x217A, 0x0078, 0x0069, 0, + 16, 0x217B, 0x0078, 0x0069, 0x0069, 0, + 16, 0x217C, 0x006C, 0, + 16, 0x217D, 0x0063, 0, + 16, 0x217E, 0x0064, 0, + 16, 0x217F, 0x006D, 0, + 1, 0x219A, 0x2190, 0x0338, 0, + 1, 0x219B, 0x2192, 0x0338, 0, + 1, 0x21AE, 0x2194, 0x0338, 0, + 1, 0x21CD, 0x21D0, 0x0338, 0, + 1, 0x21CE, 0x21D4, 0x0338, 0, + 1, 0x21CF, 0x21D2, 0x0338, 0, + 1, 0x2204, 0x2203, 0x0338, 0, + 1, 0x2209, 0x2208, 0x0338, 0, + 1, 0x220C, 0x220B, 0x0338, 0, + 1, 0x2224, 0x2223, 0x0338, 0, + 1, 0x2226, 0x2225, 0x0338, 0, + 16, 0x222C, 0x222B, 0x222B, 0, + 16, 0x222D, 0x222B, 0x222B, 0x222B, 0, + 16, 0x222F, 0x222E, 0x222E, 0, + 16, 0x2230, 0x222E, 0x222E, 0x222E, 0, + 1, 0x2241, 0x223C, 0x0338, 0, + 1, 0x2244, 0x2243, 0x0338, 0, + 1, 0x2247, 0x2245, 0x0338, 0, + 1, 0x2249, 0x2248, 0x0338, 0, + 1, 0x2260, 0x003D, 0x0338, 0, + 1, 0x2262, 0x2261, 0x0338, 0, + 1, 0x226D, 0x224D, 0x0338, 0, + 1, 0x226E, 0x003C, 0x0338, 0, + 1, 0x226F, 0x003E, 0x0338, 0, + 1, 0x2270, 0x2264, 0x0338, 0, + 1, 0x2271, 0x2265, 0x0338, 0, + 1, 0x2274, 0x2272, 0x0338, 0, + 1, 0x2275, 0x2273, 0x0338, 0, + 1, 0x2278, 0x2276, 0x0338, 0, + 1, 0x2279, 0x2277, 0x0338, 0, + 1, 0x2280, 0x227A, 0x0338, 0, + 1, 0x2281, 0x227B, 0x0338, 0, + 1, 0x2284, 0x2282, 0x0338, 0, + 1, 0x2285, 0x2283, 0x0338, 0, + 1, 0x2288, 0x2286, 0x0338, 0, + 1, 0x2289, 0x2287, 0x0338, 0, + 1, 0x22AC, 0x22A2, 0x0338, 0, + 1, 0x22AD, 0x22A8, 0x0338, 0, + 1, 0x22AE, 0x22A9, 0x0338, 0, + 1, 0x22AF, 0x22AB, 0x0338, 0, + 1, 0x22E0, 0x227C, 0x0338, 0, + 1, 0x22E1, 0x227D, 0x0338, 0, + 1, 0x22E2, 0x2291, 0x0338, 0, + 1, 0x22E3, 0x2292, 0x0338, 0, + 1, 0x22EA, 0x22B2, 0x0338, 0, + 1, 0x22EB, 0x22B3, 0x0338, 0, + 1, 0x22EC, 0x22B4, 0x0338, 0, + 1, 0x22ED, 0x22B5, 0x0338, 0, + 1, 0x2329, 0x3008, 0, + 1, 0x232A, 0x3009, 0, + 8, 0x2460, 0x0031, 0, + 8, 0x2461, 0x0032, 0, + 8, 0x2462, 0x0033, 0, + 8, 0x2463, 0x0034, 0, + 8, 0x2464, 0x0035, 0, + 8, 0x2465, 0x0036, 0, + 8, 0x2466, 0x0037, 0, + 8, 0x2467, 0x0038, 0, + 8, 0x2468, 0x0039, 0, + 8, 0x2469, 0x0031, 0x0030, 0, + 8, 0x246A, 0x0031, 0x0031, 0, + 8, 0x246B, 0x0031, 0x0032, 0, + 8, 0x246C, 0x0031, 0x0033, 0, + 8, 0x246D, 0x0031, 0x0034, 0, + 8, 0x246E, 0x0031, 0x0035, 0, + 8, 0x246F, 0x0031, 0x0036, 0, + 8, 0x2470, 0x0031, 0x0037, 0, + 8, 0x2471, 0x0031, 0x0038, 0, + 8, 0x2472, 0x0031, 0x0039, 0, + 8, 0x2473, 0x0032, 0x0030, 0, + 16, 0x2474, 0x0028, 0x0031, 0x0029, 0, + 16, 0x2475, 0x0028, 0x0032, 0x0029, 0, + 16, 0x2476, 0x0028, 0x0033, 0x0029, 0, + 16, 0x2477, 0x0028, 0x0034, 0x0029, 0, + 16, 0x2478, 0x0028, 0x0035, 0x0029, 0, + 16, 0x2479, 0x0028, 0x0036, 0x0029, 0, + 16, 0x247A, 0x0028, 0x0037, 0x0029, 0, + 16, 0x247B, 0x0028, 0x0038, 0x0029, 0, + 16, 0x247C, 0x0028, 0x0039, 0x0029, 0, + 16, 0x247D, 0x0028, 0x0031, 0x0030, 0x0029, 0, + 16, 0x247E, 0x0028, 0x0031, 0x0031, 0x0029, 0, + 16, 0x247F, 0x0028, 0x0031, 0x0032, 0x0029, 0, + 16, 0x2480, 0x0028, 0x0031, 0x0033, 0x0029, 0, + 16, 0x2481, 0x0028, 0x0031, 0x0034, 0x0029, 0, + 16, 0x2482, 0x0028, 0x0031, 0x0035, 0x0029, 0, + 16, 0x2483, 0x0028, 0x0031, 0x0036, 0x0029, 0, + 16, 0x2484, 0x0028, 0x0031, 0x0037, 0x0029, 0, + 16, 0x2485, 0x0028, 0x0031, 0x0038, 0x0029, 0, + 16, 0x2486, 0x0028, 0x0031, 0x0039, 0x0029, 0, + 16, 0x2487, 0x0028, 0x0032, 0x0030, 0x0029, 0, + 16, 0x2488, 0x0031, 0x002E, 0, + 16, 0x2489, 0x0032, 0x002E, 0, + 16, 0x248A, 0x0033, 0x002E, 0, + 16, 0x248B, 0x0034, 0x002E, 0, + 16, 0x248C, 0x0035, 0x002E, 0, + 16, 0x248D, 0x0036, 0x002E, 0, + 16, 0x248E, 0x0037, 0x002E, 0, + 16, 0x248F, 0x0038, 0x002E, 0, + 16, 0x2490, 0x0039, 0x002E, 0, + 16, 0x2491, 0x0031, 0x0030, 0x002E, 0, + 16, 0x2492, 0x0031, 0x0031, 0x002E, 0, + 16, 0x2493, 0x0031, 0x0032, 0x002E, 0, + 16, 0x2494, 0x0031, 0x0033, 0x002E, 0, + 16, 0x2495, 0x0031, 0x0034, 0x002E, 0, + 16, 0x2496, 0x0031, 0x0035, 0x002E, 0, + 16, 0x2497, 0x0031, 0x0036, 0x002E, 0, + 16, 0x2498, 0x0031, 0x0037, 0x002E, 0, + 16, 0x2499, 0x0031, 0x0038, 0x002E, 0, + 16, 0x249A, 0x0031, 0x0039, 0x002E, 0, + 16, 0x249B, 0x0032, 0x0030, 0x002E, 0, + 16, 0x249C, 0x0028, 0x0061, 0x0029, 0, + 16, 0x249D, 0x0028, 0x0062, 0x0029, 0, + 16, 0x249E, 0x0028, 0x0063, 0x0029, 0, + 16, 0x249F, 0x0028, 0x0064, 0x0029, 0, + 16, 0x24A0, 0x0028, 0x0065, 0x0029, 0, + 16, 0x24A1, 0x0028, 0x0066, 0x0029, 0, + 16, 0x24A2, 0x0028, 0x0067, 0x0029, 0, + 16, 0x24A3, 0x0028, 0x0068, 0x0029, 0, + 16, 0x24A4, 0x0028, 0x0069, 0x0029, 0, + 16, 0x24A5, 0x0028, 0x006A, 0x0029, 0, + 16, 0x24A6, 0x0028, 0x006B, 0x0029, 0, + 16, 0x24A7, 0x0028, 0x006C, 0x0029, 0, + 16, 0x24A8, 0x0028, 0x006D, 0x0029, 0, + 16, 0x24A9, 0x0028, 0x006E, 0x0029, 0, + 16, 0x24AA, 0x0028, 0x006F, 0x0029, 0, + 16, 0x24AB, 0x0028, 0x0070, 0x0029, 0, + 16, 0x24AC, 0x0028, 0x0071, 0x0029, 0, + 16, 0x24AD, 0x0028, 0x0072, 0x0029, 0, + 16, 0x24AE, 0x0028, 0x0073, 0x0029, 0, + 16, 0x24AF, 0x0028, 0x0074, 0x0029, 0, + 16, 0x24B0, 0x0028, 0x0075, 0x0029, 0, + 16, 0x24B1, 0x0028, 0x0076, 0x0029, 0, + 16, 0x24B2, 0x0028, 0x0077, 0x0029, 0, + 16, 0x24B3, 0x0028, 0x0078, 0x0029, 0, + 16, 0x24B4, 0x0028, 0x0079, 0x0029, 0, + 16, 0x24B5, 0x0028, 0x007A, 0x0029, 0, + 8, 0x24B6, 0x0041, 0, + 8, 0x24B7, 0x0042, 0, + 8, 0x24B8, 0x0043, 0, + 8, 0x24B9, 0x0044, 0, + 8, 0x24BA, 0x0045, 0, + 8, 0x24BB, 0x0046, 0, + 8, 0x24BC, 0x0047, 0, + 8, 0x24BD, 0x0048, 0, + 8, 0x24BE, 0x0049, 0, + 8, 0x24BF, 0x004A, 0, + 8, 0x24C0, 0x004B, 0, + 8, 0x24C1, 0x004C, 0, + 8, 0x24C2, 0x004D, 0, + 8, 0x24C3, 0x004E, 0, + 8, 0x24C4, 0x004F, 0, + 8, 0x24C5, 0x0050, 0, + 8, 0x24C6, 0x0051, 0, + 8, 0x24C7, 0x0052, 0, + 8, 0x24C8, 0x0053, 0, + 8, 0x24C9, 0x0054, 0, + 8, 0x24CA, 0x0055, 0, + 8, 0x24CB, 0x0056, 0, + 8, 0x24CC, 0x0057, 0, + 8, 0x24CD, 0x0058, 0, + 8, 0x24CE, 0x0059, 0, + 8, 0x24CF, 0x005A, 0, + 8, 0x24D0, 0x0061, 0, + 8, 0x24D1, 0x0062, 0, + 8, 0x24D2, 0x0063, 0, + 8, 0x24D3, 0x0064, 0, + 8, 0x24D4, 0x0065, 0, + 8, 0x24D5, 0x0066, 0, + 8, 0x24D6, 0x0067, 0, + 8, 0x24D7, 0x0068, 0, + 8, 0x24D8, 0x0069, 0, + 8, 0x24D9, 0x006A, 0, + 8, 0x24DA, 0x006B, 0, + 8, 0x24DB, 0x006C, 0, + 8, 0x24DC, 0x006D, 0, + 8, 0x24DD, 0x006E, 0, + 8, 0x24DE, 0x006F, 0, + 8, 0x24DF, 0x0070, 0, + 8, 0x24E0, 0x0071, 0, + 8, 0x24E1, 0x0072, 0, + 8, 0x24E2, 0x0073, 0, + 8, 0x24E3, 0x0074, 0, + 8, 0x24E4, 0x0075, 0, + 8, 0x24E5, 0x0076, 0, + 8, 0x24E6, 0x0077, 0, + 8, 0x24E7, 0x0078, 0, + 8, 0x24E8, 0x0079, 0, + 8, 0x24E9, 0x007A, 0, + 8, 0x24EA, 0x0030, 0, + 16, 0x2A0C, 0x222B, 0x222B, 0x222B, 0x222B, 0, + 16, 0x2A74, 0x003A, 0x003A, 0x003D, 0, + 16, 0x2A75, 0x003D, 0x003D, 0, + 16, 0x2A76, 0x003D, 0x003D, 0x003D, 0, + 1, 0x2ADC, 0x2ADD, 0x0338, 0, + 16, 0x2E9F, 0x6BCD, 0, + 16, 0x2EF3, 0x9F9F, 0, + 16, 0x2F00, 0x4E00, 0, + 16, 0x2F01, 0x4E28, 0, + 16, 0x2F02, 0x4E36, 0, + 16, 0x2F03, 0x4E3F, 0, + 16, 0x2F04, 0x4E59, 0, + 16, 0x2F05, 0x4E85, 0, + 16, 0x2F06, 0x4E8C, 0, + 16, 0x2F07, 0x4EA0, 0, + 16, 0x2F08, 0x4EBA, 0, + 16, 0x2F09, 0x513F, 0, + 16, 0x2F0A, 0x5165, 0, + 16, 0x2F0B, 0x516B, 0, + 16, 0x2F0C, 0x5182, 0, + 16, 0x2F0D, 0x5196, 0, + 16, 0x2F0E, 0x51AB, 0, + 16, 0x2F0F, 0x51E0, 0, + 16, 0x2F10, 0x51F5, 0, + 16, 0x2F11, 0x5200, 0, + 16, 0x2F12, 0x529B, 0, + 16, 0x2F13, 0x52F9, 0, + 16, 0x2F14, 0x5315, 0, + 16, 0x2F15, 0x531A, 0, + 16, 0x2F16, 0x5338, 0, + 16, 0x2F17, 0x5341, 0, + 16, 0x2F18, 0x535C, 0, + 16, 0x2F19, 0x5369, 0, + 16, 0x2F1A, 0x5382, 0, + 16, 0x2F1B, 0x53B6, 0, + 16, 0x2F1C, 0x53C8, 0, + 16, 0x2F1D, 0x53E3, 0, + 16, 0x2F1E, 0x56D7, 0, + 16, 0x2F1F, 0x571F, 0, + 16, 0x2F20, 0x58EB, 0, + 16, 0x2F21, 0x5902, 0, + 16, 0x2F22, 0x590A, 0, + 16, 0x2F23, 0x5915, 0, + 16, 0x2F24, 0x5927, 0, + 16, 0x2F25, 0x5973, 0, + 16, 0x2F26, 0x5B50, 0, + 16, 0x2F27, 0x5B80, 0, + 16, 0x2F28, 0x5BF8, 0, + 16, 0x2F29, 0x5C0F, 0, + 16, 0x2F2A, 0x5C22, 0, + 16, 0x2F2B, 0x5C38, 0, + 16, 0x2F2C, 0x5C6E, 0, + 16, 0x2F2D, 0x5C71, 0, + 16, 0x2F2E, 0x5DDB, 0, + 16, 0x2F2F, 0x5DE5, 0, + 16, 0x2F30, 0x5DF1, 0, + 16, 0x2F31, 0x5DFE, 0, + 16, 0x2F32, 0x5E72, 0, + 16, 0x2F33, 0x5E7A, 0, + 16, 0x2F34, 0x5E7F, 0, + 16, 0x2F35, 0x5EF4, 0, + 16, 0x2F36, 0x5EFE, 0, + 16, 0x2F37, 0x5F0B, 0, + 16, 0x2F38, 0x5F13, 0, + 16, 0x2F39, 0x5F50, 0, + 16, 0x2F3A, 0x5F61, 0, + 16, 0x2F3B, 0x5F73, 0, + 16, 0x2F3C, 0x5FC3, 0, + 16, 0x2F3D, 0x6208, 0, + 16, 0x2F3E, 0x6236, 0, + 16, 0x2F3F, 0x624B, 0, + 16, 0x2F40, 0x652F, 0, + 16, 0x2F41, 0x6534, 0, + 16, 0x2F42, 0x6587, 0, + 16, 0x2F43, 0x6597, 0, + 16, 0x2F44, 0x65A4, 0, + 16, 0x2F45, 0x65B9, 0, + 16, 0x2F46, 0x65E0, 0, + 16, 0x2F47, 0x65E5, 0, + 16, 0x2F48, 0x66F0, 0, + 16, 0x2F49, 0x6708, 0, + 16, 0x2F4A, 0x6728, 0, + 16, 0x2F4B, 0x6B20, 0, + 16, 0x2F4C, 0x6B62, 0, + 16, 0x2F4D, 0x6B79, 0, + 16, 0x2F4E, 0x6BB3, 0, + 16, 0x2F4F, 0x6BCB, 0, + 16, 0x2F50, 0x6BD4, 0, + 16, 0x2F51, 0x6BDB, 0, + 16, 0x2F52, 0x6C0F, 0, + 16, 0x2F53, 0x6C14, 0, + 16, 0x2F54, 0x6C34, 0, + 16, 0x2F55, 0x706B, 0, + 16, 0x2F56, 0x722A, 0, + 16, 0x2F57, 0x7236, 0, + 16, 0x2F58, 0x723B, 0, + 16, 0x2F59, 0x723F, 0, + 16, 0x2F5A, 0x7247, 0, + 16, 0x2F5B, 0x7259, 0, + 16, 0x2F5C, 0x725B, 0, + 16, 0x2F5D, 0x72AC, 0, + 16, 0x2F5E, 0x7384, 0, + 16, 0x2F5F, 0x7389, 0, + 16, 0x2F60, 0x74DC, 0, + 16, 0x2F61, 0x74E6, 0, + 16, 0x2F62, 0x7518, 0, + 16, 0x2F63, 0x751F, 0, + 16, 0x2F64, 0x7528, 0, + 16, 0x2F65, 0x7530, 0, + 16, 0x2F66, 0x758B, 0, + 16, 0x2F67, 0x7592, 0, + 16, 0x2F68, 0x7676, 0, + 16, 0x2F69, 0x767D, 0, + 16, 0x2F6A, 0x76AE, 0, + 16, 0x2F6B, 0x76BF, 0, + 16, 0x2F6C, 0x76EE, 0, + 16, 0x2F6D, 0x77DB, 0, + 16, 0x2F6E, 0x77E2, 0, + 16, 0x2F6F, 0x77F3, 0, + 16, 0x2F70, 0x793A, 0, + 16, 0x2F71, 0x79B8, 0, + 16, 0x2F72, 0x79BE, 0, + 16, 0x2F73, 0x7A74, 0, + 16, 0x2F74, 0x7ACB, 0, + 16, 0x2F75, 0x7AF9, 0, + 16, 0x2F76, 0x7C73, 0, + 16, 0x2F77, 0x7CF8, 0, + 16, 0x2F78, 0x7F36, 0, + 16, 0x2F79, 0x7F51, 0, + 16, 0x2F7A, 0x7F8A, 0, + 16, 0x2F7B, 0x7FBD, 0, + 16, 0x2F7C, 0x8001, 0, + 16, 0x2F7D, 0x800C, 0, + 16, 0x2F7E, 0x8012, 0, + 16, 0x2F7F, 0x8033, 0, + 16, 0x2F80, 0x807F, 0, + 16, 0x2F81, 0x8089, 0, + 16, 0x2F82, 0x81E3, 0, + 16, 0x2F83, 0x81EA, 0, + 16, 0x2F84, 0x81F3, 0, + 16, 0x2F85, 0x81FC, 0, + 16, 0x2F86, 0x820C, 0, + 16, 0x2F87, 0x821B, 0, + 16, 0x2F88, 0x821F, 0, + 16, 0x2F89, 0x826E, 0, + 16, 0x2F8A, 0x8272, 0, + 16, 0x2F8B, 0x8278, 0, + 16, 0x2F8C, 0x864D, 0, + 16, 0x2F8D, 0x866B, 0, + 16, 0x2F8E, 0x8840, 0, + 16, 0x2F8F, 0x884C, 0, + 16, 0x2F90, 0x8863, 0, + 16, 0x2F91, 0x897E, 0, + 16, 0x2F92, 0x898B, 0, + 16, 0x2F93, 0x89D2, 0, + 16, 0x2F94, 0x8A00, 0, + 16, 0x2F95, 0x8C37, 0, + 16, 0x2F96, 0x8C46, 0, + 16, 0x2F97, 0x8C55, 0, + 16, 0x2F98, 0x8C78, 0, + 16, 0x2F99, 0x8C9D, 0, + 16, 0x2F9A, 0x8D64, 0, + 16, 0x2F9B, 0x8D70, 0, + 16, 0x2F9C, 0x8DB3, 0, + 16, 0x2F9D, 0x8EAB, 0, + 16, 0x2F9E, 0x8ECA, 0, + 16, 0x2F9F, 0x8F9B, 0, + 16, 0x2FA0, 0x8FB0, 0, + 16, 0x2FA1, 0x8FB5, 0, + 16, 0x2FA2, 0x9091, 0, + 16, 0x2FA3, 0x9149, 0, + 16, 0x2FA4, 0x91C6, 0, + 16, 0x2FA5, 0x91CC, 0, + 16, 0x2FA6, 0x91D1, 0, + 16, 0x2FA7, 0x9577, 0, + 16, 0x2FA8, 0x9580, 0, + 16, 0x2FA9, 0x961C, 0, + 16, 0x2FAA, 0x96B6, 0, + 16, 0x2FAB, 0x96B9, 0, + 16, 0x2FAC, 0x96E8, 0, + 16, 0x2FAD, 0x9751, 0, + 16, 0x2FAE, 0x975E, 0, + 16, 0x2FAF, 0x9762, 0, + 16, 0x2FB0, 0x9769, 0, + 16, 0x2FB1, 0x97CB, 0, + 16, 0x2FB2, 0x97ED, 0, + 16, 0x2FB3, 0x97F3, 0, + 16, 0x2FB4, 0x9801, 0, + 16, 0x2FB5, 0x98A8, 0, + 16, 0x2FB6, 0x98DB, 0, + 16, 0x2FB7, 0x98DF, 0, + 16, 0x2FB8, 0x9996, 0, + 16, 0x2FB9, 0x9999, 0, + 16, 0x2FBA, 0x99AC, 0, + 16, 0x2FBB, 0x9AA8, 0, + 16, 0x2FBC, 0x9AD8, 0, + 16, 0x2FBD, 0x9ADF, 0, + 16, 0x2FBE, 0x9B25, 0, + 16, 0x2FBF, 0x9B2F, 0, + 16, 0x2FC0, 0x9B32, 0, + 16, 0x2FC1, 0x9B3C, 0, + 16, 0x2FC2, 0x9B5A, 0, + 16, 0x2FC3, 0x9CE5, 0, + 16, 0x2FC4, 0x9E75, 0, + 16, 0x2FC5, 0x9E7F, 0, + 16, 0x2FC6, 0x9EA5, 0, + 16, 0x2FC7, 0x9EBB, 0, + 16, 0x2FC8, 0x9EC3, 0, + 16, 0x2FC9, 0x9ECD, 0, + 16, 0x2FCA, 0x9ED1, 0, + 16, 0x2FCB, 0x9EF9, 0, + 16, 0x2FCC, 0x9EFD, 0, + 16, 0x2FCD, 0x9F0E, 0, + 16, 0x2FCE, 0x9F13, 0, + 16, 0x2FCF, 0x9F20, 0, + 16, 0x2FD0, 0x9F3B, 0, + 16, 0x2FD1, 0x9F4A, 0, + 16, 0x2FD2, 0x9F52, 0, + 16, 0x2FD3, 0x9F8D, 0, + 16, 0x2FD4, 0x9F9C, 0, + 16, 0x2FD5, 0x9FA0, 0, + 12, 0x3000, 0x0020, 0, + 16, 0x3036, 0x3012, 0, + 16, 0x3038, 0x5341, 0, + 16, 0x3039, 0x5344, 0, + 16, 0x303A, 0x5345, 0, + 1, 0x304C, 0x304B, 0x3099, 0, + 1, 0x304E, 0x304D, 0x3099, 0, + 1, 0x3050, 0x304F, 0x3099, 0, + 1, 0x3052, 0x3051, 0x3099, 0, + 1, 0x3054, 0x3053, 0x3099, 0, + 1, 0x3056, 0x3055, 0x3099, 0, + 1, 0x3058, 0x3057, 0x3099, 0, + 1, 0x305A, 0x3059, 0x3099, 0, + 1, 0x305C, 0x305B, 0x3099, 0, + 1, 0x305E, 0x305D, 0x3099, 0, + 1, 0x3060, 0x305F, 0x3099, 0, + 1, 0x3062, 0x3061, 0x3099, 0, + 1, 0x3065, 0x3064, 0x3099, 0, + 1, 0x3067, 0x3066, 0x3099, 0, + 1, 0x3069, 0x3068, 0x3099, 0, + 1, 0x3070, 0x306F, 0x3099, 0, + 1, 0x3071, 0x306F, 0x309A, 0, + 1, 0x3073, 0x3072, 0x3099, 0, + 1, 0x3074, 0x3072, 0x309A, 0, + 1, 0x3076, 0x3075, 0x3099, 0, + 1, 0x3077, 0x3075, 0x309A, 0, + 1, 0x3079, 0x3078, 0x3099, 0, + 1, 0x307A, 0x3078, 0x309A, 0, + 1, 0x307C, 0x307B, 0x3099, 0, + 1, 0x307D, 0x307B, 0x309A, 0, + 1, 0x3094, 0x3046, 0x3099, 0, + 16, 0x309B, 0x0020, 0x3099, 0, + 16, 0x309C, 0x0020, 0x309A, 0, + 1, 0x309E, 0x309D, 0x3099, 0, + 11, 0x309F, 0x3088, 0x308A, 0, + 1, 0x30AC, 0x30AB, 0x3099, 0, + 1, 0x30AE, 0x30AD, 0x3099, 0, + 1, 0x30B0, 0x30AF, 0x3099, 0, + 1, 0x30B2, 0x30B1, 0x3099, 0, + 1, 0x30B4, 0x30B3, 0x3099, 0, + 1, 0x30B6, 0x30B5, 0x3099, 0, + 1, 0x30B8, 0x30B7, 0x3099, 0, + 1, 0x30BA, 0x30B9, 0x3099, 0, + 1, 0x30BC, 0x30BB, 0x3099, 0, + 1, 0x30BE, 0x30BD, 0x3099, 0, + 1, 0x30C0, 0x30BF, 0x3099, 0, + 1, 0x30C2, 0x30C1, 0x3099, 0, + 1, 0x30C5, 0x30C4, 0x3099, 0, + 1, 0x30C7, 0x30C6, 0x3099, 0, + 1, 0x30C9, 0x30C8, 0x3099, 0, + 1, 0x30D0, 0x30CF, 0x3099, 0, + 1, 0x30D1, 0x30CF, 0x309A, 0, + 1, 0x30D3, 0x30D2, 0x3099, 0, + 1, 0x30D4, 0x30D2, 0x309A, 0, + 1, 0x30D6, 0x30D5, 0x3099, 0, + 1, 0x30D7, 0x30D5, 0x309A, 0, + 1, 0x30D9, 0x30D8, 0x3099, 0, + 1, 0x30DA, 0x30D8, 0x309A, 0, + 1, 0x30DC, 0x30DB, 0x3099, 0, + 1, 0x30DD, 0x30DB, 0x309A, 0, + 1, 0x30F4, 0x30A6, 0x3099, 0, + 1, 0x30F7, 0x30EF, 0x3099, 0, + 1, 0x30F8, 0x30F0, 0x3099, 0, + 1, 0x30F9, 0x30F1, 0x3099, 0, + 1, 0x30FA, 0x30F2, 0x3099, 0, + 1, 0x30FE, 0x30FD, 0x3099, 0, + 11, 0x30FF, 0x30B3, 0x30C8, 0, + 16, 0x3131, 0x1100, 0, + 16, 0x3132, 0x1101, 0, + 16, 0x3133, 0x11AA, 0, + 16, 0x3134, 0x1102, 0, + 16, 0x3135, 0x11AC, 0, + 16, 0x3136, 0x11AD, 0, + 16, 0x3137, 0x1103, 0, + 16, 0x3138, 0x1104, 0, + 16, 0x3139, 0x1105, 0, + 16, 0x313A, 0x11B0, 0, + 16, 0x313B, 0x11B1, 0, + 16, 0x313C, 0x11B2, 0, + 16, 0x313D, 0x11B3, 0, + 16, 0x313E, 0x11B4, 0, + 16, 0x313F, 0x11B5, 0, + 16, 0x3140, 0x111A, 0, + 16, 0x3141, 0x1106, 0, + 16, 0x3142, 0x1107, 0, + 16, 0x3143, 0x1108, 0, + 16, 0x3144, 0x1121, 0, + 16, 0x3145, 0x1109, 0, + 16, 0x3146, 0x110A, 0, + 16, 0x3147, 0x110B, 0, + 16, 0x3148, 0x110C, 0, + 16, 0x3149, 0x110D, 0, + 16, 0x314A, 0x110E, 0, + 16, 0x314B, 0x110F, 0, + 16, 0x314C, 0x1110, 0, + 16, 0x314D, 0x1111, 0, + 16, 0x314E, 0x1112, 0, + 16, 0x314F, 0x1161, 0, + 16, 0x3150, 0x1162, 0, + 16, 0x3151, 0x1163, 0, + 16, 0x3152, 0x1164, 0, + 16, 0x3153, 0x1165, 0, + 16, 0x3154, 0x1166, 0, + 16, 0x3155, 0x1167, 0, + 16, 0x3156, 0x1168, 0, + 16, 0x3157, 0x1169, 0, + 16, 0x3158, 0x116A, 0, + 16, 0x3159, 0x116B, 0, + 16, 0x315A, 0x116C, 0, + 16, 0x315B, 0x116D, 0, + 16, 0x315C, 0x116E, 0, + 16, 0x315D, 0x116F, 0, + 16, 0x315E, 0x1170, 0, + 16, 0x315F, 0x1171, 0, + 16, 0x3160, 0x1172, 0, + 16, 0x3161, 0x1173, 0, + 16, 0x3162, 0x1174, 0, + 16, 0x3163, 0x1175, 0, + 16, 0x3164, 0x1160, 0, + 16, 0x3165, 0x1114, 0, + 16, 0x3166, 0x1115, 0, + 16, 0x3167, 0x11C7, 0, + 16, 0x3168, 0x11C8, 0, + 16, 0x3169, 0x11CC, 0, + 16, 0x316A, 0x11CE, 0, + 16, 0x316B, 0x11D3, 0, + 16, 0x316C, 0x11D7, 0, + 16, 0x316D, 0x11D9, 0, + 16, 0x316E, 0x111C, 0, + 16, 0x316F, 0x11DD, 0, + 16, 0x3170, 0x11DF, 0, + 16, 0x3171, 0x111D, 0, + 16, 0x3172, 0x111E, 0, + 16, 0x3173, 0x1120, 0, + 16, 0x3174, 0x1122, 0, + 16, 0x3175, 0x1123, 0, + 16, 0x3176, 0x1127, 0, + 16, 0x3177, 0x1129, 0, + 16, 0x3178, 0x112B, 0, + 16, 0x3179, 0x112C, 0, + 16, 0x317A, 0x112D, 0, + 16, 0x317B, 0x112E, 0, + 16, 0x317C, 0x112F, 0, + 16, 0x317D, 0x1132, 0, + 16, 0x317E, 0x1136, 0, + 16, 0x317F, 0x1140, 0, + 16, 0x3180, 0x1147, 0, + 16, 0x3181, 0x114C, 0, + 16, 0x3182, 0x11F1, 0, + 16, 0x3183, 0x11F2, 0, + 16, 0x3184, 0x1157, 0, + 16, 0x3185, 0x1158, 0, + 16, 0x3186, 0x1159, 0, + 16, 0x3187, 0x1184, 0, + 16, 0x3188, 0x1185, 0, + 16, 0x3189, 0x1188, 0, + 16, 0x318A, 0x1191, 0, + 16, 0x318B, 0x1192, 0, + 16, 0x318C, 0x1194, 0, + 16, 0x318D, 0x119E, 0, + 16, 0x318E, 0x11A1, 0, + 9, 0x3192, 0x4E00, 0, + 9, 0x3193, 0x4E8C, 0, + 9, 0x3194, 0x4E09, 0, + 9, 0x3195, 0x56DB, 0, + 9, 0x3196, 0x4E0A, 0, + 9, 0x3197, 0x4E2D, 0, + 9, 0x3198, 0x4E0B, 0, + 9, 0x3199, 0x7532, 0, + 9, 0x319A, 0x4E59, 0, + 9, 0x319B, 0x4E19, 0, + 9, 0x319C, 0x4E01, 0, + 9, 0x319D, 0x5929, 0, + 9, 0x319E, 0x5730, 0, + 9, 0x319F, 0x4EBA, 0, + 16, 0x3200, 0x0028, 0x1100, 0x0029, 0, + 16, 0x3201, 0x0028, 0x1102, 0x0029, 0, + 16, 0x3202, 0x0028, 0x1103, 0x0029, 0, + 16, 0x3203, 0x0028, 0x1105, 0x0029, 0, + 16, 0x3204, 0x0028, 0x1106, 0x0029, 0, + 16, 0x3205, 0x0028, 0x1107, 0x0029, 0, + 16, 0x3206, 0x0028, 0x1109, 0x0029, 0, + 16, 0x3207, 0x0028, 0x110B, 0x0029, 0, + 16, 0x3208, 0x0028, 0x110C, 0x0029, 0, + 16, 0x3209, 0x0028, 0x110E, 0x0029, 0, + 16, 0x320A, 0x0028, 0x110F, 0x0029, 0, + 16, 0x320B, 0x0028, 0x1110, 0x0029, 0, + 16, 0x320C, 0x0028, 0x1111, 0x0029, 0, + 16, 0x320D, 0x0028, 0x1112, 0x0029, 0, + 16, 0x320E, 0x0028, 0x1100, 0x1161, 0x0029, 0, + 16, 0x320F, 0x0028, 0x1102, 0x1161, 0x0029, 0, + 16, 0x3210, 0x0028, 0x1103, 0x1161, 0x0029, 0, + 16, 0x3211, 0x0028, 0x1105, 0x1161, 0x0029, 0, + 16, 0x3212, 0x0028, 0x1106, 0x1161, 0x0029, 0, + 16, 0x3213, 0x0028, 0x1107, 0x1161, 0x0029, 0, + 16, 0x3214, 0x0028, 0x1109, 0x1161, 0x0029, 0, + 16, 0x3215, 0x0028, 0x110B, 0x1161, 0x0029, 0, + 16, 0x3216, 0x0028, 0x110C, 0x1161, 0x0029, 0, + 16, 0x3217, 0x0028, 0x110E, 0x1161, 0x0029, 0, + 16, 0x3218, 0x0028, 0x110F, 0x1161, 0x0029, 0, + 16, 0x3219, 0x0028, 0x1110, 0x1161, 0x0029, 0, + 16, 0x321A, 0x0028, 0x1111, 0x1161, 0x0029, 0, + 16, 0x321B, 0x0028, 0x1112, 0x1161, 0x0029, 0, + 16, 0x321C, 0x0028, 0x110C, 0x116E, 0x0029, 0, + 16, 0x3220, 0x0028, 0x4E00, 0x0029, 0, + 16, 0x3221, 0x0028, 0x4E8C, 0x0029, 0, + 16, 0x3222, 0x0028, 0x4E09, 0x0029, 0, + 16, 0x3223, 0x0028, 0x56DB, 0x0029, 0, + 16, 0x3224, 0x0028, 0x4E94, 0x0029, 0, + 16, 0x3225, 0x0028, 0x516D, 0x0029, 0, + 16, 0x3226, 0x0028, 0x4E03, 0x0029, 0, + 16, 0x3227, 0x0028, 0x516B, 0x0029, 0, + 16, 0x3228, 0x0028, 0x4E5D, 0x0029, 0, + 16, 0x3229, 0x0028, 0x5341, 0x0029, 0, + 16, 0x322A, 0x0028, 0x6708, 0x0029, 0, + 16, 0x322B, 0x0028, 0x706B, 0x0029, 0, + 16, 0x322C, 0x0028, 0x6C34, 0x0029, 0, + 16, 0x322D, 0x0028, 0x6728, 0x0029, 0, + 16, 0x322E, 0x0028, 0x91D1, 0x0029, 0, + 16, 0x322F, 0x0028, 0x571F, 0x0029, 0, + 16, 0x3230, 0x0028, 0x65E5, 0x0029, 0, + 16, 0x3231, 0x0028, 0x682A, 0x0029, 0, + 16, 0x3232, 0x0028, 0x6709, 0x0029, 0, + 16, 0x3233, 0x0028, 0x793E, 0x0029, 0, + 16, 0x3234, 0x0028, 0x540D, 0x0029, 0, + 16, 0x3235, 0x0028, 0x7279, 0x0029, 0, + 16, 0x3236, 0x0028, 0x8CA1, 0x0029, 0, + 16, 0x3237, 0x0028, 0x795D, 0x0029, 0, + 16, 0x3238, 0x0028, 0x52B4, 0x0029, 0, + 16, 0x3239, 0x0028, 0x4EE3, 0x0029, 0, + 16, 0x323A, 0x0028, 0x547C, 0x0029, 0, + 16, 0x323B, 0x0028, 0x5B66, 0x0029, 0, + 16, 0x323C, 0x0028, 0x76E3, 0x0029, 0, + 16, 0x323D, 0x0028, 0x4F01, 0x0029, 0, + 16, 0x323E, 0x0028, 0x8CC7, 0x0029, 0, + 16, 0x323F, 0x0028, 0x5354, 0x0029, 0, + 16, 0x3240, 0x0028, 0x796D, 0x0029, 0, + 16, 0x3241, 0x0028, 0x4F11, 0x0029, 0, + 16, 0x3242, 0x0028, 0x81EA, 0x0029, 0, + 16, 0x3243, 0x0028, 0x81F3, 0x0029, 0, + 8, 0x3251, 0x0032, 0x0031, 0, + 8, 0x3252, 0x0032, 0x0032, 0, + 8, 0x3253, 0x0032, 0x0033, 0, + 8, 0x3254, 0x0032, 0x0034, 0, + 8, 0x3255, 0x0032, 0x0035, 0, + 8, 0x3256, 0x0032, 0x0036, 0, + 8, 0x3257, 0x0032, 0x0037, 0, + 8, 0x3258, 0x0032, 0x0038, 0, + 8, 0x3259, 0x0032, 0x0039, 0, + 8, 0x325A, 0x0033, 0x0030, 0, + 8, 0x325B, 0x0033, 0x0031, 0, + 8, 0x325C, 0x0033, 0x0032, 0, + 8, 0x325D, 0x0033, 0x0033, 0, + 8, 0x325E, 0x0033, 0x0034, 0, + 8, 0x325F, 0x0033, 0x0035, 0, + 8, 0x3260, 0x1100, 0, + 8, 0x3261, 0x1102, 0, + 8, 0x3262, 0x1103, 0, + 8, 0x3263, 0x1105, 0, + 8, 0x3264, 0x1106, 0, + 8, 0x3265, 0x1107, 0, + 8, 0x3266, 0x1109, 0, + 8, 0x3267, 0x110B, 0, + 8, 0x3268, 0x110C, 0, + 8, 0x3269, 0x110E, 0, + 8, 0x326A, 0x110F, 0, + 8, 0x326B, 0x1110, 0, + 8, 0x326C, 0x1111, 0, + 8, 0x326D, 0x1112, 0, + 8, 0x326E, 0x1100, 0x1161, 0, + 8, 0x326F, 0x1102, 0x1161, 0, + 8, 0x3270, 0x1103, 0x1161, 0, + 8, 0x3271, 0x1105, 0x1161, 0, + 8, 0x3272, 0x1106, 0x1161, 0, + 8, 0x3273, 0x1107, 0x1161, 0, + 8, 0x3274, 0x1109, 0x1161, 0, + 8, 0x3275, 0x110B, 0x1161, 0, + 8, 0x3276, 0x110C, 0x1161, 0, + 8, 0x3277, 0x110E, 0x1161, 0, + 8, 0x3278, 0x110F, 0x1161, 0, + 8, 0x3279, 0x1110, 0x1161, 0, + 8, 0x327A, 0x1111, 0x1161, 0, + 8, 0x327B, 0x1112, 0x1161, 0, + 8, 0x3280, 0x4E00, 0, + 8, 0x3281, 0x4E8C, 0, + 8, 0x3282, 0x4E09, 0, + 8, 0x3283, 0x56DB, 0, + 8, 0x3284, 0x4E94, 0, + 8, 0x3285, 0x516D, 0, + 8, 0x3286, 0x4E03, 0, + 8, 0x3287, 0x516B, 0, + 8, 0x3288, 0x4E5D, 0, + 8, 0x3289, 0x5341, 0, + 8, 0x328A, 0x6708, 0, + 8, 0x328B, 0x706B, 0, + 8, 0x328C, 0x6C34, 0, + 8, 0x328D, 0x6728, 0, + 8, 0x328E, 0x91D1, 0, + 8, 0x328F, 0x571F, 0, + 8, 0x3290, 0x65E5, 0, + 8, 0x3291, 0x682A, 0, + 8, 0x3292, 0x6709, 0, + 8, 0x3293, 0x793E, 0, + 8, 0x3294, 0x540D, 0, + 8, 0x3295, 0x7279, 0, + 8, 0x3296, 0x8CA1, 0, + 8, 0x3297, 0x795D, 0, + 8, 0x3298, 0x52B4, 0, + 8, 0x3299, 0x79D8, 0, + 8, 0x329A, 0x7537, 0, + 8, 0x329B, 0x5973, 0, + 8, 0x329C, 0x9069, 0, + 8, 0x329D, 0x512A, 0, + 8, 0x329E, 0x5370, 0, + 8, 0x329F, 0x6CE8, 0, + 8, 0x32A0, 0x9805, 0, + 8, 0x32A1, 0x4F11, 0, + 8, 0x32A2, 0x5199, 0, + 8, 0x32A3, 0x6B63, 0, + 8, 0x32A4, 0x4E0A, 0, + 8, 0x32A5, 0x4E2D, 0, + 8, 0x32A6, 0x4E0B, 0, + 8, 0x32A7, 0x5DE6, 0, + 8, 0x32A8, 0x53F3, 0, + 8, 0x32A9, 0x533B, 0, + 8, 0x32AA, 0x5B97, 0, + 8, 0x32AB, 0x5B66, 0, + 8, 0x32AC, 0x76E3, 0, + 8, 0x32AD, 0x4F01, 0, + 8, 0x32AE, 0x8CC7, 0, + 8, 0x32AF, 0x5354, 0, + 8, 0x32B0, 0x591C, 0, + 8, 0x32B1, 0x0033, 0x0036, 0, + 8, 0x32B2, 0x0033, 0x0037, 0, + 8, 0x32B3, 0x0033, 0x0038, 0, + 8, 0x32B4, 0x0033, 0x0039, 0, + 8, 0x32B5, 0x0034, 0x0030, 0, + 8, 0x32B6, 0x0034, 0x0031, 0, + 8, 0x32B7, 0x0034, 0x0032, 0, + 8, 0x32B8, 0x0034, 0x0033, 0, + 8, 0x32B9, 0x0034, 0x0034, 0, + 8, 0x32BA, 0x0034, 0x0035, 0, + 8, 0x32BB, 0x0034, 0x0036, 0, + 8, 0x32BC, 0x0034, 0x0037, 0, + 8, 0x32BD, 0x0034, 0x0038, 0, + 8, 0x32BE, 0x0034, 0x0039, 0, + 8, 0x32BF, 0x0035, 0x0030, 0, + 16, 0x32C0, 0x0031, 0x6708, 0, + 16, 0x32C1, 0x0032, 0x6708, 0, + 16, 0x32C2, 0x0033, 0x6708, 0, + 16, 0x32C3, 0x0034, 0x6708, 0, + 16, 0x32C4, 0x0035, 0x6708, 0, + 16, 0x32C5, 0x0036, 0x6708, 0, + 16, 0x32C6, 0x0037, 0x6708, 0, + 16, 0x32C7, 0x0038, 0x6708, 0, + 16, 0x32C8, 0x0039, 0x6708, 0, + 16, 0x32C9, 0x0031, 0x0030, 0x6708, 0, + 16, 0x32CA, 0x0031, 0x0031, 0x6708, 0, + 16, 0x32CB, 0x0031, 0x0032, 0x6708, 0, + 8, 0x32D0, 0x30A2, 0, + 8, 0x32D1, 0x30A4, 0, + 8, 0x32D2, 0x30A6, 0, + 8, 0x32D3, 0x30A8, 0, + 8, 0x32D4, 0x30AA, 0, + 8, 0x32D5, 0x30AB, 0, + 8, 0x32D6, 0x30AD, 0, + 8, 0x32D7, 0x30AF, 0, + 8, 0x32D8, 0x30B1, 0, + 8, 0x32D9, 0x30B3, 0, + 8, 0x32DA, 0x30B5, 0, + 8, 0x32DB, 0x30B7, 0, + 8, 0x32DC, 0x30B9, 0, + 8, 0x32DD, 0x30BB, 0, + 8, 0x32DE, 0x30BD, 0, + 8, 0x32DF, 0x30BF, 0, + 8, 0x32E0, 0x30C1, 0, + 8, 0x32E1, 0x30C4, 0, + 8, 0x32E2, 0x30C6, 0, + 8, 0x32E3, 0x30C8, 0, + 8, 0x32E4, 0x30CA, 0, + 8, 0x32E5, 0x30CB, 0, + 8, 0x32E6, 0x30CC, 0, + 8, 0x32E7, 0x30CD, 0, + 8, 0x32E8, 0x30CE, 0, + 8, 0x32E9, 0x30CF, 0, + 8, 0x32EA, 0x30D2, 0, + 8, 0x32EB, 0x30D5, 0, + 8, 0x32EC, 0x30D8, 0, + 8, 0x32ED, 0x30DB, 0, + 8, 0x32EE, 0x30DE, 0, + 8, 0x32EF, 0x30DF, 0, + 8, 0x32F0, 0x30E0, 0, + 8, 0x32F1, 0x30E1, 0, + 8, 0x32F2, 0x30E2, 0, + 8, 0x32F3, 0x30E4, 0, + 8, 0x32F4, 0x30E6, 0, + 8, 0x32F5, 0x30E8, 0, + 8, 0x32F6, 0x30E9, 0, + 8, 0x32F7, 0x30EA, 0, + 8, 0x32F8, 0x30EB, 0, + 8, 0x32F9, 0x30EC, 0, + 8, 0x32FA, 0x30ED, 0, + 8, 0x32FB, 0x30EF, 0, + 8, 0x32FC, 0x30F0, 0, + 8, 0x32FD, 0x30F1, 0, + 8, 0x32FE, 0x30F2, 0, + 15, 0x3300, 0x30A2, 0x30D1, 0x30FC, 0x30C8, 0, + 15, 0x3301, 0x30A2, 0x30EB, 0x30D5, 0x30A1, 0, + 15, 0x3302, 0x30A2, 0x30F3, 0x30DA, 0x30A2, 0, + 15, 0x3303, 0x30A2, 0x30FC, 0x30EB, 0, + 15, 0x3304, 0x30A4, 0x30CB, 0x30F3, 0x30B0, 0, + 15, 0x3305, 0x30A4, 0x30F3, 0x30C1, 0, + 15, 0x3306, 0x30A6, 0x30A9, 0x30F3, 0, + 15, 0x3307, 0x30A8, 0x30B9, 0x30AF, 0x30FC, 0x30C9, 0, + 15, 0x3308, 0x30A8, 0x30FC, 0x30AB, 0x30FC, 0, + 15, 0x3309, 0x30AA, 0x30F3, 0x30B9, 0, + 15, 0x330A, 0x30AA, 0x30FC, 0x30E0, 0, + 15, 0x330B, 0x30AB, 0x30A4, 0x30EA, 0, + 15, 0x330C, 0x30AB, 0x30E9, 0x30C3, 0x30C8, 0, + 15, 0x330D, 0x30AB, 0x30ED, 0x30EA, 0x30FC, 0, + 15, 0x330E, 0x30AC, 0x30ED, 0x30F3, 0, + 15, 0x330F, 0x30AC, 0x30F3, 0x30DE, 0, + 15, 0x3310, 0x30AE, 0x30AC, 0, + 15, 0x3311, 0x30AE, 0x30CB, 0x30FC, 0, + 15, 0x3312, 0x30AD, 0x30E5, 0x30EA, 0x30FC, 0, + 15, 0x3313, 0x30AE, 0x30EB, 0x30C0, 0x30FC, 0, + 15, 0x3314, 0x30AD, 0x30ED, 0, + 15, 0x3315, 0x30AD, 0x30ED, 0x30B0, 0x30E9, 0x30E0, 0, + 15, 0x3316, 0x30AD, 0x30ED, 0x30E1, 0x30FC, 0x30C8, 0x30EB, 0, + 15, 0x3317, 0x30AD, 0x30ED, 0x30EF, 0x30C3, 0x30C8, 0, + 15, 0x3318, 0x30B0, 0x30E9, 0x30E0, 0, + 15, 0x3319, 0x30B0, 0x30E9, 0x30E0, 0x30C8, 0x30F3, 0, + 15, 0x331A, 0x30AF, 0x30EB, 0x30BC, 0x30A4, 0x30ED, 0, + 15, 0x331B, 0x30AF, 0x30ED, 0x30FC, 0x30CD, 0, + 15, 0x331C, 0x30B1, 0x30FC, 0x30B9, 0, + 15, 0x331D, 0x30B3, 0x30EB, 0x30CA, 0, + 15, 0x331E, 0x30B3, 0x30FC, 0x30DD, 0, + 15, 0x331F, 0x30B5, 0x30A4, 0x30AF, 0x30EB, 0, + 15, 0x3320, 0x30B5, 0x30F3, 0x30C1, 0x30FC, 0x30E0, 0, + 15, 0x3321, 0x30B7, 0x30EA, 0x30F3, 0x30B0, 0, + 15, 0x3322, 0x30BB, 0x30F3, 0x30C1, 0, + 15, 0x3323, 0x30BB, 0x30F3, 0x30C8, 0, + 15, 0x3324, 0x30C0, 0x30FC, 0x30B9, 0, + 15, 0x3325, 0x30C7, 0x30B7, 0, + 15, 0x3326, 0x30C9, 0x30EB, 0, + 15, 0x3327, 0x30C8, 0x30F3, 0, + 15, 0x3328, 0x30CA, 0x30CE, 0, + 15, 0x3329, 0x30CE, 0x30C3, 0x30C8, 0, + 15, 0x332A, 0x30CF, 0x30A4, 0x30C4, 0, + 15, 0x332B, 0x30D1, 0x30FC, 0x30BB, 0x30F3, 0x30C8, 0, + 15, 0x332C, 0x30D1, 0x30FC, 0x30C4, 0, + 15, 0x332D, 0x30D0, 0x30FC, 0x30EC, 0x30EB, 0, + 15, 0x332E, 0x30D4, 0x30A2, 0x30B9, 0x30C8, 0x30EB, 0, + 15, 0x332F, 0x30D4, 0x30AF, 0x30EB, 0, + 15, 0x3330, 0x30D4, 0x30B3, 0, + 15, 0x3331, 0x30D3, 0x30EB, 0, + 15, 0x3332, 0x30D5, 0x30A1, 0x30E9, 0x30C3, 0x30C9, 0, + 15, 0x3333, 0x30D5, 0x30A3, 0x30FC, 0x30C8, 0, + 15, 0x3334, 0x30D6, 0x30C3, 0x30B7, 0x30A7, 0x30EB, 0, + 15, 0x3335, 0x30D5, 0x30E9, 0x30F3, 0, + 15, 0x3336, 0x30D8, 0x30AF, 0x30BF, 0x30FC, 0x30EB, 0, + 15, 0x3337, 0x30DA, 0x30BD, 0, + 15, 0x3338, 0x30DA, 0x30CB, 0x30D2, 0, + 15, 0x3339, 0x30D8, 0x30EB, 0x30C4, 0, + 15, 0x333A, 0x30DA, 0x30F3, 0x30B9, 0, + 15, 0x333B, 0x30DA, 0x30FC, 0x30B8, 0, + 15, 0x333C, 0x30D9, 0x30FC, 0x30BF, 0, + 15, 0x333D, 0x30DD, 0x30A4, 0x30F3, 0x30C8, 0, + 15, 0x333E, 0x30DC, 0x30EB, 0x30C8, 0, + 15, 0x333F, 0x30DB, 0x30F3, 0, + 15, 0x3340, 0x30DD, 0x30F3, 0x30C9, 0, + 15, 0x3341, 0x30DB, 0x30FC, 0x30EB, 0, + 15, 0x3342, 0x30DB, 0x30FC, 0x30F3, 0, + 15, 0x3343, 0x30DE, 0x30A4, 0x30AF, 0x30ED, 0, + 15, 0x3344, 0x30DE, 0x30A4, 0x30EB, 0, + 15, 0x3345, 0x30DE, 0x30C3, 0x30CF, 0, + 15, 0x3346, 0x30DE, 0x30EB, 0x30AF, 0, + 15, 0x3347, 0x30DE, 0x30F3, 0x30B7, 0x30E7, 0x30F3, 0, + 15, 0x3348, 0x30DF, 0x30AF, 0x30ED, 0x30F3, 0, + 15, 0x3349, 0x30DF, 0x30EA, 0, + 15, 0x334A, 0x30DF, 0x30EA, 0x30D0, 0x30FC, 0x30EB, 0, + 15, 0x334B, 0x30E1, 0x30AC, 0, + 15, 0x334C, 0x30E1, 0x30AC, 0x30C8, 0x30F3, 0, + 15, 0x334D, 0x30E1, 0x30FC, 0x30C8, 0x30EB, 0, + 15, 0x334E, 0x30E4, 0x30FC, 0x30C9, 0, + 15, 0x334F, 0x30E4, 0x30FC, 0x30EB, 0, + 15, 0x3350, 0x30E6, 0x30A2, 0x30F3, 0, + 15, 0x3351, 0x30EA, 0x30C3, 0x30C8, 0x30EB, 0, + 15, 0x3352, 0x30EA, 0x30E9, 0, + 15, 0x3353, 0x30EB, 0x30D4, 0x30FC, 0, + 15, 0x3354, 0x30EB, 0x30FC, 0x30D6, 0x30EB, 0, + 15, 0x3355, 0x30EC, 0x30E0, 0, + 15, 0x3356, 0x30EC, 0x30F3, 0x30C8, 0x30B2, 0x30F3, 0, + 15, 0x3357, 0x30EF, 0x30C3, 0x30C8, 0, + 16, 0x3358, 0x0030, 0x70B9, 0, + 16, 0x3359, 0x0031, 0x70B9, 0, + 16, 0x335A, 0x0032, 0x70B9, 0, + 16, 0x335B, 0x0033, 0x70B9, 0, + 16, 0x335C, 0x0034, 0x70B9, 0, + 16, 0x335D, 0x0035, 0x70B9, 0, + 16, 0x335E, 0x0036, 0x70B9, 0, + 16, 0x335F, 0x0037, 0x70B9, 0, + 16, 0x3360, 0x0038, 0x70B9, 0, + 16, 0x3361, 0x0039, 0x70B9, 0, + 16, 0x3362, 0x0031, 0x0030, 0x70B9, 0, + 16, 0x3363, 0x0031, 0x0031, 0x70B9, 0, + 16, 0x3364, 0x0031, 0x0032, 0x70B9, 0, + 16, 0x3365, 0x0031, 0x0033, 0x70B9, 0, + 16, 0x3366, 0x0031, 0x0034, 0x70B9, 0, + 16, 0x3367, 0x0031, 0x0035, 0x70B9, 0, + 16, 0x3368, 0x0031, 0x0036, 0x70B9, 0, + 16, 0x3369, 0x0031, 0x0037, 0x70B9, 0, + 16, 0x336A, 0x0031, 0x0038, 0x70B9, 0, + 16, 0x336B, 0x0031, 0x0039, 0x70B9, 0, + 16, 0x336C, 0x0032, 0x0030, 0x70B9, 0, + 16, 0x336D, 0x0032, 0x0031, 0x70B9, 0, + 16, 0x336E, 0x0032, 0x0032, 0x70B9, 0, + 16, 0x336F, 0x0032, 0x0033, 0x70B9, 0, + 16, 0x3370, 0x0032, 0x0034, 0x70B9, 0, + 15, 0x3371, 0x0068, 0x0050, 0x0061, 0, + 15, 0x3372, 0x0064, 0x0061, 0, + 15, 0x3373, 0x0041, 0x0055, 0, + 15, 0x3374, 0x0062, 0x0061, 0x0072, 0, + 15, 0x3375, 0x006F, 0x0056, 0, + 15, 0x3376, 0x0070, 0x0063, 0, + 15, 0x337B, 0x5E73, 0x6210, 0, + 15, 0x337C, 0x662D, 0x548C, 0, + 15, 0x337D, 0x5927, 0x6B63, 0, + 15, 0x337E, 0x660E, 0x6CBB, 0, + 15, 0x337F, 0x682A, 0x5F0F, 0x4F1A, 0x793E, 0, + 15, 0x3380, 0x0070, 0x0041, 0, + 15, 0x3381, 0x006E, 0x0041, 0, + 15, 0x3382, 0x03BC, 0x0041, 0, + 15, 0x3383, 0x006D, 0x0041, 0, + 15, 0x3384, 0x006B, 0x0041, 0, + 15, 0x3385, 0x004B, 0x0042, 0, + 15, 0x3386, 0x004D, 0x0042, 0, + 15, 0x3387, 0x0047, 0x0042, 0, + 15, 0x3388, 0x0063, 0x0061, 0x006C, 0, + 15, 0x3389, 0x006B, 0x0063, 0x0061, 0x006C, 0, + 15, 0x338A, 0x0070, 0x0046, 0, + 15, 0x338B, 0x006E, 0x0046, 0, + 15, 0x338C, 0x03BC, 0x0046, 0, + 15, 0x338D, 0x03BC, 0x0067, 0, + 15, 0x338E, 0x006D, 0x0067, 0, + 15, 0x338F, 0x006B, 0x0067, 0, + 15, 0x3390, 0x0048, 0x007A, 0, + 15, 0x3391, 0x006B, 0x0048, 0x007A, 0, + 15, 0x3392, 0x004D, 0x0048, 0x007A, 0, + 15, 0x3393, 0x0047, 0x0048, 0x007A, 0, + 15, 0x3394, 0x0054, 0x0048, 0x007A, 0, + 15, 0x3395, 0x03BC, 0x2113, 0, + 15, 0x3396, 0x006D, 0x2113, 0, + 15, 0x3397, 0x0064, 0x2113, 0, + 15, 0x3398, 0x006B, 0x2113, 0, + 15, 0x3399, 0x0066, 0x006D, 0, + 15, 0x339A, 0x006E, 0x006D, 0, + 15, 0x339B, 0x03BC, 0x006D, 0, + 15, 0x339C, 0x006D, 0x006D, 0, + 15, 0x339D, 0x0063, 0x006D, 0, + 15, 0x339E, 0x006B, 0x006D, 0, + 15, 0x339F, 0x006D, 0x006D, 0x00B2, 0, + 15, 0x33A0, 0x0063, 0x006D, 0x00B2, 0, + 15, 0x33A1, 0x006D, 0x00B2, 0, + 15, 0x33A2, 0x006B, 0x006D, 0x00B2, 0, + 15, 0x33A3, 0x006D, 0x006D, 0x00B3, 0, + 15, 0x33A4, 0x0063, 0x006D, 0x00B3, 0, + 15, 0x33A5, 0x006D, 0x00B3, 0, + 15, 0x33A6, 0x006B, 0x006D, 0x00B3, 0, + 15, 0x33A7, 0x006D, 0x2215, 0x0073, 0, + 15, 0x33A8, 0x006D, 0x2215, 0x0073, 0x00B2, 0, + 15, 0x33A9, 0x0050, 0x0061, 0, + 15, 0x33AA, 0x006B, 0x0050, 0x0061, 0, + 15, 0x33AB, 0x004D, 0x0050, 0x0061, 0, + 15, 0x33AC, 0x0047, 0x0050, 0x0061, 0, + 15, 0x33AD, 0x0072, 0x0061, 0x0064, 0, + 15, 0x33AE, 0x0072, 0x0061, 0x0064, 0x2215, 0x0073, 0, + 15, 0x33AF, 0x0072, 0x0061, 0x0064, 0x2215, 0x0073, 0x00B2, 0, + 15, 0x33B0, 0x0070, 0x0073, 0, + 15, 0x33B1, 0x006E, 0x0073, 0, + 15, 0x33B2, 0x03BC, 0x0073, 0, + 15, 0x33B3, 0x006D, 0x0073, 0, + 15, 0x33B4, 0x0070, 0x0056, 0, + 15, 0x33B5, 0x006E, 0x0056, 0, + 15, 0x33B6, 0x03BC, 0x0056, 0, + 15, 0x33B7, 0x006D, 0x0056, 0, + 15, 0x33B8, 0x006B, 0x0056, 0, + 15, 0x33B9, 0x004D, 0x0056, 0, + 15, 0x33BA, 0x0070, 0x0057, 0, + 15, 0x33BB, 0x006E, 0x0057, 0, + 15, 0x33BC, 0x03BC, 0x0057, 0, + 15, 0x33BD, 0x006D, 0x0057, 0, + 15, 0x33BE, 0x006B, 0x0057, 0, + 15, 0x33BF, 0x004D, 0x0057, 0, + 15, 0x33C0, 0x006B, 0x03A9, 0, + 15, 0x33C1, 0x004D, 0x03A9, 0, + 15, 0x33C2, 0x0061, 0x002E, 0x006D, 0x002E, 0, + 15, 0x33C3, 0x0042, 0x0071, 0, + 15, 0x33C4, 0x0063, 0x0063, 0, + 15, 0x33C5, 0x0063, 0x0064, 0, + 15, 0x33C6, 0x0043, 0x2215, 0x006B, 0x0067, 0, + 15, 0x33C7, 0x0043, 0x006F, 0x002E, 0, + 15, 0x33C8, 0x0064, 0x0042, 0, + 15, 0x33C9, 0x0047, 0x0079, 0, + 15, 0x33CA, 0x0068, 0x0061, 0, + 15, 0x33CB, 0x0048, 0x0050, 0, + 15, 0x33CC, 0x0069, 0x006E, 0, + 15, 0x33CD, 0x004B, 0x004B, 0, + 15, 0x33CE, 0x004B, 0x004D, 0, + 15, 0x33CF, 0x006B, 0x0074, 0, + 15, 0x33D0, 0x006C, 0x006D, 0, + 15, 0x33D1, 0x006C, 0x006E, 0, + 15, 0x33D2, 0x006C, 0x006F, 0x0067, 0, + 15, 0x33D3, 0x006C, 0x0078, 0, + 15, 0x33D4, 0x006D, 0x0062, 0, + 15, 0x33D5, 0x006D, 0x0069, 0x006C, 0, + 15, 0x33D6, 0x006D, 0x006F, 0x006C, 0, + 15, 0x33D7, 0x0050, 0x0048, 0, + 15, 0x33D8, 0x0070, 0x002E, 0x006D, 0x002E, 0, + 15, 0x33D9, 0x0050, 0x0050, 0x004D, 0, + 15, 0x33DA, 0x0050, 0x0052, 0, + 15, 0x33DB, 0x0073, 0x0072, 0, + 15, 0x33DC, 0x0053, 0x0076, 0, + 15, 0x33DD, 0x0057, 0x0062, 0, + 16, 0x33E0, 0x0031, 0x65E5, 0, + 16, 0x33E1, 0x0032, 0x65E5, 0, + 16, 0x33E2, 0x0033, 0x65E5, 0, + 16, 0x33E3, 0x0034, 0x65E5, 0, + 16, 0x33E4, 0x0035, 0x65E5, 0, + 16, 0x33E5, 0x0036, 0x65E5, 0, + 16, 0x33E6, 0x0037, 0x65E5, 0, + 16, 0x33E7, 0x0038, 0x65E5, 0, + 16, 0x33E8, 0x0039, 0x65E5, 0, + 16, 0x33E9, 0x0031, 0x0030, 0x65E5, 0, + 16, 0x33EA, 0x0031, 0x0031, 0x65E5, 0, + 16, 0x33EB, 0x0031, 0x0032, 0x65E5, 0, + 16, 0x33EC, 0x0031, 0x0033, 0x65E5, 0, + 16, 0x33ED, 0x0031, 0x0034, 0x65E5, 0, + 16, 0x33EE, 0x0031, 0x0035, 0x65E5, 0, + 16, 0x33EF, 0x0031, 0x0036, 0x65E5, 0, + 16, 0x33F0, 0x0031, 0x0037, 0x65E5, 0, + 16, 0x33F1, 0x0031, 0x0038, 0x65E5, 0, + 16, 0x33F2, 0x0031, 0x0039, 0x65E5, 0, + 16, 0x33F3, 0x0032, 0x0030, 0x65E5, 0, + 16, 0x33F4, 0x0032, 0x0031, 0x65E5, 0, + 16, 0x33F5, 0x0032, 0x0032, 0x65E5, 0, + 16, 0x33F6, 0x0032, 0x0033, 0x65E5, 0, + 16, 0x33F7, 0x0032, 0x0034, 0x65E5, 0, + 16, 0x33F8, 0x0032, 0x0035, 0x65E5, 0, + 16, 0x33F9, 0x0032, 0x0036, 0x65E5, 0, + 16, 0x33FA, 0x0032, 0x0037, 0x65E5, 0, + 16, 0x33FB, 0x0032, 0x0038, 0x65E5, 0, + 16, 0x33FC, 0x0032, 0x0039, 0x65E5, 0, + 16, 0x33FD, 0x0033, 0x0030, 0x65E5, 0, + 16, 0x33FE, 0x0033, 0x0031, 0x65E5, 0, + 1, 0xF900, 0x8C48, 0, + 1, 0xF901, 0x66F4, 0, + 1, 0xF902, 0x8ECA, 0, + 1, 0xF903, 0x8CC8, 0, + 1, 0xF904, 0x6ED1, 0, + 1, 0xF905, 0x4E32, 0, + 1, 0xF906, 0x53E5, 0, + 1, 0xF907, 0x9F9C, 0, + 1, 0xF908, 0x9F9C, 0, + 1, 0xF909, 0x5951, 0, + 1, 0xF90A, 0x91D1, 0, + 1, 0xF90B, 0x5587, 0, + 1, 0xF90C, 0x5948, 0, + 1, 0xF90D, 0x61F6, 0, + 1, 0xF90E, 0x7669, 0, + 1, 0xF90F, 0x7F85, 0, + 1, 0xF910, 0x863F, 0, + 1, 0xF911, 0x87BA, 0, + 1, 0xF912, 0x88F8, 0, + 1, 0xF913, 0x908F, 0, + 1, 0xF914, 0x6A02, 0, + 1, 0xF915, 0x6D1B, 0, + 1, 0xF916, 0x70D9, 0, + 1, 0xF917, 0x73DE, 0, + 1, 0xF918, 0x843D, 0, + 1, 0xF919, 0x916A, 0, + 1, 0xF91A, 0x99F1, 0, + 1, 0xF91B, 0x4E82, 0, + 1, 0xF91C, 0x5375, 0, + 1, 0xF91D, 0x6B04, 0, + 1, 0xF91E, 0x721B, 0, + 1, 0xF91F, 0x862D, 0, + 1, 0xF920, 0x9E1E, 0, + 1, 0xF921, 0x5D50, 0, + 1, 0xF922, 0x6FEB, 0, + 1, 0xF923, 0x85CD, 0, + 1, 0xF924, 0x8964, 0, + 1, 0xF925, 0x62C9, 0, + 1, 0xF926, 0x81D8, 0, + 1, 0xF927, 0x881F, 0, + 1, 0xF928, 0x5ECA, 0, + 1, 0xF929, 0x6717, 0, + 1, 0xF92A, 0x6D6A, 0, + 1, 0xF92B, 0x72FC, 0, + 1, 0xF92C, 0x90CE, 0, + 1, 0xF92D, 0x4F86, 0, + 1, 0xF92E, 0x51B7, 0, + 1, 0xF92F, 0x52DE, 0, + 1, 0xF930, 0x64C4, 0, + 1, 0xF931, 0x6AD3, 0, + 1, 0xF932, 0x7210, 0, + 1, 0xF933, 0x76E7, 0, + 1, 0xF934, 0x8001, 0, + 1, 0xF935, 0x8606, 0, + 1, 0xF936, 0x865C, 0, + 1, 0xF937, 0x8DEF, 0, + 1, 0xF938, 0x9732, 0, + 1, 0xF939, 0x9B6F, 0, + 1, 0xF93A, 0x9DFA, 0, + 1, 0xF93B, 0x788C, 0, + 1, 0xF93C, 0x797F, 0, + 1, 0xF93D, 0x7DA0, 0, + 1, 0xF93E, 0x83C9, 0, + 1, 0xF93F, 0x9304, 0, + 1, 0xF940, 0x9E7F, 0, + 1, 0xF941, 0x8AD6, 0, + 1, 0xF942, 0x58DF, 0, + 1, 0xF943, 0x5F04, 0, + 1, 0xF944, 0x7C60, 0, + 1, 0xF945, 0x807E, 0, + 1, 0xF946, 0x7262, 0, + 1, 0xF947, 0x78CA, 0, + 1, 0xF948, 0x8CC2, 0, + 1, 0xF949, 0x96F7, 0, + 1, 0xF94A, 0x58D8, 0, + 1, 0xF94B, 0x5C62, 0, + 1, 0xF94C, 0x6A13, 0, + 1, 0xF94D, 0x6DDA, 0, + 1, 0xF94E, 0x6F0F, 0, + 1, 0xF94F, 0x7D2F, 0, + 1, 0xF950, 0x7E37, 0, + 1, 0xF951, 0x964B, 0, + 1, 0xF952, 0x52D2, 0, + 1, 0xF953, 0x808B, 0, + 1, 0xF954, 0x51DC, 0, + 1, 0xF955, 0x51CC, 0, + 1, 0xF956, 0x7A1C, 0, + 1, 0xF957, 0x7DBE, 0, + 1, 0xF958, 0x83F1, 0, + 1, 0xF959, 0x9675, 0, + 1, 0xF95A, 0x8B80, 0, + 1, 0xF95B, 0x62CF, 0, + 1, 0xF95C, 0x6A02, 0, + 1, 0xF95D, 0x8AFE, 0, + 1, 0xF95E, 0x4E39, 0, + 1, 0xF95F, 0x5BE7, 0, + 1, 0xF960, 0x6012, 0, + 1, 0xF961, 0x7387, 0, + 1, 0xF962, 0x7570, 0, + 1, 0xF963, 0x5317, 0, + 1, 0xF964, 0x78FB, 0, + 1, 0xF965, 0x4FBF, 0, + 1, 0xF966, 0x5FA9, 0, + 1, 0xF967, 0x4E0D, 0, + 1, 0xF968, 0x6CCC, 0, + 1, 0xF969, 0x6578, 0, + 1, 0xF96A, 0x7D22, 0, + 1, 0xF96B, 0x53C3, 0, + 1, 0xF96C, 0x585E, 0, + 1, 0xF96D, 0x7701, 0, + 1, 0xF96E, 0x8449, 0, + 1, 0xF96F, 0x8AAA, 0, + 1, 0xF970, 0x6BBA, 0, + 1, 0xF971, 0x8FB0, 0, + 1, 0xF972, 0x6C88, 0, + 1, 0xF973, 0x62FE, 0, + 1, 0xF974, 0x82E5, 0, + 1, 0xF975, 0x63A0, 0, + 1, 0xF976, 0x7565, 0, + 1, 0xF977, 0x4EAE, 0, + 1, 0xF978, 0x5169, 0, + 1, 0xF979, 0x51C9, 0, + 1, 0xF97A, 0x6881, 0, + 1, 0xF97B, 0x7CE7, 0, + 1, 0xF97C, 0x826F, 0, + 1, 0xF97D, 0x8AD2, 0, + 1, 0xF97E, 0x91CF, 0, + 1, 0xF97F, 0x52F5, 0, + 1, 0xF980, 0x5442, 0, + 1, 0xF981, 0x5973, 0, + 1, 0xF982, 0x5EEC, 0, + 1, 0xF983, 0x65C5, 0, + 1, 0xF984, 0x6FFE, 0, + 1, 0xF985, 0x792A, 0, + 1, 0xF986, 0x95AD, 0, + 1, 0xF987, 0x9A6A, 0, + 1, 0xF988, 0x9E97, 0, + 1, 0xF989, 0x9ECE, 0, + 1, 0xF98A, 0x529B, 0, + 1, 0xF98B, 0x66C6, 0, + 1, 0xF98C, 0x6B77, 0, + 1, 0xF98D, 0x8F62, 0, + 1, 0xF98E, 0x5E74, 0, + 1, 0xF98F, 0x6190, 0, + 1, 0xF990, 0x6200, 0, + 1, 0xF991, 0x649A, 0, + 1, 0xF992, 0x6F23, 0, + 1, 0xF993, 0x7149, 0, + 1, 0xF994, 0x7489, 0, + 1, 0xF995, 0x79CA, 0, + 1, 0xF996, 0x7DF4, 0, + 1, 0xF997, 0x806F, 0, + 1, 0xF998, 0x8F26, 0, + 1, 0xF999, 0x84EE, 0, + 1, 0xF99A, 0x9023, 0, + 1, 0xF99B, 0x934A, 0, + 1, 0xF99C, 0x5217, 0, + 1, 0xF99D, 0x52A3, 0, + 1, 0xF99E, 0x54BD, 0, + 1, 0xF99F, 0x70C8, 0, + 1, 0xF9A0, 0x88C2, 0, + 1, 0xF9A1, 0x8AAA, 0, + 1, 0xF9A2, 0x5EC9, 0, + 1, 0xF9A3, 0x5FF5, 0, + 1, 0xF9A4, 0x637B, 0, + 1, 0xF9A5, 0x6BAE, 0, + 1, 0xF9A6, 0x7C3E, 0, + 1, 0xF9A7, 0x7375, 0, + 1, 0xF9A8, 0x4EE4, 0, + 1, 0xF9A9, 0x56F9, 0, + 1, 0xF9AA, 0x5BE7, 0, + 1, 0xF9AB, 0x5DBA, 0, + 1, 0xF9AC, 0x601C, 0, + 1, 0xF9AD, 0x73B2, 0, + 1, 0xF9AE, 0x7469, 0, + 1, 0xF9AF, 0x7F9A, 0, + 1, 0xF9B0, 0x8046, 0, + 1, 0xF9B1, 0x9234, 0, + 1, 0xF9B2, 0x96F6, 0, + 1, 0xF9B3, 0x9748, 0, + 1, 0xF9B4, 0x9818, 0, + 1, 0xF9B5, 0x4F8B, 0, + 1, 0xF9B6, 0x79AE, 0, + 1, 0xF9B7, 0x91B4, 0, + 1, 0xF9B8, 0x96B8, 0, + 1, 0xF9B9, 0x60E1, 0, + 1, 0xF9BA, 0x4E86, 0, + 1, 0xF9BB, 0x50DA, 0, + 1, 0xF9BC, 0x5BEE, 0, + 1, 0xF9BD, 0x5C3F, 0, + 1, 0xF9BE, 0x6599, 0, + 1, 0xF9BF, 0x6A02, 0, + 1, 0xF9C0, 0x71CE, 0, + 1, 0xF9C1, 0x7642, 0, + 1, 0xF9C2, 0x84FC, 0, + 1, 0xF9C3, 0x907C, 0, + 1, 0xF9C4, 0x9F8D, 0, + 1, 0xF9C5, 0x6688, 0, + 1, 0xF9C6, 0x962E, 0, + 1, 0xF9C7, 0x5289, 0, + 1, 0xF9C8, 0x677B, 0, + 1, 0xF9C9, 0x67F3, 0, + 1, 0xF9CA, 0x6D41, 0, + 1, 0xF9CB, 0x6E9C, 0, + 1, 0xF9CC, 0x7409, 0, + 1, 0xF9CD, 0x7559, 0, + 1, 0xF9CE, 0x786B, 0, + 1, 0xF9CF, 0x7D10, 0, + 1, 0xF9D0, 0x985E, 0, + 1, 0xF9D1, 0x516D, 0, + 1, 0xF9D2, 0x622E, 0, + 1, 0xF9D3, 0x9678, 0, + 1, 0xF9D4, 0x502B, 0, + 1, 0xF9D5, 0x5D19, 0, + 1, 0xF9D6, 0x6DEA, 0, + 1, 0xF9D7, 0x8F2A, 0, + 1, 0xF9D8, 0x5F8B, 0, + 1, 0xF9D9, 0x6144, 0, + 1, 0xF9DA, 0x6817, 0, + 1, 0xF9DB, 0x7387, 0, + 1, 0xF9DC, 0x9686, 0, + 1, 0xF9DD, 0x5229, 0, + 1, 0xF9DE, 0x540F, 0, + 1, 0xF9DF, 0x5C65, 0, + 1, 0xF9E0, 0x6613, 0, + 1, 0xF9E1, 0x674E, 0, + 1, 0xF9E2, 0x68A8, 0, + 1, 0xF9E3, 0x6CE5, 0, + 1, 0xF9E4, 0x7406, 0, + 1, 0xF9E5, 0x75E2, 0, + 1, 0xF9E6, 0x7F79, 0, + 1, 0xF9E7, 0x88CF, 0, + 1, 0xF9E8, 0x88E1, 0, + 1, 0xF9E9, 0x91CC, 0, + 1, 0xF9EA, 0x96E2, 0, + 1, 0xF9EB, 0x533F, 0, + 1, 0xF9EC, 0x6EBA, 0, + 1, 0xF9ED, 0x541D, 0, + 1, 0xF9EE, 0x71D0, 0, + 1, 0xF9EF, 0x7498, 0, + 1, 0xF9F0, 0x85FA, 0, + 1, 0xF9F1, 0x96A3, 0, + 1, 0xF9F2, 0x9C57, 0, + 1, 0xF9F3, 0x9E9F, 0, + 1, 0xF9F4, 0x6797, 0, + 1, 0xF9F5, 0x6DCB, 0, + 1, 0xF9F6, 0x81E8, 0, + 1, 0xF9F7, 0x7ACB, 0, + 1, 0xF9F8, 0x7B20, 0, + 1, 0xF9F9, 0x7C92, 0, + 1, 0xF9FA, 0x72C0, 0, + 1, 0xF9FB, 0x7099, 0, + 1, 0xF9FC, 0x8B58, 0, + 1, 0xF9FD, 0x4EC0, 0, + 1, 0xF9FE, 0x8336, 0, + 1, 0xF9FF, 0x523A, 0, + 1, 0xFA00, 0x5207, 0, + 1, 0xFA01, 0x5EA6, 0, + 1, 0xFA02, 0x62D3, 0, + 1, 0xFA03, 0x7CD6, 0, + 1, 0xFA04, 0x5B85, 0, + 1, 0xFA05, 0x6D1E, 0, + 1, 0xFA06, 0x66B4, 0, + 1, 0xFA07, 0x8F3B, 0, + 1, 0xFA08, 0x884C, 0, + 1, 0xFA09, 0x964D, 0, + 1, 0xFA0A, 0x898B, 0, + 1, 0xFA0B, 0x5ED3, 0, + 1, 0xFA0C, 0x5140, 0, + 1, 0xFA0D, 0x55C0, 0, + 1, 0xFA10, 0x585A, 0, + 1, 0xFA12, 0x6674, 0, + 1, 0xFA15, 0x51DE, 0, + 1, 0xFA16, 0x732A, 0, + 1, 0xFA17, 0x76CA, 0, + 1, 0xFA18, 0x793C, 0, + 1, 0xFA19, 0x795E, 0, + 1, 0xFA1A, 0x7965, 0, + 1, 0xFA1B, 0x798F, 0, + 1, 0xFA1C, 0x9756, 0, + 1, 0xFA1D, 0x7CBE, 0, + 1, 0xFA1E, 0x7FBD, 0, + 1, 0xFA20, 0x8612, 0, + 1, 0xFA22, 0x8AF8, 0, + 1, 0xFA25, 0x9038, 0, + 1, 0xFA26, 0x90FD, 0, + 1, 0xFA2A, 0x98EF, 0, + 1, 0xFA2B, 0x98FC, 0, + 1, 0xFA2C, 0x9928, 0, + 1, 0xFA2D, 0x9DB4, 0, + 1, 0xFA30, 0x4FAE, 0, + 1, 0xFA31, 0x50E7, 0, + 1, 0xFA32, 0x514D, 0, + 1, 0xFA33, 0x52C9, 0, + 1, 0xFA34, 0x52E4, 0, + 1, 0xFA35, 0x5351, 0, + 1, 0xFA36, 0x559D, 0, + 1, 0xFA37, 0x5606, 0, + 1, 0xFA38, 0x5668, 0, + 1, 0xFA39, 0x5840, 0, + 1, 0xFA3A, 0x58A8, 0, + 1, 0xFA3B, 0x5C64, 0, + 1, 0xFA3C, 0x5C6E, 0, + 1, 0xFA3D, 0x6094, 0, + 1, 0xFA3E, 0x6168, 0, + 1, 0xFA3F, 0x618E, 0, + 1, 0xFA40, 0x61F2, 0, + 1, 0xFA41, 0x654F, 0, + 1, 0xFA42, 0x65E2, 0, + 1, 0xFA43, 0x6691, 0, + 1, 0xFA44, 0x6885, 0, + 1, 0xFA45, 0x6D77, 0, + 1, 0xFA46, 0x6E1A, 0, + 1, 0xFA47, 0x6F22, 0, + 1, 0xFA48, 0x716E, 0, + 1, 0xFA49, 0x722B, 0, + 1, 0xFA4A, 0x7422, 0, + 1, 0xFA4B, 0x7891, 0, + 1, 0xFA4C, 0x793E, 0, + 1, 0xFA4D, 0x7949, 0, + 1, 0xFA4E, 0x7948, 0, + 1, 0xFA4F, 0x7950, 0, + 1, 0xFA50, 0x7956, 0, + 1, 0xFA51, 0x795D, 0, + 1, 0xFA52, 0x798D, 0, + 1, 0xFA53, 0x798E, 0, + 1, 0xFA54, 0x7A40, 0, + 1, 0xFA55, 0x7A81, 0, + 1, 0xFA56, 0x7BC0, 0, + 1, 0xFA57, 0x7DF4, 0, + 1, 0xFA58, 0x7E09, 0, + 1, 0xFA59, 0x7E41, 0, + 1, 0xFA5A, 0x7F72, 0, + 1, 0xFA5B, 0x8005, 0, + 1, 0xFA5C, 0x81ED, 0, + 1, 0xFA5D, 0x8279, 0, + 1, 0xFA5E, 0x8279, 0, + 1, 0xFA5F, 0x8457, 0, + 1, 0xFA60, 0x8910, 0, + 1, 0xFA61, 0x8996, 0, + 1, 0xFA62, 0x8B01, 0, + 1, 0xFA63, 0x8B39, 0, + 1, 0xFA64, 0x8CD3, 0, + 1, 0xFA65, 0x8D08, 0, + 1, 0xFA66, 0x8FB6, 0, + 1, 0xFA67, 0x9038, 0, + 1, 0xFA68, 0x96E3, 0, + 1, 0xFA69, 0x97FF, 0, + 1, 0xFA6A, 0x983B, 0, + 16, 0xFB00, 0x0066, 0x0066, 0, + 16, 0xFB01, 0x0066, 0x0069, 0, + 16, 0xFB02, 0x0066, 0x006C, 0, + 16, 0xFB03, 0x0066, 0x0066, 0x0069, 0, + 16, 0xFB04, 0x0066, 0x0066, 0x006C, 0, + 16, 0xFB05, 0x017F, 0x0074, 0, + 16, 0xFB06, 0x0073, 0x0074, 0, + 16, 0xFB13, 0x0574, 0x0576, 0, + 16, 0xFB14, 0x0574, 0x0565, 0, + 16, 0xFB15, 0x0574, 0x056B, 0, + 16, 0xFB16, 0x057E, 0x0576, 0, + 16, 0xFB17, 0x0574, 0x056D, 0, + 1, 0xFB1D, 0x05D9, 0x05B4, 0, + 1, 0xFB1F, 0x05F2, 0x05B7, 0, + 2, 0xFB20, 0x05E2, 0, + 2, 0xFB21, 0x05D0, 0, + 2, 0xFB22, 0x05D3, 0, + 2, 0xFB23, 0x05D4, 0, + 2, 0xFB24, 0x05DB, 0, + 2, 0xFB25, 0x05DC, 0, + 2, 0xFB26, 0x05DD, 0, + 2, 0xFB27, 0x05E8, 0, + 2, 0xFB28, 0x05EA, 0, + 2, 0xFB29, 0x002B, 0, + 1, 0xFB2A, 0x05E9, 0x05C1, 0, + 1, 0xFB2B, 0x05E9, 0x05C2, 0, + 1, 0xFB2C, 0xFB49, 0x05C1, 0, + 1, 0xFB2D, 0xFB49, 0x05C2, 0, + 1, 0xFB2E, 0x05D0, 0x05B7, 0, + 1, 0xFB2F, 0x05D0, 0x05B8, 0, + 1, 0xFB30, 0x05D0, 0x05BC, 0, + 1, 0xFB31, 0x05D1, 0x05BC, 0, + 1, 0xFB32, 0x05D2, 0x05BC, 0, + 1, 0xFB33, 0x05D3, 0x05BC, 0, + 1, 0xFB34, 0x05D4, 0x05BC, 0, + 1, 0xFB35, 0x05D5, 0x05BC, 0, + 1, 0xFB36, 0x05D6, 0x05BC, 0, + 1, 0xFB38, 0x05D8, 0x05BC, 0, + 1, 0xFB39, 0x05D9, 0x05BC, 0, + 1, 0xFB3A, 0x05DA, 0x05BC, 0, + 1, 0xFB3B, 0x05DB, 0x05BC, 0, + 1, 0xFB3C, 0x05DC, 0x05BC, 0, + 1, 0xFB3E, 0x05DE, 0x05BC, 0, + 1, 0xFB40, 0x05E0, 0x05BC, 0, + 1, 0xFB41, 0x05E1, 0x05BC, 0, + 1, 0xFB43, 0x05E3, 0x05BC, 0, + 1, 0xFB44, 0x05E4, 0x05BC, 0, + 1, 0xFB46, 0x05E6, 0x05BC, 0, + 1, 0xFB47, 0x05E7, 0x05BC, 0, + 1, 0xFB48, 0x05E8, 0x05BC, 0, + 1, 0xFB49, 0x05E9, 0x05BC, 0, + 1, 0xFB4A, 0x05EA, 0x05BC, 0, + 1, 0xFB4B, 0x05D5, 0x05B9, 0, + 1, 0xFB4C, 0x05D1, 0x05BF, 0, + 1, 0xFB4D, 0x05DB, 0x05BF, 0, + 1, 0xFB4E, 0x05E4, 0x05BF, 0, + 16, 0xFB4F, 0x05D0, 0x05DC, 0, + 7, 0xFB50, 0x0671, 0, + 6, 0xFB51, 0x0671, 0, + 7, 0xFB52, 0x067B, 0, + 6, 0xFB53, 0x067B, 0, + 4, 0xFB54, 0x067B, 0, + 5, 0xFB55, 0x067B, 0, + 7, 0xFB56, 0x067E, 0, + 6, 0xFB57, 0x067E, 0, + 4, 0xFB58, 0x067E, 0, + 5, 0xFB59, 0x067E, 0, + 7, 0xFB5A, 0x0680, 0, + 6, 0xFB5B, 0x0680, 0, + 4, 0xFB5C, 0x0680, 0, + 5, 0xFB5D, 0x0680, 0, + 7, 0xFB5E, 0x067A, 0, + 6, 0xFB5F, 0x067A, 0, + 4, 0xFB60, 0x067A, 0, + 5, 0xFB61, 0x067A, 0, + 7, 0xFB62, 0x067F, 0, + 6, 0xFB63, 0x067F, 0, + 4, 0xFB64, 0x067F, 0, + 5, 0xFB65, 0x067F, 0, + 7, 0xFB66, 0x0679, 0, + 6, 0xFB67, 0x0679, 0, + 4, 0xFB68, 0x0679, 0, + 5, 0xFB69, 0x0679, 0, + 7, 0xFB6A, 0x06A4, 0, + 6, 0xFB6B, 0x06A4, 0, + 4, 0xFB6C, 0x06A4, 0, + 5, 0xFB6D, 0x06A4, 0, + 7, 0xFB6E, 0x06A6, 0, + 6, 0xFB6F, 0x06A6, 0, + 4, 0xFB70, 0x06A6, 0, + 5, 0xFB71, 0x06A6, 0, + 7, 0xFB72, 0x0684, 0, + 6, 0xFB73, 0x0684, 0, + 4, 0xFB74, 0x0684, 0, + 5, 0xFB75, 0x0684, 0, + 7, 0xFB76, 0x0683, 0, + 6, 0xFB77, 0x0683, 0, + 4, 0xFB78, 0x0683, 0, + 5, 0xFB79, 0x0683, 0, + 7, 0xFB7A, 0x0686, 0, + 6, 0xFB7B, 0x0686, 0, + 4, 0xFB7C, 0x0686, 0, + 5, 0xFB7D, 0x0686, 0, + 7, 0xFB7E, 0x0687, 0, + 6, 0xFB7F, 0x0687, 0, + 4, 0xFB80, 0x0687, 0, + 5, 0xFB81, 0x0687, 0, + 7, 0xFB82, 0x068D, 0, + 6, 0xFB83, 0x068D, 0, + 7, 0xFB84, 0x068C, 0, + 6, 0xFB85, 0x068C, 0, + 7, 0xFB86, 0x068E, 0, + 6, 0xFB87, 0x068E, 0, + 7, 0xFB88, 0x0688, 0, + 6, 0xFB89, 0x0688, 0, + 7, 0xFB8A, 0x0698, 0, + 6, 0xFB8B, 0x0698, 0, + 7, 0xFB8C, 0x0691, 0, + 6, 0xFB8D, 0x0691, 0, + 7, 0xFB8E, 0x06A9, 0, + 6, 0xFB8F, 0x06A9, 0, + 4, 0xFB90, 0x06A9, 0, + 5, 0xFB91, 0x06A9, 0, + 7, 0xFB92, 0x06AF, 0, + 6, 0xFB93, 0x06AF, 0, + 4, 0xFB94, 0x06AF, 0, + 5, 0xFB95, 0x06AF, 0, + 7, 0xFB96, 0x06B3, 0, + 6, 0xFB97, 0x06B3, 0, + 4, 0xFB98, 0x06B3, 0, + 5, 0xFB99, 0x06B3, 0, + 7, 0xFB9A, 0x06B1, 0, + 6, 0xFB9B, 0x06B1, 0, + 4, 0xFB9C, 0x06B1, 0, + 5, 0xFB9D, 0x06B1, 0, + 7, 0xFB9E, 0x06BA, 0, + 6, 0xFB9F, 0x06BA, 0, + 7, 0xFBA0, 0x06BB, 0, + 6, 0xFBA1, 0x06BB, 0, + 4, 0xFBA2, 0x06BB, 0, + 5, 0xFBA3, 0x06BB, 0, + 7, 0xFBA4, 0x06C0, 0, + 6, 0xFBA5, 0x06C0, 0, + 7, 0xFBA6, 0x06C1, 0, + 6, 0xFBA7, 0x06C1, 0, + 4, 0xFBA8, 0x06C1, 0, + 5, 0xFBA9, 0x06C1, 0, + 7, 0xFBAA, 0x06BE, 0, + 6, 0xFBAB, 0x06BE, 0, + 4, 0xFBAC, 0x06BE, 0, + 5, 0xFBAD, 0x06BE, 0, + 7, 0xFBAE, 0x06D2, 0, + 6, 0xFBAF, 0x06D2, 0, + 7, 0xFBB0, 0x06D3, 0, + 6, 0xFBB1, 0x06D3, 0, + 7, 0xFBD3, 0x06AD, 0, + 6, 0xFBD4, 0x06AD, 0, + 4, 0xFBD5, 0x06AD, 0, + 5, 0xFBD6, 0x06AD, 0, + 7, 0xFBD7, 0x06C7, 0, + 6, 0xFBD8, 0x06C7, 0, + 7, 0xFBD9, 0x06C6, 0, + 6, 0xFBDA, 0x06C6, 0, + 7, 0xFBDB, 0x06C8, 0, + 6, 0xFBDC, 0x06C8, 0, + 7, 0xFBDD, 0x0677, 0, + 7, 0xFBDE, 0x06CB, 0, + 6, 0xFBDF, 0x06CB, 0, + 7, 0xFBE0, 0x06C5, 0, + 6, 0xFBE1, 0x06C5, 0, + 7, 0xFBE2, 0x06C9, 0, + 6, 0xFBE3, 0x06C9, 0, + 7, 0xFBE4, 0x06D0, 0, + 6, 0xFBE5, 0x06D0, 0, + 4, 0xFBE6, 0x06D0, 0, + 5, 0xFBE7, 0x06D0, 0, + 4, 0xFBE8, 0x0649, 0, + 5, 0xFBE9, 0x0649, 0, + 7, 0xFBEA, 0x0626, 0x0627, 0, + 6, 0xFBEB, 0x0626, 0x0627, 0, + 7, 0xFBEC, 0x0626, 0x06D5, 0, + 6, 0xFBED, 0x0626, 0x06D5, 0, + 7, 0xFBEE, 0x0626, 0x0648, 0, + 6, 0xFBEF, 0x0626, 0x0648, 0, + 7, 0xFBF0, 0x0626, 0x06C7, 0, + 6, 0xFBF1, 0x0626, 0x06C7, 0, + 7, 0xFBF2, 0x0626, 0x06C6, 0, + 6, 0xFBF3, 0x0626, 0x06C6, 0, + 7, 0xFBF4, 0x0626, 0x06C8, 0, + 6, 0xFBF5, 0x0626, 0x06C8, 0, + 7, 0xFBF6, 0x0626, 0x06D0, 0, + 6, 0xFBF7, 0x0626, 0x06D0, 0, + 4, 0xFBF8, 0x0626, 0x06D0, 0, + 7, 0xFBF9, 0x0626, 0x0649, 0, + 6, 0xFBFA, 0x0626, 0x0649, 0, + 4, 0xFBFB, 0x0626, 0x0649, 0, + 7, 0xFBFC, 0x06CC, 0, + 6, 0xFBFD, 0x06CC, 0, + 4, 0xFBFE, 0x06CC, 0, + 5, 0xFBFF, 0x06CC, 0, + 7, 0xFC00, 0x0626, 0x062C, 0, + 7, 0xFC01, 0x0626, 0x062D, 0, + 7, 0xFC02, 0x0626, 0x0645, 0, + 7, 0xFC03, 0x0626, 0x0649, 0, + 7, 0xFC04, 0x0626, 0x064A, 0, + 7, 0xFC05, 0x0628, 0x062C, 0, + 7, 0xFC06, 0x0628, 0x062D, 0, + 7, 0xFC07, 0x0628, 0x062E, 0, + 7, 0xFC08, 0x0628, 0x0645, 0, + 7, 0xFC09, 0x0628, 0x0649, 0, + 7, 0xFC0A, 0x0628, 0x064A, 0, + 7, 0xFC0B, 0x062A, 0x062C, 0, + 7, 0xFC0C, 0x062A, 0x062D, 0, + 7, 0xFC0D, 0x062A, 0x062E, 0, + 7, 0xFC0E, 0x062A, 0x0645, 0, + 7, 0xFC0F, 0x062A, 0x0649, 0, + 7, 0xFC10, 0x062A, 0x064A, 0, + 7, 0xFC11, 0x062B, 0x062C, 0, + 7, 0xFC12, 0x062B, 0x0645, 0, + 7, 0xFC13, 0x062B, 0x0649, 0, + 7, 0xFC14, 0x062B, 0x064A, 0, + 7, 0xFC15, 0x062C, 0x062D, 0, + 7, 0xFC16, 0x062C, 0x0645, 0, + 7, 0xFC17, 0x062D, 0x062C, 0, + 7, 0xFC18, 0x062D, 0x0645, 0, + 7, 0xFC19, 0x062E, 0x062C, 0, + 7, 0xFC1A, 0x062E, 0x062D, 0, + 7, 0xFC1B, 0x062E, 0x0645, 0, + 7, 0xFC1C, 0x0633, 0x062C, 0, + 7, 0xFC1D, 0x0633, 0x062D, 0, + 7, 0xFC1E, 0x0633, 0x062E, 0, + 7, 0xFC1F, 0x0633, 0x0645, 0, + 7, 0xFC20, 0x0635, 0x062D, 0, + 7, 0xFC21, 0x0635, 0x0645, 0, + 7, 0xFC22, 0x0636, 0x062C, 0, + 7, 0xFC23, 0x0636, 0x062D, 0, + 7, 0xFC24, 0x0636, 0x062E, 0, + 7, 0xFC25, 0x0636, 0x0645, 0, + 7, 0xFC26, 0x0637, 0x062D, 0, + 7, 0xFC27, 0x0637, 0x0645, 0, + 7, 0xFC28, 0x0638, 0x0645, 0, + 7, 0xFC29, 0x0639, 0x062C, 0, + 7, 0xFC2A, 0x0639, 0x0645, 0, + 7, 0xFC2B, 0x063A, 0x062C, 0, + 7, 0xFC2C, 0x063A, 0x0645, 0, + 7, 0xFC2D, 0x0641, 0x062C, 0, + 7, 0xFC2E, 0x0641, 0x062D, 0, + 7, 0xFC2F, 0x0641, 0x062E, 0, + 7, 0xFC30, 0x0641, 0x0645, 0, + 7, 0xFC31, 0x0641, 0x0649, 0, + 7, 0xFC32, 0x0641, 0x064A, 0, + 7, 0xFC33, 0x0642, 0x062D, 0, + 7, 0xFC34, 0x0642, 0x0645, 0, + 7, 0xFC35, 0x0642, 0x0649, 0, + 7, 0xFC36, 0x0642, 0x064A, 0, + 7, 0xFC37, 0x0643, 0x0627, 0, + 7, 0xFC38, 0x0643, 0x062C, 0, + 7, 0xFC39, 0x0643, 0x062D, 0, + 7, 0xFC3A, 0x0643, 0x062E, 0, + 7, 0xFC3B, 0x0643, 0x0644, 0, + 7, 0xFC3C, 0x0643, 0x0645, 0, + 7, 0xFC3D, 0x0643, 0x0649, 0, + 7, 0xFC3E, 0x0643, 0x064A, 0, + 7, 0xFC3F, 0x0644, 0x062C, 0, + 7, 0xFC40, 0x0644, 0x062D, 0, + 7, 0xFC41, 0x0644, 0x062E, 0, + 7, 0xFC42, 0x0644, 0x0645, 0, + 7, 0xFC43, 0x0644, 0x0649, 0, + 7, 0xFC44, 0x0644, 0x064A, 0, + 7, 0xFC45, 0x0645, 0x062C, 0, + 7, 0xFC46, 0x0645, 0x062D, 0, + 7, 0xFC47, 0x0645, 0x062E, 0, + 7, 0xFC48, 0x0645, 0x0645, 0, + 7, 0xFC49, 0x0645, 0x0649, 0, + 7, 0xFC4A, 0x0645, 0x064A, 0, + 7, 0xFC4B, 0x0646, 0x062C, 0, + 7, 0xFC4C, 0x0646, 0x062D, 0, + 7, 0xFC4D, 0x0646, 0x062E, 0, + 7, 0xFC4E, 0x0646, 0x0645, 0, + 7, 0xFC4F, 0x0646, 0x0649, 0, + 7, 0xFC50, 0x0646, 0x064A, 0, + 7, 0xFC51, 0x0647, 0x062C, 0, + 7, 0xFC52, 0x0647, 0x0645, 0, + 7, 0xFC53, 0x0647, 0x0649, 0, + 7, 0xFC54, 0x0647, 0x064A, 0, + 7, 0xFC55, 0x064A, 0x062C, 0, + 7, 0xFC56, 0x064A, 0x062D, 0, + 7, 0xFC57, 0x064A, 0x062E, 0, + 7, 0xFC58, 0x064A, 0x0645, 0, + 7, 0xFC59, 0x064A, 0x0649, 0, + 7, 0xFC5A, 0x064A, 0x064A, 0, + 7, 0xFC5B, 0x0630, 0x0670, 0, + 7, 0xFC5C, 0x0631, 0x0670, 0, + 7, 0xFC5D, 0x0649, 0x0670, 0, + 7, 0xFC5E, 0x0020, 0x064C, 0x0651, 0, + 7, 0xFC5F, 0x0020, 0x064D, 0x0651, 0, + 7, 0xFC60, 0x0020, 0x064E, 0x0651, 0, + 7, 0xFC61, 0x0020, 0x064F, 0x0651, 0, + 7, 0xFC62, 0x0020, 0x0650, 0x0651, 0, + 7, 0xFC63, 0x0020, 0x0651, 0x0670, 0, + 6, 0xFC64, 0x0626, 0x0631, 0, + 6, 0xFC65, 0x0626, 0x0632, 0, + 6, 0xFC66, 0x0626, 0x0645, 0, + 6, 0xFC67, 0x0626, 0x0646, 0, + 6, 0xFC68, 0x0626, 0x0649, 0, + 6, 0xFC69, 0x0626, 0x064A, 0, + 6, 0xFC6A, 0x0628, 0x0631, 0, + 6, 0xFC6B, 0x0628, 0x0632, 0, + 6, 0xFC6C, 0x0628, 0x0645, 0, + 6, 0xFC6D, 0x0628, 0x0646, 0, + 6, 0xFC6E, 0x0628, 0x0649, 0, + 6, 0xFC6F, 0x0628, 0x064A, 0, + 6, 0xFC70, 0x062A, 0x0631, 0, + 6, 0xFC71, 0x062A, 0x0632, 0, + 6, 0xFC72, 0x062A, 0x0645, 0, + 6, 0xFC73, 0x062A, 0x0646, 0, + 6, 0xFC74, 0x062A, 0x0649, 0, + 6, 0xFC75, 0x062A, 0x064A, 0, + 6, 0xFC76, 0x062B, 0x0631, 0, + 6, 0xFC77, 0x062B, 0x0632, 0, + 6, 0xFC78, 0x062B, 0x0645, 0, + 6, 0xFC79, 0x062B, 0x0646, 0, + 6, 0xFC7A, 0x062B, 0x0649, 0, + 6, 0xFC7B, 0x062B, 0x064A, 0, + 6, 0xFC7C, 0x0641, 0x0649, 0, + 6, 0xFC7D, 0x0641, 0x064A, 0, + 6, 0xFC7E, 0x0642, 0x0649, 0, + 6, 0xFC7F, 0x0642, 0x064A, 0, + 6, 0xFC80, 0x0643, 0x0627, 0, + 6, 0xFC81, 0x0643, 0x0644, 0, + 6, 0xFC82, 0x0643, 0x0645, 0, + 6, 0xFC83, 0x0643, 0x0649, 0, + 6, 0xFC84, 0x0643, 0x064A, 0, + 6, 0xFC85, 0x0644, 0x0645, 0, + 6, 0xFC86, 0x0644, 0x0649, 0, + 6, 0xFC87, 0x0644, 0x064A, 0, + 6, 0xFC88, 0x0645, 0x0627, 0, + 6, 0xFC89, 0x0645, 0x0645, 0, + 6, 0xFC8A, 0x0646, 0x0631, 0, + 6, 0xFC8B, 0x0646, 0x0632, 0, + 6, 0xFC8C, 0x0646, 0x0645, 0, + 6, 0xFC8D, 0x0646, 0x0646, 0, + 6, 0xFC8E, 0x0646, 0x0649, 0, + 6, 0xFC8F, 0x0646, 0x064A, 0, + 6, 0xFC90, 0x0649, 0x0670, 0, + 6, 0xFC91, 0x064A, 0x0631, 0, + 6, 0xFC92, 0x064A, 0x0632, 0, + 6, 0xFC93, 0x064A, 0x0645, 0, + 6, 0xFC94, 0x064A, 0x0646, 0, + 6, 0xFC95, 0x064A, 0x0649, 0, + 6, 0xFC96, 0x064A, 0x064A, 0, + 4, 0xFC97, 0x0626, 0x062C, 0, + 4, 0xFC98, 0x0626, 0x062D, 0, + 4, 0xFC99, 0x0626, 0x062E, 0, + 4, 0xFC9A, 0x0626, 0x0645, 0, + 4, 0xFC9B, 0x0626, 0x0647, 0, + 4, 0xFC9C, 0x0628, 0x062C, 0, + 4, 0xFC9D, 0x0628, 0x062D, 0, + 4, 0xFC9E, 0x0628, 0x062E, 0, + 4, 0xFC9F, 0x0628, 0x0645, 0, + 4, 0xFCA0, 0x0628, 0x0647, 0, + 4, 0xFCA1, 0x062A, 0x062C, 0, + 4, 0xFCA2, 0x062A, 0x062D, 0, + 4, 0xFCA3, 0x062A, 0x062E, 0, + 4, 0xFCA4, 0x062A, 0x0645, 0, + 4, 0xFCA5, 0x062A, 0x0647, 0, + 4, 0xFCA6, 0x062B, 0x0645, 0, + 4, 0xFCA7, 0x062C, 0x062D, 0, + 4, 0xFCA8, 0x062C, 0x0645, 0, + 4, 0xFCA9, 0x062D, 0x062C, 0, + 4, 0xFCAA, 0x062D, 0x0645, 0, + 4, 0xFCAB, 0x062E, 0x062C, 0, + 4, 0xFCAC, 0x062E, 0x0645, 0, + 4, 0xFCAD, 0x0633, 0x062C, 0, + 4, 0xFCAE, 0x0633, 0x062D, 0, + 4, 0xFCAF, 0x0633, 0x062E, 0, + 4, 0xFCB0, 0x0633, 0x0645, 0, + 4, 0xFCB1, 0x0635, 0x062D, 0, + 4, 0xFCB2, 0x0635, 0x062E, 0, + 4, 0xFCB3, 0x0635, 0x0645, 0, + 4, 0xFCB4, 0x0636, 0x062C, 0, + 4, 0xFCB5, 0x0636, 0x062D, 0, + 4, 0xFCB6, 0x0636, 0x062E, 0, + 4, 0xFCB7, 0x0636, 0x0645, 0, + 4, 0xFCB8, 0x0637, 0x062D, 0, + 4, 0xFCB9, 0x0638, 0x0645, 0, + 4, 0xFCBA, 0x0639, 0x062C, 0, + 4, 0xFCBB, 0x0639, 0x0645, 0, + 4, 0xFCBC, 0x063A, 0x062C, 0, + 4, 0xFCBD, 0x063A, 0x0645, 0, + 4, 0xFCBE, 0x0641, 0x062C, 0, + 4, 0xFCBF, 0x0641, 0x062D, 0, + 4, 0xFCC0, 0x0641, 0x062E, 0, + 4, 0xFCC1, 0x0641, 0x0645, 0, + 4, 0xFCC2, 0x0642, 0x062D, 0, + 4, 0xFCC3, 0x0642, 0x0645, 0, + 4, 0xFCC4, 0x0643, 0x062C, 0, + 4, 0xFCC5, 0x0643, 0x062D, 0, + 4, 0xFCC6, 0x0643, 0x062E, 0, + 4, 0xFCC7, 0x0643, 0x0644, 0, + 4, 0xFCC8, 0x0643, 0x0645, 0, + 4, 0xFCC9, 0x0644, 0x062C, 0, + 4, 0xFCCA, 0x0644, 0x062D, 0, + 4, 0xFCCB, 0x0644, 0x062E, 0, + 4, 0xFCCC, 0x0644, 0x0645, 0, + 4, 0xFCCD, 0x0644, 0x0647, 0, + 4, 0xFCCE, 0x0645, 0x062C, 0, + 4, 0xFCCF, 0x0645, 0x062D, 0, + 4, 0xFCD0, 0x0645, 0x062E, 0, + 4, 0xFCD1, 0x0645, 0x0645, 0, + 4, 0xFCD2, 0x0646, 0x062C, 0, + 4, 0xFCD3, 0x0646, 0x062D, 0, + 4, 0xFCD4, 0x0646, 0x062E, 0, + 4, 0xFCD5, 0x0646, 0x0645, 0, + 4, 0xFCD6, 0x0646, 0x0647, 0, + 4, 0xFCD7, 0x0647, 0x062C, 0, + 4, 0xFCD8, 0x0647, 0x0645, 0, + 4, 0xFCD9, 0x0647, 0x0670, 0, + 4, 0xFCDA, 0x064A, 0x062C, 0, + 4, 0xFCDB, 0x064A, 0x062D, 0, + 4, 0xFCDC, 0x064A, 0x062E, 0, + 4, 0xFCDD, 0x064A, 0x0645, 0, + 4, 0xFCDE, 0x064A, 0x0647, 0, + 5, 0xFCDF, 0x0626, 0x0645, 0, + 5, 0xFCE0, 0x0626, 0x0647, 0, + 5, 0xFCE1, 0x0628, 0x0645, 0, + 5, 0xFCE2, 0x0628, 0x0647, 0, + 5, 0xFCE3, 0x062A, 0x0645, 0, + 5, 0xFCE4, 0x062A, 0x0647, 0, + 5, 0xFCE5, 0x062B, 0x0645, 0, + 5, 0xFCE6, 0x062B, 0x0647, 0, + 5, 0xFCE7, 0x0633, 0x0645, 0, + 5, 0xFCE8, 0x0633, 0x0647, 0, + 5, 0xFCE9, 0x0634, 0x0645, 0, + 5, 0xFCEA, 0x0634, 0x0647, 0, + 5, 0xFCEB, 0x0643, 0x0644, 0, + 5, 0xFCEC, 0x0643, 0x0645, 0, + 5, 0xFCED, 0x0644, 0x0645, 0, + 5, 0xFCEE, 0x0646, 0x0645, 0, + 5, 0xFCEF, 0x0646, 0x0647, 0, + 5, 0xFCF0, 0x064A, 0x0645, 0, + 5, 0xFCF1, 0x064A, 0x0647, 0, + 5, 0xFCF2, 0x0640, 0x064E, 0x0651, 0, + 5, 0xFCF3, 0x0640, 0x064F, 0x0651, 0, + 5, 0xFCF4, 0x0640, 0x0650, 0x0651, 0, + 7, 0xFCF5, 0x0637, 0x0649, 0, + 7, 0xFCF6, 0x0637, 0x064A, 0, + 7, 0xFCF7, 0x0639, 0x0649, 0, + 7, 0xFCF8, 0x0639, 0x064A, 0, + 7, 0xFCF9, 0x063A, 0x0649, 0, + 7, 0xFCFA, 0x063A, 0x064A, 0, + 7, 0xFCFB, 0x0633, 0x0649, 0, + 7, 0xFCFC, 0x0633, 0x064A, 0, + 7, 0xFCFD, 0x0634, 0x0649, 0, + 7, 0xFCFE, 0x0634, 0x064A, 0, + 7, 0xFCFF, 0x062D, 0x0649, 0, + 7, 0xFD00, 0x062D, 0x064A, 0, + 7, 0xFD01, 0x062C, 0x0649, 0, + 7, 0xFD02, 0x062C, 0x064A, 0, + 7, 0xFD03, 0x062E, 0x0649, 0, + 7, 0xFD04, 0x062E, 0x064A, 0, + 7, 0xFD05, 0x0635, 0x0649, 0, + 7, 0xFD06, 0x0635, 0x064A, 0, + 7, 0xFD07, 0x0636, 0x0649, 0, + 7, 0xFD08, 0x0636, 0x064A, 0, + 7, 0xFD09, 0x0634, 0x062C, 0, + 7, 0xFD0A, 0x0634, 0x062D, 0, + 7, 0xFD0B, 0x0634, 0x062E, 0, + 7, 0xFD0C, 0x0634, 0x0645, 0, + 7, 0xFD0D, 0x0634, 0x0631, 0, + 7, 0xFD0E, 0x0633, 0x0631, 0, + 7, 0xFD0F, 0x0635, 0x0631, 0, + 7, 0xFD10, 0x0636, 0x0631, 0, + 6, 0xFD11, 0x0637, 0x0649, 0, + 6, 0xFD12, 0x0637, 0x064A, 0, + 6, 0xFD13, 0x0639, 0x0649, 0, + 6, 0xFD14, 0x0639, 0x064A, 0, + 6, 0xFD15, 0x063A, 0x0649, 0, + 6, 0xFD16, 0x063A, 0x064A, 0, + 6, 0xFD17, 0x0633, 0x0649, 0, + 6, 0xFD18, 0x0633, 0x064A, 0, + 6, 0xFD19, 0x0634, 0x0649, 0, + 6, 0xFD1A, 0x0634, 0x064A, 0, + 6, 0xFD1B, 0x062D, 0x0649, 0, + 6, 0xFD1C, 0x062D, 0x064A, 0, + 6, 0xFD1D, 0x062C, 0x0649, 0, + 6, 0xFD1E, 0x062C, 0x064A, 0, + 6, 0xFD1F, 0x062E, 0x0649, 0, + 6, 0xFD20, 0x062E, 0x064A, 0, + 6, 0xFD21, 0x0635, 0x0649, 0, + 6, 0xFD22, 0x0635, 0x064A, 0, + 6, 0xFD23, 0x0636, 0x0649, 0, + 6, 0xFD24, 0x0636, 0x064A, 0, + 6, 0xFD25, 0x0634, 0x062C, 0, + 6, 0xFD26, 0x0634, 0x062D, 0, + 6, 0xFD27, 0x0634, 0x062E, 0, + 6, 0xFD28, 0x0634, 0x0645, 0, + 6, 0xFD29, 0x0634, 0x0631, 0, + 6, 0xFD2A, 0x0633, 0x0631, 0, + 6, 0xFD2B, 0x0635, 0x0631, 0, + 6, 0xFD2C, 0x0636, 0x0631, 0, + 4, 0xFD2D, 0x0634, 0x062C, 0, + 4, 0xFD2E, 0x0634, 0x062D, 0, + 4, 0xFD2F, 0x0634, 0x062E, 0, + 4, 0xFD30, 0x0634, 0x0645, 0, + 4, 0xFD31, 0x0633, 0x0647, 0, + 4, 0xFD32, 0x0634, 0x0647, 0, + 4, 0xFD33, 0x0637, 0x0645, 0, + 5, 0xFD34, 0x0633, 0x062C, 0, + 5, 0xFD35, 0x0633, 0x062D, 0, + 5, 0xFD36, 0x0633, 0x062E, 0, + 5, 0xFD37, 0x0634, 0x062C, 0, + 5, 0xFD38, 0x0634, 0x062D, 0, + 5, 0xFD39, 0x0634, 0x062E, 0, + 5, 0xFD3A, 0x0637, 0x0645, 0, + 5, 0xFD3B, 0x0638, 0x0645, 0, + 6, 0xFD3C, 0x0627, 0x064B, 0, + 7, 0xFD3D, 0x0627, 0x064B, 0, + 4, 0xFD50, 0x062A, 0x062C, 0x0645, 0, + 6, 0xFD51, 0x062A, 0x062D, 0x062C, 0, + 4, 0xFD52, 0x062A, 0x062D, 0x062C, 0, + 4, 0xFD53, 0x062A, 0x062D, 0x0645, 0, + 4, 0xFD54, 0x062A, 0x062E, 0x0645, 0, + 4, 0xFD55, 0x062A, 0x0645, 0x062C, 0, + 4, 0xFD56, 0x062A, 0x0645, 0x062D, 0, + 4, 0xFD57, 0x062A, 0x0645, 0x062E, 0, + 6, 0xFD58, 0x062C, 0x0645, 0x062D, 0, + 4, 0xFD59, 0x062C, 0x0645, 0x062D, 0, + 6, 0xFD5A, 0x062D, 0x0645, 0x064A, 0, + 6, 0xFD5B, 0x062D, 0x0645, 0x0649, 0, + 4, 0xFD5C, 0x0633, 0x062D, 0x062C, 0, + 4, 0xFD5D, 0x0633, 0x062C, 0x062D, 0, + 6, 0xFD5E, 0x0633, 0x062C, 0x0649, 0, + 6, 0xFD5F, 0x0633, 0x0645, 0x062D, 0, + 4, 0xFD60, 0x0633, 0x0645, 0x062D, 0, + 4, 0xFD61, 0x0633, 0x0645, 0x062C, 0, + 6, 0xFD62, 0x0633, 0x0645, 0x0645, 0, + 4, 0xFD63, 0x0633, 0x0645, 0x0645, 0, + 6, 0xFD64, 0x0635, 0x062D, 0x062D, 0, + 4, 0xFD65, 0x0635, 0x062D, 0x062D, 0, + 6, 0xFD66, 0x0635, 0x0645, 0x0645, 0, + 6, 0xFD67, 0x0634, 0x062D, 0x0645, 0, + 4, 0xFD68, 0x0634, 0x062D, 0x0645, 0, + 6, 0xFD69, 0x0634, 0x062C, 0x064A, 0, + 6, 0xFD6A, 0x0634, 0x0645, 0x062E, 0, + 4, 0xFD6B, 0x0634, 0x0645, 0x062E, 0, + 6, 0xFD6C, 0x0634, 0x0645, 0x0645, 0, + 4, 0xFD6D, 0x0634, 0x0645, 0x0645, 0, + 6, 0xFD6E, 0x0636, 0x062D, 0x0649, 0, + 6, 0xFD6F, 0x0636, 0x062E, 0x0645, 0, + 4, 0xFD70, 0x0636, 0x062E, 0x0645, 0, + 6, 0xFD71, 0x0637, 0x0645, 0x062D, 0, + 4, 0xFD72, 0x0637, 0x0645, 0x062D, 0, + 4, 0xFD73, 0x0637, 0x0645, 0x0645, 0, + 6, 0xFD74, 0x0637, 0x0645, 0x064A, 0, + 6, 0xFD75, 0x0639, 0x062C, 0x0645, 0, + 6, 0xFD76, 0x0639, 0x0645, 0x0645, 0, + 4, 0xFD77, 0x0639, 0x0645, 0x0645, 0, + 6, 0xFD78, 0x0639, 0x0645, 0x0649, 0, + 6, 0xFD79, 0x063A, 0x0645, 0x0645, 0, + 6, 0xFD7A, 0x063A, 0x0645, 0x064A, 0, + 6, 0xFD7B, 0x063A, 0x0645, 0x0649, 0, + 6, 0xFD7C, 0x0641, 0x062E, 0x0645, 0, + 4, 0xFD7D, 0x0641, 0x062E, 0x0645, 0, + 6, 0xFD7E, 0x0642, 0x0645, 0x062D, 0, + 6, 0xFD7F, 0x0642, 0x0645, 0x0645, 0, + 6, 0xFD80, 0x0644, 0x062D, 0x0645, 0, + 6, 0xFD81, 0x0644, 0x062D, 0x064A, 0, + 6, 0xFD82, 0x0644, 0x062D, 0x0649, 0, + 4, 0xFD83, 0x0644, 0x062C, 0x062C, 0, + 6, 0xFD84, 0x0644, 0x062C, 0x062C, 0, + 6, 0xFD85, 0x0644, 0x062E, 0x0645, 0, + 4, 0xFD86, 0x0644, 0x062E, 0x0645, 0, + 6, 0xFD87, 0x0644, 0x0645, 0x062D, 0, + 4, 0xFD88, 0x0644, 0x0645, 0x062D, 0, + 4, 0xFD89, 0x0645, 0x062D, 0x062C, 0, + 4, 0xFD8A, 0x0645, 0x062D, 0x0645, 0, + 6, 0xFD8B, 0x0645, 0x062D, 0x064A, 0, + 4, 0xFD8C, 0x0645, 0x062C, 0x062D, 0, + 4, 0xFD8D, 0x0645, 0x062C, 0x0645, 0, + 4, 0xFD8E, 0x0645, 0x062E, 0x062C, 0, + 4, 0xFD8F, 0x0645, 0x062E, 0x0645, 0, + 4, 0xFD92, 0x0645, 0x062C, 0x062E, 0, + 4, 0xFD93, 0x0647, 0x0645, 0x062C, 0, + 4, 0xFD94, 0x0647, 0x0645, 0x0645, 0, + 4, 0xFD95, 0x0646, 0x062D, 0x0645, 0, + 6, 0xFD96, 0x0646, 0x062D, 0x0649, 0, + 6, 0xFD97, 0x0646, 0x062C, 0x0645, 0, + 4, 0xFD98, 0x0646, 0x062C, 0x0645, 0, + 6, 0xFD99, 0x0646, 0x062C, 0x0649, 0, + 6, 0xFD9A, 0x0646, 0x0645, 0x064A, 0, + 6, 0xFD9B, 0x0646, 0x0645, 0x0649, 0, + 6, 0xFD9C, 0x064A, 0x0645, 0x0645, 0, + 4, 0xFD9D, 0x064A, 0x0645, 0x0645, 0, + 6, 0xFD9E, 0x0628, 0x062E, 0x064A, 0, + 6, 0xFD9F, 0x062A, 0x062C, 0x064A, 0, + 6, 0xFDA0, 0x062A, 0x062C, 0x0649, 0, + 6, 0xFDA1, 0x062A, 0x062E, 0x064A, 0, + 6, 0xFDA2, 0x062A, 0x062E, 0x0649, 0, + 6, 0xFDA3, 0x062A, 0x0645, 0x064A, 0, + 6, 0xFDA4, 0x062A, 0x0645, 0x0649, 0, + 6, 0xFDA5, 0x062C, 0x0645, 0x064A, 0, + 6, 0xFDA6, 0x062C, 0x062D, 0x0649, 0, + 6, 0xFDA7, 0x062C, 0x0645, 0x0649, 0, + 6, 0xFDA8, 0x0633, 0x062E, 0x0649, 0, + 6, 0xFDA9, 0x0635, 0x062D, 0x064A, 0, + 6, 0xFDAA, 0x0634, 0x062D, 0x064A, 0, + 6, 0xFDAB, 0x0636, 0x062D, 0x064A, 0, + 6, 0xFDAC, 0x0644, 0x062C, 0x064A, 0, + 6, 0xFDAD, 0x0644, 0x0645, 0x064A, 0, + 6, 0xFDAE, 0x064A, 0x062D, 0x064A, 0, + 6, 0xFDAF, 0x064A, 0x062C, 0x064A, 0, + 6, 0xFDB0, 0x064A, 0x0645, 0x064A, 0, + 6, 0xFDB1, 0x0645, 0x0645, 0x064A, 0, + 6, 0xFDB2, 0x0642, 0x0645, 0x064A, 0, + 6, 0xFDB3, 0x0646, 0x062D, 0x064A, 0, + 4, 0xFDB4, 0x0642, 0x0645, 0x062D, 0, + 4, 0xFDB5, 0x0644, 0x062D, 0x0645, 0, + 6, 0xFDB6, 0x0639, 0x0645, 0x064A, 0, + 6, 0xFDB7, 0x0643, 0x0645, 0x064A, 0, + 4, 0xFDB8, 0x0646, 0x062C, 0x062D, 0, + 6, 0xFDB9, 0x0645, 0x062E, 0x064A, 0, + 4, 0xFDBA, 0x0644, 0x062C, 0x0645, 0, + 6, 0xFDBB, 0x0643, 0x0645, 0x0645, 0, + 6, 0xFDBC, 0x0644, 0x062C, 0x0645, 0, + 6, 0xFDBD, 0x0646, 0x062C, 0x062D, 0, + 6, 0xFDBE, 0x062C, 0x062D, 0x064A, 0, + 6, 0xFDBF, 0x062D, 0x062C, 0x064A, 0, + 6, 0xFDC0, 0x0645, 0x062C, 0x064A, 0, + 6, 0xFDC1, 0x0641, 0x0645, 0x064A, 0, + 6, 0xFDC2, 0x0628, 0x062D, 0x064A, 0, + 4, 0xFDC3, 0x0643, 0x0645, 0x0645, 0, + 4, 0xFDC4, 0x0639, 0x062C, 0x0645, 0, + 4, 0xFDC5, 0x0635, 0x0645, 0x0645, 0, + 6, 0xFDC6, 0x0633, 0x062E, 0x064A, 0, + 6, 0xFDC7, 0x0646, 0x062C, 0x064A, 0, + 7, 0xFDF0, 0x0635, 0x0644, 0x06D2, 0, + 7, 0xFDF1, 0x0642, 0x0644, 0x06D2, 0, + 7, 0xFDF2, 0x0627, 0x0644, 0x0644, 0x0647, 0, + 7, 0xFDF3, 0x0627, 0x0643, 0x0628, 0x0631, 0, + 7, 0xFDF4, 0x0645, 0x062D, 0x0645, 0x062F, 0, + 7, 0xFDF5, 0x0635, 0x0644, 0x0639, 0x0645, 0, + 7, 0xFDF6, 0x0631, 0x0633, 0x0648, 0x0644, 0, + 7, 0xFDF7, 0x0639, 0x0644, 0x064A, 0x0647, 0, + 7, 0xFDF8, 0x0648, 0x0633, 0x0644, 0x0645, 0, + 7, 0xFDF9, 0x0635, 0x0644, 0x0649, 0, + 7, 0xFDFA, 0x0635, 0x0644, 0x0649, 0x0020, 0x0627, 0x0644, 0x0644, 0x0647, 0x0020, 0x0639, 0x0644, 0x064A, 0x0647, 0x0020, 0x0648, 0x0633, 0x0644, 0x0645, 0, + 7, 0xFDFB, 0x062C, 0x0644, 0x0020, 0x062C, 0x0644, 0x0627, 0x0644, 0x0647, 0, + 7, 0xFDFC, 0x0631, 0x06CC, 0x0627, 0x0644, 0, + 11, 0xFE30, 0x2025, 0, + 11, 0xFE31, 0x2014, 0, + 11, 0xFE32, 0x2013, 0, + 11, 0xFE33, 0x005F, 0, + 11, 0xFE34, 0x005F, 0, + 11, 0xFE35, 0x0028, 0, + 11, 0xFE36, 0x0029, 0, + 11, 0xFE37, 0x007B, 0, + 11, 0xFE38, 0x007D, 0, + 11, 0xFE39, 0x3014, 0, + 11, 0xFE3A, 0x3015, 0, + 11, 0xFE3B, 0x3010, 0, + 11, 0xFE3C, 0x3011, 0, + 11, 0xFE3D, 0x300A, 0, + 11, 0xFE3E, 0x300B, 0, + 11, 0xFE3F, 0x3008, 0, + 11, 0xFE40, 0x3009, 0, + 11, 0xFE41, 0x300C, 0, + 11, 0xFE42, 0x300D, 0, + 11, 0xFE43, 0x300E, 0, + 11, 0xFE44, 0x300F, 0, + 16, 0xFE49, 0x203E, 0, + 16, 0xFE4A, 0x203E, 0, + 16, 0xFE4B, 0x203E, 0, + 16, 0xFE4C, 0x203E, 0, + 16, 0xFE4D, 0x005F, 0, + 16, 0xFE4E, 0x005F, 0, + 16, 0xFE4F, 0x005F, 0, + 14, 0xFE50, 0x002C, 0, + 14, 0xFE51, 0x3001, 0, + 14, 0xFE52, 0x002E, 0, + 14, 0xFE54, 0x003B, 0, + 14, 0xFE55, 0x003A, 0, + 14, 0xFE56, 0x003F, 0, + 14, 0xFE57, 0x0021, 0, + 14, 0xFE58, 0x2014, 0, + 14, 0xFE59, 0x0028, 0, + 14, 0xFE5A, 0x0029, 0, + 14, 0xFE5B, 0x007B, 0, + 14, 0xFE5C, 0x007D, 0, + 14, 0xFE5D, 0x3014, 0, + 14, 0xFE5E, 0x3015, 0, + 14, 0xFE5F, 0x0023, 0, + 14, 0xFE60, 0x0026, 0, + 14, 0xFE61, 0x002A, 0, + 14, 0xFE62, 0x002B, 0, + 14, 0xFE63, 0x002D, 0, + 14, 0xFE64, 0x003C, 0, + 14, 0xFE65, 0x003E, 0, + 14, 0xFE66, 0x003D, 0, + 14, 0xFE68, 0x005C, 0, + 14, 0xFE69, 0x0024, 0, + 14, 0xFE6A, 0x0025, 0, + 14, 0xFE6B, 0x0040, 0, + 7, 0xFE70, 0x0020, 0x064B, 0, + 5, 0xFE71, 0x0640, 0x064B, 0, + 7, 0xFE72, 0x0020, 0x064C, 0, + 7, 0xFE74, 0x0020, 0x064D, 0, + 7, 0xFE76, 0x0020, 0x064E, 0, + 5, 0xFE77, 0x0640, 0x064E, 0, + 7, 0xFE78, 0x0020, 0x064F, 0, + 5, 0xFE79, 0x0640, 0x064F, 0, + 7, 0xFE7A, 0x0020, 0x0650, 0, + 5, 0xFE7B, 0x0640, 0x0650, 0, + 7, 0xFE7C, 0x0020, 0x0651, 0, + 5, 0xFE7D, 0x0640, 0x0651, 0, + 7, 0xFE7E, 0x0020, 0x0652, 0, + 5, 0xFE7F, 0x0640, 0x0652, 0, + 7, 0xFE80, 0x0621, 0, + 7, 0xFE81, 0x0622, 0, + 6, 0xFE82, 0x0622, 0, + 7, 0xFE83, 0x0623, 0, + 6, 0xFE84, 0x0623, 0, + 7, 0xFE85, 0x0624, 0, + 6, 0xFE86, 0x0624, 0, + 7, 0xFE87, 0x0625, 0, + 6, 0xFE88, 0x0625, 0, + 7, 0xFE89, 0x0626, 0, + 6, 0xFE8A, 0x0626, 0, + 4, 0xFE8B, 0x0626, 0, + 5, 0xFE8C, 0x0626, 0, + 7, 0xFE8D, 0x0627, 0, + 6, 0xFE8E, 0x0627, 0, + 7, 0xFE8F, 0x0628, 0, + 6, 0xFE90, 0x0628, 0, + 4, 0xFE91, 0x0628, 0, + 5, 0xFE92, 0x0628, 0, + 7, 0xFE93, 0x0629, 0, + 6, 0xFE94, 0x0629, 0, + 7, 0xFE95, 0x062A, 0, + 6, 0xFE96, 0x062A, 0, + 4, 0xFE97, 0x062A, 0, + 5, 0xFE98, 0x062A, 0, + 7, 0xFE99, 0x062B, 0, + 6, 0xFE9A, 0x062B, 0, + 4, 0xFE9B, 0x062B, 0, + 5, 0xFE9C, 0x062B, 0, + 7, 0xFE9D, 0x062C, 0, + 6, 0xFE9E, 0x062C, 0, + 4, 0xFE9F, 0x062C, 0, + 5, 0xFEA0, 0x062C, 0, + 7, 0xFEA1, 0x062D, 0, + 6, 0xFEA2, 0x062D, 0, + 4, 0xFEA3, 0x062D, 0, + 5, 0xFEA4, 0x062D, 0, + 7, 0xFEA5, 0x062E, 0, + 6, 0xFEA6, 0x062E, 0, + 4, 0xFEA7, 0x062E, 0, + 5, 0xFEA8, 0x062E, 0, + 7, 0xFEA9, 0x062F, 0, + 6, 0xFEAA, 0x062F, 0, + 7, 0xFEAB, 0x0630, 0, + 6, 0xFEAC, 0x0630, 0, + 7, 0xFEAD, 0x0631, 0, + 6, 0xFEAE, 0x0631, 0, + 7, 0xFEAF, 0x0632, 0, + 6, 0xFEB0, 0x0632, 0, + 7, 0xFEB1, 0x0633, 0, + 6, 0xFEB2, 0x0633, 0, + 4, 0xFEB3, 0x0633, 0, + 5, 0xFEB4, 0x0633, 0, + 7, 0xFEB5, 0x0634, 0, + 6, 0xFEB6, 0x0634, 0, + 4, 0xFEB7, 0x0634, 0, + 5, 0xFEB8, 0x0634, 0, + 7, 0xFEB9, 0x0635, 0, + 6, 0xFEBA, 0x0635, 0, + 4, 0xFEBB, 0x0635, 0, + 5, 0xFEBC, 0x0635, 0, + 7, 0xFEBD, 0x0636, 0, + 6, 0xFEBE, 0x0636, 0, + 4, 0xFEBF, 0x0636, 0, + 5, 0xFEC0, 0x0636, 0, + 7, 0xFEC1, 0x0637, 0, + 6, 0xFEC2, 0x0637, 0, + 4, 0xFEC3, 0x0637, 0, + 5, 0xFEC4, 0x0637, 0, + 7, 0xFEC5, 0x0638, 0, + 6, 0xFEC6, 0x0638, 0, + 4, 0xFEC7, 0x0638, 0, + 5, 0xFEC8, 0x0638, 0, + 7, 0xFEC9, 0x0639, 0, + 6, 0xFECA, 0x0639, 0, + 4, 0xFECB, 0x0639, 0, + 5, 0xFECC, 0x0639, 0, + 7, 0xFECD, 0x063A, 0, + 6, 0xFECE, 0x063A, 0, + 4, 0xFECF, 0x063A, 0, + 5, 0xFED0, 0x063A, 0, + 7, 0xFED1, 0x0641, 0, + 6, 0xFED2, 0x0641, 0, + 4, 0xFED3, 0x0641, 0, + 5, 0xFED4, 0x0641, 0, + 7, 0xFED5, 0x0642, 0, + 6, 0xFED6, 0x0642, 0, + 4, 0xFED7, 0x0642, 0, + 5, 0xFED8, 0x0642, 0, + 7, 0xFED9, 0x0643, 0, + 6, 0xFEDA, 0x0643, 0, + 4, 0xFEDB, 0x0643, 0, + 5, 0xFEDC, 0x0643, 0, + 7, 0xFEDD, 0x0644, 0, + 6, 0xFEDE, 0x0644, 0, + 4, 0xFEDF, 0x0644, 0, + 5, 0xFEE0, 0x0644, 0, + 7, 0xFEE1, 0x0645, 0, + 6, 0xFEE2, 0x0645, 0, + 4, 0xFEE3, 0x0645, 0, + 5, 0xFEE4, 0x0645, 0, + 7, 0xFEE5, 0x0646, 0, + 6, 0xFEE6, 0x0646, 0, + 4, 0xFEE7, 0x0646, 0, + 5, 0xFEE8, 0x0646, 0, + 7, 0xFEE9, 0x0647, 0, + 6, 0xFEEA, 0x0647, 0, + 4, 0xFEEB, 0x0647, 0, + 5, 0xFEEC, 0x0647, 0, + 7, 0xFEED, 0x0648, 0, + 6, 0xFEEE, 0x0648, 0, + 7, 0xFEEF, 0x0649, 0, + 6, 0xFEF0, 0x0649, 0, + 7, 0xFEF1, 0x064A, 0, + 6, 0xFEF2, 0x064A, 0, + 4, 0xFEF3, 0x064A, 0, + 5, 0xFEF4, 0x064A, 0, + 7, 0xFEF5, 0x0644, 0x0622, 0, + 6, 0xFEF6, 0x0644, 0x0622, 0, + 7, 0xFEF7, 0x0644, 0x0623, 0, + 6, 0xFEF8, 0x0644, 0x0623, 0, + 7, 0xFEF9, 0x0644, 0x0625, 0, + 6, 0xFEFA, 0x0644, 0x0625, 0, + 7, 0xFEFB, 0x0644, 0x0627, 0, + 6, 0xFEFC, 0x0644, 0x0627, 0, + 12, 0xFF01, 0x0021, 0, + 12, 0xFF02, 0x0022, 0, + 12, 0xFF03, 0x0023, 0, + 12, 0xFF04, 0x0024, 0, + 12, 0xFF05, 0x0025, 0, + 12, 0xFF06, 0x0026, 0, + 12, 0xFF07, 0x0027, 0, + 12, 0xFF08, 0x0028, 0, + 12, 0xFF09, 0x0029, 0, + 12, 0xFF0A, 0x002A, 0, + 12, 0xFF0B, 0x002B, 0, + 12, 0xFF0C, 0x002C, 0, + 12, 0xFF0D, 0x002D, 0, + 12, 0xFF0E, 0x002E, 0, + 12, 0xFF0F, 0x002F, 0, + 12, 0xFF10, 0x0030, 0, + 12, 0xFF11, 0x0031, 0, + 12, 0xFF12, 0x0032, 0, + 12, 0xFF13, 0x0033, 0, + 12, 0xFF14, 0x0034, 0, + 12, 0xFF15, 0x0035, 0, + 12, 0xFF16, 0x0036, 0, + 12, 0xFF17, 0x0037, 0, + 12, 0xFF18, 0x0038, 0, + 12, 0xFF19, 0x0039, 0, + 12, 0xFF1A, 0x003A, 0, + 12, 0xFF1B, 0x003B, 0, + 12, 0xFF1C, 0x003C, 0, + 12, 0xFF1D, 0x003D, 0, + 12, 0xFF1E, 0x003E, 0, + 12, 0xFF1F, 0x003F, 0, + 12, 0xFF20, 0x0040, 0, + 12, 0xFF21, 0x0041, 0, + 12, 0xFF22, 0x0042, 0, + 12, 0xFF23, 0x0043, 0, + 12, 0xFF24, 0x0044, 0, + 12, 0xFF25, 0x0045, 0, + 12, 0xFF26, 0x0046, 0, + 12, 0xFF27, 0x0047, 0, + 12, 0xFF28, 0x0048, 0, + 12, 0xFF29, 0x0049, 0, + 12, 0xFF2A, 0x004A, 0, + 12, 0xFF2B, 0x004B, 0, + 12, 0xFF2C, 0x004C, 0, + 12, 0xFF2D, 0x004D, 0, + 12, 0xFF2E, 0x004E, 0, + 12, 0xFF2F, 0x004F, 0, + 12, 0xFF30, 0x0050, 0, + 12, 0xFF31, 0x0051, 0, + 12, 0xFF32, 0x0052, 0, + 12, 0xFF33, 0x0053, 0, + 12, 0xFF34, 0x0054, 0, + 12, 0xFF35, 0x0055, 0, + 12, 0xFF36, 0x0056, 0, + 12, 0xFF37, 0x0057, 0, + 12, 0xFF38, 0x0058, 0, + 12, 0xFF39, 0x0059, 0, + 12, 0xFF3A, 0x005A, 0, + 12, 0xFF3B, 0x005B, 0, + 12, 0xFF3C, 0x005C, 0, + 12, 0xFF3D, 0x005D, 0, + 12, 0xFF3E, 0x005E, 0, + 12, 0xFF3F, 0x005F, 0, + 12, 0xFF40, 0x0060, 0, + 12, 0xFF41, 0x0061, 0, + 12, 0xFF42, 0x0062, 0, + 12, 0xFF43, 0x0063, 0, + 12, 0xFF44, 0x0064, 0, + 12, 0xFF45, 0x0065, 0, + 12, 0xFF46, 0x0066, 0, + 12, 0xFF47, 0x0067, 0, + 12, 0xFF48, 0x0068, 0, + 12, 0xFF49, 0x0069, 0, + 12, 0xFF4A, 0x006A, 0, + 12, 0xFF4B, 0x006B, 0, + 12, 0xFF4C, 0x006C, 0, + 12, 0xFF4D, 0x006D, 0, + 12, 0xFF4E, 0x006E, 0, + 12, 0xFF4F, 0x006F, 0, + 12, 0xFF50, 0x0070, 0, + 12, 0xFF51, 0x0071, 0, + 12, 0xFF52, 0x0072, 0, + 12, 0xFF53, 0x0073, 0, + 12, 0xFF54, 0x0074, 0, + 12, 0xFF55, 0x0075, 0, + 12, 0xFF56, 0x0076, 0, + 12, 0xFF57, 0x0077, 0, + 12, 0xFF58, 0x0078, 0, + 12, 0xFF59, 0x0079, 0, + 12, 0xFF5A, 0x007A, 0, + 12, 0xFF5B, 0x007B, 0, + 12, 0xFF5C, 0x007C, 0, + 12, 0xFF5D, 0x007D, 0, + 12, 0xFF5E, 0x007E, 0, + 12, 0xFF5F, 0x2985, 0, + 12, 0xFF60, 0x2986, 0, + 13, 0xFF61, 0x3002, 0, + 13, 0xFF62, 0x300C, 0, + 13, 0xFF63, 0x300D, 0, + 13, 0xFF64, 0x3001, 0, + 13, 0xFF65, 0x30FB, 0, + 13, 0xFF66, 0x30F2, 0, + 13, 0xFF67, 0x30A1, 0, + 13, 0xFF68, 0x30A3, 0, + 13, 0xFF69, 0x30A5, 0, + 13, 0xFF6A, 0x30A7, 0, + 13, 0xFF6B, 0x30A9, 0, + 13, 0xFF6C, 0x30E3, 0, + 13, 0xFF6D, 0x30E5, 0, + 13, 0xFF6E, 0x30E7, 0, + 13, 0xFF6F, 0x30C3, 0, + 13, 0xFF70, 0x30FC, 0, + 13, 0xFF71, 0x30A2, 0, + 13, 0xFF72, 0x30A4, 0, + 13, 0xFF73, 0x30A6, 0, + 13, 0xFF74, 0x30A8, 0, + 13, 0xFF75, 0x30AA, 0, + 13, 0xFF76, 0x30AB, 0, + 13, 0xFF77, 0x30AD, 0, + 13, 0xFF78, 0x30AF, 0, + 13, 0xFF79, 0x30B1, 0, + 13, 0xFF7A, 0x30B3, 0, + 13, 0xFF7B, 0x30B5, 0, + 13, 0xFF7C, 0x30B7, 0, + 13, 0xFF7D, 0x30B9, 0, + 13, 0xFF7E, 0x30BB, 0, + 13, 0xFF7F, 0x30BD, 0, + 13, 0xFF80, 0x30BF, 0, + 13, 0xFF81, 0x30C1, 0, + 13, 0xFF82, 0x30C4, 0, + 13, 0xFF83, 0x30C6, 0, + 13, 0xFF84, 0x30C8, 0, + 13, 0xFF85, 0x30CA, 0, + 13, 0xFF86, 0x30CB, 0, + 13, 0xFF87, 0x30CC, 0, + 13, 0xFF88, 0x30CD, 0, + 13, 0xFF89, 0x30CE, 0, + 13, 0xFF8A, 0x30CF, 0, + 13, 0xFF8B, 0x30D2, 0, + 13, 0xFF8C, 0x30D5, 0, + 13, 0xFF8D, 0x30D8, 0, + 13, 0xFF8E, 0x30DB, 0, + 13, 0xFF8F, 0x30DE, 0, + 13, 0xFF90, 0x30DF, 0, + 13, 0xFF91, 0x30E0, 0, + 13, 0xFF92, 0x30E1, 0, + 13, 0xFF93, 0x30E2, 0, + 13, 0xFF94, 0x30E4, 0, + 13, 0xFF95, 0x30E6, 0, + 13, 0xFF96, 0x30E8, 0, + 13, 0xFF97, 0x30E9, 0, + 13, 0xFF98, 0x30EA, 0, + 13, 0xFF99, 0x30EB, 0, + 13, 0xFF9A, 0x30EC, 0, + 13, 0xFF9B, 0x30ED, 0, + 13, 0xFF9C, 0x30EF, 0, + 13, 0xFF9D, 0x30F3, 0, + 13, 0xFF9E, 0x3099, 0, + 13, 0xFF9F, 0x309A, 0, + 13, 0xFFA0, 0x3164, 0, + 13, 0xFFA1, 0x3131, 0, + 13, 0xFFA2, 0x3132, 0, + 13, 0xFFA3, 0x3133, 0, + 13, 0xFFA4, 0x3134, 0, + 13, 0xFFA5, 0x3135, 0, + 13, 0xFFA6, 0x3136, 0, + 13, 0xFFA7, 0x3137, 0, + 13, 0xFFA8, 0x3138, 0, + 13, 0xFFA9, 0x3139, 0, + 13, 0xFFAA, 0x313A, 0, + 13, 0xFFAB, 0x313B, 0, + 13, 0xFFAC, 0x313C, 0, + 13, 0xFFAD, 0x313D, 0, + 13, 0xFFAE, 0x313E, 0, + 13, 0xFFAF, 0x313F, 0, + 13, 0xFFB0, 0x3140, 0, + 13, 0xFFB1, 0x3141, 0, + 13, 0xFFB2, 0x3142, 0, + 13, 0xFFB3, 0x3143, 0, + 13, 0xFFB4, 0x3144, 0, + 13, 0xFFB5, 0x3145, 0, + 13, 0xFFB6, 0x3146, 0, + 13, 0xFFB7, 0x3147, 0, + 13, 0xFFB8, 0x3148, 0, + 13, 0xFFB9, 0x3149, 0, + 13, 0xFFBA, 0x314A, 0, + 13, 0xFFBB, 0x314B, 0, + 13, 0xFFBC, 0x314C, 0, + 13, 0xFFBD, 0x314D, 0, + 13, 0xFFBE, 0x314E, 0, + 13, 0xFFC2, 0x314F, 0, + 13, 0xFFC3, 0x3150, 0, + 13, 0xFFC4, 0x3151, 0, + 13, 0xFFC5, 0x3152, 0, + 13, 0xFFC6, 0x3153, 0, + 13, 0xFFC7, 0x3154, 0, + 13, 0xFFCA, 0x3155, 0, + 13, 0xFFCB, 0x3156, 0, + 13, 0xFFCC, 0x3157, 0, + 13, 0xFFCD, 0x3158, 0, + 13, 0xFFCE, 0x3159, 0, + 13, 0xFFCF, 0x315A, 0, + 13, 0xFFD2, 0x315B, 0, + 13, 0xFFD3, 0x315C, 0, + 13, 0xFFD4, 0x315D, 0, + 13, 0xFFD5, 0x315E, 0, + 13, 0xFFD6, 0x315F, 0, + 13, 0xFFD7, 0x3160, 0, + 13, 0xFFDA, 0x3161, 0, + 13, 0xFFDB, 0x3162, 0, + 13, 0xFFDC, 0x3163, 0, + 12, 0xFFE0, 0x00A2, 0, + 12, 0xFFE1, 0x00A3, 0, + 12, 0xFFE2, 0x00AC, 0, + 12, 0xFFE3, 0x00AF, 0, + 12, 0xFFE4, 0x00A6, 0, + 12, 0xFFE5, 0x00A5, 0, + 12, 0xFFE6, 0x20A9, 0, + 13, 0xFFE8, 0x2502, 0, + 13, 0xFFE9, 0x2190, 0, + 13, 0xFFEA, 0x2191, 0, + 13, 0xFFEB, 0x2192, 0, + 13, 0xFFEC, 0x2193, 0, + 13, 0xFFED, 0x25A0, 0, + 13, 0xFFEE, 0x25CB, 0, + +}; + +const Q_UINT16 TQUnicodeTables::decomposition_info[] = { + 1, 2, 3, 4, 5, 6, 7, 8, + 8, 9, 10, 11, 12, 13, 14, 15, + 16, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 17, 18, + 19, 20, 21, 22, 23, 8, 8, 8, + 8, 8, 24, 8, 8, 8, 25, 26, + 27, 28, 29, 30, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, + 8, 31, 32, 33, 34, 35, 36, 37, + + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 0, 0, 0, 0, + 5, 0, 10, 0, 0, 0, 0, 14, + 0, 0, 19, 23, 27, 32, 0, 0, + 36, 41, 45, 0, 49, 55, 61, 0, + 67, 72, 77, 82, 87, 92, 0, 97, + 102, 107, 112, 117, 122, 127, 132, 137, + 0, 142, 147, 152, 157, 162, 167, 0, + 0, 172, 177, 182, 187, 192, 0, 0, + 197, 202, 207, 212, 217, 222, 0, 227, + 232, 237, 242, 247, 252, 257, 262, 267, + 0, 272, 277, 282, 287, 292, 297, 0, + 0, 302, 307, 312, 317, 322, 0, 327, + + 332, 337, 342, 347, 352, 357, 362, 367, + 372, 377, 382, 387, 392, 397, 402, 407, + 0, 0, 412, 417, 422, 427, 432, 437, + 442, 447, 452, 457, 462, 467, 472, 477, + 482, 487, 492, 497, 502, 507, 0, 0, + 512, 517, 522, 527, 532, 537, 542, 547, + 552, 0, 557, 562, 567, 572, 577, 582, + 0, 587, 592, 597, 602, 607, 612, 617, + 622, 0, 0, 627, 632, 637, 642, 647, + 652, 657, 0, 0, 662, 667, 672, 677, + 682, 687, 0, 0, 692, 697, 702, 707, + 712, 717, 722, 727, 732, 737, 742, 747, + 752, 757, 762, 767, 772, 777, 0, 0, + 782, 787, 792, 797, 802, 807, 812, 817, + 822, 827, 832, 837, 842, 847, 852, 857, + 862, 867, 872, 877, 882, 887, 892, 897, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 901, 906, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 911, + 916, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 921, 926, 931, 936, + 941, 946, 951, 956, 961, 966, 971, 976, + 981, 986, 991, 996, 1001, 1006, 1011, 1016, + 1021, 1026, 1031, 1036, 1041, 0, 1046, 1051, + 1056, 1061, 1066, 1071, 0, 0, 1076, 1081, + 1086, 1091, 1096, 1101, 1106, 1111, 1116, 1121, + 1126, 1131, 1136, 1141, 1146, 1151, 0, 0, + 1156, 1161, 1166, 1171, 1176, 1181, 1186, 1191, + + 1196, 1201, 1206, 1211, 1216, 1221, 1226, 1231, + 1236, 1241, 1246, 1251, 1256, 1261, 1266, 1271, + 1276, 1281, 1286, 1291, 1296, 1301, 1306, 1311, + 1316, 1321, 1326, 1331, 0, 0, 1336, 1341, + 0, 0, 0, 0, 0, 0, 1346, 1351, + 1356, 1361, 1366, 1371, 1376, 1381, 1386, 1391, + 1396, 1401, 1406, 1411, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 1416, 1420, 1424, 1428, 1432, 1436, 1440, 1444, + 1448, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 1452, 1457, 1462, 1467, 1472, 1477, 0, 0, + 1482, 1486, 1490, 1494, 1498, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 1502, 1506, 0, 1510, 1514, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1519, 0, 0, 0, + 0, 0, 1523, 0, 0, 0, 1528, 0, + 0, 0, 0, 0, 1532, 1537, 1542, 1547, + 1551, 1556, 1561, 0, 1566, 0, 1571, 1576, + 1581, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1586, 1591, 1596, 1601, 1606, 1611, + 1616, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1621, 1626, 1631, 1636, 1641, 0, + 1646, 1650, 1654, 1658, 1663, 1668, 1672, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 1676, 1680, 1684, 0, 1688, 1692, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 1696, 1701, 0, 1706, 0, 0, 0, 1711, + 0, 0, 0, 0, 1716, 1721, 1726, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1731, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1736, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 1741, 1746, 0, 1751, 0, 0, 0, 1756, + 0, 0, 0, 0, 1761, 1766, 1771, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 1776, 1781, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1786, 1791, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 1796, 1801, 1806, 1811, 0, 0, 1816, 1821, + 0, 0, 1826, 1831, 1836, 1841, 1846, 1851, + 0, 0, 1856, 1861, 1866, 1871, 1876, 1881, + 0, 0, 1886, 1891, 1896, 1901, 1906, 1911, + 1916, 1921, 1926, 1931, 1936, 1941, 0, 0, + 1946, 1951, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 1956, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1961, 1966, 1971, 1976, 1981, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1986, 1991, 1996, + 2001, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 2006, 0, 2011, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 2016, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 2021, 0, 0, 0, 0, 0, 0, + 0, 2026, 0, 0, 2031, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 2036, 2041, 2046, 2051, 2056, 2061, 2066, 2071, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 2076, 2081, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 2086, 2091, 0, 2096, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 2101, 0, 0, 2106, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 2111, 2116, 2121, 0, 0, 2126, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 2131, 0, 0, 2136, 2141, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 2146, 2151, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 2156, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 2161, 2166, 2171, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 2176, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 2181, 0, 0, 0, 0, 0, 0, 2186, + 2191, 0, 2196, 2201, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 2206, 2211, 2216, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 2221, 0, 2226, 2231, 2236, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 2241, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 2246, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 2251, 2256, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 2261, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 2265, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 2270, 0, 0, + 0, 0, 2275, 0, 0, 0, 0, 2280, + 0, 0, 0, 0, 2285, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 2290, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 2295, 0, 2300, 2305, 2310, + 2315, 2320, 0, 0, 0, 0, 0, 0, + 0, 2325, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 2330, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 2335, 0, 0, + 0, 0, 2340, 0, 0, 0, 0, 2345, + 0, 0, 0, 0, 2350, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 2355, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 2360, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 2365, 2370, 2375, 2380, 2385, 2390, 2395, 2400, + 2405, 2410, 2415, 2420, 2425, 2430, 2435, 2440, + 2445, 2450, 2455, 2460, 2465, 2470, 2475, 2480, + 2485, 2490, 2495, 2500, 2505, 2510, 2515, 2520, + 2525, 2530, 2535, 2540, 2545, 2550, 2555, 2560, + 2565, 2570, 2575, 2580, 2585, 2590, 2595, 2600, + 2605, 2610, 2615, 2620, 2625, 2630, 2635, 2640, + 2645, 2650, 2655, 2660, 2665, 2670, 2675, 2680, + 2685, 2690, 2695, 2700, 2705, 2710, 2715, 2720, + 2725, 2730, 2735, 2740, 2745, 2750, 2755, 2760, + 2765, 2770, 2775, 2780, 2785, 2790, 2795, 2800, + 2805, 2810, 2815, 2820, 2825, 2830, 2835, 2840, + 2845, 2850, 2855, 2860, 2865, 2870, 2875, 2880, + 2885, 2890, 2895, 2900, 2905, 2910, 2915, 2920, + 2925, 2930, 2935, 2940, 2945, 2950, 2955, 2960, + 2965, 2970, 2975, 2980, 2985, 2990, 2995, 3000, + 3005, 3010, 3015, 3020, 3025, 3030, 3035, 3040, + 3045, 3050, 3055, 3060, 3065, 3070, 3075, 3080, + 3085, 3090, 3095, 3100, 3105, 3110, 3115, 3120, + 3125, 3130, 3135, 3140, 0, 0, 0, 0, + 3145, 3150, 3155, 3160, 3165, 3170, 3175, 3180, + 3185, 3190, 3195, 3200, 3205, 3210, 3215, 3220, + 3225, 3230, 3235, 3240, 3245, 3250, 3255, 3260, + 3265, 3270, 3275, 3280, 3285, 3290, 3295, 3300, + 3305, 3310, 3315, 3320, 3325, 3330, 3335, 3340, + 3345, 3350, 3355, 3360, 3365, 3370, 3375, 3380, + 3385, 3390, 3395, 3400, 3405, 3410, 3415, 3420, + 3425, 3430, 3435, 3440, 3445, 3450, 3455, 3460, + 3465, 3470, 3475, 3480, 3485, 3490, 3495, 3500, + 3505, 3510, 3515, 3520, 3525, 3530, 3535, 3540, + 3545, 3550, 3555, 3560, 3565, 3570, 3575, 3580, + 3585, 3590, 0, 0, 0, 0, 0, 0, + + 3595, 3600, 3605, 3610, 3615, 3620, 3625, 3630, + 3635, 3640, 3645, 3650, 3655, 3660, 3665, 3670, + 3675, 3680, 3685, 3690, 3695, 3700, 0, 0, + 3705, 3710, 3715, 3720, 3725, 3730, 0, 0, + 3735, 3740, 3745, 3750, 3755, 3760, 3765, 3770, + 3775, 3780, 3785, 3790, 3795, 3800, 3805, 3810, + 3815, 3820, 3825, 3830, 3835, 3840, 3845, 3850, + 3855, 3860, 3865, 3870, 3875, 3880, 3885, 3890, + 3895, 3900, 3905, 3910, 3915, 3920, 0, 0, + 3925, 3930, 3935, 3940, 3945, 3950, 0, 0, + 3955, 3960, 3965, 3970, 3975, 3980, 3985, 3990, + 0, 3995, 0, 4000, 0, 4005, 0, 4010, + 4015, 4020, 4025, 4030, 4035, 4040, 4045, 4050, + 4055, 4060, 4065, 4070, 4075, 4080, 4085, 4090, + 4095, 4100, 4104, 4109, 4113, 4118, 4122, 4127, + 4131, 4136, 4140, 4145, 4149, 4154, 0, 0, + 4158, 4163, 4168, 4173, 4178, 4183, 4188, 4193, + 4198, 4203, 4208, 4213, 4218, 4223, 4228, 4233, + 4238, 4243, 4248, 4253, 4258, 4263, 4268, 4273, + 4278, 4283, 4288, 4293, 4298, 4303, 4308, 4313, + 4318, 4323, 4328, 4333, 4338, 4343, 4348, 4353, + 4358, 4363, 4368, 4373, 4378, 4383, 4388, 4393, + 4398, 4403, 4408, 4413, 4418, 0, 4423, 4428, + 4433, 4438, 4443, 4448, 4452, 4457, 4462, 4466, + 4471, 4476, 4481, 4486, 4491, 0, 4496, 4501, + 4506, 4511, 4515, 4520, 4524, 4529, 4534, 4539, + 4544, 4549, 4554, 4559, 0, 0, 4563, 4568, + 4573, 4578, 4583, 4588, 0, 4592, 4597, 4602, + 4607, 4612, 4617, 4622, 4626, 4631, 4636, 4641, + 4646, 4651, 4656, 4661, 4665, 4670, 4675, 4679, + 0, 0, 4683, 4688, 4693, 0, 4698, 4703, + 4708, 4713, 4717, 4722, 4726, 4731, 4735, 0, + + 4740, 4744, 4748, 4752, 4756, 4760, 4764, 4768, + 4772, 4776, 4780, 0, 0, 0, 0, 0, + 0, 4784, 0, 0, 0, 0, 0, 4788, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 4793, 4797, 4802, 0, + 0, 0, 0, 0, 0, 0, 0, 4808, + 0, 0, 0, 4812, 4817, 0, 4823, 4828, + 0, 0, 0, 0, 4834, 0, 4839, 0, + 0, 0, 0, 0, 0, 0, 0, 4844, + 4849, 4854, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 4859, + 0, 0, 0, 0, 0, 0, 0, 4866, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 4870, 4874, 0, 0, 4878, 4882, 4886, 4890, + 4894, 4898, 4902, 4906, 4910, 4914, 4918, 4922, + 4926, 4930, 4934, 4938, 4942, 4946, 4950, 4954, + 4958, 4962, 4966, 4970, 4974, 4978, 4982, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 4986, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 4991, 4997, 5003, 5007, 0, 5012, 5018, 5024, + 0, 5028, 5033, 5037, 5041, 5045, 5049, 5053, + 5057, 5061, 5065, 5069, 0, 5073, 5077, 0, + 0, 5082, 5086, 5090, 5094, 5098, 0, 0, + 5102, 5107, 5113, 0, 5118, 0, 5122, 0, + 5126, 0, 5130, 5134, 5138, 5142, 0, 5146, + 5150, 5154, 0, 5158, 5162, 5166, 5170, 5174, + 5178, 5182, 0, 0, 0, 5186, 5190, 5194, + 5198, 0, 0, 0, 0, 5202, 5206, 5210, + 5214, 5218, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 5222, 5228, 5234, 5240, 5246, + 5252, 5258, 5264, 5270, 5276, 5282, 5288, 5294, + 5299, 5303, 5308, 5314, 5319, 5323, 5328, 5334, + 5341, 5346, 5350, 5355, 5361, 5365, 5369, 5373, + 5377, 5381, 5386, 5392, 5397, 5401, 5406, 5412, + 5419, 5424, 5428, 5433, 5439, 5443, 5447, 5451, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 5455, 5460, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 5465, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 5470, 5475, 5480, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 5485, 0, 0, 0, + 0, 5490, 0, 0, 5495, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 5500, 0, 5505, 0, + 0, 0, 0, 0, 5510, 5515, 0, 5521, + 5526, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 5532, 0, 0, 5537, 0, 0, 5542, + 0, 5547, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 5552, 0, 5557, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 5562, 5567, 5572, + 5577, 5582, 0, 0, 5587, 5592, 0, 0, + 5597, 5602, 0, 0, 0, 0, 0, 0, + 5607, 5612, 0, 0, 5617, 5622, 0, 0, + 5627, 5632, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 5637, 5642, 5647, 5652, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 5657, 5662, 5667, 5672, 0, 0, 0, 0, + 0, 0, 5677, 5682, 5687, 5692, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 5697, 5701, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 5705, 5709, 5713, 5717, 5721, 5725, 5729, 5733, + 5737, 5741, 5746, 5751, 5756, 5761, 5766, 5771, + 5776, 5781, 5786, 5791, 5796, 5802, 5808, 5814, + 5820, 5826, 5832, 5838, 5844, 5850, 5857, 5864, + 5871, 5878, 5885, 5892, 5899, 5906, 5913, 5920, + 5927, 5932, 5937, 5942, 5947, 5952, 5957, 5962, + 5967, 5972, 5978, 5984, 5990, 5996, 6002, 6008, + 6014, 6020, 6026, 6032, 6038, 6044, 6050, 6056, + 6062, 6068, 6074, 6080, 6086, 6092, 6098, 6104, + 6110, 6116, 6122, 6128, 6134, 6140, 6146, 6152, + 6158, 6164, 6170, 6176, 6182, 6188, 6194, 6198, + 6202, 6206, 6210, 6214, 6218, 6222, 6226, 6230, + 6234, 6238, 6242, 6246, 6250, 6254, 6258, 6262, + 6266, 6270, 6274, 6278, 6282, 6286, 6290, 6294, + 6298, 6302, 6306, 6310, 6314, 6318, 6322, 6326, + 6330, 6334, 6338, 6342, 6346, 6350, 6354, 6358, + 6362, 6366, 6370, 6374, 6378, 6382, 6386, 6390, + 6394, 6398, 6402, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 6406, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 6413, 6419, 6424, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 6430, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 6435, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 6439, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 6443, 6447, 6451, 6455, 6459, 6463, 6467, 6471, + 6475, 6479, 6483, 6487, 6491, 6495, 6499, 6503, + 6507, 6511, 6515, 6519, 6523, 6527, 6531, 6535, + 6539, 6543, 6547, 6551, 6555, 6559, 6563, 6567, + 6571, 6575, 6579, 6583, 6587, 6591, 6595, 6599, + 6603, 6607, 6611, 6615, 6619, 6623, 6627, 6631, + 6635, 6639, 6643, 6647, 6651, 6655, 6659, 6663, + 6667, 6671, 6675, 6679, 6683, 6687, 6691, 6695, + 6699, 6703, 6707, 6711, 6715, 6719, 6723, 6727, + 6731, 6735, 6739, 6743, 6747, 6751, 6755, 6759, + 6763, 6767, 6771, 6775, 6779, 6783, 6787, 6791, + 6795, 6799, 6803, 6807, 6811, 6815, 6819, 6823, + 6827, 6831, 6835, 6839, 6843, 6847, 6851, 6855, + 6859, 6863, 6867, 6871, 6875, 6879, 6883, 6887, + 6891, 6895, 6899, 6903, 6907, 6911, 6915, 6919, + 6923, 6927, 6931, 6935, 6939, 6943, 6947, 6951, + 6955, 6959, 6963, 6967, 6971, 6975, 6979, 6983, + 6987, 6991, 6995, 6999, 7003, 7007, 7011, 7015, + 7019, 7023, 7027, 7031, 7035, 7039, 7043, 7047, + 7051, 7055, 7059, 7063, 7067, 7071, 7075, 7079, + 7083, 7087, 7091, 7095, 7099, 7103, 7107, 7111, + 7115, 7119, 7123, 7127, 7131, 7135, 7139, 7143, + 7147, 7151, 7155, 7159, 7163, 7167, 7171, 7175, + 7179, 7183, 7187, 7191, 7195, 7199, 7203, 7207, + 7211, 7215, 7219, 7223, 7227, 7231, 7235, 7239, + 7243, 7247, 7251, 7255, 7259, 7263, 7267, 7271, + 7275, 7279, 7283, 7287, 7291, 7295, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 7299, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 7303, 0, + 7307, 7311, 7315, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 7319, 0, 7324, 0, + 7329, 0, 7334, 0, 7339, 0, 7344, 0, + 7349, 0, 7354, 0, 7359, 0, 7364, 0, + 7369, 0, 7374, 0, 0, 7379, 0, 7384, + 0, 7389, 0, 0, 0, 0, 0, 0, + 7394, 7399, 0, 7404, 7409, 0, 7414, 7419, + 0, 7424, 7429, 0, 7434, 7439, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 7444, 0, 0, 0, + 0, 0, 0, 7449, 7454, 0, 7459, 7464, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 7469, 0, 7474, 0, + 7479, 0, 7484, 0, 7489, 0, 7494, 0, + 7499, 0, 7504, 0, 7509, 0, 7514, 0, + 7519, 0, 7524, 0, 0, 7529, 0, 7534, + 0, 7539, 0, 0, 0, 0, 0, 0, + 7544, 7549, 0, 7554, 7559, 0, 7564, 7569, + 0, 7574, 7579, 0, 7584, 7589, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 7594, 0, 0, 7599, + 7604, 7609, 7614, 0, 0, 0, 7619, 7624, + + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 7629, 7633, 7637, 7641, 7645, 7649, 7653, + 7657, 7661, 7665, 7669, 7673, 7677, 7681, 7685, + 7689, 7693, 7697, 7701, 7705, 7709, 7713, 7717, + 7721, 7725, 7729, 7733, 7737, 7741, 7745, 7749, + 7753, 7757, 7761, 7765, 7769, 7773, 7777, 7781, + 7785, 7789, 7793, 7797, 7801, 7805, 7809, 7813, + 7817, 7821, 7825, 7829, 7833, 7837, 7841, 7845, + 7849, 7853, 7857, 7861, 7865, 7869, 7873, 7877, + 7881, 7885, 7889, 7893, 7897, 7901, 7905, 7909, + 7913, 7917, 7921, 7925, 7929, 7933, 7937, 7941, + 7945, 7949, 7953, 7957, 7961, 7965, 7969, 7973, + 7977, 7981, 7985, 7989, 7993, 7997, 8001, 0, + 0, 0, 8005, 8009, 8013, 8017, 8021, 8025, + 8029, 8033, 8037, 8041, 8045, 8049, 8053, 8057, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 8061, 8067, 8073, 8079, 8085, 8091, 8097, 8103, + 8109, 8115, 8121, 8127, 8133, 8139, 8145, 8152, + 8159, 8166, 8173, 8180, 8187, 8194, 8201, 8208, + 8215, 8222, 8229, 8236, 8243, 0, 0, 0, + 8250, 8256, 8262, 8268, 8274, 8280, 8286, 8292, + 8298, 8304, 8310, 8316, 8322, 8328, 8334, 8340, + 8346, 8352, 8358, 8364, 8370, 8376, 8382, 8388, + 8394, 8400, 8406, 8412, 8418, 8424, 8430, 8436, + 8442, 8448, 8454, 8460, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 8466, 8471, 8476, 8481, 8486, 8491, 8496, + 8501, 8506, 8511, 8516, 8521, 8526, 8531, 8536, + 8541, 8545, 8549, 8553, 8557, 8561, 8565, 8569, + 8573, 8577, 8581, 8585, 8589, 8593, 8597, 8602, + 8607, 8612, 8617, 8622, 8627, 8632, 8637, 8642, + 8647, 8652, 8657, 8662, 0, 0, 0, 0, + 8667, 8671, 8675, 8679, 8683, 8687, 8691, 8695, + 8699, 8703, 8707, 8711, 8715, 8719, 8723, 8727, + 8731, 8735, 8739, 8743, 8747, 8751, 8755, 8759, + 8763, 8767, 8771, 8775, 8779, 8783, 8787, 8791, + 8795, 8799, 8803, 8807, 8811, 8815, 8819, 8823, + 8827, 8831, 8835, 8839, 8843, 8847, 8851, 8855, + 8859, 8863, 8868, 8873, 8878, 8883, 8888, 8893, + 8898, 8903, 8908, 8913, 8918, 8923, 8928, 8933, + 8938, 8943, 8948, 8953, 8958, 8963, 8968, 8973, + 8978, 8983, 8989, 8995, 0, 0, 0, 0, + 9001, 9005, 9009, 9013, 9017, 9021, 9025, 9029, + 9033, 9037, 9041, 9045, 9049, 9053, 9057, 9061, + 9065, 9069, 9073, 9077, 9081, 9085, 9089, 9093, + 9097, 9101, 9105, 9109, 9113, 9117, 9121, 9125, + 9129, 9133, 9137, 9141, 9145, 9149, 9153, 9157, + 9161, 9165, 9169, 9173, 9177, 9181, 9185, 0, + + 9189, 9196, 9203, 9210, 9216, 9223, 9229, 9235, + 9243, 9250, 9256, 9262, 9268, 9275, 9282, 9288, + 9294, 9299, 9305, 9312, 9319, 9324, 9332, 9341, + 9349, 9355, 9363, 9371, 9378, 9384, 9390, 9396, + 9403, 9411, 9418, 9424, 9430, 9436, 9441, 9446, + 9451, 9456, 9462, 9468, 9476, 9482, 9489, 9497, + 9503, 9508, 9513, 9521, 9528, 9536, 9542, 9550, + 9555, 9561, 9567, 9573, 9579, 9585, 9592, 9598, + 9603, 9609, 9615, 9621, 9628, 9634, 9640, 9646, + 9654, 9661, 9666, 9674, 9679, 9686, 9693, 9699, + 9705, 9711, 9718, 9723, 9729, 9736, 9741, 9749, + 9755, 9760, 9765, 9770, 9775, 9780, 9785, 9790, + 9795, 9800, 9805, 9811, 9817, 9823, 9829, 9835, + 9841, 9847, 9853, 9859, 9865, 9871, 9877, 9883, + 9889, 9895, 9901, 9906, 9911, 9917, 9922, 0, + 0, 0, 0, 9927, 9932, 9937, 9942, 9947, + 9954, 9959, 9964, 9969, 9974, 9979, 9984, 9989, + 9994, 10000, 10007, 10012, 10017, 10022, 10027, 10032, + 10037, 10042, 10048, 10054, 10060, 10066, 10071, 10076, + 10081, 10086, 10091, 10096, 10101, 10106, 10111, 10116, + 10122, 10128, 10133, 10139, 10145, 10151, 10156, 10162, + 10168, 10175, 10180, 10186, 10192, 10198, 10204, 10212, + 10221, 10226, 10231, 10236, 10241, 10246, 10251, 10256, + 10261, 10266, 10271, 10276, 10281, 10286, 10291, 10296, + 10301, 10306, 10311, 10318, 10323, 10328, 10333, 10340, + 10346, 10351, 10356, 10361, 10366, 10371, 10376, 10381, + 10386, 10391, 10396, 10402, 10407, 10412, 10418, 10424, + 10429, 10436, 10442, 10447, 10452, 10457, 0, 0, + 10462, 10467, 10472, 10477, 10482, 10487, 10492, 10497, + 10502, 10507, 10513, 10519, 10525, 10531, 10537, 10543, + 10549, 10555, 10561, 10567, 10573, 10579, 10585, 10591, + 10597, 10603, 10609, 10615, 10621, 10627, 10633, 0, + + 10639, 10643, 10647, 10651, 10655, 10659, 10663, 10667, + 10671, 10675, 10679, 10683, 10687, 10691, 10695, 10699, + 10703, 10707, 10711, 10715, 10719, 10723, 10727, 10731, + 10735, 10739, 10743, 10747, 10751, 10755, 10759, 10763, + 10767, 10771, 10775, 10779, 10783, 10787, 10791, 10795, + 10799, 10803, 10807, 10811, 10815, 10819, 10823, 10827, + 10831, 10835, 10839, 10843, 10847, 10851, 10855, 10859, + 10863, 10867, 10871, 10875, 10879, 10883, 10887, 10891, + 10895, 10899, 10903, 10907, 10911, 10915, 10919, 10923, + 10927, 10931, 10935, 10939, 10943, 10947, 10951, 10955, + 10959, 10963, 10967, 10971, 10975, 10979, 10983, 10987, + 10991, 10995, 10999, 11003, 11007, 11011, 11015, 11019, + 11023, 11027, 11031, 11035, 11039, 11043, 11047, 11051, + 11055, 11059, 11063, 11067, 11071, 11075, 11079, 11083, + 11087, 11091, 11095, 11099, 11103, 11107, 11111, 11115, + 11119, 11123, 11127, 11131, 11135, 11139, 11143, 11147, + 11151, 11155, 11159, 11163, 11167, 11171, 11175, 11179, + 11183, 11187, 11191, 11195, 11199, 11203, 11207, 11211, + 11215, 11219, 11223, 11227, 11231, 11235, 11239, 11243, + 11247, 11251, 11255, 11259, 11263, 11267, 11271, 11275, + 11279, 11283, 11287, 11291, 11295, 11299, 11303, 11307, + 11311, 11315, 11319, 11323, 11327, 11331, 11335, 11339, + 11343, 11347, 11351, 11355, 11359, 11363, 11367, 11371, + 11375, 11379, 11383, 11387, 11391, 11395, 11399, 11403, + 11407, 11411, 11415, 11419, 11423, 11427, 11431, 11435, + 11439, 11443, 11447, 11451, 11455, 11459, 11463, 11467, + 11471, 11475, 11479, 11483, 11487, 11491, 11495, 11499, + 11503, 11507, 11511, 11515, 11519, 11523, 11527, 11531, + 11535, 11539, 11543, 11547, 11551, 11555, 11559, 11563, + 11567, 11571, 11575, 11579, 11583, 11587, 11591, 11595, + 11599, 11603, 11607, 11611, 11615, 11619, 11623, 11627, + 11631, 11635, 11639, 11643, 11647, 11651, 11655, 11659, + + 11663, 11667, 11671, 11675, 11679, 11683, 11687, 11691, + 11695, 11699, 11703, 11707, 11711, 11715, 0, 0, + 11719, 0, 11723, 0, 0, 11727, 11731, 11735, + 11739, 11743, 11747, 11751, 11755, 11759, 11763, 0, + 11767, 0, 11771, 0, 0, 11775, 11779, 0, + 0, 0, 11783, 11787, 11791, 11795, 0, 0, + 11799, 11803, 11807, 11811, 11815, 11819, 11823, 11827, + 11831, 11835, 11839, 11843, 11847, 11851, 11855, 11859, + 11863, 11867, 11871, 11875, 11879, 11883, 11887, 11891, + 11895, 11899, 11903, 11907, 11911, 11915, 11919, 11923, + 11927, 11931, 11935, 11939, 11943, 11947, 11951, 11955, + 11959, 11963, 11967, 11971, 11975, 11979, 11983, 11987, + 11991, 11995, 11999, 12003, 12007, 12011, 12015, 12019, + 12023, 12027, 12031, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 12035, 12040, 12045, 12050, 12056, 12062, 12067, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 12072, 12077, 12082, 12087, 12092, + 0, 0, 0, 0, 0, 12097, 0, 12102, + 12107, 12111, 12115, 12119, 12123, 12127, 12131, 12135, + 12139, 12143, 12147, 12152, 12157, 12162, 12167, 12172, + 12177, 12182, 12187, 12192, 12197, 12202, 12207, 0, + 12212, 12217, 12222, 12227, 12232, 0, 12237, 0, + 12242, 12247, 0, 12252, 12257, 0, 12262, 12267, + 12272, 12277, 12282, 12287, 12292, 12297, 12302, 12307, + 12312, 12316, 12320, 12324, 12328, 12332, 12336, 12340, + 12344, 12348, 12352, 12356, 12360, 12364, 12368, 12372, + 12376, 12380, 12384, 12388, 12392, 12396, 12400, 12404, + 12408, 12412, 12416, 12420, 12424, 12428, 12432, 12436, + 12440, 12444, 12448, 12452, 12456, 12460, 12464, 12468, + 12472, 12476, 12480, 12484, 12488, 12492, 12496, 12500, + 12504, 12508, 12512, 12516, 12520, 12524, 12528, 12532, + 12536, 12540, 12544, 12548, 12552, 12556, 12560, 12564, + 12568, 12572, 12576, 12580, 12584, 12588, 12592, 12596, + 12600, 12604, 12608, 12612, 12616, 12620, 12624, 12628, + 12632, 12636, 12640, 12644, 12648, 12652, 12656, 12660, + 12664, 12668, 12672, 12676, 12680, 12684, 12688, 12692, + 12696, 12700, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 12704, 12708, 12712, 12716, 12720, + 12724, 12728, 12732, 12736, 12740, 12744, 12748, 12752, + 12756, 12760, 12764, 12768, 12772, 12776, 12780, 12784, + 12788, 12792, 12796, 12801, 12806, 12811, 12816, 12821, + 12826, 12831, 12836, 12841, 12846, 12851, 12856, 12861, + 12866, 12871, 12876, 12881, 12886, 12890, 12894, 12898, + + 12902, 12907, 12912, 12917, 12922, 12927, 12932, 12937, + 12942, 12947, 12952, 12957, 12962, 12967, 12972, 12977, + 12982, 12987, 12992, 12997, 13002, 13007, 13012, 13017, + 13022, 13027, 13032, 13037, 13042, 13047, 13052, 13057, + 13062, 13067, 13072, 13077, 13082, 13087, 13092, 13097, + 13102, 13107, 13112, 13117, 13122, 13127, 13132, 13137, + 13142, 13147, 13152, 13157, 13162, 13167, 13172, 13177, + 13182, 13187, 13192, 13197, 13202, 13207, 13212, 13217, + 13222, 13227, 13232, 13237, 13242, 13247, 13252, 13257, + 13262, 13267, 13272, 13277, 13282, 13287, 13292, 13297, + 13302, 13307, 13312, 13317, 13322, 13327, 13332, 13337, + 13342, 13347, 13352, 13357, 13362, 13367, 13372, 13378, + 13384, 13390, 13396, 13402, 13408, 13413, 13418, 13423, + 13428, 13433, 13438, 13443, 13448, 13453, 13458, 13463, + 13468, 13473, 13478, 13483, 13488, 13493, 13498, 13503, + 13508, 13513, 13518, 13523, 13528, 13533, 13538, 13543, + 13548, 13553, 13558, 13563, 13568, 13573, 13578, 13583, + 13588, 13593, 13598, 13603, 13608, 13613, 13618, 13623, + 13628, 13633, 13638, 13643, 13648, 13653, 13658, 13663, + 13668, 13673, 13678, 13683, 13688, 13693, 13698, 13703, + 13708, 13713, 13718, 13723, 13728, 13733, 13738, 13743, + 13748, 13753, 13758, 13763, 13768, 13773, 13778, 13783, + 13788, 13793, 13798, 13803, 13808, 13813, 13818, 13823, + 13828, 13833, 13838, 13843, 13848, 13853, 13858, 13863, + 13868, 13873, 13878, 13883, 13888, 13893, 13898, 13903, + 13908, 13913, 13918, 13923, 13928, 13933, 13938, 13943, + 13948, 13953, 13958, 13963, 13968, 13973, 13978, 13983, + 13988, 13993, 13998, 14003, 14008, 14013, 14018, 14023, + 14028, 14033, 14038, 14043, 14048, 14053, 14058, 14063, + 14068, 14073, 14078, 14083, 14088, 14093, 14098, 14103, + 14108, 14113, 14118, 14124, 14130, 14136, 14141, 14146, + 14151, 14156, 14161, 14166, 14171, 14176, 14181, 14186, + + 14191, 14196, 14201, 14206, 14211, 14216, 14221, 14226, + 14231, 14236, 14241, 14246, 14251, 14256, 14261, 14266, + 14271, 14276, 14281, 14286, 14291, 14296, 14301, 14306, + 14311, 14316, 14321, 14326, 14331, 14336, 14341, 14346, + 14351, 14356, 14361, 14366, 14371, 14376, 14381, 14386, + 14391, 14396, 14401, 14406, 14411, 14416, 14421, 14426, + 14431, 14436, 14441, 14446, 14451, 14456, 14461, 14466, + 14471, 14476, 14481, 14486, 14491, 14496, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 14501, 14507, 14513, 14519, 14525, 14531, 14537, 14543, + 14549, 14555, 14561, 14567, 14573, 14579, 14585, 14591, + 14597, 14603, 14609, 14615, 14621, 14627, 14633, 14639, + 14645, 14651, 14657, 14663, 14669, 14675, 14681, 14687, + 14693, 14699, 14705, 14711, 14717, 14723, 14729, 14735, + 14741, 14747, 14753, 14759, 14765, 14771, 14777, 14783, + 14789, 14795, 14801, 14807, 14813, 14819, 14825, 14831, + 14837, 14843, 14849, 14855, 14861, 14867, 14873, 14879, + 0, 0, 14885, 14891, 14897, 14903, 14909, 14915, + 14921, 14927, 14933, 14939, 14945, 14951, 14957, 14963, + 14969, 14975, 14981, 14987, 14993, 14999, 15005, 15011, + 15017, 15023, 15029, 15035, 15041, 15047, 15053, 15059, + 15065, 15071, 15077, 15083, 15089, 15095, 15101, 15107, + 15113, 15119, 15125, 15131, 15137, 15143, 15149, 15155, + 15161, 15167, 15173, 15179, 15185, 15191, 15197, 15203, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 15209, 15215, 15221, 15228, 15235, 15242, 15249, 15256, + 15263, 15270, 15276, 15297, 15308, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 15315, 15319, 15323, 15327, 15331, 15335, 15339, 15343, + 15347, 15351, 15355, 15359, 15363, 15367, 15371, 15375, + 15379, 15383, 15387, 15391, 15395, 0, 0, 0, + 0, 15399, 15403, 15407, 15411, 15415, 15419, 15423, + 15427, 15431, 15435, 0, 15439, 15443, 15447, 15451, + 15455, 15459, 15463, 15467, 15471, 15475, 15479, 15483, + 15487, 15491, 15495, 15499, 15503, 15507, 15511, 0, + 15515, 15519, 15523, 15527, 0, 0, 0, 0, + 15531, 15536, 15541, 0, 15546, 0, 15551, 15556, + 15561, 15566, 15571, 15576, 15581, 15586, 15591, 15596, + 15601, 15605, 15609, 15613, 15617, 15621, 15625, 15629, + 15633, 15637, 15641, 15645, 15649, 15653, 15657, 15661, + 15665, 15669, 15673, 15677, 15681, 15685, 15689, 15693, + 15697, 15701, 15705, 15709, 15713, 15717, 15721, 15725, + 15729, 15733, 15737, 15741, 15745, 15749, 15753, 15757, + 15761, 15765, 15769, 15773, 15777, 15781, 15785, 15789, + 15793, 15797, 15801, 15805, 15809, 15813, 15817, 15821, + 15825, 15829, 15833, 15837, 15841, 15845, 15849, 15853, + 15857, 15861, 15865, 15869, 15873, 15877, 15881, 15885, + 15889, 15893, 15897, 15901, 15905, 15909, 15913, 15917, + 15921, 15925, 15929, 15933, 15937, 15941, 15945, 15949, + 15953, 15957, 15961, 15965, 15969, 15973, 15977, 15981, + 15985, 15989, 15993, 15997, 16001, 16005, 16009, 16013, + 16017, 16021, 16025, 16029, 16033, 16037, 16041, 16045, + 16049, 16053, 16057, 16061, 16065, 16069, 16074, 16079, + 16084, 16089, 16094, 16099, 16104, 0, 0, 0, + + 0, 16109, 16113, 16117, 16121, 16125, 16129, 16133, + 16137, 16141, 16145, 16149, 16153, 16157, 16161, 16165, + 16169, 16173, 16177, 16181, 16185, 16189, 16193, 16197, + 16201, 16205, 16209, 16213, 16217, 16221, 16225, 16229, + 16233, 16237, 16241, 16245, 16249, 16253, 16257, 16261, + 16265, 16269, 16273, 16277, 16281, 16285, 16289, 16293, + 16297, 16301, 16305, 16309, 16313, 16317, 16321, 16325, + 16329, 16333, 16337, 16341, 16345, 16349, 16353, 16357, + 16361, 16365, 16369, 16373, 16377, 16381, 16385, 16389, + 16393, 16397, 16401, 16405, 16409, 16413, 16417, 16421, + 16425, 16429, 16433, 16437, 16441, 16445, 16449, 16453, + 16457, 16461, 16465, 16469, 16473, 16477, 16481, 16485, + 16489, 16493, 16497, 16501, 16505, 16509, 16513, 16517, + 16521, 16525, 16529, 16533, 16537, 16541, 16545, 16549, + 16553, 16557, 16561, 16565, 16569, 16573, 16577, 16581, + 16585, 16589, 16593, 16597, 16601, 16605, 16609, 16613, + 16617, 16621, 16625, 16629, 16633, 16637, 16641, 16645, + 16649, 16653, 16657, 16661, 16665, 16669, 16673, 16677, + 16681, 16685, 16689, 16693, 16697, 16701, 16705, 16709, + 16713, 16717, 16721, 16725, 16729, 16733, 16737, 16741, + 16745, 16749, 16753, 16757, 16761, 16765, 16769, 16773, + 16777, 16781, 16785, 16789, 16793, 16797, 16801, 16805, + 16809, 16813, 16817, 16821, 16825, 16829, 16833, 16837, + 16841, 16845, 16849, 16853, 16857, 16861, 16865, 0, + 0, 0, 16869, 16873, 16877, 16881, 16885, 16889, + 0, 0, 16893, 16897, 16901, 16905, 16909, 16913, + 0, 0, 16917, 16921, 16925, 16929, 16933, 16937, + 0, 0, 16941, 16945, 16949, 0, 0, 0, + 16953, 16957, 16961, 16965, 16969, 16973, 16977, 0, + 16981, 16985, 16989, 16993, 16997, 17001, 17005, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, +}; + +// 67552 bytes + +const Q_UINT16 TQUnicodeTables::ligature_map[] = { + 0, + 5567, 0, + 5552, 0, + 5572, 0, + 67, 72, 77, 82, 87, 92, 332, 342, 352, 966, 1196, 1206, 1346, 2365, 3145, 3155, 0, + 2375, 2385, 2395, 0, + 97, 362, 372, 382, 392, 0, + 402, 2415, 2425, 2435, 2445, 2455, 0, + 102, 107, 112, 117, 412, 422, 432, 442, 452, 1216, 1226, 1356, 2485, 2495, 3265, 3275, 3285, 0, + 2515, 0, + 462, 472, 482, 492, 1076, 1146, 2525, 0, + 502, 1336, 2535, 2545, 2555, 2565, 2575, 0, + 122, 127, 132, 137, 512, 522, 532, 542, 552, 976, 1236, 1246, 2585, 3345, 3355, 0, + 567, 0, + 577, 1086, 2605, 2615, 2625, 0, + 587, 597, 607, 2635, 2655, 2665, 0, + 2675, 2685, 2695, 0, + 142, 627, 637, 647, 1156, 2705, 2715, 2725, 2735, 0, + 147, 152, 157, 162, 167, 662, 672, 682, 901, 986, 1096, 1256, 1266, 1386, 3365, 3375, 0, + 2785, 2795, 0, + 692, 702, 712, 1276, 1286, 2805, 2815, 2835, 0, + 722, 732, 742, 752, 1316, 2845, 2855, 0, + 762, 772, 1326, 2895, 2905, 2915, 2925, 0, + 172, 177, 182, 187, 782, 792, 802, 812, 822, 832, 911, 996, 1296, 1306, 2935, 2945, 2955, 3485, 3495, 0, + 2985, 2995, 0, + 842, 3005, 3015, 3025, 3035, 3045, 0, + 3055, 3065, 0, + 192, 852, 862, 1406, 3075, 3555, 3565, 3575, 3585, 0, + 867, 877, 887, 3085, 3095, 3105, 0, + 197, 202, 207, 212, 217, 222, 337, 347, 357, 971, 1201, 1211, 1351, 2370, 3150, 3160, 0, + 2380, 2390, 2400, 0, + 227, 367, 377, 387, 397, 0, + 407, 2420, 2430, 2440, 2450, 2460, 0, + 232, 237, 242, 247, 417, 427, 437, 447, 457, 1221, 1231, 1361, 2490, 2500, 3270, 3280, 3290, 0, + 2520, 0, + 467, 477, 487, 497, 1081, 1151, 2530, 0, + 507, 1341, 2540, 2550, 2560, 2570, 2580, 3115, 0, + 252, 257, 262, 267, 517, 527, 537, 547, 981, 1241, 1251, 2590, 3350, 3360, 0, + 572, 1126, 0, + 582, 1091, 2610, 2620, 2630, 0, + 592, 602, 612, 2640, 2660, 2670, 0, + 2680, 2690, 2700, 0, + 272, 632, 642, 652, 1161, 2710, 2720, 2730, 2740, 0, + 277, 282, 287, 292, 297, 667, 677, 687, 906, 991, 1101, 1261, 1271, 1391, 3370, 3380, 0, + 2790, 2800, 0, + 697, 707, 717, 1281, 1291, 2810, 2820, 2840, 0, + 727, 737, 747, 757, 1321, 2850, 2860, 0, + 767, 777, 1331, 2900, 2910, 2920, 2930, 3120, 0, + 302, 307, 312, 317, 787, 797, 807, 817, 827, 837, 916, 1001, 1301, 1311, 2940, 2950, 2960, 3490, 3500, 0, + 2990, 3000, 0, + 847, 3010, 3020, 3030, 3040, 3050, 3125, 0, + 3060, 3070, 0, + 322, 327, 857, 1411, 3080, 3130, 3560, 3570, 3580, 3590, 0, + 872, 882, 892, 3090, 3100, 3110, 0, + 1537, 4476, 4670, 0, + 3165, 3175, 3185, 3195, 0, + 1046, 0, + 1166, 0, + 1066, 1176, 0, + 2405, 0, + 3295, 3305, 3315, 3325, 0, + 2595, 0, + 3385, 3395, 3405, 3415, 0, + 1376, 2745, 2755, 0, + 1366, 0, + 1186, 0, + 1006, 1016, 1026, 1036, 0, + 3170, 3180, 3190, 3200, 0, + 1051, 0, + 1171, 0, + 1071, 1181, 0, + 2410, 0, + 3300, 3310, 3320, 3330, 0, + 2600, 0, + 3390, 3400, 3410, 3420, 0, + 1381, 2750, 2760, 0, + 1371, 0, + 1191, 0, + 1011, 1021, 1031, 1041, 0, + 3215, 3225, 3235, 3245, 0, + 3220, 3230, 3240, 3250, 0, + 2465, 2475, 0, + 2470, 2480, 0, + 2765, 2775, 0, + 2770, 2780, 0, + 2865, 0, + 2870, 0, + 2875, 0, + 2880, 0, + 2965, 0, + 2970, 0, + 2975, 0, + 2980, 0, + 3140, 0, + 3435, 3445, 3455, 3465, 3475, 0, + 3440, 3450, 3460, 3470, 3480, 0, + 3505, 3515, 3525, 3535, 3545, 0, + 3510, 3520, 3530, 3540, 3550, 0, + 1116, 0, + 1106, 0, + 1111, 0, + 1056, 0, + 1061, 0, + 2505, 0, + 2510, 0, + 1396, 0, + 1401, 0, + 1121, 0, + 1514, 0, + 1542, 3635, 3640, 4433, 4438, 4443, 4452, 0, + 1551, 3705, 3710, 4506, 0, + 1556, 3775, 3780, 4515, 4524, 0, + 1561, 1586, 3855, 3860, 4573, 4578, 4583, 0, + 1566, 3925, 3930, 4708, 0, + 4665, 0, + 1571, 1591, 3995, 4646, 4651, 4656, 0, + 1576, 4055, 4060, 4717, 4726, 0, + 4418, 0, + 4491, 0, + 1596, 3595, 3600, 4095, 4398, 4403, 4413, 4423, 0, + 1601, 3675, 3680, 4104, 0, + 1606, 3735, 3740, 4113, 4486, 4496, 0, + 1611, 1621, 3815, 3820, 4122, 4544, 4549, 4563, 0, + 1631, 3895, 3900, 4131, 0, + 4626, 4631, 0, + 1626, 1636, 3955, 3960, 4140, 4607, 4612, 4636, 0, + 1641, 4015, 4020, 4149, 4688, 4698, 0, + 1581, 4554, 4568, 0, + 1616, 4617, 4641, 0, + 4693, 0, + 1658, 1663, 0, + 1711, 0, + 1796, 1806, 0, + 1706, 0, + 1696, 1701, 1816, 0, + 1786, 1836, 0, + 1846, 0, + 1721, 1731, 1856, 1866, 0, + 1716, 0, + 1876, 0, + 1726, 1906, 1916, 1926, 0, + 1936, 0, + 1946, 0, + 1896, 0, + 1801, 1811, 0, + 1751, 0, + 1741, 1746, 1821, 0, + 1791, 1841, 0, + 1851, 0, + 1736, 1766, 1861, 1871, 0, + 1761, 0, + 1881, 0, + 1771, 1911, 1921, 1931, 0, + 1941, 0, + 1951, 0, + 1901, 0, + 1756, 0, + 1776, 0, + 1781, 0, + 1826, 0, + 1831, 0, + 1886, 0, + 1891, 0, + 12167, 12172, 12177, 0, + 12182, 12292, 0, + 12187, 0, + 12192, 0, + 12197, 0, + 12202, 12287, 0, + 12207, 0, + 12212, 0, + 12097, 12217, 0, + 12222, 0, + 12227, 12297, 0, + 12232, 0, + 12237, 0, + 12242, 0, + 12247, 0, + 12252, 0, + 12257, 12302, 0, + 12262, 0, + 12267, 0, + 12272, 0, + 12147, 12152, 12277, 0, + 12282, 0, + 12102, 0, + 1961, 1966, 1976, 0, + 1971, 0, + 1981, 0, + 2011, 0, + 2016, 0, + 2006, 0, + 2036, 0, + 2041, 0, + 2046, 0, + 2051, 0, + 2056, 0, + 2061, 0, + 2021, 0, + 2066, 0, + 2071, 0, + 2026, 0, + 2031, 0, + 2086, 0, + 2091, 0, + 2096, 0, + 2076, 2081, 0, + 2111, 0, + 2116, 0, + 2121, 0, + 2126, 0, + 2101, 0, + 2106, 0, + 2146, 0, + 2151, 0, + 2131, 2136, 2141, 0, + 2156, 0, + 2161, 2171, 0, + 2166, 0, + 2176, 0, + 2181, 0, + 2186, 2191, 2196, 0, + 2201, 0, + 2206, 2216, 0, + 2211, 0, + 2221, 2226, 2236, 0, + 2231, 0, + 2290, 0, + 2265, 0, + 2270, 0, + 2275, 0, + 2280, 0, + 2285, 0, + 2295, 2300, 2325, 0, + 2355, 0, + 2330, 0, + 2335, 0, + 2340, 0, + 2345, 0, + 2350, 0, + 2305, 0, + 2315, 0, + 2360, 0, + 2645, 0, + 2650, 0, + 2825, 0, + 2830, 0, + 2885, 0, + 2890, 0, + 3205, 3255, 0, + 3210, 3260, 0, + 3335, 0, + 3340, 0, + 3425, 0, + 3430, 0, + 3605, 3615, 3625, 4158, 0, + 3610, 3620, 3630, 4163, 0, + 4168, 0, + 4173, 0, + 4178, 0, + 4183, 0, + 4188, 0, + 4193, 0, + 3645, 3655, 3665, 4198, 0, + 3650, 3660, 3670, 4203, 0, + 4208, 0, + 4213, 0, + 4218, 0, + 4223, 0, + 4228, 0, + 4233, 0, + 3685, 3695, 0, + 3690, 3700, 0, + 3715, 3725, 0, + 3720, 3730, 0, + 3745, 3755, 3765, 4238, 0, + 3750, 3760, 3770, 4243, 0, + 4248, 0, + 4253, 0, + 4258, 0, + 4263, 0, + 4268, 0, + 4273, 0, + 3785, 3795, 3805, 4278, 0, + 3790, 3800, 3810, 4283, 0, + 4288, 0, + 4293, 0, + 4298, 0, + 4303, 0, + 4308, 0, + 4313, 0, + 3825, 3835, 3845, 0, + 3830, 3840, 3850, 0, + 3865, 3875, 3885, 0, + 3870, 3880, 3890, 0, + 3905, 3915, 0, + 3910, 3920, 0, + 3935, 3945, 0, + 3940, 3950, 0, + 3965, 3975, 3985, 0, + 3970, 3980, 3990, 0, + 4000, 4005, 4010, 0, + 4025, 4035, 4045, 4318, 0, + 4030, 4040, 4050, 4323, 0, + 4328, 0, + 4333, 0, + 4338, 0, + 4343, 0, + 4348, 0, + 4353, 0, + 4065, 4075, 4085, 4358, 0, + 4070, 4080, 4090, 4363, 0, + 4368, 0, + 4373, 0, + 4378, 0, + 4383, 0, + 4388, 0, + 4393, 0, + 4408, 0, + 4481, 0, + 4683, 0, + 4428, 0, + 4529, 4534, 4539, 0, + 4501, 0, + 4703, 0, + 4592, 4597, 4602, 0, + 5455, 0, + 5460, 0, + 5465, 0, + 5470, 0, + 5480, 0, + 5475, 0, + 5485, 0, + 5490, 0, + 5495, 0, + 5500, 0, + 5505, 0, + 5532, 0, + 5537, 0, + 5542, 0, + 5547, 0, + 5562, 0, + 5557, 0, + 5577, 0, + 5582, 0, + 5587, 0, + 5592, 0, + 5597, 0, + 5602, 0, + 5607, 0, + 5612, 0, + 5657, 0, + 5662, 0, + 5617, 0, + 5622, 0, + 5627, 0, + 5632, 0, + 5667, 0, + 5672, 0, + 5637, 0, + 5642, 0, + 5647, 0, + 5652, 0, + 5677, 0, + 5682, 0, + 5687, 0, + 5692, 0, + 6430, 0, + 7444, 0, + 7319, 0, + 7324, 0, + 7329, 0, + 7334, 0, + 7339, 0, + 7344, 0, + 7349, 0, + 7354, 0, + 7359, 0, + 7364, 0, + 7369, 0, + 7374, 0, + 7379, 0, + 7384, 0, + 7389, 0, + 7394, 7399, 0, + 7404, 7409, 0, + 7414, 7419, 0, + 7424, 7429, 0, + 7434, 7439, 0, + 7459, 0, + 7594, 0, + 7469, 0, + 7474, 0, + 7479, 0, + 7484, 0, + 7489, 0, + 7494, 0, + 7499, 0, + 7504, 0, + 7509, 0, + 7514, 0, + 7519, 0, + 7524, 0, + 7529, 0, + 7534, 0, + 7539, 0, + 7544, 7549, 0, + 7554, 7559, 0, + 7564, 7569, 0, + 7574, 7579, 0, + 7584, 7589, 0, + 7599, 0, + 7604, 0, + 7609, 0, + 7614, 0, + 7619, 0, + 12157, 12162, 0, + +}; + +const Q_UINT16 TQUnicodeTables::ligature_info[] = { + 1, 2, 3, 4, 5, 6, 7, 8, + 8, 9, 10, 11, 12, 13, 8, 14, + 15, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 16, 17, + 8, 18, 19, 8, 8, 8, 8, 8, + 8, 8, 20, 8, 8, 8, 8, 8, + 21, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 22, 8, 8, 8, 8, + + + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 3, 5, 0, + 0, 7, 24, 28, 34, 41, 59, 61, + 69, 77, 93, 95, 101, 108, 112, 122, + 139, 0, 142, 151, 159, 167, 187, 190, + 197, 200, 210, 0, 0, 0, 0, 0, + 0, 217, 234, 238, 244, 251, 269, 271, + 279, 288, 303, 306, 312, 319, 323, 333, + 350, 0, 353, 362, 370, 379, 399, 402, + 410, 413, 424, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 431, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 435, 0, 440, 442, 444, 447, + 0, 0, 449, 0, 0, 0, 0, 454, + 0, 0, 0, 0, 456, 461, 465, 0, + 467, 0, 0, 0, 469, 0, 0, 0, + 0, 0, 474, 0, 479, 481, 483, 486, + 0, 0, 488, 0, 0, 0, 0, 493, + 0, 0, 0, 0, 495, 500, 504, 0, + 506, 0, 0, 0, 508, 0, 0, 0, + + 0, 0, 513, 518, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 523, 526, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 529, 532, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 535, 537, 0, 0, 0, 0, + 539, 541, 0, 0, 0, 0, 0, 0, + 543, 545, 547, 549, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 551, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 553, 559, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 565, + 571, 0, 0, 0, 0, 0, 0, 577, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 579, 581, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 583, 585, + 587, 589, 0, 0, 0, 0, 591, 593, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 595, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, + 597, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 599, 0, 0, 0, 607, 0, 612, + 0, 618, 0, 0, 0, 0, 0, 626, + 0, 631, 0, 0, 0, 633, 0, 0, + 0, 640, 0, 0, 646, 0, 648, 0, + 0, 650, 0, 0, 0, 659, 0, 664, + 0, 671, 0, 0, 0, 0, 0, 680, + 0, 685, 0, 0, 0, 688, 0, 0, + 0, 697, 704, 708, 0, 0, 712, 0, + 0, 0, 714, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 717, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 719, 0, 0, 722, 0, 724, 728, 731, + 733, 0, 738, 0, 0, 0, 740, 0, + 0, 0, 0, 742, 0, 0, 0, 747, + 0, 0, 0, 749, 0, 751, 0, 0, + 753, 0, 0, 756, 0, 758, 762, 765, + 767, 0, 772, 0, 0, 0, 774, 0, + 0, 0, 0, 776, 0, 0, 0, 781, + 0, 0, 0, 783, 0, 785, 0, 0, + 0, 0, 0, 0, 0, 0, 787, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 789, 791, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 793, 795, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 797, 799, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 801, 805, 808, 810, 812, 814, 817, 0, + 819, 821, 824, 826, 829, 0, 831, 0, + 833, 835, 0, 837, 839, 0, 842, 844, + 846, 848, 852, 0, 0, 0, 0, 0, + 0, 0, 854, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 856, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 860, 0, 862, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 864, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 866, 0, 0, 868, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 870, 872, 874, + 0, 0, 0, 0, 876, 0, 0, 0, + 0, 878, 880, 0, 0, 0, 0, 0, + 882, 0, 0, 884, 0, 0, 0, 886, + 888, 0, 0, 890, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 892, 894, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 896, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 898, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 901, 903, + 0, 0, 0, 0, 905, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 907, 0, 0, 0, 0, + 0, 0, 909, 0, 0, 0, 0, 0, + 911, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 913, 915, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 917, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 921, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 923, 926, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 928, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 930, + 0, 0, 0, 0, 0, 0, 932, 0, + 0, 0, 936, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 938, 941, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 943, 0, 0, 947, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 949, 0, 951, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 953, 0, 0, 0, + 0, 955, 0, 0, 0, 0, 957, 0, + 0, 0, 0, 959, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 961, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 965, 0, 967, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 969, 0, 0, 0, + 0, 971, 0, 0, 0, 0, 973, 0, + 0, 0, 0, 975, 0, 0, 0, 0, + 0, 0, 977, 979, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 981, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 983, 985, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 987, 989, 0, 0, 0, 0, + 0, 0, 991, 993, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 995, 998, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 1001, 1003, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1005, 1007, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 1009, 1014, 1019, 1021, 1023, 1025, 1027, 1029, + 1031, 1036, 1041, 1043, 1045, 1047, 1049, 1051, + 1053, 1056, 0, 0, 0, 0, 0, 0, + 1059, 1062, 0, 0, 0, 0, 0, 0, + 1065, 1070, 1075, 1077, 1079, 1081, 1083, 1085, + 1087, 1092, 1097, 1099, 1101, 1103, 1105, 1107, + 1109, 1113, 0, 0, 0, 0, 0, 0, + 1117, 1121, 0, 0, 0, 0, 0, 0, + 1125, 1128, 0, 0, 0, 0, 0, 0, + 1131, 1134, 0, 0, 0, 0, 0, 0, + 1137, 1141, 0, 0, 0, 0, 0, 0, + 0, 1145, 0, 0, 0, 0, 0, 0, + 1149, 1154, 1159, 1161, 1163, 1165, 1167, 1169, + 1171, 1176, 1181, 1183, 1185, 1187, 1189, 1191, + 1193, 0, 0, 0, 1195, 0, 0, 0, + 0, 0, 0, 0, 1197, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 1199, 0, + 0, 0, 0, 0, 0, 0, 0, 1201, + 0, 0, 0, 0, 0, 0, 1205, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 1207, 0, + 0, 0, 0, 0, 0, 0, 1209, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 1213, 0, 1215, 0, 1217, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 1219, 0, 1221, 0, 1223, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 1225, 0, 0, 0, 0, + 1227, 0, 0, 1229, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1231, 0, 1233, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1235, 0, 0, 0, + 0, 0, 0, 1237, 0, 1239, 0, 0, + 1241, 0, 0, 0, 0, 1243, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1245, 0, 0, 1247, 1249, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1251, 1253, 0, 0, 1255, 1257, + 0, 0, 1259, 1261, 1263, 1265, 0, 0, + 0, 0, 1267, 1269, 0, 0, 1271, 1273, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1275, 1277, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1279, 0, 0, 0, 0, 0, + 1281, 1283, 0, 1285, 0, 0, 0, 0, + 0, 0, 1287, 1289, 1291, 1293, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1295, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 1297, 0, + 0, 0, 0, 1299, 0, 1301, 0, 1303, + 0, 1305, 0, 1307, 0, 1309, 0, 1311, + 0, 1313, 0, 1315, 0, 1317, 0, 1319, + 0, 1321, 0, 0, 1323, 0, 1325, 0, + 1327, 0, 0, 0, 0, 0, 0, 1329, + 0, 0, 1332, 0, 0, 1335, 0, 0, + 1338, 0, 0, 1341, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1344, 0, 0, + 0, 0, 0, 0, 0, 0, 1346, 0, + 0, 0, 0, 1348, 0, 1350, 0, 1352, + 0, 1354, 0, 1356, 0, 1358, 0, 1360, + 0, 1362, 0, 1364, 0, 1366, 0, 1368, + 0, 1370, 0, 0, 1372, 0, 1374, 0, + 1376, 0, 0, 0, 0, 0, 0, 1378, + 0, 0, 1381, 0, 0, 1384, 0, 0, + 1387, 0, 0, 1390, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 1393, + 1395, 1397, 1399, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1401, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1403, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, +}; + +// 14586 bytes + +const Q_UINT8 TQUnicodeTables::direction_info[] = { + 1, 2, 3, 4, 5, 6, 7, 8, + 2, 9, 10, 11, 12, 13, 14, 15, + 16, 2, 2, 2, 2, 2, 17, 18, + 19, 2, 2, 2, 2, 2, 2, 20, + 21, 22, 23, 24, 25, 26, 27, 28, + 26, 29, 30, 2, 2, 2, 31, 32, + 33, 2, 34, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 35, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 36, 37, 38, 39, 40, + + + 18, 18, 18, 18, 18, 18, 18, 18, + 18, 8, 7, 8, 9, 7, 18, 18, + 18, 18, 18, 18, 18, 18, 18, 18, + 18, 18, 18, 18, 7, 7, 7, 8, + 9, 10, 10, 4, 4, 4, 10, 10, + 138, 138, 10, 4, 6, 4, 6, 3, + 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 6, 10, 138, 10, 138, 10, + 10, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 138, 10, 138, 10, 10, + 10, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 138, 10, 138, 10, 18, + 18, 18, 18, 18, 18, 7, 18, 18, + 18, 18, 18, 18, 18, 18, 18, 18, + 18, 18, 18, 18, 18, 18, 18, 18, + 18, 18, 18, 18, 18, 18, 18, 18, + 6, 10, 4, 4, 4, 4, 10, 10, + 10, 10, 0, 138, 10, 10, 10, 10, + 4, 4, 2, 2, 10, 0, 10, 10, + 10, 2, 0, 138, 10, 10, 10, 10, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 10, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 10, + 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 10, 10, 0, 0, 0, 0, 0, + 0, 0, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 0, 0, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 0, 0, 0, 0, 0, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 17, 17, 17, 17, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 17, 17, 17, 17, + 0, 0, 0, 0, 10, 10, 0, 0, + 0, 0, 0, 0, 0, 0, 10, 0, + 0, 0, 0, 0, 10, 10, 0, 10, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 10, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 17, 17, 17, 17, 0, + 17, 17, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 10, 0, 0, 0, 0, 0, + 0, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 0, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 0, 17, 17, 17, 1, 17, + 1, 17, 17, 1, 17, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 0, 0, 0, 0, 0, + 1, 1, 1, 1, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 6, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 13, 0, 0, 0, 13, + 0, 13, 77, 77, 77, 77, 45, 77, + 45, 77, 45, 45, 45, 45, 45, 77, + 77, 77, 77, 45, 45, 45, 45, 45, + 45, 45, 45, 0, 0, 0, 0, 0, + 109, 45, 45, 45, 45, 45, 45, 45, + 77, 45, 45, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 17, 17, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 4, 5, 5, 13, 45, 45, + 17, 77, 77, 77, 13, 77, 77, 77, + 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, + 77, 77, 77, 77, 77, 77, 77, 77, + 77, 77, 77, 77, 77, 77, 77, 77, + 77, 77, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, + 77, 45, 77, 77, 77, 77, 77, 77, + 77, 77, 77, 77, 45, 77, 45, 77, + 45, 45, 77, 77, 13, 77, 17, 17, + 17, 17, 17, 17, 17, 13, 17, 17, + 17, 17, 17, 17, 17, 13, 13, 17, + 17, 10, 17, 17, 17, 17, 0, 0, + 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 45, 45, 45, 13, 13, 0, + + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 0, 18, + 77, 17, 45, 45, 45, 77, 77, 77, + 77, 77, 45, 45, 45, 45, 77, 45, + 45, 45, 45, 45, 45, 45, 45, 45, + 77, 45, 77, 45, 77, 0, 0, 0, + 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 17, 17, + 17, 17, 17, 17, 17, 17, 17, 17, + 17, 13, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 17, 17, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 17, 0, 0, 0, + 0, 17, 17, 17, 17, 17, 17, 17, + 17, 0, 0, 0, 0, 17, 0, 0, + 0, 17, 17, 17, 17, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 17, 17, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 17, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 17, 0, 0, 0, + 0, 17, 17, 17, 17, 0, 0, 0, + 0, 0, 0, 0, 0, 17, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 17, 17, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 4, 4, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 17, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 17, 0, 0, 0, + 0, 17, 17, 0, 0, 0, 0, 17, + 17, 0, 0, 17, 17, 17, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 17, 17, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 17, 17, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 17, 0, 0, 0, + 0, 17, 17, 17, 17, 17, 0, 17, + 17, 0, 0, 0, 0, 17, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 17, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 17, 0, 0, 17, + 0, 17, 17, 17, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 17, 0, 0, + 0, 0, 0, 0, 0, 0, 17, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 17, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 17, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 17, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 17, 17, + 17, 0, 0, 0, 0, 0, 17, 17, + 17, 0, 17, 17, 17, 17, 0, 0, + 0, 0, 0, 0, 0, 17, 17, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 17, + 0, 0, 0, 0, 0, 0, 17, 0, + 0, 0, 0, 0, 17, 17, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 17, 17, 17, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 17, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 17, 0, 0, 0, 0, 0, + 0, 0, 17, 17, 17, 0, 17, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 17, 0, 0, 17, 17, 17, 17, + 17, 17, 17, 0, 0, 0, 0, 4, + 0, 0, 0, 0, 0, 0, 0, 17, + 17, 17, 17, 17, 17, 17, 17, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 17, 0, 0, 17, 17, 17, 17, + 17, 17, 0, 17, 17, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 17, 17, 17, 17, 17, 17, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 17, 17, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 17, 0, 17, + 0, 17, 10, 10, 10, 10, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 17, 17, 17, 0, + 17, 17, 17, 17, 17, 0, 17, 17, + 0, 0, 0, 0, 0, 0, 0, 0, + 17, 17, 17, 17, 17, 17, 17, 17, + 0, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 17, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 17, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 17, 17, 17, + 17, 0, 17, 0, 0, 0, 17, 17, + 0, 17, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 17, 17, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 9, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 10, 10, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 17, 17, 17, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 17, 17, 17, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 17, 17, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 17, 17, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 17, + 17, 17, 17, 17, 17, 17, 0, 0, + 0, 0, 0, 0, 0, 0, 17, 0, + 0, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 0, 0, 0, 0, + 0, 0, 0, 4, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 17, 17, 17, 18, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 17, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 10, 0, 10, + 10, 10, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 10, 10, 10, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 10, 10, 10, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 10, 10, 10, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 10, 10, 0, + + 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 18, 18, 114, 0, 1, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 9, 7, 11, 14, 16, 12, 15, 9, + 4, 4, 4, 4, 4, 10, 10, 10, + 10, 138, 138, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 138, 138, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 0, 0, 0, 0, 10, + 0, 0, 0, 0, 0, 0, 0, 9, + 18, 18, 18, 18, 0, 0, 0, 0, + 0, 0, 18, 18, 18, 18, 18, 18, + 2, 0, 0, 0, 2, 2, 2, 2, + 2, 2, 4, 4, 10, 138, 138, 0, + 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 4, 4, 10, 138, 138, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 10, 10, 0, 10, 10, 10, 10, 0, + 10, 10, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 10, 0, 10, 10, + 10, 0, 0, 0, 0, 0, 10, 10, + 10, 10, 10, 10, 0, 10, 0, 10, + 0, 10, 0, 0, 0, 0, 4, 0, + 0, 0, 10, 0, 0, 0, 0, 0, + 0, 0, 10, 0, 0, 0, 0, 0, + 138, 10, 10, 10, 10, 0, 0, 0, + 0, 0, 10, 10, 0, 0, 0, 0, + 0, 0, 0, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + + 10, 138, 138, 138, 138, 10, 10, 10, + 138, 138, 138, 138, 138, 138, 10, 10, + 10, 138, 4, 4, 10, 138, 138, 10, + 10, 10, 138, 138, 138, 138, 10, 138, + 138, 138, 138, 10, 138, 10, 138, 10, + 10, 10, 10, 138, 138, 138, 138, 138, + 138, 138, 138, 138, 10, 10, 10, 10, + 10, 138, 10, 138, 138, 138, 138, 138, + 138, 138, 138, 138, 138, 138, 138, 138, + 138, 138, 138, 138, 138, 10, 10, 10, + 10, 10, 138, 138, 138, 138, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 138, + 138, 10, 138, 10, 138, 138, 138, 138, + 138, 138, 138, 138, 10, 10, 138, 138, + 138, 138, 138, 138, 138, 138, 138, 138, + 138, 138, 138, 138, 138, 138, 138, 138, + 138, 138, 138, 138, 138, 138, 138, 138, + 138, 138, 138, 138, 138, 10, 10, 138, + 138, 138, 138, 10, 10, 10, 10, 10, + 138, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 138, 138, 10, 10, 138, 138, + 138, 138, 138, 138, 138, 138, 138, 138, + 138, 138, 138, 138, 138, 138, 138, 138, + 138, 10, 10, 10, 10, 10, 138, 138, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 138, 138, 138, 138, 138, 10, 10, + 138, 138, 10, 10, 10, 10, 138, 138, + 138, 138, 138, 138, 138, 138, 138, 138, + 138, 138, 138, 138, 138, 138, 138, 138, + 138, 138, 138, 138, 138, 138, 10, 10, + 138, 138, 138, 138, 138, 138, 138, 138, + 138, 138, 138, 138, 138, 138, 138, 138, + + 10, 10, 10, 10, 10, 10, 10, 10, + 138, 138, 138, 138, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 138, 138, 10, 10, 10, 10, 10, 10, + 10, 138, 138, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 0, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 2, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 0, + + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 0, 0, 10, 10, + 0, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 0, 0, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 10, 10, 10, 10, 0, 10, 10, + 10, 10, 0, 0, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 0, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 0, 10, 0, 10, + 10, 10, 10, 0, 0, 0, 10, 0, + 10, 10, 10, 10, 10, 10, 10, 0, + 0, 10, 10, 10, 10, 10, 10, 10, + 138, 138, 138, 138, 138, 138, 138, 138, + 138, 138, 138, 138, 138, 138, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 0, 0, 0, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 0, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 10, 10, 10, 138, 138, 138, 138, 10, + 10, 10, 10, 10, 138, 138, 138, 10, + 10, 10, 138, 138, 138, 138, 138, 138, + 138, 138, 138, 138, 0, 0, 0, 0, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 138, 138, 138, 138, 138, + 138, 138, 138, 138, 138, 138, 138, 138, + 138, 138, 138, 138, 138, 138, 138, 138, + 138, 10, 10, 138, 138, 138, 138, 138, + 138, 138, 138, 138, 138, 138, 138, 138, + 138, 138, 138, 138, 138, 138, 138, 138, + 10, 10, 10, 10, 10, 10, 10, 10, + 138, 10, 10, 10, 10, 10, 10, 10, + 138, 138, 138, 138, 138, 138, 10, 10, + 10, 138, 10, 10, 10, 10, 138, 138, + 138, 138, 138, 10, 138, 138, 10, 10, + 138, 138, 138, 138, 138, 10, 10, 10, + 10, 138, 10, 138, 138, 138, 10, 10, + 138, 138, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 138, 138, 138, 138, + 138, 138, 10, 10, 138, 138, 10, 10, + + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 138, 138, 138, 138, 138, 138, + 138, 138, 138, 138, 138, 138, 138, 138, + 138, 138, 138, 138, 138, 10, 138, 138, + 138, 138, 10, 10, 138, 10, 138, 10, + 10, 138, 10, 138, 138, 138, 138, 10, + 10, 10, 10, 10, 138, 138, 10, 10, + 10, 10, 10, 10, 138, 138, 138, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 138, + 138, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 138, 138, 10, 10, + 10, 10, 138, 138, 138, 138, 10, 138, + 138, 10, 10, 138, 138, 10, 10, 10, + 10, 138, 138, 138, 138, 138, 138, 138, + 138, 138, 138, 138, 138, 138, 138, 138, + 138, 138, 138, 138, 138, 138, 138, 138, + 138, 138, 138, 138, 138, 138, 138, 138, + 138, 138, 138, 138, 138, 138, 138, 138, + 138, 138, 138, 138, 10, 10, 138, 138, + 138, 138, 138, 138, 138, 138, 10, 138, + 138, 138, 138, 138, 138, 138, 138, 138, + 138, 138, 138, 138, 138, 138, 138, 138, + 138, 138, 138, 138, 138, 138, 138, 138, + 138, 138, 138, 138, 138, 138, 138, 138, + 138, 138, 138, 138, 138, 138, 138, 10, + 10, 10, 10, 10, 138, 10, 138, 10, + 10, 10, 138, 138, 138, 138, 138, 10, + 10, 10, 10, 10, 138, 138, 138, 10, + 10, 10, 10, 138, 10, 10, 10, 138, + 138, 138, 138, 138, 10, 138, 10, 10, + + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 0, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 0, 0, 0, 0, + + 9, 10, 10, 10, 10, 0, 0, 0, + 138, 138, 138, 138, 138, 138, 138, 138, + 138, 138, 10, 10, 138, 138, 138, 138, + 138, 138, 138, 138, 10, 10, 10, 10, + 10, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 17, 17, 17, 17, 17, 17, + 10, 0, 0, 0, 0, 0, 10, 10, + 0, 0, 0, 0, 0, 10, 10, 10, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 17, 17, 10, 10, 0, 0, 0, + 10, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 10, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1, 17, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 4, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 0, + 1, 1, 1, 1, 1, 0, 1, 0, + 1, 1, 0, 1, 1, 0, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 10, 10, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 0, 0, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 0, 0, 0, + + 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 17, 17, 17, 17, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 17, 17, 17, 17, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 0, + 0, 10, 10, 10, 10, 10, 10, 10, + 6, 10, 6, 0, 10, 6, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 4, + 10, 10, 4, 4, 10, 10, 10, 0, + 10, 4, 4, 10, 0, 0, 0, 0, + 13, 13, 13, 13, 13, 0, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 0, 0, 18, + + 0, 10, 10, 4, 4, 4, 10, 10, + 138, 138, 10, 4, 6, 4, 6, 3, + 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 6, 10, 138, 10, 138, 10, + 10, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 138, 10, 138, 10, 10, + 10, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 138, 10, 138, 10, 138, + 138, 10, 138, 138, 10, 10, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 4, 4, 10, 10, 10, 4, 4, 0, + 10, 10, 10, 10, 10, 10, 10, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 18, 18, 18, 10, 10, 0, 0, +}; + +// 25082 bytes + +const Q_UINT8 TQUnicodeTables::combining_info[] = { + 1, 1, 1, 2, 3, 4, 5, 6, + 1, 7, 8, 9, 10, 11, 12, 13, + 14, 1, 1, 1, 1, 1, 1, 15, + 16, 1, 1, 1, 1, 1, 1, 1, + 17, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 18, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 19, 1, 1, 20, 1, + + + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 230, 230, 230, 230, 230, 230, 230, 230, + 230, 230, 230, 230, 230, 230, 230, 230, + 230, 230, 230, 230, 230, 232, 220, 220, + 220, 220, 232, 216, 220, 220, 220, 220, + 220, 202, 202, 220, 220, 220, 220, 202, + 202, 220, 220, 220, 220, 220, 220, 220, + 220, 220, 220, 220, 1, 1, 1, 1, + 1, 220, 220, 220, 220, 230, 230, 230, + 230, 230, 230, 230, 230, 240, 230, 220, + 220, 220, 230, 230, 230, 220, 220, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 234, 234, 233, 230, 230, 230, 230, 230, + 230, 230, 230, 230, 230, 230, 230, 230, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 230, 230, 230, 230, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 220, 230, 230, 230, 230, 220, 230, + 230, 230, 222, 220, 230, 230, 230, 230, + 230, 230, 0, 220, 220, 220, 220, 220, + 230, 230, 220, 230, 230, 222, 228, 230, + 10, 11, 12, 13, 14, 15, 16, 17, + 18, 19, 0, 20, 21, 22, 0, 23, + 0, 24, 25, 0, 230, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 27, 28, 29, 30, 31, + 32, 33, 34, 230, 230, 220, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 35, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 230, 230, + 230, 230, 230, 230, 230, 0, 0, 230, + 230, 230, 230, 220, 230, 0, 0, 230, + 230, 0, 220, 230, 230, 220, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 36, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 230, 220, 230, 230, 220, 230, 230, 220, + 220, 220, 230, 220, 220, 230, 220, 230, + 230, 230, 220, 230, 220, 230, 220, 230, + 220, 230, 230, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 7, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 9, 0, 0, + 0, 230, 220, 230, 230, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 7, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 9, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 7, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 9, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 7, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 9, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 7, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 9, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 9, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 9, 0, 0, + 0, 0, 0, 0, 0, 84, 91, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 9, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 9, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 9, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 103, 103, 9, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 107, 107, 107, 107, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 118, 118, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 122, 122, 122, 122, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 220, 220, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 220, 0, 220, + 0, 216, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 129, 130, 0, 132, 0, 0, 0, + 0, 0, 130, 130, 130, 130, 0, 0, + 130, 0, 230, 230, 9, 0, 230, 230, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 220, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 7, + 0, 9, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 9, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 9, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 9, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 228, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 230, 230, 1, 1, 230, 230, 230, 230, + 1, 1, 1, 230, 230, 0, 0, 0, + 0, 230, 0, 0, 0, 1, 1, 230, + 220, 230, 1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 218, 228, 232, 222, 224, 224, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 8, 8, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 26, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 230, 230, 230, 230, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, +}; + +// 30458 bytes + +const Q_UINT16 TQUnicodeTables::case_info[] = { + 1, 2, 3, 4, 5, 6, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 7, 8, + 0, 9, 0, 0, 10, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 11, + + + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, + 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, + 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, + 0x78, 0x79, 0x7a, 0, 0, 0, 0, 0, + 0, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, + 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, + 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, + 0x58, 0x59, 0x5a, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0x39c, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, + 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, + 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0, + 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0, + 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, + 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, + 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0, + 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0x178, + + 0x101, 0x100, 0x103, 0x102, 0x105, 0x104, 0x107, 0x106, + 0x109, 0x108, 0x10b, 0x10a, 0x10d, 0x10c, 0x10f, 0x10e, + 0x111, 0x110, 0x113, 0x112, 0x115, 0x114, 0x117, 0x116, + 0x119, 0x118, 0x11b, 0x11a, 0x11d, 0x11c, 0x11f, 0x11e, + 0x121, 0x120, 0x123, 0x122, 0x125, 0x124, 0x127, 0x126, + 0x129, 0x128, 0x12b, 0x12a, 0x12d, 0x12c, 0x12f, 0x12e, + 0x69, 0x49, 0x133, 0x132, 0x135, 0x134, 0x137, 0x136, + 0, 0x13a, 0x139, 0x13c, 0x13b, 0x13e, 0x13d, 0x140, + 0x13f, 0x142, 0x141, 0x144, 0x143, 0x146, 0x145, 0x148, + 0x147, 0, 0x14b, 0x14a, 0x14d, 0x14c, 0x14f, 0x14e, + 0x151, 0x150, 0x153, 0x152, 0x155, 0x154, 0x157, 0x156, + 0x159, 0x158, 0x15b, 0x15a, 0x15d, 0x15c, 0x15f, 0x15e, + 0x161, 0x160, 0x163, 0x162, 0x165, 0x164, 0x167, 0x166, + 0x169, 0x168, 0x16b, 0x16a, 0x16d, 0x16c, 0x16f, 0x16e, + 0x171, 0x170, 0x173, 0x172, 0x175, 0x174, 0x177, 0x176, + 0xff, 0x17a, 0x179, 0x17c, 0x17b, 0x17e, 0x17d, 0x53, + 0, 0x253, 0x183, 0x182, 0x185, 0x184, 0x254, 0x188, + 0x187, 0x256, 0x257, 0x18c, 0x18b, 0, 0x1dd, 0x259, + 0x25b, 0x192, 0x191, 0x260, 0x263, 0x1f6, 0x269, 0x268, + 0x199, 0x198, 0, 0, 0x26f, 0x272, 0x220, 0x275, + 0x1a1, 0x1a0, 0x1a3, 0x1a2, 0x1a5, 0x1a4, 0x280, 0x1a8, + 0x1a7, 0x283, 0, 0, 0x1ad, 0x1ac, 0x288, 0x1b0, + 0x1af, 0x28a, 0x28b, 0x1b4, 0x1b3, 0x1b6, 0x1b5, 0x292, + 0x1b9, 0x1b8, 0, 0, 0x1bd, 0x1bc, 0, 0x1f7, + 0, 0, 0, 0, 0x1c6, 0x1c4, 0x1c4, 0x1c9, + 0x1c7, 0x1c7, 0x1cc, 0x1ca, 0x1ca, 0x1ce, 0x1cd, 0x1d0, + 0x1cf, 0x1d2, 0x1d1, 0x1d4, 0x1d3, 0x1d6, 0x1d5, 0x1d8, + 0x1d7, 0x1da, 0x1d9, 0x1dc, 0x1db, 0x18e, 0x1df, 0x1de, + 0x1e1, 0x1e0, 0x1e3, 0x1e2, 0x1e5, 0x1e4, 0x1e7, 0x1e6, + 0x1e9, 0x1e8, 0x1eb, 0x1ea, 0x1ed, 0x1ec, 0x1ef, 0x1ee, + 0, 0x1f3, 0x1f1, 0x1f1, 0x1f5, 0x1f4, 0x195, 0x1bf, + 0x1f9, 0x1f8, 0x1fb, 0x1fa, 0x1fd, 0x1fc, 0x1ff, 0x1fe, + + 0x201, 0x200, 0x203, 0x202, 0x205, 0x204, 0x207, 0x206, + 0x209, 0x208, 0x20b, 0x20a, 0x20d, 0x20c, 0x20f, 0x20e, + 0x211, 0x210, 0x213, 0x212, 0x215, 0x214, 0x217, 0x216, + 0x219, 0x218, 0x21b, 0x21a, 0x21d, 0x21c, 0x21f, 0x21e, + 0x19e, 0, 0x223, 0x222, 0x225, 0x224, 0x227, 0x226, + 0x229, 0x228, 0x22b, 0x22a, 0x22d, 0x22c, 0x22f, 0x22e, + 0x231, 0x230, 0x233, 0x232, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0x181, 0x186, 0, 0x189, 0x18a, + 0, 0x18f, 0, 0x190, 0, 0, 0, 0, + 0x193, 0, 0, 0x194, 0, 0, 0, 0, + 0x197, 0x196, 0, 0, 0, 0, 0, 0x19c, + 0, 0, 0x19d, 0, 0, 0x19f, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0x1a6, 0, 0, 0x1a9, 0, 0, 0, 0, + 0x1ae, 0, 0x1b1, 0x1b2, 0, 0, 0, 0, + 0, 0, 0x1b7, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0x399, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0x3ac, 0, + 0x3ad, 0x3ae, 0x3af, 0, 0x3cc, 0, 0x3cd, 0x3ce, + 0, 0x3b1, 0x3b2, 0x3b3, 0x3b4, 0x3b5, 0x3b6, 0x3b7, + 0x3b8, 0x3b9, 0x3ba, 0x3bb, 0x3bc, 0x3bd, 0x3be, 0x3bf, + 0x3c0, 0x3c1, 0, 0x3c3, 0x3c4, 0x3c5, 0x3c6, 0x3c7, + 0x3c8, 0x3c9, 0x3ca, 0x3cb, 0x386, 0x388, 0x389, 0x38a, + 0, 0x391, 0x392, 0x393, 0x394, 0x395, 0x396, 0x397, + 0x398, 0x399, 0x39a, 0x39b, 0x39c, 0x39d, 0x39e, 0x39f, + 0x3a0, 0x3a1, 0x3a3, 0x3a3, 0x3a4, 0x3a5, 0x3a6, 0x3a7, + 0x3a8, 0x3a9, 0x3aa, 0x3ab, 0x38c, 0x38e, 0x38f, 0, + 0x392, 0x398, 0, 0, 0, 0x3a6, 0x3a0, 0, + 0x3d9, 0x3d8, 0x3db, 0x3da, 0x3dd, 0x3dc, 0x3df, 0x3de, + 0x3e1, 0x3e0, 0x3e3, 0x3e2, 0x3e5, 0x3e4, 0x3e7, 0x3e6, + 0x3e9, 0x3e8, 0x3eb, 0x3ea, 0x3ed, 0x3ec, 0x3ef, 0x3ee, + 0x39a, 0x3a1, 0x3a3, 0, 0x3b8, 0x395, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 0x450, 0x451, 0x452, 0x453, 0x454, 0x455, 0x456, 0x457, + 0x458, 0x459, 0x45a, 0x45b, 0x45c, 0x45d, 0x45e, 0x45f, + 0x430, 0x431, 0x432, 0x433, 0x434, 0x435, 0x436, 0x437, + 0x438, 0x439, 0x43a, 0x43b, 0x43c, 0x43d, 0x43e, 0x43f, + 0x440, 0x441, 0x442, 0x443, 0x444, 0x445, 0x446, 0x447, + 0x448, 0x449, 0x44a, 0x44b, 0x44c, 0x44d, 0x44e, 0x44f, + 0x410, 0x411, 0x412, 0x413, 0x414, 0x415, 0x416, 0x417, + 0x418, 0x419, 0x41a, 0x41b, 0x41c, 0x41d, 0x41e, 0x41f, + 0x420, 0x421, 0x422, 0x423, 0x424, 0x425, 0x426, 0x427, + 0x428, 0x429, 0x42a, 0x42b, 0x42c, 0x42d, 0x42e, 0x42f, + 0x400, 0x401, 0x402, 0x403, 0x404, 0x405, 0x406, 0x407, + 0x408, 0x409, 0x40a, 0x40b, 0x40c, 0x40d, 0x40e, 0x40f, + 0x461, 0x460, 0x463, 0x462, 0x465, 0x464, 0x467, 0x466, + 0x469, 0x468, 0x46b, 0x46a, 0x46d, 0x46c, 0x46f, 0x46e, + 0x471, 0x470, 0x473, 0x472, 0x475, 0x474, 0x477, 0x476, + 0x479, 0x478, 0x47b, 0x47a, 0x47d, 0x47c, 0x47f, 0x47e, + 0x481, 0x480, 0, 0, 0, 0, 0, 0, + 0, 0, 0x48b, 0x48a, 0x48d, 0x48c, 0x48f, 0x48e, + 0x491, 0x490, 0x493, 0x492, 0x495, 0x494, 0x497, 0x496, + 0x499, 0x498, 0x49b, 0x49a, 0x49d, 0x49c, 0x49f, 0x49e, + 0x4a1, 0x4a0, 0x4a3, 0x4a2, 0x4a5, 0x4a4, 0x4a7, 0x4a6, + 0x4a9, 0x4a8, 0x4ab, 0x4aa, 0x4ad, 0x4ac, 0x4af, 0x4ae, + 0x4b1, 0x4b0, 0x4b3, 0x4b2, 0x4b5, 0x4b4, 0x4b7, 0x4b6, + 0x4b9, 0x4b8, 0x4bb, 0x4ba, 0x4bd, 0x4bc, 0x4bf, 0x4be, + 0, 0x4c2, 0x4c1, 0x4c4, 0x4c3, 0x4c6, 0x4c5, 0x4c8, + 0x4c7, 0x4ca, 0x4c9, 0x4cc, 0x4cb, 0x4ce, 0x4cd, 0, + 0x4d1, 0x4d0, 0x4d3, 0x4d2, 0x4d5, 0x4d4, 0x4d7, 0x4d6, + 0x4d9, 0x4d8, 0x4db, 0x4da, 0x4dd, 0x4dc, 0x4df, 0x4de, + 0x4e1, 0x4e0, 0x4e3, 0x4e2, 0x4e5, 0x4e4, 0x4e7, 0x4e6, + 0x4e9, 0x4e8, 0x4eb, 0x4ea, 0x4ed, 0x4ec, 0x4ef, 0x4ee, + 0x4f1, 0x4f0, 0x4f3, 0x4f2, 0x4f5, 0x4f4, 0, 0, + 0x4f9, 0x4f8, 0, 0, 0, 0, 0, 0, + + 0x501, 0x500, 0x503, 0x502, 0x505, 0x504, 0x507, 0x506, + 0x509, 0x508, 0x50b, 0x50a, 0x50d, 0x50c, 0x50f, 0x50e, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0x561, 0x562, 0x563, 0x564, 0x565, 0x566, 0x567, + 0x568, 0x569, 0x56a, 0x56b, 0x56c, 0x56d, 0x56e, 0x56f, + 0x570, 0x571, 0x572, 0x573, 0x574, 0x575, 0x576, 0x577, + 0x578, 0x579, 0x57a, 0x57b, 0x57c, 0x57d, 0x57e, 0x57f, + 0x580, 0x581, 0x582, 0x583, 0x584, 0x585, 0x586, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0x531, 0x532, 0x533, 0x534, 0x535, 0x536, 0x537, + 0x538, 0x539, 0x53a, 0x53b, 0x53c, 0x53d, 0x53e, 0x53f, + 0x540, 0x541, 0x542, 0x543, 0x544, 0x545, 0x546, 0x547, + 0x548, 0x549, 0x54a, 0x54b, 0x54c, 0x54d, 0x54e, 0x54f, + 0x550, 0x551, 0x552, 0x553, 0x554, 0x555, 0x556, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 0x1e01, 0x1e00, 0x1e03, 0x1e02, 0x1e05, 0x1e04, 0x1e07, 0x1e06, + 0x1e09, 0x1e08, 0x1e0b, 0x1e0a, 0x1e0d, 0x1e0c, 0x1e0f, 0x1e0e, + 0x1e11, 0x1e10, 0x1e13, 0x1e12, 0x1e15, 0x1e14, 0x1e17, 0x1e16, + 0x1e19, 0x1e18, 0x1e1b, 0x1e1a, 0x1e1d, 0x1e1c, 0x1e1f, 0x1e1e, + 0x1e21, 0x1e20, 0x1e23, 0x1e22, 0x1e25, 0x1e24, 0x1e27, 0x1e26, + 0x1e29, 0x1e28, 0x1e2b, 0x1e2a, 0x1e2d, 0x1e2c, 0x1e2f, 0x1e2e, + 0x1e31, 0x1e30, 0x1e33, 0x1e32, 0x1e35, 0x1e34, 0x1e37, 0x1e36, + 0x1e39, 0x1e38, 0x1e3b, 0x1e3a, 0x1e3d, 0x1e3c, 0x1e3f, 0x1e3e, + 0x1e41, 0x1e40, 0x1e43, 0x1e42, 0x1e45, 0x1e44, 0x1e47, 0x1e46, + 0x1e49, 0x1e48, 0x1e4b, 0x1e4a, 0x1e4d, 0x1e4c, 0x1e4f, 0x1e4e, + 0x1e51, 0x1e50, 0x1e53, 0x1e52, 0x1e55, 0x1e54, 0x1e57, 0x1e56, + 0x1e59, 0x1e58, 0x1e5b, 0x1e5a, 0x1e5d, 0x1e5c, 0x1e5f, 0x1e5e, + 0x1e61, 0x1e60, 0x1e63, 0x1e62, 0x1e65, 0x1e64, 0x1e67, 0x1e66, + 0x1e69, 0x1e68, 0x1e6b, 0x1e6a, 0x1e6d, 0x1e6c, 0x1e6f, 0x1e6e, + 0x1e71, 0x1e70, 0x1e73, 0x1e72, 0x1e75, 0x1e74, 0x1e77, 0x1e76, + 0x1e79, 0x1e78, 0x1e7b, 0x1e7a, 0x1e7d, 0x1e7c, 0x1e7f, 0x1e7e, + 0x1e81, 0x1e80, 0x1e83, 0x1e82, 0x1e85, 0x1e84, 0x1e87, 0x1e86, + 0x1e89, 0x1e88, 0x1e8b, 0x1e8a, 0x1e8d, 0x1e8c, 0x1e8f, 0x1e8e, + 0x1e91, 0x1e90, 0x1e93, 0x1e92, 0x1e95, 0x1e94, 0, 0, + 0, 0, 0, 0x1e60, 0, 0, 0, 0, + 0x1ea1, 0x1ea0, 0x1ea3, 0x1ea2, 0x1ea5, 0x1ea4, 0x1ea7, 0x1ea6, + 0x1ea9, 0x1ea8, 0x1eab, 0x1eaa, 0x1ead, 0x1eac, 0x1eaf, 0x1eae, + 0x1eb1, 0x1eb0, 0x1eb3, 0x1eb2, 0x1eb5, 0x1eb4, 0x1eb7, 0x1eb6, + 0x1eb9, 0x1eb8, 0x1ebb, 0x1eba, 0x1ebd, 0x1ebc, 0x1ebf, 0x1ebe, + 0x1ec1, 0x1ec0, 0x1ec3, 0x1ec2, 0x1ec5, 0x1ec4, 0x1ec7, 0x1ec6, + 0x1ec9, 0x1ec8, 0x1ecb, 0x1eca, 0x1ecd, 0x1ecc, 0x1ecf, 0x1ece, + 0x1ed1, 0x1ed0, 0x1ed3, 0x1ed2, 0x1ed5, 0x1ed4, 0x1ed7, 0x1ed6, + 0x1ed9, 0x1ed8, 0x1edb, 0x1eda, 0x1edd, 0x1edc, 0x1edf, 0x1ede, + 0x1ee1, 0x1ee0, 0x1ee3, 0x1ee2, 0x1ee5, 0x1ee4, 0x1ee7, 0x1ee6, + 0x1ee9, 0x1ee8, 0x1eeb, 0x1eea, 0x1eed, 0x1eec, 0x1eef, 0x1eee, + 0x1ef1, 0x1ef0, 0x1ef3, 0x1ef2, 0x1ef5, 0x1ef4, 0x1ef7, 0x1ef6, + 0x1ef9, 0x1ef8, 0, 0, 0, 0, 0, 0, + + 0x1f08, 0x1f09, 0x1f0a, 0x1f0b, 0x1f0c, 0x1f0d, 0x1f0e, 0x1f0f, + 0x1f00, 0x1f01, 0x1f02, 0x1f03, 0x1f04, 0x1f05, 0x1f06, 0x1f07, + 0x1f18, 0x1f19, 0x1f1a, 0x1f1b, 0x1f1c, 0x1f1d, 0, 0, + 0x1f10, 0x1f11, 0x1f12, 0x1f13, 0x1f14, 0x1f15, 0, 0, + 0x1f28, 0x1f29, 0x1f2a, 0x1f2b, 0x1f2c, 0x1f2d, 0x1f2e, 0x1f2f, + 0x1f20, 0x1f21, 0x1f22, 0x1f23, 0x1f24, 0x1f25, 0x1f26, 0x1f27, + 0x1f38, 0x1f39, 0x1f3a, 0x1f3b, 0x1f3c, 0x1f3d, 0x1f3e, 0x1f3f, + 0x1f30, 0x1f31, 0x1f32, 0x1f33, 0x1f34, 0x1f35, 0x1f36, 0x1f37, + 0x1f48, 0x1f49, 0x1f4a, 0x1f4b, 0x1f4c, 0x1f4d, 0, 0, + 0x1f40, 0x1f41, 0x1f42, 0x1f43, 0x1f44, 0x1f45, 0, 0, + 0, 0x1f59, 0, 0x1f5b, 0, 0x1f5d, 0, 0x1f5f, + 0, 0x1f51, 0, 0x1f53, 0, 0x1f55, 0, 0x1f57, + 0x1f68, 0x1f69, 0x1f6a, 0x1f6b, 0x1f6c, 0x1f6d, 0x1f6e, 0x1f6f, + 0x1f60, 0x1f61, 0x1f62, 0x1f63, 0x1f64, 0x1f65, 0x1f66, 0x1f67, + 0x1fba, 0x1fbb, 0x1fc8, 0x1fc9, 0x1fca, 0x1fcb, 0x1fda, 0x1fdb, + 0x1ff8, 0x1ff9, 0x1fea, 0x1feb, 0x1ffa, 0x1ffb, 0, 0, + 0x1f88, 0x1f89, 0x1f8a, 0x1f8b, 0x1f8c, 0x1f8d, 0x1f8e, 0x1f8f, + 0x1f80, 0x1f81, 0x1f82, 0x1f83, 0x1f84, 0x1f85, 0x1f86, 0x1f87, + 0x1f98, 0x1f99, 0x1f9a, 0x1f9b, 0x1f9c, 0x1f9d, 0x1f9e, 0x1f9f, + 0x1f90, 0x1f91, 0x1f92, 0x1f93, 0x1f94, 0x1f95, 0x1f96, 0x1f97, + 0x1fa8, 0x1fa9, 0x1faa, 0x1fab, 0x1fac, 0x1fad, 0x1fae, 0x1faf, + 0x1fa0, 0x1fa1, 0x1fa2, 0x1fa3, 0x1fa4, 0x1fa5, 0x1fa6, 0x1fa7, + 0x1fb8, 0x1fb9, 0, 0x1fbc, 0, 0, 0, 0, + 0x1fb0, 0x1fb1, 0x1f70, 0x1f71, 0x1fb3, 0, 0x399, 0, + 0, 0, 0, 0x1fcc, 0, 0, 0, 0, + 0x1f72, 0x1f73, 0x1f74, 0x1f75, 0x1fc3, 0, 0, 0, + 0x1fd8, 0x1fd9, 0, 0, 0, 0, 0, 0, + 0x1fd0, 0x1fd1, 0x1f76, 0x1f77, 0, 0, 0, 0, + 0x1fe8, 0x1fe9, 0, 0, 0, 0x1fec, 0, 0, + 0x1fe0, 0x1fe1, 0x1f7a, 0x1f7b, 0x1fe5, 0, 0, 0, + 0, 0, 0, 0x1ffc, 0, 0, 0, 0, + 0x1f78, 0x1f79, 0x1f7c, 0x1f7d, 0x1ff3, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0x3c9, 0, + 0, 0, 0x6b, 0xe5, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0x2170, 0x2171, 0x2172, 0x2173, 0x2174, 0x2175, 0x2176, 0x2177, + 0x2178, 0x2179, 0x217a, 0x217b, 0x217c, 0x217d, 0x217e, 0x217f, + 0x2160, 0x2161, 0x2162, 0x2163, 0x2164, 0x2165, 0x2166, 0x2167, + 0x2168, 0x2169, 0x216a, 0x216b, 0x216c, 0x216d, 0x216e, 0x216f, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0x24d0, 0x24d1, + 0x24d2, 0x24d3, 0x24d4, 0x24d5, 0x24d6, 0x24d7, 0x24d8, 0x24d9, + 0x24da, 0x24db, 0x24dc, 0x24dd, 0x24de, 0x24df, 0x24e0, 0x24e1, + 0x24e2, 0x24e3, 0x24e4, 0x24e5, 0x24e6, 0x24e7, 0x24e8, 0x24e9, + 0x24b6, 0x24b7, 0x24b8, 0x24b9, 0x24ba, 0x24bb, 0x24bc, 0x24bd, + 0x24be, 0x24bf, 0x24c0, 0x24c1, 0x24c2, 0x24c3, 0x24c4, 0x24c5, + 0x24c6, 0x24c7, 0x24c8, 0x24c9, 0x24ca, 0x24cb, 0x24cc, 0x24cd, + 0x24ce, 0x24cf, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0xff41, 0xff42, 0xff43, 0xff44, 0xff45, 0xff46, 0xff47, + 0xff48, 0xff49, 0xff4a, 0xff4b, 0xff4c, 0xff4d, 0xff4e, 0xff4f, + 0xff50, 0xff51, 0xff52, 0xff53, 0xff54, 0xff55, 0xff56, 0xff57, + 0xff58, 0xff59, 0xff5a, 0, 0, 0, 0, 0, + 0, 0xff21, 0xff22, 0xff23, 0xff24, 0xff25, 0xff26, 0xff27, + 0xff28, 0xff29, 0xff2a, 0xff2b, 0xff2c, 0xff2d, 0xff2e, 0xff2f, + 0xff30, 0xff31, 0xff32, 0xff33, 0xff34, 0xff35, 0xff36, 0xff37, + 0xff38, 0xff39, 0xff3a, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, +}; +// 36602 bytes + +const Q_INT8 TQUnicodeTables::decimal_info[] = { + 1, 0, 0, 0, 0, 0, 2, 0, + 0, 3, 3, 4, 3, 5, 6, 7, + 8, 0, 0, 9, 0, 0, 0, 10, + 11, 0, 0, 0, 0, 0, 0, 0, + 12, 0, 0, 0, 13, 0, 0, 14, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 11, + + + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + 0, 1, 2, 3, 4, 5, 6, 7, + 8, 9, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 2, 3, -1, -1, -1, -1, + -1, 1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + 0, 1, 2, 3, 4, 5, 6, 7, + 8, 9, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + 0, 1, 2, 3, 4, 5, 6, 7, + 8, 9, -1, -1, -1, -1, -1, -1, + + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 0, 1, + 2, 3, 4, 5, 6, 7, 8, 9, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 0, 1, + 2, 3, 4, 5, 6, 7, 8, 9, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 0, 1, + 2, 3, 4, 5, 6, 7, 8, 9, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 1, + 2, 3, 4, 5, 6, 7, 8, 9, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 0, 1, + 2, 3, 4, 5, 6, 7, 8, 9, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + 0, 1, 2, 3, 4, 5, 6, 7, + 8, 9, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + 0, 1, 2, 3, 4, 5, 6, 7, + 8, 9, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + 0, 1, 2, 3, 4, 5, 6, 7, + 8, 9, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + 0, 1, 2, 3, 4, 5, 6, 7, + 8, 9, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, 1, 2, 3, 4, 5, 6, 7, + 8, 9, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + 0, 1, 2, 3, 4, 5, 6, 7, + 8, 9, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + 0, 1, 2, 3, 4, 5, 6, 7, + 8, 9, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + 0, -1, -1, -1, 4, 5, 6, 7, + 8, 9, -1, -1, -1, -1, -1, -1, + 0, 1, 2, 3, 4, 5, 6, 7, + 8, 9, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + 1, 2, 3, 4, 5, 6, 7, 8, + 9, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 1, 2, 3, 4, + 5, 6, 7, 8, 9, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + 1, 2, 3, 4, 5, 6, 7, 8, + 9, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 0, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 1, 2, 3, + 4, 5, 6, 7, 8, 9, -1, -1, + + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 1, 2, + 3, 4, 5, 6, 7, 8, 9, -1, + 1, 2, 3, 4, 5, 6, 7, 8, + 9, -1, 1, 2, 3, 4, 5, 6, + 7, 8, 9, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, +}; +// 40698 bytes + +#endif + +#ifdef QT_NO_UNICODETABLES + +const Q_UINT8 TQUnicodeTables::latin1_line_break_info[] = { + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 15, 23, 19, 21, 22, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 26, 5, 2, 11, 8, 9, 11, 2, + 0, 1, 11, 8, 7, 14, 7, 6, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 7, 7, 11, 11, 11, 5, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 0, 8, 1, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 0, 15, 1, 11, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 3, 11, 9, 8, 8, 8, 11, 11, + 11, 11, 11, 2, 11, 15, 11, 11, + 9, 8, 11, 11, 16, 11, 11, 11, + 11, 11, 11, 2, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, +}; + +#else + +const Q_UINT8 TQUnicodeTables::line_break_info[] = { + 1, 2, 3, 4, 5, 6, 7, 8, + 2, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 2, 18, 2, 2, 19, 20, + 21, 2, 2, 2, 2, 2, 2, 2, + 22, 23, 24, 25, 2, 2, 2, 26, + 2, 27, 2, 2, 2, 2, 28, 29, + 30, 31, 32, 33, 34, 34, 34, 34, + 34, 34, 34, 34, 34, 34, 34, 34, + 34, 34, 34, 34, 34, 34, 34, 34, + 34, 34, 34, 34, 34, 35, 34, 34, + 34, 34, 34, 34, 34, 34, 34, 34, + 34, 34, 34, 34, 34, 34, 34, 34, + 34, 34, 34, 34, 34, 34, 34, 34, + 34, 34, 34, 34, 34, 34, 34, 34, + 34, 34, 34, 34, 34, 34, 34, 34, + 34, 34, 34, 34, 34, 34, 34, 34, + 34, 34, 34, 34, 34, 34, 34, 34, + 34, 34, 34, 34, 34, 34, 34, 34, + 34, 34, 34, 34, 34, 34, 34, 34, + 34, 34, 34, 34, 34, 34, 34, 36, + 34, 34, 34, 34, 37, 2, 2, 2, + 2, 2, 2, 2, 34, 34, 34, 34, + 34, 34, 34, 34, 34, 34, 34, 34, + 34, 34, 34, 34, 34, 34, 34, 34, + 34, 34, 34, 34, 34, 34, 34, 34, + 34, 34, 34, 34, 34, 34, 34, 34, + 34, 34, 34, 34, 34, 34, 34, 38, + 39, 39, 39, 39, 39, 39, 39, 39, + 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, + 2, 34, 40, 41, 2, 42, 43, 44, + + + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 15, 23, 19, 21, 22, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 26, 5, 2, 11, 8, 9, 11, 2, + 0, 1, 11, 8, 7, 14, 7, 6, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 7, 7, 11, 11, 11, 5, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 0, 8, 1, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 0, 15, 1, 11, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 3, 11, 9, 8, 8, 8, 11, 11, + 11, 11, 11, 2, 11, 15, 11, 11, + 9, 8, 11, 11, 16, 11, 11, 11, + 11, 11, 11, 2, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 16, 11, 11, 11, 16, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 19, 19, 19, 19, 11, + 19, 19, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 7, 15, 11, 11, 11, 11, 11, + 11, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 11, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 11, 19, 19, 19, 11, 19, + 11, 19, 19, 11, 19, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 11, 11, 11, 11, 11, 11, + 19, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 11, 11, 19, + 19, 11, 19, 19, 19, 19, 11, 11, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 11, 11, 11, 11, 11, 11, + + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 19, + 11, 19, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + + 11, 19, 19, 19, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 19, 11, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 11, 11, + 11, 19, 19, 19, 19, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 19, 19, 11, 11, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 19, 19, 19, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 19, 11, 19, 19, + 19, 19, 19, 19, 19, 11, 11, 19, + 19, 11, 11, 19, 19, 19, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 19, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 19, 19, 11, 11, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 11, 11, 8, 8, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + + 11, 11, 19, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 19, 11, 19, 19, + 19, 19, 19, 11, 11, 11, 11, 19, + 19, 11, 11, 19, 19, 19, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 19, 19, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 19, 19, 19, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 19, 11, 19, 19, + 19, 19, 19, 19, 19, 19, 11, 19, + 19, 19, 11, 19, 19, 19, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + + 11, 19, 19, 19, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 19, 11, 19, 19, + 19, 19, 19, 19, 11, 11, 11, 19, + 19, 11, 11, 19, 19, 19, 11, 11, + 11, 11, 11, 11, 11, 11, 19, 19, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 19, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 19, 19, + 19, 19, 19, 11, 11, 11, 19, 19, + 19, 11, 19, 19, 19, 19, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 19, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + + 11, 19, 19, 19, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 19, 19, + 19, 19, 19, 19, 19, 11, 19, 19, + 19, 11, 19, 19, 19, 19, 11, 11, + 11, 11, 11, 11, 11, 19, 19, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 19, 19, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 19, 19, + 19, 19, 19, 19, 19, 11, 19, 19, + 19, 11, 19, 19, 19, 19, 11, 11, + 11, 11, 11, 11, 11, 19, 19, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + + 11, 11, 19, 19, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 19, 19, + 19, 19, 19, 19, 11, 11, 19, 19, + 19, 11, 19, 19, 19, 19, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 19, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 19, 19, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 19, 11, 11, 11, 11, 19, + 19, 19, 19, 19, 19, 11, 19, 11, + 19, 19, 19, 19, 19, 19, 19, 19, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 19, 19, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + + 11, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, + 20, 19, 20, 20, 19, 19, 19, 19, + 19, 19, 19, 11, 11, 11, 11, 8, + 20, 20, 20, 20, 20, 20, 20, 19, + 19, 19, 19, 19, 19, 19, 19, 11, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 4, 4, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 20, 20, 11, 20, 11, 11, 20, + 20, 11, 20, 11, 11, 20, 11, 11, + 11, 11, 11, 11, 20, 20, 20, 20, + 11, 20, 20, 20, 20, 20, 20, 20, + 11, 20, 20, 20, 11, 20, 11, 20, + 11, 11, 20, 20, 11, 20, 20, 20, + 20, 19, 20, 20, 19, 19, 19, 19, + 19, 19, 11, 19, 19, 20, 11, 11, + 20, 20, 20, 20, 20, 11, 20, 11, + 19, 19, 19, 19, 19, 19, 11, 11, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 11, 11, 20, 20, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 15, 3, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 19, 19, 11, 11, 11, 11, 11, 11, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 19, 11, 19, + 11, 19, 0, 1, 0, 1, 19, 19, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 11, 19, 19, + 11, 11, 11, 11, 11, 11, 11, 11, + 19, 19, 19, 19, 19, 19, 19, 19, + 11, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 19, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + + 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 11, 20, 20, 20, 20, 20, + 11, 20, 20, 11, 19, 19, 19, 19, + 19, 19, 19, 11, 11, 11, 19, 19, + 19, 19, 11, 11, 11, 11, 11, 11, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 11, 11, 11, 11, 11, 11, + 20, 20, 20, 20, 20, 20, 19, 19, + 19, 19, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 11, 11, 11, 11, 11, 12, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 11, 11, 11, 11, 11, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 11, 11, 11, 11, 11, 11, + + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 15, 11, 11, 11, 11, 11, 11, + 11, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 15, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 0, 1, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 19, 19, 19, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 19, 19, 19, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 19, 19, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 19, 19, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 4, 15, 4, 4, + 4, 4, 4, 8, 11, 11, 11, 11, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + + 11, 11, 11, 11, 11, 11, 16, 11, + 11, 11, 11, 19, 19, 19, 19, 11, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 19, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + + 15, 15, 15, 15, 15, 15, 15, 3, + 15, 15, 15, 18, 19, 19, 19, 19, + 15, 3, 15, 15, 17, 11, 11, 11, + 2, 2, 0, 2, 2, 2, 0, 2, + 11, 11, 11, 11, 13, 13, 13, 15, + 21, 21, 19, 19, 19, 19, 19, 3, + 9, 9, 9, 9, 9, 9, 9, 9, + 11, 2, 2, 11, 4, 11, 11, 11, + 11, 11, 11, 11, 4, 0, 1, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 15, + 3, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 19, 19, 19, 19, 19, 19, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 0, 1, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 0, 1, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 8, 8, 8, 8, 8, 8, 8, 9, + 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + + 11, 11, 11, 9, 11, 11, 11, 11, + 11, 9, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 8, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 9, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 8, 8, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 0, 1, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 0, 1, 2, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 2, 2, 2, 2, 11, + 11, 11, 5, 5, 11, 11, 11, 11, + 0, 1, 0, 1, 0, 1, 0, 1, + 0, 1, 0, 1, 0, 1, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 0, 1, + 0, 1, 0, 1, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 0, 1, 0, 1, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 0, 1, 11, 11, + + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 11, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 11, 11, 11, 11, + + 12, 1, 1, 12, 12, 4, 12, 12, + 0, 1, 0, 1, 0, 1, 0, 1, + 0, 1, 12, 12, 0, 1, 0, 1, + 0, 1, 0, 1, 4, 0, 1, 1, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 19, 19, 19, 19, 19, 19, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 4, 4, 12, 12, 12, + 11, 4, 12, 4, 12, 4, 12, 4, + 12, 4, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 4, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 4, 12, 4, 12, 4, + 12, 12, 12, 12, 12, 12, 4, 12, + 12, 12, 12, 12, 12, 4, 4, 11, + 11, 19, 19, 4, 4, 4, 4, 12, + 4, 4, 12, 4, 12, 4, 12, 4, + 12, 4, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 4, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 4, 12, 4, 12, 4, + 12, 12, 12, 12, 12, 12, 4, 12, + 12, 12, 12, 12, 12, 4, 4, 12, + 12, 12, 12, 4, 4, 4, 12, 12, + + 11, 11, 11, 11, 11, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 11, 11, 11, + 11, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 11, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 11, 11, 11, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 11, 11, 11, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 11, 11, 11, 11, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 11, + + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 11, + 11, 11, 11, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 11, 11, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 11, + + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 11, 11, 11, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + + 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, + + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 11, 11, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 19, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 0, 1, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 9, 11, 11, 11, + + 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 19, 19, 19, 19, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 12, 12, 12, 12, 12, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 12, 12, 11, + 11, 12, 12, 12, 12, 12, 12, 12, + 1, 12, 1, 11, 4, 4, 5, 5, + 12, 0, 1, 0, 1, 0, 1, 12, + 12, 12, 12, 12, 12, 12, 12, 11, + 12, 8, 9, 12, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 3, + + 11, 5, 12, 12, 8, 9, 12, 12, + 0, 1, 12, 12, 1, 12, 1, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 4, 4, 12, 12, 12, 5, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 0, 12, 1, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 0, 12, 1, 12, 0, + 1, 1, 0, 1, 1, 4, 11, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 4, 4, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 9, 8, 12, 12, 12, 8, 8, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, + 11, 19, 19, 19, 25, 11, 11, 11, +}; +// 52474 bytes + +// END OF GENERATED DATA +#endif + + + +#ifndef QT_NO_UNICODETABLES +const Q_UINT16 TQUnicodeTables::symmetricPairs[] = { + 0x0028, 0x0029, 0x003C, 0x003E, 0x005B, 0x005D, 0x007B, 0x007D, + 0x00AB, 0x00BB, 0x2039, 0x203A, 0x2045, 0x2046, 0x207D, 0x207E, + 0x208D, 0x208E, 0x2208, 0x220B, 0x2209, 0x220C, 0x220A, 0x220D, + 0x2215, 0x29F5, 0x223C, 0x223D, 0x2243, 0x22CD, 0x2252, 0x2253, + 0x2254, 0x2255, 0x2264, 0x2265, 0x2266, 0x2267, 0x2268, 0x2269, + 0x226A, 0x226B, 0x226E, 0x226F, 0x2270, 0x2271, 0x2272, 0x2273, + 0x2274, 0x2275, 0x2276, 0x2277, 0x2278, 0x2279, 0x227A, 0x227B, + 0x227C, 0x227D, 0x227E, 0x227F, 0x2280, 0x2281, 0x2282, 0x2283, + 0x2284, 0x2285, 0x2286, 0x2287, 0x2288, 0x2289, 0x228A, 0x228B, + 0x228F, 0x2290, 0x2291, 0x2292, 0x2298, 0x29B8, 0x22A2, 0x22A3, + 0x22A6, 0x2ADE, 0x22A8, 0x2AE4, 0x22A9, 0x2AE3, 0x22AB, 0x2AE5, + 0x22B0, 0x22B1, 0x22B2, 0x22B3, 0x22B4, 0x22B5, 0x22B6, 0x22B7, + 0x22C9, 0x22CA, 0x22CB, 0x22CC, 0x22D0, 0x22D1, 0x22D6, 0x22D7, + 0x22D8, 0x22D9, 0x22DA, 0x22DB, 0x22DC, 0x22DD, 0x22DE, 0x22DF, + 0x22E0, 0x22E1, 0x22E2, 0x22E3, 0x22E4, 0x22E5, 0x22E6, 0x22E7, + 0x22E8, 0x22E9, 0x22EA, 0x22EB, 0x22EC, 0x22ED, 0x22F0, 0x22F1, + 0x22F2, 0x22FA, 0x22F3, 0x22FB, 0x22F4, 0x22FC, 0x22F6, 0x22FD, + 0x22F7, 0x22FE, 0x2308, 0x2309, 0x230A, 0x230B, 0x2329, 0x232A, + 0x2768, 0x2769, 0x276A, 0x276B, 0x276C, 0x276D, 0x276E, 0x276F, + 0x2770, 0x2771, 0x2772, 0x2773, 0x2774, 0x2775, 0x27D5, 0x27D6, + 0x27DD, 0x27DE, 0x27E2, 0x27E3, 0x27E4, 0x27E5, 0x27E6, 0x27E7, + 0x27E8, 0x27E9, 0x27EA, 0x27EB, 0x2983, 0x2984, 0x2985, 0x2986, + 0x2987, 0x2988, 0x2989, 0x298A, 0x298B, 0x298C, 0x298D, 0x2990, + 0x298E, 0x298F, 0x2991, 0x2992, 0x2993, 0x2994, 0x2995, 0x2996, + 0x2997, 0x2998, 0x29C0, 0x29C1, 0x29C4, 0x29C5, 0x29CF, 0x29D0, + 0x29D1, 0x29D2, 0x29D4, 0x29D5, 0x29D8, 0x29D9, 0x29DA, 0x29DB, + 0x29F8, 0x29F9, 0x29FC, 0x29FD, 0x2A2B, 0x2A2C, 0x2A34, 0x2A35, + 0x2A3C, 0x2A3D, 0x2A64, 0x2A65, 0x2A79, 0x2A7A, 0x2A7D, 0x2A7E, + 0x2A7F, 0x2A80, 0x2A81, 0x2A82, 0x2A83, 0x2A84, 0x2A8B, 0x2A8C, + 0x2A91, 0x2A92, 0x2A93, 0x2A94, 0x2A95, 0x2A96, 0x2A97, 0x2A98, + 0x2A99, 0x2A9A, 0x2A9B, 0x2A9C, 0x2AA1, 0x2AA2, 0x2AA6, 0x2AA7, + 0x2AA8, 0x2AA9, 0x2AAA, 0x2AAB, 0x2AAC, 0x2AAD, 0x2AAF, 0x2AB0, + 0x2AB3, 0x2AB4, 0x2ABB, 0x2ABC, 0x2ABD, 0x2ABE, 0x2ABF, 0x2AC0, + 0x2AC1, 0x2AC2, 0x2AC3, 0x2AC4, 0x2AC5, 0x2AC6, 0x2ACD, 0x2ACE, + 0x2ACF, 0x2AD0, 0x2AD1, 0x2AD2, 0x2AD3, 0x2AD4, 0x2AD5, 0x2AD6, + 0x2AEC, 0x2AED, 0x2AF7, 0x2AF8, 0x2AF9, 0x2AFA, 0x3008, 0x3009, + 0x300A, 0x300B, 0x300C, 0x300D, 0x300E, 0x300F, 0x3010, 0x3011, + 0x3014, 0x3015, 0x3016, 0x3017, 0x3018, 0x3019, 0x301A, 0x301B, + 0xFF08, 0xFF09, 0xFF1C, 0xFF1E, 0xFF3B, 0xFF3D, 0xFF5B, 0xFF5D, + 0xFF5F, 0xFF60, 0xFF62, 0xFF63, +}; + +// ### shouldn't this be const? +const int TQUnicodeTables::symmetricPairsSize = + sizeof(symmetricPairs)/sizeof(symmetricPairs[0]); + +#else + +/* + only include info for the first unicode range (latin1) when building + without unicode tables. +*/ +const Q_UINT8 TQUnicodeTables::unicode_info[] = { + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 7, 26, 26, 26, 28, 26, 26, 26, + 22, 23, 26, 27, 26, 21, 26, 26, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 26, 26, 27, 27, 27, 26, + 26, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 22, 26, 23, 29, 20, + 29, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 22, 27, 23, 27, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, + 7, 26, 28, 28, 28, 28, 30, 30, + 29, 30, 16, 24, 27, 21, 30, 29, + 30, 27, 6, 6, 29, 16, 30, 26, + 29, 6, 16, 25, 6, 6, 6, 26, + 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 27, + 15, 15, 15, 15, 15, 15, 15, 16, + 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 27, + 16, 16, 16, 16, 16, 16, 16, 16 +}; + +#endif + +/* + * ---------------------------------------------------------------------- + * End of unicode tables + * ---------------------------------------------------------------------- + */ + +enum Script { + // European Alphabetic Scripts + Latin, + Greek, + Cyrillic, + Armenian, + Georgian, + Runic, + Ogham, + SpacingModifiers, + CombiningMarks, + + // Middle Eastern Scripts + Hebrew, + Arabic, + Syriac, + Thaana, + + // South and Southeast Asian Scripts + Devanagari, + Bengali, + Gurmukhi, + Gujarati, + Oriya, + Tamil, + Telugu, + Kannada, + Malayalam, + Sinhala, + Thai, + Lao, + Tibetan, + Myanmar, + Khmer, + + // East Asian Scripts + Han, + Hiragana, + Katakana, + Hangul, + Bopomofo, + Yi, + + // Additional Scripts + Ethiopic, + Cherokee, + CanadianAboriginal, + Mongolian, + + // Symbols + CurrencySymbols, + LetterlikeSymbols, + NumberForms, + MathematicalOperators, + TechnicalSymbols, + GeometricSymbols, + MiscellaneousSymbols, + EnclosedAndSquare, + Braille, + + Unicode, + + // some scripts added in Unicode 3.2 + Tagalog, + Hanunoo, + Buhid, + Tagbanwa, + + KatakanaHalfWidth, // from JIS X 0201 + + // from Unicode 4.0 + Limbu, + TaiLe, + + // End + NScripts, + UnknownScript = NScripts +}; + +// copied form qfont.h, as we can't include it in tools. Do not modify without +// changing the script enum in qfont.h aswell. +const unsigned char TQUnicodeTables::otherScripts [128] = { +#define SCRIPTS_02 0 + 0xaf, Latin, 0xff, SpacingModifiers, // row 0x02, index 0 +#define SCRIPTS_03 4 + 0x6f, CombiningMarks, 0xff, Greek, // row 0x03, index 4 +#define SCRIPTS_05 8 + 0x2f, Cyrillic, 0x8f, Armenian, 0xff, Hebrew, // row 0x05, index 8 +#define SCRIPTS_07 14 + 0x4f, Syriac, 0x7f, Unicode, 0xbf, Thaana, + 0xff, Unicode, // row 0x07, index 14 +#define SCRIPTS_10 22 + 0x9f, Myanmar, 0xff, Georgian, // row 0x10, index 20 +#define SCRIPTS_13 26 + 0x7f, Ethiopic, 0x9f, Unicode, 0xff, Cherokee, // row 0x13, index 24 +#define SCRIPTS_16 32 + 0x7f, CanadianAboriginal, 0x9f, Ogham, + 0xff, Runic, // row 0x16 index 30 +#define SCRIPTS_17 38 + 0x1f, Tagalog, 0x3f, Hanunoo, 0x5f, Buhid, + 0x7f, Tagbanwa, 0xff, Khmer, // row 0x17, index 36 +#define SCRIPTS_18 48 + 0xaf, Mongolian, 0xff, Unicode, // row 0x18, index 46 +#define SCRIPTS_19 52 + 0x4f, Limbu, 0x7f, TaiLe, 0xdf, Unicode, 0xff, Khmer, +#define SCRIPTS_20 60 + 0x0a, Unicode, 0x0d, UnknownScript, 0x6f, Unicode, 0x9f, NumberForms, + 0xab, CurrencySymbols, 0xac, Latin, + 0xcf, CurrencySymbols, 0xff, CombiningMarks, // row 0x20, index 50 +#define SCRIPTS_21 76 + 0x4f, LetterlikeSymbols, 0x8f, NumberForms, + 0xff, MathematicalOperators, // row 0x21, index 62 +#define SCRIPTS_24 82 + 0x5f, TechnicalSymbols, 0xff, EnclosedAndSquare, // row 0x24, index 68 +#define SCRIPTS_2e 86 + 0x7f, Unicode, 0xff, Han, // row 0x2e, index 72 +#define SCRIPTS_30 90 + 0x3f, Han, 0x9f, Hiragana, 0xff, Katakana, // row 0x30, index 76 +#define SCRIPTS_31 96 + 0x2f, Bopomofo, 0x8f, Hangul, 0x9f, Han, + 0xff, Unicode, // row 0x31, index 82 +#define SCRIPTS_fb 104 + 0x06, Latin, 0x1c, Unicode, 0x4f, Hebrew, + 0xff, Arabic, // row 0xfb, index 90 +#define SCRIPTS_fe 112 + 0x1f, Unicode, 0x2f, CombiningMarks, 0x6f, Han, + 0xff, Arabic, // row 0xfe, index 98 +#define SCRIPTS_ff 120 + 0x60, Han, // row 0xff, index 106 + 0x9f, KatakanaHalfWidth, 0xef, Han, 0xff, Unicode +}; + +// (uc-0x0900)>>7 +const unsigned char TQUnicodeTables::indicScripts [] = +{ + Devanagari, Bengali, + Gurmukhi, Gujarati, + Oriya, Tamil, + Telugu, Kannada, + Malayalam, Sinhala, + Thai, Lao +}; + + +// 0x80 + x: x is the offset into the otherScripts table +const unsigned char TQUnicodeTables::scriptTable[256] = +{ + Latin, Latin, 0x80+SCRIPTS_02, 0x80+SCRIPTS_03, + Cyrillic, 0x80+SCRIPTS_05, Arabic, 0x80+SCRIPTS_07, + Unicode, SCRIPTS_INDIC, SCRIPTS_INDIC, SCRIPTS_INDIC, + SCRIPTS_INDIC, SCRIPTS_INDIC, SCRIPTS_INDIC, Tibetan, + + 0x80+SCRIPTS_10, Hangul, Ethiopic, 0x80+SCRIPTS_13, + CanadianAboriginal, CanadianAboriginal, 0x80+SCRIPTS_16, 0x80+SCRIPTS_17, + 0x80+SCRIPTS_18, 0x80+SCRIPTS_19, Unicode, Unicode, + Unicode, Unicode, Latin, Greek, + + 0x80+SCRIPTS_20, 0x80+SCRIPTS_21, MathematicalOperators, TechnicalSymbols, + 0x80+SCRIPTS_24, GeometricSymbols, MiscellaneousSymbols, MiscellaneousSymbols, + Braille, Unicode, Unicode, Unicode, + Unicode, Unicode, 0x80+SCRIPTS_2e, Han, + + 0x80+SCRIPTS_30, 0x80+SCRIPTS_31, EnclosedAndSquare, EnclosedAndSquare, + Han, Han, Han, Han, + Han, Han, Han, Han, + Han, Han, Han, Han, + + Han, Han, Han, Han, Han, Han, Han, Han, + Han, Han, Han, Han, Han, Han, Han, Han, + + Han, Han, Han, Han, Han, Han, Han, Han, + Han, Han, Han, Han, Han, Han, Han, Han, + + Han, Han, Han, Han, Han, Han, Han, Han, + Han, Han, Han, Han, Han, Han, Han, Han, + + Han, Han, Han, Han, Han, Han, Han, Han, + Han, Han, Han, Han, Han, Han, Han, Han, + + + Han, Han, Han, Han, Han, Han, Han, Han, + Han, Han, Han, Han, Han, Han, Han, Han, + + Han, Han, Han, Han, Han, Han, Han, Han, + Han, Han, Han, Han, Han, Han, Han, Han, + + Yi, Yi, Yi, Yi, Yi, Unicode, Unicode, Unicode, + Unicode, Unicode, Unicode, Unicode, Hangul, Hangul, Hangul, Hangul, + + Hangul, Hangul, Hangul, Hangul, Hangul, Hangul, Hangul, Hangul, + Hangul, Hangul, Hangul, Hangul, Hangul, Hangul, Hangul, Hangul, + + Hangul, Hangul, Hangul, Hangul, Hangul, Hangul, Hangul, Hangul, + Hangul, Hangul, Hangul, Hangul, Hangul, Hangul, Hangul, Hangul, + + Hangul, Hangul, Hangul, Hangul, Hangul, Hangul, Hangul, Hangul, + Unicode, Unicode, Unicode, Unicode, Unicode, Unicode, Unicode, Unicode, + + Unicode, Unicode, Unicode, Unicode, Unicode, Unicode, Unicode, Unicode, + Unicode, Unicode, Unicode, Unicode, Unicode, Unicode, Unicode, Unicode, + + Unicode, Unicode, Unicode, Unicode, Unicode, Unicode, Unicode, Unicode, + Unicode, Han, Han, 0x80+SCRIPTS_fb, Arabic, Arabic, 0x80+SCRIPTS_fe, 0x80+SCRIPTS_ff +}; + diff --git a/src/tools/qunicodetables_p.h b/src/tools/qunicodetables_p.h new file mode 100644 index 000000000..3dff630d4 --- /dev/null +++ b/src/tools/qunicodetables_p.h @@ -0,0 +1,266 @@ +/**************************************************************************** +** +** ??? +** +** Copyright (C) 2005-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the widgets module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQUNICODETABLES_P_H +#define TQUNICODETABLES_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the TQt API. It exists for the convenience +// of internal files. This header file may change from version to version +// without notice, or even be removed. +// +// We mean it. +// +// + +#ifndef QT_H +#include "qstring.h" +#endif // QT_H + +#ifdef QT_NO_UNICODETABLES +# include +#endif + +class TQUnicodeTables { +public: + static const Q_UINT8 unicode_info[]; +#ifndef QT_NO_UNICODETABLES + static const Q_UINT16 decomposition_map[]; + static const Q_UINT16 decomposition_info[]; + static const Q_UINT16 ligature_map[]; + static const Q_UINT16 ligature_info[]; + static const Q_UINT8 direction_info[]; + static const Q_UINT8 combining_info[]; + static const Q_UINT16 case_info[]; + static const Q_INT8 decimal_info[]; + static const Q_UINT16 symmetricPairs[]; + static const int symmetricPairsSize; + static const Q_UINT8 line_break_info[]; +#else + static const Q_UINT8 latin1_line_break_info[]; +#endif + static const unsigned char otherScripts[]; + static const unsigned char indicScripts[]; + static const unsigned char scriptTable[]; + enum { SCRIPTS_INDIC = 0x7e }; + + // see http://www.unicode.org/reports/tr14/tr14-13.html + // we don't use the XX and AI properties and map them to AL instead. + enum LineBreakClass { + LineBreak_OP, LineBreak_CL, LineBreak_QU, LineBreak_GL, LineBreak_NS, + LineBreak_EX, LineBreak_SY, LineBreak_IS, LineBreak_PR, LineBreak_PO, + LineBreak_NU, LineBreak_AL, LineBreak_ID, LineBreak_IN, LineBreak_HY, + LineBreak_BA, LineBreak_BB, LineBreak_B2, LineBreak_ZW, LineBreak_CM, + LineBreak_SA, LineBreak_BK, LineBreak_CR, LineBreak_LF, LineBreak_SG, + LineBreak_CB, LineBreak_SP + }; +}; + + +inline TQChar::Category category( const TQChar &c ) +{ +#ifdef QT_NO_UNICODETABLES + if ( c.unicode() > 0xff ) return TQChar::Letter_Uppercase; //######## + return (TQChar::Category)TQUnicodeTables::unicode_info[c.unicode()]; +#else + register int uc = ((int)TQUnicodeTables::unicode_info[c.row()]) << 8; + uc += c.cell(); + return (TQChar::Category)TQUnicodeTables::unicode_info[uc]; +#endif // QT_NO_UNICODETABLES +} + +inline TQChar lower( const TQChar &c ) +{ +#ifndef QT_NO_UNICODETABLES + int row = c.row(); + int cell = c.cell(); + register int ci = TQUnicodeTables::case_info[row]; + register int uc = ((int)TQUnicodeTables::unicode_info[c.row()]) << 8; + uc += c.cell(); + if (TQUnicodeTables::unicode_info[uc] != TQChar::Letter_Uppercase || !ci) + return c; + Q_UINT16 lower = TQUnicodeTables::case_info[(ci<<8)+cell]; + return lower ? TQChar(lower) : c; +#else + if ( c.row() ) + return c; + return TQChar( tolower((uchar) c.latin1()) ); +#endif +} + +inline TQChar upper( const TQChar &c ) +{ +#ifndef QT_NO_UNICODETABLES + int row = c.row(); + int cell = c.cell(); + register int ci = TQUnicodeTables::case_info[row]; + register int uc = ((int)TQUnicodeTables::unicode_info[c.row()]) << 8; + uc += c.cell(); + if (TQUnicodeTables::unicode_info[uc] != TQChar::Letter_Lowercase || !ci) + return c; + Q_UINT16 upper = TQUnicodeTables::case_info[(ci<<8)+cell]; + return upper ? TQChar(upper) : c; +#else + if ( c.row() ) + return c; + return TQChar( toupper((uchar) c.latin1()) ); +#endif +} + +inline TQChar::Direction direction( const TQChar &c ) +{ +#ifndef QT_NO_UNICODETABLES + register int pos = TQUnicodeTables::direction_info[c.row()]; + return (TQChar::Direction) (TQUnicodeTables::direction_info[(pos<<8)+c.cell()] & 0x1f); +#else + Q_UNUSED(c); + return TQChar::DirL; +#endif +} + +inline bool mirrored( const TQChar &c ) +{ +#ifndef QT_NO_UNICODETABLES + register int pos = TQUnicodeTables::direction_info[c.row()]; + return TQUnicodeTables::direction_info[(pos<<8)+c.cell()] > 128; +#else + Q_UNUSED(c); + return FALSE; +#endif +} + + +inline TQChar mirroredChar( const TQChar &ch ) +{ +#ifndef QT_NO_UNICODETABLES + if(!::mirrored( ch )) + return ch; + + int i; + int c = ch.unicode(); + for (i = 0; i < TQUnicodeTables::symmetricPairsSize; i ++) { + if (TQUnicodeTables::symmetricPairs[i] == c) + return TQUnicodeTables::symmetricPairs[(i%2) ? (i-1) : (i+1)]; + } +#endif + return ch; +} + +inline TQChar::Joining joining( const TQChar &ch ) +{ +#ifndef QT_NO_UNICODETABLES + register int pos = TQUnicodeTables::direction_info[ch.row()]; + return (TQChar::Joining) ((TQUnicodeTables::direction_info[(pos<<8)+ch.cell()] >> 5) &0x3); +#else + Q_UNUSED(ch); + return TQChar::OtherJoining; +#endif +} + +inline bool isMark( const TQChar &ch ) +{ + TQChar::Category c = ::category( ch ); + return c >= TQChar::Mark_NonSpacing && c <= TQChar::Mark_Enclosing; +} + +inline unsigned char combiningClass( const TQChar &ch ) +{ +#ifndef QT_NO_UNICODETABLES + const int pos = TQUnicodeTables::combining_info[ch.row()]; + return TQUnicodeTables::combining_info[(pos<<8) + ch.cell()]; +#else + Q_UNUSED(ch); + return 0; +#endif +} + +inline bool isSpace( const TQChar &ch ) +{ + if( ch.unicode() >= 9 && ch.unicode() <=13 ) return TRUE; + TQChar::Category c = ::category( ch ); + return c >= TQChar::Separator_Space && c <= TQChar::Separator_Paragraph; +} + +inline int lineBreakClass( const TQChar &ch ) +{ +#ifdef QT_NO_UNICODETABLES + return ch.row() ? TQUnicodeTables::LineBreak_AL + : TQUnicodeTables::latin1_line_break_info[ch.cell()]; +#else + register int pos = ((int)TQUnicodeTables::line_break_info[ch.row()] << 8) + ch.cell(); + return TQUnicodeTables::line_break_info[pos]; +#endif +} + +inline int scriptForChar( ushort uc ) +{ + unsigned char script = TQUnicodeTables::scriptTable[(uc>>8)]; + if ( script >= TQUnicodeTables::SCRIPTS_INDIC ) { + if ( script == TQUnicodeTables::SCRIPTS_INDIC ) { + script = TQUnicodeTables::indicScripts[ (uc-0x0900)>>7 ]; + } else { + // 0x80 + SCRIPTS_xx + unsigned char index = script-0x80; + unsigned char cell = uc &0xff; + while( TQUnicodeTables::otherScripts[index++] < cell ) + index++; + script = TQUnicodeTables::otherScripts[index]; + } + } + return script; +} + +#ifdef Q_WS_X11 +#define SCRIPT_FOR_CHAR( script, c ) \ +do { \ + unsigned short _uc = (c).unicode(); \ + if ( _uc < 0x100 ) { \ + script = TQFont::Latin; \ + } else { \ + script = (TQFont::Script)scriptForChar( _uc ); \ + } \ +} while( FALSE ) +#else +#define SCRIPT_FOR_CHAR( script, c ) \ + script = (TQFont::Script)scriptForChar( (c).unicode() ) +#endif + +#endif diff --git a/src/tools/quuid.cpp b/src/tools/quuid.cpp new file mode 100644 index 000000000..a486a6c9d --- /dev/null +++ b/src/tools/quuid.cpp @@ -0,0 +1,421 @@ +/**************************************************************************** +** +** Implementation of TQUuid class +** +** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "quuid.h" + +#include "qdatastream.h" + +/*! + \class TQUuid quuid.h + \brief The TQUuid class defines a Universally Unique Identifier (UUID). + + \reentrant + + For objects or declarations that must be uniquely identified, + UUIDs (also known as GUIDs) are widely used in order to assign a + fixed and easy to compare value to the object or declaration. The + 128-bit value of a UUID is generated by an algorithm that + guarantees that the value is unique. + + In TQt, UUIDs are wrapped by the TQUuid struct which provides + convenience functions for handling UUIDs. Most platforms provide a + tool to generate new UUIDs, for example, uuidgen and guidgen. + + UUIDs generated by TQUuid, are based on the \c Random version of the + \c DCE (Distributed Computing Environment) standard. + + UUIDs can be constructed from numeric values or from strings, or + using the static createUuid() function. They can be converted to a + string with toString(). UUIDs have a variant() and a version(), + and null UUIDs return TRUE from isNull(). +*/ + +/*! + \fn TQUuid::TQUuid() + + Creates the null UUID {00000000-0000-0000-0000-000000000000}. +*/ + +/*! + \fn TQUuid::TQUuid( uint l, ushort w1, ushort w2, uchar b1, uchar b2, uchar b3, uchar b4, uchar b5, uchar b6, uchar b7, uchar b8 ) + + Creates a UUID with the value specified by the parameters, \a l, + \a w1, \a w2, \a b1, \a b2, \a b3, \a b4, \a b5, \a b6, \a b7, \a + b8. + + Example: + \code + // {67C8770B-44F1-410A-AB9A-F9B5446F13EE} + TQUuid IID_MyInterface( 0x67c8770b, 0x44f1, 0x410a, 0xab, 0x9a, 0xf9, 0xb5, 0x44, 0x6f, 0x13, 0xee ) + \endcode +*/ + +/*! + \fn TQUuid::TQUuid( const TQUuid &orig ) + + Creates a copy of the TQUuid \a orig. +*/ +#ifndef QT_NO_QUUID_STRING +/*! + Creates a TQUuid object from the string \a text. The function can + only convert a string in the format + {HHHHHHHH-HHHH-HHHH-HHHH-HHHHHHHHHHHH} (where 'H' stands for a hex + digit). If the conversion fails a null UUID is created. +*/ +TQUuid::TQUuid( const TQString &text ) +{ + bool ok; + if ( text.isEmpty() ) { + *this = TQUuid(); + return; + } + TQString temp = text.upper(); + if ( temp[0] != '{' ) + temp = "{" + text; + if ( text[(int)text.length()-1] != '}' ) + temp += "}"; + + data1 = temp.mid( 1, 8 ).toULong( &ok, 16 ); + if ( !ok ) { + *this = TQUuid(); + return; + } + + data2 = temp.mid( 10, 4 ).toUInt( &ok, 16 ); + if ( !ok ) { + *this = TQUuid(); + return; + } + data3 = temp.mid( 15, 4 ).toUInt( &ok, 16 ); + if ( !ok ) { + *this = TQUuid(); + return; + } + data4[0] = temp.mid( 20, 2 ).toUInt( &ok, 16 ); + if ( !ok ) { + *this = TQUuid(); + return; + } + data4[1] = temp.mid( 22, 2 ).toUInt( &ok, 16 ); + if ( !ok ) { + *this = TQUuid(); + return; + } + for ( int i = 2; i<8; i++ ) { + data4[i] = temp.mid( 25 + (i-2)*2, 2 ).toUShort( &ok, 16 ); + if ( !ok ) { + *this = TQUuid(); + return; + } + } +} + +/*! + \internal +*/ +TQUuid::TQUuid( const char *text ) +{ + *this = TQUuid( TQString(text) ); +} +#endif +/*! + \fn TQUuid TQUuid::operator=(const TQUuid &uuid ) + + Assigns the value of \a uuid to this TQUuid object. +*/ + +/*! + \fn bool TQUuid::operator==(const TQUuid &other) const + + Returns TRUE if this TQUuid and the \a other TQUuid are identical; + otherwise returns FALSE. +*/ + +/*! + \fn bool TQUuid::operator!=(const TQUuid &other) const + + Returns TRUE if this TQUuid and the \a other TQUuid are different; + otherwise returns FALSE. +*/ +#ifndef QT_NO_QUUID_STRING +/*! + \fn TQUuid::operator TQString() const + + Returns the string representation of the uuid. + + \sa toString() +*/ + +/*! + TQString TQUuid::toString() const + + Returns the string representation of the uuid. +*/ +TQString TQUuid::toString() const +{ + TQString result; + + result = "{" + TQString::number( data1, 16 ).rightJustify( 8, '0' ) + "-"; + result += TQString::number( (int)data2, 16 ).rightJustify( 4, '0' ) + "-"; + result += TQString::number( (int)data3, 16 ).rightJustify( 4, '0' ) + "-"; + result += TQString::number( (int)data4[0], 16 ).rightJustify( 2, '0' ); + result += TQString::number( (int)data4[1], 16 ).rightJustify( 2, '0' ) + "-"; + for ( int i = 2; i < 8; i++ ) + result += TQString::number( (int)data4[i], 16 ).rightJustify( 2, '0' ); + + return result + "}"; +} +#endif + +#ifndef QT_NO_DATASTREAM +/*! + \relates TQUuid + Writes the uuid \a id to the datastream \a s. +*/ +TQDataStream &operator<<( TQDataStream &s, const TQUuid &id ) +{ + s << (Q_UINT32)id.data1; + s << (Q_UINT16)id.data2; + s << (Q_UINT16)id.data3; + for (int i = 0; i < 8; i++ ) + s << (Q_UINT8)id.data4[i]; + return s; +} + +/*! + \relates TQUuid + Reads uuid from from the stream \a s into \a id. +*/ +TQDataStream &operator>>( TQDataStream &s, TQUuid &id ) +{ + Q_UINT32 u32; + Q_UINT16 u16; + Q_UINT8 u8; + s >> u32; + id.data1 = u32; + s >> u16; + id.data2 = u16; + s >> u16; + id.data3 = u16; + for (int i = 0; i < 8; i++ ) { + s >> u8; + id.data4[i] = u8; + } + return s; +} +#endif + +/*! + Returns TRUE if this is the null UUID + {00000000-0000-0000-0000-000000000000}; otherwise returns FALSE. +*/ +bool TQUuid::isNull() const +{ + return data4[0] == 0 && data4[1] == 0 && data4[2] == 0 && data4[3] == 0 && + data4[4] == 0 && data4[5] == 0 && data4[6] == 0 && data4[7] == 0 && + data1 == 0 && data2 == 0 && data3 == 0; +} + +/*! + \enum TQUuid::Variant + + This enum defines the variant of the UUID, which is the scheme + which defines the layout of the 128-bits value. + + \value VarUnknown Variant is unknown + \value NCS Reserved for NCS (Network Computing System) backward compatibility + \value DCE Distributed Computing Environment, the scheme used by TQUuid + \value Microsoft Reserved for Microsoft backward compatibility (GUID) + \value Reserved Reserved for future definition +*/ + +/*! + \enum TQUuid::Version + + This enum defines the version of the UUID. + + \value VerUnknown Version is unknown + \value Time Time-based, by using timestamp, clock sequence, and + MAC network card address (if available) for the node sections + \value EmbeddedPOSIX DCE Security version, with embedded POSIX UUIDs + \value Name Name-based, by using values from a name for all sections + \value Random Random-based, by using random numbers for all sections +*/ + +/*! + \fn TQUuid::Variant TQUuid::variant() const + + Returns the variant of the UUID. + The null UUID is considered to be of an unknown variant. + + \sa version() +*/ +TQUuid::Variant TQUuid::variant() const +{ + if ( isNull() ) + return VarUnknown; + // Check the 3 MSB of data4[0] + if ( (data4[0] & 0x80) == 0x00 ) return NCS; + else if ( (data4[0] & 0xC0) == 0x80 ) return DCE; + else if ( (data4[0] & 0xE0) == 0xC0 ) return Microsoft; + else if ( (data4[0] & 0xE0) == 0xE0 ) return Reserved; + return VarUnknown; +} + +/*! + \fn TQUuid::Version TQUuid::version() const + + Returns the version of the UUID, if the UUID is of the DCE + variant; otherwise returns VerUnknown. + + \sa variant() +*/ +TQUuid::Version TQUuid::version() const +{ + // Check the 4 MSB of data3 + Version ver = (Version)(data3>>12); + if ( isNull() + || (variant() != DCE) + || ver < Time + || ver > Random ) + return VerUnknown; + return ver; +} + +/*! + \fn bool TQUuid::operator<(const TQUuid &other) const + + Returns TRUE if this TQUuid is of the same variant, + and lexicographically before the \a other TQUuid; + otherwise returns FALSE. + + \sa variant() +*/ +#define ISLESS(f1, f2) if (f1!=f2) return (f1(const TQUuid &other) const + + Returns TRUE if this TQUuid is of the same variant, + and lexicographically after the \a other TQUuid; + otherwise returns FALSE. + + \sa variant() +*/ +#define ISMORE(f1, f2) if (f1!=f2) return (f1>f2); +bool TQUuid::operator>(const TQUuid &other ) const +{ + if ( variant() != other.variant() ) + return FALSE; + + ISMORE( data1, other.data1 ); + ISMORE( data2, other.data2 ); + ISMORE( data3, other.data3 ); + for ( int n = 0; n < 8; n++ ) { + ISMORE( data4[n], other.data4[n] ); + } + return FALSE; +} + +/*! + \fn TQUuid TQUuid::createUuid() + + Returns a new UUID of \c DCE variant, and \c Random type. The + UUIDs generated are based on the platform specific pseudo-random + generator, which is usually not a cryptographic-quality random + number generator. Therefore, a UUID is not guaranteed to be unique + cross application instances. + + On Windows, the new UUID is extremely likely to be unique on the + same or any other system, networked or not. + + \sa variant(), version() +*/ +#if defined(Q_OS_WIN32) +#include // For CoCreateGuid +TQUuid TQUuid::createUuid() +{ + GUID guid; + CoCreateGuid( &guid ); + TQUuid result = guid; + return result; +} +#else // !Q_OS_WIN32 +#include "qdatetime.h" +#include "stdlib.h" // For srand/rand +TQUuid TQUuid::createUuid() +{ + static const int intbits = sizeof(int)*8; + static int randbits = 0; + if ( !randbits ) { + int max = RAND_MAX; + do { ++randbits; } while ( (max=max>>1) ); + srand( (uint)TQDateTime::currentDateTime().toTime_t() ); + rand(); // Skip first + } + + TQUuid result; + uint *data = &(result.data1); + int chunks = 16 / sizeof(uint); + while ( chunks-- ) { + uint randNumber = 0; + for ( int filled = 0; filled < intbits; filled += randbits ) + randNumber |= rand()< + +#if defined(Q_OS_WIN32) +#ifndef GUID_DEFINED +#define GUID_DEFINED +typedef struct _GUID +{ + ulong Data1; + ushort Data2; + ushort Data3; + uchar Data4[ 8 ]; +} GUID, *REFGUID, *LPGUID; +#endif +#endif + + +struct Q_EXPORT TQUuid +{ + enum Variant { + VarUnknown =-1, + NCS = 0, // 0 - - + DCE = 2, // 1 0 - + Microsoft = 6, // 1 1 0 + Reserved = 7 // 1 1 1 + }; + + enum Version { + VerUnknown =-1, + Time = 1, // 0 0 0 1 + EmbeddedPOSIX = 2, // 0 0 1 0 + Name = 3, // 0 0 1 1 + Random = 4 // 0 1 0 0 + }; + + TQUuid() + { + memset( this, 0, sizeof(TQUuid) ); + } + TQUuid( uint l, ushort w1, ushort w2, uchar b1, uchar b2, uchar b3, uchar b4, uchar b5, uchar b6, uchar b7, uchar b8 ) + { + data1 = l; + data2 = w1; + data3 = w2; + data4[0] = b1; + data4[1] = b2; + data4[2] = b3; + data4[3] = b4; + data4[4] = b5; + data4[5] = b6; + data4[6] = b7; + data4[7] = b8; + } + TQUuid( const TQUuid &uuid ) + { + memcpy( this, &uuid, sizeof(TQUuid) ); + } +#ifndef QT_NO_QUUID_STRING + TQUuid( const TQString & ); + TQUuid( const char * ); + TQString toString() const; + operator TQString() const { return toString(); } +#endif + bool isNull() const; + + TQUuid &operator=(const TQUuid &orig ) + { + memcpy( this, &orig, sizeof(TQUuid) ); + return *this; + } + + bool operator==(const TQUuid &orig ) const + { + uint i; + if ( data1 != orig.data1 || data2 != orig.data2 || + data3 != orig.data3 ) + return FALSE; + + for( i = 0; i < 8; i++ ) + if ( data4[i] != orig.data4[i] ) + return FALSE; + + return TRUE; + } + + bool operator!=(const TQUuid &orig ) const + { + return !( *this == orig ); + } + + bool operator<(const TQUuid &other ) const; + bool operator>(const TQUuid &other ) const; + +#if defined(Q_OS_WIN32) + // On Windows we have a type GUID that is used by the platform API, so we + // provide convenience operators to cast from and to this type. + TQUuid( const GUID &guid ) + { + memcpy( this, &guid, sizeof(GUID) ); + } + + TQUuid &operator=(const GUID &orig ) + { + memcpy( this, &orig, sizeof(TQUuid) ); + return *this; + } + + operator GUID() const + { + GUID guid = { data1, data2, data3, { data4[0], data4[1], data4[2], data4[3], data4[4], data4[5], data4[6], data4[7] } }; + return guid; + } + + bool operator==( const GUID &guid ) const + { + uint i; + if ( data1 != guid.Data1 || data2 != guid.Data2 || + data3 != guid.Data3 ) + return FALSE; + + for( i = 0; i < 8; i++ ) + if ( data4[i] != guid.Data4[i] ) + return FALSE; + + return TRUE; + } + + bool operator!=( const GUID &guid ) const + { + return !( *this == guid ); + } +#endif + static TQUuid createUuid(); + TQUuid::Variant variant() const; + TQUuid::Version version() const; + + uint data1; + ushort data2; + ushort data3; + uchar data4[ 8 ]; +}; + +#ifndef QT_NO_DATASTREAM +Q_EXPORT TQDataStream &operator<<( TQDataStream &, const TQUuid & ); +Q_EXPORT TQDataStream &operator>>( TQDataStream &, TQUuid & ); +#endif + +#endif //TQUUID_H diff --git a/src/tools/qvaluelist.h b/src/tools/qvaluelist.h new file mode 100644 index 000000000..41babd8c1 --- /dev/null +++ b/src/tools/qvaluelist.h @@ -0,0 +1,670 @@ +/**************************************************************************** +** +** Definition of TQValueList class +** +** Created : 990406 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQVALUELIST_H +#define TQVALUELIST_H + +#ifndef QT_H +#include "qtl.h" +#include "qshared.h" +#include "qdatastream.h" +#endif // QT_H + +#ifndef QT_NO_STL +#include +#include +#include +#endif + +//#define QT_CHECK_VALUELIST_RANGE + +#if defined(Q_CC_MSVC) +#pragma warning(disable:4284) // "return type for operator -> is not a UDT" +#endif + +template +class TQValueListNode +{ +public: + TQValueListNode( const T& t ) : data( t ) { } + TQValueListNode() { } +#if defined(Q_TEMPLATEDLL) + // Workaround MS bug in memory de/allocation in DLL vs. EXE + virtual ~TQValueListNode() { } +#endif + + TQValueListNode* next; + TQValueListNode* prev; + T data; +}; + +template +class TQValueListIterator +{ + public: + /** + * Typedefs + */ + typedef TQValueListNode* NodePtr; +#ifndef QT_NO_STL + typedef std::bidirectional_iterator_tag iterator_category; +#endif + typedef T value_type; + typedef size_t size_type; +#ifndef QT_NO_STL + typedef ptrdiff_t difference_type; +#else + typedef int difference_type; +#endif + typedef T* pointer; + typedef T& reference; + + /** + * Variables + */ + NodePtr node; + + /** + * Functions + */ + TQValueListIterator() : node( 0 ) {} + TQValueListIterator( NodePtr p ) : node( p ) {} + TQValueListIterator( const TQValueListIterator& it ) : node( it.node ) {} + + bool operator==( const TQValueListIterator& it ) const { return node == it.node; } + bool operator!=( const TQValueListIterator& it ) const { return node != it.node; } + const T& operator*() const { return node->data; } + T& operator*() { return node->data; } + // UDT for T = x* + // T* operator->() const { return &node->data; } + + TQValueListIterator& operator++() { + node = node->next; + return *this; + } + + TQValueListIterator operator++(int) { + TQValueListIterator tmp = *this; + node = node->next; + return tmp; + } + + TQValueListIterator& operator--() { + node = node->prev; + return *this; + } + + TQValueListIterator operator--(int) { + TQValueListIterator tmp = *this; + node = node->prev; + return tmp; + } + + TQValueListIterator& operator+=( int j ) { + while ( j-- ) + node = node->next; + return *this; + } + + TQValueListIterator& operator-=( int j ) { + while ( j-- ) + node = node->prev; + return *this; + } + +}; + +template +class TQValueListConstIterator +{ + public: + /** + * Typedefs + */ + typedef TQValueListNode* NodePtr; +#ifndef QT_NO_STL + typedef std::bidirectional_iterator_tag iterator_category; +#endif + typedef T value_type; + typedef size_t size_type; +#ifndef QT_NO_STL + typedef ptrdiff_t difference_type; +#else + typedef int difference_type; +#endif + typedef const T* pointer; + typedef const T& reference; + + /** + * Variables + */ + NodePtr node; + + /** + * Functions + */ + TQValueListConstIterator() : node( 0 ) {} + TQValueListConstIterator( NodePtr p ) : node( p ) {} + TQValueListConstIterator( const TQValueListConstIterator& it ) : node( it.node ) {} + TQValueListConstIterator( const TQValueListIterator& it ) : node( it.node ) {} + + bool operator==( const TQValueListConstIterator& it ) const { return node == it.node; } + bool operator!=( const TQValueListConstIterator& it ) const { return node != it.node; } + const T& operator*() const { return node->data; } + // UDT for T = x* + // const T* operator->() const { return &node->data; } + + TQValueListConstIterator& operator++() { + node = node->next; + return *this; + } + + TQValueListConstIterator operator++(int) { + TQValueListConstIterator tmp = *this; + node = node->next; + return tmp; + } + + TQValueListConstIterator& operator--() { + node = node->prev; + return *this; + } + + TQValueListConstIterator operator--(int) { + TQValueListConstIterator tmp = *this; + node = node->prev; + return tmp; + } +}; + +template +class TQValueListPrivate : public TQShared +{ +public: + /** + * Typedefs + */ + typedef TQValueListIterator Iterator; + typedef TQValueListConstIterator ConstIterator; + typedef TQValueListNode Node; + typedef TQValueListNode* NodePtr; + typedef size_t size_type; + + /** + * Functions + */ + TQValueListPrivate(); + TQValueListPrivate( const TQValueListPrivate& _p ); + + void derefAndDelete() // ### hack to get around hp-cc brain damage + { + if ( deref() ) + delete this; + } + +#if defined(Q_TEMPLATEDLL) + // Workaround MS bug in memory de/allocation in DLL vs. EXE + virtual +#endif + ~TQValueListPrivate(); + + Iterator insert( Iterator it, const T& x ); + Iterator remove( Iterator it ); + NodePtr find( NodePtr start, const T& x ) const; + int findIndex( NodePtr start, const T& x ) const; + uint contains( const T& x ) const; + uint remove( const T& x ); + NodePtr at( size_type i ) const; + void clear(); + + NodePtr node; + size_type nodes; +}; + +template +Q_INLINE_TEMPLATES TQValueListPrivate::TQValueListPrivate() +{ + node = new Node; node->next = node->prev = node; nodes = 0; +} + +template +Q_INLINE_TEMPLATES TQValueListPrivate::TQValueListPrivate( const TQValueListPrivate& _p ) + : TQShared() +{ + node = new Node; node->next = node->prev = node; nodes = 0; + Iterator b( _p.node->next ); + Iterator e( _p.node ); + Iterator i( node ); + while( b != e ) + insert( i, *b++ ); +} + +template +Q_INLINE_TEMPLATES TQValueListPrivate::~TQValueListPrivate() { + NodePtr p = node->next; + while( p != node ) { + NodePtr x = p->next; + delete p; + p = x; + } + delete node; +} + +template +Q_INLINE_TEMPLATES Q_TYPENAME TQValueListPrivate::Iterator TQValueListPrivate::insert( Q_TYPENAME TQValueListPrivate::Iterator it, const T& x ) +{ + NodePtr p = new Node( x ); + p->next = it.node; + p->prev = it.node->prev; + it.node->prev->next = p; + it.node->prev = p; + nodes++; + return p; +} + +template +Q_INLINE_TEMPLATES Q_TYPENAME TQValueListPrivate::Iterator TQValueListPrivate::remove( Q_TYPENAME TQValueListPrivate::Iterator it ) +{ + Q_ASSERT ( it.node != node ); + NodePtr next = it.node->next; + NodePtr prev = it.node->prev; + prev->next = next; + next->prev = prev; + delete it.node; + nodes--; + return Iterator( next ); +} + +template +Q_INLINE_TEMPLATES Q_TYPENAME TQValueListPrivate::NodePtr TQValueListPrivate::find( Q_TYPENAME TQValueListPrivate::NodePtr start, const T& x ) const +{ + ConstIterator first( start ); + ConstIterator last( node ); + while( first != last) { + if ( *first == x ) + return first.node; + ++first; + } + return last.node; +} + +template +Q_INLINE_TEMPLATES int TQValueListPrivate::findIndex( Q_TYPENAME TQValueListPrivate::NodePtr start, const T& x ) const +{ + ConstIterator first( start ); + ConstIterator last( node ); + int pos = 0; + while( first != last) { + if ( *first == x ) + return pos; + ++first; + ++pos; + } + return -1; +} + +template +Q_INLINE_TEMPLATES uint TQValueListPrivate::contains( const T& x ) const +{ + uint result = 0; + Iterator first = Iterator( node->next ); + Iterator last = Iterator( node ); + while( first != last) { + if ( *first == x ) + ++result; + ++first; + } + return result; +} + +template +Q_INLINE_TEMPLATES uint TQValueListPrivate::remove( const T& _x ) +{ + const T x = _x; + uint result = 0; + Iterator first = Iterator( node->next ); + Iterator last = Iterator( node ); + while( first != last) { + if ( *first == x ) { + first = remove( first ); + ++result; + } else + ++first; + } + return result; +} + +template +Q_INLINE_TEMPLATES Q_TYPENAME TQValueListPrivate::NodePtr TQValueListPrivate::at( size_type i ) const +{ + Q_ASSERT( i <= nodes ); + NodePtr p = node->next; + for( size_type x = 0; x < i; ++x ) + p = p->next; + return p; +} + +template +Q_INLINE_TEMPLATES void TQValueListPrivate::clear() +{ + nodes = 0; + NodePtr p = node->next; + while( p != node ) { + NodePtr next = p->next; + delete p; + p = next; + } + node->next = node->prev = node; +} + +#ifdef QT_CHECK_RANGE +# if !defined( QT_NO_DEBUG ) && defined( QT_CHECK_VALUELIST_RANGE ) +# define QT_CHECK_INVALID_LIST_ELEMENT if ( empty() ) qWarning( "TQValueList: Warning invalid element" ) +# define QT_CHECK_INVALID_LIST_ELEMENT_FATAL Q_ASSERT( !empty() ); +# else +# define QT_CHECK_INVALID_LIST_ELEMENT +# define QT_CHECK_INVALID_LIST_ELEMENT_FATAL +# endif +#else +# define QT_CHECK_INVALID_LIST_ELEMENT +# define QT_CHECK_INVALID_LIST_ELEMENT_FATAL +#endif + +template class TQDeepCopy; + +template +class TQValueList +{ +public: + /** + * Typedefs + */ + typedef TQValueListIterator iterator; + typedef TQValueListConstIterator const_iterator; + typedef T value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; + typedef size_t size_type; +#ifndef QT_NO_STL + typedef ptrdiff_t difference_type; +#else + typedef int difference_type; +#endif + + /** + * API + */ + TQValueList() { sh = new TQValueListPrivate; } + TQValueList( const TQValueList& l ) { sh = l.sh; sh->ref(); } +#ifndef QT_NO_STL + TQValueList( const std::list& l ) + { + sh = new TQValueListPrivate; + qCopy( l.begin(), l.end(), std::back_inserter( *this ) ); + } +#endif + ~TQValueList() { sh->derefAndDelete(); } + + TQValueList& operator= ( const TQValueList& l ) + { + l.sh->ref(); + sh->derefAndDelete(); + sh = l.sh; + return *this; + } +#ifndef QT_NO_STL + TQValueList& operator= ( const std::list& l ) + { + detach(); + qCopy( l.begin(), l.end(), std::back_inserter( *this ) ); + return *this; + } + bool operator== ( const std::list& l ) const + { + if ( size() != l.size() ) + return FALSE; + const_iterator it2 = begin(); +#if !defined(Q_CC_MIPS) + typename +#endif + std::list::const_iterator it = l.begin(); + for ( ; it2 != end(); ++it2, ++it ) + if ( !((*it2) == (*it)) ) + return FALSE; + return TRUE; + } +#endif + bool operator== ( const TQValueList& l ) const; + bool operator!= ( const TQValueList& l ) const { return !( *this == l ); } + iterator begin() { detach(); return iterator( sh->node->next ); } + const_iterator begin() const { return const_iterator( sh->node->next ); } + const_iterator constBegin() const { return const_iterator( sh->node->next ); } + iterator end() { detach(); return iterator( sh->node ); } + const_iterator end() const { return const_iterator( sh->node ); } + const_iterator constEnd() const { return const_iterator( sh->node ); } + iterator insert( iterator it, const T& x ) { detach(); return sh->insert( it, x ); } + uint remove( const T& x ) { detach(); return sh->remove( x ); } + void clear(); + + // ### 4.0: move out of class + TQValueList& operator<< ( const T& x ) + { + append( x ); + return *this; + } + + size_type size() const { return sh->nodes; } + bool empty() const { return sh->nodes == 0; } + void push_front( const T& x ) { detach(); sh->insert( begin(), x ); } + void push_back( const T& x ) { detach(); sh->insert( end(), x ); } + iterator erase( iterator pos ) { detach(); return sh->remove( pos ); } + iterator erase( iterator first, iterator last ); + reference front() { QT_CHECK_INVALID_LIST_ELEMENT_FATAL; return *begin(); } + const_reference front() const { QT_CHECK_INVALID_LIST_ELEMENT_FATAL; return *begin(); } + reference back() { QT_CHECK_INVALID_LIST_ELEMENT_FATAL; return *(--end()); } + const_reference back() const { QT_CHECK_INVALID_LIST_ELEMENT_FATAL; return *(--end()); } + void pop_front() { QT_CHECK_INVALID_LIST_ELEMENT; erase( begin() ); } + void pop_back() { + QT_CHECK_INVALID_LIST_ELEMENT; + iterator tmp = end(); + erase( --tmp ); + } + void insert( iterator pos, size_type n, const T& x ); + // Some compilers (incl. vc++) would instantiate this function even if + // it is not used; this would constrain TQValueList to classes that provide + // an operator< + /* + void sort() + { + qHeapSort( *this ); + } + */ + + TQValueList operator+ ( const TQValueList& l ) const; + TQValueList& operator+= ( const TQValueList& l ); + + iterator fromLast() { detach(); return iterator( sh->node->prev ); } + const_iterator fromLast() const { return const_iterator( sh->node->prev ); } + + bool isEmpty() const { return ( sh->nodes == 0 ); } + + iterator append( const T& x ) { detach(); return sh->insert( end(), x ); } + iterator prepend( const T& x ) { detach(); return sh->insert( begin(), x ); } + + iterator remove( iterator it ) { detach(); return sh->remove( it ); } + + T& first() { QT_CHECK_INVALID_LIST_ELEMENT; detach(); return sh->node->next->data; } + const T& first() const { QT_CHECK_INVALID_LIST_ELEMENT; return sh->node->next->data; } + T& last() { QT_CHECK_INVALID_LIST_ELEMENT; detach(); return sh->node->prev->data; } + const T& last() const { QT_CHECK_INVALID_LIST_ELEMENT; return sh->node->prev->data; } + + T& operator[] ( size_type i ) { QT_CHECK_INVALID_LIST_ELEMENT; detach(); return sh->at(i)->data; } + const T& operator[] ( size_type i ) const { QT_CHECK_INVALID_LIST_ELEMENT; return sh->at(i)->data; } + iterator at( size_type i ) { QT_CHECK_INVALID_LIST_ELEMENT; detach(); return iterator( sh->at(i) ); } + const_iterator at( size_type i ) const { QT_CHECK_INVALID_LIST_ELEMENT; return const_iterator( sh->at(i) ); } + iterator find ( const T& x ) { detach(); return iterator( sh->find( sh->node->next, x) ); } + const_iterator find ( const T& x ) const { return const_iterator( sh->find( sh->node->next, x) ); } + iterator find ( iterator it, const T& x ) { detach(); return iterator( sh->find( it.node, x ) ); } + const_iterator find ( const_iterator it, const T& x ) const { return const_iterator( sh->find( it.node, x ) ); } + int findIndex( const T& x ) const { return sh->findIndex( sh->node->next, x) ; } + size_type contains( const T& x ) const { return sh->contains( x ); } + + size_type count() const { return sh->nodes; } + + TQValueList& operator+= ( const T& x ) + { + append( x ); + return *this; + } + typedef TQValueListIterator Iterator; + typedef TQValueListConstIterator ConstIterator; + typedef T ValueType; + +protected: + /** + * Helpers + */ + void detach() { if ( sh->count > 1 ) detachInternal(); } + + /** + * Variables + */ + TQValueListPrivate* sh; + +private: + void detachInternal(); + + friend class TQDeepCopy< TQValueList >; +}; + +template +Q_INLINE_TEMPLATES bool TQValueList::operator== ( const TQValueList& l ) const +{ + if ( size() != l.size() ) + return FALSE; + const_iterator it2 = begin(); + const_iterator it = l.begin(); + for( ; it != l.end(); ++it, ++it2 ) + if ( !( *it == *it2 ) ) + return FALSE; + return TRUE; +} + +template +Q_INLINE_TEMPLATES void TQValueList::clear() +{ + if ( sh->count == 1 ) sh->clear(); else { sh->deref(); sh = new TQValueListPrivate; } +} + +template +Q_INLINE_TEMPLATES Q_TYPENAME TQValueList::iterator TQValueList::erase( Q_TYPENAME TQValueList::iterator first, Q_TYPENAME TQValueList::iterator last ) +{ + while ( first != last ) + erase( first++ ); + return last; +} + + +template +Q_INLINE_TEMPLATES void TQValueList::insert( Q_TYPENAME TQValueList::iterator pos, size_type n, const T& x ) +{ + for ( ; n > 0; --n ) + insert( pos, x ); +} + +template +Q_INLINE_TEMPLATES TQValueList TQValueList::operator+ ( const TQValueList& l ) const +{ + TQValueList l2( *this ); + for( const_iterator it = l.begin(); it != l.end(); ++it ) + l2.append( *it ); + return l2; +} + +template +Q_INLINE_TEMPLATES TQValueList& TQValueList::operator+= ( const TQValueList& l ) +{ + TQValueList copy = l; + for( const_iterator it = copy.begin(); it != copy.end(); ++it ) + append( *it ); + return *this; +} + +template +Q_INLINE_TEMPLATES void TQValueList::detachInternal() +{ + sh->deref(); sh = new TQValueListPrivate( *sh ); +} + +#ifndef QT_NO_DATASTREAM +template +Q_INLINE_TEMPLATES TQDataStream& operator>>( TQDataStream& s, TQValueList& l ) +{ + l.clear(); + Q_UINT32 c; + s >> c; + for( Q_UINT32 i = 0; i < c; ++i ) + { + T t; + s >> t; + l.append( t ); + if ( s.atEnd() ) + break; + } + return s; +} + +template +Q_INLINE_TEMPLATES TQDataStream& operator<<( TQDataStream& s, const TQValueList& l ) +{ + s << (Q_UINT32)l.size(); + TQValueListConstIterator it = l.begin(); + for( ; it != l.end(); ++it ) + s << *it; + return s; +} +#endif // QT_NO_DATASTREAM + +#define Q_DEFINED_QVALUELIST +#define Q_DEFINED_QVALUELIST +#include "qwinexport.h" +#endif // TQVALUELIST_H diff --git a/src/tools/qvaluestack.h b/src/tools/qvaluestack.h new file mode 100644 index 000000000..7c2b61078 --- /dev/null +++ b/src/tools/qvaluestack.h @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Definition of TQValueStack class +** +** Created : 990925 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQVALUESTACK_H +#define TQVALUESTACK_H + +#ifndef QT_H +#include "qvaluelist.h" +#endif // QT_H + + +template +class TQValueStack : public TQValueList +{ +public: + TQValueStack() {} + ~TQValueStack() {} + void push( const T& d ) { this->append(d); } + T pop() + { + T elem( this->last() ); + if ( !this->isEmpty() ) + this->remove( this->fromLast() ); + return elem; + } + T& top() { return this->last(); } + const T& top() const { return this->last(); } +}; + +#endif diff --git a/src/tools/qvaluevector.h b/src/tools/qvaluevector.h new file mode 100644 index 000000000..7ec972ce6 --- /dev/null +++ b/src/tools/qvaluevector.h @@ -0,0 +1,577 @@ +/**************************************************************************** +** +** Definition of TQValueVector class +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQVALUEVECTOR_H +#define TQVALUEVECTOR_H + +#include + +#ifndef QT_H +#include "qtl.h" +#include "qshared.h" +#include "qdatastream.h" +#endif // QT_H + +#ifndef QT_NO_STL +#include +#endif + +template +class TQValueVectorPrivate : public TQShared +{ +public: + typedef T value_type; + typedef T* pointer; + + TQValueVectorPrivate() + : start( 0 ), finish( 0 ), end( 0 ) + { + } + + TQValueVectorPrivate( const TQValueVectorPrivate& x ); + TQValueVectorPrivate( size_t size ); + + void derefAndDelete() // work-around for hp-cc + { + if ( deref() ) + delete this; + } + +#if defined(Q_TEMPLATEDLL) + // Workaround MS bug in memory de/allocation in DLL vs. EXE + virtual +#endif + ~TQValueVectorPrivate() + { + delete[] start; + } + + size_t size() const + { + return finish - start; + } + + bool empty() const + { + return start == finish; + } + + size_t capacity() const + { + return end - start; + } + + void insert( pointer pos, const T& x ); + void insert( pointer pos, size_t n, const T& x ); + void reserve( size_t n ); + + void clear() + { + delete[] start; + start = 0; + finish = 0; + end = 0; + } + + + pointer start; + pointer finish; + pointer end; + +private: + pointer growAndCopy( size_t n, pointer s, pointer f ); + + TQValueVectorPrivate& operator=( const TQValueVectorPrivate& x ); + +}; + +template +Q_INLINE_TEMPLATES TQValueVectorPrivate::TQValueVectorPrivate( const TQValueVectorPrivate& x ) + : TQShared() +{ + size_t i = x.size(); + if ( i > 0 ) { + start = new T[ i ]; + finish = start + i; + end = start + i; +#if defined(__xlC__) && __xlC__ < 0x400 // xlC 3.6 confused by const + qCopy( (pointer)x.start, (pointer)x.finish, start ); +#else + qCopy( x.start, x.finish, start ); +#endif + } else { + start = 0; + finish = 0; + end = 0; + } +} + +template +Q_INLINE_TEMPLATES TQValueVectorPrivate::TQValueVectorPrivate( size_t size ) +{ + if ( size > 0 ) { + start = new T[size]; + finish = start + size; + end = start + size; + } else { + start = 0; + finish = 0; + end = 0; + } +} + +template +Q_INLINE_TEMPLATES void TQValueVectorPrivate::insert( pointer pos, const T& x ) +{ + const size_t lastSize = size(); + const size_t n = lastSize !=0 ? 2*lastSize : 1; + const size_t offset = pos - start; + pointer newStart = new T[n]; + pointer newFinish = newStart + offset; + qCopy( start, pos, newStart ); + *newFinish = x; + qCopy( pos, finish, ++newFinish ); + delete[] start; + start = newStart; + finish = newStart + lastSize + 1; + end = newStart + n; +} + +template +Q_INLINE_TEMPLATES void TQValueVectorPrivate::insert( pointer pos, size_t n, const T& x ) +{ + if ( size_t( end - finish ) >= n ) { + // enough room + const size_t elems_after = finish - pos; + pointer old_finish = finish; + if ( elems_after > n ) { + qCopy( finish - n, finish, finish ); + finish += n; + qCopyBackward( pos, old_finish - n, old_finish ); + qFill( pos, pos + n, x ); + } else { + pointer filler = finish; + size_t i = n - elems_after; + for ( ; i > 0; --i, ++filler ) + *filler = x; + finish += n - elems_after; + qCopy( pos, old_finish, finish ); + finish += elems_after; + qFill( pos, old_finish, x ); + } + } else { + // not enough room + const size_t lastSize = size(); + const size_t len = lastSize + TQMAX( lastSize, n ); + pointer newStart = new T[len]; + pointer newFinish = qCopy( start, pos, newStart ); + // fill up inserted space + size_t i = n; + for ( ; i > 0; --i, ++newFinish ) + *newFinish = x; + newFinish = qCopy( pos, finish, newFinish ); + delete[] start; + start = newStart; + finish = newFinish; + end = newStart + len; + } +} + +template +Q_INLINE_TEMPLATES void TQValueVectorPrivate::reserve( size_t n ) +{ + const size_t lastSize = size(); + pointer tmp = growAndCopy( n, start, finish ); + start = tmp; + finish = tmp + lastSize; + end = start + n; +} + +template +Q_INLINE_TEMPLATES Q_TYPENAME TQValueVectorPrivate::pointer TQValueVectorPrivate::growAndCopy( size_t n, pointer s, pointer f ) +{ + pointer newStart = new T[n]; + qCopy( s, f, newStart ); + delete[] start; + return newStart; +} + +template class TQDeepCopy; + +template +class TQValueVector +{ +public: + typedef T value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type* iterator; + typedef const value_type* const_iterator; + typedef value_type& reference; + typedef const value_type& const_reference; + typedef size_t size_type; +#ifndef QT_NO_STL + typedef ptrdiff_t difference_type; +#else + typedef int difference_type; +#endif + + TQValueVector() + { + sh = new TQValueVectorPrivate; + } + + TQValueVector( const TQValueVector& v ) + { + sh = v.sh; + sh->ref(); + } + + TQValueVector( size_type n, const T& val = T() ); + +#ifndef QT_NO_STL + TQValueVector( std::vector& v ) // ### remove in 4.0 + { + sh = new TQValueVectorPrivate( v.size() ); + qCopy( v.begin(), v.end(), begin() ); + } + + TQValueVector( const std::vector& v ) + { + sh = new TQValueVectorPrivate( v.size() ); + qCopy( v.begin(), v.end(), begin() ); + } +#endif + + ~TQValueVector() + { + sh->derefAndDelete(); + } + + TQValueVector& operator= ( const TQValueVector& v ) + { + v.sh->ref(); + sh->derefAndDelete(); + sh = v.sh; + return *this; + } + +#ifndef QT_NO_STL + TQValueVector& operator= ( const std::vector& v ) + { + clear(); + resize( v.size() ); + qCopy( v.begin(), v.end(), begin() ); + return *this; + } +#endif + + size_type size() const { return sh->size(); } + + bool empty() const { return sh->empty(); } + + size_type capacity() const + { + return size_type( sh->capacity() ); + } + + iterator begin() + { + detach(); + return sh->start; + } + + const_iterator begin() const + { + return sh->start; + } + + const_iterator constBegin() const + { + return sh->start; + } + + iterator end() + { + detach(); + return sh->finish; + } + + const_iterator end() const + { + return sh->finish; + } + + const_iterator constEnd() const + { + return sh->finish; + } + + reference at( size_type i, bool* ok = 0 ) + { + detach(); + if ( ok ) + *ok = ( i < size() ); + return *( begin() + i ); + } + + const_reference at( size_type i, bool* ok = 0 ) const + { + if ( ok ) + *ok = ( i < size() ); + return *( begin() + i ); + } + + reference operator[]( size_type i ) + { + detach(); + return *( begin() + i ); + } + + const_reference operator[]( size_type i ) const + { + return *( begin() + i ); + } + + reference front() + { + Q_ASSERT( !empty() ); + detach(); + return *begin(); + } + + const_reference front() const + { + Q_ASSERT( !empty() ); + return *begin(); + } + + reference back() + { + Q_ASSERT( !empty() ); + detach(); + return *( end() - 1 ); + } + + const_reference back() const + { + Q_ASSERT( !empty() ); + return *( end() - 1 ); + } + + void push_back( const T& x ) + { + detach(); + if ( sh->finish == sh->end ) { + sh->reserve( size()+size()/2+1 ); + } + *sh->finish = x; + ++sh->finish; + } + + void pop_back() + { + detach(); + if ( empty() ) + return; + --sh->finish; + } + + iterator insert( iterator pos, const T& x ); + iterator insert( iterator pos, size_type n, const T& x ); + + void reserve( size_type n ) + { + if ( capacity() < n ) { + detach(); + sh->reserve( n ); + } + } + + void resize( size_type n, const T& val = T() ) + { + if ( n < size() ) + erase( begin() + n, end() ); + else + insert( end(), n - size(), val ); + } + + void clear() + { + detach(); + sh->clear(); + } + + iterator erase( iterator pos ) + { + detach(); + if ( pos + 1 != end() ) + qCopy( pos + 1, sh->finish, pos ); + --sh->finish; + return pos; + } + + iterator erase( iterator first, iterator last ) + { + detach(); + qCopy( last, sh->finish, first ); + sh->finish = sh->finish - ( last - first ); + return first; + } + + // ### remove in TQt 4.0 + bool operator==( const TQValueVector& x ) + { + return size()==x.size() ? qEqual( constBegin(), constEnd(), x.begin()) : FALSE; + } + + bool operator==( const TQValueVector& x ) const + { + return size()==x.size() ? qEqual( begin(), end(), x.begin() ) : FALSE; + } + + typedef T ValueType; + typedef ValueType *Iterator; + typedef const ValueType *ConstIterator; + + size_type count() const { return size(); } + bool isEmpty() const { return empty(); } + + reference first() { return front(); } + const_reference first() const { return front(); } + reference last() { return back(); } + const_reference last() const { return back(); } + void append( const T& x ) { push_back( x ); } + +protected: + void detach() + { + if ( sh->count > 1 ) { detachInternal(); } + } + void detachInternal(); + TQValueVectorPrivate* sh; + +private: + friend class TQDeepCopy< TQValueVector >; +}; + +template +Q_INLINE_TEMPLATES TQValueVector::TQValueVector( size_type n, const T& val ) +{ + sh = new TQValueVectorPrivate( n ); + qFill( begin(), end(), val ); +} + +template +Q_INLINE_TEMPLATES void TQValueVector::detachInternal() +{ + sh->deref(); + sh = new TQValueVectorPrivate( *sh ); +} + +template +Q_INLINE_TEMPLATES Q_TYPENAME TQValueVector::iterator TQValueVector::insert( iterator pos, const T& x ) +{ + size_type offset = pos - sh->start; + detach(); + if ( pos == end() ) { + if ( sh->finish == sh->end ) + push_back( x ); + else { + *sh->finish = x; + ++sh->finish; + } + } else { + if ( sh->finish == sh->end ) { + sh->insert( pos, x ); + } else { + *sh->finish = *(sh->finish - 1); + ++sh->finish; + qCopyBackward( pos, sh->finish - 2, sh->finish - 1 ); + *pos = x; + } + } + return begin() + offset; +} + +template +Q_INLINE_TEMPLATES Q_TYPENAME TQValueVector::iterator TQValueVector::insert( iterator pos, size_type n, const T& x ) +{ + if ( n != 0 ) { + size_type offset = pos - sh->start; + detach(); + pos = begin() + offset; + sh->insert( pos, n, x ); + } + return pos; +} + + +#ifndef QT_NO_DATASTREAM +template +Q_INLINE_TEMPLATES TQDataStream& operator>>( TQDataStream& s, TQValueVector& v ) +{ + v.clear(); + Q_UINT32 c; + s >> c; + v.resize( c ); + for( Q_UINT32 i = 0; i < c; ++i ) + { + T t; + s >> t; + v[i] = t; + } + return s; +} + +template +Q_INLINE_TEMPLATES TQDataStream& operator<<( TQDataStream& s, const TQValueVector& v ) +{ + s << (Q_UINT32)v.size(); + // ### use typename TQValueVector::const_iterator once all supported + // ### compilers know about the 'typename' keyword. + const T* it = v.begin(); + for( ; it != v.end(); ++it ) + s << *it; + return s; +} +#endif // QT_NO_DATASTREAM + +#define Q_DEFINED_QVALUEVECTOR +#include "qwinexport.h" +#endif // TQVALUEVECTOR_H diff --git a/src/tools/qwaitcondition.h b/src/tools/qwaitcondition.h new file mode 100644 index 000000000..1bdb1c1e0 --- /dev/null +++ b/src/tools/qwaitcondition.h @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Definition of TQWaitCondition class +** +** Created : 931107 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQWAITCONDITION_H +#define TQWAITCONDITION_H + +#ifndef QT_H +#include "qglobal.h" +#endif // QT_H + +#if defined(QT_THREAD_SUPPORT) + +#include + +class TQWaitConditionPrivate; +class TQMutex; + +class Q_EXPORT TQWaitCondition +{ +public: + TQWaitCondition(); + virtual ~TQWaitCondition(); + + // default argument causes thread to block indefinately + bool wait( unsigned long time = ULONG_MAX ); + bool wait( TQMutex *mutex, unsigned long time = ULONG_MAX ); + + void wakeOne(); + void wakeAll(); + +private: + TQWaitConditionPrivate * d; + +#if defined(Q_DISABLE_COPY) + TQWaitCondition( const TQWaitCondition & ); + TQWaitCondition &operator=( const TQWaitCondition & ); +#endif +}; + +#endif + +#endif diff --git a/src/tools/qwaitcondition_unix.cpp b/src/tools/qwaitcondition_unix.cpp new file mode 100644 index 000000000..e3becc54e --- /dev/null +++ b/src/tools/qwaitcondition_unix.cpp @@ -0,0 +1,316 @@ +/**************************************************************************** +** +** TQWaitCondition class for Unix +** +** Created : 20010725 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#if defined(QT_THREAD_SUPPORT) + +#include "qplatformdefs.h" + +typedef pthread_mutex_t Q_MUTEX_T; + +#include "qwaitcondition.h" +#include "qmutex.h" +#include "qmutex_p.h" + +#include +#include + + +struct TQWaitConditionPrivate { + pthread_cond_t cond; +}; + + +/*! + \class TQWaitCondition qwaitcondition.h + \threadsafe + \brief The TQWaitCondition class allows waiting/waking for conditions between threads. + + \ingroup thread + \ingroup environment + + TQWaitConditions allow a thread to tell other threads that some + sort of condition has been met; one or many threads can block + waiting for a TQWaitCondition to set a condition with wakeOne() or + wakeAll(). Use wakeOne() to wake one randomly selected event or + wakeAll() to wake them all. For example, say we have three tasks + that should be performed every time the user presses a key; each + task could be split into a thread, each of which would have a + run() body like this: + + \code + TQWaitCondition key_pressed; + + for (;;) { + key_pressed.wait(); // This is a TQWaitCondition global variable + // Key was pressed, do something interesting + do_something(); + } + \endcode + + A fourth thread would read key presses and wake the other three + threads up every time it receives one, like this: + + \code + TQWaitCondition key_pressed; + + for (;;) { + getchar(); + // Causes any thread in key_pressed.wait() to return from + // that method and continue processing + key_pressed.wakeAll(); + } + \endcode + + Note that the order the three threads are woken up in is + undefined, and that if some or all of the threads are still in + do_something() when the key is pressed, they won't be woken up + (since they're not waiting on the condition variable) and so the + task will not be performed for that key press. This can be + avoided by, for example, doing something like this: + + \code + TQMutex mymutex; + TQWaitCondition key_pressed; + int mycount=0; + + // Worker thread code + for (;;) { + key_pressed.wait(); // This is a TQWaitCondition global variable + mymutex.lock(); + mycount++; + mymutex.unlock(); + do_something(); + mymutex.lock(); + mycount--; + mymutex.unlock(); + } + + // Key reading thread code + for (;;) { + getchar(); + mymutex.lock(); + // Sleep until there are no busy worker threads + while( mycount > 0 ) { + mymutex.unlock(); + sleep( 1 ); + mymutex.lock(); + } + mymutex.unlock(); + key_pressed.wakeAll(); + } + \endcode + + The mutexes are necessary because the results of two threads + attempting to change the value of the same variable simultaneously + are unpredictable. +*/ + +/*! + Constructs a new event signalling, i.e. wait condition, object. +*/ +TQWaitCondition::TQWaitCondition() +{ + d = new TQWaitConditionPrivate; + + int ret = pthread_cond_init(&d->cond, NULL); + +#ifdef QT_CHECK_RANGE + if (ret) + qWarning( "Wait condition init failure: %s", strerror( ret ) ); +#endif +} + + +/*! + Deletes the event signalling, i.e. wait condition, object. +*/ +TQWaitCondition::~TQWaitCondition() +{ + int ret = pthread_cond_destroy(&d->cond); + + if (ret) { +#ifdef QT_CHECK_RANGE + qWarning( "Wait condition destroy failure: %s", strerror( ret ) ); +#endif + + // seems we have threads waiting on us, lets wake them up + pthread_cond_broadcast(&d->cond); + } + + delete d; +} + +/*! + This wakes one thread waiting on the TQWaitCondition. The thread + that is woken up depends on the operating system's scheduling + policies, and cannot be controlled or predicted. + + \sa wakeAll() +*/ +void TQWaitCondition::wakeOne() +{ + int ret = pthread_cond_signal(&d->cond); + +#ifdef QT_CHECK_RANGE + if (ret) + qWarning("Wait condition wakeOne failure: %s", strerror(ret)); +#endif +} + +/*! + This wakes all threads waiting on the TQWaitCondition. The order in + which the threads are woken up depends on the operating system's + scheduling policies, and cannot be controlled or predicted. + + \sa wakeOne() +*/ +void TQWaitCondition::wakeAll() +{ + int ret = pthread_cond_broadcast(&d->cond); + +#ifdef QT_CHECK_RANGE + if (ret) + qWarning("Wait condition wakeAll failure: %s", strerror(ret)); +#endif +} + +/*! + Wait on the thread event object. The thread calling this will + block until either of these conditions is met: + \list + \i Another thread signals it using wakeOne() or wakeAll(). This + function will return TRUE in this case. + \i \a time milliseconds has elapsed. If \a time is ULONG_MAX (the + default), then the wait will never timeout (the event must be + signalled). This function will return FALSE if the wait timed + out. + \endlist + + \sa wakeOne(), wakeAll() +*/ +bool TQWaitCondition::wait(unsigned long time) +{ + static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; + pthread_mutex_lock( &mutex ); + + int ret; + if (time != ULONG_MAX) { + struct timeval tv; + gettimeofday(&tv, 0); + + timespec ti; + ti.tv_nsec = ( tv.tv_usec + ( time % 1000 ) * 1000 ) * 1000; + ti.tv_sec = tv.tv_sec + (time / 1000) + ( ti.tv_nsec / 1000000000 ); + ti.tv_nsec %= 1000000000; + + ret = pthread_cond_timedwait(&d->cond, &mutex, &ti); + } else + ret = pthread_cond_wait(&d->cond, &mutex); + +#ifdef QT_CHECK_RANGE + if (ret && ret != ETIMEDOUT) + qWarning("Wait condition wait failure: %s",strerror(ret)); +#endif + + pthread_mutex_unlock( &mutex ); + + return (ret == 0); +} + +/*! + \overload + + Release the locked \a mutex and wait on the thread event object. + The \a mutex must be initially locked by the calling thread. If \a + mutex is not in a locked state, this function returns immediately. + If \a mutex is a recursive mutex, this function returns + immediately. The \a mutex will be unlocked, and the calling thread + will block until either of these conditions is met: + \list + \i Another thread signals it using wakeOne() or wakeAll(). This + function will return TRUE in this case. + \i \a time milliseconds has elapsed. If \a time is ULONG_MAX (the + default), then the wait will never timeout (the event must be + signalled). This function will return FALSE if the wait timed + out. + \endlist + + The mutex will be returned to the same locked state. This function + is provided to allow the atomic transition from the locked state + to the wait state. + + \sa wakeOne(), wakeAll() +*/ +bool TQWaitCondition::wait(TQMutex *mutex, unsigned long time) +{ + if (! mutex) + return FALSE; + + if (mutex->d->type() == Q_MUTEX_RECURSIVE) { +#ifdef QT_CHECK_RANGE + qWarning("Wait condition warning: using recursive mutexes with\n" + " wait conditions is undefined!"); +#endif + return FALSE; + } + + int ret; + if (time != ULONG_MAX) { + struct timeval tv; + gettimeofday(&tv, 0); + + timespec ti; + ti.tv_nsec = ( tv.tv_usec + ( time % 1000 ) * 1000 ) * 1000; + ti.tv_sec = tv.tv_sec + (time / 1000) + ( ti.tv_nsec / 1000000000 ); + ti.tv_nsec %= 1000000000; + + ret = pthread_cond_timedwait(&d->cond, &mutex->d->handle, &ti); + } else + ret = pthread_cond_wait(&d->cond, &mutex->d->handle); + +#ifdef QT_CHECK_RANGE + if (ret && ret != ETIMEDOUT) + qWarning("Wait condition wait failure: %s",strerror(ret)); +#endif + + return (ret == 0); +} + +#endif // QT_THREAD_SUPPORT diff --git a/src/tools/qwinexport.cpp b/src/tools/qwinexport.cpp new file mode 100644 index 000000000..99126c92e --- /dev/null +++ b/src/tools/qwinexport.cpp @@ -0,0 +1,31 @@ +#define Q_EXPORT_TEMPLATES + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include diff --git a/src/tools/qwinexport.h b/src/tools/qwinexport.h new file mode 100644 index 000000000..28856063e --- /dev/null +++ b/src/tools/qwinexport.h @@ -0,0 +1,224 @@ +/**************************************************************************** +** +** Global type declarations and definitions +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the tools module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#if defined(Q_TEMPLATEDLL) && ( !defined(Q_CC_BOR) || !defined(QT_MAKEDLL) || defined(Q_EXPORT_TEMPLATES) ) +// MOC_SKIP_BEGIN + +#if defined(Q_DEFINED_QASCIIDICT) && defined(Q_DEFINED_QCONNECTION_LIST) && !defined(Q_EXPORTED_QASCIIDICT_TEMPLATES) +#define Q_EXPORTED_QASCIIDICT_TEMPLATES +Q_TEMPLATE_EXTERN template class Q_EXPORT TQAsciiDictIterator; +Q_TEMPLATE_EXTERN template class Q_EXPORT TQAsciiDict; +#endif + +#if defined(Q_DEFINED_QSTYLESHEET) && defined(Q_DEFINED_QDICT) && !defined(Q_EXPORTED_QSTYLESHEET_TEMPLATES) +#define Q_EXPORTED_QSTYLESHEET_TEMPLATES +Q_TEMPLATE_EXTERN template class Q_EXPORT TQDict; +#endif + +#if defined(Q_DEFINED_QLIBRARY) && defined(Q_DEFINED_QDICT) && !defined(Q_EXPORTED_QDICTLIBRARY_TEMPLATES) +#define Q_EXPORTED_QDICTLIBRARY_TEMPLATES +Q_TEMPLATE_EXTERN template class Q_EXPORT TQDict; // for TQtopia +#endif + +#if defined(Q_DEFINED_QGUARDEDPTR) && defined(Q_DEFINED_QOBJECT) && !defined(Q_EXPORTED_QGUARDEDPTROBJECT_TEMPLATES) +#define Q_EXPORTED_QGUARDEDPTROBJECT_TEMPLATES +Q_TEMPLATE_EXTERN template class Q_EXPORT TQGuardedPtr; +#endif + +// needed for TQtopia +#if defined(Q_DEFINED_QGUARDEDPTR) && defined(Q_DEFINED_QWIDGET) && !defined(Q_EXPORTED_QGUARDEDPTRTQWIDGET_TEMPLATES) +#define Q_EXPORTED_QGUARDEDPTRTQWIDGET_TEMPLATES +Q_TEMPLATE_EXTERN template class Q_EXPORT TQGuardedPtr; +#endif + +#if defined(Q_DEFINED_QGUARDEDPTR) && defined(Q_DEFINED_QACCESSIBLE_OBJECT) && !defined(Q_EXPORTED_QACCESSIBLEOBJECT_TEMPLATES) +#define Q_EXPORTED_QACCESSIBLEOBJECT_TEMPLATES +Q_TEMPLATE_EXTERN template class Q_EXPORT TQGuardedPtr; +#endif + +#if defined(Q_DEFINED_QINTDICT) && !defined(Q_EXPORTED_QINTDICT_TEMPLATES) +#define Q_EXPORTED_QINTDICT_TEMPLATES +Q_TEMPLATE_EXTERN template class Q_EXPORT TQIntDict; +#endif + +#if defined(Q_DEFINED_QINTDICT) && defined(Q_DEFINED_QWIDGET) && !defined(Q_EXPORTED__TEMPLATES) +#define Q_EXPORTED__TEMPLATES +Q_TEMPLATE_EXTERN template class Q_EXPORT TQIntDictIterator; +Q_TEMPLATE_EXTERN template class Q_EXPORT TQIntDict; +#endif + +#if defined(Q_DEFINED_QMAP) && !defined(Q_EXPORTED_QMAPBASIC_TEMPLATES) +#define Q_EXPORTED_QMAPBASIC_TEMPLATES +Q_TEMPLATE_EXTERN template class Q_EXPORT TQMap; // for TQtopia +Q_TEMPLATE_EXTERN template class Q_EXPORT TQMap; // for TQtopia +#endif + +#if defined(Q_DEFINED_QMAP) && defined(Q_DEFINED_QSTRING) && !defined(Q_EXPORTED_QMAPTQSTRING_TEMPLATES) +#define Q_EXPORTED_QMAPTQSTRING_TEMPLATES +Q_TEMPLATE_EXTERN template class Q_EXPORT TQMap; +Q_TEMPLATE_EXTERN template class Q_EXPORT TQMap; // for TQtopia +Q_TEMPLATE_EXTERN template class Q_EXPORT TQMap; // for TQtopia +#endif + +#if defined(Q_DEFINED_QMEMARRAY) && !defined(Q_EXPORTED_QMEMARRAY_BASIC_TEMPLATES) +#define Q_EXPORTED_QMEMARRAY_BASIC_TEMPLATES +Q_TEMPLATE_EXTERN template class Q_EXPORT TQMemArray; +Q_TEMPLATE_EXTERN template class Q_EXPORT TQMemArray; +Q_TEMPLATE_EXTERN template class Q_EXPORT TQMemArray; +#endif + +#if defined(Q_DEFINED_QMEMARRAY) && defined(Q_DEFINED_QPOINT) && !defined(Q_EXPORTED_QMEMARAYPOINT_TEMPLATES) +#define Q_EXPORTED_QMEMARAYPOINT_TEMPLATES +Q_TEMPLATE_EXTERN template class Q_EXPORT TQMemArray; +#endif + +#if defined(Q_DEFINED_QPTRLIST) && !defined(Q_EXPORTED_QPTRLIST_BASIC_TEMPLATES) +#define Q_EXPORTED_QPTRLIST_BASIC_TEMPLATES +Q_TEMPLATE_EXTERN template class Q_EXPORT TQPtrListIterator; +Q_TEMPLATE_EXTERN template class Q_EXPORT TQPtrList; +#endif + +#if defined(Q_DEFINED_QPTRLIST) && defined(Q_DEFINED_QWIDGET) && !defined(Q_EXPORTED_QPTRLISTWIDGET_TEMPLATES) +#define Q_EXPORTED_QPTRLISTWIDGET_TEMPLATES +Q_TEMPLATE_EXTERN template class Q_EXPORT TQPtrListIterator; +Q_TEMPLATE_EXTERN template class Q_EXPORT TQPtrList; +#endif + +#if defined(Q_DEFINED_QPTRLIST) && defined(Q_DEFINED_QCONNECTION) && !defined(Q_EXPORTED_QPTRLISTCONNECTION_TEMPLATES) +#define Q_EXPORTED_QPTRLISTCONNECTION_TEMPLATES +Q_TEMPLATE_EXTERN template class Q_EXPORT TQPtrListIterator; +Q_TEMPLATE_EXTERN template class Q_EXPORT TQPtrList; +#endif + +#if defined(Q_DEFINED_QPTRLIST) && defined(Q_DEFINED_QOBJECT) && !defined(Q_EXPORTED_QPTRLISTOBJECT_TEMPLATES) +#define Q_EXPORTED_QPTRLISTOBJECT_TEMPLATES +Q_TEMPLATE_EXTERN template class Q_EXPORT TQPtrListIterator; +Q_TEMPLATE_EXTERN template class Q_EXPORT TQPtrList; +#endif + +#if defined(Q_DEFINED_QPTRLIST) && defined(Q_DEFINED_QDOCKWINDOW) && !defined(Q_EXPORTED_QPTRLISTDOCWINDOW_TEMPLATES) +#define Q_EXPORTED_QPTRLISTDOCWINDOW_TEMPLATES +Q_TEMPLATE_EXTERN template class Q_EXPORT TQPtrListIterator; +Q_TEMPLATE_EXTERN template class Q_EXPORT TQPtrList; +#endif + +#if defined(Q_DEFINED_QPTRVECTOR) && !defined(Q_EXPORTED_QPTRVECTOR_BASIC_TEMPLATES) +#define Q_EXPORTED_QPTRVECTOR_BASIC_TEMPLATES +Q_TEMPLATE_EXTERN template class Q_EXPORT TQPtrVector; +#endif + +#if defined(Q_DEFINED_QPTRVECTOR) && defined(Q_DEFINED_QSTYLESHEET) && !defined(Q_EXPORTED_QPTRVECTORSTYLESHEETITEM_TEMPLATES) +#define Q_EXPORTED_QPTRVECTORSTYLESHEETITEM_TEMPLATES +Q_TEMPLATE_EXTERN template class Q_EXPORT TQPtrVector; +#endif + +#if defined(Q_DEFINED_QPTRVECTOR) && defined(Q_DEFINED_QWIDGET) && !defined(Q_EXPORTED_QPTRVECTORWIDGET_TEMPLATES) +#define Q_EXPORTED_QPTRVECTORWIDGET_TEMPLATES +Q_TEMPLATE_EXTERN template class Q_EXPORT TQPtrVector; +#endif + +#if defined(Q_DEFINED_QPTRVECTOR) && defined(Q_DEFINED_QCONNECTION_LIST) && !defined(Q_EXPORTED_QPTRVECTORCONNECTTIONLIST_TEMPLATES) +#define Q_EXPORTED_QPTRVECTORCONNECTTIONLIST_TEMPLATES +Q_TEMPLATE_EXTERN template class Q_EXPORT TQPtrVector; +#endif + +#if defined(Q_DEFINED_QVALUELIST) && !defined(Q_EXPORTED_QVALUELIST_BASIC_TEMPLATES) +#define Q_EXPORTED_QVALUELIST_BASIC_TEMPLATES +Q_TEMPLATE_EXTERN template class Q_EXPORT TQValueListIterator; +Q_TEMPLATE_EXTERN template class Q_EXPORT TQValueList; +Q_TEMPLATE_EXTERN template class Q_EXPORT TQValueListIterator; +Q_TEMPLATE_EXTERN template class Q_EXPORT TQValueList; +#endif + +#if defined(Q_DEFINED_QVALUELIST) && defined(Q_DEFINED_QRECT) && !defined(Q_EXPORTED_QVALUELISTRECT_TEMPLATES) +#define Q_EXPORTED_QVALUELISTRECT_TEMPLATES +Q_TEMPLATE_EXTERN template class Q_EXPORT TQValueListIterator; +Q_TEMPLATE_EXTERN template class Q_EXPORT TQValueList; +#endif + +#if defined(Q_DEFINED_QVALUELIST) && defined(Q_DEFINED_QSTRING) && !defined(Q_EXPORTED_QVALUELISTSTRING_TEMPLATES) +#define Q_EXPORTED_QVALUELISTSTRING_TEMPLATES +Q_TEMPLATE_EXTERN template class Q_EXPORT TQValueListIterator; +Q_TEMPLATE_EXTERN template class Q_EXPORT TQValueList; +#endif + +// TQStylesheet template exports +#if defined(Q_DEFINED_QVALUELIST) && defined(Q_DEFINED_QPTRVECTOR) && defined(Q_DEFINED_QSTYLESHEET) && !defined(Q_EXPORTED_QSTYLESHEETITEM1_TEMPLATES) +#define Q_EXPORTED_QSTYLESHEETITEM1_TEMPLATES +Q_TEMPLATE_EXTERN template class Q_EXPORT TQValueList< TQPtrVector< TQStyleSheetItem> >; +#endif + +#if defined(Q_DEFINED_QVALUELIST) && defined(Q_DEFINED_QSTYLESHEET) && !defined(Q_EXPORTED_QSTYLESHEETITEM2_TEMPLATES) +#define Q_EXPORTED_QSTYLESHEETITEM2_TEMPLATES +Q_TEMPLATE_EXTERN template class Q_EXPORT TQValueList; +#endif + +// qcanvas template exports +#if defined(Q_DEFINED_QPTRLIST) && defined(Q_DEFINED_QCANVAS) && !defined(Q_EXPORTED_QCANVAS1_TEMPLATES) +#define Q_EXPORTED_QCANVAS1_TEMPLATES +TQM_TEMPLATE_EXTERN_CANVAS template class TQM_EXPORT_CANVAS TQPtrListIterator< TQCanvasItem >; +TQM_TEMPLATE_EXTERN_CANVAS template class TQM_EXPORT_CANVAS TQPtrList< TQCanvasItem >; +TQM_TEMPLATE_EXTERN_CANVAS template class TQM_EXPORT_CANVAS TQPtrListIterator< TQCanvasView >; +TQM_TEMPLATE_EXTERN_CANVAS template class TQM_EXPORT_CANVAS TQPtrList< TQCanvasView >; +#endif + +// qtable template exports +#if defined(Q_DEFINED_QPTRLIST) && defined(Q_DEFINED_QTABLE_SELECTION) && !defined(Q_EXPORTED_QTABLESELECTION_TEMPLATES) +#define Q_EXPORTED_QTABLESELECTION_TEMPLATES +TQM_TEMPLATE_EXTERN_TABLE template class TQM_EXPORT_TABLE TQPtrList; +#endif + +#if defined(Q_DEFINED_QTABLE_ITEM) && defined(Q_DEFINED_QPTRVECTOR) && !defined(Q_EXPORTED_QTABLEITEM_TEMPLATES) +#define Q_EXPORTED_QTABLEITEM_TEMPLATES +TQM_TEMPLATE_EXTERN_TABLE template class TQM_EXPORT_TABLE TQPtrVector; +#endif + +#if defined(Q_DEFINED_QTABLE) && defined(Q_DEFINED_QPTRVECTOR) +//Q_TEMPLATE_EXTERN template class Q_EXPORT TQPtrVector; +#endif + +// qsqlextension template exports +#if defined(Q_DEFINED_QSQLEXTENSION) && defined(Q_DEFINED_QMAP) && defined(Q_DEFINED_QVALUEVECTOR) && defined(Q_DEFINED_QSTRING) && !defined(Q_EXPORTED_QSQLEXTENSION_TEMPLATES) +#define Q_EXPORTED_QSQLEXTENSION_TEMPLATES +TQM_TEMPLATE_EXTERN_SQL template class TQM_EXPORT_SQL TQMap; +TQM_TEMPLATE_EXTERN_SQL template class TQM_EXPORT_SQL TQValueVector; +#endif + + +// MOC_SKIP_END +#endif // template defined -- cgit v1.2.1