⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pstring.h

📁 安装 H323需要的pwlib库
💻 H
📖 第 1 页 / 共 5 页
字号:
  /**@name Construction */  //@{    /**Construct an empty string. This will have one character in it which is       the '\0' character.     */    PINLINE PString();    /**Create a new reference to the specified string. The string memory is not       copied, only the pointer to the data.     */    PINLINE PString(      const PString & str  /// String to create new reference to.    );    /**Create a new string from the specified std::string     */    PINLINE PString(      const std::string & str    );    /**Create a string from the C string array. This is most commonly used with       a literal string, eg "hello". A new memory block is allocated of a size       sufficient to take the length of the string and its terminating       '\0' character.       If UCS-2 is used then each char from the char pointer is mapped to a       single UCS-2 character.     */    PString(      const char * cstr /// Standard '\0' terminated C string.    );    /**Create a string from the UCS-2 string array.       A new memory block is allocated of a size sufficient to take the length       of the string and its terminating '\0' character.     */    PString(      const WORD * ustr /// UCS-2 null terminated string.    );    /**Create a string from the array. A new memory block is allocated of       a size equal to #len# plus one which is sufficient to take       the string and a terminating '\0' character.       If UCS-2 is used then each char from the char pointer is mapped to a       single UCS-2 character.       Note that this function will allow a string with embedded '\0'       characters to be created, but most of the functions here will be unable       to access characters beyond the first '\0'. Furthermore, if the       #MakeMinimumSize()# function is called, all data beyond that first       #'\0'# character will be lost.     */    PString(      const char * cstr,  /// Pointer to a string of characters.      PINDEX len          /// Length of the string in bytes.    );    /**Create a string from the UCS-2 array. A new memory block is allocated       of a size equal to #len# plus one which is sufficient to take       the string and a terminating '\0' character.       Note that this function will allow a string with embedded '\0'       characters to be created, but most of the functions here will be unable       to access characters beyond the first '\0'. Furthermore, if the       #MakeMinimumSize()# function is called, all data beyond that first       #'\0'# character will be lost.     */    PString(      const WORD * ustr,  /// Pointer to a string of UCS-2 characters.      PINDEX len          /// Length of the string in bytes.    );    /**Create a string from the UCS-2 array. A new memory block is allocated       of a size equal to #len# plus one which is sufficient to take       the string and a terminating '\0' character.       Note that this function will allow a string with embedded '\0'       characters to be created, but most of the functions here will be unable       to access characters beyond the first '\0'. Furthermore, if the       #MakeMinimumSize()# function is called, all data beyond that first       #'\0'# character will be lost.     */    PString(      const PWORDArray & ustr /// UCS-2 null terminated string.    );    /**Create a string from the single character. This is most commonly used       as a type conversion constructor when a literal character, eg 'A' is       used in a string expression. A new memory block is allocated of two       characters to take the char and its terminating '\0' character.       If UCS-2 is used then the char is mapped to a single UCS-2       character.     */    PString(      char ch    /// Single character to initialise string.    );    /**Create a string from the integer type.       This will create a simple base 10, shortest length conversion of the       integer (with sign character if appropriate) into the string.      */    PString(      short n   /// Integer to convert    );    /**Create a string from the integer type.       This will create a simple base 10, shortest length conversion of the       integer (with sign character if appropriate) into the string.      */    PString(      unsigned short n   /// Integer to convert    );    /**Create a string from the integer type.       This will create a simple base 10, shortest length conversion of the       integer (with sign character if appropriate) into the string.      */    PString(      int n   /// Integer to convert    );    /**Create a string from the integer type.       This will create a simple base 10, shortest length conversion of the       integer (with sign character if appropriate) into the string.      */    PString(      unsigned int n   /// Integer to convert    );    /**Create a string from the integer type.       This will create a simple base 10, shortest length conversion of the       integer (with sign character if appropriate) into the string.      */    PString(      long n   /// Integer to convert    );    /**Create a string from the integer type.       This will create a simple base 10, shortest length conversion of the       integer (with sign character if appropriate) into the string.      */    PString(      unsigned long n   /// Integer to convert    );    /**Create a string from the integer type.       This will create a simple base 10, shortest length conversion of the       integer (with sign character if appropriate) into the string.      */    PString(      PInt64 n   /// Integer to convert    );    /**Create a string from the integer type.       This will create a simple base 10, shortest length conversion of the       integer (with sign character if appropriate) into the string.      */    PString(      PUInt64 n   /// Integer to convert    );     enum ConversionType {      Pascal,   // Data is a length byte followed by characters.      Basic,    // Data is two length bytes followed by characters.      Literal,  // Data is C language style string with \ escape codes.      Signed,   // Convert a signed integer to a string.      Unsigned, // Convert an unsigned integer to a string.      Decimal,  // Convert a real number to a string in decimal format.      Exponent, // Convert a real number to a string in exponent format.      Printf,   // Formatted output, sprintf() style function.      NumConversionTypes    };    /* Type of conversion to make in the conversion constructors.     */    /* Contruct a new string converting from the spcified data source into       a string array.     */    PString(      ConversionType type,  // Type of data source for conversion.      const char * str,    // String to convert.      ...                 // Extra parameters for #sprintf()# call.    );    PString(      ConversionType type,  // Type of data source for conversion.      long value,           // Integer value to convert.      unsigned base = 10    // Number base to use for the integer conversion.    );    PString(      ConversionType type,  // Type of data source for conversion.      double value,         // Floating point value to convert.      unsigned places       // Number of decimals in real number output.    );    /**Assign the string to the current object. The current instance then       becomes another reference to the same string in the #str#       parameter.              @return       reference to the current PString object.     */    PString & operator=(      const PString & str  /// New string to assign.    );    /**Assign the C string to the current object. The current instance then       becomes a unique reference to a copy of the #cstr# parameter.       The #cstr# parameter is typically a literal string, eg:\begin{verbatim}          myStr = "fred";\end{verbatim}       @return       reference to the current PString object.     */    PString & operator=(      const char * cstr  /// C string to assign.    );    /**Assign the character to the current object. The current instance then       becomes a unique reference to a copy of the character parameter. eg:\begin{verbatim}          myStr = 'A';\end{verbatim}       @return       reference to the current PString object.     */    PString & operator=(      char ch            /// Character to assign.    );    /**Assign a string from the integer type.       This will create a simple base 10, shortest length conversion of the       integer (with sign character if appropriate) into the string.      */    PString & operator=(      short n   /// Integer to convert    );    /**Assign a string from the integer type.       This will create a simple base 10, shortest length conversion of the       integer (with sign character if appropriate) into the string.      */    PString & operator=(      unsigned short n   /// Integer to convert    );    /**Assign a string from the integer type.       This will create a simple base 10, shortest length conversion of the       integer (with sign character if appropriate) into the string.      */    PString & operator=(      int n   /// Integer to convert    );    /**Assign a string from the integer type.       This will create a simple base 10, shortest length conversion of the       integer (with sign character if appropriate) into the string.      */    PString & operator=(      unsigned int n   /// Integer to convert    );    /**Assign a string from the integer type.       This will create a simple base 10, shortest length conversion of the       integer (with sign character if appropriate) into the string.      */    PString & operator=(      long n   /// Integer to convert    );    /**Assign a string from the integer type.       This will create a simple base 10, shortest length conversion of the       integer (with sign character if appropriate) into the string.      */    PString & operator=(      unsigned long n   /// Integer to convert    );    /**Assign a string from the integer type.       This will create a simple base 10, shortest length conversion of the       integer (with sign character if appropriate) into the string.      */    PString & operator=(      PInt64 n   /// Integer to convert    );    /**Assign a string from the integer type.       This will create a simple base 10, shortest length conversion of the       integer (with sign character if appropriate) into the string.      */    PString & operator=(      PUInt64 n   /// Integer to convert    );    /**Make the current string empty      */    virtual PString & MakeEmpty();    /**Return an empty string.      */    static PString Empty();  //@}  /**@name Overrides from class PObject */  //@{    /**Make a complete duplicate of the string. Note that the data in the       array of characters is duplicated as well and the new object is a       unique reference to that data.     */    virtual PObject * Clone() const;    /**Get the relative rank of the two strings. The system standard function,       eg strcmp(), is used.       @return       comparison of the two objects, #EqualTo# for same,       #LessThan# for #obj# logically less than the       object and #GreaterThan# for #obj# logically       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

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -