QStringList - A list of strings
#include <qstringlist.h>
Inherits QValueList.
Public Members
QStringList ()
QStringList ( const QStringList & l )
QStringList ( const QValueList<QString> & l )
QStringList ( const QString & i )
QStringList ( const char * i )
void sort ()
QString join ( const QString & sep ) const
QStringList grep ( const QString & str, bool cs = TRUE )
const
QStringList grep ( const QRegExp & expr ) const
Static Public Members
QStringList fromStrList ( const QStrList & )
QStringList split ( const QString & sep, const QString &
str, bool allowEmptyEntries = FALSE )
QStringList split ( const QChar & sep, const QString &
str, bool allowEmptyEntries = FALSE )
QStringList split ( const QRegExp & sep, const QString &
str, bool allowEmptyEntries = FALSE )
DESCRIPTION
A list of strings.
QStringList is basically a QValueList of QString objects.
As opposed to QStrList, that stores pointers to
characters, QStringList deals with real QString objects.
It is the class of choice whenever you work with unicode
strings.
Like QString itself, QStringList objects are implicit
shared. Passing them around as value-parameters is both
fast and safe.
Example:
QStringList list;
// three different ways of appending values:
list.append( "Torben");
list += "Warwick";
list << "Matthias" << "Arnt" << "Paul";
// sort the list, Arnt's now first
list.sort();
// print it out
for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
printf( "%s \n", (*it).latin1() );
Convenience methods such as sort(), split(), join() and
grep() make working with QStringList easy.
MEMBER FUNCTION DOCUMENTATION
QStringList::QStringList ()
Creates an empty list.
QStringList::QStringList ( const QString & i )
Constructs a string list consisting of the single string
i. To make longer lists easily, use:
QString s1,s2,s3;
...
QStringList mylist = QStringList() << s1 << s2 << s3;
QStringList::QStringList ( const QValueList & l )
Constructs a new string list that is a copy of l.
QStringList::QStringList ( const QStringList & l )
Creates a copy of the list. This function is very fast
since QStringList is implicit shared. However, for the
programmer this is the same as a deep copy. If this list
or the original one or some other list referencing the
same shared data is modified, then the modifying list
makes a copy first.
QStringList::QStringList ( const char * i )
Constructs a string list consisting of the single latin-1
string i.
QStringList QStringList::fromStrList ( const QStrList & ascii )
[static]
Converts from a QStrList (ASCII) to a QStringList
(Unicode).
QStringList QStringList::grep ( const QRegExp & expr ) const
Returns a list of all strings containing a substring that
matches the regular expression expr.
QStringList QStringList::grep ( const QString & str, bool cs =
TRUE ) const
Returns a list of all strings containing the substring
str.
If cs is TRUE, the grep is done case sensitively, else
not.
QString QStringList::join ( const QString & sep ) const
Joins the stringlist into a single string with each
element separated by sep.
See also split().
Sorts the list of strings in ascending order.
Sorting is very fast. It uses the Qt Template Library's
efficient HeapSort implementation that operates in O(n*log
n).
QStringList QStringList::split ( const QChar & sep, const QString
& str, bool allowEmptyEntries = FALSE ) [static]
Splits the string str using sep as separator. Returns the
list of strings. If allowEmptyEntries is TRUE, also empty
entries are inserted into the list, else not. So if you
have a string 'abc..d.e.', a list which contains 'abc',
'd', and 'e' would be returned if allowEmptyEntries is
FALSE, but a list containing 'abc', '', 'd', 'e' and ''
would be returned if allowEmptyEntries is TRUE. If str
doesn't contain sep, a stringlist with one item, which is
the same as str, is returned.
See also join().
QStringList QStringList::split ( const QRegExp & sep, const
QString & str, bool allowEmptyEntries = FALSE ) [static]
Splits the string str using the regular expression sep as
separator. Returns the list of strings. If
allowEmptyEntries is TRUE, also empty entries are inserted
into the list, else not. So if you have a string
'abc..d.e.', a list which contains 'abc', 'd', and 'e'
would be returned if allowEmptyEntries is FALSE, but a
list containing 'abc', '', 'd', 'e' and '' would be
returned if allowEmptyEntries is TRUE. If str doesn't
contain sep, a stringlist with one item, which is the same
as str, is returned.
See also join().
QStringList QStringList::split ( const QString & sep, const
QString & str, bool allowEmptyEntries = FALSE ) [static]
Splits the string str using sep as separator. Returns the
list of strings. If allowEmptyEntries is TRUE, also empty
entries are inserted into the list, else not. So if you
have a string 'abc..d.e.', a list which contains 'abc',
'd', and 'e' would be returned if allowEmptyEntries is
FALSE, but a list containing 'abc', '', 'd', 'e' and ''
would be returned if allowEmptyEntries is TRUE. If str
doesn't contain sep, a stringlist with one item, which is
the same as str, is returned.
See also join().
SEE ALSO
http://doc.trolltech.com/qstringlist.html
http://www.trolltech.com/faq/tech.html
Copyright 1992-2001 Trolltech AS,
http://www.trolltech.com. See the license file included
in the distribution for a complete license statement.
AUTHOR
Generated automatically from the source code.
BUGS
If you find a bug in Qt, please report it as described in
http://doc.trolltech.com/bughowto.html. Good bug reports
make our job much simpler. Thank you.
In case of content or formattting problems with this
manual page, please report them to qt-bugs@trolltech.com.
Please include the name of the manual page
(qstringlist.3qt) and the Qt version (2.3.1).
Man(1) output converted with
man2html