CopperSpice API
1.9.2
|
Provides a container which is optimized for strings. More...
Public Methods | |
QStringList () | |
QStringList (const QList< QString > &other) | |
QStringList (const QString &value) | |
QStringList (const QStringList &other) | |
QStringList (std::initializer_list< QString > args) | |
bool | contains (const QString &str, Qt::CaseSensitivity cs=Qt::CaseSensitive) const |
QStringList | filter (const QRegularExpression8 &rx) const |
QStringList | filter (const QString &str, Qt::CaseSensitivity cs=Qt::CaseSensitive) const |
int | indexOf (const QRegularExpression8 &rx, int from=0) const |
int | indexOf (QRegularExpression8 &rx, int from=0) const |
QString | join (const QString &separator) const |
int | lastIndexOf (const QRegularExpression8 &rx, int from=-1) const |
int | lastIndexOf (QRegularExpression8 &rx, int from=-1) const |
QStringList | operator+ (const QStringList &other) const |
QStringList & | operator<< (const QString &str) |
QStringList & | operator<< (const QStringList &other) |
QStringList & | operator= (const QStringList &other) |
int | removeDuplicates () |
QStringList & | replaceInStrings (const QRegularExpression8 &rx, const QString &after) |
QStringList & | replaceInStrings (const QString &before, const QString &after, Qt::CaseSensitivity cs=Qt::CaseSensitive) |
void | sort () |
Public Methods inherited from QList< QString > | |
QList () = default | |
QList (const QList< QString > &other) = default | |
QList (Input_Iterator first, Input_Iterator last) | |
QList (QList< QString > &&other) = default | |
QList (std::initializer_list< QString > args) | |
~QList () = default | |
void | append (const QList< QString > &other) |
void | append (const QString &value) |
void | append (QList< QString > &&other) |
void | append (QString &&value) |
const QString & | at (size_type i) const |
QString & | back () |
const QString & | back () const |
iterator | begin () |
const_iterator | begin () const |
const_iterator | cbegin () const |
const_iterator | cend () const |
void | clear () |
const_iterator | constBegin () const |
const_iterator | constEnd () const |
const_reference | constFirst () const |
const_reference | constLast () const |
bool | contains (const QString &value) const |
size_type | count () const |
size_type | count (const QString &value) const |
const_reverse_iterator | crbegin () const |
const_reverse_iterator | crend () const |
bool | empty () const |
iterator | end () |
const_iterator | end () const |
bool | endsWith (const QString &value) const |
iterator | erase (const_iterator begin, const_iterator end) |
iterator | erase (const_iterator pos) |
QString & | first () |
const QString & | first () const |
QString & | front () |
const QString & | front () const |
size_type | indexOf (const QString &value, size_type from=0) const |
iterator | insert (iterator before, const QString &value) |
void | insert (size_type i, const QString &value) |
bool | isEmpty () const |
QString & | last () |
const QString & | last () const |
size_type | lastIndexOf (const QString &value, size_type from=-1) const |
size_type | length () const |
QList< QString > | mid (size_type pos, size_type length=-1) const |
void | move (size_type from, size_type to) |
bool | operator!= (const QList< QString > &other) const |
QList< QString > | operator+ (const QList< QString > &other) const |
QList< QString > & | operator+= (const QList< QString > &other) |
QList< QString > & | operator+= (const QString &value) |
QList< QString > & | operator<< (const QList< QString > &other) |
QList< QString > & | operator<< (const QString &value) |
QList< QString > & | operator= (const QList< QString > &other) = default |
QList< QString > & | operator= (QList< QString > &&other) = default |
bool | operator== (const QList< QString > &other) const |
QString & | operator[] (size_type i) |
const QString & | operator[] (size_type i) const |
void | pop_back () |
void | pop_front () |
void | prepend (const QString &value) |
void | push_back (const QString &value) |
void | push_front (const QString &value) |
reverse_iterator | rbegin () |
const_reverse_iterator | rbegin () const |
size_type | removeAll (const QString &value) |
void | removeAt (size_type i) |
void | removeFirst () |
void | removeLast () |
bool | removeOne (const QString &value) |
reverse_iterator | rend () |
const_reverse_iterator | rend () const |
void | replace (size_type i, const QString &value) |
void | resize (size_type size) |
size_type | size () const |
bool | startsWith (const QString &value) const |
void | swap (QList< QString > &other) |
void | swap (size_type i, size_type j) |
QString | takeAt (size_type i) |
QString | takeFirst () |
QString | takeLast () |
QSet< QString > | toSet () const |
std::list< QString > | toStdList () const |
QVector< QString > | toVector () const |
QString | value (size_type i) const |
QString | value (size_type i, const QString &defaultValue) const |
Related Functions | |
These are not member functions | |
QDataStream & | operator<< (QDataStream &stream, const QStringList &list) |
QDataStream & | operator>> (QDataStream &stream, QStringList &list) |
QMutableStringListIterator | |
QStringListIterator | |
Related Functions inherited from QList< QString > | |
bool | operator< (const QList< QString > &lhs, const QList< QString > &rhs) |
QDataStream & | operator<< (QDataStream &stream, const QList< QString > &list) |
bool | operator<= (const QList< QString > &lhs, const QList< QString > &rhs) |
bool | operator> (const QList< QString > &lhs, const QList< QString > &rhs) |
bool | operator>= (const QList< QString > &lhs, const QList< QString > &rhs) |
QDataStream & | operator>> (QDataStream &stream, QList< QString > &list) |
Additional Inherited Members | |
Public Typedefs inherited from QList< QString > | |
using | allocator_type = typename std::deque< QString >::allocator_type |
using | const_iterator = typename std::deque< QString >::const_iterator |
using | const_pointer = typename std::deque< QString >::const_pointer |
using | const_reference = typename std::deque< QString >::const_reference |
using | const_reverse_iterator = typename std::deque< QString >::const_reverse_iterator |
using | difference_type = typename std::deque< QString >::difference_type |
using | iterator = typename std::deque< QString >::iterator |
using | Java_Iterator = QListIterator< QString > |
using | Java_MutableIterator = QMutableListIterator< QString > |
using | pointer = typename std::deque< QString >::pointer |
using | reference = typename std::deque< QString >::reference |
using | reverse_iterator = typename std::deque< QString >::reverse_iterator |
using | size_type = typename std::deque< QString >::difference_type |
using | value_type = typename std::deque< QString >::value_type |
Static Public Methods inherited from QList< QString > | |
static QList< QString > | fromSet (const QSet< QString > &set) |
static QList< QString > | fromStdList (const std::list< QString > &other) |
static QList< QString > | fromVector (const QVector< QString > &vector) |
The QStringList class provides a container which is optimized for strings. This container stores a list of strings using a QList<QString>. QStringList provides fast index access as well as fast insertions and removals at both ends.
For an overview and comparison of all containers, refer to the documentation for Container Classes. Refer to the section on Time Complexity for a discussion about which operations will be relatively faster or slower for a given container with a size of n.
Since QStringList inherits from QList all of the methods in QList are available in this class. For example, isEmpty() can be used to determine if the string list has any elements.
QStringList also provides methods which make handling lists of strings easier. Methods like append(), prepend(), insert(), replace(), removeAll(), removeAt(), removeFirst(), removeLast(), and removeOne() can be used to modify a QStringList.
In addition to append(), the following code shows how to add elements using the operator<<() method.
To concatenate all of the strings in an existing string list into a single string, with an optional separator, use join().
To create a QStringList from a QString using a separator character, the QString::split() method is called.
To iterate over a QStringList you can use Java style or STL style iterators.
|
inline |
Constructs an empty string list.
|
inlineexplicit |
Constructs a string list that contains the given string, str. Longer lists are easily created like this:
|
inline |
Constructs a copy of the other string list.
Constructs a copy of other.
|
inline |
Construct a list from a std::initializer_list given by args.
bool QStringList::contains | ( | const QString & | str, |
Qt::CaseSensitivity | cs = Qt::CaseSensitive |
||
) | const |
Returns true if the list contains the string str, otherwise returns false. The search is case insensitive if cs is Qt::CaseInsensitive; the search is case sensitive by default.
QStringList QStringList::filter | ( | const QRegularExpression8 & | rx | ) | const |
Returns a list of all the strings that match the regular expression rx.
QStringList QStringList::filter | ( | const QString & | str, |
Qt::CaseSensitivity | cs = Qt::CaseSensitive |
||
) | const |
Returns a list of all the strings containing the substring str. If cs is Qt::CaseSensitive (the default), the string comparison is case sensitive, otherwise the comparison is case insensitive.
This is equivalent to
int QStringList::indexOf | ( | const QRegularExpression8 & | rx, |
int | from = 0 |
||
) | const |
Returns the index position of the first exact match of rx in the list, searching forward from index position from. Returns -1 if no item matched.
By default this method is case sensitive.
int QStringList::indexOf | ( | QRegularExpression8 & | rx, |
int | from = 0 |
||
) | const |
If an item matched the rx regular expression will contain the matched objects. Returns the index position of the first exact match of rx in the list, searching forward from index position from. Returns -1 if no item matched.
By default this method is case sensitive.
Joins all the strings in the list into a single string with each element separated by the given separator. The separator can be empty.
int QStringList::lastIndexOf | ( | const QRegularExpression8 & | rx, |
int | from = -1 |
||
) | const |
Returns the index position of the last exact match of rx in the list, searching backward from index position from. If from is -1 (the default), the search starts at the last item. Returns -1 if no item matched.
By default this method is case sensitive.
int QStringList::lastIndexOf | ( | QRegularExpression8 & | rx, |
int | from = -1 |
||
) | const |
If an item matched the rx regular expression will contain the matched objects. Returns the index position of the last exact match of rx in the list, searching backward from index position from.
If from is -1 (the default), the search starts at the last item. Returns -1 if no item matched.
By default this method is case sensitive.
|
inline |
Returns a string list that is the concatenation of this string list with the other string list.
|
inline |
Appends the given string, str, to this string list and returns a reference to the string list.
|
inline |
Appends the other string list to the string list and returns a reference to the latter string list.
|
inline |
Copy assigns from other and returns a reference to this object.
int QStringList::removeDuplicates | ( | ) |
This method removes duplicate entries from a list. The entries do not have to be sorted and they will retain their original order. Returns the number of removed entries.
QStringList & QStringList::replaceInStrings | ( | const QRegularExpression8 & | rx, |
const QString & | after | ||
) |
Replaces every occurrence of the regular expression rx, in each of the strings, with after. Returns a reference to the string list.
For regular expressions that contain capturing parentheses, occurrences of \1, \2, ..., in after are replaced with rx.cap(1), rx.cap(2), ...
QStringList & QStringList::replaceInStrings | ( | const QString & | before, |
const QString & | after, | ||
Qt::CaseSensitivity | cs = Qt::CaseSensitive |
||
) |
Returns a string list where every string has had the before text replaced with the after text wherever the before text is found. The before text is matched case-sensitively or not depending on the cs flag.
void QStringList::sort | ( | ) |
Sorts the list of strings in ascending order and case sensitive.
|
related |
Writes the given list to the stream. Returns a reference to the stream.
Refer to Serializing Data Types for additional information.
|
related |
Reads from the stream into the given list. Returns a reference to the stream.
Refer to Serializing Data Types for additional information.
|
related |
The QStringListIterator type definition provides a Java style non-const iterator for QStringList.
QStringList provides both Java style iterators and STL style iterators. The Java style non-const iterator is simply a type definition for QMutableListIterator<QString>.
|
related |
The QStringListIterator type definition provides a Java-style const iterator for QStringList.
QStringList provides both Java style iterators and STL style iterators. The Java style const iterator is simply a type definition for QListIterator<QString>.