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 #ifndef SAFESTRINGS_H
00050 #define SAFESTRINGS_H
00051
00052 #ifndef _PTLIB_H
00053 #include <ptlib.h>
00054 #endif
00055
00056 #ifdef P_USE_PRAGMA
00057 #pragma interface
00058 #endif
00059
00060
00065 class SafeStrings : public PObject
00066 {
00067 PCLASSINFO(SafeStrings, PObject);
00068 public:
00073 SafeStrings();
00074
00076 ~SafeStrings();
00078
00081
00083 void AppendString(const PString & newString,
00084 BOOL splitString = FALSE
00085 );
00086
00088 void AppendString(const char *newString,
00089 BOOL splitString = FALSE
00090 ) { PString s(newString); AppendString(s, splitString); }
00091
00093 BOOL GetNextString(PString & nextString
00094 );
00095
00097 BOOL IsEmpty();
00098
00100 BOOL StringsAvailable() { return !IsEmpty(); }
00101
00103 PString GetFirstDeleteAll();
00104
00106 void GetAllDeleteAll(PStringArray & res);
00107
00109 protected:
00111 PMutex accessMutex;
00112
00114 PStringArray data;
00115 };
00116
00118
00119 class SafeString : public PObject
00120 {
00121 PCLASSINFO(SafeString, PObject);
00122 public:
00124 SafeString() { internal = PString::Empty(); }
00125
00127 SafeString(PString newValue) { internal = newValue; }
00128
00130 void operator = (PString newValue);
00131
00133 PString Get() { PWaitAndSignal m(mutex); return internal; }
00134
00136 virtual void PrintOn(ostream & str) const;
00137
00139 operator PString();
00140
00142 void operator += (PString toBeAdded);
00143
00145 PString GetAndDelete();
00146
00148 BOOL IsEmpty() const;
00149
00150
00151 protected:
00153 PString internal;
00154
00156 PMutex mutex;
00157 };
00158
00160
00161 #endif // SAFESTRINGS_H
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172