All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
pstring.h
Go to the documentation of this file.
/*
* 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): ______________________________________.
*
* $Revision: 27359 $
* $Author: rjongbloed $
* $Date: 2012-03-28 21:17:54 -0500 (Wed, 28 Mar 2012) $
*/
#ifndef PTLIB_STRING_H
#define PTLIB_STRING_H
#ifdef P_USE_PRAGMA
#pragma interface
#endif
#include <string>
#include <vector>
#include <ptlib/array.h>
// PString class
class PStringArray;
class PRegularExpression;
class PString;
PString psprintf(
const char * fmt,
...
);
PString pvsprintf(
const char * fmt,
va_list arg
);
#if (defined(_WIN32) || defined(_WIN32_WCE)) && (!defined(_NATIVE_WCHAR_T_DEFINED)) && (!defined(__MINGW32__))
PBASEARRAY(PWCharArray, unsigned short);
#else
PBASEARRAY(PWCharArray, wchar_t);
#endif
class PString : public PCharArray
{
PCLASSINFO(PString, PCharArray);
// using namespace std;
public:
typedef const char * Initialiser;
PINLINE PString();
PINLINE PString(
const PString & str
);
PINLINE PString(
const std::string & str
);
PString(
const char * cstr
);
PString(
const wchar_t * ustr
);
PString(
const char * cstr,
PINDEX len
);
PString(
const wchar_t * ustr,
PINDEX len
);
PString(
const PWCharArray & ustr
);
PString(
char ch
);
PString(
short n
);
PString(
unsigned short n
);
PString(
int n
);
PString(
unsigned int n
);
PString(
long n
);
PString(
unsigned long n
);
PString(
PInt64 n
);
PString(
PUInt64 n
);
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,
const char * str,
...
);
PString(
ConversionType type,
long value,
unsigned base = 10
);
PString(
ConversionType type,
double value,
unsigned places
);
PString & operator=(
const PString & str
);
PString & operator=(
const std::string & str
) { return operator=(str.c_str()); }
PString & operator=(
const char * cstr
);
PString & operator=(
char ch
);
PString & operator=(
short n
);
PString & operator=(
unsigned short n
);
PString & operator=(
int n
);
PString & operator=(
unsigned int n
);
PString & operator=(
long n
);
PString & operator=(
unsigned long n
);
PString & operator=(
PInt64 n
);
PString & operator=(
PUInt64 n
);
virtual PString & MakeEmpty();
static PString Empty();
virtual PObject * Clone() const;
virtual Comparison Compare(
const PObject & obj
) const;
virtual void PrintOn(
ostream & strm
) const;
virtual void ReadFrom(
istream & strm
);
virtual PINDEX HashFunction() const;
virtual PBoolean SetSize(
PINDEX newSize
);
virtual PBoolean IsEmpty() const;
virtual PBoolean MakeUnique();
PBoolean MakeMinimumSize();
PINLINE PINDEX GetLength() const;
bool operator!() const;
PString operator+(
const PString & str
) const;
PString operator+(
const char * cstr
) const;
PString operator+(
char ch
) const;
friend PString operator+(
const char * cstr,
const PString & str
);
friend PString operator+(
char ch,
const PString & str
);
PString & operator+=(
const PString & str
);
PString & operator+=(
const char * cstr
);
PString & operator+=(
char ch
);
PString operator&(
const PString & str
) const;
PString operator&(
const char * cstr
) const;
PString operator&(
char ch
) const;
friend PString operator&(
const char * cstr,
const PString & str
);
friend PString operator&(
char ch,
const PString & str
);
PString & operator&=(
const PString & str
);
PString & operator&=(
const char * cstr
);
PString & operator&=(
char ch
);
bool operator*=(
const PString & str
) const;
bool operator==(
const PObject & str
) const;
bool operator!=(
const PObject & str
) const;
bool operator<(
const PObject & str
) const;
bool operator>(
const PObject & str
) const;
bool operator<=(
const PObject & str
) const;
bool operator>=(
const PObject & str
) const;
bool operator*=(
const char * cstr
) const;
bool operator==(
const char * cstr
) const;
bool operator!=(
const char * cstr
) const;
bool operator<(
const char * cstr
) const;
bool operator>(
const char * cstr
) const;
bool operator<=(
const char * cstr
) const;
bool operator>=(
const char * cstr
) const;
Comparison NumCompare(
const PString & str,
PINDEX count = P_MAX_INDEX,
PINDEX offset = 0
) const;
Comparison NumCompare(
const char * cstr,
PINDEX count = P_MAX_INDEX,
PINDEX offset = 0
) const;
PINDEX Find(
char ch,
PINDEX offset = 0
) const;
PINDEX Find(
const PString & str,
PINDEX offset = 0
) const;
/* Locate the position within the string of the character or substring. The
search will begin at the character offset provided.
If <code>offset</code> is beyond the length of the string, then the
function will always return P_MAX_INDEX.
The matching will be for identical character or string. If a search
ignoring case is required then the string should be converted to a
PCaselessString before the search is made.
@return
position of character or substring in the string, or P_MAX_INDEX if the
character or substring is not in the string.
*/
PINDEX Find(
const char * cstr,
PINDEX offset = 0
) const;
PINDEX FindLast(
char ch,
PINDEX offset = P_MAX_INDEX
) const;
PINDEX FindLast(
const PString & str,
PINDEX offset = P_MAX_INDEX
) const;
PINDEX FindLast(
const char * cstr,
PINDEX offset = P_MAX_INDEX
) const;
PINDEX FindOneOf(
const PString & set,
PINDEX offset = 0
) const;
PINDEX FindOneOf(
const char * cset,
PINDEX offset = 0
) const;
PINDEX FindSpan(
const PString & set,
PINDEX offset = 0
) const;
PINDEX FindSpan(
const char * cset,
PINDEX offset = 0
) const;
PINDEX FindRegEx(
const PRegularExpression & regex,
PINDEX offset = 0
) const;
PBoolean FindRegEx(
const PRegularExpression & regex,
PINDEX & pos,
PINDEX & len,
PINDEX offset = 0,
PINDEX maxPos = P_MAX_INDEX
) const;
PBoolean MatchesRegEx(
const PRegularExpression & regex
) const;
void Replace(
const PString & target,
const PString & subs,
PBoolean all = false,
PINDEX offset = 0
);
void Splice(
const PString & str,
PINDEX pos,
PINDEX len = 0
);
void Splice(
const char * cstr,
PINDEX pos,
PINDEX len = 0
);
void Delete(
PINDEX start,
PINDEX len
);
PString operator()(
PINDEX start,
PINDEX end
) const;
PString Left(
PINDEX len
) const;
PString Right(
PINDEX len
) const;
PString Mid(
PINDEX start,
PINDEX len = P_MAX_INDEX
) const;
PString LeftTrim() const;
PString RightTrim() const;
PString Trim() const;
PString ToLower() const;
PString ToUpper() const;
PStringArray Tokenise(
const PString & separators,
PBoolean onePerSeparator = true
) const;
PStringArray Tokenise(
const char * cseparators,
PBoolean onePerSeparator = true
) const;
PStringArray Lines() const;
PString & sprintf(
const char * cfmt,
...
);
friend PString psprintf(
const char * cfmt,
...
);
PString & vsprintf(
const PString & fmt,
va_list args
);
PString & vsprintf(
const char * cfmt,
va_list args
);
friend PString pvsprintf(
const char * cfmt,
va_list args
);
friend PString pvsprintf(
const PString & fmt,
va_list args
);
long AsInteger(
unsigned base = 10
) const;
DWORD AsUnsigned(
unsigned base = 10
) const;
PInt64 AsInt64(
unsigned base = 10
) const;
PUInt64 AsUnsigned64(
unsigned base = 10
) const;
double AsReal() const;
PWCharArray AsUCS2() const;
PBYTEArray ToPascal() const;
PString ToLiteral() const;
operator const unsigned char *() const;
operator std::string () const
{ return std::string(theArray); }
protected:
void InternalFromUCS2(
const wchar_t * ptr,
PINDEX len
);
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.
*/
PString(int dummy, const PString * str);
PString(PContainerReference & reference) : PCharArray(reference) { }
};
inline ostream & operator<<(ostream & stream, const PString & string)
{
string.PrintOn(stream);
return stream;
}
inline wostream & operator<<(wostream & stream, const PString & string)
{
return stream << (const char *)string;
}
#ifdef _WIN32
class PWideString : public PWCharArray {
PCLASSINFO(PWideString, PWCharArray);
public:
typedef const wchar_t * Initialiser;
PWideString() { }
PWideString(const PWCharArray & arr) : PWCharArray(arr) { }
PWideString(const PString & str) : PWCharArray(str.AsUCS2()) { }
PWideString(const char * str) : PWCharArray(PString(str).AsUCS2()) { }
PWideString & operator=(const PWideString & str) { PWCharArray::operator=(str); return *this; }
PWideString & operator=(const PString & str) { PWCharArray::operator=(str.AsUCS2()); return *this; }
PWideString & operator=(const std::string & str) { PWCharArray::operator=(PString(str.c_str()).AsUCS2()); return *this; }
PWideString & operator=(const char * str) { PWCharArray::operator=(PString(str).AsUCS2()); return *this; }
friend inline ostream & operator<<(ostream & stream, const PWideString & string) { return stream << PString(string); }
protected:
PWideString(PContainerReference & reference) : PWCharArray(reference) { }
};
#ifdef UNICODE
typedef PWideString PVarString;
#else
typedef PString PVarString;
#endif
#endif
class PCaselessString : public PString
{
PCLASSINFO(PCaselessString, PString);
public:
PCaselessString();
PCaselessString(
const char * cstr
);
PCaselessString(
const PString & str
);
PCaselessString(
const std::string & str
) : PString(str)
{ }
PCaselessString & operator=(
const PString & str
);
PCaselessString & operator=(
const std::string & str
) { return operator=(str.c_str()); }
PCaselessString & operator=(
const char * cstr
);
PCaselessString & operator=(
char ch
);
// Overrides from class PObject
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);
PCaselessString(PContainerReference & reference) : PString(reference) { }
};
template <class ParentString>
class PConstantString : public ParentString
{
private:
PContainerReference m_staticReference;
public:
PConstantString(typename ParentString::Initialiser init)
: ParentString(m_staticReference)
, m_staticReference((PINDEX)strlen(init)+1, true)
{
this->theArray = (char *)init;
}
~PConstantString() { this->Destruct(); }
virtual PBoolean SetSize(PINDEX) { return false; }
virtual void AssignContents(const PContainer &) { PAssertAlways(PInvalidParameter); }
virtual void DestroyReference() { }
private:
PConstantString(const PConstantString &)
: ParentString(m_staticReference)
, m_staticReference(0, true)
{ }
void operator=(const PConstantString &) { }
};
typedef PConstantString<PString> PConstString;
typedef PConstantString<PCaselessString> PConstCaselessString;
class PStringStream;
class PStringStream : public PString, public iostream
{
PCLASSINFO(PStringStream, PString);
public:
PStringStream();
PStringStream(
PINDEX fixedBufferSize
);
PStringStream(
const PString & str
);
PStringStream(
const char * cstr
);
virtual PString & MakeEmpty();
PStringStream & operator=(
const PStringStream & strm
);
PStringStream & operator=(
const PString & str
);
PStringStream & operator=(
const char * cstr
);
PStringStream & operator=(
char ch
);
virtual ~PStringStream();
protected:
virtual void AssignContents(const PContainer & cont);
private:
PStringStream(int, const PStringStream &) : iostream(cout.rdbuf()) { }
class Buffer : public streambuf {
public:
Buffer(PStringStream & str, PINDEX size);
Buffer(const Buffer & sbuf);
Buffer & operator=(const Buffer & sbuf);
virtual int_type overflow(int_type = EOF);
virtual int_type underflow();
virtual int sync();
virtual pos_type seekoff(off_type, ios_base::seekdir, ios_base::openmode = ios_base::in | ios_base::out);
virtual pos_type seekpos(pos_type, ios_base::openmode = ios_base::in | ios_base::out);
PStringStream & string;
PBoolean fixedBufferSize;
};
};
class PStringList;
class PSortedStringList;
#ifdef DOC_PLUS_PLUS
class PStringArray : public PArray {
#endif
PDECLARE_ARRAY(PStringArray, PString);
public:
PStringArray(
PINDEX count,
char const * const * strarr,
PBoolean caseless = false
);
PStringArray(
const PString & str
);
PStringArray(
const PStringList & list
);
PStringArray(
const PSortedStringList & list
);
PStringArray(
const std::vector<PString> & vec
)
{
for (std::vector<PString>::const_iterator r = vec.begin(); r != vec.end(); ++r)
AppendString(*r);
}
PStringArray(
const std::vector<std::string> & vec
)
{
for (std::vector<std::string>::const_iterator r = vec.begin(); r != vec.end(); ++r)
AppendString(PString(*r));
}
template <typename stlContainer>
static PStringArray container(
const stlContainer & vec
)
{
PStringArray list;
for (typename stlContainer::const_iterator r = vec.begin(); r != vec.end(); ++r)
list.AppendString(PString(*r));
return list;
}
virtual void ReadFrom(
istream &strm // Stream to read the objects contents from.
);
PINDEX GetStringsIndex(
const PString & str
) const;
PString operator[](
PINDEX index
) const;
PString & operator[](
PINDEX index
);
PINDEX AppendString(
const PString & str
);
PStringArray & operator +=(const PStringArray & array);
PStringArray & operator +=(const PString & str);
PStringArray operator + (const PStringArray & array);
PStringArray operator + (const PString & str);
char ** ToCharArray(
PCharArray * storage = NULL
) const;
};
#ifdef DOC_PLUS_PLUS
class PStringList : public PList {
#endif
PDECLARE_LIST(PStringList, PString);
public:
PStringList(
PINDEX count,
char const * const * strarr,
PBoolean caseless = false
);
PStringList(
const PString & str
);
PStringList(
const PStringArray & array
);
PStringList(
const PSortedStringList & list
);
virtual void ReadFrom(
istream &strm // Stream to read the objects contents from.
);
PINDEX AppendString(
const PString & str
);
PINDEX InsertString(
const PString & before,
const PString & str
);
PINDEX GetStringsIndex(
const PString & str
) const;
PStringList & operator +=(const PStringList & list);
PStringList & operator +=(const PString & str);
PStringList operator + (const PStringList & array);
PStringList operator + (const PString & str);
template <typename stlContainer>
static PStringList container(
const stlContainer & vec
)
{
PStringList list;
for (typename stlContainer::const_iterator r = vec.begin(); r != vec.end(); ++r)
list.AppendString(PString(*r));
return list;
}
};
#ifdef DOC_PLUS_PLUS
class PSortedStringList : public PSortedList {
#endif
PDECLARE_SORTED_LIST(PSortedStringList, PString);
public:
PSortedStringList(
PINDEX count,
char const * const * strarr,
PBoolean caseless = false
);
PSortedStringList(
const PString & str
);
PSortedStringList(
const PStringArray & array
);
PSortedStringList(
const PStringList & list
);
virtual void ReadFrom(
istream &strm // Stream to read the objects contents from.
);
PINDEX AppendString(
const PString & str
);
PINDEX GetStringsIndex(
const PString & str
) const;
PINDEX GetNextStringsIndex(
const PString & str
) const;
protected:
PINDEX InternalStringSelect(
const char * str,
PINDEX len,
Element * thisElement,
Element * & lastElement
) const;
};
#ifdef DOC_PLUS_PLUS
class PStringSet : public PSet {
#endif
PDECLARE_SET(PStringSet, PString, true);
public:
PStringSet(
PINDEX count,
char const * const * strarr,
PBoolean caseless = false
);
PStringSet(
const PString & str
);
PStringSet(
const PStringArray & strArray
);
PStringSet(
const PStringList & strList
);
virtual void ReadFrom(
istream &strm
);
void Include(
const PString & key
);
PStringSet & operator+=(
const PString & key
);
void Exclude(
const PString & key
);
PStringSet & operator-=(
const PString & key
);
};
template <class K> class PStringDictionary : public PAbstractDictionary
{
PCLASSINFO(PStringDictionary, PAbstractDictionary);
public:
PStringDictionary()
: PAbstractDictionary() { }
virtual PObject * Clone() const
{ return PNEW PStringDictionary(0, this); }
const PString & operator[](const K & key) const
{ return (const PString &)GetRefAt(key); }
PString operator()(const K & key, const char * dflt = NULL) const
{
PString * str = this->GetAt(key);
return str != NULL ? *str : PString(dflt);
}
PBoolean Contains(
const K & key // Key to look for in the dictionary.
) const { return AbstractContains(key); }
virtual PString * RemoveAt(
const K & key // Key for position in dictionary to get object.
) {
PString * s = GetAt(key); AbstractSetAt(key, NULL);
return reference->deleteObjects ? (s ? (PString *)-1 : NULL) : s;
}
virtual PString * GetAt(
const K & key // Key for position in dictionary to get object.
) const { return (PString *)AbstractGetAt(key); }
virtual PBoolean SetDataAt(
PINDEX index, // Ordinal index in the dictionary.
const PString & str // New string value to put into the dictionary.
) { return PAbstractDictionary::SetDataAt(index, PNEW PString(str)); }
virtual PBoolean SetAt(
const K & key, // Key for position in dictionary to add object.
const PString & str // New string value to put into the dictionary.
) { return AbstractSetAt(key, PNEW PString(str)); }
const K & GetKeyAt(PINDEX index) const
{ return (const K &)AbstractGetKeyAt(index); }
PString & GetDataAt(PINDEX index) const
{ return (PString &)AbstractGetDataAt(index); }
protected:
PStringDictionary(int dummy, const PStringDictionary * c)
: PAbstractDictionary(dummy, c) { }
};
#define PDECLARE_STRING_DICTIONARY(cls, K) \
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); } \
#define PSTRING_DICTIONARY(cls, K) typedef PStringDictionary<K> cls
#ifdef DOC_PLUS_PLUS
class POrdinalToString : public PStringDictionary {
#endif
PDECLARE_STRING_DICTIONARY(POrdinalToString, POrdinalKey);
public:
struct Initialiser {
PINDEX key;
const char * value;
};
POrdinalToString(
PINDEX count,
const Initialiser * init
);
virtual void ReadFrom(
istream &strm // Stream to read the objects contents from.
);
};
#ifdef DOC_PLUS_PLUS
class PStringToOrdinal : public POrdinalDictionary {
#endif
PDECLARE_ORDINAL_DICTIONARY(PStringToOrdinal, PString);
public:
struct Initialiser {
const char * key;
PINDEX value;
};
PStringToOrdinal(
PINDEX count,
const Initialiser * init,
PBoolean caseless = false
);
virtual void ReadFrom(
istream &strm // Stream to read the objects contents from.
);
};
#ifdef DOC_PLUS_PLUS
class PStringToString : public PStringDictionary {
#endif
PDECLARE_STRING_DICTIONARY(PStringToString, PString);
public:
struct Initialiser {
const char * key;
const char * value;
};
PStringToString(
PINDEX count,
const Initialiser * init,
PBoolean caselessKeys = false,
PBoolean caselessValues = false
);
virtual void ReadFrom(
istream &strm // Stream to read the objects contents from.
);
char ** ToCharArray(
bool withEqualSign,
PCharArray * storage = NULL
) const;
};
class PStringOptions : public PStringToString
{
public:
PStringOptions() { }
PStringOptions(const PStringToString & other) : PStringToString(other) { }
PStringOptions & operator=(const PStringToString & other) { PStringToString::operator=(other); return *this; }
bool Contains(const char * key ) const { PConstCaselessString k(key); return PStringToString::Contains(k); }
bool Contains(const PString & key ) const { return PStringToString::Contains(PCaselessString(key)); }
bool Contains(const PCaselessString & key ) const { return PStringToString::Contains(key); }
bool Contains(const PCaselessString & (*key)()) const { return PStringToString::Contains(key()); }
// Overide default PStringToString::SetAt() to make sure the key is caseless
PString * GetAt(const char * key ) const { PConstCaselessString k(key); return PStringToString::GetAt(k); }
PString * GetAt(const PString & key ) const { return PStringToString::GetAt(PCaselessString(key)); }
PString * GetAt(const PCaselessString & key ) const { return PStringToString::GetAt(key); }
PString * GetAt(const PCaselessString & (*key)()) const { return PStringToString::GetAt(key()); }
// Overide default PStringToString::SetAt() to make sure the key is caseless
PBoolean SetAt(const char * key, const PString & data) { PConstCaselessString k(key); return SetAt(k, data); }
PBoolean SetAt(const PString & key, const PString & data) { return SetAt(PCaselessString(key), data); }
PBoolean SetAt(const PCaselessString & key, const PString & data) { MakeUnique(); return PStringToString::SetAt(key, data); }
PBoolean SetAt(const PCaselessString & (*key)(), const PString & data) { return SetAt(key(), data); }
// Overide default PStringToString::RemoveAt() to make sure the key is caseless
PString * RemoveAt(const char * key) { PConstCaselessString k(key); return RemoveAt(k); }
PString * RemoveAt(const PString & key) { return RemoveAt(PCaselessString(key)); }
PString * RemoveAt(const PCaselessString & key) { MakeUnique(); return PStringToString::RemoveAt(key); }
PString * RemoveAt(const PCaselessString & (*key)()) { return RemoveAt(key()); }
PString GetString(const char * key, const char * dflt = NULL) const { PConstCaselessString k(key); return GetString(k, dflt); }
PString GetString(const PString & key, const char * dflt = NULL) const { return GetString(PCaselessString(key), dflt); }
PString GetString(const PCaselessString & key, const char * dflt = NULL) const;
PString GetString(const PCaselessString & (*key)(), const char * dflt = NULL) const { return GetString(key(), dflt); }
bool SetString(const char * key, const PString & value) { return SetAt(key, value); }
bool SetString(const PString & key, const PString & value) { return SetAt(key, value); }
bool SetString(const PCaselessString & key, const PString & value) { return SetAt(key, value); }
bool SetString(const PCaselessString & (*key)(), const PString & value) { return SetAt(key, value); }
bool GetBoolean(const char * key, bool dflt = false) const { PConstCaselessString k(key); return GetBoolean(k, dflt); }
bool GetBoolean(const PString & key, bool dflt = false) const { return GetBoolean(PCaselessString(key), dflt); }
bool GetBoolean(const PCaselessString & key, bool dflt = false) const;
bool GetBoolean(const PCaselessString & (*key)(), bool dflt = false) const { return GetBoolean(key(), dflt); }
void SetBoolean(const char * key, bool value) { PConstCaselessString k(key); SetBoolean(k, value); }
void SetBoolean(const PString & key, bool value) { SetBoolean(PCaselessString(key), value); }
void SetBoolean(const PCaselessString & key, bool value) { SetAt(key, value ? "true" : "false"); }
void SetBoolean(const PCaselessString & (*key)(), bool value) { SetBoolean(key(), value); }
long GetInteger(const char * key, long dflt = 0) const { PConstCaselessString k(key); return GetInteger(k, dflt); }
long GetInteger(const PString & key, long dflt = 0) const { return GetInteger(PCaselessString(key), dflt); }
long GetInteger(const PCaselessString & key, long dflt = 0) const;
long GetInteger(const PCaselessString & (*key)(), long dflt = 0) const { return GetInteger(key(), dflt); }
void SetInteger(const char * key, long value) { PConstCaselessString k(key); SetInteger(k, value); }
void SetInteger(const PString & key, long value) { SetInteger(PCaselessString(key), value); }
void SetInteger(const PCaselessString & key, long value);
void SetInteger(const PCaselessString & (*key)(), long value) { SetInteger(key(), value); }
double GetReal(const char * key, double dflt = 0) const { PConstCaselessString k(key); return GetReal(k, dflt); }
double GetReal(const PString & key, double dflt = 0) const { return GetReal(PCaselessString(key), dflt); }
double GetReal(const PCaselessString & key, double dflt = 0) const;
double GetReal(const PCaselessString & (*key)(), double dflt = 0) const { return GetReal(key(), dflt); }
void SetReal(const char * key, double value, int decimals) { PConstCaselessString k(key); SetReal(k, value, decimals); }
void SetReal(const PString & key, double value, int decimals) { SetReal(PCaselessString(key), value, decimals); }
void SetReal(const PCaselessString & key, double value, int decimals);
void SetReal(const PCaselessString & (*key)(), double value, int decimals) { SetReal(key(), value, decimals); }
__inline bool Has(const char * key) const { return Contains(key); }
__inline bool Has(const PString & key) const { return Contains(key); }
__inline bool Has(const PCaselessString & key) const { return Contains(key); }
__inline bool Has(const PCaselessString & (*key)()) const { return Contains(key); }
__inline PString Get(const char * key, const char * dflt = NULL) const { return GetString(key, dflt); }
__inline PString Get(const PString & key, const char * dflt = NULL) const { return GetString(key, dflt); }
__inline PString Get(const PCaselessString & key, const char * dflt = NULL) const { return GetString(key, dflt); }
__inline PString Get(const PCaselessString & (*key)(), const char * dflt = NULL) const { return GetString(key, dflt); }
__inline PString Get(const char * key, const PString & dflt) const { return GetString(key, dflt); }
__inline PString Get(const PString & key, const PString & dflt) const { return GetString(key, dflt); }
__inline PString Get(const PCaselessString & key, const PString & dflt) const { return GetString(key, dflt); }
__inline PString Get(const PCaselessString & (*key)(), const PString & dflt) const { return GetString(key, dflt); }
__inline bool Set(const char * key, const PString & value) { return SetAt(key, value); }
__inline bool Set(const PString & key, const PString & value) { return SetAt(key, value); }
__inline bool Set(const PCaselessString & key, const PString & value) { return SetAt(key, value); }
__inline bool Set(const PCaselessString & (*key)(), const PString & value) { return SetAt(key, value); }
__inline void Remove(const char * key) { RemoveAt(key); }
__inline void Remove(const PString & key) { RemoveAt(key); }
__inline void Remove(const PCaselessString & key) { RemoveAt(key); }
__inline void Remove(const PCaselessString & (*key)()) { RemoveAt(key); }
};
class PRegularExpression : public PObject
{
PCLASSINFO(PRegularExpression, PObject);
public:
enum {
Extended = 1,
IgnoreCase = 2,
AnchorNewLine = 4
};
enum {
NotBeginningOfLine = 1,
NotEndofLine = 2
};
PRegularExpression();
PRegularExpression(
const PString & pattern,
int flags = IgnoreCase
);
PRegularExpression(
const char * cpattern,
int flags = IgnoreCase
);
PRegularExpression(
const PRegularExpression &
);
PRegularExpression & operator =(
const PRegularExpression &
);
~PRegularExpression();
virtual void PrintOn(
ostream & strm
) const;
enum ErrorCodes {
NoError = 0,
NoMatch,
// POSIX regcomp return error codes. (In the order listed in the standard.)
BadPattern,
CollateError,
BadClassType,
BadEscape,
BadSubReg,
UnmatchedBracket,
UnmatchedParen,
UnmatchedBrace,
BadBR,
RangeError,
OutOfMemory,
BadRepitition,
/* Error codes we've added. */
PrematureEnd,
TooBig,
UnmatchedRParen,
NotCompiled
};
ErrorCodes GetErrorCode() const;
PString GetErrorText() const;
const PString & GetPattern() const { return patternSaved; }
PBoolean Compile(
const PString & pattern,
int flags = IgnoreCase
);
PBoolean Compile(
const char * cpattern,
int flags = IgnoreCase
);
PBoolean Execute(
const PString & str,
PINDEX & start,
int flags = 0
) const;
PBoolean Execute(
const PString & str,
PINDEX & start,
PINDEX & len,
int flags = 0
) const;
PBoolean Execute(
const char * cstr,
PINDEX & start,
int flags = 0
) const;
PBoolean Execute(
const char * cstr,
PINDEX & start,
PINDEX & len,
int flags = 0
) const;
PBoolean Execute(
const PString & str,
PIntArray & starts,
int flags = 0
) const;
PBoolean Execute(
const PString & str,
PIntArray & starts,
PIntArray & ends,
int flags = 0
) const;
PBoolean Execute(
const char * cstr,
PIntArray & starts,
int flags = 0
) const;
PBoolean Execute(
const char * cstr,
PIntArray & starts,
PIntArray & ends,
int flags = 0
) const;
PBoolean Execute(
const char * cstr,
PStringArray & substring,
int flags = 0
) const;
static PString EscapeString(
const PString & str
);
protected:
PString patternSaved;
int flagsSaved;
void * expression;
mutable ErrorCodes lastError;
};
#endif // PTLIB_STRING_H
// End Of File ///////////////////////////////////////////////////////////////
PHashTable::AbstractContains
PINLINE PBoolean AbstractContains(const PObject &key) const
Determine if the value of the object is contained in the hash table.
POrdinalToString::Initialiser::value
const char * value
String value for ordinal.
Definition: pstring.h:2697
PString::AsInteger
long AsInteger(unsigned base=10) const
Convert the string to an integer value using the specified number base.
PStringOptions::SetReal
void SetReal(const PString &key, double value, int decimals)
Definition: pstring.h:2920
PStringOptions::GetAt
PString * GetAt(const PCaselessString &key) const
Definition: pstring.h:2861
PStringOptions::RemoveAt
PString * RemoveAt(const PString &key)
Definition: pstring.h:2872
PStringToString::ToCharArray
char ** ToCharArray(bool withEqualSign, PCharArray *storage=NULL) const
Create an array of C strings.
PContainer::MakeUnique
virtual PBoolean MakeUnique()
Make this instance to be the one and only reference to the container contents.
PStringOptions::Remove
__inline void Remove(const char *key)
Remove option value.
Definition: pstring.h:2947
PStringStream::~PStringStream
virtual ~PStringStream()
Destroy the string stream, deleting the stream buffer.
PStringOptions::SetBoolean
void SetBoolean(const PCaselessString &(*key)(), bool value)
Definition: pstring.h:2898
PRegularExpression::PRegularExpression
PRegularExpression()
Create a new, empty, regular expression.
PRegularExpression::BadEscape
Trailing backslash.
Definition: pstring.h:3053
PRegularExpression::CollateError
Not implemented.
Definition: pstring.h:3049
PRegularExpression::GetErrorCode
ErrorCodes GetErrorCode() const
Get the error code for the last Compile() or Execute() operation.
PString::pvsprintf
friend PString pvsprintf(const char *cfmt, va_list args)
Produce formatted output as a string.
PStringOptions::GetBoolean
bool GetBoolean(const char *key, bool dflt=false) const
Get the option value as a boolean.
Definition: pstring.h:2889
PString::operator&=
PString & operator&=(const PString &str)
Concatenate a string to another string, modifiying that string.
PString::operator=
PString & operator=(const PString &str)
Assign the string to the current object.
PRegularExpression::operator=
PRegularExpression & operator=(const PRegularExpression &)
Assign a regular expression.
operator<<
ostream & operator<<(ostream &stream, const PString &string)
Definition: pstring.h:1655
PString::operator*=
bool operator*=(const PString &str) const
Compare two strings using case insensitive comparison.
PString::PrintOn
virtual void PrintOn(ostream &strm) const
Output the string to the specified stream.
PSortedListElement
Definition: lists.h:686
PRegularExpression::GetPattern
const PString & GetPattern() const
Return the string which represents the pattern matched by the regular expression. ...
Definition: pstring.h:3098
PStringSet::ReadFrom
virtual void ReadFrom(istream &strm)
Input the contents of the object from the stream.
PCharArray
Array of characters.
Definition: array.h:551
PStringDictionary
This template class maps the PAbstractDictionary to a specific key type and a PString data type...
Definition: pstring.h:2463
PStringToOrdinal::Initialiser::value
PINDEX value
Ordinal value for string.
Definition: pstring.h:2744
PRegularExpression::BadClassType
Invalid character class name.
Definition: pstring.h:3051
PCLASSINFO
#define PCLASSINFO(cls, par)
Declare all the standard PTLib class information.
Definition: object.h:1049
PSortedStringList::AppendString
PINDEX AppendString(const PString &str)
Add a string to the list.
PSortedStringList::InternalStringSelect
PINDEX InternalStringSelect(const char *str, PINDEX len, Element *thisElement, Element *&lastElement) const
PStringArray::operator+=
PStringArray & operator+=(const PStringArray &array)
Concatenate a PString or PStringArray to the array.
PString::operator<=
bool operator<=(const PObject &str) const
Compare two strings using the PObject::Compare() function.
PRegularExpression::AnchorNewLine
If this bit is set, then anchors do not match at newline characters in the string.
Definition: pstring.h:2976
PStringOptions::SetAt
PBoolean SetAt(const PCaselessString &key, const PString &data)
Definition: pstring.h:2867
PStringOptions::PStringOptions
PStringOptions()
Definition: pstring.h:2848
PString::GetLength
PINLINE PINDEX GetLength() const
Determine the length of the null terminated string.
PCaselessString::Clone
virtual PObject * Clone() const
Make a complete duplicate of the string.
PStringList::container
static PStringList container(const stlContainer &vec)
Create a PStringArray from an STL container.
Definition: pstring.h:2271
PRegularExpression::expression
void * expression
Definition: pstring.h:3228
PStringStream::AssignContents
virtual void AssignContents(const PContainer &cont)
Copy the container contents.
PStringOptions::Set
__inline bool Set(const PCaselessString &key, const PString &value)
Definition: pstring.h:2943
PAssertAlways
#define PAssertAlways(msg)
This macro is used to assert immediately.
Definition: object.h:229
PStringSet::PStringSet
PStringSet(PINDEX count, char const *const *strarr, PBoolean caseless=false)
Create a PStringArray from the array of C strings.
PStringOptions::Has
__inline bool Has(const PString &key) const
Definition: pstring.h:2926
PStringOptions::GetInteger
long GetInteger(const PCaselessString &(*key)(), long dflt=0) const
Definition: pstring.h:2904
POrdinalToString::Initialiser::key
PINDEX key
Ordinal key for string.
Definition: pstring.h:2695
PCaselessString::PCaselessString
PCaselessString()
Create a new, empty, caseless string.
PStringToString::ReadFrom
virtual void ReadFrom(istream &strm)
Input the contents of the object from the stream.
POrdinalToString::POrdinalToString
POrdinalToString(PINDEX count, const Initialiser *init)
Initialise the ordinal dictionary of strings from the static array.
PString::AsInt64
PInt64 AsInt64(unsigned base=10) const
Convert the string to an integer value using the specified number base.
PString::MakeEmpty
virtual PString & MakeEmpty()
Make the current string empty.
PStringToOrdinal::Initialiser
Structure for static array initialiser for class.
Definition: pstring.h:2740
PCaselessString::operator=
PCaselessString & operator=(const PString &str)
Assign the string to the current object.
PINLINE
#define PINLINE
Definition: object.h:127
PStringStream
This class is a standard C++ stream class descendent for reading or writing streamed data to or from ...
Definition: pstring.h:1878
PString::NumConversionTypes
Definition: pstring.h:290
PString::Replace
void Replace(const PString &target, const PString &subs, PBoolean all=false, PINDEX offset=0)
Locate the substring within the string and replace it with the specifed substring.
PRegularExpression::ErrorCodes
ErrorCodes
Error codes.
Definition: pstring.h:3039
PStringList::GetStringsIndex
PINDEX GetStringsIndex(const PString &str) const
Get the index of the string with the specified value.
PString::Literal
Definition: pstring.h:284
PString::sprintf
PString & sprintf(const char *cfmt,...)
Concatenate a formatted output to the string.
PStringArray::AppendString
PINDEX AppendString(const PString &str)
Append a string to the array.
PStringToString
This is a dictionary collection class of PString objects, keyed by another string.
Definition: pstring.h:2784
PStringList::ReadFrom
virtual void ReadFrom(istream &strm)
Input the contents of the object from the stream.
PContainer::operator=
PContainer & operator=(const PContainer &cont)
Assign one container reference to another.
PRegularExpression::BadSubReg
Invalid back reference.
Definition: pstring.h:3055
PStringToString::Initialiser::key
const char * key
String key for string.
Definition: pstring.h:2793
PRegularExpression::EscapeString
static PString EscapeString(const PString &str)
Escape all characters in the str parameter that have a special meaning within a regular expression...
PCaselessString::InternalCompare
virtual Comparison InternalCompare(PINDEX offset, char c) const
PString::Decimal
Definition: pstring.h:287
PObject::Comparison
Comparison
Result of the comparison operation performed by the Compare() function.
Definition: object.h:1184
PStringOptions::Contains
bool Contains(const PCaselessString &(*key)()) const
Definition: pstring.h:2856
PString::PString
PString(PContainerReference &reference)
Definition: pstring.h:1651
PRegularExpression::PrematureEnd
Premature end.
Definition: pstring.h:3073
PString::operator!=
bool operator!=(const PObject &str) const
Compare two strings using the PObject::Compare() function.
PCaselessString
This class is a variation of a string that ignores case.
Definition: pstring.h:1708
PAbstractDictionary
An abstract dictionary container.
Definition: dict.h:626
PStringOptions::Set
__inline bool Set(const PCaselessString &(*key)(), const PString &value)
Definition: pstring.h:2944
PString::ToPascal
PBYTEArray ToPascal() const
Convert a standard null terminated string to a "pascal" style string.
PStringOptions::GetAt
PString * GetAt(const PCaselessString &(*key)()) const
Definition: pstring.h:2862
PStringSet::Include
void Include(const PString &key)
Include the spcified string value into the set.
PStringOptions::operator=
PStringOptions & operator=(const PStringToString &other)
Definition: pstring.h:2850
PStringOptions::SetAt
PBoolean SetAt(const PString &key, const PString &data)
Definition: pstring.h:2866
PConstantString::SetSize
virtual PBoolean SetSize(PINDEX)
Definition: pstring.h:1847
PString::RightTrim
PString RightTrim() const
Create a string consisting of all characters from the source string except all spaces at the end of t...
PStringOptions::SetAt
PBoolean SetAt(const PCaselessString &(*key)(), const PString &data)
Definition: pstring.h:2868
PStringArray::ToCharArray
char ** ToCharArray(PCharArray *storage=NULL) const
Create an array of C strings.
PStringOptions::GetReal
double GetReal(const PCaselessString &(*key)(), double dflt=0) const
Definition: pstring.h:2916
PStringArray::operator[]
PString operator[](PINDEX index) const
PStringOptions::SetAt
PBoolean SetAt(const char *key, const PString &data)
Definition: pstring.h:2865
PStringArray
This is an array collection class of PString objects.
Definition: pstring.h:2024
PRegularExpression::~PRegularExpression
~PRegularExpression()
Release storage for the compiled regular expression.
PStringOptions::Remove
__inline void Remove(const PCaselessString &key)
Definition: pstring.h:2949
PConstString
PConstantString< PString > PConstString
Constant PString type. See PConstantString.
Definition: pstring.h:1861
PStringOptions::Has
__inline bool Has(const PCaselessString &(*key)()) const
Definition: pstring.h:2928
PString::InternalCompare
virtual Comparison InternalCompare(PINDEX offset, char c) const
PRegularExpression::Extended
Use extended regular expressions.
Definition: pstring.h:2969
PString::Right
PString Right(PINDEX len) const
Extract a portion of the string into a new string.
PString::HashFunction
virtual PINDEX HashFunction() const
Calculate a hash value for use in sets and dictionaries.
PRegularExpression::flagsSaved
int flagsSaved
Definition: pstring.h:3226
PString::PString
PINLINE PString()
Construct an empty string.
PRegularExpression::patternSaved
PString patternSaved
Definition: pstring.h:3225
PString::ToLiteral
PString ToLiteral() const
Convert the string to C literal string format.
PRegularExpression::Compile
PBoolean Compile(const PString &pattern, int flags=IgnoreCase)
Compiler pattern.
PStringOptions::RemoveAt
PString * RemoveAt(const char *key)
Definition: pstring.h:2871
PStringOptions::GetBoolean
bool GetBoolean(const PString &key, bool dflt=false) const
Definition: pstring.h:2890
array.h
PString::ReadFrom
virtual void ReadFrom(istream &strm)
Input the string from the specified stream.
PStringArray::operator+
PStringArray operator+(const PStringArray &array)
Create a new PStringArray, and add PString or PStringArray to it a new PStringArray.
PStringOptions::Contains
bool Contains(const PCaselessString &key) const
Definition: pstring.h:2855
PRegularExpression::UnmatchedRParen
Unmatched ) or \); not returned from regcomp.
Definition: pstring.h:3077
PList
This template class maps the PAbstractList to a specific object type.
Definition: lists.h:321
PString::InternalFromUCS2
void InternalFromUCS2(const wchar_t *ptr, PINDEX len)
PString::IsEmpty
virtual PBoolean IsEmpty() const
Determine if the string is empty.
PStringDictionary::RemoveAt
virtual PString * RemoveAt(const K &key)
Remove an object at the specified key.
Definition: pstring.h:2549
PRegularExpression::BadRepitition
No preceding re for repetition op.
Definition: pstring.h:3069
POrdinalToString::ReadFrom
virtual void ReadFrom(istream &strm)
Input the contents of the object from the stream.
PString::Tokenise
PStringArray Tokenise(const PString &separators, PBoolean onePerSeparator=true) const
Split the string into an array of substrings.
PStringList::InsertString
PINDEX InsertString(const PString &before, const PString &str)
Insert a string into the list.
PStringDictionary::GetAt
virtual PString * GetAt(const K &key) const
Get the object at the specified key position.
Definition: pstring.h:2562
PString::FindSpan
PINDEX FindSpan(const PString &set, PINDEX offset=0) const
Locate the position of character not in the set.
PStringOptions::PStringOptions
PStringOptions(const PStringToString &other)
Definition: pstring.h:2849
PBoolean
BOOL PBoolean
Definition: object.h:102
PString::Compare
virtual Comparison Compare(const PObject &obj) const
Get the relative rank of the two strings.
PString::AsUCS2
PWCharArray AsUCS2() const
Convert UTF-8 string to UCS-2.
PAbstractDictionary::AbstractSetAt
virtual PBoolean AbstractSetAt(const PObject &key, PObject *obj)
Add a new object to the collection.
PStringToOrdinal::ReadFrom
virtual void ReadFrom(istream &strm)
Input the contents of the object from the stream.
PStringOptions::Get
__inline PString Get(const PCaselessString &key, const char *dflt=NULL) const
Definition: pstring.h:2933
PString::operator+=
PString & operator+=(const PString &str)
Concatenate a string to another string, modifiying that string.
PString::operator()
PString operator()(PINDEX start, PINDEX end) const
Extract a portion of the string into a new string.
PString::Find
PINDEX Find(char ch, PINDEX offset=0) const
Locate the position within the string of the character.
PStringOptions::Contains
bool Contains(const PString &key) const
Definition: pstring.h:2854
PStringList::operator+=
PStringList & operator+=(const PStringList &list)
Concatenate a PString or PStringArray to the list.
PStringToOrdinal
This is a dictionary collection class of ordinals keyed by PString objects.
Definition: pstring.h:2733
PString::MakeMinimumSize
PBoolean MakeMinimumSize()
Set the actual memory block array size to the minimum required to hold the current string contents...
PBYTEArray
Array of unsigned characters.
Definition: array.h:670
PRegularExpression::NoError
Success.
Definition: pstring.h:3041
PSortedStringList::GetNextStringsIndex
PINDEX GetNextStringsIndex(const PString &str) const
Get the index of the next string after specified value.
PStringOptions::Remove
__inline void Remove(const PString &key)
Definition: pstring.h:2948
PString::ConversionType
ConversionType
Definition: pstring.h:281
PStringDictionary::SetDataAt
virtual PBoolean SetDataAt(PINDEX index, const PString &str)
Set the data at the specified ordinal index position in the dictionary.
Definition: pstring.h:2574
PStringOptions
Specialised version of PStringToString to contain a dictionary of options/attributes.
Definition: pstring.h:2845
PStringOptions::GetInteger
long GetInteger(const PString &key, long dflt=0) const
Definition: pstring.h:2902
PStringToString::PStringToString
PStringToString(PINDEX count, const Initialiser *init, PBoolean caselessKeys=false, PBoolean caselessValues=false)
Initialise the string dictionary of strings from the static array.
PStringDictionary::GetDataAt
PString & GetDataAt(PINDEX index) const
Get the data in the dictionary at the ordinal index position.
Definition: pstring.h:2620
PSortedStringList
This is a sorted list collection class of PString objects.
Definition: pstring.h:2296
PStringToOrdinal::PStringToOrdinal
PStringToOrdinal(PINDEX count, const Initialiser *init, PBoolean caseless=false)
Initialise the string dictionary of ordinals from the static array.
PRegularExpression::IgnoreCase
Ignore case in search.
Definition: pstring.h:2971
PStringOptions::SetBoolean
void SetBoolean(const char *key, bool value)
Set the option value as a boolean.
Definition: pstring.h:2895
PStringDictionary::GetKeyAt
const K & GetKeyAt(PINDEX index) const
Get the key in the dictionary at the ordinal index position.
Definition: pstring.h:2606
PConstantString
Create a constant string.
Definition: pstring.h:1834
PAbstractDictionary::AbstractGetAt
virtual PObject * AbstractGetAt(const PObject &key) const
Get the object at the specified key position.
PString::Signed
Definition: pstring.h:285
PStringOptions::GetAt
PString * GetAt(const char *key) const
Definition: pstring.h:2859
PAbstractArray::theArray
char * theArray
Pointer to the allocated block of memory.
Definition: array.h:245
PString::Printf
Definition: pstring.h:289
PStringArray::PStringArray
PStringArray(PINDEX count, char const *const *strarr, PBoolean caseless=false)
Create a PStringArray from the array of C strings.
PStringOptions::Set
__inline bool Set(const char *key, const PString &value)
Set the option value.
Definition: pstring.h:2941
PStringToString::Initialiser::value
const char * value
String value for string.
Definition: pstring.h:2795
PStringDictionary::operator[]
const PString & operator[](const K &key) const
Get the string contained in the dictionary at the key position.
Definition: pstring.h:2504
PRegularExpression::NotEndofLine
Like NotBeginningOfLine, except for the end-of-line.
Definition: pstring.h:2988
PString::MakeUnique
virtual PBoolean MakeUnique()
Make this instance to be the one and only reference to the container contents.
PAbstractDictionary::SetDataAt
virtual PBoolean SetDataAt(PINDEX index, PObject *obj)
Set the data at the specified ordinal index position in the dictionary.
PCaselessString::PCaselessString
PCaselessString(PContainerReference &reference)
Definition: pstring.h:1814
PStringArray::PStringArray
PStringArray(const std::vector< PString > &vec)
Create a PStringArray from a vector of PStrings.
Definition: pstring.h:2058
PStringDictionary::PStringDictionary
PStringDictionary()
Create a new, empty, dictionary.
Definition: pstring.h:2476
PString::Trim
PString Trim() const
Create a string consisting of all characters from the source string except all spaces at the beginnin...
PString::Pascal
Definition: pstring.h:282
PString::NumCompare
Comparison NumCompare(const PString &str, PINDEX count=P_MAX_INDEX, PINDEX offset=0) const
Compare a string against a substring of the object.
PStringToString::Initialiser
Structure for static array initialiser for class.
Definition: pstring.h:2791
PString::Splice
void Splice(const PString &str, PINDEX pos, PINDEX len=0)
Splice the string into the current string at the specified position.
PRegularExpression::RangeError
Invalid range end.
Definition: pstring.h:3065
PStringOptions::Get
__inline PString Get(const PCaselessString &(*key)(), const char *dflt=NULL) const
Definition: pstring.h:2934
PString::AsUnsigned
DWORD AsUnsigned(unsigned base=10) const
Convert the string to an integer value using the specified number base.
PStringOptions::GetString
PString GetString(const PCaselessString &(*key)(), const char *dflt=NULL) const
Definition: pstring.h:2880
PString::operator==
bool operator==(const PObject &str) const
Compare two strings using the PObject::Compare() function.
PStringList::PStringList
PStringList(PINDEX count, char const *const *strarr, PBoolean caseless=false)
Create a PStringList from the array of C strings.
PStringSet::Exclude
void Exclude(const PString &key)
Exclude the spcified string value from the set.
PString::Delete
void Delete(PINDEX start, PINDEX len)
Remove the substring from the string.
PSet
This template class maps the PAbstractSet to a specific object type.
Definition: dict.h:455
PString::Clone
virtual PObject * Clone() const
Make a complete duplicate of the string.
PStringDictionary::operator()
PString operator()(const K &key, const char *dflt=NULL) const
Get the string contained in the dictionary at the key position.
Definition: pstring.h:2520
PString::operator=
PString & operator=(const std::string &str)
Assign the string to the current object.
Definition: pstring.h:332
PStringList::AppendString
PINDEX AppendString(const PString &str)
Append a string to the list.
PSortedStringList::GetStringsIndex
PINDEX GetStringsIndex(const PString &str) const
Get the index of the string with the specified value.
PContainerReference
Definition: contain.h:51
PStringOptions::GetAt
PString * GetAt(const PString &key) const
Definition: pstring.h:2860
PStringOptions::Set
__inline bool Set(const PString &key, const PString &value)
Definition: pstring.h:2942
PString
The character string class.
Definition: pstring.h:108
PStringOptions::SetString
bool SetString(const char *key, const PString &value)
Set the option value.
Definition: pstring.h:2883
PStringSet
This is a set collection class of PString objects.
Definition: pstring.h:2391
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 cons...
PString::operator&
PString operator&(const PString &str) const
Concatenate two strings to produce a third.
PRegularExpression::UnmatchedBracket
Unmatched left bracket.
Definition: pstring.h:3057
PString::Initialiser
const char * Initialiser
Definition: pstring.h:115
PString::Empty
static PString Empty()
Return an empty string.
PStringToOrdinal::Initialiser::key
const char * key
String key for ordinal.
Definition: pstring.h:2742
PConstantString::DestroyReference
virtual void DestroyReference()
Definition: pstring.h:1849
PContainerReference::deleteObjects
bool deleteObjects
Definition: contain.h:72
PStringOptions::RemoveAt
PString * RemoveAt(const PCaselessString &key)
Definition: pstring.h:2873
PStringDictionary::SetAt
virtual PBoolean SetAt(const K &key, const PString &str)
Add a new object to the collection.
Definition: pstring.h:2590
PRegularExpression::BadPattern
Invalid pattern.
Definition: pstring.h:3047
PCaselessString::operator=
PCaselessString & operator=(const std::string &str)
Assign the string to the current object.
Definition: pstring.h:1758
PStringDictionary::PStringDictionary
PStringDictionary(int dummy, const PStringDictionary *c)
Definition: pstring.h:2625
PStringStream::MakeEmpty
virtual PString & MakeEmpty()
Make the current string empty.
PStringOptions::GetBoolean
bool GetBoolean(const PCaselessString &(*key)(), bool dflt=false) const
Definition: pstring.h:2892
PStringOptions::Get
__inline PString Get(const PString &key, const char *dflt=NULL) const
Definition: pstring.h:2932
PStringOptions::SetBoolean
void SetBoolean(const PCaselessString &key, bool value)
Definition: pstring.h:2897
PContainer
Abstract class to embody the base functionality of a container.
Definition: contain.h:104
PStringList
This is a list collection class of PString objects.
Definition: pstring.h:2184
PString::Unsigned
Definition: pstring.h:286
PStringOptions::GetString
PString GetString(const PString &key, const char *dflt=NULL) const
Definition: pstring.h:2878
PStringOptions::Has
__inline bool Has(const PCaselessString &key) const
Definition: pstring.h:2927
PString::FindOneOf
PINDEX FindOneOf(const PString &set, PINDEX offset=0) const
Locate the position of one of the characters in the set.
PString::operator<
bool operator<(const PObject &str) const
Compare two strings using the PObject::Compare() function.
PString::Exponent
Definition: pstring.h:288
PStringSet::operator-=
PStringSet & operator-=(const PString &key)
Exclude the spcified string value from the set.
PStringArray::ReadFrom
virtual void ReadFrom(istream &strm)
Input the contents of the object from the stream.
PStringOptions::SetReal
void SetReal(const PCaselessString &(*key)(), double value, int decimals)
Definition: pstring.h:2922
PString::ToUpper
PString ToUpper() const
Create a string consisting of all characters from the source string with all lower case letters conve...
PStringOptions::Get
__inline PString Get(const char *key, const PString &dflt) const
Definition: pstring.h:2935
PBASEARRAY
PBASEARRAY(PWCharArray, wchar_t)
PString::operator>=
bool operator>=(const PObject &str) const
Compare two strings using the PObject::Compare() function.
PStringOptions::Get
__inline PString Get(const PString &key, const PString &dflt) const
Definition: pstring.h:2936
PRegularExpression::GetErrorText
PString GetErrorText() const
Get the text description for the error of the last Compile() or Execute() operation.
PStringStream::operator=
PStringStream & operator=(const PStringStream &strm)
Assign the string part of the stream to the current object.
PSortedList
This template class maps the PAbstractSortedList to a specific object type.
Definition: lists.h:954
PStringOptions::SetBoolean
void SetBoolean(const PString &key, bool value)
Definition: pstring.h:2896
PStringOptions::SetString
bool SetString(const PCaselessString &(*key)(), const PString &value)
Definition: pstring.h:2886
PSortedStringList::ReadFrom
virtual void ReadFrom(istream &strm)
Input the contents of the object from the stream.
PStringOptions::SetReal
void SetReal(const char *key, double value, int decimals)
Set a floating point real value for the particular MIME info field.
Definition: pstring.h:2919
PInvalidParameter
Invalid parameter was passed to a function.
Definition: object.h:159
PConstantString::~PConstantString
~PConstantString()
Definition: pstring.h:1845
PRegularExpression::NoMatch
Didn't find a match (for regexec).
Definition: pstring.h:3043
PAbstractDictionary::GetRefAt
virtual PObject & GetRefAt(const PObject &key) const
Get the object at the specified key position.
PConstantString::PConstantString
PConstantString(typename ParentString::Initialiser init)
Definition: pstring.h:1839
PRegularExpression::UnmatchedParen
Parenthesis imbalance.
Definition: pstring.h:3059
PStringOptions::GetString
PString GetString(const char *key, const char *dflt=NULL) const
Get an option value.
Definition: pstring.h:2877
PHashTable::AbstractGetKeyAt
virtual const PObject & AbstractGetKeyAt(PINDEX index) const
Get the key in the hash table at the ordinal index position.
POrdinalToString
This is a dictionary collection class of PString objects, keyed by an ordinal value.
Definition: pstring.h:2686
PStringDictionary::Contains
PBoolean Contains(const K &key) const
Determine if the value of the object is contained in the hash table.
Definition: pstring.h:2534
PStringArray::container
static PStringArray container(const stlContainer &vec)
Create a PStringArray from an STL container.
Definition: pstring.h:2081
PString::LeftTrim
PString LeftTrim() const
Create a string consisting of all characters from the source string except all spaces at the beginnin...
PStringOptions::SetInteger
void SetInteger(const PCaselessString &(*key)(), long value)
Definition: pstring.h:2910
PStringList::operator+
PStringList operator+(const PStringList &array)
Create a new PStringList, and add PString or PStringList to it a new PStringList. ...
PArray
This template class maps the PArrayObjects to a specific object type.
Definition: array.h:1024
PStringSet::operator+=
PStringSet & operator+=(const PString &key)
Include the spcified string value into the set.
PConstCaselessString
PConstantString< PCaselessString > PConstCaselessString
Constant PCaselessString type. See PConstantString.
Definition: pstring.h:1864
PRegularExpression
A class representing a regular expression that may be used for locating patterns in strings...
Definition: pstring.h:2959
PString::FindRegEx
PINDEX FindRegEx(const PRegularExpression &regex, PINDEX offset=0) const
Locate the position within the string of one of the regular expression.
PConstantString::AssignContents
virtual void AssignContents(const PContainer &)
Definition: pstring.h:1848
PStringArray::PStringArray
PStringArray(const std::vector< std::string > &vec)
Create a PStringArray from a vector of std::string.
Definition: pstring.h:2069
PStringOptions::Contains
bool Contains(const char *key) const
Determine if the specified key is present.
Definition: pstring.h:2853
PString::Basic
Definition: pstring.h:283
PStringOptions::SetString
bool SetString(const PString &key, const PString &value)
Definition: pstring.h:2884
PString::Lines
PStringArray Lines() const
Split the string into individual lines.
PStringOptions::SetInteger
void SetInteger(const char *key, long value)
Set an integer value for the particular MIME info field.
Definition: pstring.h:2907
PStringOptions::Get
__inline PString Get(const PCaselessString &key, const PString &dflt) const
Definition: pstring.h:2937
PStringOptions::SetString
bool SetString(const PCaselessString &key, const PString &value)
Definition: pstring.h:2885
PString::AsUnsigned64
PUInt64 AsUnsigned64(unsigned base=10) const
Convert the string to an integer value using the specified number base.
PString::AsReal
double AsReal() const
Convert the string to a floating point number.
PStringOptions::RemoveAt
PString * RemoveAt(const PCaselessString &(*key)())
Definition: pstring.h:2874
PStringOptions::Remove
__inline void Remove(const PCaselessString &(*key)())
Definition: pstring.h:2950
PStringOptions::Get
__inline PString Get(const char *key, const char *dflt=NULL) const
Get the option value.
Definition: pstring.h:2931
PRegularExpression::NotCompiled
Miscellaneous error.
Definition: pstring.h:3079
PStringArray::GetStringsIndex
PINDEX GetStringsIndex(const PString &str) const
As for GetValuesIndex() but takes a PString argument so that literals will be automatically converted...
PString::operator+
PString operator+(const PString &str) const
Concatenate two strings to produce a third.
PStringDictionary::Clone
virtual PObject * Clone() const
Make a complete duplicate of the dictionary.
Definition: pstring.h:2486
PString::operator!
bool operator!() const
Determine if the string is NOT empty.
PStringOptions::Has
__inline bool Has(const char *key) const
Determine of the option exists.
Definition: pstring.h:2925
PString::SetSize
virtual PBoolean SetSize(PINDEX newSize)
Set the size of the string.
PRegularExpression::lastError
ErrorCodes lastError
Definition: pstring.h:3229
PString::operator>
bool operator>(const PObject &str) const
Compare two strings using the PObject::Compare() function.
PString::vsprintf
PString & vsprintf(const PString &fmt, va_list args)
Concatenate a formatted output to the string.
PRegularExpression::UnmatchedBrace
Unmatched \.
Definition: pstring.h:3061
PRegularExpression::BadBR
Invalid contents of \.
Definition: pstring.h:3063
PString::FindLast
PINDEX FindLast(char ch, PINDEX offset=P_MAX_INDEX) const
Locate the position of the last matching character.
PString::Mid
PString Mid(PINDEX start, PINDEX len=P_MAX_INDEX) const
Extract a portion of the string into a new string.
PContainer::reference
PContainerReference * reference
Definition: contain.h:291
PIntArray
Array of integers.
Definition: array.h:616
PStringOptions::Get
__inline PString Get(const PCaselessString &(*key)(), const PString &dflt) const
Definition: pstring.h:2938
PHashTable::AbstractGetDataAt
virtual PObject & AbstractGetDataAt(PINDEX index) const
Get the data in the hash table at the ordinal index position.
PStringOptions::GetReal
double GetReal(const char *key, double dflt=0) const
Get the option value as a floating point real.
Definition: pstring.h:2913
psprintf
PString psprintf(const char *fmt,...)
The same as the standard C snprintf(fmt, 1000, ...), but returns a PString instead of a const char *...
POrdinalDictionary
This template class maps the PAbstractDictionary to a specific key type and a POrdinalKey data type...
Definition: dict.h:1039
PRegularExpression::Execute
PBoolean Execute(const PString &str, PINDEX &start, int flags=0) const
Execute regular expression.
PString::MatchesRegEx
PBoolean MatchesRegEx(const PRegularExpression &regex) const
Return true if the entire string matches the regular expression.
PObject
Ultimate parent class for all objects in the class library.
Definition: object.h:1118
PSortedStringList::PSortedStringList
PSortedStringList(PINDEX count, char const *const *strarr, PBoolean caseless=false)
Create a PStringArray from the array of C strings.
PRegularExpression::PrintOn
virtual void PrintOn(ostream &strm) const
Output the regular expression to the specified stream.
PStringStream::PStringStream
PStringStream()
Create a new, empty, string stream.
PRegularExpression::TooBig
Compiled pattern bigger than 2^16 bytes.
Definition: pstring.h:3075
PStringOptions::SetInteger
void SetInteger(const PString &key, long value)
Definition: pstring.h:2908
PString::Left
PString Left(PINDEX len) const
Extract a portion of the string into a new string.
PNEW
#define PNEW
Macro for overriding system default new operator.
Definition: object.h:890
PString::psprintf
friend PString psprintf(const char *cfmt,...)
Produce formatted output as a string.
PCaselessString::PCaselessString
PCaselessString(const std::string &str)
Create a caseless string from a std::string.
Definition: pstring.h:1735
POrdinalToString::Initialiser
Structure for static array initialiser for class.
Definition: pstring.h:2693
POrdinalKey
This class is used when an ordinal index value is the key for PSet and PDictionary classes...
Definition: dict.h:50
PRegularExpression::OutOfMemory
Ran out of memory.
Definition: pstring.h:3067
PRegularExpression::NotBeginningOfLine
If this bit is set, then the beginning-of-line operator doesn't match the beginning of the string (pr...
Definition: pstring.h:2986
PStringOptions::GetReal
double GetReal(const PString &key, double dflt=0) const
Definition: pstring.h:2914
PString::ToLower
PString ToLower() const
Create a string consisting of all characters from the source string with all upper case letters conve...
PStringOptions::GetInteger
long GetInteger(const char *key, long dflt=0) const
Get the option value as an integer.
Definition: pstring.h:2901