SNMP++  3.3.4
Vb Class Reference

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

#include <vb.h>

Collaboration diagram for Vb:

Public Member Functions

 Vb ()
 Constructor with no arguments. More...
 
 Vb (const Oid &oid)
 Constructor to initialize the oid. More...
 
 Vb (const Vb &vb)
 Copy constructor. More...
 
 ~Vb ()
 Destructor that frees all allocated memory. More...
 
Vboperator= (const Vb &vb)
 Overloaded assignment operator. More...
 
Vbclone () const
 Clone operator. More...
 
void set_oid (const Oid &oid)
 Set the oid from another oid. More...
 
void get_oid (Oid &oid) const
 Get the oid portion. More...
 
const Oidget_oid () const
 Get the oid portion as a const. More...
 
void set_value (const SnmpSyntax &val)
 Set the value using any SnmpSyntax object. More...
 
void set_value (const int i)
 Set the value with an int. More...
 
void set_value (const unsigned int i)
 Set the value with an unsigned int. More...
 
void set_value (const long i)
 Set the value with a long int. More...
 
void set_value (const unsigned long i)
 Set the value with an unsigned long int. More...
 
void set_value (const char *ptr)
 Set value using a null terminated string. More...
 
void set_value (const unsigned char *ptr, const unsigned int len)
 Set value using a string and length. More...
 
void set_null ()
 Set the value portion of the vb to null, if its not already. More...
 
int get_value (SnmpSyntax &val) const
 Get the value using a SnmpSyntax object. More...
 
int get_value (int &i) const
 Get the value. More...
 
int get_value (unsigned int &i) const
 Get the value. More...
 
int get_value (long &i) const
 Get the value. More...
 
int get_value (unsigned long &i) const
 Get the value. More...
 
int get_value (pp_uint64 &i) const
 Get the value. More...
 
int get_value (unsigned char *ptr, unsigned long &len) const
 Get the value. More...
 
int get_value (unsigned char *ptr, unsigned long &len, const unsigned long maxlen, const bool add_null_byte=false) const
 Get the value. More...
 
int get_value (char *ptr) const
 Get the value. More...
 
SnmpSyntaxclone_value () const
 Clone the value portion of the variable binding. More...
 
SmiUINT32 get_syntax () const
 Return the syntax or the exception status. More...
 
void set_syntax (const SmiUINT32 syntax)
 Set the syntax. More...
 
void set_exception_status (const SmiUINT32 status)
 Set the exception status. More...
 
SmiUINT32 get_exception_status () const
 Get the exception status. More...
 
const char * get_printable_value () const
 Return a formatted version of the value. More...
 
const char * get_printable_oid () const
 Return a formatted version of the Oid. More...
 
bool valid () const
 Return the validity of a Vb object. More...
 
int get_asn1_length () const
 Return the space needed for serialization. More...
 
void clear ()
 Reset the object. More...
 

Protected Member Functions

void free_vb ()
 Free the value portion. More...
 

Protected Attributes

Oid iv_vb_oid
 
SnmpSyntaxiv_vb_value
 
SmiUINT32 exception_status
 

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 88 of file vb.h.

Constructor & Destructor Documentation

Vb::Vb ( )
inline

Constructor with no arguments.

This constructor creates an unitialized vb.

Definition at line 100 of file vb.h.

Vb::Vb ( const Oid oid)
inline

Constructor to initialize the oid.

This constructor creates a vb with oid portion initialized.

Definition at line 107 of file vb.h.

Vb::Vb ( const Vb vb)
inline

Copy constructor.

Definition at line 113 of file vb.h.

Vb::~Vb ( )
inline

Destructor that frees all allocated memory.

Definition at line 118 of file vb.h.

Member Function Documentation

void Vb::clear ( )
inline

Reset the object.

Definition at line 423 of file vb.h.

Vb* Vb::clone ( ) const
inline

Clone operator.

Definition at line 128 of file vb.h.

SnmpSyntax* Vb::clone_value ( ) const
inline

Clone the value portion of the variable binding.

The returned pointer must be deleted by the caller.

Returns
a pointer to a clone of the value of the receiver.

Definition at line 354 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.
SmiUINT32 Vb::get_exception_status ( ) const
inline

Get the exception status.

Definition at line 389 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 143 of file vb.h.

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 151 of file vb.h.

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 403 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 ( 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.
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 ( unsigned int &  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 ( 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 ( pp_uint64 i) const

Get the value.

This method will only return success if the value of the vb can be mapped to an unsigned 64bit value (SMI type counter64).

Parameters
i- returned value
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. 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.
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 char *  ptr,
unsigned long &  len,
const unsigned long  maxlen,
const bool  add_null_byte = false 
) 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 part of the string is copied.
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.
add_null_byte- Add a null byte at end of output string.
Returns
SNMP_CLASS_SUCCESS on success, else SNMP_CLASS_INVALID.
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.
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 383 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 215 of file vb.h.

void Vb::set_oid ( const Oid oid)
inline

Set the oid from another oid.

Definition at line 135 of file vb.h.

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 SnmpSyntax val)
inline

Set the value using any SnmpSyntax object.

Definition at line 158 of file vb.h.

References SnmpSyntax::clone().

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 166 of file vb.h.

void Vb::set_value ( const unsigned int  i)
inline

Set the value with an unsigned int.

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

Definition at line 173 of file vb.h.

void Vb::set_value ( const long  i)
inline

Set the value with a long int.

Note
Even on 64 bit platforms, only 32 bits are used

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

Definition at line 183 of file vb.h.

void Vb::set_value ( const unsigned long  i)
inline

Set the value with an unsigned long int.

Note
Even on 64 bit platforms, only 32 bits are used

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

Definition at line 193 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 201 of file vb.h.

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 209 of file vb.h.

bool Vb::valid ( ) const

Return the validity of a Vb object.

Returns
TRUE if oid and value have been set.

Member Data Documentation

SmiUINT32 Vb::exception_status
protected

Definition at line 429 of file vb.h.

Oid Vb::iv_vb_oid
protected

Definition at line 423 of file vb.h.

SnmpSyntax* Vb::iv_vb_value
protected

Definition at line 428 of file vb.h.


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