Main Page | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members | File Members

Vb Class Reference

#include <vb.h>

Collaboration diagram for Vb:

[legend]
List of all members.

Detailed Description

The Vb class is the encapsulation of the SNMP variable binding.

Variable binding lists in SNMP++ are represented as arrays of Vb objects. Vb objects are passed to and from SNMP objects to provide getting or setting MIB values. The vb class keeps its own memory for objects and does not utilize pointers to external data structures.

Definition at line 99 of file vb.h.

Public Member Functions

 Vb ()
 Constructor with no arguments.

 Vb (const Oid &oid)
 Constructor to initialize the oid.

 Vb (const Vb &vb)
 Copy constructor.

 ~Vb ()
 Destructor that frees all allocated memory.

Vboperator= (const Vb &vb)
 Overloaded assignment operator.

Vbclone () const
 Clone operator.

void set_oid (const Oid &oid)
 Set the oid from another oid.

void get_oid (Oid &oid) const
 Get the oid portion.

const Oidget_oid () const
 Get the oid portion as a const.

void set_value (const SnmpSyntax &val)
 Set the value using any SnmpSyntax object.

void set_value (const int i)
 Set the value with an int.

void set_value (const long i)
 Set the value with an int.

void set_value (const unsigned long i)
 Set the value with an unsigned long int.

void set_value (const char *ptr)
 Set value using a null terminated string.

void set_value (const unsigned char *ptr, const unsigned int len)
 Set value using a string and length.

void set_null ()
 Set the value portion of the vb to null, if its not already.

int get_value (SnmpSyntax &val) const
 Get the value using a SnmpSyntax object.

int get_value (int &i) const
 Get the value.

int get_value (long &i) const
 Get the value.

int get_value (unsigned long &i) const
 Get the value.

int get_value (unsigned char *ptr, unsigned long &len) const
 Get the value.

int get_value (unsigned char *ptr, unsigned long &len, const unsigned long maxlen) const
 Get the value.

int get_value (char *ptr) const
 Get the value.

SmiUINT32 get_syntax () const
 Return the syntax or the exception status.

void set_syntax (const SmiUINT32 syntax)
 Set the syntax.

void set_exception_status (const SmiUINT32 status)
 Set the exception status.

const char * get_printable_value () const
 Return a formatted version of the value.

const char * get_printable_oid () const
 Return a formatted version of the Oid.

bool valid () const
 Return the validity of a Vb object.

int get_asn1_length () const
 Return the space needed for serialization.

void clear ()
 Reset the object.


Protected Member Functions

void free_vb ()
 Free the value portion.


Protected Attributes

Oid iv_vb_oid
SnmpSyntaxiv_vb_value
SmiUINT32 exception_status

Friends

DLLOPT friend void set_exception_status (Vb *vb, const SmiUINT32 status)
 deprecated! Use Vb::set_exception_status()


Constructor & Destructor Documentation

Vb::Vb  )  [inline]
 

Constructor with no arguments.

This constructor creates an unitialized vb.

Definition at line 111 of file vb.h.

References SNMP_CLASS_SUCCESS.

Vb::Vb const Oid oid  )  [inline]
 

Constructor to initialize the oid.

This constructor creates a vb with oid portion initialized.

Definition at line 118 of file vb.h.

References oid, and SNMP_CLASS_SUCCESS.

Vb::Vb const Vb vb  )  [inline]
 

Copy constructor.

Definition at line 124 of file vb.h.

Vb::~Vb  )  [inline]
 

Destructor that frees all allocated memory.

Definition at line 129 of file vb.h.


Member Function Documentation

void Vb::clear  )  [inline]
 

Reset the object.

Definition at line 381 of file vb.h.

Vb* Vb::clone  )  const [inline]
 

Clone operator.

Definition at line 139 of file vb.h.

void Vb::free_vb  )  [protected]
 

Free the value portion.

int Vb::get_asn1_length  )  const
 

Return the space needed for serialization.

Returns:
the length of the BER encoding of this Vb.

const Oid& Vb::get_oid  )  const [inline]
 

Get the oid portion as a const.

Note:
Check the validity of the object through Vb::valid() before calling this method.

Definition at line 162 of file vb.h.

void Vb::get_oid Oid oid  )  const [inline]
 

Get the oid portion.

Note:
Check the validity of the object through Vb::valid() before calling this method.

Definition at line 154 of file vb.h.

References oid.

const char* Vb::get_printable_oid  )  const [inline]
 

Return a formatted version of the Oid.

Returns:
A null terminated string (may be empty if no Oid has been set).

Definition at line 361 of file vb.h.

const char* Vb::get_printable_value  )  const
 

Return a formatted version of the value.

Returns:
A null terminated string (empty if no value).

SmiUINT32 Vb::get_syntax  )  const
 

Return the syntax or the exception status.

Returns:
If the SNMPv2 exception status is set, it is returned. otherwise the syntax of the value object is returned.

int Vb::get_value char *  ptr  )  const
 

Get the value.

This method will only return success if the value of the vb is SMI OCTET.

Note:
The caller must provide a target string big enough to handle the vb string. No length checks are done within this method. The returned string will be null terminated.
Parameters:
ptr - Pointer to already allocated space to hold the vb value. The first char will be set to zero on failure.
Returns:
SNMP_CLASS_SUCCESS on success, else SNMP_CLASS_INVALID.

int Vb::get_value unsigned char *  ptr,
unsigned long &  len,
const unsigned long  maxlen
const
 

Get the value.

This method will only return success if the value of the vb is SMI OCTET.

Note:
If the target space is not big enough to hold the complete string only maxlen bytes are copied. In any case the returned string is NOT null terminated.
Parameters:
ptr - Pointer to already allocated space to hold the vb value. The first char will be set to zero on failure.
len - Returned length of the string. Will be set to 0 on failure.
maxlen - Maximum length of the space that ptr points to.
Returns:
SNMP_CLASS_SUCCESS on success, else SNMP_CLASS_INVALID.

int Vb::get_value unsigned char *  ptr,
unsigned long &  len
const
 

Get the value.

This method will only return success if the value of the vb is SMI OCTET.

Note:
The caller must provide a target string big enough to handle the vb string. No length checks are done within this method.
Parameters:
ptr - Pointer to already allocated space to hold the vb value. The first char will be set to zero on failure.
len - Returned length of the string. Will be set to 0 on failure.
Returns:
SNMP_CLASS_SUCCESS on success, else SNMP_CLASS_INVALID.

int Vb::get_value unsigned long &  i  )  const
 

Get the value.

This method will only return success if the value of the vb can be mapped to an unsigned long (SMI types uint32, counter32, gauge and timeticks).

Parameters:
i - returned value
Returns:
SNMP_CLASS_SUCCESS on success, else SNMP_CLASS_INVALID.

int Vb::get_value long &  i  )  const
 

Get the value.

This method will only return success if the value of the vb is SMI INT32.

Parameters:
i - returned value
Returns:
SNMP_CLASS_SUCCESS on success, else SNMP_CLASS_INVALID.

int Vb::get_value int &  i  )  const
 

Get the value.

This method will only return success if the value of the vb is SMI INT32.

Parameters:
i - returned value
Returns:
SNMP_CLASS_SUCCESS on success, else SNMP_CLASS_INVALID.

int Vb::get_value SnmpSyntax val  )  const
 

Get the value using a SnmpSyntax object.

Parameters:
val - An object of a subclass of SnmpSyntax that will be assigned the value of the vb.
Returns:
SNMP_CLASS_SUCCESS if the vb value could be assigned to the passed SnmpSyntax object, else SNMP_CLASS_INVALID.

Vb& Vb::operator= const Vb vb  ) 
 

Overloaded assignment operator.

void Vb::set_exception_status const SmiUINT32  status  )  [inline]
 

Set the exception status.

Parameters:
status - the new SNMPv2 exception status.

Definition at line 343 of file vb.h.

void Vb::set_null  )  [inline]
 

Set the value portion of the vb to null, if its not already.

Definition at line 214 of file vb.h.

void Vb::set_oid const Oid oid  )  [inline]
 

Set the oid from another oid.

Definition at line 146 of file vb.h.

References oid.

void Vb::set_syntax const SmiUINT32  syntax  ) 
 

Set the syntax.

The Value portion of the Vb will be deleted and a new value portion is allocated with it's default value (zero).

Parameters:
syntax - The new syntax.

void Vb::set_value const unsigned char *  ptr,
const unsigned int  len
[inline]
 

Set value using a string and length.

The syntax of the Vb will be set to SMI octet.

Definition at line 208 of file vb.h.

void Vb::set_value const char *  ptr  )  [inline]
 

Set value using a null terminated string.

The syntax of the Vb will be set to SMI octet.

Definition at line 200 of file vb.h.

void Vb::set_value const unsigned long  i  )  [inline]
 

Set the value with an unsigned long int.

The syntax of the Vb will be set to SMI UINT32.

Definition at line 192 of file vb.h.

void Vb::set_value const long  i  )  [inline]
 

Set the value with an int.

The syntax of the Vb will be set to SMI INT32.

Definition at line 184 of file vb.h.

void Vb::set_value const int  i  )  [inline]
 

Set the value with an int.

The syntax of the Vb will be set to SMI INT32.

Definition at line 177 of file vb.h.

void Vb::set_value const SnmpSyntax val  )  [inline]
 

Set the value using any SnmpSyntax object.

Definition at line 169 of file vb.h.

References SnmpSyntax::clone().

bool Vb::valid  )  const
 

Return the validity of a Vb object.

Returns:
TRUE if oid and value have been set.


Friends And Related Function Documentation

DLLOPT friend void set_exception_status Vb vb,
const SmiUINT32  status
[friend]
 

deprecated! Use Vb::set_exception_status()


Member Data Documentation

SmiUINT32 Vb::exception_status [protected]
 

Definition at line 387 of file vb.h.

Oid Vb::iv_vb_oid [protected]
 

Definition at line 385 of file vb.h.

SnmpSyntax* Vb::iv_vb_value [protected]
 

Definition at line 386 of file vb.h.


The documentation for this class was generated from the following file:
Generated on Tue Jan 4 22:42:23 2005 for SNMP++ by doxygen 1.3.2