safestrings.h
Go to the documentation of this file.
/*
*
*
* Inter Asterisk Exchange 2
*
* Provide string list handling in a thread safe fashion.
*
* Open Phone Abstraction Library (OPAL)
*
* Copyright (c) 2005 Indranet Technologies Ltd.
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is Open Phone Abstraction Library.
*
* The Initial Developer of the Original Code is Indranet Technologies Ltd.
*
* The author of this code is Derek J Smithies
*
* $Revision: 24606 $
* $Author: dereksmithies $
* $Date: 2010-07-28 22:51:05 -0500 (Wed, 28 Jul 2010) $
*/
#ifndef OPAL_IAX2_SAFESTRINGS_H
#define OPAL_IAX2_SAFESTRINGS_H
#ifndef _PTLIB_H
#include <ptlib.h>
#endif
#include <opal/buildopts.h>
#if OPAL_IAX2
#ifdef P_USE_PRAGMA
#pragma interface
#endif
class SafeStrings : public PObject
{
PCLASSINFO(SafeStrings, PObject);
public:
SafeStrings();
~SafeStrings();
void AppendString(const PString & newString,
PBoolean splitString = false
);
void AppendString(const char *newString,
PBoolean splitString = false
) { PString s(newString); AppendString(s, splitString); }
PBoolean GetNextString(PString & nextString
);
PBoolean IsEmpty();
PBoolean StringsAvailable() { return !IsEmpty(); }
PString GetFirstDeleteAll();
void GetAllDeleteAll(PStringArray & res);
protected:
PMutex accessMutex;
PStringArray data;
};
class SafeString : public PObject
{
PCLASSINFO(SafeString, PObject);
public:
SafeString() { internal = PString::Empty(); }
SafeString(PString newValue) { internal = newValue; }
void operator = (PString newValue);
PString Get() { PWaitAndSignal m(mutex); return internal; }
virtual void PrintOn(ostream & str) const;
operator PString();
void operator += (PString toBeAdded);
PString GetAndDelete();
PBoolean IsEmpty() const;
protected:
PString internal;
PMutex mutex;
};
#endif // OPAL_IAX2
#endif // OPAL_IAX2_SAFESTRINGS_H
/* The comment below is magic for those who use emacs to edit this file.
* With the comment below, the tab key does auto indent to 2 spaces.
*
* Local Variables:
* mode:c
* c-basic-offset:2
* End:
*/
SafeStrings::GetAllDeleteAll
void GetAllDeleteAll(PStringArray &res)
SafeStrings::SafeStrings
SafeStrings()
buildopts.h
SafeString::SafeString
SafeString()
Definition: safestrings.h:112
SafeStrings::IsEmpty
PBoolean IsEmpty()
SafeString::GetAndDelete
PString GetAndDelete()
SafeString::operator+=
void operator+=(PString toBeAdded)
SafeString
Definition: safestrings.h:107
SafeStrings::AppendString
void AppendString(const PString &newString, PBoolean splitString=false)
SafeString::operator=
void operator=(PString newValue)
SafeString::SafeString
SafeString(PString newValue)
Definition: safestrings.h:115
SafeStrings::~SafeStrings
~SafeStrings()
SafeString::Get
PString Get()
Definition: safestrings.h:121
SafeString::IsEmpty
PBoolean IsEmpty() const
SafeStrings
Definition: safestrings.h:53
SafeString::mutex
PMutex mutex
Definition: safestrings.h:144
SafeStrings::accessMutex
PMutex accessMutex
Definition: safestrings.h:99
SafeStrings::StringsAvailable
PBoolean StringsAvailable()
Definition: safestrings.h:88
SafeStrings::AppendString
void AppendString(const char *newString, PBoolean splitString=false)
Definition: safestrings.h:76
SafeString::PrintOn
virtual void PrintOn(ostream &str) const
SafeStrings::GetFirstDeleteAll
PString GetFirstDeleteAll()
SafeStrings::GetNextString
PBoolean GetNextString(PString &nextString)
SafeStrings::data
PStringArray data
Definition: safestrings.h:102