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

#include <qstrlist.h>

Inheritance diagram for QStrList:
QInternalList< type > QGList QCollection QStrIList

Public Member Functions

 QStrList (bool deepCopies=TRUE)
 
 QStrList (const QStrList &)
 
 ~QStrList ()
 
QStrListoperator= (const QStrList &)
 
- Public Member Functions inherited from QInternalList< type >
 QInternalList ()
 
 QInternalList (const QInternalList< type > &l)
 
 ~QInternalList ()
 
QInternalList< type > & operator= (const QInternalList< type > &l)
 
bool operator== (const QInternalList< type > &list) const
 
uint count () const
 
bool isEmpty () const
 
bool insert (uint i, const type *d)
 
void inSort (const type *d)
 
void prepend (const type *d)
 
void append (const type *d)
 
bool remove (uint i)
 
bool remove ()
 
bool remove (const type *d)
 
bool removeRef (const type *d)
 
void removeNode (QLNode *n)
 
bool removeFirst ()
 
bool removeLast ()
 
typetake (uint i)
 
typetake ()
 
typetakeNode (QLNode *n)
 
void clear ()
 
void sort ()
 
int find (const type *d)
 
int findNext (const type *d)
 
int findRef (const type *d)
 
int findNextRef (const type *d)
 
uint contains (const type *d) const
 
uint containsRef (const type *d) const
 
typeat (uint i)
 
int at () const
 
typecurrent () const
 
QLNodecurrentNode () const
 
typegetFirst () const
 
typegetLast () const
 
typefirst ()
 
typelast ()
 
typenext ()
 
typeprev ()
 
void toVector (QGVector *vec) const
 
- Public Member Functions inherited from QGList
QDataStreamread (QDataStream &)
 
QDataStreamwrite (QDataStream &) const
 
- Public Member Functions inherited from QCollection
bool autoDelete () const
 
void setAutoDelete (bool enable)
 

Private Member Functions

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

Private Attributes

bool dc
 

Additional Inherited Members

- Public Types inherited from QCollection
typedef void * Item
 
- Protected Member Functions inherited from QGList
 QGList ()
 
 QGList (const QGList &)
 
virtual ~QGList ()
 
QGListoperator= (const QGList &)
 
bool operator== (const QGList &) const
 
void inSort (QCollection::Item)
 
void append (QCollection::Item)
 
bool insertAt (uint index, QCollection::Item)
 
void relinkNode (QLNode *)
 
bool removeNode (QLNode *)
 
bool remove (QCollection::Item=0)
 
bool removeRef (QCollection::Item=0)
 
bool removeFirst ()
 
bool removeLast ()
 
bool removeAt (uint index)
 
QCollection::Item takeNode (QLNode *)
 
QCollection::Item take ()
 
QCollection::Item takeAt (uint index)
 
QCollection::Item takeFirst ()
 
QCollection::Item takeLast ()
 
void sort ()
 
int findRef (QCollection::Item, bool=TRUE)
 
int find (QCollection::Item, bool=TRUE)
 
uint containsRef (QCollection::Item) const
 
uint contains (QCollection::Item) const
 
QCollection::Item at (uint index)
 
int at () const
 
QLNodecurrentNode () const
 
QCollection::Item get () const
 
QCollection::Item cfirst () const
 
QCollection::Item clast () const
 
QCollection::Item first ()
 
QCollection::Item last ()
 
QCollection::Item next ()
 
QCollection::Item prev ()
 
void toVector (QGVector *) 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 57 of file qstrlist.h.

Constructor & Destructor Documentation

QStrList::QStrList ( bool  deepCopies = TRUE)
inline

Definition at line 60 of file qstrlist.h.

60 { dc = deepCopies; del_item = deepCopies; }
bool dc
Definition: qstrlist.h:76
bool del_item
Definition: qcollection.h:67
QStrList::QStrList ( const QStrList strList)
inline

Definition at line 101 of file qstrlist.h.

102  : QStrListBase( strList )
103 {
104  dc = FALSE;
105  operator=(strList);
106 }
bool dc
Definition: qstrlist.h:76
QInternalList< char > QStrListBase
Definition: qstrlist.h:53
const bool FALSE
Definition: qglobal.h:370
QStrList & operator=(const QStrList &)
Definition: qstrlist.h:92
QStrList::~QStrList ( )
inline

Definition at line 62 of file qstrlist.h.

62 { clear(); }

Member Function Documentation

int QStrList::compareItems ( QCollection::Item  item1,
QCollection::Item  item2 
)
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 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 QList::inSort() function requires that compareItems() is implemented as described here.

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

The default implementation compares the pointers:

Reimplemented from QGList.

Reimplemented in QStrIList.

Definition at line 68 of file qstrlist.h.

68  { return qstrcmp((const char*)s1,
69  (const char*)s2); }
Q_EXPORT int qstrcmp(const char *str1, const char *str2)
Definition: qcstring.h:95
void QStrList::deleteItem ( QCollection::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 QInternalList< type >.

Definition at line 67 of file qstrlist.h.

67 { if ( del_item ) delete[] (char*)d; }
bool del_item
Definition: qcollection.h:67
QCollection::Item QStrList::newItem ( QCollection::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 66 of file qstrlist.h.

66 { return dc ? qstrdup( (const char*)d ) : d; }
bool dc
Definition: qstrlist.h:76
char * qstrdup(const char *str)
Definition: qcstring.cpp:548
QStrList & QStrList::operator= ( const QStrList strList)
inline

Definition at line 92 of file qstrlist.h.

93 {
94  clear();
95  dc = strList.dc;
96  del_item = dc;
97  QStrListBase::operator=(strList);
98  return *this;
99 }
bool dc
Definition: qstrlist.h:76
bool del_item
Definition: qcollection.h:67
QInternalList< type > & operator=(const QInternalList< type > &l)
Definition: qinternallist.h:52
QDataStream& QStrList::read ( QDataStream s,
QCollection::Item item 
)
inlineprivatevirtual

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

The default implementation sets item to 0.

See also
write()

Reimplemented from QGList.

Definition at line 71 of file qstrlist.h.

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

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

The default implementation does nothing.

See also
read()

Reimplemented from QGList.

Definition at line 73 of file qstrlist.h.

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

Member Data Documentation

bool QStrList::dc
private

Definition at line 76 of file qstrlist.h.


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