home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_qt.idb / usr / freeware / include / Qt / qstrvec.h.z / qstrvec.h
Encoding:
C/C++ Source or Header  |  1998-10-28  |  2.0 KB  |  75 lines

  1. /****************************************************************************
  2. ** $Id: qstrvec.h,v 2.5 1998/07/03 00:09:47 hanord Exp $
  3. **
  4. ** Definition of QStrVec and QStrIVec classes
  5. **
  6. ** Created : 931203
  7. **
  8. ** Copyright (C) 1992-1998 Troll Tech AS.  All rights reserved.
  9. **
  10. ** This file is part of Qt Free Edition, version 1.40.
  11. **
  12. ** See the file LICENSE included in the distribution for the usage
  13. ** and distribution terms, or http://www.troll.no/free-license.html.
  14. **
  15. ** IMPORTANT NOTE: You may NOT copy this file or any part of it into
  16. ** your own programs or libraries.
  17. **
  18. ** Please see http://www.troll.no/pricing.html for information about 
  19. ** Qt Professional Edition, which is this same library but with a
  20. ** license which allows creation of commercial/proprietary software.
  21. **
  22. *****************************************************************************/
  23.  
  24. #ifndef QSTRVEC_H
  25. #define QSTRVEC_H
  26.  
  27. #ifndef QT_H
  28. #include "qstring.h"
  29. #include "qvector.h"
  30. #include "qdatastream.h"
  31. #endif // QT_H
  32.  
  33.  
  34. #if defined(DEFAULT_TEMPLATECLASS)
  35. typedef QVectorT<char>            QStrVecBase;
  36. #else
  37. typedef Q_DECLARE(QVectorM,char)        QStrVecBase;
  38. #endif
  39.  
  40.  
  41. class QStrVec : public QStrVecBase
  42. {
  43. public:
  44.     QStrVec()  { dc = TRUE; }
  45.     QStrVec( uint size, bool deepc = TRUE ) : QStrVecBase(size) {dc=deepc;}
  46.    ~QStrVec()  { clear(); }
  47. private:
  48.     GCI     newItem( GCI d )    { return dc ? qstrdup( (const char*)d ) : d; }
  49.     void deleteItem( GCI d )    { if ( dc ) delete[] (char*)d; }
  50.     int     compareItems( GCI s1, GCI s2 )
  51.                 { return strcmp((const char*)s1,
  52.                         (const char*)s2); }
  53.     QDataStream &read( QDataStream &s, GCI &d )
  54.                 { s >> (char *&)d; return s; }
  55.     QDataStream &write( QDataStream &s, GCI d ) const
  56.                 { return s << (const char *)d; }
  57.     bool dc;
  58. };
  59.  
  60.  
  61. class QStrIVec : public QStrVec            // case insensitive string vec
  62. {
  63. public:
  64.     QStrIVec() {}
  65.     QStrIVec( uint size, bool dc = TRUE ) : QStrVec( size, dc ) {}
  66.    ~QStrIVec() { clear(); }
  67. private:
  68.     int     compareItems( GCI s1, GCI s2 )
  69.                 { return stricmp((const char*)s1,
  70.                          (const char*)s2); }
  71. };
  72.  
  73.  
  74. #endif // QSTRVEC_H
  75.