ronnie
2022-10-23 c843c92e9e45fb6ff0fc60f21f9832819bec8e23
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
// 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_DECOMPRESSOR_INTERFACE_H_
#define _BSDIFF_DECOMPRESSOR_INTERFACE_H_
 
#include <stddef.h>
#include <stdint.h>
 
#include <memory>
 
#include "bsdiff/constants.h"
 
namespace bsdiff {
 
class DecompressorInterface {
 public:
  virtual ~DecompressorInterface() {}
 
  // Set the buffer starting from |input_data| with length |size| as the input
  // compressed stream. This buffer is owned by the caller and should stay
  // valid until the Close() function is called.
  virtual bool SetInputData(const uint8_t* input_data, size_t size) = 0;
 
  // Decompress the stream and output |bytes_to_output| bytes of data to
  // |output_data|. Returns false if not all bytes_to_output can be
  // decompressed from the stream due to a decompressor error or EOF.
  virtual bool Read(uint8_t* output_data, size_t bytes_to_output) = 0;
 
  // Close the decompression stream.
  virtual bool Close() = 0;
};
 
std::unique_ptr<DecompressorInterface> CreateDecompressor(CompressorType type);
 
}  // namespace bsdiff
#endif  // _BSDIFF_DECOMPRESSOR_INTERFACE_H_