21 #ifndef XRDCLHTTPCHECKSUM_HH_
22 #define XRDCLHTTPCHECKSUM_HH_
44 case ChecksumType::kCRC32C:
46 case ChecksumType::kMD5:
48 case ChecksumType::kSHA1:
50 case ChecksumType::kSHA256:
52 case ChecksumType::kAll:
53 case ChecksumType::kUnknown:
61 case ChecksumType::kCRC32C:
63 case ChecksumType::kMD5:
65 case ChecksumType::kSHA1:
67 case ChecksumType::kSHA256:
69 case ChecksumType::kAll:
70 case ChecksumType::kUnknown:
77 if (str ==
"crc32c") {
78 return ChecksumType::kCRC32C;
79 }
else if (str ==
"md5") {
80 return ChecksumType::kMD5;
81 }
else if (str ==
"sha1") {
82 return ChecksumType::kSHA1;
83 }
else if (str ==
"sha256") {
84 return ChecksumType::kSHA256;
86 return ChecksumType::kUnknown;
93 std::array<unsigned char, g_max_checksum_length>
value;
108 if ((ctype == ChecksumType::kUnknown) || (ctype == ChecksumType::kAll))
return false;
109 return checksums[
static_cast<size_t>(ctype)].type != ChecksumType::kUnknown;
119 const std::array<unsigned char, g_max_checksum_length> &
Get(
ChecksumType ctype)
const {
120 if ((ctype == ChecksumType::kUnknown) || (ctype == ChecksumType::kAll))
121 ctype = ChecksumType::kCRC32C;
122 return checksums[
static_cast<size_t>(ctype)].value;
128 bool Set(
ChecksumType ctype,
const std::array<unsigned char, g_max_checksum_length> &value) {
129 if ((ctype == ChecksumType::kUnknown) || (ctype == ChecksumType::kAll))
return false;
130 checksums[
static_cast<size_t>(ctype)] =
ChecksumEntry{ctype, value};
137 std::tuple<ChecksumType, std::array<unsigned char, g_max_checksum_length>,
bool>
GetFirst()
const {
138 for (
int idx=0; idx < static_cast<int>(ChecksumType::kAll); ++idx) {
139 if (checksums[idx].type != ChecksumType::kUnknown) {
140 return std::make_tuple(
static_cast<ChecksumType>(idx), checksums[idx].value,
true);
143 return std::make_tuple(ChecksumType::kUnknown, std::array<unsigned char, g_max_checksum_length>(),
false);
147 std::array<ChecksumEntry, static_cast<int>(ChecksumType::kAll)> checksums;
std::tuple< ChecksumType, std::array< unsigned char, g_max_checksum_length >, bool > GetFirst() const
const std::array< unsigned char, g_max_checksum_length > & Get(ChecksumType ctype) const
bool IsSet(ChecksumType ctype) const
bool Set(ChecksumType ctype, const std::array< unsigned char, g_max_checksum_length > &value)
size_t GetChecksumLength(ChecksumType ctype)
ChecksumType GetTypeFromString(const std::string &str)
std::array< unsigned char, g_max_checksum_length > value
const std::string GetTypeString(ChecksumType ctype)
constexpr size_t g_max_checksum_length