libxcks  0.1.0.1
libxcks::ChecksumValue Class Reference

Stores the value of a checksum. More...

#include <ckvalue.hpp>

Public Member Functions

 ChecksumValue ()
 Default constructor. More...
 
 ChecksumValue (const uint8_t *value, const size_t size, const ChecksumAlgoId type)
 Constructor with a checksum's value. More...
 
 ChecksumValue (const std::string &strValue, const ChecksumAlgoId type)
 Constructor with a checksum's value. More...
 
 ChecksumValue (const Checksum &checksum)
 Constructor from a checksum's value. More...
 
 ChecksumValue (const ChecksumValue &source)
 Copy constructor. More...
 
 ChecksumValue (ChecksumValue &&rhs)
 Move constructor. More...
 
ChecksumValueoperator= (const ChecksumValue &source)
 Assignment operator. More...
 
ChecksumValueoperator= (ChecksumValue &&rhs)
 Move assignment operator. More...
 
virtual ~ChecksumValue ()
 Destructor. More...
 
bool operator== (const ChecksumValue &cmp) const
 Tests if two checksum's values are equals. More...
 
bool operator!= (const ChecksumValue &cmp) const
 Tests if two checksum's values are differents. More...
 
int compare (const ChecksumValue &cmp) const
 Compares this value with the value of another checksum. More...
 
const uint8_t * getValue () const
 Gets the value of the checksum. More...
 
bool getValue (uint8_t *value, const size_t size) const
 Gets the value of the checksum. More...
 
void setValue (const uint8_t *value, const size_t size, const ChecksumAlgoId type)
 Sets the value of the checksum. More...
 
void setValue (const std::string &strValue, const ChecksumAlgoId type)
 Sets the value of the checksum. More...
 
size_t getSize () const
 Gets the size of the checksum's value. More...
 
ChecksumAlgoId getType () const
 Gets the type of the checksum. More...
 

Protected Member Functions

void clone (const ChecksumValue &source)
 Clones the source instance in this instance. More...
 

Protected Attributes

uint8_t * value
 Value of the checksum. More...
 
size_t valueSize
 Size of the checksum's value. More...
 
ChecksumAlgoId type
 Type of the checksum. More...
 

Detailed Description

Stores the value of a checksum.

This class supports comparison and assignment operations.

Definition at line 44 of file ckvalue.hpp.

Constructor & Destructor Documentation

◆ ChecksumValue() [1/6]

libxcks::ChecksumValue::ChecksumValue ( )

Default constructor.

Definition at line 47 of file ckvalue.cpp.

◆ ChecksumValue() [2/6]

libxcks::ChecksumValue::ChecksumValue ( const uint8_t *  value,
const size_t  size,
const ChecksumAlgoId  type 
)

Constructor with a checksum's value.

Parameters
valueValue of the checksum.
sizeSize of the checksum' value.
typeType of the checksum.

Definition at line 135 of file ckvalue.cpp.

◆ ChecksumValue() [3/6]

libxcks::ChecksumValue::ChecksumValue ( const std::string &  strValue,
const ChecksumAlgoId  type 
)

Constructor with a checksum's value.

The provided string must be compliant with the following regular expression: (([a-fA-F0-9]){2}\s?)*(([a-fA-F0-9]){2}). If a parsing error occurs, an empty value is set.

Parameters
strValueNew value of the checksum.
typeType of the new checksum's value.

Definition at line 153 of file ckvalue.cpp.

◆ ChecksumValue() [4/6]

libxcks::ChecksumValue::ChecksumValue ( const Checksum checksum)

Constructor from a checksum's value.

Parameters
checksumChecksum from which the values are taken.

Definition at line 166 of file ckvalue.cpp.

◆ ChecksumValue() [5/6]

libxcks::ChecksumValue::ChecksumValue ( const ChecksumValue source)

Copy constructor.

Parameters
sourceSource instance.

Definition at line 74 of file ckvalue.cpp.

◆ ChecksumValue() [6/6]

libxcks::ChecksumValue::ChecksumValue ( ChecksumValue &&  rhs)

Move constructor.

Parameters
rhsThe right hand side instance.

Definition at line 86 of file ckvalue.cpp.

◆ ~ChecksumValue()

libxcks::ChecksumValue::~ChecksumValue ( )
virtual

Destructor.

Definition at line 187 of file ckvalue.cpp.

Member Function Documentation

◆ clone()

void libxcks::ChecksumValue::clone ( const ChecksumValue source)
protected

Clones the source instance in this instance.

Parameters
sourceSource instance.

Definition at line 61 of file ckvalue.cpp.

◆ compare()

int libxcks::ChecksumValue::compare ( const ChecksumValue cmp) const

Compares this value with the value of another checksum.

Note
This method assumes that the type of the two values is identical.
Parameters
cmpChecksum's value to compare with this checksum's value.
Returns
A negative, zero or positive value according to whether this value is less than, equal to or greater than the passed one.

Definition at line 244 of file ckvalue.cpp.

◆ getSize()

size_t libxcks::ChecksumValue::getSize ( ) const

Gets the size of the checksum's value.

Returns
The size of the checksum's value.

Definition at line 424 of file ckvalue.cpp.

◆ getType()

ChecksumAlgoId libxcks::ChecksumValue::getType ( ) const

Gets the type of the checksum.

Returns
The type of the checksum.

Definition at line 436 of file ckvalue.cpp.

◆ getValue() [1/2]

const uint8_t * libxcks::ChecksumValue::getValue ( ) const

Gets the value of the checksum.

Returns
The value of the checksum.
Remarks
It's the instance of this class which is responsible to the deletion of the value, don't call delete[] on the returned value. So don't use the returned value outside the lifetime of this ChecksumValue's instance.

Definition at line 270 of file ckvalue.cpp.

◆ getValue() [2/2]

bool libxcks::ChecksumValue::getValue ( uint8_t *  value,
const size_t  size 
) const

Gets the value of the checksum.

Parameters
valueThe buffer that will contain the value of checksum.
sizeSize of the buffer that will contain the value of checksum.
Returns
true if the buffer is big enough to store the checksum's value, false if not (in this case, the checksums' value is not copied).
Remarks
It's the caller which is responsible to the deletion of the value.

Definition at line 287 of file ckvalue.cpp.

◆ operator!=()

bool libxcks::ChecksumValue::operator!= ( const ChecksumValue cmp) const

Tests if two checksum's values are differents.

Parameters
cmpChecksum's value to compare with this checksum's value.
Returns
true if one or more of the value, the size or the type of the two checksums are differents, false otherwise.

Definition at line 228 of file ckvalue.cpp.

◆ operator=() [1/2]

ChecksumValue & libxcks::ChecksumValue::operator= ( ChecksumValue &&  rhs)

Move assignment operator.

Parameters
rhsThe right hand side instance.

Definition at line 113 of file ckvalue.cpp.

◆ operator=() [2/2]

ChecksumValue & libxcks::ChecksumValue::operator= ( const ChecksumValue source)

Assignment operator.

Parameters
sourceSource instance.
Returns
A reference on the instance.

Definition at line 100 of file ckvalue.cpp.

◆ operator==()

bool libxcks::ChecksumValue::operator== ( const ChecksumValue cmp) const

Tests if two checksum's values are equals.

Parameters
cmpChecksum's value to compare with this checksum's value.
Returns
true if the value, the size and the type of the two checksums are strictly equals, false otherwise.

Definition at line 202 of file ckvalue.cpp.

◆ setValue() [1/2]

void libxcks::ChecksumValue::setValue ( const std::string &  strValue,
const ChecksumAlgoId  type 
)

Sets the value of the checksum.

The provided string must be compliant with the following regular expression: (([a-fA-F0-9]){2}\s?)*(([a-fA-F0-9]){2}). If a parsing error occurs, an empty value is set.

Parameters
strValueNew value of the checksum.
typeType of the new checksum's value.

Definition at line 349 of file ckvalue.cpp.

◆ setValue() [2/2]

void libxcks::ChecksumValue::setValue ( const uint8_t *  value,
const size_t  size,
const ChecksumAlgoId  type 
)

Sets the value of the checksum.

Parameters
valueNew value of the checksum. Can be nullptr.
sizeSize of the new checksum's value.
typeType of the new checksum's value.

Definition at line 305 of file ckvalue.cpp.

Member Data Documentation

◆ type

ChecksumAlgoId libxcks::ChecksumValue::type
protected

Type of the checksum.

Definition at line 49 of file ckvalue.hpp.

◆ value

uint8_t* libxcks::ChecksumValue::value
protected

Value of the checksum.

Definition at line 47 of file ckvalue.hpp.

◆ valueSize

size_t libxcks::ChecksumValue::valueSize
protected

Size of the checksum's value.

Definition at line 48 of file ckvalue.hpp.


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