qcstring.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 1997-2015 by Dimitri van Heesch.
4 **
5 ** Permission to use, copy, modify, and distribute this software and its
6 ** documentation under the terms of the GNU General Public License is hereby
7 ** granted. No representations are made about the suitability of this software
8 ** for any purpose. It is provided "as is" without express or implied warranty.
9 ** See the GNU General Public License for more details.
10 **
11 ** Note: this is a reimplementation of the qcstring.h that came with
12 ** an Qt version 2.2.3. For short strings it stores the string data inside
13 ** the object. For long strings it uses a separate array with reference counting.
14 **
15 **********************************************************************/
16 
17 #ifndef QCSTRING_H
18 #define QCSTRING_H
19 
20 #ifndef QT_H
21 #include "qarray.h"
22 #endif // QT_H
23 
24 #include <stdio.h>
25 #include <stdlib.h>
26 #include <string.h>
27 
28 #if !defined(_OS_WIN32_) || defined(__MINGW32__)
29 #include <stdint.h>
30 #endif
31 
32 #if defined(_OS_SUN_) && defined(_CC_GNU_)
33 #include <strings.h>
34 #endif
35 
36 #include <assert.h>
37 
38 class QGString;
39 
40 /*****************************************************************************
41  Fixes and workarounds for some platforms
42  *****************************************************************************/
43 
44 #if defined(_OS_HPUX_)
45 // HP-UX has badly defined strstr() etc.
46 // ### fix in 3.0: change hack_* to qt_hack_*
47 // by the way HP-UX is probably right, the standard has evolved and
48 // we'll have to adapt to it
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))
58 #endif
59 
60 /*****************************************************************************
61  Safe and portable C string functions; extensions to standard string.h
62  *****************************************************************************/
63 
64 Q_EXPORT void *qmemmove( void *dst, const void *src, uint len );
65 
66 #if defined(_OS_SUN_) || defined(_CC_OC_)
67 #define memmove(s1,s2,n) qmemmove((s1),(s2),(n))
68 #endif
69 
70 #if defined(_OS_WIN32_)
71 #define qsnprintf _snprintf
72 #else
73 #define qsnprintf snprintf
74 #endif
75 
76 Q_EXPORT char *qstrdup( const char * );
77 
78 Q_EXPORT inline uint cstrlen( const char *str )
79 { return (uint)strlen(str); }
80 
81 Q_EXPORT inline uint qstrlen( const char *str )
82 { return str ? (uint)strlen(str) : 0; }
83 
84 Q_EXPORT inline char *cstrcpy( char *dst, const char *src )
85 { return strcpy(dst,src); }
86 
87 Q_EXPORT inline char *qstrcpy( char *dst, const char *src )
88 { return src ? strcpy(dst, src) : 0; }
89 
90 Q_EXPORT char * qstrncpy(char *src,const char *dst, uint len);
91 
92 Q_EXPORT inline int cstrcmp( const char *str1, const char *str2 )
93 { return strcmp(str1,str2); }
94 
95 Q_EXPORT inline int qstrcmp( const char *str1, const char *str2 )
96 { return (str1 && str2) ? strcmp(str1,str2) : (int)((intptr_t)str2 - (intptr_t)str1); }
97 
98 Q_EXPORT inline int cstrncmp( const char *str1, const char *str2, uint len )
99 { return strncmp(str1,str2,len); }
100 
101 Q_EXPORT inline int qstrncmp( const char *str1, const char *str2, uint len )
102 { return (str1 && str2) ? strncmp(str1,str2,len) :
103  (int)((intptr_t)str2 - (intptr_t)str1); }
104 
105 Q_EXPORT int qstricmp( const char *str1, const char *str2 );
106 
107 Q_EXPORT int qstrnicmp( const char *str1, const char *str2, uint len );
108 
109 /*****************************************************************************
110  QByteArray class
111  *****************************************************************************/
112 
113 #if defined(Q_TEMPLATEDLL)
114 template class Q_EXPORT QArray<char>;
115 #endif
116 typedef QArray<char> QByteArray;
117 
118 /*****************************************************************************
119  QByteArray stream functions
120  *****************************************************************************/
121 #ifndef QT_NO_DATASTREAM
122 Q_EXPORT QDataStream &operator<<( QDataStream &, const QByteArray & );
123 Q_EXPORT QDataStream &operator>>( QDataStream &, QByteArray & );
124 #endif
125 
126 class QRegExp;
127 
128 /** This is an alternative implementation of QCString. It provides basically
129  * the same functions but uses reference counting and copy on write.
130  */
131 class QCString
132 {
133 public:
134  /** creates an empty string */
135  QCString() : m_rep()
136  {
137  }
138 
139  /** destroys the string */
141  {
142  }
143 
144  /** makes a copy of a string. */
145  QCString( const QCString &s ) : m_rep(s.m_rep)
146  {
147  }
148 
149  /** creates a string with room for size characters
150  * @param[in] size the number of character to allocate (including the 0-terminator)
151  */
152  explicit QCString( int size ) : m_rep(size)
153  {
154  }
155 
156  /** creates a string from a plain C string.
157  * @param[in] str A zero terminated C string. When 0 an empty string is created.
158  */
159  QCString( const char *str ) : m_rep(str)
160  {
161  }
162 
163  /** creates a string from \a str and copies over the first \a maxlen characters. */
164  QCString( const char *str, uint maxlen ) : m_rep(str,maxlen)
165  {
166  }
167 
168  /** replaces the contents by that of string \a s. */
170  {
171  m_rep = s.m_rep;
172  return *this;
173  }
174 
175  /** replaces the contents by that of C string \a str. */
176  QCString &operator=( const char *str)
177  {
178  m_rep = str;
179  return *this;
180  }
181 
182  /** Returns TRUE iff the string is empty. Equivalent to isEmpty(). */
183  bool isNull() const
184  {
185  return m_rep.isEmpty();
186  }
187 
188  /** Returns TRUE iff the string is empty */
189  bool isEmpty() const
190  {
191  return m_rep.isEmpty();
192  }
193 
194  /** Returns the length of the string, excluding the 0-terminator. Equivalent to size(). */
195  uint length() const
196  {
197  return m_rep.length();
198  }
199 
200  /** Returns the length of the string, excluding the 0-terminator. */
201  uint size() const
202  {
203  return m_rep.length();
204  }
205 
206  /** Returns a pointer to the contents of the string in the form of a 0-terminated C string */
207  const char *data() const
208  {
209  return m_rep.data();
210  }
211 
212  /** Returns a writable pointer to the data.
213  * @warning if the string is shared it will modifying the string directly and
214  * this will overwrite all copies as well!
215  */
216  char *rawData() const
217  {
218  return m_rep.rawData();
219  }
220 
221  /** Resizes the string to hold \a newlen characters
222  * (this value should include the 0-terminator). If the string is enlarged the contents will
223  * be left unmodified.
224  */
225  bool resize( uint newlen )
226  {
227  m_rep.resize(newlen);
228  return TRUE;
229  }
230 
231  /** Truncates the string at position \a pos. */
232  bool truncate( uint pos )
233  {
234  return resize(pos+1);
235  }
236 
237  /** Fills a string with a predefined character
238  * @param[in] c the character used to fill the string with.
239  * @param[in] len the number of character to fill. Use -1 to fill the whole string.
240  * @note the string will be resized to contain \a len characters. The contents of the
241  * string will be lost.
242  */
243  bool fill( char c, int len = -1 )
244  {
245  m_rep.fill(c,len);
246  return TRUE;
247  }
248 
249  /** Returns a deep copy of the string. */
250  QCString copy() const
251  {
252  if (length()==0) return QCString();
253  QCString cs(length()+1);
254  memcpy(cs.rawData(),data(),length());
255  return cs;
256  }
257 
258  QCString &sprintf( const char *format, ... );
259  int find( char c, int index=0, bool cs=TRUE ) const;
260  int find( const char *str, int index=0, bool cs=TRUE ) const;
261  int find( const QCString &str, int index=0, bool cs=TRUE ) const;
262  int find( const QRegExp &rx, int index=0 ) 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;
265  int findRev( const QRegExp &rx, int index=-1 ) 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);
270  QCString left( uint len ) const;
271  QCString right( uint len ) const;
272  QCString mid( uint index, uint len=0xffffffff) const;
273  QCString lower() const;
274  QCString upper() const;
275  QCString stripWhiteSpace() const;
276  QCString simplifyWhiteSpace() const;
277  QCString &assign( const char *str );
278  QCString &insert( uint index, const char *s );
279  QCString &insert( uint index, char c);
280  QCString &append( const char *s );
281  QCString &prepend( const char *s );
282  QCString &remove( uint index, uint len );
283  QCString &replace( uint index, uint len, const char *s);
284  QCString &replace( const QRegExp &rx, 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;
292  QCString &setNum(short n);
293  QCString &setNum(ushort n);
294  QCString &setNum(int n);
295  QCString &setNum(uint n);
296  QCString &setNum(long n);
297  QCString &setNum(ulong n);
298 
299  /** Converts the string to a plain C string */
300  operator const char *() const
301  {
302  return (const char *)data();
303  }
304 
305  /** Appends string \a str to this string and returns a reference to the result. */
306  QCString &operator+=( const char *str )
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  }
315 
316  /** Appends character \a c to this string and returns a reference to the result. */
317  QCString &operator+=( char c )
318  {
319  int len = length();
320  resize(len+2);
321  rawData()[len]=c;
322  return *this;
323  }
324 
325  /** Returns a reference to the character at index \a i. */
326  char &at( uint i) const
327  {
328  return m_rep.at(i);
329  }
330 
331  /** Indexing operator. Equavalent to at(). */
332  char &operator[]( int i ) const
333  {
334  return m_rep.at((uint)i);
335  }
336 
337  private:
338 
339  struct LSData;
340 
341  // long string representation
343  {
344  uchar isShort; // : 1; // should be shared with ShortStringRep
345  //uchar : 7;
347  };
348 
349 #define SHORT_STR_CAPACITY ((int)sizeof(LongStringRep)-2)
350 #define SHORT_STR_MAX_LEN (SHORT_STR_CAPACITY-1)
351 
352  // short string representation
354  {
355  uchar isShort; // : 1; // should be shared with LongStringRep
356  uchar len; // : 7;
357  char str[SHORT_STR_CAPACITY]; // size including 0-terminator
358  };
359 
360  // ref counting string header
361  struct LSHeader
362  {
363  int len; // length of string without 0 terminator
364  int refCount; // -1=leaked, 0=one ref & non-cost, n>0, n+1 refs, const
365  };
366  // ref counting string data and methods
367  struct LSData : public LSHeader
368  {
369  char *toStr()
370  {
371  return (char*)(this+1); // string data starts after the header
372  }
373 
374  // creates a LSData item with room for size bytes (which includes the 0 terminator!)
375  // if size is zero, an empty string will be created.
376  static LSData *create(int size)
377  {
378  LSData *data;
379  data = (LSData*)malloc(sizeof(LSHeader)+size);
380  data->len = size-1;
381  data->refCount = 0;
382  data->toStr()[size-1] = 0;
383  return data;
384  }
385  // remove out reference to the data. Frees memory if no more users
386  void dispose()
387  {
388  if (--refCount<0) free(this);
389  }
390 
391  // resizes LSData so it can hold size bytes (which includes the 0 terminator!)
392  // Since this is for long strings only, size should be > SHORT_STR_CAPACITY
393  static LSData *resize(LSData *d,int size)
394  {
395  if (d->len>0 && d->refCount==0) // non-const, non-empty
396  {
397  d = (LSData*)realloc(d,sizeof(LSHeader)+size);
398  d->len = size-1;
399  d->toStr()[size-1] = 0;
400  return d;
401  }
402  else // need to make a copy
403  {
404  LSData *newData = LSData::create(size);
405  int len = d->len;
406  if (len>=size) len=size-1;
407  memcpy(newData->toStr(),d->toStr(),len);
408  newData->toStr()[len]=0;
409  d->dispose();
410  return newData;
411  }
412  }
413  };
414 
415  class StringRep
416  {
417  public:
419  {
420  initEmpty();
421  }
422  void initEmpty()
423  {
424  u.s.isShort=TRUE;
425  u.s.len=0;
426  //memset(u.s.str,0,SHORT_STR_CAPACITY);
427  }
429  {
430  if (!u.s.isShort)
431  {
432  u.l.d->dispose();
433  }
434  }
436  {
437  if (&s!=this)
438  {
439  u.s.isShort = s.u.s.isShort;
440  if (s.u.s.isShort)
441  {
442  u.s.len = s.u.s.len;
443  memcpy(u.s.str,s.u.s.str,s.u.s.len+1);
444  }
445  else
446  {
447  u.l.d = s.u.l.d;
448  u.l.d->refCount++;
449  }
450  }
451  else // self-assignment
452  {
453  u = s.u; // avoid uninitialized warning from gcc
454  }
455  }
457  {
458  u.s.isShort = size<=SHORT_STR_CAPACITY;
459  if (size<=SHORT_STR_CAPACITY) // init short string
460  {
461  if (size>0)
462  {
463  u.s.len = size-1;
464  u.s.str[size-1]='\0';
465  }
466  else
467  {
468  u.s.len = 0;
469  }
470  }
471  else // int long string
472  {
473  u.l.d = LSData::create(size);
474  }
475  }
476  StringRep(const char *str)
477  {
478  if (str)
479  {
480  int len = (int)strlen(str);
481  u.s.isShort = len<SHORT_STR_CAPACITY;
482  if (len<SHORT_STR_CAPACITY)
483  {
484  u.s.len = len;
485  qstrncpy(u.s.str,str,SHORT_STR_CAPACITY);
486  }
487  else
488  {
489  u.l.d = LSData::create(len+1);
490  memcpy(u.l.d->toStr(),str,u.l.d->len);
491  }
492  }
493  else // create empty string
494  {
495  initEmpty();
496  }
497  }
498  StringRep( const char *str, uint maxlen )
499  {
500  if (str && maxlen>0)
501  {
502  uint len=(uint)strlen(str);
503  if (len>maxlen) len=maxlen;
504  u.s.isShort = len<=SHORT_STR_MAX_LEN;
505  if (u.s.isShort)
506  {
507  u.s.len = len;
508  memcpy(u.s.str,str,len);
509  u.s.str[len]='\0';
510  }
511  else
512  {
513  u.l.d = LSData::create(len+1);
514  memcpy(u.l.d->toStr(),str,len);
515  }
516  }
517  else // create empty string
518  {
519  initEmpty();
520  }
521  }
523  {
524  if (&s!=this)
525  {
526  if (!u.s.isShort)
527  {
528  u.l.d->dispose();
529  }
530  u.s.isShort = s.u.s.isShort;
531  if (u.s.isShort) // copy by value
532  {
533  u.s.len = s.u.s.len;
534  memcpy(u.s.str,s.u.s.str,s.u.s.len+1);
535  }
536  else // copy by reference
537  {
538  u.l.d = s.u.l.d;
539  u.l.d->refCount++;
540  }
541  }
542  else // self-assignment
543  {
544  u = s.u; // avoid uninitialized warning from gcc
545  }
546  return *this;
547  }
548  StringRep &operator=(const char *str)
549  {
550  if (!u.s.isShort)
551  {
552  u.l.d->dispose();
553  }
554  if (str)
555  {
556  int len = (int)strlen(str);
557  u.s.isShort = len<SHORT_STR_CAPACITY;
558  if (len<SHORT_STR_CAPACITY)
559  {
560  u.s.len = len;
561  qstrncpy(u.s.str,str,SHORT_STR_CAPACITY);
562  }
563  else
564  {
565  u.l.d = LSData::create(len+1);
566  memcpy(u.l.d->toStr(),str,len);
567  }
568  }
569  else
570  {
571  initEmpty();
572  }
573  return *this;
574  }
575  bool isEmpty() const
576  {
577  return u.s.isShort && u.s.len==0;
578  }
579  uint length() const
580  {
581  uint l = u.s.isShort ? u.s.len : u.l.d->len;
582  return l;
583  }
584  const char *data() const
585  {
586  if (u.s.isShort)
587  {
588  return u.s.len==0 ? 0 : u.s.str;
589  }
590  else
591  {
592  return u.l.d->len==0 ? 0 : u.l.d->toStr();
593  }
594  }
595  char *rawData() const
596  {
597  if (u.s.isShort)
598  {
599  return u.s.len==0 ? 0 : (char*)u.s.str;
600  }
601  else
602  {
603  //assert(u.l.d->refCount==0); // string may not be shared when accessed raw
604  return u.l.d->len==0 ? 0 : u.l.d->toStr();
605  }
606  }
607  char &at(int i) const
608  {
609  if (u.s.isShort)
610  {
611  return (char&)u.s.str[i];
612  }
613  else
614  {
615  return u.l.d->toStr()[i];
616  }
617  }
618  bool resize( uint newlen )
619  {
620  if (u.s.isShort && newlen<=SHORT_STR_CAPACITY) // resize short string
621  {
622  if (newlen>0)
623  {
624  u.s.len = newlen-1;
625  u.s.str[newlen-1]='\0';
626  }
627  else // string becomes empty
628  {
629  initEmpty();
630  }
631  }
632  else if (u.s.isShort) // turn short string into long string
633  {
634  StringRep tmp = *this;
635  u.s.isShort=FALSE;
636  u.l.d = LSData::create(newlen);
637  if (tmp.u.s.len>0)
638  {
639  memcpy(u.l.d->toStr(),tmp.u.s.str,tmp.u.s.len+1);
640  }
641  else
642  {
643  u.l.d->toStr()[0]='\0';
644  }
645  }
646  else if (!u.s.isShort && newlen<=SHORT_STR_CAPACITY) // turn long string into short string
647  {
648  if (newlen>0)
649  {
650  StringRep tmp(newlen); // copy short part into tmp buffer
651  memcpy(tmp.u.s.str,u.l.d->toStr(),newlen-1);
652  tmp.u.s.str[newlen-1]='\0';
653  u.l.d->dispose();
654  u.s = tmp.u.s;
655  }
656  else
657  {
658  u.l.d->dispose();
659  initEmpty();
660  }
661  }
662  else // resize long string
663  {
664  u.l.d = u.l.d->resize(u.l.d,newlen);
665  }
666  return TRUE;
667  }
668  bool fill( char c, int len )
669  {
670  if (len<0) len=length();
671  if (!u.s.isShort) // detach from shared string
672  {
673  resize(len+1);
674  }
675  else if (len!=(int)length())
676  {
677  if (len>0)
678  {
679  resize(len+1);
680  }
681  }
682  if (len>0)
683  {
684  memset(rawData(),c,len);
685  }
686  return TRUE;
687  }
688  private:
690  {
693  } u;
694  };
696 
697 };
698 
699 /*****************************************************************************
700  QCString stream functions
701  *****************************************************************************/
702 #ifndef QT_NO_DATASTREAM
705 #endif
706 
707 /*****************************************************************************
708  QCString non-member operators
709  *****************************************************************************/
710 
711 Q_EXPORT inline bool operator==( const QCString &s1, const QCString &s2 )
712 { return qstrcmp(s1.data(),s2.data()) == 0; }
713 
714 Q_EXPORT inline bool operator==( const QCString &s1, const char *s2 )
715 { return qstrcmp(s1.data(),s2) == 0; }
716 
717 Q_EXPORT inline bool operator==( const char *s1, const QCString &s2 )
718 { return qstrcmp(s1,s2.data()) == 0; }
719 
720 Q_EXPORT inline bool operator!=( const QCString &s1, const QCString &s2 )
721 { return qstrcmp(s1.data(),s2.data()) != 0; }
722 
723 Q_EXPORT inline bool operator!=( const QCString &s1, const char *s2 )
724 { return qstrcmp(s1.data(),s2) != 0; }
725 
726 Q_EXPORT inline bool operator!=( const char *s1, const QCString &s2 )
727 { return qstrcmp(s1,s2.data()) != 0; }
728 
729 Q_EXPORT inline bool operator<( const QCString &s1, const QCString& s2 )
730 { return qstrcmp(s1.data(),s2.data()) < 0; }
731 
732 Q_EXPORT inline bool operator<( const QCString &s1, const char *s2 )
733 { return qstrcmp(s1.data(),s2) < 0; }
734 
735 Q_EXPORT inline bool operator<( const char *s1, const QCString &s2 )
736 { return qstrcmp(s1,s2.data()) < 0; }
737 
738 Q_EXPORT inline bool operator<=( const QCString &s1, const char *s2 )
739 { return qstrcmp(s1.data(),s2) <= 0; }
740 
741 Q_EXPORT inline bool operator<=( const char *s1, const QCString &s2 )
742 { return qstrcmp(s1,s2.data()) <= 0; }
743 
744 Q_EXPORT inline bool operator>( const QCString &s1, const char *s2 )
745 { return qstrcmp(s1.data(),s2) > 0; }
746 
747 Q_EXPORT inline bool operator>( const char *s1, const QCString &s2 )
748 { return qstrcmp(s1,s2.data()) > 0; }
749 
750 Q_EXPORT inline bool operator>=( const QCString &s1, const char *s2 )
751 { return qstrcmp(s1.data(),s2) >= 0; }
752 
753 Q_EXPORT inline bool operator>=( const char *s1, const QCString &s2 )
754 { return qstrcmp(s1,s2.data()) >= 0; }
755 
756 Q_EXPORT inline QCString operator+( const QCString &s1, const QCString &s2 )
757 {
758  QCString tmp(s1);
759  tmp += s2;
760  return tmp;
761 }
762 
763 
764 inline QCString operator+( const QCString &s1, const QGString &s2 );
765 inline QCString operator+( const QGString &s1, const QCString &s2 );
766 
767 
768 Q_EXPORT inline QCString operator+( const QCString &s1, const char *s2 )
769 {
770  QCString tmp(s1);
771  tmp += s2;
772  return tmp;
773 }
774 
775 Q_EXPORT inline QCString operator+( const char *s1, const QCString &s2 )
776 {
777  QCString tmp(s1);
778  tmp += s2;
779  return tmp;
780 }
781 
782 Q_EXPORT inline QCString operator+( const QCString &s1, char c2 )
783 {
784  QCString tmp( s1.data() );
785  tmp += c2;
786  return tmp;
787 }
788 
789 Q_EXPORT inline QCString operator+( char c1, const QCString &s2 )
790 {
791  QCString tmp;
792  tmp += c1;
793  tmp += s2;
794  return tmp;
795 }
796 
797 inline const char *qPrint(const char *s)
798 {
799  if (s) return s; else return "";
800 }
801 
802 inline const char *qPrint(const QCString &s)
803 {
804  if (!s.isEmpty()) return s.data(); else return "";
805 }
806 
807 #endif // QCSTRING_H
Q_EXPORT char * qstrncpy(char *src, const char *dst, uint len)
Definition: qcstring.cpp:557
StringRep m_rep
Definition: qcstring.h:695
int operator>(QChar c1, QChar c2)
Definition: qstring.h:329
bool resize(uint newlen)
Definition: qcstring.h:225
Q_EXPORT int qstrncmp(const char *str1, const char *str2, uint len)
Definition: qcstring.h:101
char * rawData() const
Definition: qcstring.h:216
QDataStream & operator<<(QDataStream &s, const QString &str)
Definition: qstring.cpp:15066
Q_EXPORT QDataStream & operator>>(QDataStream &, QByteArray &)
Definition: qcstring.cpp:605
StringRep(const char *str)
Definition: qcstring.h:476
StringRep(const StringRep &s)
Definition: qcstring.h:435
QCString(const QCString &s)
Definition: qcstring.h:145
bool resize(uint newlen)
Definition: qcstring.h:618
void dispose()
Definition: qcstring.h:386
Q_EXPORT int qstrnicmp(const char *str1, const char *str2, uint len)
Definition: qcstring.cpp:581
QCString & operator+=(const char *str)
Definition: qcstring.h:306
char str[SHORT_STR_CAPACITY]
Definition: qcstring.h:357
bool isEmpty() const
Definition: qcstring.h:189
The QRegExp class provides pattern matching using regular expressions or wildcards.
Definition: qregexp.h:46
static const int maxlen
Definition: qregexp.cpp:904
uint length() const
Definition: qgstring.h:40
uint length() const
Definition: qcstring.h:195
QCString & operator+=(char c)
Definition: qcstring.h:317
char & at(uint i) const
Definition: qcstring.h:326
static bool format(QChar::Decomposition tag, QString &str, int index, int len)
Definition: qstring.cpp:11496
int operator<(QChar c1, QChar c2)
Definition: qstring.h:326
const bool FALSE
Definition: qglobal.h:370
const char * data() const
Definition: qcstring.h:584
QCString()
Definition: qcstring.h:135
static LSData * resize(LSData *d, int size)
Definition: qcstring.h:393
Q_EXPORT uint cstrlen(const char *str)
Definition: qcstring.h:78
uint size() const
Definition: qcstring.h:201
bool isEmpty() const
Definition: qcstring.h:575
char & at(int i) const
Definition: qcstring.h:607
QCString & operator=(const char *str)
Definition: qcstring.h:176
void resize(Vector< T > &vec1, Index n1, const V &val)
static QStrList * l
Definition: config.cpp:1044
unsigned char uchar
Definition: nybbler.cc:11
QCString(const char *str)
Definition: qcstring.h:159
QCString copy() const
Definition: qcstring.h:250
StringRep & operator=(const StringRep &s)
Definition: qcstring.h:522
Q_EXPORT int qstricmp(const char *str1, const char *str2)
Definition: qcstring.cpp:567
QCString & operator=(const QCString &s)
Definition: qcstring.h:169
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:92
bool operator<=(const QString &s1, const char *s2)
Definition: qstring.cpp:14884
bool isNull() const
Definition: qcstring.h:183
Q_EXPORT uint qstrlen(const char *str)
Definition: qcstring.h:81
~QCString()
Definition: qcstring.h:140
StringRep(int size)
Definition: qcstring.h:456
std::void_t< T > n
char & operator[](int i) const
Definition: qcstring.h:332
static LSData * create(int size)
Definition: qcstring.h:376
QString operator+(const QString &s1, const QString &s2)
Definition: qstring.h:774
unsigned long ulong
Definition: qglobal.h:352
const char * data() const
Definition: qcstring.h:207
string tmp
Definition: languages.py:63
QCString(const char *str, uint maxlen)
Definition: qcstring.h:164
#define SHORT_STR_MAX_LEN
Definition: qcstring.h:350
char * toStr()
Definition: qcstring.h:369
unsigned short ushort
Definition: qglobal.h:350
int operator>=(QChar c1, QChar c2)
Definition: qstring.h:323
char * rawData() const
Definition: qcstring.h:595
bool operator==(const QString &s1, const QString &s2)
Definition: qstring.cpp:14843
Q_EXPORT char * cstrcpy(char *dst, const char *src)
Definition: qcstring.h:84
int strcmp(const String &s1, const String &s2)
Definition: relates.cpp:14
Q_EXPORT int cstrcmp(const char *str1, const char *str2)
Definition: qcstring.h:92
bool fill(char c, int len=-1)
Definition: qcstring.h:243
Q_EXPORT char * qstrcpy(char *dst, const char *src)
Definition: qcstring.h:87
bool truncate(uint pos)
Definition: qcstring.h:232
bool operator!=(const QString &s1, const QString &s2)
Definition: qstring.cpp:14850
StringRep & operator=(const char *str)
Definition: qcstring.h:548
The QDataStream class provides serialization of binary data to a QIODevice.
Definition: qdatastream.h:47
Q_EXPORT int cstrncmp(const char *str1, const char *str2, uint len)
Definition: qcstring.h:98
QCString(int size)
Definition: qcstring.h:152
Q_EXPORT void * qmemmove(void *dst, const void *src, uint len)
Definition: qcstring.cpp:530
StringRep(const char *str, uint maxlen)
Definition: qcstring.h:498
const char * cs
#define SHORT_STR_CAPACITY
Definition: qcstring.h:349
union QCString::StringRep::ShortOrLongStringSelector u
QArray< char > QByteArray
Definition: qcstring.h:116
unsigned long long uint64
Definition: qglobal.h:361
Q_EXPORT int qstrcmp(const char *str1, const char *str2)
Definition: qcstring.h:95
Q_EXPORT char * qstrdup(const char *)
Definition: qcstring.cpp:548
unsigned uint
Definition: qglobal.h:351
bool fill(char c, int len)
Definition: qcstring.h:668
static QCString * s
Definition: config.cpp:1042
#define Q_EXPORT
Definition: qglobal.h:468
const char * qPrint(const char *s)
Definition: qcstring.h:797
const bool TRUE
Definition: qglobal.h:371
static QCString str
uint length() const
Definition: qcstring.h:579