28 #if !defined(_OS_WIN32_) || defined(__MINGW32__) 32 #if defined(_OS_SUN_) && defined(_CC_GNU_) 44 #if defined(_OS_HPUX_) 49 inline char *hack_strstr(
const char *s1,
const char *s2 )
50 {
return (
char *)strstr(s1, s2); }
51 inline char *hack_strchr(
const char *
s,
int c )
52 {
return (
char *)strchr(s, c); }
53 inline char *hack_strrchr(
const char *s,
int c )
54 {
return (
char *)strrchr(s, c); }
55 #define strstr(s1,s2) hack_strstr((s1),(s2)) 56 #define strchr(s,c) hack_strchr((s),(c)) 57 #define strrchr(s,c) hack_strrchr((s),(c)) 66 #if defined(_OS_SUN_) || defined(_CC_OC_) 67 #define memmove(s1,s2,n) qmemmove((s1),(s2),(n)) 70 #if defined(_OS_WIN32_) 71 #define qsnprintf _snprintf 73 #define qsnprintf snprintf 79 {
return (
uint)strlen(str); }
82 {
return str ? (
uint)strlen(str) : 0; }
85 {
return strcpy(dst,src); }
88 {
return src ? strcpy(dst, src) : 0; }
93 {
return strcmp(str1,str2); }
96 {
return (str1 && str2) ?
strcmp(str1,str2) : (
int)((intptr_t)str2 - (intptr_t)str1); }
99 {
return strncmp(str1,str2,len); }
102 {
return (str1 && str2) ? strncmp(str1,str2,len) :
103 (
int)((intptr_t)str2 - (intptr_t)str1); }
113 #if defined(Q_TEMPLATEDLL) 121 #ifndef QT_NO_DATASTREAM 185 return m_rep.isEmpty();
191 return m_rep.isEmpty();
197 return m_rep.length();
203 return m_rep.length();
218 return m_rep.rawData();
227 m_rep.resize(newlen);
243 bool fill(
char c,
int len = -1 )
259 int find(
char c,
int index=0,
bool cs=
TRUE )
const;
263 int findRev(
char c,
int index=-1,
bool cs=
TRUE)
const;
264 int findRev(
const char *str,
int index=-1,
bool cs=
TRUE)
const;
266 int contains(
char c,
bool cs=
TRUE )
const;
267 int contains(
const char *str,
bool cs=
TRUE )
const;
268 int contains(
const QRegExp &rx )
const;
269 bool stripPrefix(
const char *
prefix);
276 QCString simplifyWhiteSpace()
const;
277 QCString &assign(
const char *str );
285 short toShort(
bool *ok=0 )
const;
286 ushort toUShort(
bool *ok=0 )
const;
287 int toInt(
bool *ok=0 )
const;
288 uint toUInt(
bool *ok=0 )
const;
289 long toLong(
bool *ok=0 )
const;
290 ulong toULong(
bool *ok=0 )
const;
291 uint64 toUInt64(
bool *ok=0 )
const;
300 operator const char *()
const 302 return (
const char *)
data();
308 if (!str)
return *
this;
310 int len2 = (
int)strlen(str);
312 memcpy(rawData()+len1,str,len2);
334 return m_rep.at((
uint)i);
349 #define SHORT_STR_CAPACITY ((int)sizeof(LongStringRep)-2) 350 #define SHORT_STR_MAX_LEN (SHORT_STR_CAPACITY-1) 371 return (
char*)(
this+1);
382 data->
toStr()[size-1] = 0;
388 if (--refCount<0) free(
this);
399 d->
toStr()[size-1] = 0;
404 LSData *newData = LSData::create(size);
406 if (len>=size) len=size-1;
408 newData->
toStr()[len]=0;
464 u.s.str[size-1]=
'\0';
473 u.l.d = LSData::create(size);
480 int len = (
int)strlen(str);
482 if (len<SHORT_STR_CAPACITY)
485 qstrncpy(u.s.str,str,SHORT_STR_CAPACITY);
489 u.l.d = LSData::create(len+1);
490 memcpy(u.l.d->toStr(),
str,u.l.d->len);
503 if (len>maxlen) len=
maxlen;
508 memcpy(u.s.str,str,len);
513 u.l.d = LSData::create(len+1);
514 memcpy(u.l.d->toStr(),
str,len);
556 int len = (
int)strlen(str);
558 if (len<SHORT_STR_CAPACITY)
561 qstrncpy(u.s.str,str,SHORT_STR_CAPACITY);
565 u.l.d = LSData::create(len+1);
566 memcpy(u.l.d->toStr(),
str,len);
577 return u.s.isShort && u.s.len==0;
581 uint l = u.s.isShort ? u.s.len : u.l.d->len;
588 return u.s.len==0 ? 0 : u.s.str;
592 return u.l.d->len==0 ? 0 : u.l.d->toStr();
599 return u.s.len==0 ? 0 : (
char*)u.s.str;
604 return u.l.d->len==0 ? 0 : u.l.d->toStr();
607 char &
at(
int i)
const 611 return (
char&)u.s.str[i];
615 return u.l.d->toStr()[i];
625 u.s.str[newlen-1]=
'\0';
632 else if (u.s.isShort)
636 u.l.d = LSData::create(newlen);
639 memcpy(u.l.d->toStr(),tmp.
u.
s.
str,tmp.
u.
s.
len+1);
643 u.l.d->toStr()[0]=
'\0';
651 memcpy(tmp.
u.
s.
str,u.l.d->toStr(),newlen-1);
652 tmp.
u.
s.
str[newlen-1]=
'\0';
664 u.l.d = u.l.d->resize(u.l.d,newlen);
675 else if (len!=(
int)
length())
684 memset(rawData(),c,len);
702 #ifndef QT_NO_DATASTREAM 799 if (s)
return s;
else return "";
Q_EXPORT char * qstrncpy(char *src, const char *dst, uint len)
int operator>(QChar c1, QChar c2)
Q_EXPORT int qstrncmp(const char *str1, const char *str2, uint len)
QDataStream & operator<<(QDataStream &s, const QString &str)
Q_EXPORT QDataStream & operator>>(QDataStream &, QByteArray &)
StringRep(const char *str)
StringRep(const StringRep &s)
QCString(const QCString &s)
Q_EXPORT int qstrnicmp(const char *str1, const char *str2, uint len)
QCString & operator+=(const char *str)
char str[SHORT_STR_CAPACITY]
The QRegExp class provides pattern matching using regular expressions or wildcards.
QCString & operator+=(char c)
static bool format(QChar::Decomposition tag, QString &str, int index, int len)
int operator<(QChar c1, QChar c2)
const char * data() const
static LSData * resize(LSData *d, int size)
Q_EXPORT uint cstrlen(const char *str)
QCString & operator=(const char *str)
void resize(Vector< T > &vec1, Index n1, const V &val)
QCString(const char *str)
StringRep & operator=(const StringRep &s)
Q_EXPORT int qstricmp(const char *str1, const char *str2)
QCString & operator=(const QCString &s)
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
bool operator<=(const QString &s1, const char *s2)
Q_EXPORT uint qstrlen(const char *str)
char & operator[](int i) const
static LSData * create(int size)
QString operator+(const QString &s1, const QString &s2)
const char * data() const
QCString(const char *str, uint maxlen)
#define SHORT_STR_MAX_LEN
int operator>=(QChar c1, QChar c2)
bool operator==(const QString &s1, const QString &s2)
Q_EXPORT char * cstrcpy(char *dst, const char *src)
int strcmp(const String &s1, const String &s2)
Q_EXPORT int cstrcmp(const char *str1, const char *str2)
bool fill(char c, int len=-1)
Q_EXPORT char * qstrcpy(char *dst, const char *src)
bool operator!=(const QString &s1, const QString &s2)
StringRep & operator=(const char *str)
The QDataStream class provides serialization of binary data to a QIODevice.
Q_EXPORT int cstrncmp(const char *str1, const char *str2, uint len)
Q_EXPORT void * qmemmove(void *dst, const void *src, uint len)
StringRep(const char *str, uint maxlen)
#define SHORT_STR_CAPACITY
union QCString::StringRep::ShortOrLongStringSelector u
QArray< char > QByteArray
unsigned long long uint64
Q_EXPORT int qstrcmp(const char *str1, const char *str2)
Q_EXPORT char * qstrdup(const char *)
bool fill(char c, int len)
const char * qPrint(const char *s)