浏览该文件的文档.
27 va_start( ap, format );
30 if (l<minlen) {
resize(minlen); l=minlen; }
31 int n=vsnprintf(
rawData(), l, format, ap);
40 if (index<0 || index>=(
int)
length())
return -1;
44 pos = strchr(
data()+index,c);
49 c = (char)tolower((
unsigned char)c);
50 while (*pos && tolower((
unsigned char)*pos)!=c) pos++;
51 if (!*pos && c) pos=0;
53 return pos ? (int)(pos -
data()) : -1;
59 if (index<0 || index>=l)
return -1;
61 if (!*
str)
return index;
78 return pos ? (int)(pos -
data()) : -1;
83 return find(
str.data(),index,cs);
88 const char *b =
data();
91 if (len==0)
return -1;
97 return pos ? (int)(pos - b) : -1;
108 while ( pos>=b && *pos!=c) pos--;
112 c = (char)tolower((
unsigned char)c);
113 while ( pos>=b && tolower((
unsigned char)*pos)!=c) pos--;
115 return pos>=b ? (int)(pos - b) : -1;
122 if (index<0) index = len-slen;
123 else if (index>len)
return -1;
124 else if (index+slen>len) index=len-slen;
125 if (index<0)
return -1;
126 const char *pos =
data()+index;
129 for (
int i=index; i>=0; i--)
if (
qstrncmp(pos--,
str,slen)==0)
return i;
133 for (
int i=index; i>=0; i--)
if (
qstrnicmp(pos,
str,slen)==0)
return i;
140 if (
length()==0)
return 0;
142 const char *pos =
data();
145 while (*pos)
if (*pos++ == c) count++;
149 c = (char)tolower((
unsigned char)c);
152 if (tolower((
unsigned char)*pos)==c) count++;
163 const char *pos =
data();
186 const char *from =
data();
200 if ( to > first && *(to-1) == 0x20 )
203 result.
resize( (
int)(to - result.
data()) + 1 );
217 return c>=
'0' && c<=
'9' && (c-
'0') < base;
219 return (c>=
'0' && c<=
'9') ||
220 (c >=
'a' && c < char(
'a'+base-10)) ||
221 (c >=
'A' && c <
char(
'A'+base-10));
226 long v =
toLong( ok, base );
227 if ( ok && *ok && (v < -32768 || v > 32767) ) {
237 if ( ok && *ok && (v > 65535) ) {
246 return (
int)
toLong( ok, base );
257 const char *p =
data();
260 const long max_mult = INT_MAX / base;
267 if ( l && *p ==
'-' ) {
271 }
else if ( *p ==
'+' ) {
282 if ( *p>=
'0' && *p<=
'9' ) {
285 if ( *p >=
'a' && *p <=
'z' )
290 if ( val > max_mult || (val == max_mult && dv > (INT_MAX%base)+neg) )
304 return is_ok ? val : 0;
309 const char *p =
data();
312 const ulong max_mult = 429496729;
327 if ( *p>=
'0' && *p<=
'9' ) {
330 if ( *p >=
'a' && *p <=
'z' )
335 if ( val > max_mult || (val == max_mult && dv > (UINT_MAX%base)) )
348 return is_ok ? val : 0;
353 const char *p =
data();
356 const uint64 max_mult = 1844674407370955161ULL;
371 if ( *p>=
'0' && *p<=
'9' ) {
374 if ( *p >=
'a' && *p <=
'z' )
379 if ( val > max_mult || (val == max_mult && dv > (ULLONG_MAX%base)) )
392 return is_ok ? val : 0;
397 void *
qmemmove(
void *dst,
const void *src,
size_t len )
402 d = (
char *)dst + len - 1;
403 s = (
char *)src + len - 1;
406 }
else if ( dst < src ) {
419 char *dst =
new char[
qstrlen(str)+1];
420 return strcpy( dst, str );
423 char *
qstrncpy(
char *dst,
const char *src,
size_t len )
427 strncpy( dst, src, len );
440 return s1 == s2 ? 0 : (int)(s2 - s1);
441 for ( ; !(res = (c=(char)tolower(*s1)) - tolower(*s2)); s1++, s2++ )
447 int qstrnicmp(
const char *str1,
const char *str2,
size_t len )
454 return (
int)(s2 - s1);
455 for ( ; len--; s1++, s2++ ) {
456 if ( (res = (c=(
char)tolower(*s1)) - tolower(*s2)) )
469 int srcLen = src.
length();
470 int dstLen = dst.
length();
475 for (count=0, p=s.
data(); (q=strstr(p,src.
data()))!=0; p=q+srcLen) count++;
476 resLen = s.
length()+count*(dstLen-srcLen);
484 for (r=result.
rawData(), p=s.
data(); (q=strstr(p,src.
data()))!=0; p=q+srcLen)
490 if (dstLen>0) memcpy(r,dst.
data(),dstLen);
510 int srcLen = src.
length();
511 int dstLen = dst.
length();
516 for (count=0, p=s.
data(); (q=strstr(p,src.
data()))!=0; p=q+srcLen) count++;
517 resLen = s.
length()+count*(dstLen-srcLen);
525 for (r=result.
rawData(), p=s.
data(); (q=strstr(p,src.
data()))!=0; p=q+srcLen)
528 int seq = 0, skip = 0;
531 for (
const char *n=q+srcLen;
qstrncmp(n,src.
data(),srcLen)==0; seq=1+skip, n+=srcLen)
535 if (skip_seq > 0 && skip_seq != seq)
540 int l = (int)((q + seq * srcLen)-p);
552 if (dstLen>0) memcpy(r,dst.
data(),dstLen);
char * rawData()
Returns a writable pointer to the data.
QCString & replace(size_t index, size_t len, const char *s)
char * qstrdup(const char *str)
uint length() const
Returns the length of the string, not counting the 0-terminator.
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
char * qstrncpy(char *dst, const char *src, size_t len)
char * qstrcpy(char *dst, const char *src)
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)
int contains(char c, bool cs=TRUE) const
QCString & insert(size_t index, const QCString &s)
QCString simplifyWhiteSpace() const
return a copy of this string with leading and trailing whitespace removed and multiple whitespace cha...
int qstricmp(const char *str1, const char *str2)
int qstrnicmp(const char *str1, const char *str2, size_t len)
int toInt(bool *ok=0, int base=10) const
ushort toUShort(bool *ok=0, int base=10) const
ulong toULong(bool *ok=0, int base=10) const
long toLong(bool *ok=0, int base=10) const
QCString substitute(const QCString &s, const QCString &src, const QCString &dst)
substitute all occurrences of src in s by dst
QCString & remove(size_t index, size_t len)
const char * data() const
Returns a pointer to the contents of the string in the form of a 0-terminated C string
uint64 toUInt64(bool *ok=0, int base=10) const
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 & sprintf(const char *format,...)
static bool ok_in_base(char c, int base)
This is an alternative implementation of QCString.
void * qmemmove(void *dst, const void *src, size_t len)