SNMP 2.0.0
|
BER object to handle integer. More...
#include <src/BER.h>
Public Member Functions | |
IntegerBER (const int32_t value) | |
Creates an IntegerBER object. | |
virtual void | encode (Stream &stream) |
Encodes IntegerBER to stream. | |
virtual void | decode (Stream &stream, const uint8_t flag=Flag::None) |
Decodes IntegerBER from stream. | |
virtual uint8_t * | encode (uint8_t *buffer) |
Encodes IntegerBER to memory buffer. | |
virtual uint8_t * | decode (uint8_t *buffer) |
Decodes IntegerBER from memory buffer. | |
const int32_t | getValue () const |
Gets the IntegerBER value. | |
void | setValue (const int32_t value) |
Sets the IntegerBER value. | |
Public Member Functions inherited from SNMP::BER | |
BER (const unsigned int type) | |
Creates a BER object. | |
virtual | ~BER () |
BER destructor. | |
template<typename T > | |
void | encodeNumeric (T value, Stream &stream) |
Encodes BER numeric value to stream. | |
template<typename T > | |
void | decodeNumeric (T *value, Stream &stream, const uint8_t flag=Flag::None) |
Decodes BER numeric value from stream. | |
template<typename T > | |
uint8_t * | encodeNumeric (T value, uint8_t *buffer) |
Encodes BER numeric value to memory buffer. | |
template<typename T > | |
uint8_t * | decodeNumeric (T *value, uint8_t *buffer, const uint8_t flag=Flag::None) |
Decodes BER numeric value from memory buffer. | |
template<typename T > | |
void | setNegative (T value) |
Computes BER length of a negative integer. | |
template<typename T > | |
void | setPositive (T value) |
Computes BER length of a positive integer. | |
const unsigned int | getType () const |
Gets the BER type. | |
const unsigned int | getLength () const |
Gets the BER length. | |
virtual const unsigned int | getSize (const bool refresh=false) |
Gets the size of the BER. | |
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 Attributes | |
int32_t | _value |
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 Member Functions inherited from SNMP::BER | |
BER * | create (const Type &type) |
Creates a BER of given type. | |
Protected Attributes inherited from SNMP::BER | |
Length | _length |
Type | _type |
Protected Attributes inherited from SNMP::Base | |
unsigned int | _size = 0 |
BER object to handle integer.
Example
Integer | Encoding |
---|---|
0 | 02 01 00 |
127 | 02 01 7F |
128 | 02 02 00 80 |
256 | 02 02 01 00 |
2147483647 | 02 04 7F FF FF FF |
-128 | 02 01 80 |
-129 | 02 02 FF 7F |
-2147483648 | 02 04 80 00 00 00 |
|
inline |
Creates an IntegerBER object.
value | IntegerBER integer value. |
Definition at line 1185 of file BER.h.
References setValue().
|
inlinevirtual |
Decodes IntegerBER from stream.
The inherited BER::decodeNumeric<T>() template function decodes type, length and value.
stream | Stream to read from. |
flag | Decoding flag. |
Reimplemented from SNMP::BER.
Definition at line 1212 of file BER.h.
References _value, and SNMP::BER::decodeNumeric().
|
inlinevirtual |
Decodes IntegerBER from memory buffer.
The inherited BER::decodeNumeric<T>() template function decodes type, length and value.
buffer | Pointer to the buffer. |
Reimplemented from SNMP::BER.
Definition at line 1239 of file BER.h.
References _value, and SNMP::BER::decodeNumeric().
|
inlinevirtual |
Encodes IntegerBER to stream.
The inherited BER::encodeNumeric<T>() template function encodes type, length and value.
stream | Stream to write to. |
Reimplemented from SNMP::BER.
Definition at line 1199 of file BER.h.
References _value, and SNMP::BER::encodeNumeric().
|
inlinevirtual |
Encodes IntegerBER to memory buffer.
The inherited BER::encodeNumeric<T>() template function encodes type, length and value.
buffer | Pointer to the buffer. |
Reimplemented from SNMP::BER.
Definition at line 1226 of file BER.h.
References _value, and SNMP::BER::encodeNumeric().
|
inline |
Gets the IntegerBER value.
Definition at line 1249 of file BER.h.
References _value.
|
inline |
Sets the IntegerBER value.
value | IntegerBER integer value. |
Definition at line 1260 of file BER.h.
References _value, SNMP::BER::setNegative(), and SNMP::BER::setPositive().
Referenced by IntegerBER().
|
private |
IntegerBER integer value.
Definition at line 1271 of file BER.h.
Referenced by decode(), decode(), encode(), encode(), getValue(), and setValue().