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