Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qstring.cpp File Reference

(d1539331dd813c83916a323f6cdc7fd6aacb0043)

#include "qstringlist.h"
#include "qunicodetables_p.h"
#include <private/qstringconverter_p.h>
#include <private/qtools_p.h>
#include "qlocale_tools_p.h"
#include "private/qsimd_p.h"
#include <qnumeric.h>
#include <qdatastream.h>
#include <qlist.h>
#include "qlocale.h"
#include "qlocale_p.h"
#include "qspan.h"
#include "qstringbuilder.h"
#include "qstringmatcher.h"
#include "qvarlengtharray.h"
#include "qdebug.h"
#include "qendian.h"
#include "qcollator.h"
#include "qttypetraits.h"
#include <private/qfunctions_p.h>
#include <limits.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <wchar.h>
#include "qchar.cpp"
#include "qlatin1stringmatcher.h"
#include "qstringmatcher.cpp"
#include "qstringiterator_p.h"
#include "qstringalgorithms_p.h"
#include "qthreadstorage.h"
#include <algorithm>
#include <functional>
+ Include dependency graph for qstring.cpp:

Go to the source code of this file.

Classes

struct  ArgEscapeData
 

Namespaces

namespace  QUnicodeTables
 

Macros

#define REHASH(a)
 
#define ATTRIBUTE_NO_SANITIZE
 
#define CSTR_LESS_THAN   1
 
#define CSTR_EQUAL   2
 
#define CSTR_GREATER_THAN   3
 

Typedefs

using CaseInsensitiveL1 = QtPrivate::QCaseInsensitiveLatin1Hash
 

Enumerations

enum  LengthMod {
  lm_none , lm_hh , lm_h , lm_l ,
  lm_ll , lm_L , lm_j , lm_z ,
  lm_t , lm_none , lm_hh , lm_h ,
  lm_l , lm_ll , lm_L , lm_j ,
  lm_z , lm_t
}
 
enum  LengthMod {
  lm_none , lm_hh , lm_h , lm_l ,
  lm_ll , lm_L , lm_j , lm_z ,
  lm_t , lm_none , lm_hh , lm_h ,
  lm_l , lm_ll , lm_L , lm_j ,
  lm_z , lm_t
}
 

Functions

qsizetype qFindStringBoyerMoore (QStringView haystack, qsizetype from, QStringView needle, Qt::CaseSensitivity cs)
 
bool qt_is_ascii (const char *&ptr, const char *end) noexcept
 
static bool isAscii_helper (const char16_t *&ptr, const char16_t *end)
 
Q_CORE_EXPORT void qt_from_latin1 (char16_t *dst, const char *str, size_t size) noexcept
 
static QVarLengthArray< char16_t > qt_from_latin1_to_qvla (QLatin1StringView str)
 
template<bool Checked>
static void qt_to_latin1_internal (uchar *dst, const char16_t *src, qsizetype length)
 
void qt_to_latin1 (uchar *dst, const char16_t *src, qsizetype length)
 
void qt_to_latin1_unchecked (uchar *dst, const char16_t *src, qsizetype length)
 
static Q_NEVER_INLINE int ucstricmp (qsizetype alen, const char16_t *a, qsizetype blen, const char16_t *b)
 
static Q_NEVER_INLINE int ucstricmp (qsizetype alen, const char16_t *a, qsizetype blen, const char *b)
 
static Q_NEVER_INLINE int ucstricmp8 (const char *utf8, const char *utf8end, const QChar *utf16, const QChar *utf16end)
 
template<StringComparisonMode Mode>
static int ucstrncmp (const char16_t *a, const char16_t *b, size_t l)
 
template<StringComparisonMode Mode>
static int ucstrncmp (const char16_t *a, const char *b, size_t l)
 
template<typename Char2>
static bool ucstreq (const char16_t *a, size_t alen, const Char2 *b)
 
template<typename Char2>
static int ucstrcmp (const char16_t *a, size_t alen, const Char2 *b, size_t blen)
 
static int latin1nicmp (const char *lhsChar, qsizetype lSize, const char *rhsChar, qsizetype rSize)
 
static int qArgDigitValue (QChar ch) noexcept
 
static bool needsReallocate (const QString &str, qsizetype newSize)
 
template<typename T>
static void insert_helper (QString &str, qsizetype i, const T &toInsert)
 
template<typename T>
static void removeStringImpl (QString &s, const T &needle, Qt::CaseSensitivity cs)
 
static void replace_with_copy (QString &str, QSpan< size_t > indices, qsizetype blen, QStringView after)
 
static void replace_in_place (QString &str, QSpan< size_t > indices, qsizetype blen, QStringView after)
 
static void replace_helper (QString &str, QSpan< size_t > indices, qsizetype blen, QStringView after)
 
static bool checkCase (QStringView s, QUnicodeTables::Case c) noexcept
 
static QByteArray qt_convert_to_latin1 (QStringView string)
 
static QByteArray qt_convert_to_local_8bit (QStringView string)
 
static QByteArray qt_convert_to_utf8 (QStringView str)
 
static QList< uintqt_convert_to_ucs4 (QStringView string)
 
bool comparesEqual (const QByteArrayView &lhs, const QChar &rhs)
 
Qt::strong_ordering compareThreeWay (const QByteArrayView &lhs, const QChar &rhs)
 
bool comparesEqual (const QByteArrayView &lhs, char16_t rhs)
 
Qt::strong_ordering compareThreeWay (const QByteArrayView &lhs, char16_t rhs)
 
bool comparesEqual (const QByteArray &lhs, const QChar &rhs)
 
Qt::strong_ordering compareThreeWay (const QByteArray &lhs, const QChar &rhs)
 
bool comparesEqual (const QByteArray &lhs, char16_t rhs)
 
Qt::strong_ordering compareThreeWay (const QByteArray &lhs, char16_t rhs)
 
template<typename T>
static Q_NEVER_INLINE QString QUnicodeTables::detachAndConvertCase (T &str, QStringIterator it, QUnicodeTables::Case which)
 
template<typename T>
static QString QUnicodeTables::convertCase (T &str, QUnicodeTables::Case which)
 
static void append_utf8 (QString &qs, const char *cs, qsizetype len)
 
static uint parse_flag_characters (const char *&c) noexcept
 
static int parse_field_width (const char *&c, qsizetype size)
 
static bool can_consume (const char *&c, char ch) noexcept
 
static LengthMod parse_length_modifier (const char *&c) noexcept
 
template<typename Int>
static Int toIntegral (QStringView string, bool *ok, int base)
 
void qt_string_normalize (QString *data, QString::NormalizationForm mode, QChar::UnicodeVersion version, qsizetype from)
 
static ArgEscapeData findArgEscapes (QStringView s)
 
static QString replaceArgEscapes (QStringView s, const ArgEscapeData &d, qsizetype field_width, QStringView arg, QStringView larg, QChar fillChar)
 
static char16_t to_unicode (const QChar c)
 
static char16_t to_unicode (const char c)
 
template<typename Char>
static int getEscape (const Char *uc, qsizetype *pos, qsizetype len)
 
 Q_DECLARE_TYPEINFO (Part, Q_PRIMITIVE_TYPE)
 
QDataStreamoperator<< (QDataStream &out, const QString &str)
 
QDataStreamoperator>> (QDataStream &in, QString &str)
 

Macro Definition Documentation

◆ ATTRIBUTE_NO_SANITIZE

#define ATTRIBUTE_NO_SANITIZE

Definition at line 366 of file qstring.cpp.

◆ CSTR_EQUAL

#define CSTR_EQUAL   2

Definition at line 6947 of file qstring.cpp.

◆ CSTR_GREATER_THAN

#define CSTR_GREATER_THAN   3

Definition at line 6948 of file qstring.cpp.

◆ CSTR_LESS_THAN

#define CSTR_LESS_THAN   1

Definition at line 6946 of file qstring.cpp.

◆ REHASH

#define REHASH ( a)
Value:
if (sl_minus_1 < sizeof(sl_minus_1) * CHAR_BIT) \
hashHaystack -= decltype(hashHaystack)(a) << sl_minus_1; \
hashHaystack <<= 1
GLboolean GLboolean GLboolean GLboolean a
[7]

Definition at line 65 of file qstring.cpp.

Typedef Documentation

◆ CaseInsensitiveL1

Enumeration Type Documentation

◆ LengthMod [1/2]

enum LengthMod
Enumerator
lm_none 
lm_hh 
lm_h 
lm_l 
lm_ll 
lm_L 
lm_j 
lm_z 
lm_t 
lm_none 
lm_hh 
lm_h 
lm_l 
lm_ll 
lm_L 
lm_j 
lm_z 
lm_t 

Definition at line 7404 of file qstring.cpp.

◆ LengthMod [2/2]

enum LengthMod
Enumerator
lm_none 
lm_hh 
lm_h 
lm_l 
lm_ll 
lm_L 
lm_j 
lm_z 
lm_t 
lm_none 
lm_hh 
lm_h 
lm_l 
lm_ll 
lm_L 
lm_j 
lm_z 
lm_t 

Definition at line 7404 of file qstring.cpp.

Function Documentation

◆ append_utf8()

static void append_utf8 ( QString & qs,
const char * cs,
qsizetype len )
static

Definition at line 7359 of file qstring.cpp.

◆ can_consume()

static bool can_consume ( const char *& c,
char ch )
inlinestaticnoexcept

Definition at line 7406 of file qstring.cpp.

Referenced by parse_length_modifier().

+ Here is the caller graph for this function:

◆ checkCase()

static bool checkCase ( QStringView s,
QUnicodeTables::Case c )
staticnoexcept

Definition at line 5559 of file qstring.cpp.

References QStringIterator::hasNext(), and QStringIterator::next().

+ Here is the call graph for this function:

◆ comparesEqual() [1/4]

bool comparesEqual ( const QByteArray & lhs,
char16_t rhs )
noexcept

Definition at line 6813 of file qstring.cpp.

◆ comparesEqual() [2/4]

bool comparesEqual ( const QByteArray & lhs,
const QChar & rhs )
noexcept

Definition at line 6802 of file qstring.cpp.

◆ comparesEqual() [3/4]

bool comparesEqual ( const QByteArrayView & lhs,
char16_t rhs )
noexcept

Definition at line 6791 of file qstring.cpp.

◆ comparesEqual() [4/4]

bool comparesEqual ( const QByteArrayView & lhs,
const QChar & rhs )
noexcept

Definition at line 6780 of file qstring.cpp.

◆ compareThreeWay() [1/4]

Qt::strong_ordering compareThreeWay ( const QByteArray & lhs,
char16_t rhs )
noexcept

Definition at line 6818 of file qstring.cpp.

◆ compareThreeWay() [2/4]

Qt::strong_ordering compareThreeWay ( const QByteArray & lhs,
const QChar & rhs )
noexcept

Definition at line 6807 of file qstring.cpp.

◆ compareThreeWay() [3/4]

Qt::strong_ordering compareThreeWay ( const QByteArrayView & lhs,
char16_t rhs )
noexcept

Definition at line 6796 of file qstring.cpp.

◆ compareThreeWay() [4/4]

Qt::strong_ordering compareThreeWay ( const QByteArrayView & lhs,
const QChar & rhs )
noexcept

Definition at line 6785 of file qstring.cpp.

◆ findArgEscapes()

static ArgEscapeData findArgEscapes ( QStringView s)
static

Definition at line 8607 of file qstring.cpp.

References ArgEscapeData::min_escape.

◆ getEscape()

template<typename Char>
static int getEscape ( const Char * uc,
qsizetype * pos,
qsizetype len )
static

Definition at line 9005 of file qstring.cpp.

◆ insert_helper()

template<typename T>
static void insert_helper ( QString & str,
qsizetype i,
const T & toInsert )
static

T is a view or a container on/of QChar, char16_t, or char

Definition at line 2962 of file qstring.cpp.

◆ isAscii_helper()

static bool isAscii_helper ( const char16_t *& ptr,
const char16_t * end )
static

Definition at line 858 of file qstring.cpp.

Referenced by QtPrivate::isAscii().

+ Here is the caller graph for this function:

◆ latin1nicmp()

static int latin1nicmp ( const char * lhsChar,
qsizetype lSize,
const char * rhsChar,
qsizetype rSize )
static

Definition at line 1368 of file qstring.cpp.

References QtPrivate::QCaseInsensitiveLatin1Hash::difference().

+ Here is the call graph for this function:

◆ needsReallocate()

static bool needsReallocate ( const QString & str,
qsizetype newSize )
static

Definition at line 2623 of file qstring.cpp.

◆ operator<<()

QDataStream & operator<< ( QDataStream & out,
const QString & str )
related

Definition at line 9503 of file qstring.cpp.

◆ operator>>()

QDataStream & operator>> ( QDataStream & in,
QString & str )
related

Definition at line 9534 of file qstring.cpp.

◆ parse_field_width()

static int parse_field_width ( const char *& c,
qsizetype size )
static

Definition at line 7387 of file qstring.cpp.

◆ parse_flag_characters()

◆ parse_length_modifier()

static LengthMod parse_length_modifier ( const char *& c)
staticnoexcept

Definition at line 7415 of file qstring.cpp.

References can_consume(), lm_h, lm_hh, lm_j, lm_L, lm_l, lm_ll, lm_none, lm_t, and lm_z.

+ Here is the call graph for this function:

◆ Q_DECLARE_TYPEINFO()

Q_DECLARE_TYPEINFO ( Part ,
Q_PRIMITIVE_TYPE  )

◆ qArgDigitValue()

static int qArgDigitValue ( QChar ch)
staticnoexcept

Definition at line 1626 of file qstring.cpp.

◆ qFindStringBoyerMoore()

qsizetype qFindStringBoyerMoore ( QStringView haystack,
qsizetype haystackOffset,
QStringView needle,
Qt::CaseSensitivity cs )

Definition at line 322 of file qstringmatcher.cpp.

◆ qt_convert_to_latin1()

static Q_NEVER_INLINE QByteArray qt_convert_to_latin1 ( QStringView string)
static

Definition at line 5656 of file qstring.cpp.

◆ qt_convert_to_local_8bit()

static QByteArray qt_convert_to_local_8bit ( QStringView string)
static

Definition at line 5768 of file qstring.cpp.

◆ qt_convert_to_ucs4()

static QList< uint > qt_convert_to_ucs4 ( QStringView string)
static

Definition at line 5861 of file qstring.cpp.

References QStringIterator::hasNext(), and QStringIterator::next().

+ Here is the call graph for this function:

◆ qt_convert_to_utf8()

static QByteArray qt_convert_to_utf8 ( QStringView str)
static

Definition at line 5814 of file qstring.cpp.

◆ qt_from_latin1()

QT_BEGIN_NAMESPACE void qt_from_latin1 ( char16_t * dst,
const char * str,
size_t size )
noexcept

Definition at line 920 of file qstring.cpp.

◆ qt_from_latin1_to_qvla()

static QVarLengthArray< char16_t > qt_from_latin1_to_qvla ( QLatin1StringView str)
static

Definition at line 995 of file qstring.cpp.

◆ qt_is_ascii()

bool qt_is_ascii ( const char *& ptr,
const char * end )
noexcept

Definition at line 786 of file qstring.cpp.

Referenced by QtPrivate::isAscii().

+ Here is the caller graph for this function:

◆ qt_string_normalize()

◆ qt_to_latin1()

void qt_to_latin1 ( uchar * dst,
const char16_t * src,
qsizetype length )

Definition at line 1183 of file qstring.cpp.

◆ qt_to_latin1_internal()

template<bool Checked>
static void qt_to_latin1_internal ( uchar * dst,
const char16_t * src,
qsizetype length )
static

Definition at line 1004 of file qstring.cpp.

◆ qt_to_latin1_unchecked()

void qt_to_latin1_unchecked ( uchar * dst,
const char16_t * src,
qsizetype length )

Definition at line 1188 of file qstring.cpp.

◆ removeStringImpl()

template<typename T>
static void removeStringImpl ( QString & s,
const T & needle,
Qt::CaseSensitivity cs )
static

Definition at line 3487 of file qstring.cpp.

◆ replace_helper()

static void replace_helper ( QString & str,
QSpan< size_t > indices,
qsizetype blen,
QStringView after )
static

Definition at line 3751 of file qstring.cpp.

◆ replace_in_place()

static void replace_in_place ( QString & str,
QSpan< size_t > indices,
qsizetype blen,
QStringView after )
static

Definition at line 3707 of file qstring.cpp.

◆ replace_with_copy()

static void replace_with_copy ( QString & str,
QSpan< size_t > indices,
qsizetype blen,
QStringView after )
static

Instead of detaching, or reallocating if "before" is shorter than "after" and there isn't enough capacity, create a new string, copy characters to it as needed, then swap it with "str".

Definition at line 3684 of file qstring.cpp.

◆ replaceArgEscapes()

static QString replaceArgEscapes ( QStringView s,
const ArgEscapeData & d,
qsizetype field_width,
QStringView arg,
QStringView larg,
QChar fillChar )
static

Definition at line 8683 of file qstring.cpp.

References ArgEscapeData::min_escape.

◆ to_unicode() [1/2]

static char16_t to_unicode ( const char c)
inlinestatic

Definition at line 9002 of file qstring.cpp.

References QLatin1Char::QLatin1Char(), and QLatin1Char::unicode().

+ Here is the call graph for this function:

◆ to_unicode() [2/2]

static char16_t to_unicode ( const QChar c)
inlinestatic

Definition at line 9001 of file qstring.cpp.

◆ toIntegral()

template<typename Int>
static Int toIntegral ( QStringView string,
bool * ok,
int base )
static

Definition at line 7725 of file qstring.cpp.

◆ ucstrcmp()

template<typename Char2>
static int ucstrcmp ( const char16_t * a,
size_t alen,
const Char2 * b,
size_t blen )
static

Definition at line 1359 of file qstring.cpp.

◆ ucstreq()

template<typename Char2>
static bool ucstreq ( const char16_t * a,
size_t alen,
const Char2 * b )
static

Definition at line 1352 of file qstring.cpp.

◆ ucstricmp() [1/2]

static Q_NEVER_INLINE int ucstricmp ( qsizetype alen,
const char16_t * a,
qsizetype blen,
const char * b )
static

Definition at line 1221 of file qstring.cpp.

◆ ucstricmp() [2/2]

static Q_NEVER_INLINE int ucstricmp ( qsizetype alen,
const char16_t * a,
qsizetype blen,
const char16_t * b )
static

Definition at line 1194 of file qstring.cpp.

◆ ucstricmp8()

static Q_NEVER_INLINE int ucstricmp8 ( const char * utf8,
const char * utf8end,
const QChar * utf16,
const QChar * utf16end )
static

Definition at line 1239 of file qstring.cpp.

References QStringIterator::hasNext().

+ Here is the call graph for this function:

◆ ucstrncmp() [1/2]

template<StringComparisonMode Mode>
static int ucstrncmp ( const char16_t * a,
const char * b,
size_t l )
static

Definition at line 1330 of file qstring.cpp.

◆ ucstrncmp() [2/2]

template<StringComparisonMode Mode>
static int ucstrncmp ( const char16_t * a,
const char16_t * b,
size_t l )
static

Definition at line 1277 of file qstring.cpp.