blob: c0ff18deb55be967ea5ed7853d114b5e55e82cc3 [file] [log] [blame]
Tianjie Xu1c26e2e2017-10-26 17:19:41 -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_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
Tianjie Xu4d10c3e2017-10-26 14:02:06 -070014#include "bsdiff/constants.h"
Tianjie Xu1c26e2e2017-10-26 17:19:41 -070015
Tianjie Xu4d10c3e2017-10-26 14:02:06 -070016namespace bsdiff {
Tianjie Xu1c26e2e2017-10-26 17:19:41 -070017
18class 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
Tianjie Xub4cba642017-11-14 22:46:38 -080031 // Return the type of the current compressor.
Tianjie Xu32b1f212018-03-06 11:42:45 -080032 virtual CompressorType Type() const = 0;
Tianjie Xub4cba642017-11-14 22:46:38 -080033
Tianjie Xu1c26e2e2017-10-26 17:19:41 -070034 protected:
35 CompressorInterface() = default;
36};
37
Tianjie Xu1c26e2e2017-10-26 17:19:41 -070038} // namespace bsdiff
39
40#endif // _BSDIFF_COMPRESSOR_INTERFACE_H_