📄 pstring.h
字号:
class PCaselessString : public PString{ PCLASSINFO(PCaselessString, PString); public: /**Create a new, empty, caseless string. */ PCaselessString(); /**Create a new caseless string, initialising it to the characters in the C string provided. */ PCaselessString( const char * cstr /// C string to initialise the caseless string from. ); /**Create a caseless string, with a reference to the characters in the normal #PString# provided. A PCaselessString may also be provided to this constructor. */ PCaselessString( const PString & str /// String to initialise the caseless string from. ); /**Set the current instance to reference the same string as the #str# parameter. */ PCaselessString & operator=( const PString & str /// String to initialise the caseless string from. ); /**Set the current instance to reference the same string as the #str# parameter. The previous reference is decremented and if no more references to the string are present, the string buffer is released. A PCaselessString may also be provided to this operator. */ PCaselessString & operator=( const char * cstr /// C string to initialise the caseless string from. ); // 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; protected: // Overrides from class PString virtual Comparison InternalCompare( PINDEX offset, // Offset into string to compare. char c // Character to compare against. ) const; virtual Comparison InternalCompare( PINDEX offset, // Offset into string to compare. PINDEX length, // Number of characters to compare. const char * cstr // C string to compare against. ) const; /* Internal function to compare the current string value against the specified C string. @return relative rank of the two strings or characters. */ PCaselessString(int dummy, const PCaselessString * str);};//////////////////////////////////////////////////////////////////////////////class PStringStream;/**This class is a standard C++ stream class descendent for reading or writing streamed data to or from a #PString# class. All of the standard stream I/O operators, manipulators etc will operate on the PStringStream class. */class PStringStream : public PString, public iostream{ PCLASSINFO(PStringStream, PString); public: /**Create a new, empty, string stream. Data may be output to this stream, but attempts to input from it will return end of file. */ PStringStream(); /**Create a new string stream and initialise it to the provided value. The string stream references the same string buffer as the #str# parameter until any output to the string stream is attempted. The reference is then broken and the instance of the string stream becomes a unique reference to a string buffer. */ PStringStream( const PString & str /// Initial value for string stream. ); /**Create a new string stream and initialise it with the provided value. The stream may be read or written from. Writes will append to the end of the string. */ PStringStream( const char * cstr /// Initial value for the string stream. ); /**Assign the string to the current object. The current instance then becomes another reference to the same string in the #str# parameter. This will reset the read pointer for input to the beginning of the string. Also, any data output to the string up until the asasignement will be lost. @return reference to the current PStringStream object. */ PStringStream & operator=( const PString & str /// New string to assign. ); /**Assign the C string to the string stream. 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} This will reset the read pointer for input to the beginning of the string. Also, any data output to the string up until the asasignement will be lost. @return reference to the current PStringStream object. */ PStringStream & operator=( const char * cstr /// C string to assign. ); /// Destroy the string stream, deleting the stream buffer virtual ~PStringStream(); private: PStringStream(int, const PStringStream &) { } PStringStream & operator=(const PStringStream &) { return *this; } class Buffer : public streambuf { public: Buffer(PStringStream * str); Buffer(const Buffer & sbuf); Buffer & operator=(const Buffer & sbuf); virtual int overflow(int=EOF); virtual int underflow(); virtual int sync();#ifdef __MWERKS__ virtual streampos seekoff(streamoff, ios::seekdir, ios::openmode);#else virtual streampos seekoff(streamoff, ios::seek_dir, int);#endif PStringStream * string; };};/**This is an array collection class of #PString# objects. It has all the usual functions for a collection, with the object types set to #PString# pointers. In addition some addition functions are added that take a const #PString# reference instead of a pointer as most standard collection functions do. This is more convenient for when string expressions are used as parameters to function in the collection. See the #PAbstractArray# and #PArray# classes and #PDECLARE_ARRAY# macro for more information.*/#ifdef DOC_PLUS_PLUSclass PStringArray : public PArray {#endifPDECLARE_ARRAY(PStringArray, PString); public: /**@name Construction */ //@{ /**Create a PStringArray from the array of C strings. */ PStringArray( PINDEX count, /// Count of strings in array char const * const * strarr, /// Array of C strings BOOL caseless = FALSE /// New strings are to be PCaselessStrings ); //@} /**@name New functions for class */ //@{ /**As for #GetValuesIndex()# but takes a PString argument so that literals will be automatically converted. @return Index of string in array or P_MAX_INDEX if not found. */ PINDEX GetStringsIndex( const PString & str /// String to search for index of ) const; inline PString & operator[]( PINDEX index // Index position in the collection of the object. ) const { return PStringArray_PTemplate::operator[](index); } /**Retrieve a reference to the object in the array. If there was not an object at that ordinal position or the index was beyond the size of the array then the function will create a new one. @return reference to the object at #index# position. */ PString & operator[]( PINDEX index /// Index position in the collection of the object. ); //@}};/**This is a list collection class of #PString# objects. It has all the usual functions for a collection, with the object types set to #PString# pointers. In addition some addition functions are added that take a const #PString# reference instead of a pointer as most standard collection functions do. This is more convenient for when string expressions are used as parameters to function in the collection. See the #PAbstractList# and #PList# classes and #PDECLARE_LIST# macro for more information. */#ifdef DOC_PLUS_PLUSclass PStringList : public PList {#endifPDECLARE_LIST(PStringList, PString); public: /**@name Construction */ //@{ /**Create a PStringArray from the array of C strings. */ PStringList( PINDEX count, /// Count of strings in array char const * const * strarr, /// Array of C strings BOOL caseless = FALSE /// New strings are to be PCaselessStrings ); //@} /**@name Operations */ //@{ /** Append a string to the list. */ PINDEX AppendString( const PString & str /// String to append. ); /** Insert a string into the list. */ PINDEX InsertString( const PString & before, /// String to insert before. const PString & str /// String to insert. ); /** Get the index of the string with the specified value. A linear search of list is performed to find the string value. */ PINDEX GetStringsIndex( const PString & str /// String value to search for. ) const; //@}};/**This is a sorted list collection class of #PString# objects. It has all the usual functions for a collection, with the object types set to #PString# pointers. In addition some addition functions are added that take a const #PString# reference instead of a pointer as most standard collection functions do. This is more convenient for when string expressions are used as parameters to function in the collection. See the #PAbstractSortedList# and #PSortedList# classes and #PDECLARE_SORTEDLIST# macro for more information. */#ifdef DOC_PLUS_PLUSclass PSortedStringList : public PSortedList {#endifPDECLARE_SORTED_LIST(PSortedStringList, PString); public: /**@name Construction */ //@{ /**Create a PStringArray from the array of C strings. */ PSortedStringList( PINDEX count, /// Count of strings in array char const * const * strarr, /// Array of C strings BOOL caseless = FALSE /// New strings are to be PCaselessStrings ); //@} /**@name Operations */ //@{ /** Add a string to the list. This will place the string in the correct position in the sorted list. */ PINDEX AppendString( const PString & str /// String to append. ); /** Get the index of the string with the specified value. A binary search of tree is performed to find the string value. */ PINDEX GetStringsIndex( const PString & str /// String value to search for. ) const; //@}};/**This is a set collection class of #PString# objects. It has all the usual functions for a collection, with the object types set to #PString# pointers. In addition some addition functions are added that take a const #PString# reference instead of a pointer as most standard collection functions do. This is more convenient for when string expressions are used as parameters to function in the collection. Unlike the normal sets, this will delete the PStrings removed from it. This complements the automatic creation of new PString objects when literals or expressions are used. See the #PAbstractSet# and #PSet# classes and #PDECLARE_SET# macro for more information. */#ifdef DOC_PLUS_PLUSclass PStringSet : public PSet {#endifPDECLARE_SET(PStringSet, PString, TRUE); public: /**@name Construction */ //@{ /**Create a PStringArray from the array of C strings. */ PStringSet( PINDEX count, /// Count of strings in array char const * const * strarr, /// Array of C strings BOOL caseless = FALSE /// New strings are to be PCaselessStrings ); //@} /**@name Operations */ //@{ /** Include the spcified string value into the set. */ void Include( const PString & key /// String value to add to set. ); /** Include the spcified string value into the set. */ PStringSet & operator+=( const PString & key /// String value to add to set. ); /** Exclude the spcified string value from the set. */ void Exclude( const PString & key /// String value to remove from set. ); /** Exclude the spcified string value from the set. */ PStringSet & operator-=( const PString & key /// String value to remove from set.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -