object.h File Reference
`#include "unix/ptlib/contain.h"`
`#include <stdio.h>`
`#include <stdarg.h>`
`#include <stdlib.h>`
`#include <string.h>`
`#include <string>`
`#include <iomanip>`
`#include <iostream>`
`#include <sstream>`
`#include <vector>`
`#include <list>`
`#include <map>`
`#include <algorithm>`
`#include <typeinfo>`

Go to the source code of this file.

## Classes

class | PTrace
| Class to encapsulate tracing functions. More...
class | PTrace::Block
| Class to trace Execution blocks. More...
class | PMemoryHeap
| Memory heap checking class. More...
struct | PMemoryHeap::State
class | PMemoryHeap::Wrapper
struct | PMemoryHeap::Header
class | PMemoryHeapIgnoreAllocationsForScope
class | PMemoryAllocationBreakpoint
struct | PAllocatorTemplate< GnuAllocator, Type >
struct | PFixedPoolAllocator< Type >
struct | PVariablePoolAllocator< Type >
class | PObject
| Ultimate parent class for all objects in the class library. More...
struct | PIntSameOrder< type >
struct | PIntReversedOrder< type >

## Macros

#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, msg) PAssertFuncInline((b), __FILE__,__LINE__,__CLASS__,(msg))
| This macro is used to assert that a condition must be true. More...
#define | PAssert2(b, cls, msg) PAssertFuncInline((b), __FILE__,__LINE__,(cls),(msg))
| This macro is used to assert that a condition must be true. More...
#define | PAssertOS(b) PAssertFuncInline((b), __FILE__,__LINE__,__CLASS__,POperatingSystemError)
| This macro is used to assert that an operating system call succeeds. More...
#define | PAssertNULL(ptr)
| This macro is used to assert that a pointer must be non-null. More...
#define | PAssertAlways(msg) PAssertFunc(__FILE__,__LINE__,__CLASS__,(msg))
| This macro is used to assert immediately. More...
#define | PAssertAlways2(cls, msg) PAssertFunc(__FILE__,__LINE__,(cls),(msg))
| This macro is used to assert immediately. More...
#define | PError (PGetErrorStream())
| This macro is used to access the platform specific error output stream. More...
#define | PTRACING 1
#define | PTRACE_PARAM(param) param
#define | PTRACE_BLOCK(name) PTrace::Block __trace_block_instance(__FILE__, __LINE__, name)
| Trace an execution block. More...
#define | PTRACE_LINE()
| Trace the execution of a line. More...
#define | PTRACE(level, args)
| Output trace. More...
#define | PTRACE_IF(level, cond, args)
| Output trace on condition. More...
#define | PMEMORY_HEAP 1
#define | malloc(s) PMemoryHeap::Allocate(s, __FILE__, __LINE__, NULL)
| Override of system call for memory check system. More...
#define | calloc(n, s) PMemoryHeap::Allocate(n, s, __FILE__, __LINE__)
| Override of system call for memory check system. More...
#define | realloc(p, s) PMemoryHeap::Reallocate(p, s, __FILE__, __LINE__)
| Override of system call for memory check system. More...
#define | free(p) PMemoryHeap::Deallocate(p, NULL)
| Override of system call for memory check system. More...
#define | cfree(p) PMemoryHeap::Deallocate(p, NULL)
| Override of system call for memory check system. More...
#define | PNEW new (__FILE__, __LINE__)
| Macro for overriding system default `new` operator. More...
#define | PSPECIAL_DELETE_FUNCTION
#define | PNEW_AND_DELETE_FUNCTIONS
#define | PMEMORY_IGNORE_ALLOCATIONS_FOR_SCOPE PMemoryHeapIgnoreAllocationsForScope instance_PMemoryHeapIgnoreAllocationsForScope
#define | PMEMORY_ALLOCATION_BREAKPOINT(point) PMemoryAllocationBreakpoint PMemoryAllocationBreakpointInstance(point)
#define | GCC_VERSION
#define | PDECLARE_POOL_ALLOCATOR()
#define | PDEFINE_POOL_ALLOCATOR(cls)
#define | PCLASSINFO(cls, par)
| Declare all the standard PTLib class information. More...
#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)
| Declare a class with PWLib class information. More...
#define | PANSI_CHAR 1
#define | PLITTLE_ENDIAN 2
#define | PBIG_ENDIAN 3
#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
typedef PIntSameOrder< char > | PChar8
typedef PIntSameOrder< char > | PInt8
typedef PIntSameOrder< unsigned char > | PUInt8

## 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 ()
| Get the stream being used for error output. More...
void | PSetErrorStream (ostream *strm)
| Set the stream to be used for error output. More...
void * | runtime_malloc (size_t bytes)
| Allocate memory for the run time library. More...
void | runtime_free (void *ptr)
| Free memory allocated by run time library. More...
void * | operator new (size_t nSize, const char *file, int line)
void * | operator new[] (size_t nSize, const char *file, int line)
void * | operator new (size_t nSize)
void * | operator new[] (size_t nSize)
void | operator delete (void *ptr)
void | operator delete[] (void *ptr)
template<class BaseClass >
BaseClass * | PAssertCast (BaseClass *obj, const char *file, int line)

## Macro Definition Documentation

## __CLASS__

#define __CLASS__ NULL

## calloc

#define calloc | ( |  | n,
|  |  | s
| ) |  | PMemoryHeap::Allocate(n, s, __FILE__, __LINE__)

Override of system call for memory check system.

This macro is used to allocate memory via the memory check system selected with the `PMEMORY_CHECK` compile time option. It will include the source file and line into the memory allocation to allow the PMemoryHeap class to keep track of the memory block.

## cfree

#define cfree | ( |  | p | ) | PMemoryHeap::Deallocate(p, NULL)

Override of system call for memory check system.

This macro is used to deallocate memory via the memory check system selected with the `PMEMORY_CHECK` compile time option. It will include the source file and line into the memory allocation to allow the PMemoryHeap class to keep track of the memory block.

## free

#define free | ( |  | p | ) | PMemoryHeap::Deallocate(p, NULL)

Override of system call for memory check system.

This macro is used to deallocate memory via the memory check system selected with the `PMEMORY_CHECK` compile time option. It will include the source file and line into the memory allocation to allow the PMemoryHeap class to keep track of the memory block.

Referenced by runtime_free(), and P_fd_set::~P_fd_set().

## GCC_VERSION

#define GCC_VERSION

Value:
(__GNUC__ * 10000 \
+ __GNUC_MINOR__ * 100 \
+ __GNUC_PATCHLEVEL__)

## malloc

#define malloc | ( |  | s | ) | PMemoryHeap::Allocate(s, __FILE__, __LINE__, NULL)

Override of system call for memory check system.

This macro is used to allocate memory via the memory check system selected with the `PMEMORY_CHECK` compile time option. It will include the source file and line into the memory allocation to allow the PMemoryHeap class to keep track of the memory block.

Referenced by runtime_malloc().

## P_DEPRECATED

#define P_DEPRECATED

## P_REMOVE_VIRTUAL

#define P_REMOVE_VIRTUAL | ( |  | type,
|  |  | fn,
|  |  | ret
| ) |  | P_REMOVE_VIRTUAL_INTERNAL(type, fn, { return ret; })

## P_REMOVE_VIRTUAL_INTERNAL

#define P_REMOVE_VIRTUAL_INTERNAL | ( |  | type,
|  |  | fn,
|  |  | body
| ) |  | P_REMOVE_VIRTUAL_INTERNAL_BASE(fn)

## P_REMOVE_VIRTUAL_INTERNAL_BASE

#define P_REMOVE_VIRTUAL_INTERNAL_BASE | ( |  | fn | ) | __inline virtual struct ptlib_virtual_function_changed_or_removed ****** fn { return 0; }

## P_REMOVE_VIRTUAL_VOID

#define P_REMOVE_VIRTUAL_VOID | ( |  | fn | ) | P_REMOVE_VIRTUAL_INTERNAL(void, fn, {})

## P_USE_ASSERTS

#define P_USE_ASSERTS 1

## P_USE_INLINES

#define P_USE_INLINES 0

## PABS

#define PABS | ( |  | v | ) | ((v) < 0 ? -(v) : (v))

## PANSI_CHAR

#define PANSI_CHAR 1

## PARRAYSIZE

#define PARRAYSIZE | ( |  | array | ) | ((PINDEX)(sizeof(array)/sizeof(array[0])))

## PAssert

#define PAssert | ( |  | b,
|  |  | msg
| ) |  | PAssertFuncInline((b), __FILE__,__LINE__,__CLASS__,(msg))

This macro is used to assert that a condition must be true.

If the condition is false 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 >::WorkerBase::Create(), PFactory< AbstractClass, KeyType >::GetInstance(), PBaseArray< char *>::operator[](), PArray< ParamValue >::operator[](), PThreadPool< Work_T >::RemoveWork(), PSafeDictionaryBase< PDictionary< Key, Base >, Key, Base >::SetAt(), PXMLObject::SetParent(), and PStack< T >::Top().

## PAssert2

#define PAssert2 | ( |  | b,
|  |  | cls,
|  |  | msg
| ) |  | PAssertFuncInline((b), __FILE__,__LINE__,(cls),(msg))

This macro is used to assert that a condition must be true.

If the condition is false 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 `cls` parameter specifies the class name that the error occurred in

## PAssertAlways

#define PAssertAlways | ( |  | msg | ) | PAssertFunc(__FILE__,__LINE__,__CLASS__,(msg))

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 PConstantString< ParentString >::AssignContents().

## PAssertAlways2

#define PAssertAlways2 | ( |  | cls,
|  |  | msg
| ) |  | PAssertFunc(__FILE__,__LINE__,(cls),(msg))

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.

## PAssertNULL

#define PAssertNULL | ( |  | ptr | ) |

Value:
(((ptr)!=NULL)?(ptr): \
(PAssertFunc(__FILE__,__LINE__, __CLASS__, PNullPointerReference),(ptr)))
__CLASS__
#define __CLASS__
Definition: object.h:167
PNullPointerReference
A reference was made through a NULL pointer.
Definition: object.h:153
PAssertFunc
void PAssertFunc(const char *file, int line, const char *className, PStandardAssertMessage msg)

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< PMultiPartInfo >::back(), PList< PMultiPartInfo >::front(), PXMLRPCStructBase::GetInitialiser(), PLDAPStructBase::GetInitialiser(), PList< T >::iterator_base::Next(), PNotifierTemplate< INT >::operator()(), PSmartPtr< T >::operator*(), PSafePtr< PMonitoredSockets >::operator*(), PSmartPtr< T >::operator->(), PSafePtr< PMonitoredSockets >::operator->(), PNotifierFunctionTemplate< ParmType >::PNotifierFunctionTemplate(), PList< T >::iterator_base::Prev(), PList< T >::iterator_base::Ptr(), and PFactory< AbstractClass, KeyType >::Register_Internal().

## PAssertOS

#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 false 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.

## PBIG_ENDIAN

#define PBIG_ENDIAN 3

## PCHAR8

#define PCHAR8 PANSI_CHAR

## PCLASSINFO

#define PCLASSINFO | ( |  | cls,
|  |  | par
| ) |  |

Value:
public: \
typedef cls P_thisClass; \
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 PObject::Comparison CompareObjectMemoryDirect(const PObject & obj) const \
{ return PObject::InternalCompareObjectMemoryDirect(this, dynamic_cast<const cls *>(&obj), sizeof(cls)); } \
PNEW_AND_DELETE_FUNCTIONS
PObject::Comparison
Comparison
Result of the comparison operation performed by the Compare() function.
Definition: object.h:1184
PBoolean
BOOL PBoolean
Definition: object.h:102
PObject
Ultimate parent class for all objects in the class library.
Definition: object.h:1118
PObject::InternalCompareObjectMemoryDirect
static Comparison InternalCompareObjectMemoryDirect(const PObject *obj1, const PObject *obj2, PINDEX size)
Internal function caled from CompareObjectMemoryDirect()

Declare all the standard PTLib 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.

Referenced by P_timeval::operator*(), and operator<<().

## PDECLARE_CLASS

#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.

## PDECLARE_POOL_ALLOCATOR

#define PDECLARE_POOL_ALLOCATOR | ( |  | ) |

Value:
void * operator new(size_t nSize); \
void * operator new(size_t nSize, const char * file, int line); \
void operator delete(void * ptr); \
void operator delete(void * ptr, const char *, int)

## PDEFINE_POOL_ALLOCATOR

#define PDEFINE_POOL_ALLOCATOR | ( |  | cls | ) |

Value:
static PFixedPoolAllocator<cls> cls##_allocator; \
void * cls::operator new(size_t) { return cls##_allocator.allocate(1); } \
void * cls::operator new(size_t, const char *, int) { return cls##_allocator.allocate(1); } \
void cls::operator delete(void * ptr) { cls##_allocator.deallocate((cls *)ptr, 1); } \
void cls::operator delete(void * ptr, const char *, int) { cls##_allocator.deallocate((cls *)ptr, 1); }
PAllocatorTemplate< std::allocator< Type >, Type >::deallocate
void deallocate(Type *p, size_t v)
Definition: object.h:996
PAllocatorTemplate< std::allocator< Type >, Type >::allocate
Type * allocate(size_t v)
Definition: object.h:991
PFixedPoolAllocator
Definition: object.h:1021

## PDownCast

#define PDownCast | ( |  | cls,
|  |  | ptr
| ) |  | PAssertCast<cls>(dynamic_cast<cls*>(ptr),__FILE__,__LINE__)

## PError

#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 {is} `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 error stream. The internal variable is initialised to std::cerr for all but MS-Windows and NT GUI applications. An application could change this pointer to a std::ofstream variable of PError output is wished to be redirected to a file.

## PFalse

#define PFalse FALSE

## PINLINE

#define PINLINE

Referenced by PString::operator=().

## PIsDescendant

#define PIsDescendant | ( |  | ptr,
|  |  | cls
| ) |  | (dynamic_cast<const cls *>(ptr) != NULL)

Referenced by PSafePtrCast().

## PIsDescendantStr

#define PIsDescendantStr | ( |  | ptr,
|  |  | str
| ) |  | ((ptr)->InternalIsDescendant(str))

## PLITTLE_ENDIAN

#define PLITTLE_ENDIAN 2

## PMAX

#define PMAX | ( |  | v1,
|  |  | v2
| ) |  | ((v1) > (v2) ? (v1) : (v2))

## PMEMORY_ALLOCATION_BREAKPOINT

#define PMEMORY_ALLOCATION_BREAKPOINT | ( |  | point | ) | PMemoryAllocationBreakpoint PMemoryAllocationBreakpointInstance(point)

## PMEMORY_HEAP

#define PMEMORY_HEAP 1

## PMEMORY_IGNORE_ALLOCATIONS_FOR_SCOPE

#define PMEMORY_IGNORE_ALLOCATIONS_FOR_SCOPE PMemoryHeapIgnoreAllocationsForScope instance_PMemoryHeapIgnoreAllocationsForScope

Referenced by PFactory< AbstractClass, KeyType >::GetInstance(), and PFactory< AbstractClass, KeyType >::Worker< ConcreteClass >::Worker().

## PMIN

#define PMIN | ( |  | v1,
|  |  | v2
| ) |  | ((v1) < (v2) ? (v1) : (v2))

## PNEW

#define PNEW new (__FILE__, __LINE__)

Macro for overriding system default `new` operator.

This macro is used to allocate memory via the memory check system selected with the PMEMORY_CHECK compile time option. It will include the source file and line into the memory allocation to allow the PMemoryHeap class to keep track of the memory block.

This macro could be used instead of the system `new` operator. Or you can place the line

      #define new PNEW

at the begining of the source file, after all declarations that use the `PCLASSINFO` macro.

Referenced by PBaseArray< char *>::Clone(), PASNIPAddress::Clone(), PList< PMultiPartInfo >::Clone(), PASNTimeTicks::Clone(), PASNCounter::Clone(), PASNGauge::Clone(), PSet< T >::Clone(), PQueue< PXML >::Clone(), PStack< T >::Clone(), PDictionary< PString, PNotifierList >::Clone(), PSortedList< T >::Clone(), PArray< ParamValue >::Clone(), POrdinalDictionary< K >::Clone(), PStringDictionary< K >::Clone(), PFactory< AbstractClass, KeyType >::Register(), POrdinalDictionary< K >::SetAt(), PStringDictionary< K >::SetAt(), POrdinalDictionary< K >::SetDataAt(), and PStringDictionary< K >::SetDataAt().

## PNEW_AND_DELETE_FUNCTIONS

#define PNEW_AND_DELETE_FUNCTIONS

Value:
void * operator new(size_t nSize, const char * file, int line) \
{ return PMemoryHeap::Allocate(nSize, file, line, Class()); } \
void * operator new(size_t nSize) \
{ return PMemoryHeap::Allocate(nSize, NULL, 0, Class()); } \
void operator delete(void * ptr) \
{ PMemoryHeap::Deallocate(ptr, Class()); } \
void * operator new(size_t, void * placement) \
{ return placement; } \
void operator delete(void *, void *) \
{ } \
void * operator new[](size_t nSize, const char * file, int line) \
{ return PMemoryHeap::Allocate(nSize, file, line, Class()); } \
void * operator new[](size_t nSize) \
{ return PMemoryHeap::Allocate(nSize, NULL, 0, Class()); } \
void operator delete[](void * ptr) \
{ PMemoryHeap::Deallocate(ptr, Class()); } \
PSPECIAL_DELETE_FUNCTION
PMemoryHeap::Deallocate
static void Deallocate(void *ptr, const char *className)
Free a memory block.
PMemoryHeap::Allocate
static void * Allocate(size_t nSize, const char *file, int line, const char *className)
Allocate a memory block.

## PRemoveConst

#define PRemoveConst | ( |  | cls,
|  |  | ptr
| ) |  | (const_cast<cls*>(ptr))

## PSPECIAL_DELETE_FUNCTION

#define PSPECIAL_DELETE_FUNCTION

## PTRACE

#define PTRACE | ( |  | level,
|  |  | args
| ) |  |

Value:
if (PTrace::CanTrace(level)) \
PTrace::Begin(level, __FILE__, __LINE__) << args << PTrace::End; \
else (void)0
PTrace::End
static ostream & End(ostream &strm)
End a trace output.
PTrace::Begin
static ostream & Begin(unsigned level, const char *fileName, int lineNum)
Begin a trace output.
PTrace::CanTrace
static PBoolean CanTrace(unsigned level)
Determine if the level may cause trace output.

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 SetLevel() function is greater than or equal to the `level` argument.

Referenced by PThreadPool< Work_T >::AddWork(), and PLoadPluginDirectory().

## PTRACE_BLOCK

#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.

## PTRACE_IF

#define PTRACE_IF | ( |  | level,
|  |  | cond,
|  |  | args
| ) |  |

Value:
if ((PTrace::CanTrace(level) && (cond))) \
PTrace::Begin(level, __FILE__, __LINE__) << args << PTrace::End; \
else (void)0
PTrace::End
static ostream & End(ostream &strm)
End a trace output.
PTrace::Begin
static ostream & Begin(unsigned level, const char *fileName, int lineNum)
Begin a trace output.
PTrace::CanTrace
static PBoolean CanTrace(unsigned level)
Determine if the level may cause trace output.

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 SetLevel() function is greater than or equal to the `level` argument and the conditional is true. Note the conditional is only evaluated if the trace level is sufficient.

## PTRACE_LINE

#define PTRACE_LINE | ( |  | ) |

Value:
if (PTrace::CanTrace(1)) \
PTrace::Begin(1, __FILE__, __LINE__) << __FILE__ << '(' << __LINE__ << ')' << PTrace::End; \
else (void)0
PTrace::End
static ostream & End(ostream &strm)
End a trace output.
PTrace::Begin
static ostream & Begin(unsigned level, const char *fileName, int lineNum)
Begin a trace output.
PTrace::CanTrace
static PBoolean CanTrace(unsigned level)
Determine if the level may cause trace output.

Trace the execution of a line.

This macro outputs a trace of a source file line execution.

## PTRACE_PARAM

#define PTRACE_PARAM | ( |  | param | ) | param

## PTRACING

#define PTRACING 1

## PTrue

#define PTrue TRUE

## realloc

#define realloc | ( |  | p,
|  |  | s
| ) |  | PMemoryHeap::Reallocate(p, s, __FILE__, __LINE__)

Override of system call for memory check system.

This macro is used to allocate memory via the memory check system selected with the `PMEMORY_CHECK` compile time option. It will include the source file and line into the memory allocation to allow the PMemoryHeap class to keep track of the memory block.

## Typedef Documentation

## PBoolean

typedef BOOL PBoolean

## PChar8

typedef PIntSameOrder<char> PChar8

## PInt8

typedef PIntSameOrder<char> PInt8

## PUInt8

typedef PIntSameOrder<unsigned char> PUInt8

## Enumeration Type Documentation

## PStandardAssertMessage

enum PStandardAssertMessage

Standard assert messages for the PAssert macro.

Enumerator
PLogicError | A logic error occurred.
POutOfMemory | A new or malloc failed.
PNullPointerReference | A reference was made through a NULL pointer.
PInvalidCast | An invalid cast to descendant is required.
PInvalidArrayIndex | An index into an array was negative.
PInvalidArrayElement | A NULL array element object was accessed.
PStackEmpty | A Pop() was made of a stack with no elements.
PUnimplementedFunction | Funtion is not implemented.
PInvalidParameter | Invalid parameter was passed to a function.
POperatingSystemError | Error was returned by Operating System.
PChannelNotOpen | Operation attempted when channel not open.
PUnsupportedFeature | Feature is not supported.
PInvalidWindow | Access through invalid window.
PMaxStandardAssertMessage | Number of standard assert message.

## Function Documentation

## operator delete()

void operator delete | ( | void * | ptr | ) |

## operator delete[]()

void operator delete[] | ( | void * | ptr | ) |

## operator new() [1/2]

void* operator new | ( | size_t | nSize,
|  | const char * | file,
|  | int | line
| ) |  |

inline

References PMemoryHeap::Allocate().

## operator new() [2/2]

void* operator new | ( | size_t | nSize | ) |

## operator new[]() [1/2]

void* operator new[] | ( | size_t | nSize,
|  | const char * | file,
|  | int | line
| ) |  |

inline

References PMemoryHeap::Allocate(), and PMemoryHeap::Deallocate().

## operator new[]() [2/2]

void* operator new[] | ( | size_t | nSize | ) |

## PAssertCast()

template<class BaseClass >

BaseClass* PAssertCast | ( | BaseClass * | obj,
|  | const char * | file,
|  | int | line
| ) |  |

inline

References PAssertFunc(), and PInvalidCast.

## PAssertFunc() [1/3]

void PAssertFunc | ( | const char * | file,
|  | int | line,
|  | const char * | className,
|  | PStandardAssertMessage | msg
| ) |  |

Referenced by PAssertCast(), and PAssertFuncInline().

## PAssertFunc() [2/3]

void PAssertFunc | ( | const char * | file,
|  | int | line,
|  | const char * | className,
|  | const char * | msg
| ) |  |

## PAssertFunc() [3/3]

void PAssertFunc | ( | const char * | full_msg | ) |

## PAssertFuncInline() [1/2]

bool PAssertFuncInline | ( | bool | b,
|  | const char * | file,
|  | int | line,
|  | const char * | className,
|  | PStandardAssertMessage | msg
| ) |  |

inline

References PAssertFunc().

## PAssertFuncInline() [2/2]

bool PAssertFuncInline | ( | bool | b,
|  | const char * | file,
|  | int | line,
|  | const char * | className,
|  | const char * | msg
| ) |  |

inline

References PAssertFunc().

## PGetErrorStream()

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.

## PSetErrorStream()

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.

Parameters

  strm | New stream for error output

## runtime_free()

void runtime_free | ( | void * | ptr | ) |

inline

Free memory allocated by run time library.

This version of free is used for data that is not allocated using the memory check system, ie was malloc'ed inside the C run time library.

Parameters

  ptr | Memory block to free

References free.

## runtime_malloc()

void* runtime_malloc | ( | size_t | bytes | ) |

inline

Allocate memory for the run time library.

This version of free is used for data that is not to be allocated using the memory check system, ie will be free'ed inside the C run time library.

Parameters

  bytes | Size of block to allocate

References malloc.