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

BER object to handle boolean. More...

#include <src/BER.h>

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

Public Member Functions

 BooleanBER (const bool value)
 Creates a BooleanBER object.
 
virtual void encode (Stream &stream)
 Encodes BooleanBER to stream.
 
virtual void decode (Stream &stream, const uint8_t flag=Flag::None)
 Decodes BooleanBER from stream.
 
virtual uint8_t * encode (uint8_t *buffer)
 Encodes BooleanBER to memory buffer.
 
virtual uint8_t * decode (uint8_t *buffer)
 Decodes BooleanBER from memory buffer.
 
const bool getValue () const
 Gets the BooleanBER value.
 
void setValue (const bool value)
 Sets the BooleanBER 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

bool _value
 

Static Private Attributes

static constexpr uint8_t LENGTH = 1
 
static constexpr uint8_t SIZE = 3
 

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
BERcreate (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
 

Detailed Description

BER object to handle boolean.

  • Type is TYPE_BOOLEAN.
  • Length is fixed, 1 byte, short form encoding.
  • Size is fixed, 3 bytes.

Example

Boolean Encoding
true 01 01 FF
false 01 01 00

Definition at line 1056 of file BER.h.

Constructor & Destructor Documentation

◆ BooleanBER()

SNMP::BooleanBER::BooleanBER ( const bool value)
inline

Creates a BooleanBER object.

Parameters
valueBooleanBER boolean value.

Definition at line 1063 of file BER.h.

References SNMP::BER::_length, _value, and LENGTH.

Member Function Documentation

◆ decode() [1/2]

virtual void SNMP::BooleanBER::decode ( Stream & stream,
const uint8_t flag = Flag::None )
inlinevirtual

Decodes BooleanBER from stream.

Type and length are decoded by the inherited BER::decode() then BooleanBER value is decoded.

Parameters
streamStream to read from.
flagDecoding flag.

Reimplemented from SNMP::BER.

Definition at line 1092 of file BER.h.

References _value, and SNMP::BER::decode().

◆ decode() [2/2]

virtual uint8_t * SNMP::BooleanBER::decode ( uint8_t * buffer)
inlinevirtual

Decodes BooleanBER from memory buffer.

Type and length are decoded by the inherited BER::decode() then BooleanBER value is decoded.

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

Reimplemented from SNMP::BER.

Definition at line 1121 of file BER.h.

References _value, SNMP::BER::decode(), and SIZE.

◆ encode() [1/2]

virtual void SNMP::BooleanBER::encode ( Stream & stream)
inlinevirtual

Encodes BooleanBER to stream.

Type and length are encoded by the inherited BER::encode() then BooleanBER value is encoded.

Parameters
streamStream to write to.

Reimplemented from SNMP::BER.

Definition at line 1078 of file BER.h.

References _value, and SNMP::BER::encode().

◆ encode() [2/2]

virtual uint8_t * SNMP::BooleanBER::encode ( uint8_t * buffer)
inlinevirtual

Encodes BooleanBER to memory buffer.

Type and length are encoded by the inherited BER::encode() then BooleanBER value is encoded.

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

Reimplemented from SNMP::BER.

Definition at line 1106 of file BER.h.

References _value, SNMP::BER::encode(), and SIZE.

◆ getValue()

const bool SNMP::BooleanBER::getValue ( ) const
inline

Gets the BooleanBER value.

Returns
BER boolean value.

Definition at line 1133 of file BER.h.

References _value.

◆ setValue()

void SNMP::BooleanBER::setValue ( const bool value)
inline

Sets the BooleanBER value.

Note
No needs to update fixed length.
Parameters
valueIntegerBER boolean value.

Definition at line 1144 of file BER.h.

References _value.

Member Data Documentation

◆ _value

bool SNMP::BooleanBER::_value
private

BooleanBER boolean value.

Definition at line 1154 of file BER.h.

Referenced by BooleanBER(), decode(), decode(), encode(), encode(), getValue(), and setValue().

◆ LENGTH

uint8_t SNMP::BooleanBER::LENGTH = 1
staticconstexprprivate

Fixed length of the BooleanBER.

Definition at line 1150 of file BER.h.

Referenced by BooleanBER().

◆ SIZE

uint8_t SNMP::BooleanBER::SIZE = 3
staticconstexprprivate

Fixed size of the BooleanBER.

Definition at line 1152 of file BER.h.

Referenced by decode(), and encode().


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