pstring.h File Reference
`#include <string>`
`#include <vector>`
`#include <ptlib/array.h>`

Go to the source code of this file.

## Classes

class | PString
| The character string class. More...
class | PCaselessString
| This class is a variation of a string that ignores case. More...
class | PConstantString< ParentString >
| Create a constant string. More...
class | PStringStream
| This class is a standard C++ stream class descendent for reading or writing streamed data to or from a `PString` class. More...
class | PStringArray
| This is an array collection class of `PString` objects. More...
class | PStringList
| This is a list collection class of `PString` objects. More...
class | PSortedStringList
| This is a sorted list collection class of `PString` objects. More...
class | PStringSet
| This is a set collection class of `PString` objects. More...
class | PStringDictionary< K >
| This template class maps the PAbstractDictionary to a specific key type and a `PString` data type. More...
class | POrdinalToString
| This is a dictionary collection class of `PString` objects, keyed by an ordinal value. More...
struct | POrdinalToString::Initialiser
| Structure for static array initialiser for class. More...
class | PStringToOrdinal
| This is a dictionary collection class of ordinals keyed by `PString` objects. More...
struct | PStringToOrdinal::Initialiser
| Structure for static array initialiser for class. More...
class | PStringToString
| This is a dictionary collection class of `PString` objects, keyed by another string. More...
struct | PStringToString::Initialiser
| Structure for static array initialiser for class. More...
class | PStringOptions
| Specialised version of PStringToString to contain a dictionary of options/attributes. More...
class | PRegularExpression
| A class representing a regular expression that may be used for locating patterns in strings. More...

## Macros

#define | PDECLARE_STRING_DICTIONARY(cls, K)
| Begin declaration of a dictionary of strings class. More...
#define | PSTRING_DICTIONARY(cls, K) typedef PStringDictionary<K> cls
| Declare a dictionary of strings class. More...

## Typedefs

typedef PConstantString< PString > | PConstString
| Constant PString type. See PConstantString. More...
typedef PConstantString< PCaselessString > | PConstCaselessString
| Constant PCaselessString type. See PConstantString. More...

## Functions

PString | psprintf (const char *fmt,...)
| The same as the standard C snprintf(fmt, 1000, ...), but returns a PString instead of a const char *. More...
PString | pvsprintf (const char *fmt, va_list arg)
| The same as the standard C vsnprintf(fmt, 1000, va_list arg), but returns a PString instead of a const char *. More...
| PBASEARRAY (PWCharArray, wchar_t)
ostream & | operator<< (ostream &stream, const PString &string)
wostream & | operator<< (wostream &stream, const PString &string)

## Macro Definition Documentation

## PDECLARE_STRING_DICTIONARY

#define PDECLARE_STRING_DICTIONARY | ( |  | cls,
|  |  | K
| ) |  |

Value:
PDECLARE_CLASS(cls, PStringDictionary<K>) \
protected: \
cls(int dummy, const cls * c) \
: PStringDictionary<K>(dummy, c) { } \
public: \
cls() \
: PStringDictionary<K>() { } \
virtual PObject * Clone() const \
{ return PNEW cls(0, this); } \
PStringDictionary
This template class maps the PAbstractDictionary to a specific key type and a PString data type...
Definition: pstring.h:2463
PDECLARE_CLASS
#define PDECLARE_CLASS(cls, par)
Declare a class with PWLib class information.
Definition: object.h:1106
PObject
Ultimate parent class for all objects in the class library.
Definition: object.h:1118
PNEW
#define PNEW
Macro for overriding system default new operator.
Definition: object.h:890

Begin declaration of a dictionary of strings class.

This macro is used to declare a descendent of PAbstractList class, customised for a particular key type K and data object type `PString`.

If the compilation is using templates then this macro produces a descendent of the `PStringDictionary` template class. If templates are not being used then the macro defines a set of inline functions to do all casting of types. The resultant classes have an identical set of functions in either case.

See the `PStringDictionary` and `PAbstractDictionary` classes for more information.

## PSTRING_DICTIONARY

#define PSTRING_DICTIONARY | ( |  | cls,
|  |  | K
| ) |  | typedef PStringDictionary<K> cls

Declare a dictionary of strings class.

This macro is used to declare a descendent of PAbstractDictionary class, customised for a particular key type K and data object type `PString`. This macro closes the class declaration off so no additional members can be added.

If the compilation is using templates then this macro produces a typedef of the `PStringDictionary` template class.

See the `PStringDictionary` class and `PDECLARE_STRING_DICTIONARY` macro for more information.

## Typedef Documentation

## PConstCaselessString

typedef PConstantString<PCaselessString> PConstCaselessString

Constant PCaselessString type. See PConstantString.

## PConstString

typedef PConstantString<PString> PConstString

Constant PString type. See PConstantString.

## Function Documentation

## operator<<() [1/2]

ostream& operator<< | ( | ostream & | stream,
|  | const PString & | string
| ) |  |

inline

## operator<<() [2/2]

wostream& operator<< | ( | wostream & | stream,
|  | const PString & | string
| ) |  |

inline

References PString::AsUCS2(), PObject::operator<<, PString::operator=(), PCLASSINFO, PString::PString(), and PContainer::reference.

## PBASEARRAY()

PBASEARRAY | ( | PWCharArray | ,
|  | wchar_t |
| ) |  |

## psprintf()

PString psprintf | ( | const char * | fmt,
|  |  | ...
| ) |  |

The same as the standard C snprintf(fmt, 1000, ...), but returns a PString instead of a const char *.

Produce formatted output as a string.

This is identical to the standard C library `sprintf()` function, but sends its output to a `PString`.

This function makes the assumption that there is less the 1000 characters of formatted output. The function will assert if this occurs.

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.

Returns
  reference to the current string object.

Parameters

  fmt | printf style format string

## pvsprintf()

PString pvsprintf | ( | const char * | fmt,
|  | va_list | arg
| ) |  |

The same as the standard C vsnprintf(fmt, 1000, va_list arg), but returns a PString instead of a const char *.

Produce formatted output as a string.

Parameters

  fmt | printf style format string
  arg | Arguments for formatting