#include "unix/ptlib/contain.h"
#include "pmachdep.h"
#include <unistd.h>
#include <ctype.h>
#include <limits.h>
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <iomanip>
#include <iostream>
#include <sstream>
#include <typeinfo>
Go to the source code of this file.
Classes | |
class | PTrace |
class | PTrace::Block |
class | PObject |
Defines | |
#define | P_REMOVE_VIRTUAL_INTERNAL_BASE(fn) __inline virtual struct ptlib_virtual_function_changed_or_removed ****** fn { return 0; } |
#define | P_DEPRECATED |
#define | P_REMOVE_VIRTUAL_INTERNAL(type, fn, body) P_REMOVE_VIRTUAL_INTERNAL_BASE(fn) |
#define | P_REMOVE_VIRTUAL_VOID(fn) P_REMOVE_VIRTUAL_INTERNAL(void, fn, {}) |
#define | P_REMOVE_VIRTUAL(type, fn, ret) P_REMOVE_VIRTUAL_INTERNAL(type, fn, { return ret; }) |
#define | PTrue TRUE |
#define | PFalse FALSE |
#define | P_USE_INLINES 0 |
#define | PINLINE |
#define | P_USE_ASSERTS 1 |
#define | __CLASS__ NULL |
#define | PAssert(b, m) PAssertFuncInline((b), __FILE__,__LINE__,__CLASS__,(m)) |
#define | PAssert2(b, c, m) PAssertFuncInline((b), __FILE__,__LINE__,(c),(m)) |
#define | PAssertOS(b) PAssertFuncInline((b), __FILE__,__LINE__,__CLASS__,POperatingSystemError) |
#define | PAssertNULL(p) |
#define | PAssertAlways(m) PAssertFunc(__FILE__,__LINE__,__CLASS__,(m)) |
#define | PAssertAlways2(c, m) PAssertFunc(__FILE__,__LINE__,(c),(m)) |
#define | PError (PGetErrorStream()) |
#define | PTRACING 1 |
#define | PTRACE_PARAM(param) param |
#define | PTRACE_BLOCK(name) PTrace::Block __trace_block_instance(__FILE__, __LINE__, name) |
#define | PTRACE_LINE() |
#define | PTRACE(level, args) |
#define | PTRACE_IF(level, cond, args) |
#define | PMEMORY_HEAP 0 |
#define | PNEW new |
#define | PNEW_AND_DELETE_FUNCTIONS |
#define | runtime_malloc(s) malloc(s) |
#define | runtime_free(p) free(p) |
#define | PMEMORY_IGNORE_ALLOCATIONS_FOR_SCOPE |
#define | PMEMORY_ALLOCATION_BREAKPOINT(point) |
#define | PCLASSINFO(cls, par) |
#define | PIsDescendant(ptr, cls) (dynamic_cast<const cls *>(ptr) != NULL) |
#define | PIsDescendantStr(ptr, str) ((ptr)->InternalIsDescendant(str)) |
#define | PRemoveConst(cls, ptr) (const_cast<cls*>(ptr)) |
#define | PDownCast(cls, ptr) PAssertCast<cls>(dynamic_cast<cls*>(ptr),__FILE__,__LINE__) |
#define | PDECLARE_CLASS(cls, par) class cls : public par { PCLASSINFO(cls, par) |
#define | PANSI_CHAR 1 |
#define | PLITTLE_ENDIAN 2 |
#define | PBIG_ENDIAN 3 |
#define | PI_SAME(name, type) |
#define | PI_LOOP(src, dst) |
#define | PI_DIFF(name, type) |
#define | PCHAR8 PANSI_CHAR |
#define | PARRAYSIZE(array) ((PINDEX)(sizeof(array)/sizeof(array[0]))) |
#define | PMIN(v1, v2) ((v1) < (v2) ? (v1) : (v2)) |
#define | PMAX(v1, v2) ((v1) > (v2) ? (v1) : (v2)) |
#define | PABS(v) ((v) < 0 ? -(v) : (v)) |
Typedefs | |
typedef BOOL | PBoolean |
Enumerations | |
enum | PStandardAssertMessage { PLogicError, POutOfMemory, PNullPointerReference, PInvalidCast, PInvalidArrayIndex, PInvalidArrayElement, PStackEmpty, PUnimplementedFunction, PInvalidParameter, POperatingSystemError, PChannelNotOpen, PUnsupportedFeature, PInvalidWindow, PMaxStandardAssertMessage } |
Standard assert messages for the PAssert macro. More... | |
Functions | |
void | PAssertFunc (const char *file, int line, const char *className, PStandardAssertMessage msg) |
void | PAssertFunc (const char *file, int line, const char *className, const char *msg) |
void | PAssertFunc (const char *full_msg) |
bool | PAssertFuncInline (bool b, const char *file, int line, const char *className, PStandardAssertMessage msg) |
bool | PAssertFuncInline (bool b, const char *file, int line, const char *className, const char *msg) |
ostream & | PGetErrorStream () |
void | PSetErrorStream (ostream *strm) |
template<class BaseClass > | |
BaseClass * | PAssertCast (BaseClass *obj, const char *file, int line) |
PI_SAME (PChar8, char) | |
PI_SAME (PInt8, char) | |
PI_SAME (PUInt8, unsigned char) |
#define __CLASS__ NULL |
#define P_DEPRECATED |
#define P_REMOVE_VIRTUAL | ( | type, | |||
fn, | |||||
ret | ) | P_REMOVE_VIRTUAL_INTERNAL(type, fn, { return ret; }) |
#define P_REMOVE_VIRTUAL_INTERNAL | ( | type, | |||
fn, | |||||
body | ) | P_REMOVE_VIRTUAL_INTERNAL_BASE(fn) |
#define P_REMOVE_VIRTUAL_INTERNAL_BASE | ( | fn | ) | __inline virtual struct ptlib_virtual_function_changed_or_removed ****** fn { return 0; } |
#define P_REMOVE_VIRTUAL_VOID | ( | fn | ) | P_REMOVE_VIRTUAL_INTERNAL(void, fn, {}) |
#define P_USE_ASSERTS 1 |
#define P_USE_INLINES 0 |
#define PABS | ( | v | ) | ((v) < 0 ? -(v) : (v)) |
#define PANSI_CHAR 1 |
#define PARRAYSIZE | ( | array | ) | ((PINDEX)(sizeof(array)/sizeof(array[0]))) |
#define PAssert | ( | b, | |||
m | ) | PAssertFuncInline((b), __FILE__,__LINE__,__CLASS__,(m)) |
This macro is used to assert that a condition must be PTrue. If the condition is PFalse then an assert function is called with the source file and line number the macro was instantiated on, plus the message described by the msg parameter. This parameter may be either a standard value from the PStandardAssertMessage enum or a literal string.
Referenced by PSafeColl< PArray< Base >, Base >::Append(), PFactory< AbstractClass, KeyType >::GetInstance(), PAbstractList::GetReferenceAt(), PBaseArray< T >::operator[](), PAbstractList::PAbstractList(), PThreadPool< Work_T >::RemoveWork(), PSafeDictionaryBase< PDictionary< Key, Base >, Key, Base >::SetAt(), and PStack< PStringStream >::Top().
#define PAssert2 | ( | b, | |||
c, | |||||
m | ) | PAssertFuncInline((b), __FILE__,__LINE__,(c),(m)) |
This macro is used to assert that a condition must be PTrue. If the condition is PFalse then an assert function is called with the source file and line number the macro was instantiated on, plus the message described by the msg parameter. This parameter may be either a standard value from the PStandardAssertMessage enum or a literal string. The c parameter specifies the class name that the error occurred in
#define PAssertAlways | ( | m | ) | PAssertFunc(__FILE__,__LINE__,__CLASS__,(m)) |
This macro is used to assert immediately. The assert function is called with the source file and line number the macro was instantiated on, plus the message described by the msg parameter. This parameter may be either a standard value from the PStandardAssertMessage enum or a literal string.
Referenced by PChannel::operator=(), and PChannel::PChannel().
#define PAssertAlways2 | ( | c, | |||
m | ) | PAssertFunc(__FILE__,__LINE__,(c),(m)) |
This macro is used to assert immediately. The assert function is called with the source file and line number the macro was instantiated on, plus the message described by the msg parameter. This parameter may be either a standard value from the PStandardAssertMessage enum or a literal string.
#define PAssertNULL | ( | p | ) |
(((p)!=NULL)?(p): \ (PAssertFunc(__FILE__,__LINE__, __CLASS__, PNullPointerReference),(p)))
This macro is used to assert that a pointer must be non-null. If the pointer is NULL then an assert function is called with the source file and line number the macro was instantiated on, plus the message described by the PNullPointerReference value in the PStandardAssertMessage enum.
Note that this evaluates the expression defined by ptr twice. To prevent incorrect behaviour with this, the macro will assume that the ptr parameter is an L-Value.
Referenced by PList< PNotifier >::back(), PList< PNotifier >::front(), PContainer::GetSize(), PContainer::IsUnique(), PList< T >::iterator_base::Next(), PNotifier::operator()(), PSmartPtr< T >::operator*(), PSafePtr< PMonitoredSockets >::operator*(), PSmartPtr< T >::operator->(), PSafePtr< PMonitoredSockets >::operator->(), PNotifierFunction::PNotifierFunction(), PList< T >::iterator_base::Prev(), and PList< T >::iterator_base::Ptr().
#define PAssertOS | ( | b | ) | PAssertFuncInline((b), __FILE__,__LINE__,__CLASS__,POperatingSystemError) |
This macro is used to assert that an operating system call succeeds. If the condition is PFalse then an assert function is called with the source file and line number the macro was instantiated on, plus the message described by the POperatingSystemError value in the PStandardAssertMessage enum.
#define PBIG_ENDIAN 3 |
#define PCHAR8 PANSI_CHAR |
#define PCLASSINFO | ( | cls, | |||
par | ) |
public: \ static inline const char * Class() \ { return #cls; } \ virtual PBoolean InternalIsDescendant(const char * clsName) const \ { return strcmp(clsName, cls::Class()) == 0 || par::InternalIsDescendant(clsName); } \ virtual const char * GetClass(unsigned ancestor = 0) const \ { return ancestor > 0 ? par::GetClass(ancestor-1) : cls::Class(); } \ virtual Comparison CompareObjectMemoryDirect(const PObject & _obj) const \ { return (Comparison)memcmp(this, &_obj, sizeof(cls)); } \ PNEW_AND_DELETE_FUNCTIONS
Declare all the standard PWlib class information. This macro is used to provide the basic run-time typing capability needed by the library. All descendent classes from the PObject class require these functions for correct operation. Either use this macro or the PDECLARE_CLASS macro.
The use of the PDECLARE_CLASS macro is no longer recommended for reasons of compatibility with documentation systems.
#define PDECLARE_CLASS | ( | cls, | |||
par | ) | class cls : public par { PCLASSINFO(cls, par) |
Declare a class with PWLib class information. This macro is used to declare a new class with a single public ancestor. It starts the class declaration and then uses the PCLASSINFO macro to get all the run-time type functions.
The use of this macro is no longer recommended for reasons of compatibility with documentation systems.
#define PDownCast | ( | cls, | |||
ptr | ) | PAssertCast<cls>(dynamic_cast<cls*>(ptr),__FILE__,__LINE__) |
#define PError (PGetErrorStream()) |
This macro is used to access the platform specific error output stream. This is to be used in preference to assuming cerr is always available. On Unix platforms this {} cerr but for MS-Windows this is another stream that uses the OutputDebugString() Windows API function. Note that a MS-DOS or Windows NT console application would still use cerr.
The PError stream would normally only be used for debugging information as a suitable display is not always available in windowed environments.
The macro is a wrapper for a global variable PErrorStream which is a pointer to an ostream. The variable is initialised to cerr for all but MS-Windows and NT GUI applications. An application could change this pointer to a ofstream variable of PError output is wished to be redirected to a file.
#define PFalse FALSE |
Referenced by PDevicePluginAdapter< DeviceBase >::CreateFactory(), PSafeCollection::DisallowDeleteObjects(), PCollection::DisallowDeleteObjects(), PIPSocket::InterfaceEntry::HasIP6Address(), PPluginModuleManager::LoadPlugin(), PSharedPtr< T >::MakeUnique(), PFile::PFile(), PFactory< AbstractClass, KeyType >::RegisterAs_Internal(), and PIPSocket::SetCaptureReceiveToAddress().
#define PI_DIFF | ( | name, | |||
type | ) |
struct name { \ name() : data(0) { } \ name(type value) : data(0) { operator=(value); } \ name(const name & value) : data(value.data) { } \ name & operator =(type value) { PI_LOOP(value, data); return *this; } \ name & operator =(const name & value) { data = value.data; return *this; } \ operator type() const { type value; PI_LOOP(data, value); return value; } \ friend ostream & operator<<(ostream & s, const name & value) { return s << (type)value; } \ friend istream & operator>>(istream & s, name & v) { type val; s >> val; v = val; return s; } \ private: type data; \ }
#define PI_LOOP | ( | src, | |||
dst | ) |
BYTE *s = ((BYTE *)&src)+sizeof(src); BYTE *d = (BYTE *)&dst; \ while (s != (BYTE *)&src) *d++ = *--s;
#define PI_SAME | ( | name, | |||
type | ) |
struct name { \ name() : data(0) { } \ name(type value) : data(value) { } \ name(const name & value) : data(value.data) { } \ name & operator =(type value) { data = value; return *this; } \ name & operator =(const name & value) { data = value.data; return *this; } \ operator type() const { return data; } \ friend ostream & operator<<(ostream & s, const name & v) { return s << v.data; } \ friend istream & operator>>(istream & s, name & v) { return s >> v.data; } \ private: type data; \ }
#define PINLINE |
#define PIsDescendant | ( | ptr, | |||
cls | ) | (dynamic_cast<const cls *>(ptr) != NULL) |
Referenced by PSafePtrCast().
#define PIsDescendantStr | ( | ptr, | |||
str | ) | ((ptr)->InternalIsDescendant(str)) |
#define PLITTLE_ENDIAN 2 |
#define PMAX | ( | v1, | |||
v2 | ) | ((v1) > (v2) ? (v1) : (v2)) |
#define PMEMORY_ALLOCATION_BREAKPOINT | ( | point | ) |
#define PMEMORY_HEAP 0 |
#define PMEMORY_IGNORE_ALLOCATIONS_FOR_SCOPE |
#define PMIN | ( | v1, | |||
v2 | ) | ((v1) < (v2) ? (v1) : (v2)) |
#define PNEW new |
Referenced by PStringDictionary< K >::Clone(), PASNGauge::Clone(), PASNCounter::Clone(), PASNTimeTicks::Clone(), PASNIPAddress::Clone(), PTime::Clone(), PTimeInterval::Clone(), PSortedList< T >::Clone(), PStack< PStringStream >::Clone(), PQueue< T >::Clone(), PList< PNotifier >::Clone(), POrdinalDictionary< K >::Clone(), PDictionary< POrdinalKey, PThread >::Clone(), PSet< T >::Clone(), PBaseArray< T >::Clone(), PFactory< AbstractClass, KeyType >::Register(), PStringDictionary< K >::SetAt(), PMIMEInfo::SetAt(), POrdinalDictionary< K >::SetAt(), PStringDictionary< K >::SetDataAt(), and POrdinalDictionary< K >::SetDataAt().
#define PNEW_AND_DELETE_FUNCTIONS |
#define PRemoveConst | ( | cls, | |||
ptr | ) | (const_cast<cls*>(ptr)) |
#define PTRACE | ( | level, | |||
args | ) |
if (PTrace::CanTrace(level)) \ PTrace::Begin(level, __FILE__, __LINE__) << args << PTrace::End; \ else (void)0
Output trace. This macro outputs a trace of any information needed, using standard stream output operators. The output is only made if the trace level set by the PSetTraceLevel function is greater than or equal to the level argument.
Referenced by PThreadPool< Work_T >::AddWork(), and PLoadPluginDirectory().
#define PTRACE_BLOCK | ( | name | ) | PTrace::Block __trace_block_instance(__FILE__, __LINE__, name) |
Trace an execution block. This macro creates a trace variable for tracking the entry and exit of program blocks. It creates an instance of the PTraceBlock class that will output a trace message at the line PTRACE_BLOCK is called and then on exit from the scope it is defined in.
#define PTRACE_IF | ( | level, | |||
cond, | |||||
args | ) |
if ((PTrace::CanTrace(level) && (cond))) \ PTrace::Begin(level, __FILE__, __LINE__) << args << PTrace::End; \ else (void)0
Output trace on condition. This macro outputs a trace of any information needed, using standard stream output operators. The output is only made if the trace level set by the PSetTraceLevel function is greater than or equal to the level argument and the conditional is PTrue. Note the conditional is only evaluated if the trace level is sufficient.
#define PTRACE_LINE | ( | ) |
if (PTrace::CanTrace(1)) \ PTrace::Begin(1, __FILE__, __LINE__) << __FILE__ << '(' << __LINE__ << ')' << PTrace::End; \ else (void)0
Trace the execution of a line. This macro outputs a trace of a source file line execution.
#define PTRACE_PARAM | ( | param | ) | param |
#define PTRACING 1 |
#define PTrue TRUE |
#define runtime_free | ( | p | ) | free(p) |
#define runtime_malloc | ( | s | ) | malloc(s) |
typedef BOOL PBoolean |
Standard assert messages for the PAssert macro.
BaseClass* PAssertCast | ( | BaseClass * | obj, | |
const char * | file, | |||
int | line | |||
) | [inline] |
References PAssertFunc(), and PInvalidCast.
void PAssertFunc | ( | const char * | full_msg | ) |
void PAssertFunc | ( | const char * | file, | |
int | line, | |||
const char * | className, | |||
const char * | msg | |||
) |
void PAssertFunc | ( | const char * | file, | |
int | line, | |||
const char * | className, | |||
PStandardAssertMessage | msg | |||
) |
Referenced by PAssertCast(), and PAssertFuncInline().
bool PAssertFuncInline | ( | bool | b, | |
const char * | file, | |||
int | line, | |||
const char * | className, | |||
const char * | msg | |||
) | [inline] |
References PAssertFunc().
bool PAssertFuncInline | ( | bool | b, | |
const char * | file, | |||
int | line, | |||
const char * | className, | |||
PStandardAssertMessage | msg | |||
) | [inline] |
References PAssertFunc().
ostream& PGetErrorStream | ( | ) |
Get the stream being used for error output. This stream is used for all trace output using the various trace functions and macros.
PI_SAME | ( | PUInt8 | , | |
unsigned | char | |||
) |
PI_SAME | ( | PInt8 | , | |
char | ||||
) |
PI_SAME | ( | PChar8 | , | |
char | ||||
) |
void PSetErrorStream | ( | ostream * | strm | ) |
Set the stream to be used for error output. This stream is used for all error output using the PError macro.
strm | New stream for error output |