nlib
nn::nlib::Crc32 Class Referencefinal

The class for calculating the CRC-32 for data (streams). More...

#include "nn/nlib/Crc.h"

Public Member Functions

errno_t Update (const void *buf, size_t len) noexcept
 Updates the checksum with data located in the given region. More...
 
errno_t Update (int b) noexcept
 Updates the checksum with one byte of data. More...
 
uint32_t GetValue () const noexcept
 Returns a CRC-32 value. More...
 

Detailed Description

The class for calculating the CRC-32 for data (streams).

Description
There are many ways to calculate CRC-32, but this class uses the same methods as RFC 2083 (PNG) and RFC 1952 (gzip).
// Gets the checksum for the string.
Crc32 c;
const char str[] = "This is a string";
c.Update(&str[0], std::strlen(str));
c.GetValue(); // 0x0876633FUL

Definition at line 10 of file Crc.h.

Member Function Documentation

nn::nlib::Crc32::GetValue ( ) const
noexcept

Returns a CRC-32 value.

Returns
A CRC-32 value.
nn::nlib::Crc32::Update ( const void *  buf,
size_t  len 
)
noexcept

Updates the checksum with data located in the given region.

Parameters
[in]bufThe memory region to use for updating the checksum.
[in]lenThe size of the memory region.
Returns
The function may return ENOMEM only when it is executed for the first time.
nn::nlib::Crc32::Update ( int  b)
noexcept

Updates the checksum with one byte of data.

Parameters
[in]bThe byte data to use for updating the checksum.
Returns
The function may return ENOMEM only when it is executed for the first time.

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