Doxygen
Loading...
Searching...
No Matches
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#include <string>
21#include <string_view>
22#include <algorithm>
23
24#include <cctype>
25#include <cstring>
26#include <cstdio>
27#include <cstdlib>
28#include <cstdint>
29#include <ostream>
30
31#include "utf8.h"
32
33#ifndef FALSE
34#define FALSE false
35#endif
36#ifndef TRUE
37#define TRUE true
38#endif
39#define ASSERT(x) if ( !(x) )\
40 fprintf(stderr,"ASSERT: \"%s\" in %s (%d)\n",#x,__FILE__,__LINE__)
41
42
43/*****************************************************************************
44 Safe and portable C string functions; extensions to standard string.h
45 *****************************************************************************/
46
47void *qmemmove( void *dst, const void *src, size_t len );
48
49#define qsnprintf snprintf
50
51//! Returns a copy of a string \a s.
52//! Note that memory is passed to the caller, use qstrfree() to release.
53char *qstrdup( const char *s );
54//! Frees the memory allocated using qstrdup().
55void qstrfree( const char *s );
56
57//! Returns the length of string \a str, or 0 if a null pointer is passed.
58inline uint32_t qstrlen( const char *str )
59{ return str ? static_cast<uint32_t>(strlen(str)) : 0; }
60
61inline char *qstrcpy( char *dst, const char *src )
62{ return src ? strcpy(dst, src) : nullptr; }
63
64char *qstrncpy(char *dst,const char *src, size_t len);
65
66inline bool qisempty( const char *s)
67{ return s==nullptr || *s=='\0'; }
68
69inline int qstrcmp( const char *str1, const char *str2 )
70{ return (str1 && str2) ? strcmp(str1,str2) : // both non-empty
71 (qisempty(str1) && qisempty(str2)) ? 0 : // both empty
72 qisempty(str1) ? -1 : 1; // one empty, other non-empty
73}
74
75inline int qstrncmp( const char *str1, const char *str2, size_t len )
76{ return (str1 && str2) ? strncmp(str1,str2,len) : // both non-empty
77 (qisempty(str1) && qisempty(str2)) ? 0 : // both empty
78 qisempty(str1) ? -1 : 1; // one empty other non-empty
79}
80
81inline bool qisspace(char c)
82{ return c==' ' || c=='\t' || c=='\n' || c=='\r'; }
83
84int qstricmp( const char *str1, const char *str2 );
85
86inline int qstricmp_sort( const char *str1, const char *str2 )
87{
88 int result = qstricmp(str1,str2);
89 return result==0 ? qstrcmp(str1,str2) : result;
90}
91
92
93int qstrnicmp( const char *str1, const char *str2, size_t len );
94
95using JavaCCString = std::basic_string<JAVACC_CHAR_TYPE>;
96
97/** This is an alternative implementation of QCString. It provides basically
98 * the same functions but uses std::string as the underlying string type
99 */
101{
102 public:
103 QCString() = default;
104 QCString(const QCString &) = default;
105 QCString &operator=(const QCString &) = default;
106 QCString(QCString &&) = default;
108 ~QCString() = default;
109
110 QCString( const std::string &s ) : m_rep(s) {}
111
112 QCString( std::string &&s) : m_rep(std::move(s)) {}
113
114 QCString &operator=( std::string &&s)
115 {
116 m_rep=std::move(s);
117 return *this;
118 }
119
120 QCString( std::string_view sv) : m_rep(sv) {}
121
122 QCString &operator=(std::string_view sv)
123 {
124 m_rep=sv;
125 return *this;
126 }
127
128 QCString( int ) = delete;
129
130 /** For converting a JavaCC string */
132 {
133 m_rep.resize(s.size());
134 memcpy(m_rep.data(),s.data(),s.size());
135 }
137 {
138 m_rep.resize(s.size());
139 memcpy(m_rep.data(),s.data(),s.size());
140 return *this;
141 }
142
143 /** creates a string with room for size characters
144 * @param[in] size the number of character to allocate (also counting the 0-terminator!)
145 */
147 explicit QCString( size_t size, SizeTag t) { m_rep.resize(size); }
148
149 /** creates a string from a plain C string.
150 * @param[in] str A zero terminated C string. When 0 an empty string is created.
151 */
152 QCString( const char *str ) : m_rep(str?str:"") {}
153
154 /** creates a string from \a str and copies over the first \a maxlen characters. */
155 QCString( const char *str, size_t maxlen ) : m_rep(str?str:"") { m_rep.resize(maxlen); }
156
157 /** replaces the contents by that of C string \a str. */
158 QCString &operator=( const char *str) { m_rep = str?str:""; return *this; }
159
160 QCString &operator=( const std::string &s) { m_rep = s; return *this; }
161
162 /** Returns TRUE iff the string is empty */
163 bool isEmpty() const { return m_rep.empty(); }
164
165 /** Returns the length of the string, not counting the 0-terminator. Equivalent to size(). */
166 size_t length() const { return m_rep.size(); }
167
168 /** Returns the length of the string, not counting the 0-terminator. */
169 size_t size() const { return m_rep.size(); }
170
171 /** Returns a pointer to the contents of the string in the form of a 0-terminated C string */
172 const char *data() const { return m_rep.c_str(); }
173
174 std::string_view view() const { return m_rep; }
175
176 /** Returns a writable pointer to the data.
177 */
178 char *rawData() { return &m_rep[0]; }
179
180 void resize( size_t newlen) { m_rep.resize(newlen); }
181
182 void clear() { m_rep.clear(); }
183
184 /** Reserve space for \a size bytes without changing the string contents */
185 void reserve( size_t size ) { m_rep.reserve(size); }
186
187 /** Fills a string with a predefined character
188 * @param[in] c the character used to fill the string with.
189 * @param[in] len the number of character to fill. Use -1 to fill the whole string.
190 * @note the string will be resized to contain \a len characters. The contents of the
191 * string will be lost.
192 */
193 QCString fill( char c, int len = -1 )
194 {
195 int l = len==-1 ? static_cast<int>(m_rep.size()) : len;
196 m_rep = std::string(l,c);
197 return *this;
198 }
199
200 QCString &sprintf( const char *format, ... );
201
202 int find( char c, int index=0, bool cs=TRUE ) const;
203 int find( const char *str, int index=0, bool cs=TRUE ) const;
204 int find( const std::string &str, int index=0, bool cs=TRUE ) const;
205 int find( const QCString &str, int index=0, bool cs=TRUE ) const;
206
207 int findRev( char c, int index=-1, bool cs=TRUE) const;
208 int findRev( const char *str, int index=-1, bool cs=TRUE) const;
209
210 int contains( char c, bool cs=TRUE ) const;
211 int contains( const char *str, bool cs=TRUE ) const;
212
214 {
215 if (prefix.isEmpty() || m_rep.empty()) return FALSE;
216 if (m_rep.rfind(prefix.data(),0)==0) // string starts with prefix
217 {
218 m_rep.erase(0,prefix.length());
219 return TRUE;
220 }
221 return FALSE;
222 }
223
224 bool stripPrefix(const char *prefix)
225 {
226 return stripPrefix(QCString(prefix));
227 }
228
229 QCString left( size_t len ) const
230 {
231 return m_rep.empty() ? QCString() : QCString(m_rep.substr(0,len));
232 }
233
234 QCString right( size_t len ) const
235 {
236 return m_rep.empty() ? QCString() :
237 len<m_rep.size() ? QCString(m_rep.substr(m_rep.size()-len,len)) :
238 *this;
239 }
240
241 QCString mid( size_t index, size_t len=static_cast<size_t>(-1) ) const
242 {
243 size_t slen = m_rep.size();
244 if (len==static_cast<uint32_t>(-1)) len = slen-index;
245 return m_rep.empty() || index>slen || len==0 ? QCString() :
246 QCString(m_rep.substr(index,len));
247 }
248
250 {
252 }
253
255 {
257 }
258
259 /// returns a copy of this string with leading and trailing whitespace removed
261 {
262 size_t sl = m_rep.size();
263 if (sl==0 || (!qisspace(m_rep[0]) && !qisspace(m_rep[sl-1]))) return *this;
264 size_t start=0,end=sl-1;
265 while (start<sl && qisspace(m_rep[start])) start++;
266 if (start==sl) return QCString(); // only whitespace
267 while (end>start && qisspace(m_rep[end])) end--;
268 return QCString(m_rep.substr(start,1+end-start));
269 }
270
272
273 // Returns a quoted copy of this string, unless it is already quoted.
274 // Note that trailing and leading whitespace is removed.
276 {
277 size_t start=0, sl=m_rep.size(), end=sl-1;
278 while (start<sl && qisspace(m_rep[start])) start++; // skip over leading whitespace
279 if (start==sl) return QCString(); // only whitespace
280 while (end>start && qisspace(m_rep[end])) end--; // skip over trailing whitespace
281 bool needsQuotes=false;
282 size_t i=start;
283 if (i<end && m_rep[i]!='"') // stripped string has at least non-whitespace unquoted character
284 {
285 while (i<end && !needsQuotes) // check if the to be quoted part has at least one whitespace character
286 {
287 needsQuotes = m_rep[i] =='-';
288 needsQuotes |= qisspace(m_rep[i++]);
289 }
290 }
291 QCString result(m_rep.substr(start,1+end-start));
292 if (needsQuotes)
293 {
294 result.prepend("\"");
295 result.append("\"");
296 }
297 return result;
298 }
299
300 /// returns a copy of this string with all whitespace removed
302 {
303 size_t sl = m_rep.size();
304 if (sl==0) return *this;
305 std::string result = m_rep;
306 size_t src=0,dst=0;
307 while (src<sl)
308 {
309 if (!qisspace(m_rep[src])) result[dst++]=m_rep[src];
310 src++;
311 }
312 if (dst<m_rep.size()) result.resize(dst);
313 return QCString(result);
314 }
315
316 /// return a copy of this string with leading and trailing whitespace removed and multiple
317 /// whitespace characters replaced by a single space
319
320 // Returns a copy of this string repeated n times
321 QCString repeat(unsigned int n) const
322 {
323 QCString result(n * size(), ExplicitSize);
324 size_t offset = 0;
325 for (offset = 0; offset < n * size(); offset += size())
326 {
327 memcpy(result.rawData() + offset, data(), size());
328 }
329 return result;
330 }
331
332 QCString &insert( size_t index, const QCString &s )
333 {
334 if (s.length()>0)
335 {
336 size_t ol = m_rep.size();
337 if (index>ol) // insert beyond end of string and fill gap with spaces
338 {
339 m_rep.resize(index+s.length());
340 std::memset(&m_rep[ol],' ',index-ol);
341 std::memcpy(&m_rep[index],s.data(),s.length()+1);
342 }
343 else // insert inside the string
344 {
345 m_rep.insert(index,s.str());
346 }
347 }
348 return *this;
349 }
350
351 QCString &insert( size_t index, std::string_view s)
352 {
353 if (s.length()>0)
354 {
355 size_t ol = m_rep.size();
356 if (index>ol) // insert beyond end of string and fill gap with spaces
357 {
358 m_rep.resize(index+s.length());
359 std::memset(&m_rep[ol],' ',index-ol);
360 std::memcpy(&m_rep[index],s.data(),s.length()+1);
361 }
362 else // insert inside the string
363 {
364 m_rep.insert(index,s);
365 }
366 }
367 return *this;
368 }
369
370 QCString &insert( size_t index, const char *s )
371 {
372 size_t len = s ? qstrlen(s) : 0;
373 if (len>0)
374 {
375 size_t ol = m_rep.size();
376 if (index>ol) // insert beyond end of string and fill gap with spaces
377 {
378 m_rep.resize(index+len);
379 std::memset(&m_rep[ol],' ',index-ol);
380 std::memcpy(&m_rep[index],s,len+1);
381 }
382 else // insert inside the string
383 {
384 m_rep.insert(index,s);
385 }
386 }
387 return *this;
388 }
389
390 QCString &insert( size_t index, char c)
391 {
392 char s[2] = { c, '\0' };
393 return insert(index,s);
394 }
395
396 QCString &append( char c)
397 {
398 m_rep+=c;
399 return *this;
400 }
401
402 QCString &append( const char *s )
403 {
404 return operator+=(s);
405 }
406
408 {
409 return operator+=(s);
410 }
411
412 QCString &append( const std::string &s )
413 {
414 return operator+=(s);
415 }
416
417 QCString &append( std::string_view s)
418 {
419 return operator+=(s);
420 }
421
422 QCString &prepend( const char *s )
423 {
424 return insert(0,s);
425 }
426
428 {
429 return insert(0,s.data());
430 }
431
432 QCString &prepend( const std::string &s )
433 {
434 return insert(0,s.c_str());
435 }
436
437 QCString &prepend( std::string_view s)
438 {
439 return insert(0,s);
440 }
441
442 QCString &remove( size_t index, size_t len )
443 {
444 size_t ol = m_rep.size();
445 if (index<ol && len>0) m_rep.erase(index,index+len>=ol ? std::string::npos : len);
446 return *this;
447 }
448
449 QCString &replace( size_t index, size_t len, const char *s);
450
451 short toShort( bool *ok=nullptr, int base=10 ) const;
452 uint16_t toUShort( bool *ok=nullptr, int base=10 ) const;
453 int toInt( bool *ok=nullptr, int base=10 ) const;
454 uint32_t toUInt( bool *ok=nullptr, int base=10 ) const;
455 long toLong( bool *ok=nullptr, int base=10 ) const;
456 unsigned long toULong( bool *ok=nullptr, int base=10 ) const;
457 uint64_t toUInt64( bool *ok=nullptr, int base=10 ) const;
458
459 QCString &setNum(short n)
460 {
461 m_rep = std::to_string(n);
462 return *this;
463 }
464
465 QCString &setNum(uint16_t n)
466 {
467 m_rep = std::to_string(n);
468 return *this;
469 }
470
472 {
473 m_rep = std::to_string(n);
474 return *this;
475 }
476
477 QCString &setNum(uint32_t n)
478 {
479 m_rep = std::to_string(n);
480 return *this;
481 }
482
484 {
485 m_rep = std::to_string(n);
486 return *this;
487 }
488
489 QCString &setNum(long long n)
490 {
491 m_rep = std::to_string(n);
492 return *this;
493 }
494
495 QCString &setNum(unsigned long long n)
496 {
497 m_rep = std::to_string(n);
498 return *this;
499 }
500
501 QCString &setNum(unsigned long n)
502 {
503 m_rep = std::to_string(n);
504 return *this;
505 }
506
507 bool startsWith( const char *s ) const
508 {
509 if (m_rep.empty() || s==nullptr) return s==nullptr;
510 return m_rep.rfind(s,0)==0; // looking "backward" starting and ending at index 0
511 }
512
513 bool startsWith( const std::string &s) const
514 {
515 return m_rep.rfind(s,0)==0; // looking "backward" starting and ending at index 0
516 }
517
518 bool startsWith( const QCString &s ) const
519 {
520 if (m_rep.empty() || s.isEmpty()) return s.isEmpty();
521 return m_rep.rfind(s.str(),0)==0; // looking "backward" starting and ending at index 0
522 }
523
524 bool endsWith(const char *s) const
525 {
526 if (m_rep.empty() || s==nullptr) return s==nullptr;
527 size_t l = strlen(s);
528 return m_rep.length()>=l && m_rep.compare(m_rep.length()-l, l, s, l)==0;
529 }
530
531 bool endsWith(const std::string &s) const
532 {
533 size_t l = s.length();
534 return m_rep.length()>=l && m_rep.compare(m_rep.length()-l, l, s)==0;
535 }
536
537 bool endsWith(const QCString &s) const
538 {
539 size_t l = s.length();
540 return m_rep.length()>=l && m_rep.compare(m_rep.length()-l, l, s.str())==0;
541 }
542
543#define HAS_IMPLICIT_CAST_TO_PLAIN_C_STRING 0
544#if HAS_IMPLICIT_CAST_TO_PLAIN_C_STRING
545 /** Converts the string to a plain C string */
546 operator const char *() const
547 {
548 return data();
549 }
550#endif
551
552 const std::string &str() const
553 {
554 return m_rep;
555 }
556
558 {
559 m_rep+=s.str();
560 return *this;
561 }
562
563 QCString &operator+=( const std::string &s)
564 {
565 m_rep+=s;
566 return *this;
567 }
568
569 QCString &operator+=(std::string_view s)
570 {
571 m_rep+=s;
572 return *this;
573 }
574
575 /** Appends string \a str to this string and returns a reference to the result. */
576 QCString &operator+=( const char *s )
577 {
578 if (s) m_rep+=s;
579 return *this;
580 }
581
582#define HAS_CHARACTER_APPEND_OPERATOR 1
583#if HAS_CHARACTER_APPEND_OPERATOR
584 /** Appends character \a c to this string and returns a reference to the result. */
585 QCString &operator+=( char c )
586 {
587 m_rep+=c;
588 return *this;
589 }
590#endif
591
592 /** Returns a reference to the character at index \a i. */
593 char &at( size_t i)
594 {
595 return m_rep[i];
596 }
597
598 const char &at( size_t i) const
599 {
600 return m_rep[i];
601 }
602
603 /** Indexing operator. Equivalent to at(). */
604 char &operator[]( size_t i )
605 {
606 return m_rep[i];
607 }
608
609 const char &operator[]( size_t i ) const
610 {
611 return m_rep[i];
612 }
613
614 private:
615 std::string m_rep;
616};
617
618/*****************************************************************************
619 QCString non-member operators
620 *****************************************************************************/
621
622inline bool operator==( const QCString &s1, const QCString &s2 )
623{ return s1.str() == s2.str(); }
624
625inline bool operator==( const QCString &s1, const char *s2 )
626{ return qstrcmp(s1.data(),s2) == 0; }
627
628inline bool operator==( const char *s1, const QCString &s2 )
629{ return qstrcmp(s1,s2.data()) == 0; }
630
631inline bool operator!=( const QCString &s1, const QCString &s2 )
632{ return s1.str() != s2.str(); }
633
634inline bool operator!=( const QCString &s1, const char *s2 )
635{ return qstrcmp(s1.data(),s2) != 0; }
636
637inline bool operator!=( const char *s1, const QCString &s2 )
638{ return qstrcmp(s1,s2.data()) != 0; }
639
640inline bool operator<( const QCString &s1, const QCString& s2 )
641{ return qstrcmp(s1.data(),s2.data()) < 0; }
642
643inline bool operator<( const QCString &s1, const char *s2 )
644{ return qstrcmp(s1.data(),s2) < 0; }
645
646inline bool operator<( const char *s1, const QCString &s2 )
647{ return qstrcmp(s1,s2.data()) < 0; }
648
649inline bool operator<=( const QCString &s1, const char *s2 )
650{ return qstrcmp(s1.data(),s2) <= 0; }
651
652inline bool operator<=( const char *s1, const QCString &s2 )
653{ return qstrcmp(s1,s2.data()) <= 0; }
654
655inline bool operator>( const QCString &s1, const char *s2 )
656{ return qstrcmp(s1.data(),s2) > 0; }
657
658inline bool operator>( const char *s1, const QCString &s2 )
659{ return qstrcmp(s1,s2.data()) > 0; }
660
661inline bool operator>=( const QCString &s1, const char *s2 )
662{ return qstrcmp(s1.data(),s2) >= 0; }
663
664inline bool operator>=( const char *s1, const QCString &s2 )
665{ return qstrcmp(s1,s2.data()) >= 0; }
666
667inline QCString operator+( const QCString &s1, const QCString &s2 )
668{
669 return QCString(s1.str()+s2.str());
670}
671
672
673inline QCString operator+( const QCString &s1, const char *s2 )
674{
675 QCString tmp(s1);
676 tmp.append(s2);
677 return tmp;
678}
679
680inline QCString operator+( const char *s1, const QCString &s2 )
681{
682 QCString tmp(s1);
683 tmp.append(s2);
684 return tmp;
685}
686
687inline const char *qPrint(const char *s)
688{
689 if (s) return s; else return "";
690}
691
692inline const char *qPrint(const QCString &s)
693{
694 if (!s.isEmpty()) return s.data(); else return "";
695}
696
697inline const char *qPrint(const std::string &s)
698{
699 return s.c_str();
700}
701
702inline std::string toStdString(const QCString &s)
703{
704 return s.str();
705}
706
707//---- overloads
708
709inline int qstrcmp( const QCString &str1, const char *str2 )
710{
711 return qstrcmp(str1.data(),str2);
712}
713
714inline int qstrcmp( const char *str1, const QCString &str2 )
715{
716 return qstrcmp(str1,str2.data());
717}
718
719inline int qstrcmp( const QCString &str1, const QCString &str2 )
720{
721 return qstrcmp(str1.data(),str2.data());
722}
723
724inline int qstricmp( const QCString &str1, const char *str2 )
725{
726 return qstricmp(str1.data(),str2);
727}
728
729inline int qstricmp( const char *str1, const QCString &str2 )
730{
731 return qstricmp(str1,str2.data());
732}
733
734inline int qstricmp( const QCString &str1, const QCString &str2 )
735{
736 return qstricmp(str1.data(),str2.data());
737}
738
739inline int qstricmp_sort( const QCString &str1, const char *str2 )
740{
741 return qstricmp_sort(str1.data(),str2);
742}
743
744inline int qstricmp_sort( const char *str1, const QCString &str2 )
745{
746 return qstricmp_sort(str1,str2.data());
747}
748
749inline int qstricmp_sort( const QCString &str1, const QCString &str2 )
750{
751 return qstricmp_sort(str1.data(),str2.data());
752}
753
754
755inline int qstrnicmp( const QCString &str1, const char *str2, size_t len )
756{
757 return qstrnicmp(str1.data(),str2,len);
758}
759
760inline int qstrnicmp( const char *str1, const QCString &str2, size_t len )
761{
762 return qstrnicmp(str1,str2.data(),len);
763}
764
765inline int qstrnicmp( const QCString &str1, const QCString &str2, size_t len )
766{
767 return qstrnicmp(str1.data(),str2.data(),len);
768}
769
770// helper functions
771QCString substitute(const QCString &str,const QCString &find,const QCString &replace);
772inline QCString substitute(const QCString &str,const char *find,const char *replace)
773{
774 return substitute(str,QCString(find),QCString(replace));
775}
776QCString substitute(const QCString &s,const QCString &src,const QCString &dst,int skip_seq);
777
778inline QCString substitute(const QCString &s,char srcChar,char dstChar)
779{
780 std::string ss = s.str();
781 std::replace(ss.begin(),ss.end(),srcChar,dstChar);
782 return QCString(ss);
783}
784
785inline std::ostream& operator<<(std::ostream& os, const QCString& s)
786{
787 os << s.str();
788 return os;
789}
790
791#endif // QCSTRING_H
constexpr auto prefix
Definition anchor.cpp:44
This is an alternative implementation of QCString.
Definition qcstring.h:101
int find(char c, int index=0, bool cs=TRUE) const
Definition qcstring.cpp:43
QCString & prepend(const char *s)
Definition qcstring.h:422
QCString & insert(size_t index, const char *s)
Definition qcstring.h:370
QCString(std::string_view sv)
Definition qcstring.h:120
int toInt(bool *ok=nullptr, int base=10) const
Definition qcstring.cpp:254
QCString upper() const
Definition qcstring.h:254
QCString & setNum(uint32_t n)
Definition qcstring.h:477
QCString & operator=(QCString &&)=default
size_t length() const
Returns the length of the string, not counting the 0-terminator.
Definition qcstring.h:166
QCString & operator=(const QCString &)=default
QCString & operator=(std::string_view sv)
Definition qcstring.h:122
bool startsWith(const char *s) const
Definition qcstring.h:507
QCString(const char *str)
creates a string from a plain C string.
Definition qcstring.h:152
QCString(const JavaCCString &s)
For converting a JavaCC string.
Definition qcstring.h:131
QCString & setNum(long n)
Definition qcstring.h:483
QCString & setNum(uint16_t n)
Definition qcstring.h:465
QCString mid(size_t index, size_t len=static_cast< size_t >(-1)) const
Definition qcstring.h:241
QCString & operator=(const JavaCCString &s)
Definition qcstring.h:136
QCString & append(const char *s)
Definition qcstring.h:402
bool endsWith(const QCString &s) const
Definition qcstring.h:537
QCString lower() const
Definition qcstring.h:249
bool stripPrefix(const char *prefix)
Definition qcstring.h:224
QCString & operator+=(const std::string &s)
Definition qcstring.h:563
QCString & operator+=(const QCString &s)
Definition qcstring.h:557
bool endsWith(const char *s) const
Definition qcstring.h:524
char & at(size_t i)
Returns a reference to the character at index i.
Definition qcstring.h:593
~QCString()=default
QCString & append(const QCString &s)
Definition qcstring.h:407
uint64_t toUInt64(bool *ok=nullptr, int base=10) const
Definition qcstring.cpp:361
QCString & operator=(const std::string &s)
Definition qcstring.h:160
const char & operator[](size_t i) const
Definition qcstring.h:609
unsigned long toULong(bool *ok=nullptr, int base=10) const
Definition qcstring.cpp:317
char * rawData()
Returns a writable pointer to the data.
Definition qcstring.h:178
bool isEmpty() const
Returns TRUE iff the string is empty.
Definition qcstring.h:163
QCString & operator+=(std::string_view s)
Definition qcstring.h:569
QCString stripLeadingAndTrailingEmptyLines() const
Definition qcstring.cpp:578
QCString stripWhiteSpace() const
returns a copy of this string with leading and trailing whitespace removed
Definition qcstring.h:260
QCString & remove(size_t index, size_t len)
Definition qcstring.h:442
QCString repeat(unsigned int n) const
Definition qcstring.h:321
QCString & append(std::string_view s)
Definition qcstring.h:417
bool endsWith(const std::string &s) const
Definition qcstring.h:531
QCString(std::string &&s)
Definition qcstring.h:112
void resize(size_t newlen)
Definition qcstring.h:180
QCString & append(const std::string &s)
Definition qcstring.h:412
QCString fill(char c, int len=-1)
Fills a string with a predefined character.
Definition qcstring.h:193
std::string m_rep
Definition qcstring.h:615
QCString & prepend(const std::string &s)
Definition qcstring.h:432
QCString(QCString &&)=default
QCString & prepend(std::string_view s)
Definition qcstring.h:437
QCString & operator+=(const char *s)
Appends string str to this string and returns a reference to the result.
Definition qcstring.h:576
bool startsWith(const QCString &s) const
Definition qcstring.h:518
QCString(int)=delete
const std::string & str() const
Definition qcstring.h:552
QCString & setNum(short n)
Definition qcstring.h:459
uint16_t toUShort(bool *ok=nullptr, int base=10) const
Definition qcstring.cpp:244
QCString simplifyWhiteSpace() const
return a copy of this string with leading and trailing whitespace removed and multiple whitespace cha...
Definition qcstring.cpp:190
QCString & append(char c)
Definition qcstring.h:396
QCString right(size_t len) const
Definition qcstring.h:234
QCString & setNum(unsigned long long n)
Definition qcstring.h:495
QCString & operator=(std::string &&s)
Definition qcstring.h:114
size_t size() const
Returns the length of the string, not counting the 0-terminator.
Definition qcstring.h:169
QCString & setNum(long long n)
Definition qcstring.h:489
void reserve(size_t size)
Reserve space for size bytes without changing the string contents.
Definition qcstring.h:185
QCString & setNum(int n)
Definition qcstring.h:471
QCString & setNum(unsigned long n)
Definition qcstring.h:501
QCString(const QCString &)=default
char & operator[](size_t i)
Indexing operator.
Definition qcstring.h:604
QCString & sprintf(const char *format,...)
Definition qcstring.cpp:29
long toLong(bool *ok=nullptr, int base=10) const
Definition qcstring.cpp:265
SizeTag
creates a string with room for size characters
Definition qcstring.h:146
@ ExplicitSize
Definition qcstring.h:146
uint32_t toUInt(bool *ok=nullptr, int base=10) const
Definition qcstring.cpp:259
int findRev(char c, int index=-1, bool cs=TRUE) const
Definition qcstring.cpp:96
QCString & replace(size_t index, size_t len, const char *s)
Definition qcstring.cpp:217
QCString(const char *str, size_t maxlen)
creates a string from str and copies over the first maxlen characters.
Definition qcstring.h:155
QCString & insert(size_t index, char c)
Definition qcstring.h:390
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:172
std::string_view view() const
Definition qcstring.h:174
const char & at(size_t i) const
Definition qcstring.h:598
QCString(size_t size, SizeTag t)
Definition qcstring.h:147
bool startsWith(const std::string &s) const
Definition qcstring.h:513
QCString & prepend(const QCString &s)
Definition qcstring.h:427
QCString()=default
QCString & insert(size_t index, const QCString &s)
Definition qcstring.h:332
QCString removeWhiteSpace() const
returns a copy of this string with all whitespace removed
Definition qcstring.h:301
QCString left(size_t len) const
Definition qcstring.h:229
int contains(char c, bool cs=TRUE) const
Definition qcstring.cpp:148
bool stripPrefix(const QCString &prefix)
Definition qcstring.h:213
QCString quoted() const
Definition qcstring.h:275
void clear()
Definition qcstring.h:182
QCString(const std::string &s)
Definition qcstring.h:110
QCString & operator=(const char *str)
replaces the contents by that of C string str.
Definition qcstring.h:158
QCString & insert(size_t index, std::string_view s)
Definition qcstring.h:351
short toShort(bool *ok=nullptr, int base=10) const
Definition qcstring.cpp:234
DirIterator end(const DirIterator &) noexcept
Definition dir.cpp:175
int qstricmp_sort(const char *str1, const char *str2)
Definition qcstring.h:86
char * qstrncpy(char *dst, const char *src, size_t len)
Definition qcstring.cpp:437
int qstrncmp(const char *str1, const char *str2, size_t len)
Definition qcstring.h:75
bool operator>(const QCString &s1, const char *s2)
Definition qcstring.h:655
bool operator>=(const QCString &s1, const char *s2)
Definition qcstring.h:661
int qstricmp(const char *str1, const char *str2)
Definition qcstring.cpp:447
std::ostream & operator<<(std::ostream &os, const QCString &s)
Definition qcstring.h:785
QCString substitute(const QCString &str, const QCString &find, const QCString &replace)
substitute all occurrences of src in s by dst
Definition qcstring.cpp:482
bool qisspace(char c)
Definition qcstring.h:81
int qstrnicmp(const char *str1, const char *str2, size_t len)
Definition qcstring.cpp:463
const char * qPrint(const char *s)
Definition qcstring.h:687
#define TRUE
Definition qcstring.h:37
#define FALSE
Definition qcstring.h:34
bool operator<=(const QCString &s1, const char *s2)
Definition qcstring.h:649
uint32_t qstrlen(const char *str)
Returns the length of string str, or 0 if a null pointer is passed.
Definition qcstring.h:58
void qstrfree(const char *s)
Frees the memory allocated using qstrdup().
Definition qcstring.cpp:432
char * qstrcpy(char *dst, const char *src)
Definition qcstring.h:61
std::string toStdString(const QCString &s)
Definition qcstring.h:702
bool qisempty(const char *s)
Definition qcstring.h:66
int qstrcmp(const char *str1, const char *str2)
Definition qcstring.h:69
bool operator==(const QCString &s1, const QCString &s2)
Definition qcstring.h:622
QCString operator+(const QCString &s1, const QCString &s2)
Definition qcstring.h:667
void * qmemmove(void *dst, const void *src, size_t len)
Definition qcstring.cpp:407
bool operator<(const QCString &s1, const QCString &s2)
Definition qcstring.h:640
bool operator!=(const QCString &s1, const QCString &s2)
Definition qcstring.h:631
std::basic_string< JAVACC_CHAR_TYPE > JavaCCString
Definition qcstring.h:95
char * qstrdup(const char *s)
Definition qcstring.cpp:424
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
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
Various UTF8 related helper functions.