📄 qcstring.3qt
字号:
Returns the number of times \fIstr\fR occurs in the string..PPThe match is case sensitive if \fIcs\fR is TRUE, or case insensitive if \fIcs\fR if FALSE..PPThis function counts overlapping substrings, for example, "banana" contains two occurrences of "ana"..PPSee also findRev() and Note on character comparisons..SH "int QCString::contains ( const QRegExp & rx ) const"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPCounts the number of overlapping occurrences of \fIrx\fR in the string..PPExample:.PP.nf.br QString s = "banana and panama";.br QRegExp r = QRegExp( "a[nm]a", TRUE, FALSE );.br s.contains( r ); // 4 matches.br.fi.PPSee also find() and findRev()..PP\fBWarning:\fR If you want to apply this function repeatedly to the same string it is more efficient to convert the string to a QString and apply the function to that..SH "QCString QCString::copy () const"Returns a deep copy of this string..PPSee also detach()..SH "bool QCString::fill ( char c, int len = -1 )"Fills the string with \fIlen\fR bytes of character \fIc\fR, followed by a '\0'-terminator..PPIf \fIlen\fR is negative, then the current string length is used..PPReturns FALSE is \fIlen\fR is nonnegative and there is not enough memory to resize the string; otherwise returns TRUE..SH "int QCString::find ( char c, int index = 0, bool cs = TRUE ) const"Finds the first occurrence of the character \fIc\fR, starting at position \fIindex\fR..PPThe search is case sensitive if \fIcs\fR is TRUE, or case insensitive if \fIcs\fR is FALSE..PPReturns the position of \fIc\fR, or -1 if \fIc\fR could not be found..PPSee also Note on character comparisons..PPExample: network/networkprotocol/nntp.cpp..SH "int QCString::find ( const char * str, int index = 0, bool cs = TRUE ) const"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPFinds the first occurrence of the string \fIstr\fR, starting at position \fIindex\fR..PPThe search is case sensitive if \fIcs\fR is TRUE, or case insensitive if \fIcs\fR is FALSE..PPReturns the position of \fIstr\fR, or -1 if \fIstr\fR could not be found..PPSee also Note on character comparisons..SH "int QCString::find ( const QRegExp & rx, int index = 0 ) const"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPFinds the first occurrence of the regular expression \fIrx\fR, starting at position \fIindex\fR..PPReturns the position of the next match, or -1 if \fIrx\fR was not found..PP\fBWarning:\fR If you want to apply this function repeatedly to the same string it is more efficient to convert the string to a QString and apply the function to that..SH "int QCString::findRev ( char c, int index = -1, bool cs = TRUE ) const"Finds the first occurrence of the character \fIc\fR, starting at position \fIindex\fR and searching backwards..PPThe search is case sensitive if \fIcs\fR is TRUE, or case insensitive if \fIcs\fR is FALSE..PPReturns the position of \fIc\fR, or -1 if \fIc\fR could not be found..PPSee also Note on character comparisons..SH "int QCString::findRev ( const char * str, int index = -1, bool cs = TRUE ) const"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPFinds the first occurrence of the string \fIstr\fR, starting at position \fIindex\fR and searching backwards..PPThe search is case sensitive if \fIcs\fR is TRUE, or case insensitive if \fIcs\fR is FALSE..PPReturns the position of \fIstr\fR, or -1 if \fIstr\fR could not be found..PPSee also Note on character comparisons..SH "int QCString::findRev ( const QRegExp & rx, int index = -1 ) const"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPFinds the first occurrence of the regular expression \fIrx\fR, starting at position \fIindex\fR and searching backwards..PPReturns the position of the next match (backwards), or -1 if \fIrx\fR was not found..PP\fBWarning:\fR If you want to apply this function repeatedly to the same string it is more efficient to convert the string to a QString and apply the function to that..SH "QCString & QCString::insert ( uint index, char c )"Inserts character \fIc\fR into the string at position \fIindex\fR and returns a reference to the string..PPIf \fIindex\fR is beyond the end of the string, the string is padded with spaces (ASCII 32) to length \fIindex\fR and then \fIc\fR is appended..PPExample:.PP.nf.br QCString s = "Yes";.br s.insert( 3, '!'); // s == "Yes!".br.fi.PPSee also remove() and replace()..SH "QCString & QCString::insert ( uint index, const char * s )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPInserts string \fIs\fR into the string at position \fIindex\fR..PPIf \fIindex\fR is beyond the end of the string, the string is padded with spaces (ASCII 32) to length \fIindex\fR and then \fIs\fR is appended..PP.nf.br QCString s = "I like fish";.br s.insert( 2, "don't "); // s == "I don't like fish".br.br s = "x"; // index 01234.br s.insert( 3, "yz" ); // s == "x yz".br.fi.SH "bool QCString::isEmpty () const"Returns TRUE if the string is empty, i.e. if length() == 0; otherwise returns FALSE. An empty string is not always a null string..PPSee example in isNull()..PPSee also isNull(), length(), and size()..SH "bool QCString::isNull () const"Returns TRUE if the string is null, i.e. if data() == 0; otherwise returns FALSE. A null string is also an empty string..PPExample:.PP.nf.br QCString a; // a.data() == 0, a.size() == 0, a.length() == 0.br QCString b == ""; // b.data() == "", b.size() == 1, b.length() == 0.br a.isNull(); // TRUE because a.data() == 0.br a.isEmpty(); // TRUE because a.length() == 0.br b.isNull(); // FALSE because b.data() == "".br b.isEmpty(); // TRUE because b.length() == 0.br.fi.PPSee also isEmpty(), length(), and size()..SH "QCString QCString::left ( uint len ) const"Returns a substring that contains the \fIlen\fR leftmost characters of the string..PPThe whole string is returned if \fIlen\fR exceeds the length of the string..PPExample:.PP.nf.br QCString s = "Pineapple";.br QCString t = s.left( 4 ); // t == "Pine".br.fi.PPSee also right() and mid()..PPExample: network/networkprotocol/nntp.cpp..SH "QCString QCString::leftJustify ( uint width, char fill = ' ', bool truncate = FALSE ) const"Returns a string of length \fIwidth\fR (plus one for the terminating '\0') that contains this string padded with the \fIfill\fR character..PPIf the length of the string exceeds \fIwidth\fR and \fItruncate\fR is FALSE (the default), then the returned string is a copy of the string. If the length of the string exceeds \fIwidth\fR and \fItruncate\fR is TRUE, then the returned string is a left(\fIwidth\fR)..PPExample:.PP.nf.br QCString s("apple");.br QCString t = s.leftJustify(8, '.'); // t == "apple...".br.fi.PPSee also rightJustify()..SH "uint QCString::length () const"Returns the length of the string, excluding the '\0'-terminator. Equivalent to calling \fCstrlen(data())\fR..PPNull strings and empty strings have zero length..PPSee also size(), isNull(), and isEmpty()..PPExample: network/networkprotocol/nntp.cpp..SH "QCString QCString::lower () const"Returns a new string that is a copy of this string converted to lower case..PPExample:.PP.nf.br QCString s("Credit");.br QCString t = s.lower(); // t == "credit".br.fi.PPSee also upper() and Note on character comparisons..SH "QCString QCString::mid ( uint index, uint len = 0xffffffff ) const"Returns a substring that contains at most \fIlen\fR characters from this string, starting at position \fIindex\fR..PPReturns a null string if the string is empty or if \fIindex\fR is out of range. Returns the whole string from \fIindex\fR if \fIindex+len\fR exceeds the length of the string..PPExample:.PP.nf.br QCString s = "Two pineapples";.br QCString t = s.mid( 4, 3 ); // t == "pin".br.fi.PPSee also left() and right()..PPExample: network/networkprotocol/nntp.cpp..SH "QCString::operator const char * () const"Returns the string data..SH "QCString & QCString::operator+= ( const char * str )"Appends string \fIstr\fR to the string and returns a reference to the string..SH "QCString & QCString::operator+= ( char c )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPAppends character \fIc\fR to the string and returns a reference to the string..SH "QCString & QCString::operator= ( const QCString & s )"Assigns a shallow copy of \fIs\fR to this string and returns a reference to this string..SH "QCString & QCString::operator= ( const char * str )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPAssigns a deep copy of \fIstr\fR to this string and returns a reference to this string..PPIf \fIstr\fR is 0 a null string is created..PPSee also isNull()..SH "QCString & QCString::prepend ( const char * s )"Prepend \fIs\fR to the string. Equivalent to insert(0, s)..PPSee also insert()..SH "QCString & QCString::remove ( uint index, uint len )"Removes \fIlen\fR characters from the string, starting at position \fIindex\fR, and returns a reference to the string..PPIf \fIindex\fR is out of range, nothing happens. If \fIindex\fR is valid, but \fIindex\fR + \fIlen\fR is larger than the length of the string, the string is truncated at position \fIindex\fR..PP.nf.br QCString s = "Montreal";.br s.remove( 1, 4 ); // s == "Meal".br.fi.PPSee also insert() and replace()..PPExample: network/networkprotocol/nntp.cpp..SH "QCString & QCString::replace ( uint index, uint len, const char * str )"Replaces \fIlen\fR characters from the string, starting at position \fIindex\fR, with \fIstr\fR, and returns a reference to the string..PPIf \fIindex\fR is out of range, nothing is removed and \fIstr\fR is appended at the end of the string. If \fIindex\fR is valid, but \fIindex\fR + \fIlen\fR is larger than the length of the string, \fIstr\fR replaces the rest of the string from position \fIindex\fR..PP.nf.br QCString s = "Say yes!";.br s.replace( 4, 3, "NO" ); // s == "Say NO!".br.fi.PPSee also insert() and remove()..SH "QCString & QCString::replace ( const QRegExp & rx, const char * str )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPReplaces every occurrence of \fIrx\fR in the string with \fIstr\fR. Returns a reference to the string..PPExample:.PP.nf.br QString s = "banana";.br s.replace( QRegExp("a.*a"), "" ); // becomes "b".br.br s = "banana";.br s.replace( QRegExp("^[bn]a"), "X" ); // becomes "Xnana".br.br s = "banana";.br s.replace( QRegExp("^[bn]a"), "" ); // becomes "nana".br.fi.PP\fBWarning:\fR If you want to apply this function repeatedly to the same string it is more efficient to convert the string to a QString and apply the function to that..SH "QCString & QCString::replace ( char c, const char * after )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPReplaces every occurrence of the character \fIc\fR in the string with \fIafter\fR. Returns a reference to the string..PPExample:.PP.nf.br QCString s = "a,b,c";.br s.replace( ',', " or " );.br // s == "a or b or c".br.fi.SH "QCString & QCString::replace ( const char * before, const char * after )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPReplaces every occurrence of the string \fIbefore\fR in the string with the string \fIafter\fR. Returns a reference to the string..PPExample:.PP.nf.br QCString s = "Greek is Greek";.br s.replace( "Greek", "English" );.br // s == "English is English".br.fi.SH "QCString & QCString::replace ( char c1, char c2 )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPReplaces every occurrence of \fIc1\fR with the char \fIc2\fR. Returns a reference to the string..SH "bool QCString::resize ( uint len )"Extends or shrinks the string to \fIlen\fR bytes, including the '\0'-terminator..PPA '\0'-terminator is set at position \fClen - 1\fR unless \fClen == 0\fR..PPExample:.PP.nf.br QCString s = "resize this string";.br s.resize( 7 ); // s == "resize".br.fi.PPSee also truncate()..PPExample: network/networkprotocol/nntp.cpp..SH "QCString QCString::right ( uint len ) const"Returns a substring that contains the \fIlen\fR rightmost characters of the string..PPThe whole string is returned if \fIlen\fR exceeds the length of the string..PPExample:.PP.nf.br QCString s = "Pineapple";.br QCString t = s.right( 5 ); // t == "apple".br.fi.PPSee also left() and mid()..PPExample: network/networkprotocol/nntp.cpp.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -