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 #ifndef SAFESTRINGS_H
00044 #define SAFESTRINGS_H
00045
00046 #include <ptlib.h>
00047
00048 #ifdef P_USE_PRAGMA
00049 #pragma interface
00050 #endif
00051
00052
00057 class SafeStrings : public PObject
00058 {
00059 PCLASSINFO(SafeStrings, PObject);
00060 public:
00065 SafeStrings();
00066
00068 ~SafeStrings();
00070
00073
00075 void AppendString(PString & newString,
00076 BOOL splitString = FALSE
00077 );
00078
00080 void AppendString(const char *newString,
00081 BOOL splitString = FALSE
00082 ) { PString s(newString); AppendString(s, splitString); }
00083
00085 BOOL GetNextString(PString & nextString
00086 );
00087
00089 BOOL IsEmpty();
00090
00092 PString GetFirstDeleteAll();
00093
00095 void GetAllDeleteAll(PStringArray & res);
00096
00098 protected:
00100 PMutex accessMutex;
00101
00103 PStringArray data;
00104 };
00105
00107
00108 class SafeString : public PObject
00109 {
00110 PCLASSINFO(SafeString, PObject);
00111 public:
00113 SafeString() { internal = PString::Empty(); }
00114
00116 SafeString(PString newValue) { internal = newValue; }
00117
00119 void operator = (PString newValue);
00120
00122 PString Get() { PWaitAndSignal m(mutex); return internal; }
00123
00125 virtual void PrintOn(ostream & str) const;
00126
00128 operator PString();
00129
00131 void operator += (PString toBeAdded);
00132
00134 PString GetAndDelete();
00135
00137 BOOL IsEmpty() const;
00138
00139
00140 protected:
00142 PString internal;
00143
00145 PMutex mutex;
00146 };
00147
00149
00150 #endif // SAFESTRINGS_H
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161