PObject Class Reference

Ultimate parent class for all objects in the class library. More...

`#include <object.h>`

Inheritance diagram for PObject:

## Public Member Functions

virtual | ~PObject ()
Miscellaneous functions
virtual PObject * | Clone () const
| Create a copy of the class on the heap. More...
virtual PINDEX | HashFunction () const
| This function yields a hash value required by the `PDictionary` class. More...

## Protected Member Functions

| PObject ()
| Constructor for PObject, made protected so cannot ever create one on its own. More...

## Run Time Type functions

virtual const char * | GetClass (unsigned ancestor=0) const
| Get the current dynamic type of the object instance. More...
PBoolean | IsClass (const char *cls) const
virtual PBoolean | InternalIsDescendant (const char *clsName) const
| Determine if the dynamic type of the current instance is a descendent of the specified class. More...
static const char * | Class ()
| Get the name of the class as a C string. More...

## Comparison functions

enum | Comparison { LessThan = -1, EqualTo = 0, GreaterThan = 1 }
| Result of the comparison operation performed by the `Compare()` function. More...
virtual Comparison | Compare (const PObject &obj) const
| Compare the two objects and return their relative rank. More...
virtual Comparison | CompareObjectMemoryDirect (const PObject &obj) const
| Determine the byte wise comparison of two objects. More...
bool | operator== (const PObject &obj) const
| Compare the two objects. More...
bool | operator!= (const PObject &obj) const
| Compare the two objects. More...
bool | operator< (const PObject &obj) const
| Compare the two objects. More...
bool | operator> (const PObject &obj) const
| Compare the two objects. More...
bool | operator<= (const PObject &obj) const
| Compare the two objects. More...
bool | operator>= (const PObject &obj) const
| Compare the two objects. More...
static Comparison | InternalCompareObjectMemoryDirect (const PObject *obj1, const PObject *obj2, PINDEX size)
| Internal function caled from CompareObjectMemoryDirect() More...

## I/O functions

virtual void | PrintOn (ostream &strm) const
| Output the contents of the object to the stream. More...
virtual void | ReadFrom (istream &strm)
| Input the contents of the object from the stream. More...
ostream & | operator<< (ostream &strm, const PObject &obj)
| Global function for using the standard << operator on objects descended from PObject. More...
istream & | operator>> (istream &strm, PObject &obj)
| Global function for using the standard >> operator on objects descended from PObject. More...

## Detailed Description

Ultimate parent class for all objects in the class library.

This provides functionality provided to all classes, eg run-time types, default comparison operations, simple stream I/O and serialisation support.

## Member Enumeration Documentation

## Comparison

enum PObject::Comparison

Result of the comparison operation performed by the `Compare()` function.

Enumerator
LessThan |
EqualTo |
GreaterThan |

## Constructor & Destructor Documentation

## PObject()

PObject::PObject | ( |  | ) |

inline protected

Constructor for PObject, made protected so cannot ever create one on its own.

## ~PObject()

virtual PObject::~PObject | ( |  | ) |

inline virtual

## Member Function Documentation

## Class()

static const char* PObject::Class | ( |  | ) |

inline static

Get the name of the class as a C string.

This is a static function which returns the type of a specific class.

When comparing class names, always use the `strcmp()` function rather than comparing pointers. The pointers are not necessarily the same over compilation units depending on the compiler, platform etc.

Returns
  pointer to C string literal.

## Clone()

virtual PObject* PObject::Clone | ( |  | ) | const

virtual

Create a copy of the class on the heap.

The exact semantics of the descendent class determine what is required to make a duplicate of the instance. Not all classes can even do a clone operation.

The main user of the clone function is the `PDictionary` class as it requires copies of the dictionary keys.

The default behaviour is for this function to assert.

Returns
  pointer to new copy of the class instance.

Reimplemented in PStringDictionary< K >, PCaselessString, PHTTPMultiSimpAuth, PBitArray, PHTTPSimpleAuth, POrdinalDictionary< K >, PArray< T >, PArray< PvCard::Address >, PArray< PBYTEArray >, PArray< PPluginService >, PArray< PvCard::Telephone >, PArray< PvCard::EMail >, PArray< TextValue >, PArray< PDynaLink >, PArray< PXMLRPCVariableBase >, PArray< PODBC::Field >, PArray< ParamValue >, PSortedList< T >, PASN_Set, PDictionary< K, D >, PDictionary< PString, PDynaLink >, PDictionary< PString, XMPP::Presence >, PDictionary< PRFC1155_ObjectName, PRFC1155_ObjectSyntax >, PDictionary< XMPP::JID, PNotifierList >, PDictionary< PString, PXMLRPCVariableBase >, PDictionary< PString, PLDAPAttributeBase >, PDictionary< PString, PNotifierList >, PASN_Sequence, PASN_BMPString, PStack< T >, PASNNull, PQueue< T >, PQueue< PXML >, PASN_OctetString, PSet< T >, PASNObjectID, PASNGauge, PString, PASN_BitString, PASNCounter, PASNTimeTicks, PASN_ObjectId, PList< T >, PASN_Real, PList< PSafeObject >, PList< PNotifier >, PList< PMultiPartInfo >, PASNIPAddress, PSocksUDPSocket, PBaseArray< T >, PBaseArray< struct berval *>, PBaseArray< PObject *>, PBaseArray< char *>, PASN_Enumeration, PASNString, PSocks5Socket, PRFC1155_Opaque, PSNMP_Message, PASNInteger, PRFC1155_TimeTicks, PSNMP_SetRequest_PDU, PASN_Integer, PSocks4Socket, PRFC1155_Gauge, PSNMP_GetResponse_PDU, PASN_Boolean, PRFC1155_Counter, PSNMP_GetNextRequest_PDU, PRFC1155_IpAddress, PSNMP_GetRequest_PDU, PASN_Null, PSNMP_Trap_PDU, PRFC1155_NetworkAddress, PASNObject, PSNMP_PDU, PRFC1155_ApplicationSyntax, PTime, PSNMP_VarBindList, XMPP::BareJID, PSNMP_VarBind, PGloballyUniqueID, PTimeInterval, PTCPSocket, PRFC1155_SimpleSyntax, PSNMP_PDUs, XMPP::JID, POrdinalKey, PRFC1155_ObjectSyntax, and PRFC1155_ObjectName.

Referenced by PASN_Enumeration::GetMaximum(), PASN_BitString::GetSize(), PASN_OctetString::GetSize(), PXMLData::GetString(), PXMLElement::GetSubObject(), PASN_ObjectId::GetValue(), PXMLObject::IsDirty(), PASN_Sequence::operator[](), PASN_Boolean::SetValue(), PASN_Integer::SetValue(), PASN_Real::SetValue(), and PASN_BMPString::SetValueRaw().

## Compare()

virtual Comparison PObject::Compare | ( | const PObject & | obj | ) | const

virtual

Compare the two objects and return their relative rank.

This function is usually overridden by descendent classes to yield the ranking according to the semantics of the object.

The default function is to use the `CompareObjectMemoryDirect()` function to do a byte wise memory comparison of the two objects.

Returns
  `LessThan`, `EqualTo` or `GreaterThan` according to the relative rank of the objects.

Reimplemented in PASN_Array, PArrayObjects, PASN_Sequence, PAbstractSortedList, PASN_Choice, PSafePtrMultiThreaded, PASN_BMPString, PSafePtrBase, PASN_ConstrainedString, PASN_OctetString, PString, PASN_BitString, PASN_ObjectId, PHTTPClientDigestAuthentication, PServiceMacro, PHTTPClientBasicAuthentication, PASN_Real, MXRecord, PASN_Enumeration, PHTTPClientAuthentication, PSNMP_Message, PProcess, PDNS::SRVRecord, PASN_Integer, PASN_Boolean, PHashTable, PASN_Null, PSNMP_Trap_PDU, PPipeChannel, PAbstractArray, PSNMP_PDU, PFile, PSmartPointer, PTime, PChannel, PIPSocket::Address, PAbstractList, XMPP::BareJID, PSNMP_VarBind, PTimeInterval, PVideoFrameInfo, PURL, POrdinalKey, XMPP::MUC::User, PRemoteConnection, PIndirectChannel, PIpAccessControlEntry, PMemoryFile, XMPP::JID, PHTTPField, and PDNS::NAPTRRecord.

Referenced by PASN_Enumeration::GetMaximum(), PASN_BitString::GetSize(), PASN_OctetString::GetSize(), PASN_ObjectId::GetValue(), PASN_Choice::IsValid(), PASN_ConstrainedString::operator[](), PASN_Sequence::operator[](), PSmartPointer::PSmartPointer(), PASN_Array::RemoveAll(), PASN_Boolean::SetValue(), PASN_Integer::SetValue(), PASN_Real::SetValue(), and PASN_BMPString::SetValueRaw().

## CompareObjectMemoryDirect()

virtual Comparison PObject::CompareObjectMemoryDirect | ( | const PObject & | obj | ) | const

virtual

Determine the byte wise comparison of two objects.

This is the default comparison operation for objects that do not explicitly override the `Compare()` function.

The `PCLASSINFO` macro declares an override of this function for the particular class. The user need not implement it.

Returns
  `LessThan`, `EqualTo` or `GreaterThan` according to the result `memcpy()` function.

## GetClass()

virtual const char* PObject::GetClass | ( | unsigned | ancestor = `0` | ) | const

inline virtual

Get the current dynamic type of the object instance.

When comparing class names, always use the `strcmp()` function rather than comparing pointers. The pointers are not necessarily the same over compilation units depending on the compiler, platform etc.

The `PCLASSINFO` macro declares an override of this function for the particular class. The user need not implement it.

Returns
  pointer to C string literal.

## HashFunction()

virtual PINDEX PObject::HashFunction | ( |  | ) | const

virtual

This function yields a hash value required by the `PDictionary` class.

A descendent class that is required to be the key of a dictionary should override this function. The precise values returned is dependent on the semantics of the class. For example, the `PString` class overrides it to provide a hash function for distinguishing text strings.

The default behaviour is to return the value zero.

Returns
  hash function value for class instance.

Reimplemented in PString, PChannel, PGloballyUniqueID, PURL, POrdinalKey, and PRemoteConnection.

## InternalCompareObjectMemoryDirect()

static Comparison PObject::InternalCompareObjectMemoryDirect | ( | const PObject * | obj1,
|  | const PObject * | obj2,
|  | PINDEX | size
| ) |  |

static

Internal function caled from CompareObjectMemoryDirect()

## InternalIsDescendant()

virtual PBoolean PObject::InternalIsDescendant | ( | const char * | clsName | ) | const

inline virtual

Determine if the dynamic type of the current instance is a descendent of the specified class.

The class name is usually provided by the `Class()` static function of the desired class.

The `PCLASSINFO` macro declares an override of this function for the particular class. The user need not implement it.

Returns
  true if object is descended from the class.

## IsClass()

PBoolean PObject::IsClass | ( | const char * | cls | ) | const

inline

## operator!=()

bool PObject::operator!= | ( | const PObject & | obj | ) | const

inline

Compare the two objects.

Returns
  true if objects are not equal.

## operator<()

bool PObject::operator< | ( | const PObject & | obj | ) | const

inline

Compare the two objects.

Returns
  true if objects are less than.

## operator<=()

bool PObject::operator<= | ( | const PObject & | obj | ) | const

inline

Compare the two objects.

Returns
  true if objects are less than or equal.

## operator==()

bool PObject::operator== | ( | const PObject & | obj | ) | const

inline

Compare the two objects.

Returns
  true if objects are equal.

Referenced by PASN_ObjectId::operator!=(), and PASN_ObjectId::SetValue().

## operator>()

bool PObject::operator> | ( | const PObject & | obj | ) | const

inline

Compare the two objects.

Returns
  true if objects are greater than.

## operator>=()

bool PObject::operator>= | ( | const PObject & | obj | ) | const

inline

Compare the two objects.

Returns
  true if objects are greater than or equal.

References PrintOn(), and ReadFrom().

## PrintOn()

virtual void PObject::PrintOn | ( | ostream & | strm | ) | const

virtual

Output the contents of the object to the stream.

The exact output is dependent on the exact semantics of the descendent class. This is primarily used by the standard `operator<<` function.

The default behaviour is to print the class name.

Reimplemented in PRegularExpression, PASN_Stream, PASN_Array, PASN_Sequence, PASN_Choice, PIPSocket::InterfaceEntry, PAbstractDictionary, PASN_BMPString, PCharArray, PASNSequence, PSafePtrBase, PASN_ConstrainedString, PASNNull, PASN_OctetString, PASNObjectID, PLDAPStructBase, PString, PASN_BitString, PCollection, PASN_ObjectId, PXMLElement, PASNUnsignedInteger, PASN_Real, MXRecord, PASN_Enumeration, PASNString, PSNMP_Message, PXMLRPCStructBase, PASNInteger, PDNS::SRVRecord, PvCard::EMail, PASN_Integer, PvCard::Telephone, PXMLRPCArrayBase, PASN_Boolean, PvCard::Address, PASN_Null, PSNMP_Trap_PDU, PvCard::InlineValue, PvCard::URIValue, PSNMP_PDU, PXML, PvCard::TextValues, PThread, PTime, PASNObject, PvCard::TextValue, PvCard::TypeValues, PAbstractArray, PvCard::ParamValues, PTimeInterval, PvCard::ParamValue, PVideoFrameInfo, PURL, PSNMP_VarBind, PArgList, POrdinalKey, PColourConverter, PvCard::Separator, XMPP::JID, PGloballyUniqueID, PvCard::Token, PIpAccessControlEntry, PMIMEInfo, PNatMethod, PSNMPVarBindingList, PDNS::NAPTRRecord, and PvCard.

Referenced by PASN_Enumeration::GetMaximum(), PASN_BitString::GetSize(), PASN_OctetString::GetSize(), PASN_ObjectId::GetValue(), PASN_Choice::IsValid(), PASN_ConstrainedString::operator[](), PASN_Sequence::operator[](), PASN_Array::RemoveAll(), PASN_Boolean::SetValue(), PASN_Integer::SetValue(), PASN_Real::SetValue(), and PASN_BMPString::SetValueRaw().

## ReadFrom()

virtual void PObject::ReadFrom | ( | istream & | strm | ) |

virtual

Input the contents of the object from the stream.

The exact input is dependent on the exact semantics of the descendent class. This is primarily used by the standard `operator>>` function.

The default behaviour is to do nothing.

Reimplemented in PStringToString, PStringToOrdinal, POrdinalToString, PStringSet, PSortedStringList, PStringList, PStringArray, PCharArray, PString, PvCard::Address, PvCard::InlineValue, PTime, PvCard::URIValue, PXML, PvCard::TextValues, PvCard::TextValue, PAbstractArray, PTimeInterval, PvCard::ParamValues, PURL, PvCard::ParamValue, PArgList, PvCard::Separator, PGloballyUniqueID, PIpAccessControlEntry, PvCard::Token, PMIMEInfo, and PvCard.

## Friends And Related Function Documentation

## operator<<

ostream& operator<< | ( | ostream & | strm,
|  | const PObject & | obj
| ) |  |

friend

Global function for using the standard << operator on objects descended from PObject.

This simply calls the objects `PrintOn()` function.

Returns
  the `strm` parameter.

Parameters

  strm | Stream to print the object into.
  obj | Object to print to the stream.

Referenced by operator<<().

## operator>>

istream& operator>> | ( | istream & | strm,
|  | PObject & | obj
| ) |  |

friend

Global function for using the standard >> operator on objects descended from PObject.

This simply calls the objects `ReadFrom()` function.

Returns
  the `strm` parameter.

Parameters

  strm | Stream to read the objects contents from.
  obj | Object to read inormation into.

The documentation for this class was generated from the following file:

- object.h