class PStringArray

This is an array collection class of PString objects.

Inheritance:


Public Methods

[more] Construction
[more] Overrides from class PObject
[more] New functions for class


Inherited from PArray:


Inherited from PArrayObjects:

Public Methods

Overrides from class PContainer

Overrides from class PCollection


Inherited from PCollection:

Public Methods

Common functions for collections


Inherited from PContainer:

Public Methods

Common functions for containers

Protected Methods

ovirtual void DestroyContents()
ovirtual void AssignContents(const PContainer & c)
ovoid CopyContents(const PContainer & c)
ovoid CloneContents(const PContainer* src)
ovoid Destruct()


Inherited from PObject:

Public Methods

Run Time Type functions

I/O functions

Miscellaneous functions

Public Members

Comparison functions


Documentation

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.

o Construction

o PStringArray( PINDEX count, char const* const* strarr, BOOL caseless = FALSE )
Create a PStringArray from the array of C strings. If count is P_MAX_INDEX then strarr is assumed to point to an array of strings where the last pointer is NULL.
Parameters:
- count Count of strings in array
strarr - Array of C strings
caseless - New strings are to be PCaselessStrings

o PStringArray( const PString & str )
Create a PStringArray of length one from the single string.
Parameters:
- str Single string to convert to an array of one.

o PStringArray( const PStringList & list )
Create a PStringArray from the list of strings.
Parameters:
list - List of strings to convert to array.

o PStringArray( const PSortedStringList & list )
Create a PStringArray from the sorted list strings.
Parameters:
list - List of strings to convert to array.

o Overrides from class PObject

ovirtual void ReadFrom( istream &strm )
Input the contents of the object from the stream. This is primarily used by the standard operator>> function.

The default behaviour reads '\n' separated strings until !strm.good().

o New functions for class

oPINDEX GetStringsIndex( const PString & str ) const
As for GetValuesIndex() but takes a PString argument so that literals will be automatically converted.

Parameters:
- str String to search for index of
Returns:
Index of string in array or P_MAX_INDEX if not found.

oPString& operator[]( PINDEX 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.

Parameters:
index - Index position in the collection of the object.
Returns:
reference to the object at index position.

oPINDEX AppendString( const PString & str )
Append a string to the array
Parameters:
- str String to append.

oPStringArray& operator +=(const PStringArray & array)
Concatenate a PString or PStringArray to the array

Returns:
The PStringArray with the new items appended

oPStringArray operator + (const PStringArray & array)
Create a new PStringArray, and add PString or PStringArray to it a new PStringArray

Returns:
A new PStringArray with the additional elements(s)

ochar** ToCharArray( PCharArray* storage = NULL ) const
Create an array of C strings. If storage is NULL then this returns a single pointer that may be disposed of using free(). Note that each of the strings are part of the same memory allocation so only one free() is required.

If storage is not null then that is used to allocate the memory.


This class has no child classes.

Alphabetic index HTML hierarchy of classes or Java



This page was generated with the help of DOC++.