SNMP 2.0.0
Loading...
Searching...
No Matches
SNMP::Length Class Reference

Length of a BER object. More...

#include <src/BER.h>

Inheritance diagram for SNMP::Length:
[legend]
Collaboration diagram for SNMP::Length:
[legend]

Public Member Functions

 Length (unsigned int length=0)
 Creates a BER length from a length value.
 
void encode (Stream &stream)
 Encodes BER length to stream.
 
void decode (Stream &stream)
 Decodes BER length from stream.
 
uint8_t * encode (uint8_t *buffer)
 Encodes BER length to memory buffer.
 
uint8_t * decode (uint8_t *buffer)
 Decodes BER length from memory buffer.
 
 operator unsigned int () const
 Unsigned int conversion function.
 
Lengthoperator= (const unsigned int length)
 Unsigned int assignment operator.
 
Lengthoperator+= (const unsigned int length)
 Addition operator.
 
Lengthoperator-= (const unsigned int length)
 Subtraction operator.
 
Lengthoperator++ ()
 Prefix increment operator.
 
Length operator++ (int)
 Postfix increment operator.
 
- Public Member Functions inherited from SNMP::Base
void encode7bits (uint32_t value, uint8_t *buffer, const uint8_t size)
 Encodes integer value to memory buffer.
 

Private Member Functions

void setLength (unsigned int length)
 Sets length from integer.
 

Private Attributes

unsigned int _length
 

Additional Inherited Members

- Static Public Member Functions inherited from SNMP::Base
static void encode7bits (uint32_t value, Stream &stream, const uint8_t size)
 Encodes integer value to stream.
 
- Protected Attributes inherited from SNMP::Base
unsigned int _size = 0
 

Detailed Description

Length of a BER object.

This class handles the length of a BER object.

Definition at line 549 of file BER.h.

Constructor & Destructor Documentation

◆ Length()

SNMP::Length::Length ( unsigned int length = 0)
inline

Creates a BER length from a length value.

Parameters
length

Definition at line 556 of file BER.h.

References setLength().

Member Function Documentation

◆ decode() [1/2]

void SNMP::Length::decode ( Stream & stream)
inline

Decodes BER length from stream.

Parameters
streamStream to read from.

Definition at line 589 of file BER.h.

References _length, and SNMP::Base::_size.

Referenced by SNMP::BER::decode(), and SNMP::BER::decode().

◆ decode() [2/2]

uint8_t * SNMP::Length::decode ( uint8_t * buffer)
inline

Decodes BER length from memory buffer.

Parameters
bufferPointer to the buffer.
Returns
Next position to be read in buffer.

Definition at line 637 of file BER.h.

References _length, and SNMP::Base::_size.

◆ encode() [1/2]

void SNMP::Length::encode ( Stream & stream)
inline

Encodes BER length to stream.

There is two ways to encode a BER length.

  • Short form if length < 127.
  • Long form otherwise.
Parameters
streamStream to write to.

Definition at line 572 of file BER.h.

References _length, and SNMP::Base::_size.

Referenced by SNMP::BER::encode(), and SNMP::BER::encode().

◆ encode() [2/2]

uint8_t * SNMP::Length::encode ( uint8_t * buffer)
inline

Encodes BER length to memory buffer.

There is two ways to encode a BER length.

  • Short form if length < 127.
  • Long form otherwise.
Parameters
bufferPointer to the buffer.
Returns
Next position to be written in buffer.

Definition at line 615 of file BER.h.

References _length, and SNMP::Base::_size.

◆ operator unsigned int()

SNMP::Length::operator unsigned int ( ) const
inline

Unsigned int conversion function.

Gets length as integer.

Length length;
unsigned int a = length;
Length of a BER object.
Definition BER.h:549
Returns
BER length.

Definition at line 664 of file BER.h.

References _length.

◆ operator++() [1/2]

Length & SNMP::Length::operator++ ( )
inline

Prefix increment operator.

Increments length and return incremented value.

Length length;
++length;
Returns
Length value.

Definition at line 734 of file BER.h.

References _length, and setLength().

Referenced by operator++().

◆ operator++() [2/2]

Length SNMP::Length::operator++ ( int )
inline

Postfix increment operator.

Increments length and return value before increment.

Length length;
length++;
Returns
Length value.

Definition at line 751 of file BER.h.

References operator++().

◆ operator+=()

Length & SNMP::Length::operator+= ( const unsigned int length)
inline

Addition operator.

Adds integer to length.

Length length;
length += 10;
Parameters
lengthValue to add.
Returns
Length object.

Definition at line 699 of file BER.h.

References _length, and setLength().

◆ operator-=()

Length & SNMP::Length::operator-= ( const unsigned int length)
inline

Subtraction operator.

Subtracts integer from length.

Length length;
length -= 10;
Parameters
lengthValue to subtract.
Returns
Length object.

Definition at line 717 of file BER.h.

References _length, and setLength().

◆ operator=()

Length & SNMP::Length::operator= ( const unsigned int length)
inline

Unsigned int assignment operator.

Sets length from integer.

Length length;
length = 10;
Parameters
length
Returns
Length object.

Definition at line 681 of file BER.h.

References setLength().

◆ setLength()

void SNMP::Length::setLength ( unsigned int length)
inlineprivate

Sets length from integer.

Length is set and the size is computed again.

Parameters
length

Definition at line 768 of file BER.h.

References _length, and SNMP::Base::_size.

Referenced by Length(), operator++(), operator+=(), operator-=(), and operator=().

Member Data Documentation

◆ _length

unsigned int SNMP::Length::_length
private

Length of the BER object.

Definition at line 759 of file BER.h.

Referenced by decode(), decode(), encode(), encode(), operator unsigned int(), operator++(), operator+=(), operator-=(), and setLength().


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