47 ChecksumValue::ChecksumValue()
51 type = ChecksumAlgoId::Invalid;
74 ChecksumValue::ChecksumValue(
const ChecksumValue& source) : value(nullptr)
87 valueSize(exchange(rhs.valueSize, 0)),
117 if (
value !=
nullptr)
119 value = exchange(rhs.value,
nullptr);
121 type = exchange(rhs.type, ChecksumAlgoId::Invalid);
137 this->value =
nullptr;
155 this->
value =
nullptr;
170 if (
value ==
nullptr)
173 type = ChecksumAlgoId::Invalid;
189 if (
value !=
nullptr)
190 setValue(
nullptr, 0, ChecksumAlgoId::Invalid);
230 return !((*this) == cmp);
250 while ((res == 0) && i < this->
valueSize)
307 if ((this->value !=
nullptr) && (this->value !=
value))
310 delete[] this->
value;
311 this->value =
nullptr;
314 if (
value ==
nullptr || size == 0)
316 this->value =
nullptr;
318 this->type = ChecksumAlgoId::Invalid;
322 this->value =
new uint8_t[size];
323 if (this->value ==
nullptr)
326 this->type = ChecksumAlgoId::Invalid;
330 memcpy(this->value,
value, size);
351 if (strValue.empty())
353 setValue(
nullptr, 0, ChecksumAlgoId::Invalid);
358 uint8_t* buf =
new uint8_t[strValue.length() / 2];
361 const size_t l = strValue.length();
366 while (res !=
nullptr && i < l)
372 if (sc > 0 && b.length() > 0)
383 lVal = stoul(b,
nullptr, 16);
390 buf[size] =
static_cast<uint8_t
>(lVal);
398 if (sc > 1 || i == 0 || i == l - 1)
410 setValue(
nullptr, 0, ChecksumAlgoId::Invalid);
458 bool notFound =
true;
459 ArrayChecksumValue::const_iterator it = ckvalues.cbegin();
461 while (notFound && it != ckvalues.cend())
463 if (it->getType() == type)
Classes for enumerate and create all the checksums' algorithms that the application knows.
Stores the value of a checksum.
void LIBXCKS_SO_EXPORT getNullValues(ArrayChecksumValue &values, const ArrayChecksumAlgoId &ids)
Gets an array of null checksums' values from an array of checksums ids.
std::vector< ChecksumValue > ArrayChecksumValue
Array of values of checksum.
bool LIBXCKS_SO_EXPORT hasChecksumValueWithAlgoId(const ArrayChecksumValue &ckvalues, const ChecksumAlgoId type)
Checks if the array as a value of the given type.
static ChecksumValue getNullValue(const ChecksumAlgoId id)
Gives null value of the specified checksum or hash identifier.
static bool exists(const ChecksumAlgoId id)
Returns true if the given identifier of the checksum or hash algorithm exists.
Stores the value of a checksum.
virtual ~ChecksumValue()
Destructor.
ChecksumValue()
Default constructor.
ChecksumAlgoId type
Type of the checksum.
ChecksumAlgoId getType() const
Gets the type of the checksum.
const uint8_t * getValue() const
Gets the value of the checksum.
ChecksumValue & operator=(const ChecksumValue &source)
Assignment operator.
int compare(const ChecksumValue &cmp) const
Compares this value with the value of another checksum.
bool operator!=(const ChecksumValue &cmp) const
Tests if two checksum's values are differents.
bool operator==(const ChecksumValue &cmp) const
Tests if two checksum's values are equals.
void setValue(const uint8_t *value, const size_t size, const ChecksumAlgoId type)
Sets the value of the checksum.
void clone(const ChecksumValue &source)
Clones the source instance in this instance.
size_t getSize() const
Gets the size of the checksum's value.
size_t valueSize
Size of the checksum's value.
uint8_t * value
Value of the checksum.
Computes a checksum from a byte stream.
virtual ChecksumAlgoId getID() const =0
Returns an unique identifier for the checksum or the hash algorithm.
virtual size_t getSize() const =0
Returns the minimal size to allocate in memory to store the checksum with the getValue(buffer) metho...
virtual uint8_t * getValue(uint8_t *buffer) const =0
Returns the checksum value in the first bytes of the given address.
std::vector< ChecksumAlgoId > ArrayChecksumAlgoId
Array of ids of algorithms of checksums.
ChecksumAlgoId
Ids of algorithms of checksums.
@ Invalid
Invalid algorithm id.