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