PTLib Version 2.12.9

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Macros | Typedefs | Functions
pstring.h File Reference
`#include <string>`
`#include <vector>`
`#include <ptlib/array.h>`
`#include <ptlib/bitwise_enum.h>`
Include dependency graph for pstring.h:
This graph shows which files directly or indirectly include this file:

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 | PSTRSTRM(arg) dynamic_cast<const PString &>(PStringStream() << std::flush << arg)
| Output a stream expression to a string parameter. More...
#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...
ostream & | operator<< (ostream &stream, const PString &string)

## Macro Definition Documentation

#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); } \

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.

#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.

#define PSTRSTRM | ( |  | arg | ) | dynamic_cast<const PString &>(PStringStream() << std::flush << arg)

Output a stream expression to a string parameter.

This allows a string parameter to a function use a stream expression to generate that string. For example, given the function:

          void DoSomething(const PString & str);

you could make a call to that function as:

          DoSomething(PSTRSTRM("Fred used" << number << " of \"" << item << '"'));

## Typedef Documentation

typedef PConstantString<PCaselessString> PConstCaselessString

Constant PCaselessString type. See PConstantString.

typedef PConstantString<PString> PConstString

Constant PString type. See PConstantString.

## Function Documentation

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

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

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