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 #ifndef OPAL_IAX2_SAFESTRINGS_H
00034 #define OPAL_IAX2_SAFESTRINGS_H
00035
00036 #ifndef _PTLIB_H
00037 #include <ptlib.h>
00038 #endif
00039
00040 #include <opal/buildopts.h>
00041
00042 #if OPAL_IAX2
00043
00044 #ifdef P_USE_PRAGMA
00045 #pragma interface
00046 #endif
00047
00048
00053 class SafeStrings : public PObject
00054 {
00055 PCLASSINFO(SafeStrings, PObject);
00056 public:
00061 SafeStrings();
00062
00064 ~SafeStrings();
00066
00069
00071 void AppendString(const PString & newString,
00072 PBoolean splitString = PFalse
00073 );
00074
00076 void AppendString(const char *newString,
00077 PBoolean splitString = PFalse
00078 ) { PString s(newString); AppendString(s, splitString); }
00079
00081 PBoolean GetNextString(PString & nextString
00082 );
00083
00085 PBoolean IsEmpty();
00086
00088 PBoolean StringsAvailable() { return !IsEmpty(); }
00089
00091 PString GetFirstDeleteAll();
00092
00094 void GetAllDeleteAll(PStringArray & res);
00095
00097 protected:
00099 PMutex accessMutex;
00100
00102 PStringArray data;
00103 };
00104
00106
00107 class SafeString : public PObject
00108 {
00109 PCLASSINFO(SafeString, PObject);
00110 public:
00112 SafeString() { internal = PString::Empty(); }
00113
00115 SafeString(PString newValue) { internal = newValue; }
00116
00118 void operator = (PString newValue);
00119
00121 PString Get() { PWaitAndSignal m(mutex); return internal; }
00122
00124 virtual void PrintOn(ostream & str) const;
00125
00127 operator PString();
00128
00130 void operator += (PString toBeAdded);
00131
00133 PString GetAndDelete();
00134
00136 PBoolean IsEmpty() const;
00137
00138
00139 protected:
00141 PString internal;
00142
00144 PMutex mutex;
00145 };
00146
00148
00149
00150 #endif // OPAL_IAX2
00151
00152 #endif // OPAL_IAX2_SAFESTRINGS_H
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163