Rename the variable 'quality' to 'brotli_quality'
Right now the quality is only used in the brotli compressor. And it
would be ambiguous if we add another compressor in the future; since the
compressors may have different interpretion on the quality value.
Test: unit tests pass; run bsdiff
Change-Id: I23af06a135b2b47df5209171f7db0773ac02a326
diff --git a/bsdiff_arguments.h b/bsdiff_arguments.h
index b330834..1907e73 100644
--- a/bsdiff_arguments.h
+++ b/bsdiff_arguments.h
@@ -14,18 +14,19 @@
namespace bsdiff {
-// Class to store the patch writer options about format, type and quality.
+// Class to store the patch writer options about format, type and
+// brotli_quality.
class BsdiffArguments {
public:
BsdiffArguments()
: format_(BsdiffFormat::kLegacy),
compressor_type_(CompressorType::kBZ2),
- compression_quality_(-1) {}
+ brotli_quality_(-1) {}
- BsdiffArguments(BsdiffFormat format, CompressorType type, int quality)
+ BsdiffArguments(BsdiffFormat format, CompressorType type, int brotli_quality)
: format_(format),
compressor_type_(type),
- compression_quality_(quality) {}
+ brotli_quality_(brotli_quality) {}
// Check if the compressor type is compatible with the bsdiff format.
bool IsValid() const;
@@ -37,7 +38,7 @@
CompressorType compressor_type() const { return compressor_type_; }
- int compression_quality() const { return compression_quality_; }
+ int brotli_quality() const { return brotli_quality_; }
// Parse the command line arguments of the main function and set all the
// fields accordingly.
@@ -52,8 +53,12 @@
// Parse the bsdiff format from string.
static bool ParseBsdiffFormat(const std::string& str, BsdiffFormat* format);
- // Parse the compression quality (for brotli) from string.
- static bool ParseQuality(const std::string& str, int* quality);
+ // Parse the compression quality (for brotli) from string; also check if the
+ // value is within the valid range.
+ static bool ParseQuality(const std::string& str,
+ int* quality,
+ int min,
+ int max);
private:
// Current format supported are the legacy "BSDIFF40" or "BSDF2".
@@ -62,9 +67,8 @@
// The algorithm to compress the patch, i.e. BZ2 or Brotli.
CompressorType compressor_type_;
- // The quality of compression, only valid when using brotli as the
- // compression algorithm.
- int compression_quality_;
+ // The quality of brotli compressor.
+ int brotli_quality_;
size_t min_length_{0};
};