00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
#ifdef P_USE_PRAGMA
00290
#pragma interface
00291
#endif
00292
00293
#include <string>
00294
#include <vector>
00295
00297
00298
00299
class PStringArray;
00300
class PRegularExpression;
00301
00336 class PString :
public PCharArray {
00337
PCLASSINFO(
PString,
PCharArray);
00338
00339
00340
00341
public:
00347
PINLINE PString();
00348
00352
PINLINE PString(
00353
const PString & str
00354 );
00355
00358
PINLINE PString(
00359
const std::string & str
00360 );
00361
00370
PString(
00371
const char * cstr
00372 );
00373
00378
PString(
00379
const WORD * ustr
00380 );
00381
00395
PString(
00396
const char * cstr,
00397 PINDEX len
00398 );
00399
00410
PString(
00411
const WORD * ustr,
00412 PINDEX len
00413 );
00414
00425
PString(
00426
const PWORDArray & ustr
00427 );
00428
00437
PString(
00438
char ch
00439 );
00440
00445
PString(
00446
short n
00447 );
00448
00453
PString(
00454
unsigned short n
00455 );
00456
00461
PString(
00462
int n
00463 );
00464
00469
PString(
00470
unsigned int n
00471 );
00472
00477
PString(
00478
long n
00479 );
00480
00485
PString(
00486
unsigned long n
00487 );
00488
00493
PString(
00494 PInt64 n
00495 );
00496
00501
PString(
00502 PUInt64 n
00503 );
00504
00505
00506 enum ConversionType {
00507
Pascal,
00508
Basic,
00509
Literal,
00510
Signed,
00511
Unsigned,
00512
Decimal,
00513
Exponent,
00514
Printf,
00515
NumConversionTypes
00516 };
00517
00518
00519
00520
00521
00522
00523
PString(
00524 ConversionType type,
00525
const char * str,
00526 ...
00527 );
00528
PString(
00529 ConversionType type,
00530
long value,
00531
unsigned base = 10
00532 );
00533
PString(
00534 ConversionType type,
00535
double value,
00536
unsigned places
00537 );
00538
00546 PString & operator=(
00547
const PString & str
00548 );
00549
00559 PString & operator=(
00560
const char * cstr
00561 );
00562
00571 PString & operator=(
00572
char ch
00573 );
00574
00579 PString & operator=(
00580
short n
00581 );
00582
00587 PString & operator=(
00588
unsigned short n
00589 );
00590
00595 PString & operator=(
00596
int n
00597 );
00598
00603 PString & operator=(
00604
unsigned int n
00605 );
00606
00611 PString & operator=(
00612
long n
00613 );
00614
00619 PString & operator=(
00620
unsigned long n
00621 );
00622
00627 PString & operator=(
00628 PInt64 n
00629 );
00630
00635 PString & operator=(
00636 PUInt64 n
00637 );
00638
00641
virtual PString &
MakeEmpty();
00642
00645
static PString
Empty();
00647
00654
virtual PObject *
Clone() const;
00655
00665 virtual Comparison Compare(
00666 const
PObject & obj
00667 ) const;
00668
00671 virtual
void PrintOn(
00672 ostream & strm
00673 ) const;
00674
00680 virtual
void ReadFrom(
00681 istream & strm
00682 );
00683
00697 virtual PINDEX HashFunction() const;
00699
00714 virtual BOOL SetSize(
00715 PINDEX newSize
00716 );
00717
00726 virtual BOOL IsEmpty() const;
00727
00736 virtual BOOL MakeUnique();
00738
00739
00752 BOOL MakeMinimumSize();
00753
00762 PINLINE PINDEX GetLength() const;
00763
00770
bool operator!() const;
00772
00781 PString operator+(
00782 const PString & str
00783 ) const;
00784
00796 PString operator+(
00797 const
char * cstr
00798 ) const;
00799
00811 PString operator+(
00812
char ch
00813 ) const;
00814
00826 friend PString operator+(
00827 const
char * cstr,
00828 const PString & str
00829 );
00830
00842 friend PString operator+(
00843
char c,
00844 const PString & str
00845 );
00846
00852 PString & operator+=(
00853 const PString & str
00854 );
00855
00865 PString & operator+=(
00866 const
char * cstr
00867 );
00868
00878 PString & operator+=(
00879
char ch
00880 );
00881
00882
00889 PString operator&(
00890 const PString & str
00891 ) const;
00892
00909 PString operator&(
00910 const
char * cstr
00911 ) const;
00912
00929 PString operator&(
00930
char ch
00931 ) const;
00932
00949 friend PString operator&(
00950 const
char * cstr,
00951 const PString & str
00952 );
00953
00970 friend PString operator&(
00971
char ch,
00972 const PString & str
00973 );
00974
00980 PString & operator&=(
00981 const PString & str
00982 );
00983
00998 PString & operator&=(
00999 const
char * cstr
01000 );
01001
01002
01017 PString & operator&=(
01018
char ch
01019 );
01021
01022
01030
bool operator*=(
01031 const PString & str
01032 ) const;
01033
01041
bool operator==(
01042 const
PObject & str
01043 ) const;
01044
01052
bool operator!=(
01053 const
PObject & str
01054 ) const;
01055
01063
bool operator<(
01064 const
PObject & str
01065 ) const;
01066
01074
bool operator>(
01075 const
PObject & str
01076 ) const;
01077
01085
bool operator<=(
01086 const
PObject & str
01087 ) const;
01088
01096
bool operator>=(
01097 const
PObject & str
01098 ) const;
01099
01100
01111
bool operator*=(
01112 const
char * cstr
01113 ) const;
01114
01125
bool operator==(
01126 const
char * cstr
01127 ) const;
01128
01139
bool operator!=(
01140 const
char * cstr
01141 ) const;
01142
01153
bool operator<(
01154 const
char * cstr
01155 ) const;
01156
01167
bool operator>(
01168 const
char * cstr
01169 ) const;
01170
01181
bool operator<=(
01182 const
char * cstr
01183 ) const;
01184
01195
bool operator>=(
01196 const
char * cstr
01197 ) const;
01198
01210 Comparison NumCompare(
01211 const PString & str,
01212 PINDEX count = P_MAX_INDEX,
01213 PINDEX offset = 0
01214 ) const;
01215
01227 Comparison NumCompare(
01228 const
char * cstr,
01229 PINDEX count = P_MAX_INDEX,
01230 PINDEX offset = 0
01231 ) const;
01233
01234
01238 PINDEX Find(
01239
char ch,
01240 PINDEX offset = 0
01241 ) const;
01242
01244 PINDEX Find(
01245 const PString & str,
01246 PINDEX offset = 0
01247 ) const;
01248
01249
01250
01251
01252
01253
01254
01255
01256
01257
01258
01259
01260
01261
01262
01263 PINDEX Find(
01264 const
char * cstr,
01265 PINDEX offset = 0
01266 ) const;
01267
01269 PINDEX FindLast(
01270
char ch,
01271 PINDEX offset = P_MAX_INDEX
01272 ) const;
01273
01275 PINDEX FindLast(
01276 const PString & str,
01277 PINDEX offset = P_MAX_INDEX
01278 ) const;
01279
01297 PINDEX FindLast(
01298 const
char * cstr,
01299 PINDEX offset = P_MAX_INDEX
01300 ) const;
01301
01303 PINDEX FindOneOf(
01304 const PString & set,
01305 PINDEX offset = 0
01306 ) const;
01307
01322 PINDEX FindOneOf(
01323 const
char * cset,
01324 PINDEX offset = 0
01325 ) const;
01326
01337 PINDEX FindRegEx(
01338 const
PRegularExpression & regex,
01339 PINDEX offset = 0
01340 ) const;
01341
01352 BOOL FindRegEx(
01353 const
PRegularExpression & regex,
01354 PINDEX & pos,
01355 PINDEX & len,
01356 PINDEX offset = 0,
01357 PINDEX maxPos = P_MAX_INDEX
01358 ) const;
01359
01360
01371
void Replace(
01372 const PString & target,
01373 const PString & subs,
01374 BOOL all = FALSE,
01375 PINDEX offset = 0
01376 );
01377
01385
void Splice(
01386 const PString & str,
01387 PINDEX pos,
01388 PINDEX len = 0
01389 );
01390
01398
void Splice(
01399 const
char * cstr,
01400 PINDEX pos,
01401 PINDEX len = 0
01402 );
01403
01410
void Delete(
01411 PINDEX start,
01412 PINDEX len
01413 );
01415
01416
01436 PString operator()(
01437 PINDEX start,
01438 PINDEX end
01439 ) const;
01440
01455 PString Left(
01456 PINDEX len
01457 ) const;
01458
01473 PString Right(
01474 PINDEX len
01475 ) const;
01476
01493 PString Mid(
01494 PINDEX start,
01495 PINDEX len = P_MAX_INDEX
01496 ) const;
01497
01498
01506 PString LeftTrim() const;
01507
01515 PString RightTrim() const;
01516
01525 PString Trim() const;
01526
01527
01536 PString ToLower() const;
01537
01546 PString ToUpper() const;
01547
01548
01550
PStringArray Tokenise(
01551 const PString & separators,
01553 BOOL onePerSeparator = TRUE
01555 ) const;
01578
PStringArray Tokenise(
01579 const
char * cseparators,
01581 BOOL onePerSeparator = TRUE
01583 ) const;
01584
01598
PStringArray Lines() const;
01600
01617 PString & sprintf(
01618 const
char * cfmt,
01619 ...
01620 );
01621
01636 friend PString psprintf(
01637 const
char * cfmt,
01638 ...
01639 );
01640
01642 PString & vsprintf(
01643 const PString & fmt,
01644 va_list args
01645 );
01660 PString & vsprintf(
01661 const
char * cfmt,
01662 va_list args
01663 );
01664
01666 friend PString pvsprintf(
01667 const
char * cfmt,
01668 va_list args
01669 );
01684 friend PString pvsprintf(
01685 const PString & fmt,
01686 va_list args
01687 );
01688
01689
01702
long AsInteger(
01703
unsigned base = 10
01704 ) const;
01717 DWORD AsUnsigned(
01718
unsigned base = 10
01719 ) const;
01733 PInt64 AsInt64(
01734
unsigned base = 10
01735 ) const;
01749 PUInt64 AsUnsigned64(
01750
unsigned base = 10
01751 ) const;
01752
01763
double AsReal() const;
01764
01768
PWORDArray AsUCS2() const;
01769
01780
PBYTEArray ToPascal() const;
01781
01790 PString ToLiteral() const;
01791
01799 operator const
unsigned char *() const;
01800
01802
01803
01804 protected:
01805
void InternalFromUCS2(
01806 const WORD * ptr,
01807 PINDEX len
01808 );
01809 virtual Comparison InternalCompare(
01810 PINDEX offset,
01811
char c
01812 ) const;
01813 virtual Comparison InternalCompare(
01814 PINDEX offset,
01815 PINDEX length,
01816 const
char * cstr
01817 ) const;
01818
01819
01820
01821
01822
01823
01824
01825 PString(
int dummy, const PString * str);
01826 };
01827
01828
01830
01840 class
PCaselessString : public PString
01841 {
01842
PCLASSINFO(
PCaselessString, PString);
01843
01844
public:
01847
PCaselessString();
01848
01852
PCaselessString(
01853
const char * cstr
01854 );
01855
01860
PCaselessString(
01861
const PString & str
01862 );
01863
01864
01872
PCaselessString & operator=(
01873
const PString & str
01874 );
01875
01885
PCaselessString & operator=(
01886
const char * cstr
01887 );
01888
01897
PCaselessString & operator=(
01898
char ch
01899 );
01900
01901
01902
01907
virtual PObject *
Clone()
const;
01908
01909
protected:
01910
01911
virtual Comparison InternalCompare(
01912 PINDEX offset,
01913
char c
01914 )
const;
01915
virtual Comparison InternalCompare(
01916 PINDEX offset,
01917 PINDEX length,
01918
const char * cstr
01919 )
const;
01920
01921
01922
01923
01924
01925
01926
01927
PCaselessString(
int dummy,
const PCaselessString * str);
01928 };
01929
01931
01932
class PStringStream;
01933
01940 class PStringStream :
public PString,
public iostream
01941 {
01942
PCLASSINFO(
PStringStream, PString);
01943
01944
public:
01950
PStringStream();
01951
01956
PStringStream(
01957 PINDEX fixedBufferSize
01958 );
01959
01966
PStringStream(
01967
const PString & str
01968 );
01969
01974
PStringStream(
01975
const char * cstr
01976 );
01977
01980
virtual PString &
MakeEmpty();
01981
01993
PStringStream & operator=(
01994
const PStringStream & strm
01995 );
01996
02008
PStringStream & operator=(
02009
const PString & str
02010 );
02011
02027
PStringStream & operator=(
02028
const char * cstr
02029 );
02030
02039
PStringStream & operator=(
02040
char ch
02041 );
02042
02043
02045
virtual ~
PStringStream();
02046
02047
02048
protected:
02049
virtual void AssignContents(
const PContainer & cont);
02050
02051
private:
02052
PStringStream(
int,
const PStringStream &) : iostream(cout.rdbuf()) { }
02053
02054
class Buffer :
public streambuf {
02055
public:
02056 Buffer(
PStringStream & str, PINDEX size);
02057 Buffer(
const Buffer & sbuf);
02058 Buffer & operator=(
const Buffer & sbuf);
02059
virtual int overflow(
int=EOF);
02060
virtual int underflow();
02061
virtual int sync();
02062
#if __USE_STL__
02063
virtual pos_type seekoff(off_type, ios_base::seekdir, ios_base::openmode = ios_base::in | ios_base::out);
02064
virtual pos_type seekpos(pos_type, ios_base::openmode = ios_base::in | ios_base::out);
02065
#else
02066
virtual streampos seekoff(streamoff, ios::seek_dir,
int);
02067
#endif
02068
PStringStream & string;
02069 BOOL fixedBufferSize;
02070 };
02071 };
02072
02073
02074
class PStringList;
02075
class PSortedStringList;
02076
02089
#ifdef DOC_PLUS_PLUS
02090 class PStringArray :
public PArray {
02091
#endif
02092
PDECLARE_ARRAY(
PStringArray, PString);
02093
public:
02100
PStringArray(
02101 PINDEX count,
02102
char const *
const * strarr,
02103 BOOL caseless = FALSE
02104 );
02107
PStringArray(
02108
const PString & str
02109 );
02112
PStringArray(
02113
const PStringList & list
02114 );
02117
PStringArray(
02118
const PSortedStringList & list
02119 );
02120
02124 PStringArray(
02125
const std::vector<PString> & vec
02126 )
02127 {
02128
for (std::vector<PString>::const_iterator r = vec.begin(); r != vec.end(); ++r)
02129 AppendString(*r);
02130 }
02131
02135 PStringArray(
02136
const std::vector<std::string> & vec
02137 )
02138 {
02139
for (std::vector<std::string>::const_iterator r = vec.begin(); r != vec.end(); ++r)
02140 AppendString(
PString(*r));
02141 }
02143
02151
virtual void ReadFrom(
02152 istream &strm
02153 );
02155
02164 PINDEX GetStringsIndex(
02165
const PString & str
02166 )
const;
02167
02168 inline PString & operator[](
02169 PINDEX index
02170 )
const {
return PStringArray_PTemplate::operator[](index); }
02171
02179 PString & operator[](
02180 PINDEX index
02181 );
02182
02185 PINDEX AppendString(
02186
const PString & str
02187 );
02188
02194
PStringArray & operator +=(
const PStringArray & array);
02195
PStringArray & operator +=(
const PString & str);
02196
02197
02204
PStringArray operator + (
const PStringArray & array);
02205
PStringArray operator + (
const PString & str);
02206
02214
char ** ToCharArray(
02215
PCharArray * storage = NULL
02216 )
const;
02218 };
02219
02220
02233
#ifdef DOC_PLUS_PLUS
02234 class PStringList :
public PList {
02235
#endif
02236
PDECLARE_LIST(
PStringList, PString);
02237
public:
02242
PStringList(
02243 PINDEX count,
02244
char const *
const * strarr,
02245 BOOL caseless = FALSE
02246 );
02249
PStringList(
02250
const PString & str
02251 );
02254
PStringList(
02255
const PStringArray & array
02256 );
02259
PStringList(
02260
const PSortedStringList & list
02261 );
02263
02271
virtual void ReadFrom(
02272 istream &strm
02273 );
02275
02280 PINDEX AppendString(
02281
const PString & str
02282 );
02283
02286 PINDEX InsertString(
02287
const PString & before,
02288
const PString & str
02289 );
02290
02294 PINDEX GetStringsIndex(
02295
const PString & str
02296 )
const;
02297
02303
PStringList & operator +=(
const PStringList & list);
02304
PStringList & operator +=(
const PString & str);
02305
02306
02313
PStringList operator + (
const PStringList & array);
02314
PStringList operator + (
const PString & str);
02315
02317 };
02318
02319
02332
#ifdef DOC_PLUS_PLUS
02333 class PSortedStringList :
public PSortedList {
02334
#endif
02335
PDECLARE_SORTED_LIST(
PSortedStringList, PString);
02336
public:
02341
PSortedStringList(
02342 PINDEX count,
02343
char const *
const * strarr,
02344 BOOL caseless = FALSE
02345 );
02348
PSortedStringList(
02349
const PString & str
02350 );
02353
PSortedStringList(
02354
const PStringArray & array
02355 );
02358
PSortedStringList(
02359
const PStringList & list
02360 );
02362
02370
virtual void ReadFrom(
02371 istream &strm
02372 );
02374
02380 PINDEX AppendString(
02381
const PString & str
02382 );
02383
02387 PINDEX GetStringsIndex(
02388
const PString & str
02389 )
const;
02390
02395 PINDEX GetNextStringsIndex(
02396
const PString & str
02397 )
const;
02399
02400
protected:
02401 PINDEX InternalStringSelect(
02402
const char * str,
02403 PINDEX len,
02404 Element * thisElement
02405 )
const;
02406 };
02407
02408
02425
#ifdef DOC_PLUS_PLUS
02426 class PStringSet :
public PSet {
02427
#endif
02428
PDECLARE_SET(
PStringSet, PString, TRUE);
02429
public:
02434
PStringSet(
02435 PINDEX count,
02436
char const *
const * strarr,
02437 BOOL caseless = FALSE
02438 );
02441
PStringSet(
02442
const PString & str
02443 );
02445
02453
virtual void ReadFrom(
02454 istream &strm
02455 );
02457
02461
void Include(
02462
const PString & key
02463 );
02465
PStringSet & operator+=(
02466
const PString & key
02467 );
02469
void Exclude(
02470
const PString & key
02471 );
02473
PStringSet & operator-=(
02474
const PString & key
02475 );
02477 };
02478
02479
02480
#ifdef PHAS_TEMPLATES
02481
02489
template <
class K>
class PStringDictionary :
public PAbstractDictionary
02490 {
02491
PCLASSINFO(PStringDictionary,
PAbstractDictionary);
02492
02493
public:
02502 PStringDictionary()
02503 :
PAbstractDictionary() { }
02505
02512
virtual PObject *
Clone()
const
02513
{
return PNEW PStringDictionary(0,
this); }
02515
02530
const PString & operator[](
const K & key)
const
02531
{
return (
const PString &)GetRefAt(key); }
02532
02546 PString operator()(
const K & key,
const char * dflt =
"")
const
02547
{
if (AbstractContains(key))
return (*this)[key];
return dflt; }
02548
02557 BOOL Contains(
02558
const K & key
02559 )
const {
return AbstractContains(key); }
02560
02569
virtual PString * RemoveAt(
02570
const K & key
02571 ) { PString * s = GetAt(key); AbstractSetAt(key, NULL);
return s; }
02572
02579
virtual PString * GetAt(
02580
const K & key
02581 )
const {
return (PString *)AbstractGetAt(key); }
02582
02591
virtual BOOL SetDataAt(
02592 PINDEX index,
02593
const PString & str
02594 ) {
return PAbstractDictionary::SetDataAt(index, PNEW
PString(str)); }
02595
02607
virtual BOOL SetAt(
02608
const K & key,
02609
const PString & str
02610 ) {
return AbstractSetAt(key, PNEW
PString(str)); }
02611
02623
const K & GetKeyAt(PINDEX index)
const
02624
{
return (
const K &)AbstractGetKeyAt(index); }
02625
02637 PString & GetDataAt(PINDEX index)
const
02638
{
return (PString &)AbstractGetDataAt(index); }
02640
02641
protected:
02642 PStringDictionary(
int dummy,
const PStringDictionary * c)
02643 :
PAbstractDictionary(dummy, c) { }
02644 };
02645
02646
02661
#define PDECLARE_STRING_DICTIONARY(cls, K) \
02662
PDECLARE_CLASS(cls, PStringDictionary<K>) \
02663
protected: \
02664
cls(int dummy, const cls * c) \
02665
: PStringDictionary<K>(dummy, c) { } \
02666
public: \
02667
cls() \
02668
: PStringDictionary<K>() { } \
02669
virtual PObject * Clone() const \
02670
{ return PNEW cls(0, this); } \
02671
02672
02685
#define PSTRING_DICTIONARY(cls, K) typedef PStringDictionary<K> cls
02686
02687
02688
#else // PHAS_TEMPLATES
02689
02690
02691 #define PSTRING_DICTIONARY(cls, K) \
02692
class cls : public PAbstractDictionary { \
02693
PCLASSINFO(cls, PAbstractDictionary) \
02694
protected: \
02695
inline cls(int dummy, const cls * c) \
02696
: PAbstractDictionary(dummy, c) { } \
02697
public: \
02698
inline cls() \
02699
: PAbstractDictionary() { } \
02700
inline PObject * Clone() const \
02701
{ return PNEW cls(0, this); } \
02702
inline PString & operator[](const K & key) const \
02703
{ return (PString &)GetRefAt(key); } \
02704
inline PString operator()(const K & key, const char * dflt = "") const \
02705
{ if (Contains(key)) return (PString &)GetRefAt(key); return dflt; } \
02706
virtual BOOL Contains(const K & key) const \
02707
{ return AbstractContains(key); } \
02708
virtual PString * RemoveAt(const K & key) \
02709
{ PString * s = GetAt(key); AbstractSetAt(key, NULL); return s; } \
02710
virtual PString * GetAt(const K & key) const \
02711
{ return (PString *)AbstractGetAt(key); } \
02712
virtual BOOL SetDataAt(PINDEX index, const PString & str) \
02713
{ return PAbstractDictionary::SetDataAt(index,PNEW PString(str));} \
02714
virtual BOOL SetAt(const K & key, const PString & str) \
02715
{ return AbstractSetAt(key, PNEW PString(str)); } \
02716
inline const K & GetKeyAt(PINDEX index) const \
02717
{ return (const K &)AbstractGetKeyAt(index); } \
02718
inline PString & GetDataAt(PINDEX index) const \
02719
{ return (PString &)AbstractGetDataAt(index); } \
02720
}
02721
02722 #define PDECLARE_STRING_DICTIONARY(cls, K) \
02723
PSTRING_DICTIONARY(cls##_PTemplate, K); \
02724
PDECLARE_CLASS(cls, cls##_PTemplate) \
02725
protected: \
02726
cls(int dummy, const cls * c) \
02727
: cls##_PTemplate(dummy, c) { } \
02728
public: \
02729
cls() \
02730
: cls##_PTemplate() { } \
02731
virtual PObject * Clone() const \
02732
{ return PNEW cls(0, this); } \
02733
02734
#endif // PHAS_TEMPLATES
02735
02736
02751
#ifdef DOC_PLUS_PLUS
02752 class POrdinalToString :
public PStringDictionary {
02753
#endif
02754
PDECLARE_STRING_DICTIONARY(
POrdinalToString,
POrdinalKey);
02755
public:
02758
02759 struct Initialiser {
02761 PINDEX key;
02763 const char * value;
02764 };
02767
POrdinalToString(
02768 PINDEX count,
02769
const Initialiser * init
02770 );
02772
02780
virtual void ReadFrom(
02781 istream &strm
02782 );
02784 };
02785
02798
#ifdef DOC_PLUS_PLUS
02799 class PStringToOrdinal :
public POrdinalDictionary {
02800
#endif
02801
PDECLARE_ORDINAL_DICTIONARY(
PStringToOrdinal, PString);
02802
public:
02805
02806 struct Initialiser {
02808 const char * key;
02810 PINDEX value;
02811 };
02814
PStringToOrdinal(
02815 PINDEX count,
02816
const Initialiser * init,
02817 BOOL caseless = FALSE
02818 );
02820
02828
virtual void ReadFrom(
02829 istream &strm
02830 );
02832 };
02833
02834
02848
#ifdef DOC_PLUS_PLUS
02849 class PStringToString :
public PStringDictionary {
02850
#endif
02851
PDECLARE_STRING_DICTIONARY(
PStringToString, PString);
02852
public:
02855
02856 struct Initialiser {
02858 const char * key;
02860 const char * value;
02861 };
02864
PStringToString(
02865 PINDEX count,
02866
const Initialiser * init,
02867 BOOL caselessKeys = FALSE,
02868 BOOL caselessValues = FALSE
02869 );
02871
02879
virtual void ReadFrom(
02880 istream &strm
02881 );
02883 };
02884
02885
02891 class PRegularExpression :
public PObject
02892 {
02893
PCLASSINFO(
PRegularExpression,
PObject);
02894
02895
public:
02898
02899
enum {
02901 Extended = 1,
02903 IgnoreCase = 2,
02908 AnchorNewLine = 4
02909 };
02911
enum {
02918 NotBeginningOfLine = 1,
02920 NotEndofLine = 2
02921 };
02922
02924
PRegularExpression();
02925
02928
PRegularExpression(
02929
const PString & pattern,
02930
int flags = IgnoreCase
02931 );
02932
02935
PRegularExpression(
02936
const char * cpattern,
02937
int flags = IgnoreCase
02938 );
02939
02943
PRegularExpression(
02944
const PRegularExpression &
02945 );
02946
02950
PRegularExpression & operator =(
02951
const PRegularExpression &
02952 );
02953
02955 ~
PRegularExpression();
02957
02960
02961 enum ErrorCodes {
02963 NoError = 0,
02965 NoMatch,
02966
02967
02969 BadPattern,
02971 CollateError,
02973 BadClassType,
02975 BadEscape,
02977 BadSubReg,
02979 UnmatchedBracket,
02981 UnmatchedParen,
02983 UnmatchedBrace,
02985 BadBR,
02987 RangeError,
02989 OutOfMemory,
02991 BadRepitition,
02992
02993
02995 PrematureEnd,
02997 TooBig,
02999 UnmatchedRParen,
03001 NotCompiled
03002 };
03003
03009 ErrorCodes GetErrorCode() const;
03010
03017 PString GetErrorText() const;
03019
03023 BOOL Compile(
03024 const PString & pattern,
03025
int flags = IgnoreCase
03026 );
03034 BOOL Compile(
03035 const
char * cpattern,
03036
int flags = IgnoreCase
03037 );
03038
03039
03041 BOOL Execute(
03042 const PString & str,
03043 PINDEX & start,
03044
int flags = 0
03045 ) const;
03047 BOOL Execute(
03048 const PString & str,
03049 PINDEX & start,
03050 PINDEX & len,
03051
int flags = 0
03052 ) const;
03054 BOOL Execute(
03055 const
char * cstr,
03056 PINDEX & start,
03057
int flags = 0
03058 ) const;
03060 BOOL Execute(
03061 const
char * cstr,
03062 PINDEX & start,
03063 PINDEX & len,
03064
int flags = 0
03065 ) const;
03067 BOOL Execute(
03068 const PString & str,
03069
PIntArray & starts,
03070
int flags = 0
03071 ) const;
03073 BOOL Execute(
03074 const PString & str,
03075
PIntArray & starts,
03076
PIntArray & ends,
03077
int flags = 0
03078 ) const;
03080 BOOL Execute(
03081 const
char * cstr,
03082
PIntArray & starts,
03083
int flags = 0
03084 ) const;
03100 BOOL Execute(
03101 const
char * cstr,
03102
PIntArray & starts,
03103
PIntArray & ends,
03104
int flags = 0
03105 ) const;
03107
03116 static PString EscapeString(
03117 const PString & str
03118 );
03120
03121 protected:
03122 PString patternSaved;
03123 int flagsSaved;
03124
03125 void * expression;
03126 int lastError;
03127 };
03128
03129
03130