Pioneer
Loading...
Searching...
No Matches
LZ4Format.h
Go to the documentation of this file.
1// Copyright © 2019 Pioneer Developers. See AUTHORS.txt for details
2// Licensed under the terms of the GPL v3. See licenses/GPL-3.txt
3
4#pragma once
5
6#include <memory>
7#include <stdexcept>
8#include <string>
9#include <string_view>
10
11namespace lz4 {
12
13 struct DecompressionFailedException : public std::runtime_error {
14 using std::runtime_error::runtime_error;
15 };
16 struct CompressionFailedException : public std::runtime_error {
17 using std::runtime_error::runtime_error;
18 };
19
20 // Checks if the data block could plausibly be a lz4 file.
21 // This really just checks for the magic lz4 bytes and a basic length check.
22 bool IsLZ4Format(const char *data, size_t length);
23
24 // Decompress lz4 format data.
25 // If the input fails format checks or checksum then it will throw an exception.
26 std::string DecompressLZ4(const std::string_view data);
27
28 // Compresses a block of data according to the lz4 framing format.
29 // If compression fails it throws an exception.
30 // lz4_speed is the compression preset; 0 = default compression, 3-12 = HC compression
31 std::string CompressLZ4(const std::string_view data, const int lz4_preset);
32} // namespace lz4
Definition LZ4Format.h:11
std::string CompressLZ4(const std::string_view data, const int lz4_preset)
Definition LZ4Format.cpp:71
bool IsLZ4Format(const char *data, size_t length)
Definition LZ4Format.cpp:11
std::string DecompressLZ4(const std::string_view data)
Definition LZ4Format.cpp:26
Definition LZ4Format.h:16
Definition LZ4Format.h:13