huangcm
2025-02-24 69ed55dec4b2116a19e4cca4393cbc014fce5fb2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Copyright 2017 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
 
#ifndef _BSDIFF_COMPRESSOR_INTERFACE_H_
#define _BSDIFF_COMPRESSOR_INTERFACE_H_
 
#include <stddef.h>
#include <stdint.h>
 
#include <memory>
#include <vector>
 
#include "bsdiff/constants.h"
 
namespace bsdiff {
 
class CompressorInterface {
 public:
  virtual ~CompressorInterface() = default;
 
  // Compress and write |size| bytes of input data starting from |buf|.
  virtual bool Write(const uint8_t* buf, size_t size) = 0;
 
  // Finish the compression step.
  virtual bool Finish() = 0;
 
  // Return the compressed data. This method must be only called after Finish().
  virtual const std::vector<uint8_t>& GetCompressedData() = 0;
 
  // Return the type of the current compressor.
  virtual CompressorType Type() const = 0;
 
 protected:
  CompressorInterface() = default;
};
 
}  // namespace bsdiff
 
#endif  // _BSDIFF_COMPRESSOR_INTERFACE_H_