pstring.h
来自「开源代码的pwlib的1.10.0版本,使用openh323的1.18.0版本毕」· C头文件 代码 · 共 1,755 行 · 第 1/5 页
H
1,755 行
greater than the object.
*/
virtual Comparison Compare(
const PObject & obj ///< Other PString to compare against.
) const;
/**Output the string to the specified stream.
*/
virtual void PrintOn(
ostream & strm ///< I/O stream to output to.
) const;
/**Input the string from the specified stream. This will read all
characters until a end of line is reached. The end of line itself is
{\bf not} placed in the string, however it {\bf is} removed from
the stream.
*/
virtual void ReadFrom(
istream & strm ///< I/O stream to input from.
);
/**Calculate a hash value for use in sets and dictionaries.
The hash function for strings will produce a value based on the sum of
the first three characters of the string. This is a fairly basic
function and make no assumptions about the string contents. A user may
descend from PString and override the hash function if they can take
advantage of the types of strings being used, eg if all strings start
with the letter 'A' followed by 'B or 'C' then the current hash function
will not perform very well.
@return
hash value for string.
*/
virtual PINDEX HashFunction() const;
//@}
/**@name Overrides from class PContainer */
//@{
/**Set the size of the string. A new string may be allocated to accomodate
the new number of characters. If the string increases in size then the
new characters are initialised to zero. If the string is made smaller
then the data beyond the new size is lost.
Note that this function will break the current instance from multiple
references to an array. A new array is allocated and the data from the
old array copied to it.
@return
TRUE if the memory for the array was allocated successfully.
*/
virtual BOOL SetSize(
PINDEX newSize ///< New size of the array in elements.
);
/**Determine if the string is empty. This is semantically slightly
different from the usual #PContainer::IsEmpty()# function. It does
not test for #PContainer::GetSize()# equal to zero, it tests for
#GetLength()# equal to zero.
@return
TRUE if no non-null characters in string.
*/
virtual BOOL IsEmpty() const;
/**Make this instance to be the one and only reference to the container
contents. This implicitly does a clone of the contents of the container
to make a unique reference. If the instance was already unique then
the function does nothing.
@return
TRUE if the instance was already unique.
*/
virtual BOOL MakeUnique();
//@}
/**@name Size/Length functions */
//@{
/**Set the actual memory block array size to the minimum required to hold
the current string contents.
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.
@return
TRUE if new memory block successfully allocated.
*/
BOOL MakeMinimumSize();
/**Determine the length of the null terminated string. This is different
from #PContainer::GetSize()# which returns the amount of memory
allocated to the string. This is often, though no necessarily, one
larger than the length of the string.
@return
length of the null terminated string.
*/
PINLINE PINDEX GetLength() const;
/**Determine if the string is NOT empty. This is semantically identical
to executing !IsEmpty() on the string.
@return
TRUE if non-null characters in string.
*/
bool operator!() const;
//@}
/**@name Concatenation operators **/
//@{
/**Concatenate two strings to produce a third. The original strings are
not modified, an entirely new unique reference to a string is created.
@return
new string with concatenation of the object and parameter.
*/
PString operator+(
const PString & str ///< String to concatenate.
) const;
/**Concatenate a C string to a PString to produce a third. The original
string is not modified, an entirely new unique reference to a string
is created. The #cstr# parameter is typically a literal
string, eg:
\begin{verbatim}
myStr = aStr + "fred";
\end{verbatim}
@return
new string with concatenation of the object and parameter.
*/
PString operator+(
const char * cstr ///< C string to concatenate.
) const;
/**Concatenate a single character to a PString to produce a third. The
original string is not modified, an entirely new unique reference to a
string is created. The #ch# parameter is typically a
literal, eg:
\begin{verbatim}
myStr = aStr + '!';
\end{verbatim}
@return
new string with concatenation of the object and parameter.
*/
PString operator+(
char ch ///< Character to concatenate.
) const;
/**Concatenate a PString to a C string to produce a third. The original
string is not modified, an entirely new unique reference to a string
is created. The #cstr# parameter is typically a literal
string, eg:
\begin{verbatim}
myStr = "fred" + aStr;
\end{verbatim}
@return
new string with concatenation of the object and parameter.
*/
friend PString operator+(
const char * cstr, ///< C string to be concatenated to.
const PString & str ///< String to concatenate.
);
/**Concatenate a PString to a single character to produce a third. The
original string is not modified, an entirely new unique reference to a
string is created. The #c# parameter is typically a literal,
eg:
\begin{verbatim}
myStr = '!' + aStr;
\end{verbatim}
@return
new string with concatenation of the object and parameter.
*/
friend PString operator+(
char c, ///< Character to be concatenated to.
const PString & str ///< String to concatenate.
);
/**Concatenate a string to another string, modifiying that string.
@return
reference to string that was concatenated to.
*/
PString & operator+=(
const PString & str ///< String to concatenate.
);
/**Concatenate a C string to a PString, modifiying that string. The
#cstr# parameter is typically a literal string, eg:
\begin{verbatim}
myStr += "fred";
\end{verbatim}
@return
reference to string that was concatenated to.
*/
PString & operator+=(
const char * cstr ///< C string to concatenate.
);
/**Concatenate a single character to a PString. The #ch#
parameter is typically a literal, eg:
\begin{verbatim}
myStr += '!';
\end{verbatim}
@return
new string with concatenation of the object and parameter.
*/
PString & operator+=(
char ch ///< Character to concatenate.
);
/**Concatenate two strings to produce a third. The original strings are
not modified, an entirely new unique reference to a string is created.
@return
new string with concatenation of the object and parameter.
*/
PString operator&(
const PString & str ///< String to concatenate.
) const;
/**Concatenate a C string to a PString to produce a third. The original
string is not modified, an entirely new unique reference to a string
is created. The #cstr# parameter is typically a literal
string, eg:
\begin{verbatim}
myStr = aStr & "fred";
\end{verbatim}
This function differes from operator+ in that it assures there is at
least one space between the strings. Exactly one space is added if
there is not a space at the end of the first or beggining of the last
string.
@return
new string with concatenation of the object and parameter.
*/
PString operator&(
const char * cstr ///< C string to concatenate.
) const;
/**Concatenate a single character to a PString to produce a third. The
original string is not modified, an entirely new unique reference to a
string is created. The #ch# parameter is typically a
literal, eg:
\begin{verbatim}
myStr = aStr & '!';
\end{verbatim}
This function differes from operator+ in that it assures there is at
least one space between the strings. Exactly one space is added if
there is not a space at the end of the first or beggining of the last
string.
@return
new string with concatenation of the object and parameter.
*/
PString operator&(
char ch ///< Character to concatenate.
) const;
/**Concatenate a PString to a C string to produce a third. The original
string is not modified, an entirely new unique reference to a string
is created. The #cstr# parameter is typically a literal
string, eg:
\begin{verbatim}
myStr = "fred" & aStr;
\end{verbatim}
This function differes from operator+ in that it assures there is at
least one space between the strings. Exactly one space is added if
there is not a space at the end of the first or beggining of the last
string.
@return
new string with concatenation of the object and parameter.
*/
friend PString operator&(
const char * cstr, ///< C string to be concatenated to.
const PString & str ///< String to concatenate.
);
/**Concatenate a PString to a single character to produce a third. The
original string is not modified, an entirely new unique reference to a
string is created. The #c# parameter is typically a literal,
eg:
\begin{verbatim}
myStr = '!' & aStr;
\end{verbatim}
This function differes from #operator+# in that it assures there is at
least one space between the strings. Exactly one space is added if
there is not a space at the end of the first or beggining of the last
string.
@return
new string with concatenation of the object and parameter.
*/
friend PString operator&(
char ch, ///< Character to be concatenated to.
const PString & str ///< String to concatenate.
);
/**Concatenate a string to another string, modifiying that string.
@return
reference to string that was concatenated to.
*/
PString & operator&=(
const PString & str ///< String to concatenate.
);
/**Concatenate a C string to a PString, modifiying that string. The
#cstr# parameter is typically a literal string, eg:
\begin{verbatim}
myStr &= "fred";
\end{verbatim}
This function differes from operator+ in that it assures there is at
least one space between the strings. Exactly one space is added if
there is not a space at the end of the first or beggining of the last
string.
@return
reference to string that was concatenated to.
*/
PString & operator&=(
const char * cstr ///< C string to concatenate.
);
/**Concatenate a character to a PString, modifiying that string. The
#ch# parameter is typically a literal string, eg:
\begin{verbatim}
myStr &= '!';
\end{verbatim}
This function differes from operator+ in that it assures there is at
least one space between the strings. Exactly one space is added if
there is not a space at the end of the first or beggining of the last
string.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?