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

OctetStr Class Reference

#include <octet.h>

Inheritance diagram for OctetStr:

[legend]
Collaboration diagram for OctetStr:
[legend]
List of all members.

Public Types

enum  OutputType { OutputHexAndClear, OutputHex, OutputClear }
 Enum for setting the hex output format. More...


Public Member Functions

 OctetStr ()
 Constructs a valid OctetStr with zero length.

 OctetStr (const char *str)
 Constructs a OctetStr with the given value.

 OctetStr (const unsigned char *str, unsigned long len)
 Constructs a OctetStr with the given value.

 OctetStr (const OctetStr &octet)
 Construct a OctetStr from another OctetStr.

 ~OctetStr ()
 Destructor, frees allocated space.

OctetStroperator= (const char *str)
 Assign a char string to a OctetStr.

OctetStroperator= (const OctetStr &octet)
 Assign a OctetStr to a OctetStr.

OctetStroperator+= (const char *a)
 Append a char string to this OctetStr.

OctetStroperator+= (const unsigned char c)
 Append a single char to this OctetStr.

OctetStroperator+= (const OctetStr &octet)
 Append another OctetStr to this OctetStr.

unsigned char & operator[] (int i)
 Allow access as if it was an array.

unsigned char operator[] (int i) const
 Allow access as if it was an array for const OctetStr objects.

SmiUINT32 get_syntax () const
 Return the syntax.

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

bool valid () const
 Return validity of the object.

SnmpSyntaxclone () const
 Clone this object.

SnmpSyntaxoperator= (const SnmpSyntax &val)
 Map other SnmpSyntax objects to OctetStr.

const char * get_printable () const
 Get a printable ASCII value of the string.

const char * get_printable_hex () const
 Get an ASCII formatted hex dump of the contents.

const char * get_printable_clear () const
 Get the contents with all non printable characters replaced.

void set_data (const unsigned char *str, unsigned long len)
 Set the data on an already constructed OctetStr.

unsigned long len () const
 Get the length of the string.

unsigned char * data () const
 Get a pointer to internal data.

int nCompare (const unsigned long n, const OctetStr &o) const
void clear ()
 Null out the contents of the string.


Static Public Member Functions

void set_hex_output_type (const enum OutputType ot)
 Set the output format for get_pritable_hex().

void set_hex_np_char (const char np)
 Set the char get_printable_hex() will use for non printable characters.

OctetStr from_hex_string (const OctetStr &hex_string)
 Build an OctetStr from a hex string.


Protected Attributes

char * output_buffer
unsigned int output_buffer_len
bool validity

Static Protected Attributes

enum OutputType hex_output_type
char hex_nonprintable_char

Friends

DLLOPT friend int operator== (const OctetStr &lhs, const OctetStr &rhs)
 Equal operator for two OctetStr.

DLLOPT friend int operator!= (const OctetStr &lhs, const OctetStr &rhs)
 Not equal operator for two OctetStr.

DLLOPT friend int operator< (const OctetStr &lhs, const OctetStr &rhs)
 Not equal operator for two OctetStr.

DLLOPT friend int operator<= (const OctetStr &lhs, const OctetStr &rhs)
 Less than operator for two OctetStr.

DLLOPT friend int operator> (const OctetStr &lhs, const OctetStr &rhs)
 Greater than operator for two OctetStr.

DLLOPT friend int operator>= (const OctetStr &lhs, const OctetStr &rhs)
 Greater than or equal operator for two OctetStr.

DLLOPT friend int operator== (const OctetStr &lhs, const char *rhs)
 Equal operator for OctetStr and char string.

DLLOPT friend int operator!= (const OctetStr &lhs, const char *rhs)
 Not equal operator for OctetStr and char string.

DLLOPT friend int operator< (const OctetStr &lhs, const char *rhs)
 Less than operator for OctetStr and char string.

DLLOPT friend int operator<= (const OctetStr &lhs, const char *rhs)
 Less than or equal operator for OctetStr and char string.

DLLOPT friend int operator> (const OctetStr &lhs, const char *rhs)
 Greater than operator for OctetStr and char string.

DLLOPT friend int operator>= (const OctetStr &lhs, const char *rhs)
 Greater than or equal operator for OctetStr and char string.


Member Enumeration Documentation

enum OctetStr::OutputType
 

Enum for setting the hex output format.

Enumeration values:
OutputHexAndClear 
OutputHex 
OutputClear 

Definition at line 85 of file octet.h.


Constructor & Destructor Documentation

OctetStr::OctetStr  ) 
 

Constructs a valid OctetStr with zero length.

OctetStr::OctetStr const char *  str  ) 
 

Constructs a OctetStr with the given value.

The OctetStr will be valid unless a call to new fails.

Parameters:
str - Null terminated string

OctetStr::OctetStr const unsigned char *  str,
unsigned long  len
 

Constructs a OctetStr with the given value.

The OctetStr will be valid unless a call to new fails.

Parameters:
str - string that may contain null bytes
len - length of the string

OctetStr::OctetStr const OctetStr octet  ) 
 

Construct a OctetStr from another OctetStr.

The OctetStr will be valid unless a call to new fails.

Parameters:
octet - Value for the new object

OctetStr::~OctetStr  ) 
 

Destructor, frees allocated space.


Member Function Documentation

void OctetStr::clear  )  [virtual]
 

Null out the contents of the string.

The string will be empty after calling this method

Implements SnmpSyntax.

SnmpSyntax* OctetStr::clone  )  const [inline, virtual]
 

Clone this object.

Returns:
Pointer to the newly created object (allocated through new).

Implements SnmpSyntax.

Reimplemented in OpaqueStr.

Definition at line 252 of file octet.h.

unsigned char* OctetStr::data  )  const [inline]
 

Get a pointer to internal data.

Definition at line 325 of file octet.h.

OctetStr OctetStr::from_hex_string const OctetStr hex_string  )  [static]
 

Build an OctetStr from a hex string.

Called with "5465 737469 6e672074686973206D657468 6f 64 21" the returned value will be "Testing this method!"

Parameters:
hex_string - The hex string (may contain spaces)
Returns:
created string

int OctetStr::get_asn1_length  )  const [virtual]
 

Return the space needed for serialization.

Implements SnmpSyntax.

const char* OctetStr::get_printable  )  const [virtual]
 

Get a printable ASCII value of the string.

Note:
Depending on the selected output format, this method will return get_printable_hex() or get_printable_clear() if the string contains not printable characters.
Returns:
Printable, null terminated string

Implements SnmpSyntax.

Referenced by CTarget::get_writecommunity().

const char* OctetStr::get_printable_clear  )  const
 

Get the contents with all non printable characters replaced.

Returns:
Printable, null terminated string.

const char* OctetStr::get_printable_hex  )  const
 

Get an ASCII formatted hex dump of the contents.

If the output format was set to OctetStr::OutputHexAndClear, the produced string of this method will look like this:

09 4F 63 74 65 74 53 74 72 3A 3A 67 65 74 5F 70 .OctetStr::get_p 72 69 6E 74 61 62 6C 65 5F 68 65 78 28 29 rintable_hex()
If the output format was set to OctetStr::OutputHex the produced string will look like this:
09 4F 63 74 65 74 53 74 72 3A 3A 67 65 74 5F 70 72 69 6E 74 61 62 6C 65 5F 68 65 78 28 29
Returns:
Printable, null terminated string.

SmiUINT32 OctetStr::get_syntax  )  const [inline, virtual]
 

Return the syntax.

Returns:
This method always returns sNMP_SYNTAX_OCTETS.

Implements SnmpSyntax.

Reimplemented in OpaqueStr.

Definition at line 235 of file octet.h.

References SmiUINT32, and sNMP_SYNTAX_OCTETS.

unsigned long OctetStr::len  )  const [inline]
 

Get the length of the string.

Definition at line 320 of file octet.h.

int OctetStr::nCompare const unsigned long  n,
const OctetStr o
const
 

OctetStr& OctetStr::operator+= const OctetStr octet  ) 
 

Append another OctetStr to this OctetStr.

OctetStr& OctetStr::operator+= const unsigned char  c  ) 
 

Append a single char to this OctetStr.

OctetStr& OctetStr::operator+= const char *  a  ) 
 

Append a char string to this OctetStr.

SnmpSyntax& OctetStr::operator= const SnmpSyntax val  )  [virtual]
 

Map other SnmpSyntax objects to OctetStr.

Reimplemented from SnmpSyntax.

Reimplemented in OpaqueStr.

OctetStr& OctetStr::operator= const OctetStr octet  ) 
 

Assign a OctetStr to a OctetStr.

OctetStr& OctetStr::operator= const char *  str  ) 
 

Assign a char string to a OctetStr.

Referenced by OpaqueStr::operator=().

unsigned char OctetStr::operator[] int  i  )  const [inline]
 

Allow access as if it was an array for const OctetStr objects.

Note:
The given param is not checked for validity.

Definition at line 228 of file octet.h.

unsigned char& OctetStr::operator[] int  i  )  [inline]
 

Allow access as if it was an array.

Note:
The given param is not checked for validity.

Definition at line 221 of file octet.h.

void OctetStr::set_data const unsigned char *  str,
unsigned long  len
 

Set the data on an already constructed OctetStr.

The given string is copied to an internal member var, so the params can be destroyed afterwards.

Parameters:
str - The new string value
len - Length of the given string

void OctetStr::set_hex_np_char const char  np  )  [inline, static]
 

Set the char get_printable_hex() will use for non printable characters.

Definition at line 305 of file octet.h.

void OctetStr::set_hex_output_type const enum OutputType  ot  )  [inline, static]
 

Set the output format for get_pritable_hex().

Definition at line 298 of file octet.h.

bool OctetStr::valid  )  const [inline, virtual]
 

Return validity of the object.

Implements SnmpSyntax.

Definition at line 245 of file octet.h.

Referenced by Pdu::get_context_engine_id(), Pdu::get_context_name(), Pdu::set_context_engine_id(), and Pdu::set_context_name().


Friends And Related Function Documentation

DLLOPT friend int operator!= const OctetStr lhs,
const char *  rhs
[friend]
 

Not equal operator for OctetStr and char string.

DLLOPT friend int operator!= const OctetStr lhs,
const OctetStr rhs
[friend]
 

Not equal operator for two OctetStr.

DLLOPT friend int operator< const OctetStr lhs,
const char *  rhs
[friend]
 

Less than operator for OctetStr and char string.

DLLOPT friend int operator< const OctetStr lhs,
const OctetStr rhs
[friend]
 

Not equal operator for two OctetStr.

DLLOPT friend int operator<= const OctetStr lhs,
const char *  rhs
[friend]
 

Less than or equal operator for OctetStr and char string.

DLLOPT friend int operator<= const OctetStr lhs,
const OctetStr rhs
[friend]
 

Less than operator for two OctetStr.

DLLOPT friend int operator== const OctetStr lhs,
const char *  rhs
[friend]
 

Equal operator for OctetStr and char string.

DLLOPT friend int operator== const OctetStr lhs,
const OctetStr rhs
[friend]
 

Equal operator for two OctetStr.

DLLOPT friend int operator> const OctetStr lhs,
const char *  rhs
[friend]
 

Greater than operator for OctetStr and char string.

DLLOPT friend int operator> const OctetStr lhs,
const OctetStr rhs
[friend]
 

Greater than operator for two OctetStr.

DLLOPT friend int operator>= const OctetStr lhs,
const char *  rhs
[friend]
 

Greater than or equal operator for OctetStr and char string.

DLLOPT friend int operator>= const OctetStr lhs,
const OctetStr rhs
[friend]
 

Greater than or equal operator for two OctetStr.


Member Data Documentation

char OctetStr::hex_nonprintable_char [static, protected]
 

Definition at line 353 of file octet.h.

enum OutputType OctetStr::hex_output_type [static, protected]
 

Definition at line 352 of file octet.h.

char* OctetStr::output_buffer [protected]
 

Definition at line 349 of file octet.h.

unsigned int OctetStr::output_buffer_len [protected]
 

Definition at line 350 of file octet.h.

bool OctetStr::validity [protected]
 

Definition at line 351 of file octet.h.


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