浏览该文件的文档.
44 #define ASSERT(x) if ( !(x) )\
45 fprintf(stderr,"ASSERT: \"%s\" in %s (%d)\n",#x,__FILE__,__LINE__)
52 void *
qmemmove(
void *dst,
const void *src,
size_t len );
54 #if defined(_OS_WIN32_)
55 #define qsnprintf _snprintf
57 #define qsnprintf snprintf
63 {
return (
uint)strlen(str); }
66 {
return str ? (
uint)strlen(str) : 0; }
68 inline char *
cstrcpy(
char *dst,
const char *src )
69 {
return strcpy(dst,src); }
71 inline char *
qstrcpy(
char *dst,
const char *src )
72 {
return src ? strcpy(dst, src) : 0; }
74 char *
qstrncpy(
char *dst,
const char *src,
size_t len);
76 inline int cstrcmp(
const char *str1,
const char *str2 )
77 {
return strcmp(str1,str2); }
80 {
return s==0 || *s==0; }
82 inline int qstrcmp(
const char *str1,
const char *str2 )
83 {
return (str1 && str2) ? strcmp(str1,str2) :
88 inline int cstrncmp(
const char *str1,
const char *str2,
size_t len )
89 {
return strncmp(str1,str2,len); }
91 inline int qstrncmp(
const char *str1,
const char *str2,
size_t len )
92 {
return (str1 && str2) ? strncmp(str1,str2,len) :
98 {
return c==
' ' || c==
'\t' || c==
'\n' || c==
'\r'; }
100 int qstricmp(
const char *str1,
const char *str2 );
102 int qstrnicmp(
const char *str1,
const char *str2,
size_t len );
164 bool resize(
size_t newlen ) {
m_rep.resize( newlen>0 ? newlen-1 : 0 );
return TRUE; }
175 bool fill(
char c,
int len = -1 )
177 int l = len==-1 ? (int)
m_rep.size() : len;
178 m_rep = std::string(l,c);
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;
189 int findRev(
char c,
int index=-1,
bool cs=
TRUE)
const;
224 QCString mid(
size_t index,
size_t len=
static_cast<size_t>(-1))
const
226 size_t slen =
m_rep.size();
227 if (len==
static_cast<uint>(-1)) len = slen-index;
245 size_t sl =
m_rep.size();
247 size_t start=0,
end=sl-1;
257 size_t sl =
m_rep.size();
258 if (sl==0)
return *
this;
259 std::string result =
m_rep;
266 if (dst<
m_rep.size()) result.resize(dst);
278 size_t ol =
m_rep.size();
282 std::memset(&
m_rep[ol],
' ',index-ol);
294 size_t len = s ?
qstrlen(s) : 0;
297 size_t ol =
m_rep.size();
300 m_rep.resize(index+len);
301 std::memset(&
m_rep[ol],
' ',index-ol);
302 std::memcpy(&
m_rep[index],s,len+1);
306 m_rep.insert(index,s);
314 char s[2] = { c,
'\0' };
351 return insert(0,s.c_str());
356 size_t ol =
m_rep.size();
357 if (index<ol && len>0)
m_rep.erase(index,index+len>=ol ? std::string::npos : len);
364 short toShort(
bool *ok=0,
int base=10 )
const;
366 int toInt(
bool *ok=0,
int base=10 )
const;
368 long toLong(
bool *ok=0,
int base=10 )
const;
374 m_rep = std::to_string(n);
380 m_rep = std::to_string(n);
386 m_rep = std::to_string(n);
392 m_rep = std::to_string(n);
398 m_rep = std::to_string(n);
404 m_rep = std::to_string(n);
410 if (
m_rep.empty() || s==0)
return s==0;
411 return m_rep.rfind(s,0)==0;
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;
433 #define HAS_IMPLICIT_CAST_TO_PLAIN_C_STRING 0
434 #if HAS_IMPLICIT_CAST_TO_PLAIN_C_STRING
436 operator const char *()
const
466 #define HAS_CHARACTER_APPEND_OPERATOR 1
467 #if HAS_CHARACTER_APPEND_OPERATOR
482 const char &
at(
size_t i)
const
571 #define HAD_PLUS_OPERATOR_FOR_CHAR 0
572 #if HAS_PLUS_OPERATOR_FOR_CHAR
591 if (s)
return s;
else return "";
599 inline const char *
qPrint(
const std::string &s)
651 std::string ss = s.
str();
QCString operator+(const QCString &s1, const QCString &s2)
QCString & operator=(const QCString &s)=default
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...
char * rawData()
Returns a writable pointer to the data.
QCString & replace(size_t index, size_t len, const char *s)
QCString(const std::string &s)
void * qmemmove(void *dst, const void *src, size_t len)
std::string convertUTF8ToLower(const std::string &input)
Converts the input string into a lower case version, also taking into account non-ASCII characters th...
const char & operator[](int i) const
bool operator==(const QCString &s1, const QCString &s2)
char * qstrdup(const char *)
uint length() const
Returns the length of the string, not counting the 0-terminator.
QCString & setNum(long n)
QCString & operator=(const char *str)
replaces the contents by that of C string str.
bool operator>=(const QCString &s1, const char *s2)
QCString(std::string &&s)
short toShort(bool *ok=0, int base=10) const
int findRev(char c, int index=-1, bool cs=TRUE) const
bool isEmpty() const
Returns TRUE iff the string is empty
QCString & setNum(uint n)
uint size() const
Returns the length of the string, not counting the 0-terminator.
char * qstrcpy(char *dst, const char *src)
QCString & operator+=(const std::string &s)
std::string toStdString(const QCString &s)
QCString(size_t size)
creates a string with room for size characters
char & at(size_t i)
Returns a reference to the character at index i.
int find(char c, int index=0, bool cs=TRUE) const
uint toUInt(bool *ok=0, int base=10) const
int qstrncmp(const char *str1, const char *str2, size_t len)
QCString & insert(size_t index, char c)
bool operator<=(const QCString &s1, const char *s2)
DirIterator end(const DirIterator &) noexcept
int contains(char c, bool cs=TRUE) const
QCString & operator+=(const QCString &s)
QCString & operator+=(const char *s)
Appends string str to this string and returns a reference to the result.
bool startsWith(const QCString &s) const
QCString(const char *str, size_t maxlen)
creates a string from str and copies over the first maxlen characters.
QCString stripWhiteSpace() const
returns a copy of this string with leading and trailing whitespace removed
QCString left(size_t len) const
QCString & prepend(const std::string &s)
QCString & insert(size_t index, const QCString &s)
int qstricmp(const char *str1, const char *str2)
QCString simplifyWhiteSpace() const
return a copy of this string with leading and trailing whitespace removed and multiple whitespace cha...
bool endsWith(const QCString &s) const
bool operator!=(const QCString &s1, const QCString &s2)
QCString(const char *str)
creates a string from a plain C string.
bool operator<(const QCString &s1, const QCString &s2)
QCString & append(const char *s)
bool operator>(const QCString &s1, const char *s2)
int toInt(bool *ok=0, int base=10) const
ushort toUShort(bool *ok=0, int base=10) const
std::ostream & operator<<(std::ostream &os, const QCString &s)
int cstrcmp(const char *str1, const char *str2)
char * qstrncpy(char *dst, const char *src, size_t len)
bool fill(char c, int len=-1)
Fills a string with a predefined character
uint cstrlen(const char *str)
ulong toULong(bool *ok=0, int base=10) const
QCString & setNum(ushort n)
QCString & operator+=(char c)
Appends character c to this string and returns a reference to the result.
QCString & setNum(short n)
char * cstrcpy(char *dst, const char *src)
bool truncate(size_t pos)
Truncates the string at position pos.
long toLong(bool *ok=0, int base=10) const
Various UTF8 related helper functions.
QCString mid(size_t index, size_t len=static_cast< size_t >(-1)) const
bool stripPrefix(const char *prefix)
QCString substitute(const QCString &str, const QCString &find, const QCString &replace)
substitute all occurrences of src in s by dst
QCString & remove(size_t index, size_t len)
QCString & append(const std::string &s)
bool qisempty(const char *s)
QCString & append(char c)
QCString & operator=(const std::string &s)
bool endsWith(const char *s) const
bool startsWith(const char *s) const
bool isNull() const
Returns TRUE iff the string is empty.
const char & at(size_t i) const
const char * qPrint(const char *s)
QCString & append(const QCString &s)
const char * data() const
Returns a pointer to the contents of the string in the form of a 0-terminated C string
int qstrcmp(const char *str1, const char *str2)
QCString & setNum(ulong n)
int qstrnicmp(const char *str1, const char *str2, size_t len)
uint64 toUInt64(bool *ok=0, int base=10) const
char & operator[](int i)
Indexing operator.
int cstrncmp(const char *str1, const char *str2, size_t len)
std::string convertUTF8ToUpper(const std::string &input)
Converts the input string into a upper case version, also taking into account non-ASCII characters th...
QCString & prepend(const QCString &s)
bool stripPrefix(const QCString &prefix)
QCString right(size_t len) const
QCString & prepend(const char *s)
bool resize(size_t newlen)
Resizes the string to hold newlen characters (this value should also count the 0-terminator).
uint qstrlen(const char *str)
QCString & insert(size_t index, const char *s)
QCString & sprintf(const char *format,...)
QCString removeWhiteSpace() const
returns a copy of this string with all whitespace removed
This is an alternative implementation of QCString.