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 #include <opal/buildopts.h>
00057
00058 #ifdef P_USE_PRAGMA
00059 #pragma interface
00060 #endif
00061
00062
00067 class SafeStrings : public PObject
00068 {
00069 PCLASSINFO(SafeStrings, PObject);
00070 public:
00075 SafeStrings();
00076
00078 ~SafeStrings();
00080
00083
00085 void AppendString(const PString & newString,
00086 PBoolean splitString = PFalse
00087 );
00088
00090 void AppendString(const char *newString,
00091 PBoolean splitString = PFalse
00092 ) { PString s(newString); AppendString(s, splitString); }
00093
00095 PBoolean GetNextString(PString & nextString
00096 );
00097
00099 PBoolean IsEmpty();
00100
00102 PBoolean StringsAvailable() { return !IsEmpty(); }
00103
00105 PString GetFirstDeleteAll();
00106
00108 void GetAllDeleteAll(PStringArray & res);
00109
00111 protected:
00113 PMutex accessMutex;
00114
00116 PStringArray data;
00117 };
00118
00120
00121 class SafeString : public PObject
00122 {
00123 PCLASSINFO(SafeString, PObject);
00124 public:
00126 SafeString() { internal = PString::Empty(); }
00127
00129 SafeString(PString newValue) { internal = newValue; }
00130
00132 void operator = (PString newValue);
00133
00135 PString Get() { PWaitAndSignal m(mutex); return internal; }
00136
00138 virtual void PrintOn(ostream & str) const;
00139
00141 operator PString();
00142
00144 void operator += (PString toBeAdded);
00145
00147 PString GetAndDelete();
00148
00150 PBoolean IsEmpty() const;
00151
00152
00153 protected:
00155 PString internal;
00156
00158 PMutex mutex;
00159 };
00160
00162
00163 #endif // SAFESTRINGS_H
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174