Qt 4.8
Classes | Functions
QtPrivate Namespace Reference

Classes

class  HasResultType
 
struct  QEnableIf
 
struct  QEnableIf< true, T >
 
struct  QMetaTypeIdHelper
 
struct  QMetaTypeIdHelper< T, false >
 
struct  QScopedArrayEnsureSameType
 
struct  QScopedArrayEnsureSameType< const X, X >
 
struct  QScopedArrayEnsureSameType< X, X >
 

Functions

QBool Q_CORE_EXPORT QStringList_contains (const QStringList *that, const QString &str, Qt::CaseSensitivity cs)
 
QStringList Q_CORE_EXPORT QStringList_filter (const QStringList *that, const QString &str, Qt::CaseSensitivity cs)
 
QStringList Q_CORE_EXPORT QStringList_filter (const QStringList *that, const QRegExp &re)
 
int Q_CORE_EXPORT QStringList_indexOf (const QStringList *that, const QRegExp &rx, int from)
 
int Q_CORE_EXPORT QStringList_indexOf (const QStringList *that, QRegExp &rx, int from)
 
QString Q_CORE_EXPORT QStringList_join (const QStringList *that, const QString &sep)
 
int Q_CORE_EXPORT QStringList_lastIndexOf (const QStringList *that, const QRegExp &rx, int from)
 
int Q_CORE_EXPORT QStringList_lastIndexOf (const QStringList *that, QRegExp &rx, int from)
 
int Q_CORE_EXPORT QStringList_removeDuplicates (QStringList *that)
 
void Q_CORE_EXPORT QStringList_replaceInStrings (QStringList *that, const QString &before, const QString &after, Qt::CaseSensitivity cs)
 
void Q_CORE_EXPORT QStringList_replaceInStrings (QStringList *that, const QRegExp &rx, const QString &after)
 
void Q_CORE_EXPORT QStringList_sort (QStringList *that)
 

Function Documentation

◆ QStringList_contains()

QBool QtPrivate::QStringList_contains ( const QStringList that,
const QString str,
Qt::CaseSensitivity  cs 
)

Definition at line 349 of file qstringlist.cpp.

Referenced by QStringList::contains(), and QStringList::operator<<().

351 {
352  for (int i = 0; i < that->size(); ++i) {
353  const QString & string = that->at(i);
354  if (string.length() == str.length() && str.compare(string, cs) == 0)
355  return QBool(true);
356  }
357  return QBool(false);
358 }
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
The QString class provides a Unicode character string.
Definition: qstring.h:83
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
int compare(const QString &s) const
Definition: qstring.cpp:5037
int size() const
Returns the number of items in the list.
Definition: qlist.h:137

◆ QStringList_filter() [1/2]

QStringList QtPrivate::QStringList_filter ( const QStringList that,
const QString str,
Qt::CaseSensitivity  cs 
)

Definition at line 325 of file qstringlist.cpp.

Referenced by QStringList::filter(), and QStringList::operator<<().

327 {
328  QStringMatcher matcher(str, cs);
329  QStringList res;
330  for (int i = 0; i < that->size(); ++i)
331  if (matcher.indexIn(that->at(i)) != -1)
332  res << that->at(i);
333  return res;
334 }
The QStringMatcher class holds a sequence of characters that can be quickly matched in a Unicode stri...
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
int size() const
Returns the number of items in the list.
Definition: qlist.h:137

◆ QStringList_filter() [2/2]

QStringList QtPrivate::QStringList_filter ( const QStringList that,
const QRegExp re 
)

Definition at line 372 of file qstringlist.cpp.

373 {
374  QStringList res;
375  for (int i = 0; i < that->size(); ++i)
376  if (that->at(i).contains(rx))
377  res << that->at(i);
378  return res;
379 }
QBool contains(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.h:904
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
int size() const
Returns the number of items in the list.
Definition: qlist.h:137

◆ QStringList_indexOf() [1/2]

int QtPrivate::QStringList_indexOf ( const QStringList that,
const QRegExp rx,
int  from 
)

Definition at line 645 of file qstringlist.cpp.

Referenced by QStringList::indexOf(), and QStringList::operator<<().

646 {
647  QRegExp rx2(rx);
648  return indexOfMutating(that, rx2, from);
649 }
The QRegExp class provides pattern matching using regular expressions.
Definition: qregexp.h:61
static int indexOfMutating(const QStringList *that, QRegExp &rx, int from)

◆ QStringList_indexOf() [2/2]

int QtPrivate::QStringList_indexOf ( const QStringList that,
QRegExp rx,
int  from 
)

Definition at line 670 of file qstringlist.cpp.

671 {
672  return indexOfMutating(that, rx, from);
673 }
static int indexOfMutating(const QStringList *that, QRegExp &rx, int from)

◆ QStringList_join()

QString QtPrivate::QStringList_join ( const QStringList that,
const QString sep 
)

Definition at line 453 of file qstringlist.cpp.

Referenced by QStringList::join(), and QStringList::operator<<().

454 {
455  int totalLength = 0;
456  const int size = that->size();
457 
458  for (int i = 0; i < size; ++i)
459  totalLength += that->at(i).size();
460 
461  if(size > 0)
462  totalLength += sep.size() * (size - 1);
463 
464  QString res;
465  if (totalLength == 0)
466  return res;
467  res.reserve(totalLength);
468  for (int i = 0; i < that->size(); ++i) {
469  if (i)
470  res += sep;
471  res += that->at(i);
472  }
473  return res;
474 }
The QString class provides a Unicode character string.
Definition: qstring.h:83
void reserve(int size)
Attempts to allocate memory for at least size characters.
Definition: qstring.h:881
int size() const
Returns the number of characters in this string.
Definition: qstring.h:102
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
int size() const
Returns the number of items in the list.
Definition: qlist.h:137

◆ QStringList_lastIndexOf() [1/2]

int QtPrivate::QStringList_lastIndexOf ( const QStringList that,
const QRegExp rx,
int  from 
)

Definition at line 690 of file qstringlist.cpp.

Referenced by QStringList::lastIndexOf(), and QStringList::operator<<().

691 {
692  QRegExp rx2(rx);
693  return lastIndexOfMutating(that, rx2, from);
694 }
The QRegExp class provides pattern matching using regular expressions.
Definition: qregexp.h:61
static int lastIndexOfMutating(const QStringList *that, QRegExp &rx, int from)

◆ QStringList_lastIndexOf() [2/2]

int QtPrivate::QStringList_lastIndexOf ( const QStringList that,
QRegExp rx,
int  from 
)

Definition at line 716 of file qstringlist.cpp.

717 {
718  return lastIndexOfMutating(that, rx, from);
719 }
static int lastIndexOfMutating(const QStringList *that, QRegExp &rx, int from)

◆ QStringList_removeDuplicates()

int QtPrivate::QStringList_removeDuplicates ( QStringList that)

Definition at line 765 of file qstringlist.cpp.

Referenced by QStringList::operator<<(), and QStringList::removeDuplicates().

766 {
767  int n = that->size();
768  int j = 0;
769  QSet<QString> seen;
770  seen.reserve(n);
771  for (int i = 0; i < n; ++i) {
772  const QString &s = that->at(i);
773  if (seen.contains(s))
774  continue;
775  seen.insert(s);
776  if (j != i)
777  (*that)[j] = s;
778  ++j;
779  }
780  if (n != j)
781  that->erase(that->begin() + j, that->end());
782  return n - j;
783 }
iterator begin()
Returns an STL-style iterator pointing to the first item in the list.
Definition: qlist.h:267
The QString class provides a Unicode character string.
Definition: qstring.h:83
bool contains(const T &value) const
Definition: qset.h:91
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the list...
Definition: qlist.h:270
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
const_iterator insert(const T &value)
Definition: qset.h:179
iterator erase(iterator pos)
Removes the item associated with the iterator pos from the list, and returns an iterator to the next ...
Definition: qlist.h:464
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
void reserve(int size)
Definition: qset.h:241

◆ QStringList_replaceInStrings() [1/2]

void QtPrivate::QStringList_replaceInStrings ( QStringList that,
const QString before,
const QString after,
Qt::CaseSensitivity  cs 
)

Definition at line 400 of file qstringlist.cpp.

Referenced by QStringList::operator<<(), and QStringList::replaceInStrings().

402 {
403  for (int i = 0; i < that->size(); ++i)
404  (*that)[i].replace(before, after, cs);
405 }
int size() const
Returns the number of items in the list.
Definition: qlist.h:137

◆ QStringList_replaceInStrings() [2/2]

void QtPrivate::QStringList_replaceInStrings ( QStringList that,
const QRegExp rx,
const QString after 
)

Definition at line 434 of file qstringlist.cpp.

435 {
436  for (int i = 0; i < that->size(); ++i)
437  (*that)[i].replace(rx, after);
438 }
int size() const
Returns the number of items in the list.
Definition: qlist.h:137

◆ QStringList_sort()

void QtPrivate::QStringList_sort ( QStringList that)

Definition at line 252 of file qstringlist.cpp.

Referenced by QStringList::operator<<(), and QStringList::sort().

253 {
254  qSort(*that);
255 }
void qSort(RandomAccessIterator start, RandomAccessIterator end)
Definition: qalgorithms.h:177