📄 pstring.h
字号:
/**Compare two strings using the #PObject::Compare()# function. This is identical to the #PObject# class function but is necessary due to other overloaded versions. @return TRUE if greater than. */ bool operator>( const PObject & str /// PString object to compare against. ) const; /**Compare two strings using the #PObject::Compare()# function. This is identical to the #PObject# class function but is necessary due to other overloaded versions. @return TRUE if less than or equal. */ bool operator<=( const PObject & str /// PString object to compare against. ) const; /**Compare two strings using the #PObject::Compare()# function. This is identical to the #PObject# class function but is necessary due to other overloaded versions. @return TRUE if greater than or equal. */ bool operator>=( const PObject & str /// PString object to compare against. ) const; /**Compare a PString to a C string using a case insensitive compare function. The #cstr# parameter is typically a literal string, eg:\begin{verbatim} if (myStr == "fred")\end{verbatim} @return TRUE if equal. */ bool operator*=( const char * cstr /// C string to compare against. ) const; /**Compare a PString to a C string using the ##Compare()## function. The #cstr# parameter is typically a literal string, eg:\begin{verbatim} if (myStr == "fred")\end{verbatim} @return TRUE if equal. */ bool operator==( const char * cstr /// C string to compare against. ) const; /**Compare a PString to a C string using the #PObject::Compare()# function. The #cstr# parameter is typically a literal string, eg:\begin{verbatim} if (myStr != "fred")\end{verbatim} @return TRUE if not equal. */ bool operator!=( const char * cstr /// C string to compare against. ) const; /**Compare a PString to a C string using the #PObject::Compare()# function. The #cstr# parameter is typically a literal string, eg:\begin{verbatim} if (myStr < "fred")\end{verbatim} @return TRUE if less than. */ bool operator<( const char * cstr /// C string to compare against. ) const; /**Compare a PString to a C string using the #PObject::Compare()# function. The #cstr# parameter is typically a literal string, eg:\begin{verbatim} if (myStr > "fred")\end{verbatim} @return TRUE if greater than. */ bool operator>( const char * cstr /// C string to compare against. ) const; /**Compare a PString to a C string using the #PObject::Compare()# function. The #cstr# parameter is typically a literal string, eg:\begin{verbatim} if (myStr <= "fred")\end{verbatim} @return TRUE if less than or equal. */ bool operator<=( const char * cstr /// C string to compare against. ) const; /**Compare a PString to a C string using the #PObject::Compare()# function. The #cstr# parameter is typically a literal string, eg:\begin{verbatim} if (myStr >= "fred")\end{verbatim} @return TRUE if greater than or equal. */ bool operator>=( const char * cstr /// C string to compare against. ) const; /**Compare a string against a substring of the object. This will compare at most #count# characters of the string, starting at the specified #offset#, against that many characters of the #str# parameter. If #count# greater than the length of the #str# parameter then the actual length of #str# is used. If #count# and the length of #str# are greater than the length of the string remaining from the #offset# then FALSE is returned. @return TRUE if str is a substring of . */ Comparison NumCompare( const PString & str, /// PString object to compare against. PINDEX count = P_MAX_INDEX, /// Number of chacracters in str to compare PINDEX offset = 0 /// Offset into string to compare ) const; /**Compare a string against a substring of the object. This will compare at most #count# characters of the string, starting at the specified #offset#, against that many characters of the #str# parameter. If #count# greater than the length of the #str# parameter then the actual length of #str# is used. If #count# and the length of #str# are greater than the length of the string remaining from the #offset# then FALSE is returned. @return TRUE if str is a substring of . */ Comparison NumCompare( const char * cstr, /// C string object to compare against. PINDEX count = P_MAX_INDEX, /// Number of chacracters in str to compare PINDEX offset = 0 /// Offset into string to compare ) const; //@} /**@name Search & replace functions */ //@{ /** Locate the position within the string of the character. */ PINDEX Find( char ch, /// Character to search for in string. PINDEX offset = 0 /// Offset into string to begin search. ) const; /** Locate the position within the string of the substring. */ PINDEX Find( const PString & str, /// String to search for in string. PINDEX offset = 0 /// Offset into string to begin search. ) const; /* Locate the position within the string of the character or substring. The search will begin at the character offset provided. If #offset# is beyond the length of the string, then the function will always return #P_MAX_INDEX#. The matching will be for identical character or string. If a search ignoring case is required then the string should be converted to a #PCaselessString# before the search is made. @return position of character or substring in the string, or P_MAX_INDEX if the character or substring is not in the string. */ PINDEX Find( const char * cstr, /// C string to search for in string. PINDEX offset = 0 /// Offset into string to begin search. ) const; /** Locate the position of the last matching character. */ PINDEX FindLast( char ch, /// Character to search for in string. PINDEX offset = P_MAX_INDEX /// Offset into string to begin search. ) const; /** Locate the position of the last matching substring. */ PINDEX FindLast( const PString & str, /// String to search for in string. PINDEX offset = P_MAX_INDEX /// Offset into string to begin search. ) const; /**Locate the position of the last matching substring. Locate the position within the string of the last matching character or substring. The search will begin at the character offset provided, moving backward through the string. If #offset# is beyond the length of the string, then the search begins at the end of the string. If #offset# is zero then the function always returns #P_MAX_INDEX#. The matching will be for identical character or string. If a search ignoring case is required then the string should be converted to a #PCaselessString# before the search is made. @return position of character or substring in the string, or P_MAX_INDEX if the character or substring is not in the string. */ PINDEX FindLast( const char * cstr, /// C string to search for in string. PINDEX offset = P_MAX_INDEX /// Offset into string to begin search. ) const; /** Locate the position of one of the characters in the set. */ PINDEX FindOneOf( const PString & set, /// String of characters to search for in string. PINDEX offset = 0 /// Offset into string to begin search. ) const; /**Locate the position of one of the characters in the set. The search will begin at the character offset provided. If #offset# is beyond the length of the string, then the function will always return #P_MAX_INDEX#. The matching will be for identical character or string. If a search ignoring case is required then the string should be converted to a #PCaselessString# before the search is made. @return position of character in the string, or P_MAX_INDEX if no characters from the set are in the string. */ PINDEX FindOneOf( const char * cset, /// C string of characters to search for in string. PINDEX offset = 0 /// Offset into string to begin search. ) const; /**Locate the position within the string of one of the regular expression. The search will begin at the character offset provided. If #offset# is beyond the length of the string, then the function will always return #P_MAX_INDEX#. @return position of regular expression in the string, or P_MAX_INDEX if no characters from the set are in the string. */ PINDEX FindRegEx( const PRegularExpression & regex, /// regular expression to find PINDEX offset = 0 /// Offset into string to begin search. ) const; /**Locate the position within the string of one of the regular expression. The search will begin at the character offset provided. If #offset# is beyond the length of the string, then the function will always return #P_MAX_INDEX#. @return position of regular expression in the string, or P_MAX_INDEX if no characters from the set are in the string. */ BOOL FindRegEx( const PRegularExpression & regex, /// regular expression to find PINDEX & pos, /// Position of matched expression PINDEX & len, /// Length of matched expression PINDEX offset = 0, /// Offset into string to begin search. PINDEX maxPos = P_MAX_INDEX /// Maximum offset into string ) const; /**Locate the substring within the string and replace it with the specifed substring. The search will begin at the character offset provided. If #offset# is beyond the length of the string, then the function will do nothing. The matching will be for identical character or string. If a search ignoring case is required then the string should be converted to a #PCaselessString# before the search is made. */ void Replace( const PString & target, /// Text to be removed. const PString & subs, /// String to be inserted into the gaps created BOOL all = FALSE, /// Replace all occurrences of target text. PINDEX offset = 0 /// Offset into string to begin search. ); /**Splice the string into the current string at the specified position. The specified number of bytes are removed from the string. Note that this function will break the current instance from multiple references to the string. A new string buffer is allocated and the data from the old string buffer copied to it. */ void Splice( const PString & str, /// Substring to insert. PINDEX pos, /// Position in string to insert the substring. PINDEX len = 0 /// Length of section to remove. ); /**Splice the string into the current string at the specified position. The specified number of bytes are removed from the string. Note that this function will break the current instance from multiple references to the string. A new string buffer is allocated and the data from the old string buffer copied to it. */ void Splice( const char * cstr, /// Substring to insert. PINDEX pos, /// Position in string to insert the substring. PINDEX len = 0 /// Length of section to remove. ); /**Remove the substring from the string. Note that this function will break the current instance from multiple references to the string. A new string buffer is allocated and the data from the old string buffer copied to it. */ void Delete( PINDEX start, /// Position in string to remove. PINDEX len /// Number of characters to delete. ); //@} /**@name Sub-string functions */ //@{ /**Extract a portion of the string into a new string. The original string is not changed and a new unique reference to a string is returned. The substring is returned inclusive of the characters at the #start# and #end# positions. If the #end# position is greater than the length of the string then all characters from the #start# up to the end of the string are returned.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -