|
libxcks
0.1.0.1
|
This class provides some convenient tools to format checksum and hash values. More...
#include <ckformatter.hpp>
Classes | |
| class | ConfigurationProvider |
Configuration provider for ChecksumFormatter. More... | |
Public Types | |
| enum class | NumericBase : uint_least8_t { hexadecimal = 0 , decimal = 1 , octal = 2 } |
| The available numeric bases. More... | |
| using | Positions = std::set< uint_fast16_t > |
| Set of unsigned integers. More... | |
Public Member Functions | |
| ChecksumFormatter ()=delete | |
| Deleted default constructor. More... | |
| ChecksumFormatter (const ChecksumFormatter &)=delete | |
| Deleted copy constructor. More... | |
| ChecksumFormatter & | operator= (const ChecksumFormatter &)=delete |
| Deleted assignment operator. More... | |
| ChecksumFormatter (const ConfigurationProvider &provider, const std::string &algoName, const bool lookInAltNames=true) | |
| Constructs a new checksum's formatter for the given algorithm name or alternative name. More... | |
| ChecksumFormatter (const ConfigurationProvider &provider, const ChecksumAlgoId type) | |
| Constructs a new checksum's formatter for the given algorithm type. More... | |
| ChecksumFormatter (const bool uc=false, const NumericBase nb=NumericBase::hexadecimal, const Positions &sp=Positions()) | |
| Constructs a new checksum's formatter with the given parameters. More... | |
| std::string | format (const uint8_t *value, const size_t size) |
| Format the given checksum's value. More... | |
| bool | getUpperCase () const |
| Returns whether the output will be in uppercase. More... | |
| void | setUpperCase (const bool isUpperCase) |
| Sets whether the output will be in uppercase. More... | |
| NumericBase | getNumericBase () const |
| Returns the numeric base for the output. More... | |
| void | setNumericBase (const NumericBase base) |
| Sets the numeric base for the output. More... | |
| Positions | getSpacesPositions () const |
| Returns the positions of the spaces between two bytes. More... | |
| void | setSpacesPositions (const std::string &spacesPositions) |
| Sets the positions of the spaces between two bytes. More... | |
| void | setSpacesPositions (const Positions &spacesPositions) |
| Sets the positions of the spaces between two bytes. More... | |
Static Public Member Functions | |
| static std::string | format (const ConfigurationProvider &provider, const uint8_t *value, const size_t size, const std::string &algoName, const bool lookInAltNames=true) |
| Format the given checksum's value with the given algorithm's name. More... | |
| static std::string | format (const ConfigurationProvider &provider, const uint8_t *value, const size_t size, const ChecksumAlgoId type) |
| Format the given checksum's value with the given algorithm's type. More... | |
| static std::string | format (const ConfigurationProvider &provider, const ChecksumValue &value) |
| Format the given checksum's value. More... | |
| static Positions | toSpacesPositions (const std::string &spacesPositions) |
| Gets the positions of the spaces between two bytes from a string. More... | |
Protected Member Functions | |
| void | initialise (const ConfigurationProvider &provider, const ChecksumAlgoId type) |
| Initialises the instance. More... | |
Protected Attributes | |
| bool | upperCase |
| Case of the output if numeric base is hexadecimal. More... | |
| NumericBase | numericBase |
| Numeric base of the output. More... | |
| Positions | spacesPos |
| Positions of spaces between two bytes. More... | |
This class provides some convenient tools to format checksum and hash values.
Format parameters are :
Convenient static methods are provided to simplify the usage of this class.
Definition at line 51 of file ckformatter.hpp.
| using libxcks::ChecksumFormatter::Positions = std::set<uint_fast16_t> |
Set of unsigned integers.
Definition at line 55 of file ckformatter.hpp.
|
strong |
The available numeric bases.
Definition at line 58 of file ckformatter.hpp.
|
delete |
Deleted default constructor.
|
delete |
Deleted copy constructor.
| libxcks::ChecksumFormatter::ChecksumFormatter | ( | const ConfigurationProvider & | provider, |
| const std::string & | algoName, | ||
| const bool | lookInAltNames = true |
||
| ) |
Constructs a new checksum's formatter for the given algorithm name or alternative name.
| provider | The configuration provider. |
| algoName | The name of the checksum or hash algorithm. |
| lookInAltNames | Looks for the name of the checksum or hash algorithm in the alternative names. |
Definition at line 54 of file ckformatter.cpp.
| libxcks::ChecksumFormatter::ChecksumFormatter | ( | const ConfigurationProvider & | provider, |
| const ChecksumAlgoId | type | ||
| ) |
Constructs a new checksum's formatter for the given algorithm type.
| provider | The configuration provider. |
| type | The type (identifier) of the algorithm of the checksum. |
Definition at line 73 of file ckformatter.cpp.
| libxcks::ChecksumFormatter::ChecksumFormatter | ( | const bool | uc = false, |
| const NumericBase | nb = NumericBase::hexadecimal, |
||
| const Positions & | sp = Positions() |
||
| ) |
Constructs a new checksum's formatter with the given parameters.
| uc | The case of the output if numeric base is hexadecimal. |
| nb | The numeric base of the output. |
| sp | The positions of spaces between two bytes. |
Definition at line 88 of file ckformatter.cpp.
|
static |
Format the given checksum's value.
| provider | The configuration provider. |
| value | The checksum's value to format. |
Definition at line 310 of file ckformatter.cpp.
|
static |
Format the given checksum's value with the given algorithm's type.
| provider | The configuration provider. |
| value | The value of the checksum. |
| size | The size of the value of the checksum. |
| type | The type (identifier) of the algorithm of the checksum. |
Definition at line 293 of file ckformatter.cpp.
|
static |
Format the given checksum's value with the given algorithm's name.
| provider | The configuration provider. |
| value | The value of the checksum. |
| size | The size of the value of the checksum. |
| algoName | The name of the checksum or hash algorithm. |
| lookInAltNames | Looks for the name of the checksum or hash algorithm in the alternative names. |
Definition at line 269 of file ckformatter.cpp.
| string libxcks::ChecksumFormatter::format | ( | const uint8_t * | value, |
| const size_t | size | ||
| ) |
Format the given checksum's value.
| value | The value of the checksum. |
| size | The size of the value of the checksum. |
3 (hex)digits max + nul character
Definition at line 120 of file ckformatter.cpp.
| ChecksumFormatter::NumericBase libxcks::ChecksumFormatter::getNumericBase | ( | ) | const |
Returns the numeric base for the output.
Definition at line 186 of file ckformatter.cpp.
| ChecksumFormatter::Positions libxcks::ChecksumFormatter::getSpacesPositions | ( | ) | const |
Returns the positions of the spaces between two bytes.
Definition at line 221 of file ckformatter.cpp.
| bool libxcks::ChecksumFormatter::getUpperCase | ( | ) | const |
Returns whether the output will be in uppercase.
Definition at line 161 of file ckformatter.cpp.
|
protected |
Initialises the instance.
| provider | The configuration provider. |
| type | The type (identifier) of the algorithm of the checksum. |
Definition at line 104 of file ckformatter.cpp.
|
delete |
Deleted assignment operator.
| void libxcks::ChecksumFormatter::setNumericBase | ( | const NumericBase | base | ) |
Sets the numeric base for the output.
| base | The new numeric base for the output. |
Definition at line 200 of file ckformatter.cpp.
| void libxcks::ChecksumFormatter::setSpacesPositions | ( | const Positions & | spacesPositions | ) |
Sets the positions of the spaces between two bytes.
| spacesPositions | The new list of the positions of the spaces. |
Definition at line 251 of file ckformatter.cpp.
| void libxcks::ChecksumFormatter::setSpacesPositions | ( | const std::string & | spacesPositions | ) |
Sets the positions of the spaces between two bytes.
The given string must be a suite of integers (which represent the position of the byte where the space will be placed after, the first byte is identified as 0) separated by commas with or without spaces.
| spacesPositions | The new list of the positions of the spaces. |
Definition at line 237 of file ckformatter.cpp.
| void libxcks::ChecksumFormatter::setUpperCase | ( | const bool | isUpperCase | ) |
Sets whether the output will be in uppercase.
| isUpperCase | true if the output should be in uppercase, false otherwise. |
Definition at line 174 of file ckformatter.cpp.
|
static |
Gets the positions of the spaces between two bytes from a string.
The given string must be a suite of integers (which represent the position of the byte where the space will be placed after, the first byte is identified as 0) separated by commas with or without spaces.
| spacesPositions | The new list of the positions of the spaces. |
spacesPositions. Definition at line 328 of file ckformatter.cpp.
|
protected |
Numeric base of the output.
Definition at line 115 of file ckformatter.hpp.
|
protected |
Positions of spaces between two bytes.
Definition at line 116 of file ckformatter.hpp.
|
protected |
Case of the output if numeric base is hexadecimal.
Definition at line 114 of file ckformatter.hpp.