decompressor maintenence
cleaning up a bit of code for consistency + adding in zstd to FromString() function Test: m libsnapshot Change-Id: Ic8b7243c5a5ee25326a46e944c13578136f27078
This commit is contained in:
parent
fe6c1d55f7
commit
ad5df32560
1 changed files with 11 additions and 8 deletions
|
@ -18,6 +18,7 @@
|
|||
|
||||
#include <array>
|
||||
#include <cstring>
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
|
@ -62,6 +63,8 @@ std::unique_ptr<IDecompressor> IDecompressor::FromString(std::string_view compre
|
|||
return IDecompressor::Brotli();
|
||||
} else if (compressor == "gz") {
|
||||
return IDecompressor::Gz();
|
||||
} else if (compressor == "zstd") {
|
||||
return IDecompressor::Zstd();
|
||||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -211,10 +214,6 @@ bool GzDecompressor::PartialDecompress(const uint8_t* data, size_t length) {
|
|||
return true;
|
||||
}
|
||||
|
||||
std::unique_ptr<IDecompressor> IDecompressor::Gz() {
|
||||
return std::unique_ptr<IDecompressor>(new GzDecompressor());
|
||||
}
|
||||
|
||||
class BrotliDecompressor final : public StreamDecompressor {
|
||||
public:
|
||||
~BrotliDecompressor();
|
||||
|
@ -275,10 +274,6 @@ bool BrotliDecompressor::PartialDecompress(const uint8_t* data, size_t length) {
|
|||
return true;
|
||||
}
|
||||
|
||||
std::unique_ptr<IDecompressor> IDecompressor::Brotli() {
|
||||
return std::unique_ptr<IDecompressor>(new BrotliDecompressor());
|
||||
}
|
||||
|
||||
class Lz4Decompressor final : public IDecompressor {
|
||||
public:
|
||||
~Lz4Decompressor() override = default;
|
||||
|
@ -382,6 +377,14 @@ class ZstdDecompressor final : public IDecompressor {
|
|||
}
|
||||
};
|
||||
|
||||
std::unique_ptr<IDecompressor> IDecompressor::Brotli() {
|
||||
return std::make_unique<BrotliDecompressor>();
|
||||
}
|
||||
|
||||
std::unique_ptr<IDecompressor> IDecompressor::Gz() {
|
||||
return std::make_unique<GzDecompressor>();
|
||||
}
|
||||
|
||||
std::unique_ptr<IDecompressor> IDecompressor::Lz4() {
|
||||
return std::make_unique<Lz4Decompressor>();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue