blob: ce494305a9526eb7dc428bbca4d3ce3290130691 [file] [log] [blame]
Kelvin Zhang4eae81e2021-12-09 17:07:17 -08001//
2// Copyright (C) 2021 The Android Open Source Project
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15//
16
17#ifndef UPDATE_ENGINE_LZ4DIFF_LZ4PATCH_H_
18#define UPDATE_ENGINE_LZ4DIFF_LZ4PATCH_H_
19
Kelvin Zhang893b3a12021-12-30 12:28:53 -080020#include "lz4diff/lz4diff_compress.h"
Kelvin Zhang4eae81e2021-12-09 17:07:17 -080021#include "lz4diff_format.h"
22
23namespace chromeos_update_engine {
24bool Lz4Patch(std::string_view src_data,
25 std::string_view patch_data,
26 Blob* output);
Kelvin Zhang893b3a12021-12-30 12:28:53 -080027bool Lz4Patch(const Blob& src_data, const Blob& patch_data, Blob* output);
Kelvin Zhang4eae81e2021-12-09 17:07:17 -080028
Kelvin Zhang8389dfe2022-01-13 12:47:11 -080029std::ostream& operator<<(std::ostream& out, const CompressionAlgorithm& info);
30
Kelvin Zhang4eae81e2021-12-09 17:07:17 -080031std::ostream& operator<<(std::ostream& out, const Lz4diffHeader&);
32
33template <typename T>
34std::ostream& operator<<(std::ostream& out,
35 const google::protobuf::RepeatedPtrField<T>& arr) {
36 if (arr.empty()) {
37 out << "[]";
38 return out;
39 }
40 out << "[";
41 auto begin = arr.begin();
42 out << *begin;
43 ++begin;
44 for (; begin != arr.end(); ++begin) {
45 out << ", " << *begin;
46 }
47 out << "]";
48
49 return out;
50}
51
52} // namespace chromeos_update_engine
53
54#endif