Public Member Functions | Private Member Functions | Private Attributes | List of all members
QStrVec Class Reference

#include <qstrvec.h>

Inheritance diagram for QStrVec:
QVector< type > QGVector QCollection QStrIVec

Public Member Functions

 QStrVec ()
 
 QStrVec (uint size, bool deepc=TRUE)
 
 ~QStrVec ()
 
- Public Member Functions inherited from QVector< type >
 QVector ()
 
 QVector (uint size)
 
 QVector (const QVector< type > &v)
 
 ~QVector ()
 
QVector< type > & operator= (const QVector< type > &v)
 
type ** data () const
 
uint size () const
 
uint count () const
 
bool isEmpty () const
 
bool isNull () const
 
bool resize (uint size)
 
bool insert (uint i, const type *d)
 
bool remove (uint i)
 
typetake (uint i)
 
void clear ()
 
bool fill (const type *d, int size=-1)
 
void sort ()
 
int bsearch (const type *d) const
 
int findRef (const type *d, uint i=0) const
 
int find (const type *d, uint i=0) const
 
uint containsRef (const type *d) const
 
uint contains (const type *d) const
 
typeoperator[] (int i) const
 
typeat (uint i) const
 
void toList (QGList *list) const
 
- Public Member Functions inherited from QGVector
QDataStreamread (QDataStream &)
 
QDataStreamwrite (QDataStream &) const
 
- Public Member Functions inherited from QCollection
bool autoDelete () const
 
void setAutoDelete (bool enable)
 

Private Member Functions

Item newItem (Item d)
 
void deleteItem (Item d)
 
int compareItems (Item s1, Item s2)
 
QDataStreamread (QDataStream &s, Item &d)
 
QDataStreamwrite (QDataStream &s, Item d) const
 

Private Attributes

bool dc
 

Additional Inherited Members

- Public Types inherited from QCollection
typedef void * Item
 
- Protected Member Functions inherited from QGVector
 QGVector ()
 
 QGVector (uint size)
 
 QGVector (const QGVector &v)
 
 ~QGVector ()
 
QGVectoroperator= (const QGVector &v)
 
Itemdata () const
 
uint size () const
 
bool insert (uint index, Item)
 
bool remove (uint index)
 
Item take (uint index)
 
bool resize (uint newsize)
 
bool fill (Item, int flen)
 
void sort ()
 
int bsearch (Item) const
 
int findRef (Item, uint index) const
 
int find (Item, uint index) const
 
uint containsRef (Item) const
 
uint contains (Item) const
 
Item at (uint index) const
 
bool insertExpand (uint index, Item)
 
void toList (QGList *) const
 
- Protected Member Functions inherited from QCollection
 QCollection ()
 
 QCollection (const QCollection &)
 
virtual ~QCollection ()
 
- Protected Attributes inherited from QCollection
bool del_item
 

Detailed Description

Definition at line 55 of file qstrvec.h.

Constructor & Destructor Documentation

QStrVec::QStrVec ( )
inline

Definition at line 58 of file qstrvec.h.

58 { dc = TRUE; }
bool dc
Definition: qstrvec.h:73
const bool TRUE
Definition: qglobal.h:371
QStrVec::QStrVec ( uint  size,
bool  deepc = TRUE 
)
inline

Definition at line 59 of file qstrvec.h.

59 : QStrVecBase(size) {dc=deepc;}
QVector< char > QStrVecBase
Definition: qstrvec.h:52
bool dc
Definition: qstrvec.h:73
uint size() const
Definition: qvector.h:56
QStrVec::~QStrVec ( )
inline

Definition at line 60 of file qstrvec.h.

60 { clear(); }
void clear()
Definition: qvector.h:64

Member Function Documentation

int QStrVec::compareItems ( Item  d1,
Item  d2 
)
inlineprivatevirtual

This virtual function compares two list items.

Returns:

  • 0 if item1 == item2
  • non-zero if item1 != item2

This function returns int rather than bool so that reimplementations can return one of three values and use it to sort by:

  • 0 if item1 == item2
  • > 0 (positive integer) if item1 > item2
  • < 0 (negative integer) if item1 < item2

The QVector::sort() and QVector::bsearch() functions require that compareItems() is implemented as described here.

This function should not modify the vector because some const functions call compareItems().

Reimplemented from QGVector.

Reimplemented in QStrIVec.

Definition at line 64 of file qstrvec.h.

65  { return qstrcmp((const char*)s1,
66  (const char*)s2); }
Q_EXPORT int qstrcmp(const char *str1, const char *str2)
Definition: qcstring.h:95
void QStrVec::deleteItem ( Item  d)
inlineprivatevirtual

Virtual function that deletes an item that is about to be removed from the collection.

The default implementation deletes d pointer if and only if auto-delete has been enabled.

This function is always reimplemented in the collection template classes.

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 destructed.
See also
newItem(), setAutoDelete()

Reimplemented from QCollection.

Definition at line 63 of file qstrvec.h.

63 { if ( dc ) delete[] (char*)d; }
bool dc
Definition: qstrvec.h:73
Item QStrVec::newItem ( Item  d)
inlineprivatevirtual

Virtual function that creates a copy of an object that is about to be inserted into the collection.

The default implementation returns the 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.

See also
deleteItem()

Reimplemented from QCollection.

Definition at line 62 of file qstrvec.h.

62 { return dc ? qstrdup( (const char*)d ) : d; }
bool dc
Definition: qstrvec.h:73
char * qstrdup(const char *str)
Definition: qcstring.cpp:548
QDataStream& QStrVec::read ( QDataStream s,
Item d 
)
inlineprivatevirtual

Reads a collection/vector item from the stream s and returns a reference to the stream.

The default implementation sets item to 0.

See also
write()

Reimplemented from QGVector.

Definition at line 68 of file qstrvec.h.

69  { s >> (char *&)d; return s; }
static QCString * s
Definition: config.cpp:1042
QDataStream& QStrVec::write ( QDataStream s,
Item   
) const
inlineprivatevirtual

Writes a collection/vector item to the stream s and returns a reference to the stream.

The default implementation does nothing.

See also
read()

Reimplemented from QGVector.

Definition at line 70 of file qstrvec.h.

71  { return s << (const char*)d; }

Member Data Documentation

bool QStrVec::dc
private

Definition at line 73 of file qstrvec.h.


The documentation for this class was generated from the following file: