Doxygen
qcstring.h
浏览该文件的文档.
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 #include <string>
21 #include <algorithm>
22 
23 #include <cctype>
24 #include <cstring>
25 #include <cstdio>
26 #include <cstdlib>
27 #include <cstdint>
28 #include <ostream>
29 
30 #include "utf8.h"
31 
32 #ifndef FALSE
33 #define FALSE false
34 #endif
35 #ifndef TRUE
36 #define TRUE true
37 #endif
38 typedef unsigned char uchar;
39 typedef unsigned short ushort;
40 typedef unsigned uint;
41 typedef unsigned long ulong;
42 typedef int64_t int64;
43 typedef uint64_t uint64;
44 #define ASSERT(x) if ( !(x) )\
45  fprintf(stderr,"ASSERT: \"%s\" in %s (%d)\n",#x,__FILE__,__LINE__)
46 
47 
48 /*****************************************************************************
49  Safe and portable C string functions; extensions to standard string.h
50  *****************************************************************************/
51 
52 void *qmemmove( void *dst, const void *src, size_t len );
53 
54 #if defined(_OS_WIN32_)
55 #define qsnprintf _snprintf
56 #else
57 #define qsnprintf snprintf
58 #endif
59 
60 char *qstrdup( const char * );
61 
62 inline uint cstrlen( const char *str )
63 { return (uint)strlen(str); }
64 
65 inline uint qstrlen( const char *str )
66 { return str ? (uint)strlen(str) : 0; }
67 
68 inline char *cstrcpy( char *dst, const char *src )
69 { return strcpy(dst,src); }
70 
71 inline char *qstrcpy( char *dst, const char *src )
72 { return src ? strcpy(dst, src) : 0; }
73 
74 char * qstrncpy(char *dst,const char *src, size_t len);
75 
76 inline int cstrcmp( const char *str1, const char *str2 )
77 { return strcmp(str1,str2); }
78 
79 inline bool qisempty( const char *s)
80 { return s==0 || *s==0; }
81 
82 inline int qstrcmp( const char *str1, const char *str2 )
83 { return (str1 && str2) ? strcmp(str1,str2) : // both non-empty
84  (qisempty(str1) && qisempty(str2)) ? 0 : // both empty
85  qisempty(str1) ? -1 : 1; // one empty, other non-empty
86 }
87 
88 inline int cstrncmp( const char *str1, const char *str2, size_t len )
89 { return strncmp(str1,str2,len); }
90 
91 inline int qstrncmp( const char *str1, const char *str2, size_t len )
92 { return (str1 && str2) ? strncmp(str1,str2,len) : // both non-empty
93  (qisempty(str1) && qisempty(str2)) ? 0 : // both empty
94  qisempty(str1) ? -1 : 1; // one empty other non-empty
95 }
96 
97 inline bool qisspace(char c)
98 { return c==' ' || c=='\t' || c=='\n' || c=='\r'; }
99 
100 int qstricmp( const char *str1, const char *str2 );
101 
102 int qstrnicmp( const char *str1, const char *str2, size_t len );
103 
104 
105 /** This is an alternative implementation of QCString. It provides basically
106  * the same functions but uses std::string as the underlying string type
107  */
108 class QCString
109 {
110  public:
111  QCString() = default;
112  ~QCString() = default;
113  QCString( const QCString &s ) = default;
114  QCString &operator=( const QCString &s ) = default;
115  QCString( QCString &&s ) = default;
116  QCString &operator=( QCString &&s ) = default;
117 
118  explicit QCString( const std::string &s ) : m_rep(s) {}
119 
120  QCString( std::string &&s) { m_rep = std::move(s); }
121 
122  /** creates a string with room for size characters
123  * @param[in] size the number of character to allocate (also counting the 0-terminator!)
124  */
125  explicit QCString( size_t size ) { m_rep.resize(size>0 ? size-1 : 0); }
126 
127  /** creates a string from a plain C string.
128  * @param[in] str A zero terminated C string. When 0 an empty string is created.
129  */
130  QCString( const char *str ) : m_rep(str?str:"") {}
131 
132  /** creates a string from \a str and copies over the first \a maxlen characters. */
133  QCString( const char *str, size_t maxlen ) : m_rep(str?str:"") { m_rep.resize(maxlen); }
134 
135  /** replaces the contents by that of C string \a str. */
136  QCString &operator=( const char *str) { m_rep = str?str:""; return *this; }
137 
138  QCString &operator=( const std::string &s) { m_rep = s; return *this; }
139 
140  /** Returns TRUE iff the string is empty. Equivalent to isEmpty(). */
141  bool isNull() const { return m_rep.empty(); }
142 
143  /** Returns TRUE iff the string is empty */
144  bool isEmpty() const { return m_rep.empty(); }
145 
146  /** Returns the length of the string, not counting the 0-terminator. Equivalent to size(). */
147  uint length() const { return (uint)m_rep.size(); }
148 
149  /** Returns the length of the string, not counting the 0-terminator. */
150  uint size() const { return (uint)m_rep.size(); }
151 
152  /** Returns a pointer to the contents of the string in the form of a 0-terminated C string */
153  const char *data() const { return m_rep.c_str(); }
154 
155  /** Returns a writable pointer to the data.
156  */
157  char *rawData() { return &m_rep[0]; }
158 
159  /** Resizes the string to hold \a newlen characters
160  * (this value should also count the 0-terminator).
161  * If the string is enlarged the contents will
162  * be left unmodified.
163  */
164  bool resize( size_t newlen ) { m_rep.resize( newlen>0 ? newlen-1 : 0 ); return TRUE; }
165 
166  /** Truncates the string at position \a pos. */
167  bool truncate( size_t pos ) { return resize( pos + 1 ); }
168 
169  /** Fills a string with a predefined character
170  * @param[in] c the character used to fill the string with.
171  * @param[in] len the number of character to fill. Use -1 to fill the whole string.
172  * @note the string will be resized to contain \a len characters. The contents of the
173  * string will be lost.
174  */
175  bool fill( char c, int len = -1 )
176  {
177  int l = len==-1 ? (int)m_rep.size() : len;
178  m_rep = std::string(l,c);
179  return TRUE;
180  }
181 
182  QCString &sprintf( const char *format, ... );
183 
184  int find( char c, int index=0, bool cs=TRUE ) const;
185  int find( const char *str, int index=0, bool cs=TRUE ) const;
186  int find( const QCString &str, int index=0, bool cs=TRUE ) const;
187  //int find( const QRegExp &rx, int index=0 ) const;
188 
189  int findRev( char c, int index=-1, bool cs=TRUE) const;
190  int findRev( const char *str, int index=-1, bool cs=TRUE) const;
191  //int findRev( const QRegExp &rx, int index=-1 ) const;
192 
193  int contains( char c, bool cs=TRUE ) const;
194  int contains( const char *str, bool cs=TRUE ) const;
195  //int contains( const QRegExp &rx ) const;
196 
197  bool stripPrefix(const QCString &prefix)
198  {
199  if (prefix.isEmpty() || m_rep.empty()) return FALSE;
200  if (m_rep.rfind(prefix.data(),0)==0) // string starts with prefix
201  {
202  m_rep.erase(0,prefix.length());
203  return TRUE;
204  }
205  return FALSE;
206  }
207  bool stripPrefix(const char *prefix)
208  {
209  return stripPrefix(QCString(prefix));
210  }
211 
212  QCString left( size_t len ) const
213  {
214  return m_rep.empty() ? QCString() : QCString(m_rep.substr(0,len));
215  }
216 
217  QCString right( size_t len ) const
218  {
219  return m_rep.empty() ? QCString() :
220  len<m_rep.size() ? QCString(m_rep.substr(m_rep.size()-len,len)) :
221  *this;
222  }
223 
224  QCString mid( size_t index, size_t len=static_cast<size_t>(-1)) const
225  {
226  size_t slen = m_rep.size();
227  if (len==static_cast<uint>(-1)) len = slen-index;
228  return m_rep.empty() || index>slen || len==0 ? QCString() :
229  QCString(m_rep.substr(index,len));
230  }
231 
232  QCString lower() const
233  {
235  }
236 
237  QCString upper() const
238  {
240  }
241 
242  /// returns a copy of this string with leading and trailing whitespace removed
244  {
245  size_t sl = m_rep.size();
246  if (sl==0 || (!qisspace(m_rep[0]) && !qisspace(m_rep[sl-1]))) return *this;
247  size_t start=0,end=sl-1;
248  while (start<sl && qisspace(m_rep[start])) start++;
249  if (start==sl) return QCString(); // only whitespace
250  while (end>start && qisspace(m_rep[end])) end--;
251  return QCString(m_rep.substr(start,1+end-start));
252  }
253 
254  /// returns a copy of this string with all whitespace removed
256  {
257  size_t sl = m_rep.size();
258  if (sl==0) return *this;
259  std::string result = m_rep;
260  size_t src=0,dst=0;
261  while (src<sl)
262  {
263  if (!qisspace(m_rep[src])) result[dst++]=m_rep[src];
264  src++;
265  }
266  if (dst<m_rep.size()) result.resize(dst);
267  return QCString(result);
268  }
269 
270  /// return a copy of this string with leading and trailing whitespace removed and multiple
271  /// whitespace characters replaced by a single space
273 
274  QCString &insert( size_t index, const QCString &s )
275  {
276  if (s.length()>0)
277  {
278  size_t ol = m_rep.size();
279  if (index>ol) // insert beyond end of string and fill gap with spaces
280  {
281  m_rep.resize(index+s.length());
282  std::memset(&m_rep[ol],' ',index-ol);
283  std::memcpy(&m_rep[index],s.data(),s.length()+1);
284  }
285  else // insert inside the string
286  {
287  m_rep.insert(index,s.str());
288  }
289  }
290  return *this;
291  }
292  QCString &insert( size_t index, const char *s )
293  {
294  size_t len = s ? qstrlen(s) : 0;
295  if (len>0)
296  {
297  size_t ol = m_rep.size();
298  if (index>ol) // insert beyond end of string and fill gap with spaces
299  {
300  m_rep.resize(index+len);
301  std::memset(&m_rep[ol],' ',index-ol);
302  std::memcpy(&m_rep[index],s,len+1);
303  }
304  else // insert inside the string
305  {
306  m_rep.insert(index,s);
307  }
308  }
309  return *this;
310  }
311 
312  QCString &insert( size_t index, char c)
313  {
314  char s[2] = { c, '\0' };
315  return insert(index,s);
316  }
317 
318  QCString &append( char c)
319  {
320  m_rep+=c;
321  return *this;
322  }
323 
324  QCString &append( const char *s )
325  {
326  return operator+=(s);
327  }
328 
329  QCString &append( const QCString &s )
330  {
331  return operator+=(s);
332  }
333 
334  QCString &append( const std::string &s )
335  {
336  return operator+=(s);
337  }
338 
339  QCString &prepend( const char *s )
340  {
341  return insert(0,s);
342  }
343 
344  QCString &prepend( const QCString &s )
345  {
346  return insert(0,s.data());
347  }
348 
349  QCString &prepend( const std::string &s )
350  {
351  return insert(0,s.c_str());
352  }
353 
354  QCString &remove( size_t index, size_t len )
355  {
356  size_t ol = m_rep.size();
357  if (index<ol && len>0) m_rep.erase(index,index+len>=ol ? std::string::npos : len);
358  return *this;
359  }
360 
361  QCString &replace( size_t index, size_t len, const char *s);
362  //QCString &replace( const QRegExp &rx, const char *str );
363 
364  short toShort( bool *ok=0, int base=10 ) const;
365  ushort toUShort( bool *ok=0, int base=10 ) const;
366  int toInt( bool *ok=0, int base=10 ) const;
367  uint toUInt( bool *ok=0, int base=10 ) const;
368  long toLong( bool *ok=0, int base=10 ) const;
369  ulong toULong( bool *ok=0, int base=10 ) const;
370  uint64 toUInt64( bool *ok=0, int base=10 ) const;
371 
372  QCString &setNum(short n)
373  {
374  m_rep = std::to_string(n);
375  return *this;
376  }
377 
379  {
380  m_rep = std::to_string(n);
381  return *this;
382  }
383 
384  QCString &setNum(int n)
385  {
386  m_rep = std::to_string(n);
387  return *this;
388  }
389 
391  {
392  m_rep = std::to_string(n);
393  return *this;
394  }
395 
396  QCString &setNum(long n)
397  {
398  m_rep = std::to_string(n);
399  return *this;
400  }
401 
403  {
404  m_rep = std::to_string(n);
405  return *this;
406  }
407 
408  bool startsWith( const char *s ) const
409  {
410  if (m_rep.empty() || s==0) return s==0;
411  return m_rep.rfind(s,0)==0; // looking "backward" starting and ending at index 0
412  }
413 
414  bool startsWith( const QCString &s ) const
415  {
416  if (m_rep.empty() || s.isEmpty()) return s.isEmpty();
417  return m_rep.rfind(s.str(),0)==0; // looking "backward" starting and ending at index 0
418  }
419 
420  bool endsWith(const char *s) const
421  {
422  if (m_rep.empty() || s==0) return s==0;
423  size_t l = strlen(s);
424  return m_rep.length()>=l && m_rep.compare(m_rep.length()-l, l, s, l)==0;
425  }
426 
427  bool endsWith(const QCString &s) const
428  {
429  size_t l = s.length();
430  return m_rep.length()>=l && m_rep.compare(m_rep.length()-l, l, s.str())==0;
431  }
432 
433 #define HAS_IMPLICIT_CAST_TO_PLAIN_C_STRING 0
434 #if HAS_IMPLICIT_CAST_TO_PLAIN_C_STRING
435  /** Converts the string to a plain C string */
436  operator const char *() const
437  {
438  return data();
439  }
440 #endif
441 
442  std::string str() const
443  {
444  return m_rep;
445  }
446 
448  {
449  m_rep+=s.str();
450  return *this;
451  }
452 
453  QCString &operator+=( const std::string &s)
454  {
455  m_rep+=s;
456  return *this;
457  }
458 
459  /** Appends string \a str to this string and returns a reference to the result. */
460  QCString &operator+=( const char *s )
461  {
462  if (s) m_rep+=s;
463  return *this;
464  }
465 
466 #define HAS_CHARACTER_APPEND_OPERATOR 1
467 #if HAS_CHARACTER_APPEND_OPERATOR
468  /** Appends character \a c to this string and returns a reference to the result. */
469  QCString &operator+=( char c )
470  {
471  m_rep+=c;
472  return *this;
473  }
474 #endif
475 
476  /** Returns a reference to the character at index \a i. */
477  char &at( size_t i)
478  {
479  return m_rep[i];
480  }
481 
482  const char &at( size_t i) const
483  {
484  return m_rep[i];
485  }
486 
487  /** Indexing operator. Equivalent to at(). */
488  char &operator[]( int i )
489  {
490  return m_rep[i];
491  }
492 
493  const char &operator[]( int i ) const
494  {
495  return m_rep[i];
496  }
497 
498  private:
499  std::string m_rep;
500 };
501 
502 /*****************************************************************************
503  QCString non-member operators
504  *****************************************************************************/
505 
506 inline bool operator==( const QCString &s1, const QCString &s2 )
507 { return qstrcmp(s1.data(),s2.data()) == 0; }
508 
509 inline bool operator==( const QCString &s1, const char *s2 )
510 { return qstrcmp(s1.data(),s2) == 0; }
511 
512 inline bool operator==( const char *s1, const QCString &s2 )
513 { return qstrcmp(s1,s2.data()) == 0; }
514 
515 inline bool operator!=( const QCString &s1, const QCString &s2 )
516 { return qstrcmp(s1.data(),s2.data()) != 0; }
517 
518 inline bool operator!=( const QCString &s1, const char *s2 )
519 { return qstrcmp(s1.data(),s2) != 0; }
520 
521 inline bool operator!=( const char *s1, const QCString &s2 )
522 { return qstrcmp(s1,s2.data()) != 0; }
523 
524 inline bool operator<( const QCString &s1, const QCString& s2 )
525 { return qstrcmp(s1.data(),s2.data()) < 0; }
526 
527 inline bool operator<( const QCString &s1, const char *s2 )
528 { return qstrcmp(s1.data(),s2) < 0; }
529 
530 inline bool operator<( const char *s1, const QCString &s2 )
531 { return qstrcmp(s1,s2.data()) < 0; }
532 
533 inline bool operator<=( const QCString &s1, const char *s2 )
534 { return qstrcmp(s1.data(),s2) <= 0; }
535 
536 inline bool operator<=( const char *s1, const QCString &s2 )
537 { return qstrcmp(s1,s2.data()) <= 0; }
538 
539 inline bool operator>( const QCString &s1, const char *s2 )
540 { return qstrcmp(s1.data(),s2) > 0; }
541 
542 inline bool operator>( const char *s1, const QCString &s2 )
543 { return qstrcmp(s1,s2.data()) > 0; }
544 
545 inline bool operator>=( const QCString &s1, const char *s2 )
546 { return qstrcmp(s1.data(),s2) >= 0; }
547 
548 inline bool operator>=( const char *s1, const QCString &s2 )
549 { return qstrcmp(s1,s2.data()) >= 0; }
550 
551 inline QCString operator+( const QCString &s1, const QCString &s2 )
552 {
553  return QCString(s1.str()+s2.str());
554 }
555 
556 
557 inline QCString operator+( const QCString &s1, const char *s2 )
558 {
559  QCString tmp(s1);
560  tmp.append(s2);
561  return tmp;
562 }
563 
564 inline QCString operator+( const char *s1, const QCString &s2 )
565 {
566  QCString tmp(s1);
567  tmp.append(s2);
568  return tmp;
569 }
570 
571 #define HAD_PLUS_OPERATOR_FOR_CHAR 0
572 #if HAS_PLUS_OPERATOR_FOR_CHAR
573 inline QCString operator+( const QCString &s1, char c2 )
574 {
575  QCString tmp( s1.data() );
576  tmp.append(c2);
577  return tmp;
578 }
579 
580 inline QCString operator+( char c1, const QCString &s2 )
581 {
582  QCString tmp;
583  tmp.append(c1);
584  tmp.append(s2);
585  return tmp;
586 }
587 #endif
588 
589 inline const char *qPrint(const char *s)
590 {
591  if (s) return s; else return "";
592 }
593 
594 inline const char *qPrint(const QCString &s)
595 {
596  if (!s.isEmpty()) return s.data(); else return "";
597 }
598 
599 inline const char *qPrint(const std::string &s)
600 {
601  return s.c_str();
602 }
603 
604 inline std::string toStdString(const QCString &s)
605 {
606  return s.str();
607 }
608 
609 //---- overloads
610 
611 inline int qstricmp( const QCString &str1, const char *str2 )
612 {
613  return qstricmp(str1.data(),str2);
614 }
615 
616 inline int qstricmp( const char *str1, const QCString &str2 )
617 {
618  return qstricmp(str1,str2.data());
619 }
620 
621 inline int qstricmp( const QCString &str1, const QCString &str2 )
622 {
623  return qstricmp(str1.data(),str2.data());
624 }
625 
626 inline int qstrnicmp( const QCString &str1, const char *str2, size_t len )
627 {
628  return qstrnicmp(str1.data(),str2,len);
629 }
630 
631 inline int qstrnicmp( const char *str1, const QCString &str2, size_t len )
632 {
633  return qstrnicmp(str1,str2.data(),len);
634 }
635 
636 inline int qstrnicmp( const QCString &str1, const QCString &str2, size_t len )
637 {
638  return qstrnicmp(str1.data(),str2.data(),len);
639 }
640 
641 // helper functions
642 QCString substitute(const QCString &str,const QCString &find,const QCString &replace);
643 inline QCString substitute(const QCString &str,const char *find,const char *replace)
644 {
645  return substitute(str,QCString(find),QCString(replace));
646 }
647 QCString substitute(const QCString &s,const QCString &src,const QCString &dst,int skip_seq);
648 
649 inline QCString substitute(const QCString &s,char srcChar,char dstChar)
650 {
651  std::string ss = s.str();
652  std::replace(ss.begin(),ss.end(),srcChar,dstChar);
653  return QCString(ss);
654 }
655 
656 inline std::ostream& operator<<(std::ostream& os, const QCString& s)
657 {
658  os << s.str();
659  return os;
660 }
661 
662 #endif // QCSTRING_H
QCString::QCString
QCString()=default
operator+
QCString operator+(const QCString &s1, const QCString &s2)
Definition: qcstring.h:551
QCString::operator=
QCString & operator=(const QCString &s)=default
reg::replace
std::string replace(const std::string &str, const Ex &re, const std::string &replacement)
Searching in a given input string for parts that match regular expression re and replaces those parts...
Definition: regex.cpp:740
QCString::rawData
char * rawData()
Returns a writable pointer to the data.
Definition: qcstring.h:157
QCString::replace
QCString & replace(size_t index, size_t len, const char *s)
Definition: qcstring.cpp:207
QCString::QCString
QCString(const std::string &s)
Definition: qcstring.h:118
qmemmove
void * qmemmove(void *dst, const void *src, size_t len)
Definition: qcstring.cpp:397
convertUTF8ToLower
std::string convertUTF8ToLower(const std::string &input)
Converts the input string into a lower case version, also taking into account non-ASCII characters th...
Definition: utf8.cpp:187
QCString::operator[]
const char & operator[](int i) const
Definition: qcstring.h:493
QCString::upper
QCString upper() const
Definition: qcstring.h:237
operator==
bool operator==(const QCString &s1, const QCString &s2)
Definition: qcstring.h:506
qstrdup
char * qstrdup(const char *)
Definition: qcstring.cpp:415
QCString::length
uint length() const
Returns the length of the string, not counting the 0-terminator.
Definition: qcstring.h:147
QCString::setNum
QCString & setNum(long n)
Definition: qcstring.h:396
QCString::operator=
QCString & operator=(const char *str)
replaces the contents by that of C string str.
Definition: qcstring.h:136
operator>=
bool operator>=(const QCString &s1, const char *s2)
Definition: qcstring.h:545
QCString::QCString
QCString(std::string &&s)
Definition: qcstring.h:120
QCString::toShort
short toShort(bool *ok=0, int base=10) const
Definition: qcstring.cpp:224
QCString::findRev
int findRev(char c, int index=-1, bool cs=TRUE) const
Definition: qcstring.cpp:86
QCString::isEmpty
bool isEmpty() const
Returns TRUE iff the string is empty
Definition: qcstring.h:144
QCString::setNum
QCString & setNum(uint n)
Definition: qcstring.h:390
QCString::size
uint size() const
Returns the length of the string, not counting the 0-terminator.
Definition: qcstring.h:150
qstrcpy
char * qstrcpy(char *dst, const char *src)
Definition: qcstring.h:71
QCString::operator+=
QCString & operator+=(const std::string &s)
Definition: qcstring.h:453
QCString::str
std::string str() const
Definition: qcstring.h:442
toStdString
std::string toStdString(const QCString &s)
Definition: qcstring.h:604
QCString::QCString
QCString(size_t size)
creates a string with room for size characters
Definition: qcstring.h:125
QCString::at
char & at(size_t i)
Returns a reference to the character at index i.
Definition: qcstring.h:477
QCString::find
int find(char c, int index=0, bool cs=TRUE) const
Definition: qcstring.cpp:38
QCString::toUInt
uint toUInt(bool *ok=0, int base=10) const
Definition: qcstring.cpp:249
qstrncmp
int qstrncmp(const char *str1, const char *str2, size_t len)
Definition: qcstring.h:91
QCString::insert
QCString & insert(size_t index, char c)
Definition: qcstring.h:312
operator<=
bool operator<=(const QCString &s1, const char *s2)
Definition: qcstring.h:533
end
DirIterator end(const DirIterator &) noexcept
Definition: dir.cpp:128
QCString::contains
int contains(char c, bool cs=TRUE) const
Definition: qcstring.cpp:138
QCString::operator+=
QCString & operator+=(const QCString &s)
Definition: qcstring.h:447
QCString::~QCString
~QCString()=default
uint
unsigned uint
Definition: qcstring.h:40
QCString::operator+=
QCString & operator+=(const char *s)
Appends string str to this string and returns a reference to the result.
Definition: qcstring.h:460
QCString::startsWith
bool startsWith(const QCString &s) const
Definition: qcstring.h:414
QCString::QCString
QCString(const char *str, size_t maxlen)
creates a string from str and copies over the first maxlen characters.
Definition: qcstring.h:133
QCString::stripWhiteSpace
QCString stripWhiteSpace() const
returns a copy of this string with leading and trailing whitespace removed
Definition: qcstring.h:243
uchar
unsigned char uchar
Definition: qcstring.h:38
QCString::left
QCString left(size_t len) const
Definition: qcstring.h:212
QCString::prepend
QCString & prepend(const std::string &s)
Definition: qcstring.h:349
QCString::insert
QCString & insert(size_t index, const QCString &s)
Definition: qcstring.h:274
qstricmp
int qstricmp(const char *str1, const char *str2)
Definition: qcstring.cpp:433
ulong
unsigned long ulong
Definition: qcstring.h:41
QCString::simplifyWhiteSpace
QCString simplifyWhiteSpace() const
return a copy of this string with leading and trailing whitespace removed and multiple whitespace cha...
Definition: qcstring.cpp:180
QCString::endsWith
bool endsWith(const QCString &s) const
Definition: qcstring.h:427
operator!=
bool operator!=(const QCString &s1, const QCString &s2)
Definition: qcstring.h:515
QCString::QCString
QCString(const char *str)
creates a string from a plain C string.
Definition: qcstring.h:130
operator<
bool operator<(const QCString &s1, const QCString &s2)
Definition: qcstring.h:524
QCString::append
QCString & append(const char *s)
Definition: qcstring.h:324
int64
int64_t int64
Definition: qcstring.h:42
QCString::lower
QCString lower() const
Definition: qcstring.h:232
TRUE
#define TRUE
Definition: qcstring.h:36
operator>
bool operator>(const QCString &s1, const char *s2)
Definition: qcstring.h:539
QCString::toInt
int toInt(bool *ok=0, int base=10) const
Definition: qcstring.cpp:244
QCString::toUShort
ushort toUShort(bool *ok=0, int base=10) const
Definition: qcstring.cpp:234
operator<<
std::ostream & operator<<(std::ostream &os, const QCString &s)
Definition: qcstring.h:656
cstrcmp
int cstrcmp(const char *str1, const char *str2)
Definition: qcstring.h:76
qstrncpy
char * qstrncpy(char *dst, const char *src, size_t len)
Definition: qcstring.cpp:423
QCString::fill
bool fill(char c, int len=-1)
Fills a string with a predefined character
Definition: qcstring.h:175
cstrlen
uint cstrlen(const char *str)
Definition: qcstring.h:62
ushort
unsigned short ushort
Definition: qcstring.h:39
QCString::toULong
ulong toULong(bool *ok=0, int base=10) const
Definition: qcstring.cpp:307
QCString::m_rep
std::string m_rep
Definition: qcstring.h:499
QCString::setNum
QCString & setNum(ushort n)
Definition: qcstring.h:378
QCString::operator+=
QCString & operator+=(char c)
Appends character c to this string and returns a reference to the result.
Definition: qcstring.h:469
QCString::setNum
QCString & setNum(short n)
Definition: qcstring.h:372
cstrcpy
char * cstrcpy(char *dst, const char *src)
Definition: qcstring.h:68
QCString::truncate
bool truncate(size_t pos)
Truncates the string at position pos.
Definition: qcstring.h:167
QCString::toLong
long toLong(bool *ok=0, int base=10) const
Definition: qcstring.cpp:255
utf8.h
Various UTF8 related helper functions.
QCString::mid
QCString mid(size_t index, size_t len=static_cast< size_t >(-1)) const
Definition: qcstring.h:224
QCString::stripPrefix
bool stripPrefix(const char *prefix)
Definition: qcstring.h:207
substitute
QCString substitute(const QCString &str, const QCString &find, const QCString &replace)
substitute all occurrences of src in s by dst
Definition: qcstring.cpp:465
QCString::remove
QCString & remove(size_t index, size_t len)
Definition: qcstring.h:354
QCString::append
QCString & append(const std::string &s)
Definition: qcstring.h:334
qisempty
bool qisempty(const char *s)
Definition: qcstring.h:79
QCString::append
QCString & append(char c)
Definition: qcstring.h:318
QCString::operator=
QCString & operator=(const std::string &s)
Definition: qcstring.h:138
QCString::endsWith
bool endsWith(const char *s) const
Definition: qcstring.h:420
QCString::startsWith
bool startsWith(const char *s) const
Definition: qcstring.h:408
QCString::isNull
bool isNull() const
Returns TRUE iff the string is empty.
Definition: qcstring.h:141
QCString::at
const char & at(size_t i) const
Definition: qcstring.h:482
qPrint
const char * qPrint(const char *s)
Definition: qcstring.h:589
QCString::append
QCString & append(const QCString &s)
Definition: qcstring.h:329
qisspace
bool qisspace(char c)
Definition: qcstring.h:97
QCString::data
const char * data() const
Returns a pointer to the contents of the string in the form of a 0-terminated C string
Definition: qcstring.h:153
qstrcmp
int qstrcmp(const char *str1, const char *str2)
Definition: qcstring.h:82
QCString::setNum
QCString & setNum(ulong n)
Definition: qcstring.h:402
qstrnicmp
int qstrnicmp(const char *str1, const char *str2, size_t len)
Definition: qcstring.cpp:447
QCString::toUInt64
uint64 toUInt64(bool *ok=0, int base=10) const
Definition: qcstring.cpp:351
QCString::operator[]
char & operator[](int i)
Indexing operator.
Definition: qcstring.h:488
QCString::setNum
QCString & setNum(int n)
Definition: qcstring.h:384
cstrncmp
int cstrncmp(const char *str1, const char *str2, size_t len)
Definition: qcstring.h:88
convertUTF8ToUpper
std::string convertUTF8ToUpper(const std::string &input)
Converts the input string into a upper case version, also taking into account non-ASCII characters th...
Definition: utf8.cpp:192
QCString::prepend
QCString & prepend(const QCString &s)
Definition: qcstring.h:344
QCString::stripPrefix
bool stripPrefix(const QCString &prefix)
Definition: qcstring.h:197
uint64
uint64_t uint64
Definition: qcstring.h:43
QCString::right
QCString right(size_t len) const
Definition: qcstring.h:217
QCString::prepend
QCString & prepend(const char *s)
Definition: qcstring.h:339
QCString::resize
bool resize(size_t newlen)
Resizes the string to hold newlen characters (this value should also count the 0-terminator).
Definition: qcstring.h:164
qstrlen
uint qstrlen(const char *str)
Definition: qcstring.h:65
QCString::insert
QCString & insert(size_t index, const char *s)
Definition: qcstring.h:292
QCString::sprintf
QCString & sprintf(const char *format,...)
Definition: qcstring.cpp:24
FALSE
#define FALSE
Definition: qcstring.h:33
QCString::removeWhiteSpace
QCString removeWhiteSpace() const
returns a copy of this string with all whitespace removed
Definition: qcstring.h:255
QCString
This is an alternative implementation of QCString.
Definition: qcstring.h:108