PASNObject Class Reference

This class defines the common behviour of all ASN objects. More...

`#include <pasn.h>`

Inheritance diagram for PASNObject:

## Public Types

enum | ASNType { Integer, String, ObjectID, Sequence, Choice, IPAddress, Counter, Gauge, TimeTicks, Opaque, NsapAddress, Counter64, UInteger32, Null, Unknown, ASNTypeMax }
| Value returned by the GetType() function to indicate the type of an ASN object. More...
Public Types inherited from PObject
enum | Comparison { LessThan = -1, EqualTo = 0, GreaterThan = 1 }
| Result of the comparison operation performed by the `Compare()` function. More...

## Public Member Functions

virtual ASNType | GetType () const
| Return a value of type enum ASNType which indicates the type of the object. More...
int | GetChoice () const
| Return the descriminator for Choice sequences. More...
virtual PString | GetTypeAsString () const
| Return a string giving the type of the object. More...
virtual PASNInt | GetInteger () const
| Return the value of the ASN object as a PASNInt. More...
virtual PASNUnsigned | GetUnsigned () const
| Return the value of the object as a PASNUnsigned. More...
virtual PString | GetString () const
| Return the value of the object as a PString. More...
virtual const PASNSequence & | GetSequence () const
| Return the value of the object as a PString. More...
virtual PIPSocket::Address | GetIPAddress () const
| Return the value of the object as an IPAddress. More...
virtual void | PrintOn (ostream &strm) const
| Virtual functions used by the PObject::operator<< function to print the value of the object. More...
virtual void | Encode (PBYTEArray &buffer)
| Virtual function used to encode the object into ASN format. More...
virtual WORD | GetEncodedLength ()
| Virtual function used to get the length of object when encoded into ASN format. More...
virtual PObject * | Clone () const
| Virtual function used to duplicate objects. More...
Public Member Functions inherited from PObject
virtual | ~PObject ()
virtual PINDEX | HashFunction () const
| This function yields a hash value required by the `PDictionary` class. 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...
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...
virtual void | ReadFrom (istream &strm)
| Input the contents of the object from the stream. More...

## Static Public Member Functions

static void | EncodeASNLength (PBYTEArray &buffer, WORD length)
| Encode an ASN length value. More...
static WORD | GetASNLengthLength (WORD length)
| Return the length of an encoded ASN length value. More...
static PBoolean | DecodeASNLength (const PBYTEArray &buffer, PINDEX &ptr, WORD &len)
| Decode an ASN length in the buffer at the given ptr. More...
static void | EncodeASNSequenceStart (PBYTEArray &buffer, BYTE type, WORD length)
| Encode a sequence header into the buffer at the specified offset. More...
static WORD | GetASNSequenceStartLength (WORD length)
| Return the encoded length of a sequence if it has the specified length. More...
static void | EncodeASNHeader (PBYTEArray &buffer, PASNObject::ASNType type, WORD length)
| Encode an ASN object header into the buffer. More...
static WORD | GetASNHeaderLength (WORD length)
| Return the length of an ASN object header if the object is the specified length. More...
static void | EncodeASNInteger (PBYTEArray &buffer, PASNInt data, PASNObject::ASNType type)
static void | EncodeASNUnsigned (PBYTEArray &buffer, PASNUnsigned data, PASNObject::ASNType type)
static WORD | GetASNIntegerLength (PASNInt data)
static WORD | GetASNUnsignedLength (PASNUnsigned data)
static PBoolean | DecodeASNInteger (const PBYTEArray &buffer, PINDEX &ptr, PASNInt &value, ASNType type=Integer)
static PBoolean | DecodeASNUnsigned (const PBYTEArray &buffer, PINDEX &ptr, PASNUnsigned &value, ASNType type=TimeTicks)
Static Public Member Functions inherited from PObject
static Comparison | InternalCompareObjectMemoryDirect (const PObject *obj1, const PObject *obj2, PINDEX size)
| Internal function caled from CompareObjectMemoryDirect() More...
static const char * | Class ()
| Get the name of the class as a C string. More...

## Protected Member Functions

| PASNObject ()
| Create an empty ASN object. More...
Protected Member Functions inherited from PObject
| PObject ()
| Constructor for PObject, made protected so cannot ever create one on its own. More...

## Static Protected Attributes

static BYTE | ASNTypeToType [ASNTypeMax]
| Table to map enum ASNType values to ASN identifiers. More...

## Detailed Description

This class defines the common behviour of all ASN objects.

It also contains several functions which are used for encoding common ASN primitives.

This class will never be instantiated directly. See the PASNInteger, PASNSequence, PASNString and PASNObjectID classes for examples of ASN objects that can be created.

Only descendants of this class can be put into the ASNSequence class.

## Member Enumeration Documentation

## ASNType

enum PASNObject::ASNType

Value returned by the GetType() function to indicate the type of an ASN object.

Enumerator
Integer | ASN Integer object.
String | ASN Octet String object.
ObjectID | ASN Object ID object.
Sequence | ASN Sequence object.
Choice | ASN Sequence with discriminator.
IPAddress | ASN IPAddress object.
Counter | ASN Counter object.
Gauge | ASN Gauge object.
TimeTicks | ASN TimeTicks object.
Opaque | ASN Opaque object.
NsapAddress | ASN NsapAddress.
Counter64 | ASN Counter64.
UInteger32 | ASN Unsigned integer 32.
Null | ASN Null.
Unknown | unknown ASN object type
ASNTypeMax | maximum of number of ASN object types

## Constructor & Destructor Documentation

## PASNObject()

PASNObject::PASNObject | ( |  | ) |

protected

Create an empty ASN object.

Used only by descendant constructors

## Member Function Documentation

## Clone()

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

virtual

Virtual function used to duplicate objects.

Reimplemented from PObject.

Reimplemented in PASNNull, PASNObjectID, PASNGauge, PASNCounter, PASNTimeTicks, PASNIPAddress, PASNString, and PASNInteger.

Referenced by PASNString::Encode().

## DecodeASNInteger()

static PBoolean PASNObject::DecodeASNInteger | ( | const PBYTEArray & | buffer,
|  | PINDEX & | ptr,
|  | PASNInt & | value,
|  | ASNType | type = `Integer`
| ) |  |

static

Parameters

  buffer | buffer to decode from
  ptr | ptr to data in buffer
  value | returned value
  type | actual integer type

## DecodeASNLength()

static PBoolean PASNObject::DecodeASNLength | ( | const PBYTEArray & | buffer,
|  | PINDEX & | ptr,
|  | WORD & | len
| ) |  |

static

Decode an ASN length in the buffer at the given ptr.

The ptr is moved to the byte after the end of the encoded length.

Parameters

  buffer | buffer to decode data from
  ptr | ptr to decode from
  len | returned length

## DecodeASNUnsigned()

static PBoolean PASNObject::DecodeASNUnsigned | ( | const PBYTEArray & | buffer,
|  | PINDEX & | ptr,
|  | PASNUnsigned & | value,
|  | ASNType | type = `TimeTicks`
| ) |  |

static

Parameters

  buffer | buffer to decode from
  ptr | ptr to data in buffer
  value | returned value
  type | actual integer type

## Encode()

virtual void PASNObject::Encode | ( | PBYTEArray & | buffer | ) |

virtual

Virtual function used to encode the object into ASN format.

Parameters

  buffer | buffer to encode into

Reimplemented in PASNSequence, PASNNull, PASNObjectID, PASNGauge, PASNCounter, PASNTimeTicks, PASNIPAddress, PASNString, and PASNInteger.

Referenced by PASNString::Encode(), and PASNUnsignedInteger::PASNUnsignedInteger().

## EncodeASNHeader()

static void PASNObject::EncodeASNHeader | ( | PBYTEArray & | buffer,
|  | PASNObject::ASNType | type,
|  | WORD | length
| ) |  |

static

Encode an ASN object header into the buffer.

Parameters

  buffer | buffer to encode into
  type | ASN type of the object
  length | length of the object

## EncodeASNInteger()

static void PASNObject::EncodeASNInteger | ( | PBYTEArray & | buffer,
|  | PASNInt | data,
|  | PASNObject::ASNType | type
| ) |  |

static

Parameters

  buffer | buffer to encode into
  data | value to encode
  type | actual integer type

## EncodeASNLength()

static void PASNObject::EncodeASNLength | ( | PBYTEArray & | buffer,
|  | WORD | length
| ) |  |

static

Encode an ASN length value.

Parameters

  buffer | buffer to encode into
  length | ASN length to encode

## EncodeASNSequenceStart()

static void PASNObject::EncodeASNSequenceStart | ( | PBYTEArray & | buffer,
|  | BYTE | type,
|  | WORD | length
| ) |  |

static

Encode a sequence header into the buffer at the specified offset.

Parameters

  buffer | buffer to encode data into
  type | sequence type
  length | length of sequence data

## EncodeASNUnsigned()

static void PASNObject::EncodeASNUnsigned | ( | PBYTEArray & | buffer,
|  | PASNUnsigned | data,
|  | PASNObject::ASNType | type
| ) |  |

static

Parameters

  buffer | buffer to encode into
  data | value to encode
  type | actual integer type

## GetASNHeaderLength()

static WORD PASNObject::GetASNHeaderLength | ( | WORD | length | ) |

static

Return the length of an ASN object header if the object is the specified length.

Parameters

  length | length of object

## GetASNIntegerLength()

static WORD PASNObject::GetASNIntegerLength | ( | PASNInt | data | ) |

static

Parameters

  data | value to get length of

## GetASNLengthLength()

static WORD PASNObject::GetASNLengthLength | ( | WORD | length | ) |

static

Return the length of an encoded ASN length value.

Parameters

  length | length to find length of

## GetASNSequenceStartLength()

static WORD PASNObject::GetASNSequenceStartLength | ( | WORD | length | ) |

static

Return the encoded length of a sequence if it has the specified length.

Parameters

  length | length of sequence data

## GetASNUnsignedLength()

static WORD PASNObject::GetASNUnsignedLength | ( | PASNUnsigned | data | ) |

static

Parameters

  data | value to get length of

## GetChoice()

int PASNObject::GetChoice | ( |  | ) | const

Return the descriminator for Choice sequences.

## GetEncodedLength()

virtual WORD PASNObject::GetEncodedLength | ( |  | ) |

virtual

Virtual function used to get the length of object when encoded into ASN format.

Reimplemented in PASNSequence, PASNNull, PASNObjectID, PASNUnsignedInteger, PASNString, and PASNInteger.

Referenced by PASNString::Encode(), and PASNUnsignedInteger::PASNUnsignedInteger().

## GetInteger()

virtual PASNInt PASNObject::GetInteger | ( |  | ) | const

virtual

Return the value of the ASN object as a PASNInt.

This function will assert if the object is not a descendant of PASNInteger.

Reimplemented in PASNInteger.

## GetIPAddress()

virtual PIPSocket::Address PASNObject::GetIPAddress | ( |  | ) | const

virtual

Return the value of the object as an IPAddress.

This function will assert if the object is not a descendant of PASNIPAddress.

Reimplemented in PASNIPAddress.

Referenced by PASNIPAddress::Clone().

## GetSequence()

virtual const PASNSequence& PASNObject::GetSequence | ( |  | ) | const

virtual

Return the value of the object as a PString.

This function will assert if the object is not a descendant of PASNSequence.

Reimplemented in PASNSequence.

## GetString()

virtual PString PASNObject::GetString | ( |  | ) | const

virtual

Return the value of the object as a PString.

This function can be use for all ASN object types

Reimplemented in PASNNull, PASNObjectID, PASNUnsignedInteger, PASNIPAddress, PASNString, and PASNInteger.

Referenced by PASNString::Encode(), PASNIPAddress::Encode(), and PASNUnsignedInteger::PASNUnsignedInteger().

## GetType()

virtual ASNType PASNObject::GetType | ( |  | ) | const

virtual

Return a value of type enum ASNType which indicates the type of the object.

Reimplemented in PASNSequence, PASNNull, PASNObjectID, PASNGauge, PASNCounter, PASNTimeTicks, PASNIPAddress, PASNString, and PASNInteger.

Referenced by PASNString::Encode().

## GetTypeAsString()

virtual PString PASNObject::GetTypeAsString | ( |  | ) | const

virtual

Return a string giving the type of the object.

Reimplemented in PASNSequence, PASNNull, PASNObjectID, PASNGauge, PASNCounter, PASNTimeTicks, PASNIPAddress, PASNString, and PASNInteger.

Referenced by PASNString::Encode(), PASNIPAddress::Encode(), PASNTimeTicks::GetType(), PASNCounter::GetType(), and PASNGauge::GetType().

## GetUnsigned()

virtual PASNUnsigned PASNObject::GetUnsigned | ( |  | ) | const

virtual

Return the value of the object as a PASNUnsigned.

This function will assert if the object is not a descendant of PASNTimeTicks or

PASNCounter.

Reimplemented in PASNUnsignedInteger.

Referenced by PASNUnsignedInteger::PASNUnsignedInteger().

## PrintOn()

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

virtual

Virtual functions used by the PObject::operator<< function to print the value of the object.

Parameters

  strm | stream to print on

Reimplemented from PObject.

Reimplemented in PASNSequence, PASNNull, PASNObjectID, PASNUnsignedInteger, PASNString, and PASNInteger.

Referenced by PASNUnsignedInteger::PASNUnsignedInteger().

## Member Data Documentation

## ASNTypeToType

BYTE PASNObject::ASNTypeToType[ASNTypeMax]

static protected

Table to map enum ASNType values to ASN identifiers.

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

- pasn.h