blob: 46ee444c6c62e8d92a3cad632381ff3d6fca77b8 [file] [log] [blame]
Tianjie Xu65288122017-10-13 15:10:58 -07001// 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_DECOMPRESSOR_INTERFACE_H_
6#define _BSDIFF_DECOMPRESSOR_INTERFACE_H_
7
8#include <stddef.h>
9#include <stdint.h>
10
Tianjie Xu4d10c3e2017-10-26 14:02:06 -070011#include <memory>
12
13#include "bsdiff/constants.h"
14
Tianjie Xu65288122017-10-13 15:10:58 -070015namespace bsdiff {
16
17class DecompressorInterface {
18 public:
19 virtual ~DecompressorInterface() {}
20
21 // Set the buffer starting from |input_data| with length |size| as the input
22 // compressed stream. This buffer is owned by the caller and should stay
23 // valid until the Close() function is called.
24 virtual bool SetInputData(const uint8_t* input_data, size_t size) = 0;
25
26 // Decompress the stream and output |bytes_to_output| bytes of data to
27 // |output_data|. Returns false if not all bytes_to_output can be
28 // decompressed from the stream due to a decompressor error or EOF.
29 virtual bool Read(uint8_t* output_data, size_t bytes_to_output) = 0;
30
31 // Close the decompression stream.
32 virtual bool Close() = 0;
33};
34
Tianjie Xu4d10c3e2017-10-26 14:02:06 -070035std::unique_ptr<DecompressorInterface> CreateDecompressor(CompressorType type);
36
Tianjie Xu65288122017-10-13 15:10:58 -070037} // namespace bsdiff
38#endif // _BSDIFF_DECOMPRESSOR_INTERFACE_H_