Skip to content

Commit

Permalink
[core] silence warning for deprecated fn in Compression.cxx
Browse files Browse the repository at this point in the history
  • Loading branch information
silverweed committed Jun 17, 2024
1 parent 30d8eed commit 86a5a71
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion core/zip/inc/Compression.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ struct RCompressionSetting {
};

// clang-format off
enum R__DEPRECATED(6, 34, "Use RCompressionSetting instead") ECompressionAlgorithm {
enum R__DEPRECATED(6, 34, "Use RCompressionSetting::EAlgorithm instead") ECompressionAlgorithm {
kUseGlobalCompressionSetting = static_cast<int>(RCompressionSetting::EAlgorithm::kUseGlobal),
kUseGlobalSetting = static_cast<int>(RCompressionSetting::EAlgorithm::kUseGlobal),
kZLIB = static_cast<int>(RCompressionSetting::EAlgorithm::kZLIB),
Expand Down
22 changes: 12 additions & 10 deletions core/zip/src/Compression.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ namespace ROOT {

////////////////////////////////////////////////////////////////////////////////

int CompressionSettings(RCompressionSetting::EAlgorithm::EValues algorithm,
int compressionLevel)
int CompressionSettings(RCompressionSetting::EAlgorithm::EValues algorithm, int compressionLevel)
{
if (compressionLevel < 0) compressionLevel = 0;
if (compressionLevel > 99) compressionLevel = 99;
Expand All @@ -25,24 +24,27 @@ namespace ROOT {
return algo * 100 + compressionLevel;
}

int CompressionSettings(ROOT::ECompressionAlgorithm algorithm,
int compressionLevel)
// Avoid spitting warnings for the use of ECompressionAlgorithm, as this function is itself deprecated
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
int CompressionSettings(ROOT::ECompressionAlgorithm algorithm, int compressionLevel)
{
if (compressionLevel < 0) compressionLevel = 0;
if (compressionLevel > 99) compressionLevel = 99;
int algo = algorithm;
if (algorithm >= ROOT::ECompressionAlgorithm::kUndefinedCompressionAlgorithm) algo = 0;
if (algo >= ROOT::RCompressionSetting::EAlgorithm::kUndefined) algo = 0;
return algo * 100 + compressionLevel;
}
#pragma GCC diagnostic pop

std::string RCompressionSetting::AlgorithmToString(RCompressionSetting::EAlgorithm::EValues algorithm)
{
switch (algorithm) {
case EAlgorithm::EValues::kZLIB: return "zlib"; break;
case EAlgorithm::EValues::kLZMA: return "LZMA"; break;
case EAlgorithm::EValues::kOldCompressionAlgo: return "Old compression algorithm"; break;
case EAlgorithm::EValues::kLZ4: return "lz4"; break;
case EAlgorithm::EValues::kZSTD: return "zstd"; break;
case EAlgorithm::EValues::kZLIB: return "zlib";
case EAlgorithm::EValues::kLZMA: return "LZMA";
case EAlgorithm::EValues::kOldCompressionAlgo: return "Old compression algorithm";
case EAlgorithm::EValues::kLZ4: return "lz4";
case EAlgorithm::EValues::kZSTD: return "zstd";
default: return "Undefined compression algorithm";
}
}
Expand Down

0 comments on commit 86a5a71

Please sign in to comment.