![]() |
CopperSpice API
2.1.0
|
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 |
| QString | join (const QString &separator) const |
| int | lastIndexOf (const 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<QString> all of the existing methods in QList are available in this class.
The method isEmpty() is used to determine if the current QStringList has any elements. This method is not documented in QStringList, it is documented in the QList class. As another example, methods like indexOf() or lastIndexOf() have additional overloads and their documentation can also be found in the QList class.
The QStringList class provides a vast number of other methods which make handling a list of strings easier. Methods like append(), prepend(), insert(), replace(), removeAll(), removeAt(), removeFirst(), removeLast(), and removeOne() can be used to modify or query the elements of a QStringList.
In addition to using append() to add elements to a QStringList, the following example shows how to add elements using the operator<<() method.
To create a quoted string using the elements of a existing QStringList use join(). An optional separator can be specified as a way to indicate a delimiter between each element.
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 QStringList.
|
inlineexplicit |
Constructs a new QStringList which contains the given string str.
|
inline |
Copy constructs a new QStringList from other.
Copy constructs a new QStringList from other.
|
inline |
Constructs a new QStringList using an std::initializer_list specified by args.
| bool QStringList::contains | ( | const QString & | str, |
| Qt::CaseSensitivity | cs = Qt::CaseSensitive |
||
| ) | const |
Returns true if the QStringList contains the string str, otherwise returns false. If cs is Qt::CaseSensitive, the string comparison is case sensitive, otherwise the comparison is case insensitive.
| QStringList QStringList::filter | ( | const QRegularExpression8 & | rx | ) | const |
Returns a list of all the strings which 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 string comparison is case sensitive, otherwise the comparison is case insensitive.
This is equivalent to the following example.
| 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 is found.
By default this method is case sensitive.
Concatenates the strings in the QStringList into a single QString. Each element is delimited 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 the value from is -1, the search starts at the last element. Returns -1 if no item is found.
By default this method is case sensitive.
|
inline |
Returns a QStringList which is the concatenation of this QStringList and other.
|
inline |
Appends the given str to this QStringList and returns a reference to this QStringList.
|
inline |
Appends other to this QStringList and returns a reference to this QStringList.
|
inline |
Copy assigns from other and returns a reference to this QStringList.
| int QStringList::removeDuplicates | ( | ) |
Removes duplicate elements from the current QStringList. The elements do not need to be sorted and they will retain their original order. Returns the number of removed elements.
| QStringList & QStringList::replaceInStrings | ( | const QRegularExpression8 & | rx, |
| const QString & | after | ||
| ) |
Replaces every occurrence of the regular expression rx with after.
For regular expressions which contain capturing parentheses, occurrences of \1, \2, etc, The after string is replaced with rx.cap(1), rx.cap(2), etc.
| QStringList & QStringList::replaceInStrings | ( | const QString & | before, |
| const QString & | after, | ||
| Qt::CaseSensitivity | cs = Qt::CaseSensitive |
||
| ) |
Replaces the string before with the string after for every match in any given element. If cs is Qt::CaseSensitive the string comparison is case sensitive, otherwise the comparison is case insensitive.
| void QStringList::sort | ( | ) |
Sorts the strings in the current QStringList 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>.