21 #ifndef XRDCLHTTPCHECKSUM_HH_
22 #define XRDCLHTTPCHECKSUM_HH_
46 case ChecksumType::kADLER32:
48 case ChecksumType::kCRC32:
50 case ChecksumType::kCRC32C:
52 case ChecksumType::kMD5:
54 case ChecksumType::kSHA1:
56 case ChecksumType::kSHA256:
58 case ChecksumType::kAll:
59 case ChecksumType::kUnknown:
67 case ChecksumType::kADLER32:
68 case ChecksumType::kCRC32:
69 case ChecksumType::kCRC32C:
71 case ChecksumType::kMD5:
73 case ChecksumType::kSHA1:
75 case ChecksumType::kSHA256:
77 case ChecksumType::kAll:
78 case ChecksumType::kUnknown:
85 if (str ==
"adler" || str ==
"adler32") {
86 return ChecksumType::kADLER32;
87 }
else if (str ==
"crc32") {
88 return ChecksumType::kCRC32;
89 }
else if (str ==
"crc32c") {
90 return ChecksumType::kCRC32C;
91 }
else if (str ==
"md5") {
92 return ChecksumType::kMD5;
93 }
else if (str ==
"sha1") {
94 return ChecksumType::kSHA1;
95 }
else if (str ==
"sha256") {
96 return ChecksumType::kSHA256;
98 return ChecksumType::kUnknown;
105 std::array<unsigned char, g_max_checksum_length>
value;
120 if ((ctype == ChecksumType::kUnknown) || (ctype == ChecksumType::kAll))
return false;
121 return checksums[
static_cast<size_t>(ctype)].type != ChecksumType::kUnknown;
131 const std::array<unsigned char, g_max_checksum_length> &
Get(
ChecksumType ctype)
const {
132 if ((ctype == ChecksumType::kUnknown) || (ctype == ChecksumType::kAll))
133 ctype = ChecksumType::kCRC32C;
134 return checksums[
static_cast<size_t>(ctype)].value;
140 bool Set(
ChecksumType ctype,
const std::array<unsigned char, g_max_checksum_length> &value) {
141 if ((ctype == ChecksumType::kUnknown) || (ctype == ChecksumType::kAll))
return false;
142 checksums[
static_cast<size_t>(ctype)] =
ChecksumEntry{ctype, value};
149 std::tuple<ChecksumType, std::array<unsigned char, g_max_checksum_length>,
bool>
GetFirst()
const {
150 for (
int idx=0; idx < static_cast<int>(ChecksumType::kAll); ++idx) {
151 if (checksums[idx].type != ChecksumType::kUnknown) {
152 return std::make_tuple(
static_cast<ChecksumType>(idx), checksums[idx].value,
true);
155 return std::make_tuple(ChecksumType::kUnknown, std::array<unsigned char, g_max_checksum_length>(),
false);
159 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