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

📄 pstring.h

📁 mgcp协议源代码。支持多种编码:g711
💻 H
📖 第 1 页 / 共 5 页
字号:
/* * pstring.h * * Character string class. * * Portable Windows Library * * Copyright (c) 1993-1998 Equivalence Pty. Ltd. * * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and limitations * under the License. * * The Original Code is Portable Windows Library. * * The Initial Developer of the Original Code is Equivalence Pty. Ltd. * * Portions are Copyright (C) 1993 Free Software Foundation, Inc. * All Rights Reserved. * * Contributor(s): ______________________________________. * * $Log: pstring.h,v $ * Revision 1.40  1999/08/22 12:13:43  robertj * Fixed warning when using inlines on older GNU compiler * * Revision 1.39  1999/05/28 14:01:22  robertj * Added initialisers to string containers (list, sorted list and set). * * Revision 1.38  1999/03/09 09:34:05  robertj * Fixed typo's. * * Revision 1.37  1999/03/09 02:59:50  robertj * Changed comments to doc++ compatible documentation. * * Revision 1.36  1999/02/16 08:11:09  robertj * MSVC 6.0 compatibility changes. * * Revision 1.35  1998/09/23 06:21:12  robertj * Added open source copyright license. * * Revision 1.34  1998/01/26 00:33:46  robertj * Added FindRegEx function to PString that returns position and length. * Added Execute() functions to PRegularExpression that take PINDEX references instead of PIntArrays. * Added static function to PRegularExpression to escape all special operator characters in a string. * * Revision 1.33  1998/01/05 10:39:35  robertj * Fixed "typesafe" templates/macros for dictionaries, especially on GNU. * * Revision 1.32  1997/12/11 13:32:47  robertj * Added AsUnsigned() function to convert string to DWORD. * * Revision 1.31  1997/12/11 10:29:49  robertj * Added type correct Contains() function to dictionaries. * * Revision 1.30  1997/07/08 13:13:47  robertj * DLL support. * * Revision 1.29  1997/06/10 11:36:32  craigs * Added inline statements to allow compilation uder Unix * * Revision 1.28  1997/06/08 04:48:58  robertj * Added regular expressions. * Fixed non-template class descendent order. * * Revision 1.27  1997/05/16 12:10:12  robertj * Fixed G++ compatibility bug. * * Revision 1.26  1996/10/08 13:13:38  robertj * Added operator += and &= for char so no implicit PString construction. * * Revision 1.25  1996/09/14 12:52:39  robertj * Added operator! for !IsEmpty(). * * Revision 1.24  1996/08/17 10:00:25  robertj * Changes for Windows DLL support. * * Revision 1.23  1996/05/26 03:27:02  robertj * Compatibility to GNU 2.7.x * * Revision 1.22  1996/03/31 08:51:22  robertj * Added RemoveAt() function to remove entries from dictionaries. * * Revision 1.21  1996/03/10 13:15:50  robertj * Added operator() to template version. * * Revision 1.20  1996/02/19 13:17:33  robertj * Removed PCaselessString hash function to fix dictionary match failure. * Added operator() to do string dictionary lookup with default value. * * Revision 1.19  1996/02/08 12:19:16  robertj * Added new operators to PString for case insensitive compare and spaced concatenate. * * Revision 1.18  1996/01/24 14:43:15  robertj * Added initialisers to string dictionaries. * * Revision 1.17  1996/01/23 13:15:17  robertj * Added Replace() function to strings. * Mac Metrowerks compiler support. * String searching algorithm rewrite. * * Revision 1.16  1996/01/02 12:04:31  robertj * Mac OS compatibility changes. * Removed requirement that PArray elements have parameterless constructor.. * * Revision 1.15  1995/12/23 03:46:23  robertj * Added operators for include and exclude from string set. * * Revision 1.14  1995/10/14 15:02:56  robertj * Changed arrays to not break references, but strings still need to. * * Revision 1.13  1995/06/17 11:13:08  robertj * Documentation update. * * Revision 1.12  1995/06/17 00:43:40  robertj * Added flag for PStringArray constructor to create caseless strings. * * Revision 1.11  1995/06/04 12:34:57  robertj * Better C++ compatibility (with BC++) * * Revision 1.10  1995/04/02 09:27:23  robertj * Added "balloon" help. * * Revision 1.9  1995/03/14 12:42:16  robertj * Updated documentation to use HTML codes. * * Revision 1.8  1995/03/12  04:44:39  robertj * Fixed use of PCaselessString as dictionary key. * * Revision 1.7  1995/02/05  00:48:09  robertj * Fixed template version. * * Revision 1.6  1995/01/15  04:50:20  robertj * Added inlines on friend functions, required by GNU compiler. * * Revision 1.5  1995/01/10  11:43:41  robertj * Removed PString parameter in stdarg function for GNU C++ compatibility. * * Revision 1.4  1995/01/09  12:33:44  robertj * Removed unnecesary return value from I/O functions. * Changed function names due to Mac port. * * Revision 1.3  1994/12/21  11:53:21  robertj * Documentation and variable normalisation. * * Revision 1.2  1994/12/12  13:13:13  robertj * Fixed bugs in PString mods just made. * * Revision 1.1  1994/12/12  09:59:37  robertj * Initial revision * */#ifdef __GNUC__#pragma interface#endif///////////////////////////////////////////////////////////////////////////////// PString classclass PStringArray;class PRegularExpression;#ifdef PHAS_UNICODE#define PSTRING_ANCESTOR_CLASS PWordArray#else#define PSTRING_ANCESTOR_CLASS PCharArray#endif/**The character string class. It supports a wealth of additional functions   for string processing and conversion. Operators are provided so that   strings can virtually be treated as a basic type.   The #PSTRING_ANCESTOR_CLASS# is dependent on whether UNICODE   support is selected. The {\bf entire library and application} must be   compiled with or without UNICODE or undefined results will occur.   #PSTRING_ANCESTOR_CLASS# macro is normally set to   #PCharArray#.   An important feature of the string class, which is not present in other   container classes, is that when the string contents is changed, that is   resized or elements set, the string is "dereferenced", and a duplicate   made of its contents. That is this instance of the array is disconnected   from all other references to the string data, if any, and a new string array   contents created. For example consider the following:\begin{verbatim}          PString s1 = "String"; // New array allocated and set to "String"          PString s2 = s1;       // s2 has pointer to same array as s1                                 // and reference count is 2 for both          s1[0] = 's';           // Breaks references into different strings\end{verbatim}   at the end s1 is "string" and s2 is "String" both with reference count of 1.   The functions that will "break" a reference are #SetSize()#,   #SetMinSize()#, #GetPointer()#, #SetAt()# and   #operator[]#.   Note that the array is a '\0' terminated string as in C strings. Thus the   memory allocated, and the length of the string may be different values. */#ifdef DOC_PLUS_PLUSclass PString : public PCharArray {#endifPDECLARE_CLASS(PString, PSTRING_ANCESTOR_CLASS);  public:  /**@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 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 UNICODE is used then each char from the char pointer is mapped to a       single UNICODE character.     */    PString(      const char * cstr /// Standard '\0' terminated C string.    );    /**Create a string from the Unicode 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 /// Unicode 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 UNICODE is used then each char from the char pointer is mapped to a       single UNICODE 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 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 * cstr,  /// Pointer to a string of Unicode characters.      PINDEX len          /// Length of the string in bytes.    );    /**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 UNICODE is used then the char is mapped to a single UNICODE       character.     */    PString(      char ch    /// Single character to initialise string.    );    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.    );  //@}  /**@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.     */

⌨️ 快捷键说明

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