33 #ifndef PTLIB_STRING_H
34 #define PTLIB_STRING_H
146 const std::string & str
195 const wchar_t * ustr,
210 const PWCharArray & ustr
212 #endif // P_HAS_WCHAR
271 #ifdef HAVE_LONG_LONG_INT
281 #ifdef HAVE_UNSIGNED_LONG_LONG_INT
316 #ifdef HAVE_LONG_LONG_INT
326 #ifdef HAVE_UNSIGNED_LONG_LONG_INT
367 const std::string & str
443 #ifdef HAVE_LONG_LONG_INT
453 #ifdef HAVE_UNSIGNED_LONG_LONG_INT
1529 SplitDefaultToBefore,
1530 SplitDefaultToAfter,
1531 SplitBeforeNonEmpty,
1534 SplitTrim = SplitTrimBefore|SplitTrimAfter,
1535 SplitNonEmpty = SplitBeforeNonEmpty|SplitAfterNonEmpty
1551 SplitOptions options = SplitTrim
1553 {
return InternalSplit(delimiter, before, after, options); }
1595 const char * cseparators,
1709 template <
typename T> __inline T
As(T t = T())
const;
1796 PWCharArray AsWide()
const;
1798 P_DEPRECATED PWCharArray AsUCS2()
const {
return AsWide(); }
1841 operator const unsigned char *()
const;
1845 operator std::string ()
const
1877 virtual const char *
GetPointer(PINDEX = 0)
const {
return (
const char *)(*this); }
1882 __inline std::string::size_type
size()
const {
return (std::string::size_type)
GetLength(); }
1883 __inline std::string::size_type
length()
const {
return (std::string::size_type)
GetLength(); }
1884 __inline std::string::size_type
capacity()
const {
return (std::string::size_type)(
GetSize()-1); }
1890 __inline
PString &
append(std::string::size_type count,
char ch) {
while (--count > 0) *
this += ch;
return *
this; }
1893 __inline
PString &
insert(std::string::size_type index, std::string::size_type count,
char ch) {
while (--count > 0)
Splice(&ch, index);
return *
this; }
1895 __inline
PString &
insert(std::string::size_type index,
const std::string & s) {
return Splice(s.c_str(), index); }
1896 __inline
PString &
erase(std::string::size_type index = 0, std::string::size_type count = std::string::npos) {
return Delete(index, count != std::string::npos ? count :
P_MAX_INDEX); }
1897 __inline
PString &
replace(std::string::size_type pos, std::string::size_type count,
const char * s) {
return Splice(s, pos, count); }
1898 __inline
PString &
replace(std::string::size_type pos, std::string::size_type count,
const std::string & s) {
return Splice(s.c_str(), pos, count); }
1899 __inline std::string
substr(std::string::size_type pos = 0, std::string::size_type count = std::string::npos)
const {
return std::string(
Mid(pos, count).
GetPointer()); }
1900 __inline std::string::size_type
find(
char c, std::string::size_type pos = 0)
const {
return StdStringPos(
Find(c, pos)); }
1901 __inline std::string::size_type
find(
const char * s, std::string::size_type pos = 0)
const {
return StdStringPos(
Find(s, pos)); }
1902 __inline std::string::size_type
find(
const std::string & s, std::string::size_type pos = 0)
const {
return StdStringPos(
Find(s.c_str(), pos)); }
1903 __inline std::string::size_type
rfind(
char c, std::string::size_type pos = 0)
const {
return StdStringPos(
FindLast(c, pos)); }
1904 __inline std::string::size_type
rfind(
const char * s, std::string::size_type pos = 0)
const {
return StdStringPos(
FindLast(s, pos)); }
1905 __inline std::string::size_type
rfind(
const std::string & s, std::string::size_type pos = 0)
const {
return StdStringPos(
FindLast(s.c_str(), pos)); }
1906 __inline std::string::size_type
find_first_of(
const char * s, std::string::size_type pos = 0)
const {
return StdStringPos(
FindOneOf(s, pos)); }
1907 __inline std::string::size_type
find_first_of(
const std::string & s, std::string::size_type pos = 0)
const {
return StdStringPos(
FindOneOf(s.c_str(), pos)); }
1908 __inline std::string::size_type
find_first_not_of(
const char * s, std::string::size_type pos = 0)
const {
return StdStringPos(
FindSpan(s, pos)); }
1909 __inline std::string::size_type
find_first_not_of(
const std::string & s, std::string::size_type pos = 0)
const {
return StdStringPos(
FindSpan(s.c_str(), pos)); }
1911 __inline
static std::string::size_type StdStringPos(PINDEX p) {
return p !=
P_MAX_INDEX ? (std::string::size_type)p : std::string::npos; }
1917 void InternalFromWChar(
1918 const wchar_t * ptr,
1928 virtual int internal_strncmp(
const char * s1,
const char *s2,
size_t n)
const;
1934 SplitOptions_Bits options
1958 string.PrintOn(stream);
1962 #ifdef P_HAS_WOSTREAM
1965 return stream << (
const char *)
string;
1971 class PWideString :
public PWCharArray {
1975 typedef const wchar_t * Initialiser;
1978 PWideString(
const PWCharArray & arr) : PWCharArray(arr) { }
1979 PWideString(
const PString & str) : PWCharArray(str.AsWide()) { }
1980 PWideString(
const char * str);
1981 PWideString & operator=(
const PWideString & str) { PWCharArray::operator=(str);
return *
this; }
1982 PWideString & operator=(
const PString & str) { PWCharArray::operator=(str.AsWide());
return *
this; }
1983 PWideString & operator=(
const std::string & str);
1984 PWideString & operator=(
const char * str);
1985 friend inline ostream &
operator<<(ostream & stream,
const PWideString &
string) {
return stream <<
PString(
string); }
1987 PINDEX GetLength()
const {
return GetSize() - 1; }
1994 typedef PWideString PVarString;
2040 const std::string & str
2063 const std::string & str
2102 virtual int internal_strncmp(
const char * s1,
const char *s2,
size_t n)
const;
2131 template <
class ParentString>
2138 : ParentString(m_staticReference, init != NULL ? strlen(init) : 0)
2141 this->theArray = (
char *)(init != NULL ? init :
"");
2145 : ParentString(m_staticReference, other.m_length)
2146 , m_staticReference(other.m_length + 1, true)
2148 this->theArray = other.theArray;
2174 __inline PWideString::PWideString(
const char * str) : PWCharArray(PConstString(str).AsWide()) { }
2175 __inline PWideString & PWideString::operator=(
const std::string & str) { PWCharArray::operator=(
PConstString(str.c_str()).AsWide());
return *
this; }
2176 __inline PWideString & PWideString::operator=(
const char * str) { PWCharArray::operator=(
PConstString(str).AsWide());
return *
this; }
2205 PINDEX fixedBufferSize
2295 __inline
void clear() { std::iostream::clear(); }
2304 : std::iostream(cout.rdbuf())
2308 class Buffer :
public streambuf {
2311 Buffer(
const Buffer & sbuf);
2312 Buffer &
operator=(
const Buffer & sbuf);
2313 virtual int_type overflow(int_type = EOF);
2314 virtual int_type underflow();
2316 virtual pos_type seekoff(std::streamoff, ios_base::seekdir, ios_base::openmode = ios_base::in | ios_base::out);
2317 virtual pos_type seekpos(pos_type, ios_base::openmode = ios_base::in | ios_base::out);
2337 #define PSTRSTRM(arg) PSTRSTRM_support(PStringStream() << std::flush << arg << std::flush)
2381 : BaseClass(initialSize) { }
2392 char const *
const * strarr,
2425 const std::vector<PString> & vec
2428 for (std::vector<PString>::const_iterator r = vec.begin(); r != vec.end(); ++r)
2436 const std::vector<std::string> & vec
2439 for (std::vector<std::string>::const_iterator r = vec.begin(); r != vec.end(); ++r)
2446 template <
typename stlContainer>
2448 const stlContainer & vec
2452 for (
typename stlContainer::const_iterator r = vec.begin(); r != vec.end(); ++r)
2544 char separator =
' '
2586 char const *
const * strarr,
2678 template <
typename stlContainer>
2680 const stlContainer & vec
2684 for (
typename stlContainer::const_iterator r = vec.begin(); r != vec.end(); ++r)
2727 char const *
const * strarr,
2845 char const *
const * strarr,
2964 return str != NULL ? *str :
PString(dflt);
3004 #define PDECLARE_STRING_DICTIONARY(cls, K) \
3005 PDECLARE_CLASS(cls, PStringDictionary<K>) \
3007 cls(int dummy, const cls * c) \
3008 : PStringDictionary<K>(dummy, c) { } \
3011 : PStringDictionary<K>() { } \
3012 virtual PObject * Clone() const \
3013 { return PNEW cls(0, this); } \
3028 #define PSTRING_DICTIONARY(cls, K) typedef PStringDictionary<K> cls
3045 #ifdef DOC_PLUS_PLUS
3092 #ifdef DOC_PLUS_PLUS
3150 #ifdef DOC_PLUS_PLUS
3300 bool GetBoolean(
const char * key,
bool dflt =
false)
const { PConstCaselessString k(key);
return GetBoolean(k, dflt); }
3314 long GetInteger(
const char * key,
long dflt = 0)
const { PConstCaselessString k(key);
return GetInteger(k, dflt); }
3328 template<
typename E> E
GetEnum(
const char * key, E dflt)
const { PConstCaselessString k(key);
return GetEnum(k, dflt); }
3335 template<
typename E>
void SetEnum(
const char * key, E value) { PConstCaselessString k(key);
SetInteger(k, value); }
3342 double GetReal(
const char * key,
double dflt = 0)
const { PConstCaselessString k(key);
return GetReal(k, dflt); }
3349 void SetReal(
const char * key,
double value,
int decimals) { PConstCaselessString k(key);
SetReal(k, value, decimals); }
3356 template<
typename T> T
GetVar(
const char * key,
const T & dflt)
const { PConstCaselessString k(key);
return GetVar<T>(k, dflt); }
3357 template<
typename T> T
GetVar(
const std::string & key,
const T & dflt)
const {
return GetVar<T>(
PCaselessString(key), dflt); }
3360 template<
typename T> T
GetVar(
const PCaselessString & (*key)(),
const T & dflt)
const {
return GetVar<T>(key(), dflt); }
3362 template<
typename T>
bool SetVar(
const char * key,
const T & value) { PConstCaselessString k(key);
return SetVar<T>(k, value); }
3363 template<
typename T>
bool SetVar(
const std::string & key,
const T & value) {
return SetVar<T>(
PCaselessString(key), value); }
3370 __inline
bool Has(
const std::string & key)
const {
return Contains(key); }
3378 __inline
PString Get(
const std::string & key,
const char * dflt = NULL)
const {
return GetString(key, dflt); }
3381 __inline
PString Get(
const char * key,
const std::string & dflt)
const {
return GetString(key, dflt.c_str()); }
3382 __inline
PString Get(
const std::string & key,
const std::string & dflt)
const {
return GetString(key, dflt.c_str()); }
3394 __inline
bool Set(
const std::string & key,
const PString & value) {
return SetAt(key, value); }
3454 CompileOptions options = IgnoreCase
3460 const char * cpattern,
3461 CompileOptions options = IgnoreCase
3562 CompileOptions options = IgnoreCase
3572 const char * cpattern,
3573 CompileOptions options = IgnoreCase
3581 ExecOptions options = Normal
3588 ExecOptions options = Normal
3594 ExecOptions options = Normal
3601 ExecOptions options = Normal
3607 ExecOptions options = Normal
3614 ExecOptions options = Normal
3620 ExecOptions options = Normal
3642 ExecOptions options = Normal
3663 ExecOptions options = Normal
3690 #endif // PTLIB_STRING_H
const char * value
String value for ordinal.
Definition: pstring.h:3057
__inline std::string::size_type find_first_of(const char *s, std::string::size_type pos=0) const
Definition: pstring.h:1906
__inline PString & append(std::string::size_type count, char ch)
Definition: pstring.h:1890
void SetReal(const std::string &key, double value, int decimals)
Definition: pstring.h:3350
__inline std::ostream & operator<<(std::ostream &strm, const PHashTableList &hash)
Definition: dict.h:180
void SetReal(const PString &key, double value, int decimals)
Definition: pstring.h:3351
bool Compile(const PString &pattern, CompileOptions options=IgnoreCase)
Compiler pattern.
T GetVar(const PCaselessString &key, const T &dflt) const
Definition: pstring.h:3359
PString * GetAt(const PCaselessString &key) const
Definition: pstring.h:3268
void SetEnum(const PCaselessString &key, E value)
Definition: pstring.h:3338
PString * RemoveAt(const PString &key)
Definition: pstring.h:3281
char ** ToCharArray(bool withEqualSign, PCharArray *storage=NULL) const
Create an array of C strings.
#define P_DISABLE_MSVC_WARNINGS(warnings, statement)
Definition: object.h:156
__inline std::string::size_type find(char c, std::string::size_type pos=0) const
Definition: pstring.h:1900
virtual PBoolean MakeUnique()
Make this instance to be the one and only reference to the container contents.
__inline void Remove(const char *key)
Remove option value.
Definition: pstring.h:3400
__inline char * data()
Definition: pstring.h:1888
PString ToString(char separator= ' ') const
Create a PString concatenation of all array memebers.
E GetEnum(const std::string &key, E dflt) const
Definition: pstring.h:3329
virtual ~PStringStream()
Destroy the string stream, deleting the stream buffer.
void SetBoolean(const PCaselessString &(*key)(), bool value)
Definition: pstring.h:3311
bool Contains(const std::string &key) const
Definition: pstring.h:3259
PRegularExpression()
Create a new, empty, regular expression.
Trailing backslash.
Definition: pstring.h:3509
Not implemented.
Definition: pstring.h:3505
ErrorCodes GetErrorCode() const
Get the error code for the last Compile() or Execute() operation.
friend PString pvsprintf(const char *cfmt, va_list args)
Produce formatted output as a string.
bool GetBoolean(const char *key, bool dflt=false) const
Get the option value as a boolean.
Definition: pstring.h:3300
PString & operator&=(const PString &str)
Concatenate a PString to a PString, modifiying that string.
PBoolean SetAt(const std::string &key, const PString &data)
Definition: pstring.h:3273
PString & operator=(const PString &str)
Assign the string to the current object.
E GetEnum(const PCaselessString &(*key)(), E dflt) const
Definition: pstring.h:3332
bool InternalCompile(bool assertOnFail)
PRegularExpression & operator=(const PRegularExpression &)
Assign a regular expression.
bool operator*=(const PString &str) const
Compare two strings using case insensitive comparison.
virtual void PrintOn(ostream &strm) const
Output the string to the specified stream.
const PString & GetPattern() const
Return the string which represents the pattern matched by the regular expression. ...
Definition: pstring.h:3554
__inline std::string::size_type find(const std::string &s, std::string::size_type pos=0) const
Definition: pstring.h:1902
__inline std::string::size_type size() const
Definition: pstring.h:1882
virtual void ReadFrom(istream &strm)
Input the contents of the object from the stream.
Array of characters.
Definition: array.h:552
This template class maps the PAbstractDictionary to a specific key type and a PString data type...
Definition: pstring.h:2918
PINDEX value
Ordinal value for string.
Definition: pstring.h:3104
Invalid character class name.
Definition: pstring.h:3507
bool operator!=(const PString &str) const
Compare two strings using the PObject::Compare() function.
PCaselessString(PContainerReference &reference_, PINDEX len)
Definition: pstring.h:2112
__inline const char * c_str() const
Definition: pstring.h:1887
#define PCLASSINFO(cls, par)
Declare all the standard PTLib class information.
Definition: object.h:2164
PINDEX AppendString(const PString &str)
Add a string to the list.
int64_t AsInteger64(unsigned base=0) const
Convert the string to an integer value using the specified number base.
PStringArray & operator+=(const PStringArray &array)
Concatenate a PString or PStringArray to the array.
PString & Delete(PINDEX start, PINDEX len)
Remove the substring from the string.
PBoolean SetAt(const PCaselessString &key, const PString &data)
Definition: pstring.h:3275
PStringOptions()
Definition: pstring.h:3252
This template class maps the PAbstractArray to a specific element type.
Definition: array.h:276
virtual PINDEX GetLength() const
Determine the length of the null terminated string.
E GetEnum(const char *key, E dflt) const
Get the option value as an enum.
Definition: pstring.h:3328
bool SetString(const std::string &key, const PString &value)
Definition: pstring.h:3294
__inline void Remove(const std::string &key)
Definition: pstring.h:3401
virtual PObject * Clone() const
Make a complete duplicate of the string.
static PStringList container(const stlContainer &vec)
Create a PStringArray from an STL container.
Definition: pstring.h:2679
Append to existing key value, separated by ' '.
Definition: pstring.h:3204
__inline PStringList()
Create an empty PStringList.
Definition: pstring.h:2576
virtual void AssignContents(const PContainer &cont)
Copy the container contents.
__inline bool Set(const PCaselessString &key, const PString &value)
Definition: pstring.h:3396
__inline PString & insert(std::string::size_type index, const char *s)
Definition: pstring.h:1894
#define PAssertAlways(msg)
This macro is used to assert immediately.
Definition: object.h:437
__inline bool Has(const PString &key) const
Definition: pstring.h:3371
long GetInteger(const PCaselessString &(*key)(), long dflt=0) const
Definition: pstring.h:3318
PINDEX key
Ordinal key for string.
Definition: pstring.h:3055
PCaselessString()
Create a new, empty, caseless string.
This template class maps the PAbstractDictionary to a specific key and data types.
Definition: dict.h:978
double GetReal(const std::string &key, double dflt=0) const
Definition: pstring.h:3343
virtual void ReadFrom(istream &strm)
Input the contents of the object from the stream.
POrdinalToString(PINDEX count, const Initialiser *init)
Initialise the ordinal dictionary of strings from the static array.
__inline std::string::size_type capacity() const
Definition: pstring.h:1884
virtual PString & MakeEmpty()
Make the current string empty.
Structure for static array initialiser for class.
Definition: pstring.h:3100
PCaselessString & operator=(const PString &str)
Assign the string to the current object.
__inline PSortedStringList(const BaseClass &other)
Definition: pstring.h:2720
This class is a standard C++ stream class descendent for reading or writing streamed data to or from ...
Definition: pstring.h:2188
Definition: pstring.h:304
__inline std::string::size_type length() const
Definition: pstring.h:1883
ErrorCodes
Error codes.
Definition: pstring.h:3495
PINDEX GetStringsIndex(const PString &str) const
Get the index of the string with the specified value.
T GetVar(const PString &key, const T &dflt) const
Definition: pstring.h:3358
Data is C language style string with \ escape codes.
Definition: pstring.h:297
PString & sprintf(const char *cfmt,...)
Concatenate a formatted output to the string.
PINDEX AppendString(const PString &str)
Append a string to the array.
This is a dictionary collection class of PString objects, keyed by another string.
Definition: pstring.h:3151
virtual Comparison InternalCompare(PINDEX offset, PINDEX length, const char *cstr) const
virtual void ReadFrom(istream &strm)
Input the contents of the object from the stream.
PContainer & operator=(const PContainer &cont)
Assign one container reference to another.
Invalid back reference.
Definition: pstring.h:3511
const char * key
String key for string.
Definition: pstring.h:3160
static PString EscapeString(const PString &str)
Escape all characters in the str parameter that have a special meaning within a regular expression...
Convert a real number to a string in decimal format.
Definition: pstring.h:300
Comparison
Result of the comparison operation performed by the Compare() function.
Definition: object.h:2251
bool Contains(const PCaselessString &(*key)()) const
Definition: pstring.h:3262
Premature end.
Definition: pstring.h:3529
__inline void push_back(char ch)
Definition: pstring.h:1889
PString()
Construct an empty string.
bool operator<=(const PString &str) const
Compare two strings using the PObject::Compare() function.
virtual PObject * Clone() const
Make a complete duplicate of the array.
Definition: pstring.h:2471
__inline PString Get(const std::string &key, const PString &dflt) const
Definition: pstring.h:3387
__inline std::string::size_type rfind(const std::string &s, std::string::size_type pos=0) const
Definition: pstring.h:1905
This class is a variation of a string that ignores case.
Definition: pstring.h:2012
__inline T As(T t=T()) const
Convert the string to any type that can be converted using a stream.
Definition: pstring.h:2341
__inline bool Set(const PCaselessString &(*key)(), const PString &value)
Definition: pstring.h:3397
PConstantString(const PConstantString &other)
Definition: pstring.h:2144
PBYTEArray ToPascal() const
Convert a standard null terminated string to a "pascal" style string.
PString * GetAt(const PCaselessString &(*key)()) const
Definition: pstring.h:3269
virtual PObject * AbstractSetAt(const PObject &key, PObject *obj)
Add a new object to the collection.
__inline bool Split(char delimiter, PString &before, PString &after, SplitOptions_Bits options) const
Definition: pstring.h:1557
__inline PString & append(const std::string &s)
Definition: pstring.h:1892
void Include(const PString &key)
Include the spcified string value into the set.
E GetEnum(const PCaselessString &key, E dflt) const
Definition: pstring.h:3331
PStringOptions & operator=(const PStringToString &other)
Definition: pstring.h:3255
PBoolean SetAt(const PString &key, const PString &data)
Definition: pstring.h:3274
__inline std::string::size_type find_first_not_of(const char *s, std::string::size_type pos=0) const
Definition: pstring.h:1908
PString FromLiteral(PINDEX &offset) const
Parse a C literal string format as for PString::ToLiteral().
PString RightTrim() const
Create a string consisting of all characters from the source string except all spaces at the end of t...
PBoolean SetAt(const PCaselessString &(*key)(), const PString &data)
Definition: pstring.h:3276
void push_back(const PString &str)
Definition: pstring.h:2509
char ** ToCharArray(PCharArray *storage=NULL) const
Create an array of C strings.
double GetReal(const PCaselessString &(*key)(), double dflt=0) const
Definition: pstring.h:3346
PString operator[](PINDEX index) const
virtual void AssignContents(const PContainer &)
Copy the container contents.
PBoolean SetAt(const char *key, const PString &data)
Definition: pstring.h:3272
__inline PSortedStringList()
Create an empty PStringList.
Definition: pstring.h:2717
This is an array collection class of PString objects.
Definition: pstring.h:2365
~PRegularExpression()
Release storage for the compiled regular expression.
__inline void Remove(const PCaselessString &key)
Definition: pstring.h:3403
PConstantString< PString > PConstString
Constant PString type. See PConstantString.
Definition: pstring.h:2166
__inline bool Has(const PCaselessString &(*key)()) const
Definition: pstring.h:3373
PString Right(PINDEX len) const
Extract a portion of the string into a new string.
virtual PINDEX HashFunction() const
Calculate a hash value for use in sets and dictionaries.
PStringSet(int dummy, const PStringSet *c)
Definition: pstring.h:2827
PString ToLiteral() const
Convert the string to C literal string format.
PString * RemoveAt(const char *key)
Definition: pstring.h:3279
bool GetBoolean(const PString &key, bool dflt=false) const
Definition: pstring.h:3302
virtual void ReadFrom(istream &strm)
Input the string from the specified stream.
PStringArray operator+(const PStringArray &array)
Create a new PStringArray, and add PString or PStringArray to it a new PStringArray.
__inline PString & replace(std::string::size_type pos, std::string::size_type count, const char *s)
Definition: pstring.h:1897
Output scaled to SI units, e.g. k, M, G.
Definition: pstring.h:302
bool Contains(const PCaselessString &key) const
Definition: pstring.h:3261
Unmatched ) or \); not returned from regcomp.
Definition: pstring.h:3533
This template class maps the PAbstractList to a specific object type.
Definition: lists.h:322
__inline std::string::size_type find_first_of(const std::string &s, std::string::size_type pos=0) const
Definition: pstring.h:1907
virtual PBoolean IsEmpty() const
Determine if the string is empty.
__inline PString & append(const char *s)
Definition: pstring.h:1891
No preceding re for repetition op.
Definition: pstring.h:3525
bool SetVar(const PCaselessString &key, const T &value)
Definition: pstring.h:3365
virtual void ReadFrom(istream &strm)
Input the contents of the object from the stream.
__inline bool Split(const char *delimiter, PString &before, PString &after, SplitOptions options) const
Definition: pstring.h:1558
PStringArray Tokenise(const PString &separators, PBoolean onePerSeparator=true) const
Split the string into an array of substrings.
PINDEX InsertString(const PString &before, const PString &str)
Insert a string into the list.
T GetVar(const PCaselessString &(*key)(), const T &dflt) const
Definition: pstring.h:3360
PINDEX FindSpan(const PString &set, PINDEX offset=0) const
Locate the position of character not in the set.
PStringOptions(const PStringToString &other)
Definition: pstring.h:3254
PString(PContainerReference &reference_, PINDEX len)
Definition: pstring.h:1946
virtual Comparison Compare(const PObject &obj) const
Get the relative rank of the two strings.
PString & Splice(const PString &str, PINDEX pos, PINDEX len=0)
Splice the string into the current string at the specified position.
virtual int internal_strncmp(const char *s1, const char *s2, size_t n) const
virtual void ReadFrom(istream &strm)
Input the contents of the object from the stream.
__inline PString Get(const PCaselessString &key, const char *dflt=NULL) const
Definition: pstring.h:3379
#define PSTRSTRM(arg)
Output a stream expression to a string parameter.
Definition: pstring.h:2337
PString & operator+=(const PString &str)
Concatenate a string to another string, modifiying that string.
PString operator()(PINDEX start, PINDEX end) const
Extract a portion of the string into a new string.
PINDEX Find(char ch, PINDEX offset=0) const
Locate the position within the string of the character.
bool Contains(const PString &key) const
Definition: pstring.h:3260
PStringList & operator+=(const PStringList &list)
Concatenate a PString or PStringArray to the list.
void * m_compiledRegex
Definition: pstring.h:3686
This is a dictionary collection class of ordinals keyed by PString objects.
Definition: pstring.h:3093
Array of unsigned characters.
Definition: array.h:605
Success.
Definition: pstring.h:3497
PINDEX GetNextStringsIndex(const PString &str) const
Get the index of the next string after specified value.
__inline void Remove(const PString &key)
Definition: pstring.h:3402
virtual PObject * Clone() const
Make a complete duplicate of the list.
Definition: pstring.h:2628
ConversionType
Definition: pstring.h:294
Specialised version of PStringToString to contain a dictionary of options/attributes.
Definition: pstring.h:3249
long GetInteger(const PString &key, long dflt=0) const
Definition: pstring.h:3316
char * GetPointerAndSetLength(PINDEX len)
Get a pointer to the buffer and set the length of the string.
bool SetVar(const char *key, const T &value)
Definition: pstring.h:3362
__inline bool empty() const
Definition: pstring.h:1885
__inline PString PSTRSTRM_support(const ostream &s)
Definition: pstring.h:2324
PStringToString(PINDEX count, const Initialiser *init, PBoolean caselessKeys=false, PBoolean caselessValues=false)
Initialise the string dictionary of strings from the static array.
__inline std::string::size_type rfind(char c, std::string::size_type pos=0) const
Definition: pstring.h:1903
This is a sorted list collection class of PString objects.
Definition: pstring.h:2703
PStringToOrdinal(PINDEX count, const Initialiser *init, PBoolean caseless=false)
Initialise the string dictionary of ordinals from the static array.
void SetBoolean(const char *key, bool value)
Set the option value as a boolean.
Definition: pstring.h:3307
Create a constant string.
Definition: pstring.h:2132
Convert a signed integer to a string.
Definition: pstring.h:298
PString * GetAt(const char *key) const
Definition: pstring.h:3265
MergeAction
Actions to take when doing a PStringToString::Merge()
Definition: pstring.h:3200
virtual PObject * Clone() const
Make a complete duplicate of the set.
Definition: pstring.h:2883
char * theArray
Pointer to the allocated block of memory.
Definition: array.h:247
Formatted output, sprintf() style function.
Definition: pstring.h:303
void SetInteger(const std::string &key, long value)
Definition: pstring.h:3322
__inline bool Set(const char *key, const PString &value)
Set the option value.
Definition: pstring.h:3393
const char * value
String value for string.
Definition: pstring.h:3162
__inline PInt64 AsInt64(unsigned base=0) const
Definition: pstring.h:1760
virtual PBoolean MakeUnique()
Make this instance to be the one and only reference to the container contents.
void SetEnum(const PString &key, E value)
Definition: pstring.h:3337
PStringSet(const BaseClass &other)
Definition: pstring.h:2838
This class is used when an ordinal index value is the key for PSet and PDictionary classes...
Definition: dict.h:47
__inline bool Has(const std::string &key) const
Definition: pstring.h:3370
PStringArray(const std::vector< PString > &vec)
Create a PStringArray from a vector of PStrings.
Definition: pstring.h:2424
__inline void clear()
Definition: pstring.h:1886
PStringDictionary()
Create a new, empty, dictionary.
Definition: pstring.h:2932
PString Trim() const
Create a string consisting of all characters from the source string except all spaces at the beginnin...
__inline PStringArray(const BaseClass &other)
Definition: pstring.h:2383
Data is a length byte followed by characters.
Definition: pstring.h:295
Comparison NumCompare(const PString &str, PINDEX count=P_MAX_INDEX, PINDEX offset=0) const
Compare a string against a substring of the object.
Structure for static array initialiser for class.
Definition: pstring.h:3158
bool SetVar(const std::string &key, const T &value)
Definition: pstring.h:3363
virtual PINDEX GetSize() const
Get the current size of the container.
bool SetVar(const PCaselessString &(*key)(), const T &value)
Definition: pstring.h:3366
PBoolean Contains(const K &key) const
Determine if the value of the object is contained in the hash table.
Definition: dict.h:1036
bool PBoolean
Definition: object.h:174
PStringSet(PBoolean initialDeleteObjects=true)
Create a PStringSet.
Definition: pstring.h:2835
Invalid range end.
Definition: pstring.h:3521
__inline PString Get(const PCaselessString &(*key)(), const char *dflt=NULL) const
Definition: pstring.h:3380
PString GetString(const PCaselessString &(*key)(), const char *dflt=NULL) const
Definition: pstring.h:3290
bool operator==(const PString &str) const
Compare two strings using the PObject::Compare() function.
void Exclude(const PString &key)
Exclude the spcified string value from the set.
bool InternalSplit(const PString &delimiter, PString &before, PString &after, SplitOptions_Bits options) const
This template class maps the PAbstractSet to a specific object type.
Definition: dict.h:508
virtual PObject * Clone() const
Make a complete duplicate of the string.
__inline std::string::size_type find(const char *s, std::string::size_type pos=0) const
Definition: pstring.h:1901
PSortedStringList(int dummy, const PSortedStringList *c)
Definition: pstring.h:2709
PString operator()(const K &key, const char *dflt=NULL) const
Get the string contained in the dictionary at the key position.
Definition: pstring.h:2961
#define P_MAX_INDEX
Definition: object.h:80
PString & operator=(const std::string &str)
Assign the string to the current object.
Definition: pstring.h:366
PINDEX AppendString(const PString &str)
Append a string to the list.
PINDEX GetStringsIndex(const PString &str) const
Get the index of the string with the specified value.
PString * GetAt(const PString &key) const
Definition: pstring.h:3267
__inline bool Set(const PString &key, const PString &value)
Definition: pstring.h:3395
The character string class.
Definition: pstring.h:108
__inline PString Get(const PCaselessString &(*key)(), const std::string &dflt) const
Definition: pstring.h:3385
PINDEX InternalStringSelect(const char *str, PINDEX len, PSortedListElement *thisElement, PSortedListElement *&lastElement) const
PString GetString(const std::string &key, const char *dflt=NULL) const
Definition: pstring.h:3287
bool SetString(const char *key, const PString &value)
Set the option value.
Definition: pstring.h:3293
This is a set collection class of PString objects.
Definition: pstring.h:2821
const void * GetPointer() const
Definition: array.h:204
Overwrite destination keys value.
Definition: pstring.h:3202
virtual PString * GetAt(const K &key) const
Get the object at the specified key position.
Definition: dict.h:1075
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...
__inline PString Get(const char *key, const std::string &dflt) const
Definition: pstring.h:3381
PString operator&(const PString &str) const
Concatenate a PString to another PString to produce a third.
PStringArray(int dummy, const PStringArray *c)
Definition: pstring.h:2371
Unmatched left bracket.
Definition: pstring.h:3513
const char * Initialiser
Definition: pstring.h:112
const char * key
String key for ordinal.
Definition: pstring.h:3102
virtual void DestroyReference()
Definition: pstring.h:2158
long AsInteger(unsigned base=0) const
Convert the string to an integer value using the specified number base.
PString * RemoveAt(const PCaselessString &key)
Definition: pstring.h:3282
virtual PBoolean SetAt(const K &key, const PString &str)
Add a new object to the collection.
Definition: pstring.h:2978
PINDEX m_length
Definition: pstring.h:1952
Invalid pattern.
Definition: pstring.h:3503
PCaselessString & operator=(const std::string &str)
Assign the string to the current object.
Definition: pstring.h:2062
PStringDictionary(int dummy, const PStringDictionary *c)
Definition: pstring.h:2985
__inline PString Get(const std::string &key, const std::string &dflt) const
Definition: pstring.h:3382
virtual PString & MakeEmpty()
Make the current string empty.
bool GetBoolean(const PCaselessString &(*key)(), bool dflt=false) const
Definition: pstring.h:3304
__inline PString Get(const PString &key, const char *dflt=NULL) const
Definition: pstring.h:3377
__inline PString & insert(std::string::size_type index, const std::string &s)
Definition: pstring.h:1895
void SetBoolean(const PCaselessString &key, bool value)
Definition: pstring.h:3310
Abstract class to embody the base functionality of a container.
Definition: contain.h:99
This is a list collection class of PString objects.
Definition: pstring.h:2562
Convert an unsigned integer to a string.
Definition: pstring.h:299
PString GetString(const PString &key, const char *dflt=NULL) const
Definition: pstring.h:3288
__inline bool Has(const PCaselessString &key) const
Definition: pstring.h:3372
PStringToString(const PString &str)
Initialise the string dictionary from the string.
Definition: pstring.h:3176
PINDEX FindOneOf(const PString &set, PINDEX offset=0) const
Locate the position of one of the characters in the set.
__inline bool Split(char delimiter, PString &before, PString &after, bool trim) const
Definition: pstring.h:1560
static const PString & Empty()
Return an empty string.
Convert a real number to a string in exponent format.
Definition: pstring.h:301
long GetInteger(const std::string &key, long dflt=0) const
Definition: pstring.h:3315
uint64_t AsUnsigned64(unsigned base=0) const
Convert the string to an integer value using the specified number base.
bool SetVar(const PString &key, const T &value)
Definition: pstring.h:3364
PStringSet & operator-=(const PString &key)
Exclude the spcified string value from the set.
__inline std::string::size_type rfind(const char *s, std::string::size_type pos=0) const
Definition: pstring.h:1904
virtual void ReadFrom(istream &strm)
Input the contents of the object from the stream.
void SetReal(const PCaselessString &(*key)(), double value, int decimals)
Definition: pstring.h:3353
PStringOptions(const PString &str)
Definition: pstring.h:3253
PString * GetAt(const std::string &key) const
Definition: pstring.h:3266
PStringList(int dummy, const PStringList *c)
Definition: pstring.h:2568
__inline bool Set(const std::string &key, const PString &value)
Definition: pstring.h:3394
void SetEnum(const std::string &key, E value)
Definition: pstring.h:3336
PString ToUpper() const
Create a string consisting of all characters from the source string with all lower case letters conve...
__inline PString Get(const char *key, const PString &dflt) const
Definition: pstring.h:3386
void FromString(const PString &str)
Set dictionary from string.
__inline PString Get(const PString &key, const PString &dflt) const
Definition: pstring.h:3388
PString GetErrorText() const
Get the text description for the error of the last Compile() or Execute() operation.
bool Execute(const PString &str, PINDEX &start, ExecOptions options=Normal) const
Execute regular expression.
PStringStream & operator=(const PStringStream &strm)
Assign the string part of the stream to the current object.
__inline bool Split(const PString &delimiter, PString &before, PString &after, SplitOptions options=SplitTrim) const
Split the string into two substrings around delimiter.
Definition: pstring.h:1547
This template class maps the PAbstractSortedList to a specific object type.
Definition: lists.h:964
void SetBoolean(const PString &key, bool value)
Definition: pstring.h:3309
bool SetString(const PCaselessString &(*key)(), const PString &value)
Definition: pstring.h:3297
void SetBoolean(const std::string &key, bool value)
Definition: pstring.h:3308
P_DECLARE_BITWISE_ENUM_EX(SplitOptions, 6,(SplitOnly, SplitTrimBefore, SplitTrimAfter, SplitDefaultToBefore, SplitDefaultToAfter, SplitBeforeNonEmpty, SplitAfterNonEmpty), SplitTrim=SplitTrimBefore|SplitTrimAfter, SplitNonEmpty=SplitBeforeNonEmpty|SplitAfterNonEmpty)
Options for PString::Split() function.
virtual void ReadFrom(istream &strm)
Input the contents of the object from the stream.
void SetReal(const char *key, double value, int decimals)
Set a floating point real value for the particular MIME info field.
Definition: pstring.h:3349
Invalid parameter was passed to a function.
Definition: object.h:378
~PConstantString()
Definition: pstring.h:2151
Didn't find a match (for regexec).
Definition: pstring.h:3499
void SetEnum(const char *key, E value)
Set an enum value for the particular MIME info field.
Definition: pstring.h:3335
PConstantString(typename ParentString::Initialiser init)
Definition: pstring.h:2137
Parenthesis imbalance.
Definition: pstring.h:3515
PString GetString(const char *key, const char *dflt=NULL) const
Get an option value.
Definition: pstring.h:3286
This is a dictionary collection class of PString objects, keyed by an ordinal value.
Definition: pstring.h:3046
PString & 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.
static PStringArray container(const stlContainer &vec)
Create a PStringArray from an STL container.
Definition: pstring.h:2447
PString LeftTrim() const
Create a string consisting of all characters from the source string except all spaces at the beginnin...
void SetInteger(const PCaselessString &(*key)(), long value)
Definition: pstring.h:3325
PStringList operator+(const PStringList &array)
Create a new PStringList, and add PString or PStringList to it a new PStringList. ...
E GetEnum(const PString &key, E dflt) const
Definition: pstring.h:3330
This template class maps the PArrayObjects to a specific object type.
Definition: array.h:925
PStringSet & operator+=(const PString &key)
Include the spcified string value into the set.
PConstantString< PCaselessString > PConstCaselessString
Constant PCaselessString type. See PConstantString.
Definition: pstring.h:2169
A class representing a regular expression that may be used for locating patterns in strings...
Definition: pstring.h:3413
PINDEX FindRegEx(const PRegularExpression ®ex, PINDEX offset=0) const
Locate the position within the string of one of the regular expression.
T GetVar(const std::string &key, const T &dflt) const
Definition: pstring.h:3357
virtual void AssignContents(const PContainer &)
Definition: pstring.h:2157
virtual int internal_strcmp(const char *s1, const char *s2) const
__inline PString & replace(std::string::size_type pos, std::string::size_type count, const std::string &s)
Definition: pstring.h:1898
__inline PString Get(const PCaselessString &key, const std::string &dflt) const
Definition: pstring.h:3384
PStringArray(const std::vector< std::string > &vec)
Create a PStringArray from a vector of std::string.
Definition: pstring.h:2435
bool Contains(const char *key) const
Determine if the specified key is present.
Definition: pstring.h:3258
Data is two length bytes followed by characters.
Definition: pstring.h:296
bool SetString(const PString &key, const PString &value)
Definition: pstring.h:3295
P_DECLARE_BITWISE_ENUM(CompileOptions, 3,(Simple, Extended, IgnoreCase, AnchorNewLine))
Flags for compiler options.
bool operator>(const PString &str) const
Compare two strings using the PObject::Compare() function.
virtual PINDEX GetLength() const
Determine the length of the null terminated string.
Definition: pstring.h:595
bool MakeMinimumSize(PINDEX newLength=0)
Set the actual memory block array size to the minimum required to hold the current string contents...
__inline PString & insert(std::string::size_type index, std::string::size_type count, char ch)
Definition: pstring.h:1893
PStringArray Lines() const
Split the string into individual lines.
void SetInteger(const char *key, long value)
Set an integer value for the particular MIME info field.
Definition: pstring.h:3321
__inline PString Get(const PCaselessString &key, const PString &dflt) const
Definition: pstring.h:3389
bool SetString(const PCaselessString &key, const PString &value)
Definition: pstring.h:3296
double AsReal() const
Convert the string to a floating point number.
PString * RemoveAt(const PCaselessString &(*key)())
Definition: pstring.h:3283
#define P_DEPRECATED
Definition: object.h:141
__inline void Remove(const PCaselessString &(*key)())
Definition: pstring.h:3404
__inline PString Get(const char *key, const char *dflt=NULL) const
Get the option value.
Definition: pstring.h:3376
Miscellaneous error.
Definition: pstring.h:3535
virtual const char * GetPointer(PINDEX=0) const
Get a const pointer to the buffer contents This function overrides the ancestor function that returns...
Definition: pstring.h:1877
__inline bool Split(const char *delimiter, PString &before, PString &after, SplitOptions_Bits options) const
Definition: pstring.h:1559
PINDEX GetStringsIndex(const PString &str) const
As for GetValuesIndex() but takes a PString argument so that literals will be automatically converted...
__inline PString & erase(std::string::size_type index=0, std::string::size_type count=std::string::npos)
Definition: pstring.h:1896
PString operator+(const PString &str) const
Concatenate two strings to produce a third.
virtual PObject * Clone() const
Make a complete duplicate of the dictionary.
Definition: pstring.h:2942
__inline bool Has(const char *key) const
Determine of the option exists.
Definition: pstring.h:3369
DWORD AsUnsigned(unsigned base=0) const
Convert the string to an integer value using the specified number base.
virtual PBoolean SetSize(PINDEX newSize)
Set the size of the string.
__inline PStringList(const BaseClass &other)
Definition: pstring.h:2579
bool GetBoolean(const std::string &key, bool dflt=false) const
Definition: pstring.h:3301
virtual PString * RemoveAt(const K &key)
Remove an object at the specified key.
Definition: dict.h:1049
PString & vsprintf(const PString &fmt, va_list args)
Concatenate a formatted output to the string.
Unmatched \.
Definition: pstring.h:3517
bool operator<(const PString &str) const
Compare two strings using the PObject::Compare() function.
Ignore new value, leave desstination as is.
Definition: pstring.h:3203
PString m_pattern
Definition: pstring.h:3684
Invalid contents of \.
Definition: pstring.h:3519
PINDEX FindLast(char ch, PINDEX offset=P_MAX_INDEX) const
Locate the position of the last matching character.
__inline std::string substr(std::string::size_type pos=0, std::string::size_type count=std::string::npos) const
Definition: pstring.h:1899
PString Mid(PINDEX start, PINDEX len=P_MAX_INDEX) const
Extract a portion of the string into a new string.
virtual PBoolean SetSize(PINDEX s)
Definition: pstring.h:2156
__inline PString Get(const PString &key, const std::string &dflt) const
Definition: pstring.h:3383
__inline std::string::size_type find_first_not_of(const std::string &s, std::string::size_type pos=0) const
Definition: pstring.h:1909
__inline PString Get(const PCaselessString &(*key)(), const PString &dflt) const
Definition: pstring.h:3390
double GetReal(const char *key, double dflt=0) const
Get the option value as a floating point real.
Definition: pstring.h:3342
PString psprintf(const char *fmt,...)
The same as the standard C snprintf(fmt, 1000, ...), but returns a PString instead of a const char *...
T GetVar(const char *key, const T &dflt) const
Get the option value as any type.
Definition: pstring.h:3356
void SetEnum(const PCaselessString &(*key)(), E value)
Definition: pstring.h:3339
This template class maps the PAbstractDictionary to a specific key type and a POrdinalKey data type...
Definition: dict.h:1297
__inline bool Split(char delimiter, PString &before, PString &after, SplitOptions options) const
Definition: pstring.h:1556
PBoolean MatchesRegEx(const PRegularExpression ®ex) const
Return true if the entire string matches the regular expression.
virtual int internal_strcmp(const char *s1, const char *s2) const
Ultimate parent class for all objects in the class library.
Definition: object.h:2204
virtual void PrintOn(ostream &strm) const
Output the regular expression to the specified stream.
PStringStream()
Create a new, empty, string stream.
Compiled pattern bigger than 2^16 bytes.
Definition: pstring.h:3531
void SetInteger(const PString &key, long value)
Definition: pstring.h:3323
PString Left(PINDEX len) const
Extract a portion of the string into a new string.
virtual int internal_strncmp(const char *s1, const char *s2, size_t n) const
PString * RemoveAt(const std::string &key)
Definition: pstring.h:3280
#define PNEW
Macro for overriding system default new operator.
Definition: object.h:1896
friend PString psprintf(const char *cfmt,...)
Produce formatted output as a string.
bool operator>=(const PString &str) const
Compare two strings using the PObject::Compare() function.
PCaselessString(const std::string &str)
Create a caseless string from a std::string.
Definition: pstring.h:2039
Structure for static array initialiser for class.
Definition: pstring.h:3053
Ran out of memory.
Definition: pstring.h:3523
void Merge(const PStringToString &merge, MergeAction action)
Merge string dictionary into this dictionary.
__inline PString Get(const std::string &key, const char *dflt=NULL) const
Definition: pstring.h:3378
double GetReal(const PString &key, double dflt=0) const
Definition: pstring.h:3344
PString ToLower() const
Create a string consisting of all characters from the source string with all upper case letters conve...
long GetInteger(const char *key, long dflt=0) const
Get the option value as an integer.
Definition: pstring.h:3314
__inline void clear()
Definition: pstring.h:2295
CompileOptions m_compileOptions
Definition: pstring.h:3685