SNMP 2.0.0
|
BER object to handle float. More...
#include <src/BER.h>
Public Member Functions | |
FloatBER (const float value, const unsigned int type=Type::Float) | |
Creates a FloatBER object. | |
virtual void | encode (Stream &stream) |
Encodes FloatBER to stream. | |
virtual void | decode (Stream &stream, const uint8_t flag=Flag::None) |
Decodes FloatBER from stream. | |
virtual uint8_t * | encode (uint8_t *buffer) |
Encodes FloatBER to memory buffer. | |
virtual uint8_t * | decode (uint8_t *buffer) |
Decodes FloatBER from memory buffer. | |
const float | getValue () const |
Gets the FloatBER value. | |
void | setValue (const float value) |
Sets the FloatBER 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. | |
Protected Attributes | |
float | _value |
Protected Attributes inherited from SNMP::BER | |
Length | _length |
Type | _type |
Protected Attributes inherited from SNMP::Base | |
unsigned int | _size = 0 |
Static Protected Attributes | |
static constexpr uint8_t | LENGTH = 4 |
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. | |
BER object to handle float.
IEEE 754 single precision 32-bit is used to represent float.
Example
Float | Encoding |
---|---|
0 | 48 04 00 00 00 00 |
+inf | 48 04 7F 80 00 00 |
-inf | 48 04 FF 80 00 00 |
NaN | 48 04 FF FF FF FF |
|
inline |
Creates a FloatBER object.
Definition at line 2481 of file BER.h.
References SNMP::BER::_length, LENGTH, and setValue().
|
inlinevirtual |
Decodes FloatBER 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 2509 of file BER.h.
References _value, and SNMP::BER::decodeNumeric().
|
inlinevirtual |
Decodes FloatBER 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 2536 of file BER.h.
References _value, and SNMP::BER::decodeNumeric().
|
inlinevirtual |
Encodes FloatBER 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 2496 of file BER.h.
References _value, and SNMP::BER::encodeNumeric().
|
inlinevirtual |
Encodes FloatBER 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 2522 of file BER.h.
References _value, and SNMP::BER::encodeNumeric().
|
inline |
|
inline |
|
protected |
FloatBER float value.
Definition at line 2564 of file BER.h.
Referenced by decode(), decode(), encode(), encode(), getValue(), and setValue().
|
staticconstexprprotected |