📄 qcstring.3qt
字号:
.PPSee also assign()..SH "QCString::QCString ( const char * str )"Constructs a string that is a deep copy of \fIstr.\fR.PPIf \fIstr\fR is 0 a null string is created..PPSee also isNull()..SH "QCString::QCString ( const char * str, uint maxsize )"Constructs a string that is a deep copy of \fIstr,\fR that is no more than \fImaxsize\fR bytes long including the '\\0'-terminator..PPExample:.PP.nf.br QCString str( "helloworld", 6 ); // Assigns "hello" to str..fi.PPIf \fIstr\fR contains a 0 byte within the first \fImaxsize\fR bytes, the resulting QCString will be terminated by the 0. If \fIstr\fR is 0 a null string is created..PPSee also isNull()..SH "QCString::QCString ( int size )"Constructs a string with room for \fIsize\fR characters, including the '\\0'-terminator. Makes a null string if \fIsize\fR == 0..PPIf \fIsize\fR > 0, then the first and last characters in the string are initialized to '\\0'. All other characters are uninitialized..PPSee also resize() and isNull()..SH "QCString::operator const char * () const"Returns the string data..SH "QCString& QCString::append ( const char * str )"Appends \fIstr\fR to the string and returns a reference to the string. Equivalent to operator+=()..SH "int QCString::contains ( char c, bool cs=TRUE ) const"Returns the number of times the character \fIc\fR occurs in the string..PPThe match is case sensitive if \fIcs\fR is TRUE, or case insensitive if \fIcs\fR if FALSE..SH "int QCString::contains ( const QRegExp & rx ) const"Counts 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.fi.PPSee also find() and findRev()..SH "int QCString::contains ( const char * str, bool cs=TRUE ) const"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()..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 value \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 no memory to resize the string, otherwise TRUE is returned..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..SH "int QCString::find ( const QRegExp & rx, int index=0 ) const"Finds 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..SH "int QCString::find ( const char * str, int index=0, bool cs=TRUE ) const"Finds 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..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..SH "int QCString::findRev ( const QRegExp & rx, int index=-1 ) const"Finds the first occurrence of the regular expression \fIrx,\fR starting at position \fIindex\fR and searching backwards..PPThe search will start from the end of the string if \fIindex\fR is negative..PPReturns the position of the next match (backwards), or -1 if \fIrx\fR was not found..SH "int QCString::findRev ( const char * str, int index=-1, bool cs=TRUE ) const"Finds 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..SH "QCString & QCString::insert ( uint index, char c )"Insert \fIc\fR into the string at (before) position \fIindex\fR and returns a reference to the string..PPIf \fIindex\fR is beyond the end of the string, the string is extended with spaces (ASCII 32) to length \fIindex\fR and \fIc\fR is then appended..PPExample:.PP.nf.br QCString s = "Yes";.br s.insert( 3, '!'); // s == "Yes!".fi.PPSee also remove() and replace()..SH "QCString & QCString::insert ( uint index, const char * s )"Insert \fIs\fR into the string before position \fIindex.\fR.PPIf \fIindex\fR is beyond the end of the string, the string is extended with spaces (ASCII 32) to length \fIindex\fR and \fIs\fR is then appended..PP.nf.br QCString s = "I like fish";.br s.insert( 2, "don't "); // s == "I don't like fish".br s = "x";.br s.insert( 3, "yz" ); // s == "x yz".fi.SH "bool QCString::isEmpty () const"Returns TRUE if the string is empty, i.e. if length() == 0. 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. 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.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".fi.PPSee also right() and mid()..SH "QCString QCString::leftJustify ( uint width, char fill=' ', bool truncate=FALSE ) const"Returns a string of length \fIwidth\fR (plus '\\0') that contains this string and padded by the \fIfill\fR character..PPIf the length of the string exceeds \fIwidth\fR and \fItruncate\fR is FALSE, 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...".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()..SH "QCString QCString::lower () const"Returns a new string that is the string converted to lower case..PPPresently it only handles 7-bit ASCII, or whatever tolower() handles (if $LC_CTYPE is set, most UNIX systems do the Right Thing)..PPExample:.PP.nf.br QCString s("TeX");.br QCString t = s.lower(); // t == "tex".fi.PPSee also upper()..SH "QCString QCString::mid ( uint index, uint len=0xffffffff ) const"Returns a substring that contains the \fIlen\fR characters of this string, starting at position \fIindex.\fR.PPReturns a null string if the string is empty or \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, 4 ); // t == "pine".fi.PPSee also left() and right()..SH "QCString & QCString::operator+= ( char c )"Appends \fIc\fR to the string and returns a reference to the string..SH "QCString& QCString::operator+= ( const char * str )"Appends \fIstr\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 )"Assigns 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 starting at position \fIindex\fR from the string and returns a reference to the string..PPIf \fIindex\fR is too big, nothing happens. If \fIindex\fR is valid, but \fIlen\fR is too large, the rest of the string is removed..PP.nf.br QCString s = "Montreal";.br s.remove( 1, 4 );.br // s == "Meal".fi.PPSee also insert() and replace()..SH "QCString & QCString::replace ( const QRegExp & rx, const char * str )"Replaces 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 QString s = "banana";.br s.replace( QRegExp("^[bn]a"), " " ); // becomes " nana".br.br QString s = "banana";.br s.replace( QRegExp("^[bn]a"), "" ); // NOTE! becomes "".fi.SH "QCString & QCString::replace ( uint index, uint len, const char * s )"Replaces \fIlen\fR characters starting at position \fIindex\fR from the string with \fIs,\fR and returns a reference to the string..PPIf \fIindex\fR is too big, nothing is deleted and \fIs\fR is inserted at the end of the string. If \fIindex\fR is valid, but \fIlen\fR is too large, \fIstr\fR replaces the rest of the string..PP.nf.br QCString s = "Say yes!";.br s.replace( 4, 3, "NO" ); // s == "Say NO!".fi.PPSee also insert() and remove()..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".fi.PPSee also truncate()..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
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -