Classes | Public Member Functions | Private Attributes | List of all members
QCString Class Reference

#include <qcstring.h>

Classes

struct  LongStringRep
 
struct  LSData
 
struct  LSHeader
 
struct  ShortStringRep
 
class  StringRep
 

Public Member Functions

 QCString ()
 
 ~QCString ()
 
 QCString (const QCString &s)
 
 QCString (int size)
 
 QCString (const char *str)
 
 QCString (const char *str, uint maxlen)
 
QCStringoperator= (const QCString &s)
 
QCStringoperator= (const char *str)
 
bool isNull () const
 
bool isEmpty () const
 
uint length () const
 
uint size () const
 
const char * data () const
 
char * rawData () const
 
bool resize (uint newlen)
 
bool truncate (uint pos)
 
bool fill (char c, int len=-1)
 
QCString copy () const
 
QCStringsprintf (const char *format,...)
 
int find (char c, int index=0, bool cs=TRUE) const
 
int find (const char *str, int index=0, bool cs=TRUE) const
 
int find (const QCString &str, int index=0, bool cs=TRUE) const
 
int find (const QRegExp &rx, int index=0) const
 
int findRev (char c, int index=-1, bool cs=TRUE) const
 
int findRev (const char *str, int index=-1, bool cs=TRUE) const
 
int findRev (const QRegExp &rx, int index=-1) const
 
int contains (char c, bool cs=TRUE) const
 
int contains (const char *str, bool cs=TRUE) const
 
int contains (const QRegExp &rx) const
 
bool stripPrefix (const char *prefix)
 
QCString left (uint len) const
 
QCString right (uint len) const
 
QCString mid (uint index, uint len=0xffffffff) const
 
QCString lower () const
 
QCString upper () const
 
QCString stripWhiteSpace () const
 
QCString simplifyWhiteSpace () const
 
QCStringassign (const char *str)
 
QCStringinsert (uint index, const char *s)
 
QCStringinsert (uint index, char c)
 
QCStringappend (const char *s)
 
QCStringprepend (const char *s)
 
QCStringremove (uint index, uint len)
 
QCStringreplace (uint index, uint len, const char *s)
 
QCStringreplace (const QRegExp &rx, const char *str)
 
short toShort (bool *ok=0) const
 
ushort toUShort (bool *ok=0) const
 
int toInt (bool *ok=0) const
 
uint toUInt (bool *ok=0) const
 
long toLong (bool *ok=0) const
 
ulong toULong (bool *ok=0) const
 
uint64 toUInt64 (bool *ok=0) const
 
QCStringsetNum (short n)
 
QCStringsetNum (ushort n)
 
QCStringsetNum (int n)
 
QCStringsetNum (uint n)
 
QCStringsetNum (long n)
 
QCStringsetNum (ulong n)
 
 operator const char * () const
 
QCStringoperator+= (const char *str)
 
QCStringoperator+= (char c)
 
char & at (uint i) const
 
char & operator[] (int i) const
 

Private Attributes

StringRep m_rep
 

Detailed Description

This is an alternative implementation of QCString. It provides basically the same functions but uses reference counting and copy on write.

Definition at line 131 of file qcstring.h.

Constructor & Destructor Documentation

QCString::QCString ( )
inline

creates an empty string

Definition at line 135 of file qcstring.h.

135  : m_rep()
136  {
137  }
StringRep m_rep
Definition: qcstring.h:695
QCString::~QCString ( )
inline

destroys the string

Definition at line 140 of file qcstring.h.

141  {
142  }
QCString::QCString ( const QCString s)
inline

makes a copy of a string.

Definition at line 145 of file qcstring.h.

145  : m_rep(s.m_rep)
146  {
147  }
StringRep m_rep
Definition: qcstring.h:695
QCString::QCString ( int  size)
inlineexplicit

creates a string with room for size characters

Parameters
[in]sizethe number of character to allocate (including the 0-terminator)

Definition at line 152 of file qcstring.h.

152  : m_rep(size)
153  {
154  }
StringRep m_rep
Definition: qcstring.h:695
uint size() const
Definition: qcstring.h:201
QCString::QCString ( const char *  str)
inline

creates a string from a plain C string.

Parameters
[in]strA zero terminated C string. When 0 an empty string is created.

Definition at line 159 of file qcstring.h.

159  : m_rep(str)
160  {
161  }
StringRep m_rep
Definition: qcstring.h:695
static QCString str
QCString::QCString ( const char *  str,
uint  maxlen 
)
inline

creates a string from str and copies over the first maxlen characters.

Definition at line 164 of file qcstring.h.

164  : m_rep(str,maxlen)
165  {
166  }
StringRep m_rep
Definition: qcstring.h:695
static const int maxlen
Definition: qregexp.cpp:904
static QCString str

Member Function Documentation

QCString & QCString::append ( const char *  s)

Definition at line 383 of file qcstring.cpp.

384 {
385  return operator+=(s);
386 }
QCString & operator+=(const char *str)
Definition: qcstring.h:306
static QCString * s
Definition: config.cpp:1042
QCString & QCString::assign ( const char *  str)

Definition at line 350 of file qcstring.cpp.

351 {
352  return operator=(str);
353 }
QCString & operator=(const QCString &s)
Definition: qcstring.h:169
static QCString str
char& QCString::at ( uint  i) const
inline

Returns a reference to the character at index i.

Definition at line 326 of file qcstring.h.

327  {
328  return m_rep.at(i);
329  }
StringRep m_rep
Definition: qcstring.h:695
char & at(int i) const
Definition: qcstring.h:607
int QCString::contains ( char  c,
bool  cs = TRUE 
) const

Definition at line 153 of file qcstring.cpp.

154 {
155  if (length()==0) return 0;
156  int count=0;
157  const char *pos = data();
158  if (cs)
159  {
160  while (*pos) if (*pos++ == c) count++;
161  }
162  else
163  {
164  c = tolower((unsigned char)c);
165  while (*pos)
166  {
167  if (tolower((unsigned char)*pos)==c) count++;
168  pos++;
169  }
170  }
171  return count;
172 }
uint length() const
Definition: qcstring.h:195
const char * data() const
Definition: qcstring.h:207
const char * cs
int QCString::contains ( const char *  str,
bool  cs = TRUE 
) const

Definition at line 174 of file qcstring.cpp.

175 {
176  if (str==0 || length()==0) return 0;
177  int count=0;
178  const char *pos = data();
179  int len = qstrlen(str);
180  while (*pos)
181  {
182  if (cs)
183  {
184  if (qstrncmp(pos,str,len)==0) count++;
185  }
186  else
187  {
188  if (qstrnicmp(pos,str,len)==0) count++;
189  }
190  pos++;
191  }
192  return count;
193 }
Q_EXPORT int qstrncmp(const char *str1, const char *str2, uint len)
Definition: qcstring.h:101
uint length() const
Definition: qcstring.h:195
Q_EXPORT uint qstrlen(const char *str)
Definition: qcstring.h:81
const char * data() const
Definition: qcstring.h:207
int qstrnicmp(const char *str1, const char *str2, uint len)
Definition: qcstring.cpp:581
const char * cs
static QCString str
int QCString::contains ( const QRegExp rx) const

Definition at line 195 of file qcstring.cpp.

196 {
198  return d.contains( rx );
199 }
The QString class provides an abstraction of Unicode text and the classic C null-terminated char arra...
Definition: qstring.h:350
static QString fromLatin1(const char *, int len=-1)
Definition: qstring.cpp:14539
int contains(QChar c, bool cs=TRUE) const
Definition: qstring.cpp:13104
const char * data() const
Definition: qcstring.h:207
QCString QCString::copy ( ) const
inline

Returns a deep copy of the string.

Definition at line 250 of file qcstring.h.

251  {
252  if (length()==0) return QCString();
253  QCString cs(length()+1);
254  memcpy(cs.rawData(),data(),length());
255  return cs;
256  }
uint length() const
Definition: qcstring.h:195
QCString()
Definition: qcstring.h:135
const char * data() const
Definition: qcstring.h:207
const char * cs
const char* QCString::data ( ) const
inline

Returns a pointer to the contents of the string in the form of a 0-terminated C string

Definition at line 207 of file qcstring.h.

208  {
209  return m_rep.data();
210  }
StringRep m_rep
Definition: qcstring.h:695
const char * data() const
Definition: qcstring.h:584
bool QCString::fill ( char  c,
int  len = -1 
)
inline

Fills a string with a predefined character

Parameters
[in]cthe character used to fill the string with.
[in]lenthe number of character to fill. Use -1 to fill the whole string.
Note
the string will be resized to contain len characters. The contents of the string will be lost.

Definition at line 243 of file qcstring.h.

244  {
245  m_rep.fill(c,len);
246  return TRUE;
247  }
StringRep m_rep
Definition: qcstring.h:695
bool fill(char c, int len)
Definition: qcstring.h:668
const bool TRUE
Definition: qglobal.h:371
int QCString::find ( char  c,
int  index = 0,
bool  cs = TRUE 
) const

Definition at line 41 of file qcstring.cpp.

42 {
43  if (index<0 || index>=(int)length()) return -1; // index outside string
44  register const char *pos;
45  if (cs)
46  {
47  pos = strchr(data()+index,c);
48  }
49  else
50  {
51  pos = data()+index;
52  c = tolower((unsigned char)c);
53  while (*pos && tolower((unsigned char)*pos)!=c) pos++;
54  if (!*pos && c) pos=0; // not found
55  }
56  return pos ? (int)(pos - data()) : -1;
57 }
uint length() const
Definition: qcstring.h:195
const char * data() const
Definition: qcstring.h:207
const char * cs
int QCString::find ( const char *  str,
int  index = 0,
bool  cs = TRUE 
) const

Definition at line 59 of file qcstring.cpp.

60 {
61  int l = length();
62  if (index<0 || index>=l) return -1; // index outside string
63  if (!str) return -1; // no string to search for
64  if (!*str) return index; // empty string matching at index
65  register const char *pos;
66  if (cs) // case sensitive
67  {
68  pos = strstr(data()+index,str);
69  }
70  else // case insensitive
71  {
72  pos = data();
73  int len = qstrlen(str);
74  while (*pos)
75  {
76  if (qstrnicmp(pos,str,len)==0) break;
77  pos++;
78  }
79  if (!*pos) pos = 0; // not found
80  }
81  return pos ? (int)(pos - data()) : -1;
82 }
uint length() const
Definition: qcstring.h:195
static QStrList * l
Definition: config.cpp:1044
Q_EXPORT uint qstrlen(const char *str)
Definition: qcstring.h:81
const char * data() const
Definition: qcstring.h:207
int qstrnicmp(const char *str1, const char *str2, uint len)
Definition: qcstring.cpp:581
const char * cs
static QCString str
int QCString::find ( const QCString str,
int  index = 0,
bool  cs = TRUE 
) const

Definition at line 84 of file qcstring.cpp.

85 {
86  return find(str.data(),index,cs);
87 }
int find(char c, int index=0, bool cs=TRUE) const
Definition: qcstring.cpp:41
const char * data() const
Definition: qcstring.h:207
const char * cs
int QCString::find ( const QRegExp rx,
int  index = 0 
) const

Definition at line 89 of file qcstring.cpp.

90 {
92  return d.find( rx, index );
93 }
The QString class provides an abstraction of Unicode text and the classic C null-terminated char arra...
Definition: qstring.h:350
static QString fromLatin1(const char *, int len=-1)
Definition: qstring.cpp:14539
const char * data() const
Definition: qcstring.h:207
int find(QChar c, int index=0, bool cs=TRUE) const
Definition: qstring.cpp:12902
int QCString::findRev ( char  c,
int  index = -1,
bool  cs = TRUE 
) const

Definition at line 95 of file qcstring.cpp.

96 {
97  const char *b = data();
98  const char *pos;
99  int len = length();
100  if (len==0) return -1; // empty string
101  if (index<0) // start from end
102  {
103  if (cs)
104  {
105  pos = strrchr(b,c);
106  return pos ? (int)(pos - b) : -1;
107  }
108  index=len;
109  }
110  else if (index>len) // bad index
111  {
112  return -1;
113  }
114  pos = b+index;
115  if (cs)
116  {
117  while ( pos>=b && *pos!=c) pos--;
118  }
119  else
120  {
121  c = tolower((unsigned char)c);
122  while ( pos>=b && tolower((unsigned char)*pos)!=c) pos--;
123  }
124  return pos>=b ? (int)(pos - b) : -1;
125 }
uint length() const
Definition: qcstring.h:195
const char * data() const
Definition: qcstring.h:207
static bool * b
Definition: config.cpp:1043
const char * cs
int QCString::findRev ( const char *  str,
int  index = -1,
bool  cs = TRUE 
) const

Definition at line 127 of file qcstring.cpp.

128 {
129  int slen = qstrlen(str);
130  int len = length();
131  if (index<0) index = len-slen; // start from end
132  else if (index>len) return -1; // bad index
133  else if (index+slen>len) index=len-slen; // str would be too long
134  if (index<0) return -1; // no match possible
135  register const char *pos = data()+index;
136  if (cs) // case sensitive
137  {
138  for (int i=index; i>=0; i--) if (qstrncmp(pos--,str,slen)==0) return i;
139  }
140  else // case insensitive
141  {
142  for (int i=index; i>=0; i--) if (qstrnicmp(pos,str,slen)==0) return i;
143  }
144  return -1;
145 }
Q_EXPORT int qstrncmp(const char *str1, const char *str2, uint len)
Definition: qcstring.h:101
uint length() const
Definition: qcstring.h:195
Q_EXPORT uint qstrlen(const char *str)
Definition: qcstring.h:81
const char * data() const
Definition: qcstring.h:207
int qstrnicmp(const char *str1, const char *str2, uint len)
Definition: qcstring.cpp:581
const char * cs
static QCString str
int QCString::findRev ( const QRegExp rx,
int  index = -1 
) const

Definition at line 147 of file qcstring.cpp.

148 {
150  return d.findRev( rx, index );
151 }
The QString class provides an abstraction of Unicode text and the classic C null-terminated char arra...
Definition: qstring.h:350
static QString fromLatin1(const char *, int len=-1)
Definition: qstring.cpp:14539
const char * data() const
Definition: qcstring.h:207
int findRev(QChar c, int index=-1, bool cs=TRUE) const
Definition: qstring.cpp:13021
QCString & QCString::insert ( uint  index,
const char *  s 
)

Definition at line 355 of file qcstring.cpp.

356 {
357  int len = s ? qstrlen(s) : 0;
358  if ( len == 0 ) return *this;
359  int olen = length();
360  int nlen = olen + len;
361  if ((int)index>=olen)
362  {
363  resize(nlen+index-olen+1);
364  memset(rawData()+olen, ' ', index-olen);
365  memcpy(rawData()+index,s, len+1);
366  }
367  else
368  {
369  resize(nlen+1);
370  qmemmove(rawData()+index+len,data()+index,olen-index+1);
371  memcpy(rawData()+index,s,len);
372  }
373  return *this;
374 }
bool resize(uint newlen)
Definition: qcstring.h:225
char * rawData() const
Definition: qcstring.h:216
uint length() const
Definition: qcstring.h:195
Q_EXPORT uint qstrlen(const char *str)
Definition: qcstring.h:81
const char * data() const
Definition: qcstring.h:207
void * qmemmove(void *dst, const void *src, uint len)
Definition: qcstring.cpp:530
static QCString * s
Definition: config.cpp:1042
QCString & QCString::insert ( uint  index,
char  c 
)

Definition at line 376 of file qcstring.cpp.

377 {
378  char buf[2];
379  buf[0] = c;
380  buf[1] = '\0';
381  return insert( index, buf );
382 }
QCString & insert(uint index, const char *s)
Definition: qcstring.cpp:355
bool QCString::isEmpty ( ) const
inline

Returns TRUE iff the string is empty

Definition at line 189 of file qcstring.h.

190  {
191  return m_rep.isEmpty();
192  }
StringRep m_rep
Definition: qcstring.h:695
bool isEmpty() const
Definition: qcstring.h:575
bool QCString::isNull ( ) const
inline

Returns TRUE iff the string is empty. Equivalent to isEmpty().

Definition at line 183 of file qcstring.h.

184  {
185  return m_rep.isEmpty();
186  }
StringRep m_rep
Definition: qcstring.h:695
bool isEmpty() const
Definition: qcstring.h:575
QCString QCString::left ( uint  len) const

Definition at line 213 of file qcstring.cpp.

214 {
215  if (isEmpty())
216  {
217  return QCString();
218  }
219  else if (len>=length())
220  {
221  return QCString(data());
222  }
223  else
224  {
225  QCString s( len+1 );
226  memcpy( s.rawData(), data(), len);
227  return s;
228  }
229 }
char * rawData() const
Definition: qcstring.h:216
bool isEmpty() const
Definition: qcstring.h:189
uint length() const
Definition: qcstring.h:195
QCString()
Definition: qcstring.h:135
const char * data() const
Definition: qcstring.h:207
static QCString * s
Definition: config.cpp:1042
uint QCString::length ( ) const
inline

Returns the length of the string, excluding the 0-terminator. Equivalent to size().

Definition at line 195 of file qcstring.h.

196  {
197  return m_rep.length();
198  }
StringRep m_rep
Definition: qcstring.h:695
uint length() const
Definition: qcstring.h:579
QCString QCString::lower ( ) const

Definition at line 263 of file qcstring.cpp.

264 {
265  if (length()==0) return QCString();
266  QCString s(data());
267  register char *pos = s.rawData();
268  if (pos)
269  {
270  while (*pos)
271  {
272  *pos = tolower((unsigned char)*pos);
273  pos++;
274  }
275  }
276  return s;
277 }
char * rawData() const
Definition: qcstring.h:216
uint length() const
Definition: qcstring.h:195
QCString()
Definition: qcstring.h:135
const char * data() const
Definition: qcstring.h:207
static QCString * s
Definition: config.cpp:1042
QCString QCString::mid ( uint  index,
uint  len = 0xffffffff 
) const

Definition at line 246 of file qcstring.cpp.

247 {
248  uint slen = (uint)length();
249  if (len==0xffffffff) len = slen-index;
250  if (isEmpty() || index>=slen || len==0)
251  {
252  return QCString();
253  }
254  else
255  {
256  register const char *p = data()+index;
257  QCString s(len+1);
258  qstrncpy( s.rawData(), p, len+1 );
259  return s;
260  }
261 }
char * rawData() const
Definition: qcstring.h:216
char * qstrncpy(char *dst, const char *src, uint len)
Definition: qcstring.cpp:557
bool isEmpty() const
Definition: qcstring.h:189
uint length() const
Definition: qcstring.h:195
QCString()
Definition: qcstring.h:135
p
Definition: test.py:223
const char * data() const
Definition: qcstring.h:207
unsigned uint
Definition: qglobal.h:351
static QCString * s
Definition: config.cpp:1042
QCString::operator const char * ( ) const
inline

Converts the string to a plain C string

Definition at line 300 of file qcstring.h.

301  {
302  return (const char *)data();
303  }
const char * data() const
Definition: qcstring.h:207
QCString& QCString::operator+= ( const char *  str)
inline

Appends string str to this string and returns a reference to the result.

Definition at line 306 of file qcstring.h.

307  {
308  if (!str) return *this;
309  int len1 = length();
310  int len2 = (int)strlen(str);
311  resize(len1+len2+1);
312  memcpy(rawData()+len1,str,len2);
313  return *this;
314  }
bool resize(uint newlen)
Definition: qcstring.h:225
char * rawData() const
Definition: qcstring.h:216
uint length() const
Definition: qcstring.h:195
static QCString str
QCString& QCString::operator+= ( char  c)
inline

Appends character c to this string and returns a reference to the result.

Definition at line 317 of file qcstring.h.

318  {
319  int len = length();
320  resize(len+2);
321  rawData()[len]=c;
322  return *this;
323  }
bool resize(uint newlen)
Definition: qcstring.h:225
char * rawData() const
Definition: qcstring.h:216
uint length() const
Definition: qcstring.h:195
QCString& QCString::operator= ( const QCString s)
inline

replaces the contents by that of string s.

Definition at line 169 of file qcstring.h.

170  {
171  m_rep = s.m_rep;
172  return *this;
173  }
StringRep m_rep
Definition: qcstring.h:695
QCString& QCString::operator= ( const char *  str)
inline

replaces the contents by that of C string str.

Definition at line 176 of file qcstring.h.

177  {
178  m_rep = str;
179  return *this;
180  }
StringRep m_rep
Definition: qcstring.h:695
static QCString str
char& QCString::operator[] ( int  i) const
inline

Indexing operator. Equavalent to at().

Definition at line 332 of file qcstring.h.

333  {
334  return m_rep.at((uint)i);
335  }
StringRep m_rep
Definition: qcstring.h:695
char & at(int i) const
Definition: qcstring.h:607
unsigned uint
Definition: qglobal.h:351
QCString & QCString::prepend ( const char *  s)

Definition at line 387 of file qcstring.cpp.

388 {
389  return insert(0,s);
390 }
QCString & insert(uint index, const char *s)
Definition: qcstring.cpp:355
static QCString * s
Definition: config.cpp:1042
char* QCString::rawData ( ) const
inline

Returns a writable pointer to the data.

Warning
if the string is shared it will modifying the string directly and this will overwrite all copies as well!

Definition at line 216 of file qcstring.h.

217  {
218  return m_rep.rawData();
219  }
StringRep m_rep
Definition: qcstring.h:695
char * rawData() const
Definition: qcstring.h:595
QCString & QCString::remove ( uint  index,
uint  len 
)

Definition at line 391 of file qcstring.cpp.

392 {
393  uint olen = length();
394  if ( index + len >= olen ) // range problems
395  {
396  if ( index < olen ) // index ok
397  {
398  resize( index+1 );
399  }
400  }
401  else if ( len != 0 )
402  {
403  QCString tmp(olen-index-len+1);
404  qmemmove( tmp.rawData(), data()+index+len, olen-index-len+1 );
405  resize( olen-len+1 );
406  memcpy( rawData()+index,tmp.data(),tmp.length() );
407  }
408  return *this;
409 }
bool resize(uint newlen)
Definition: qcstring.h:225
char * rawData() const
Definition: qcstring.h:216
uint length() const
Definition: qcstring.h:195
const char * data() const
Definition: qcstring.h:207
string tmp
Definition: languages.py:63
void * qmemmove(void *dst, const void *src, uint len)
Definition: qcstring.cpp:530
unsigned uint
Definition: qglobal.h:351
QCString & QCString::replace ( uint  index,
uint  len,
const char *  s 
)

Definition at line 411 of file qcstring.cpp.

412 {
413  remove( index, len );
414  insert( index, s );
415  return *this;
416 }
QCString & insert(uint index, const char *s)
Definition: qcstring.cpp:355
static QCString * s
Definition: config.cpp:1042
QCString & QCString::replace ( const QRegExp rx,
const char *  str 
)

Definition at line 418 of file qcstring.cpp.

419 {
422  d.replace( rx, r );
423  operator=( d.ascii() );
424  return *this;
425 }
The QString class provides an abstraction of Unicode text and the classic C null-terminated char arra...
Definition: qstring.h:350
static QString fromLatin1(const char *, int len=-1)
Definition: qstring.cpp:14539
QCString & operator=(const QCString &s)
Definition: qcstring.h:169
const char * ascii() const
Definition: qstring.cpp:14494
QString & replace(uint index, uint len, const QString &)
Definition: qstring.cpp:13665
const char * data() const
Definition: qcstring.h:207
static QCString str
bool QCString::resize ( uint  newlen)
inline

Resizes the string to hold newlen characters (this value should include the 0-terminator). If the string is enlarged the contents will be left unmodified.

Definition at line 225 of file qcstring.h.

226  {
227  m_rep.resize(newlen);
228  return TRUE;
229  }
StringRep m_rep
Definition: qcstring.h:695
bool resize(uint newlen)
Definition: qcstring.h:618
const bool TRUE
Definition: qglobal.h:371
QCString QCString::right ( uint  len) const

Definition at line 231 of file qcstring.cpp.

232 {
233  if (isEmpty())
234  {
235  return QCString();
236  }
237  else
238  {
239  int l = length();
240  if ((int)len>l) len=l;
241  const char *pos = data() + (l-len);
242  return QCString(pos);
243  }
244 }
bool isEmpty() const
Definition: qcstring.h:189
uint length() const
Definition: qcstring.h:195
QCString()
Definition: qcstring.h:135
static QStrList * l
Definition: config.cpp:1044
const char * data() const
Definition: qcstring.h:207
QCString & QCString::setNum ( short  n)

Definition at line 469 of file qcstring.cpp.

470 {
471  return setNum((long)n);
472 }
std::void_t< T > n
QCString & setNum(short n)
Definition: qcstring.cpp:469
QCString & QCString::setNum ( ushort  n)

Definition at line 474 of file qcstring.cpp.

475 {
476  return setNum((ulong)n);
477 }
std::void_t< T > n
unsigned long ulong
Definition: qglobal.h:352
QCString & setNum(short n)
Definition: qcstring.cpp:469
QCString & QCString::setNum ( int  n)

Definition at line 479 of file qcstring.cpp.

480 {
481  return setNum((long)n);
482 }
std::void_t< T > n
QCString & setNum(short n)
Definition: qcstring.cpp:469
QCString & QCString::setNum ( uint  n)

Definition at line 484 of file qcstring.cpp.

485 {
486  return setNum((ulong)n);
487 }
std::void_t< T > n
unsigned long ulong
Definition: qglobal.h:352
QCString & setNum(short n)
Definition: qcstring.cpp:469
QCString & QCString::setNum ( long  n)

Definition at line 489 of file qcstring.cpp.

490 {
491  char buf[20];
492  register char *p = &buf[19];
493  bool neg;
494  if ( n < 0 )
495  {
496  neg = TRUE;
497  n = -n;
498  }
499  else
500  {
501  neg = FALSE;
502  }
503  *p = '\0';
504  do
505  {
506  *--p = ((int)(n%10)) + '0';
507  n /= 10;
508  } while ( n );
509  if ( neg ) *--p = '-';
510  operator=( p );
511  return *this;
512 }
const bool FALSE
Definition: qglobal.h:370
QCString & operator=(const QCString &s)
Definition: qcstring.h:169
std::void_t< T > n
p
Definition: test.py:223
const bool TRUE
Definition: qglobal.h:371
QCString & QCString::setNum ( ulong  n)

Definition at line 514 of file qcstring.cpp.

515 {
516  char buf[20];
517  register char *p = &buf[19];
518  *p = '\0';
519  do
520  {
521  *--p = ((int)(n%10)) + '0';
522  n /= 10;
523  } while ( n );
524  operator=( p );
525  return *this;
526 }
QCString & operator=(const QCString &s)
Definition: qcstring.h:169
std::void_t< T > n
p
Definition: test.py:223
QCString QCString::simplifyWhiteSpace ( ) const

Definition at line 323 of file qcstring.cpp.

324 {
325  if ( isEmpty() ) // nothing to do
326  return *this;
327 
328  QCString result( length()+1 );
329  const char *from = data();
330  char *to = result.rawData();
331  char *first = to;
332  while ( TRUE )
333  {
334  while ( *from && isspace((uchar) *from) )
335  from++;
336  while ( *from && !isspace((uchar)*from) )
337  *to++ = *from++;
338  if ( *from )
339  *to++ = 0x20; // ' '
340  else
341  break;
342  }
343  if ( to > first && *(to-1) == 0x20 )
344  to--;
345  *to = '\0';
346  result.resize( (int)((long)to - (long)result.data()) + 1 );
347  return result;
348 }
bool resize(uint newlen)
Definition: qcstring.h:225
char * rawData() const
Definition: qcstring.h:216
static QCString result
bool isEmpty() const
Definition: qcstring.h:189
uint length() const
Definition: qcstring.h:195
unsigned char uchar
Definition: nybbler.cc:11
const char * data() const
Definition: qcstring.h:207
const bool TRUE
Definition: qglobal.h:371
uint QCString::size ( ) const
inline

Returns the length of the string, excluding the 0-terminator.

Definition at line 201 of file qcstring.h.

202  {
203  return m_rep.length();
204  }
StringRep m_rep
Definition: qcstring.h:695
uint length() const
Definition: qcstring.h:579
QCString & QCString::sprintf ( const char *  format,
  ... 
)

Definition at line 27 of file qcstring.cpp.

28 {
29  va_list ap;
30  va_start( ap, format );
31  const int minlen=256;
32  int l = length();
33  if (l<minlen) { resize(minlen); l=minlen; }
34  int n=vsnprintf( rawData(), l, format, ap);
35  if (n<0) n=l;
36  resize(n+1);
37  va_end( ap );
38  return *this;
39 }
bool resize(uint newlen)
Definition: qcstring.h:225
char * rawData() const
Definition: qcstring.h:216
uint length() const
Definition: qcstring.h:195
static bool format(QChar::Decomposition tag, QString &str, int index, int len)
Definition: qstring.cpp:11496
static QStrList * l
Definition: config.cpp:1044
std::void_t< T > n
bool QCString::stripPrefix ( const char *  prefix)

Definition at line 201 of file qcstring.cpp.

202 {
203  if (prefix==0 || length()==0) return FALSE;
204  int len = qstrlen(prefix);
205  if (qstrncmp(prefix,data(),len)==0)
206  {
207  m_rep=mid(len,length()-len).m_rep; // need to make a deep copy
208  return TRUE;
209  }
210  return FALSE;
211 }
StringRep m_rep
Definition: qcstring.h:695
Q_EXPORT int qstrncmp(const char *str1, const char *str2, uint len)
Definition: qcstring.h:101
uint length() const
Definition: qcstring.h:195
const bool FALSE
Definition: qglobal.h:370
Q_EXPORT uint qstrlen(const char *str)
Definition: qcstring.h:81
const char * data() const
Definition: qcstring.h:207
QCString mid(uint index, uint len=0xffffffff) const
Definition: qcstring.cpp:246
const bool TRUE
Definition: qglobal.h:371
QCString QCString::stripWhiteSpace ( ) const

Definition at line 295 of file qcstring.cpp.

296 {
297  if ( isEmpty() ) // nothing to do
298  return *this;
299 
300  register const char *cs = data();
301  int reslen = length();
302  if ( !isspace((uchar)cs[0]) && !isspace((uchar)cs[reslen-1]) )
303  return *this; // returns a copy
304 
305  QCString result(cs);
306  register char *s = result.rawData();
307  int start = 0;
308  int end = reslen - 1;
309  while ( isspace((uchar) s[start]) ) // skip white space from start
310  start++;
311  if ( s[start] == '\0' )
312  { // only white space
313  return QCString();
314  }
315  while ( end && isspace((uchar) s[end]) ) // skip white space from end
316  end--;
317  end -= start - 1;
318  qmemmove( s, &s[start], end );
319  result.resize( end + 1 );
320  return result;
321 }
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
bool resize(uint newlen)
Definition: qcstring.h:225
char * rawData() const
Definition: qcstring.h:216
static QCString result
bool isEmpty() const
Definition: qcstring.h:189
uint length() const
Definition: qcstring.h:195
QCString()
Definition: qcstring.h:135
unsigned char uchar
Definition: nybbler.cc:11
const char * data() const
Definition: qcstring.h:207
void * qmemmove(void *dst, const void *src, uint len)
Definition: qcstring.cpp:530
const char * cs
static QCString * s
Definition: config.cpp:1042
int QCString::toInt ( bool ok = 0) const

Definition at line 439 of file qcstring.cpp.

440 {
441  QString s(data());
442  return s.toInt(ok);
443 }
The QString class provides an abstraction of Unicode text and the classic C null-terminated char arra...
Definition: qstring.h:350
int toInt(bool *ok=0) const
Definition: qcstring.cpp:439
const char * data() const
Definition: qcstring.h:207
static QCString * s
Definition: config.cpp:1042
long QCString::toLong ( bool ok = 0) const

Definition at line 451 of file qcstring.cpp.

452 {
453  QString s(data());
454  return s.toLong(ok);
455 }
The QString class provides an abstraction of Unicode text and the classic C null-terminated char arra...
Definition: qstring.h:350
const char * data() const
Definition: qcstring.h:207
long toLong(bool *ok=0) const
Definition: qcstring.cpp:451
static QCString * s
Definition: config.cpp:1042
short QCString::toShort ( bool ok = 0) const

Definition at line 427 of file qcstring.cpp.

428 {
429  QString s(data());
430  return s.toShort(ok);
431 }
The QString class provides an abstraction of Unicode text and the classic C null-terminated char arra...
Definition: qstring.h:350
const char * data() const
Definition: qcstring.h:207
short toShort(bool *ok=0) const
Definition: qcstring.cpp:427
static QCString * s
Definition: config.cpp:1042
uint QCString::toUInt ( bool ok = 0) const

Definition at line 445 of file qcstring.cpp.

446 {
447  QString s(data());
448  return s.toUInt(ok);
449 }
The QString class provides an abstraction of Unicode text and the classic C null-terminated char arra...
Definition: qstring.h:350
const char * data() const
Definition: qcstring.h:207
uint toUInt(bool *ok=0) const
Definition: qcstring.cpp:445
static QCString * s
Definition: config.cpp:1042
uint64 QCString::toUInt64 ( bool ok = 0) const

Definition at line 463 of file qcstring.cpp.

464 {
465  QString s(data());
466  return s.toUInt64(ok);
467 }
The QString class provides an abstraction of Unicode text and the classic C null-terminated char arra...
Definition: qstring.h:350
uint64 toUInt64(bool *ok=0) const
Definition: qcstring.cpp:463
const char * data() const
Definition: qcstring.h:207
static QCString * s
Definition: config.cpp:1042
ulong QCString::toULong ( bool ok = 0) const

Definition at line 457 of file qcstring.cpp.

458 {
459  QString s(data());
460  return s.toULong(ok);
461 }
The QString class provides an abstraction of Unicode text and the classic C null-terminated char arra...
Definition: qstring.h:350
const char * data() const
Definition: qcstring.h:207
ulong toULong(bool *ok=0) const
Definition: qcstring.cpp:457
static QCString * s
Definition: config.cpp:1042
ushort QCString::toUShort ( bool ok = 0) const

Definition at line 433 of file qcstring.cpp.

434 {
435  QString s(data());
436  return s.toUShort(ok);
437 }
The QString class provides an abstraction of Unicode text and the classic C null-terminated char arra...
Definition: qstring.h:350
const char * data() const
Definition: qcstring.h:207
ushort toUShort(bool *ok=0) const
Definition: qcstring.cpp:433
static QCString * s
Definition: config.cpp:1042
bool QCString::truncate ( uint  pos)
inline

Truncates the string at position pos.

Definition at line 232 of file qcstring.h.

233  {
234  return resize(pos+1);
235  }
bool resize(uint newlen)
Definition: qcstring.h:225
QCString QCString::upper ( ) const

Definition at line 279 of file qcstring.cpp.

280 {
281  if (length()==0) return QCString();
282  QCString s(data());
283  register char *pos = s.rawData();
284  if (pos)
285  {
286  while (*pos)
287  {
288  *pos = toupper((unsigned char)*pos);
289  pos++;
290  }
291  }
292  return s;
293 }
char * rawData() const
Definition: qcstring.h:216
uint length() const
Definition: qcstring.h:195
QCString()
Definition: qcstring.h:135
const char * data() const
Definition: qcstring.h:207
static QCString * s
Definition: config.cpp:1042

Member Data Documentation

StringRep QCString::m_rep
private

Definition at line 695 of file qcstring.h.


The documentation for this class was generated from the following files: