#ifndef THIRD_PARTY_SNAPPY_SNAPPY_H__
#define THIRD_PARTY_SNAPPY_SNAPPY_H__
#include <stddef.h>
#include <stdint.h>
#include <string>
#include "snappy-stubs-public.h"
namespace snappy {
class Source;
class Sink;
struct CompressionOptions {
int level = DefaultCompressionLevel();
constexpr CompressionOptions() = default;
constexpr CompressionOptions(int compression_level)
: level(compression_level) {}
static constexpr int MinCompressionLevel() { return 1; }
static constexpr int MaxCompressionLevel() { return 2; }
static constexpr int DefaultCompressionLevel() { return 1; }
};
size_t Compress(Source* reader, Sink* writer);
size_t Compress(Source* reader, Sink* writer,
CompressionOptions options);
bool GetUncompressedLength(Source* source, uint32_t* result);
size_t Compress(const char* input, size_t input_length,
std::string* compressed);
size_t Compress(const char* input, size_t input_length,
std::string* compressed, CompressionOptions options);
size_t CompressFromIOVec(const struct iovec* iov, size_t iov_cnt,
std::string* compressed);
size_t CompressFromIOVec(const struct iovec* iov, size_t iov_cnt,
std::string* compressed,
CompressionOptions options);
bool Uncompress(const char* compressed, size_t compressed_length,
std::string* uncompressed);
bool Uncompress(Source* compressed, Sink* uncompressed);
size_t UncompressAsMuchAsPossible(Source* compressed, Sink* uncompressed);
void RawCompress(const char* input, size_t input_length, char* compressed,
size_t* compressed_length);
void RawCompress(const char* input, size_t input_length, char* compressed,
size_t* compressed_length, CompressionOptions options);
void RawCompressFromIOVec(const struct iovec* iov, size_t uncompressed_length,
char* compressed, size_t* compressed_length);
void RawCompressFromIOVec(const struct iovec* iov, size_t uncompressed_length,
char* compressed, size_t* compressed_length,
CompressionOptions options);
bool RawUncompress(const char* compressed, size_t compressed_length,
char* uncompressed);
bool RawUncompress(Source* compressed, char* uncompressed);
bool RawUncompressToIOVec(const char* compressed, size_t compressed_length,
const struct iovec* iov, size_t iov_cnt);
bool RawUncompressToIOVec(Source* compressed, const struct iovec* iov,
size_t iov_cnt);
size_t MaxCompressedLength(size_t source_bytes);
bool GetUncompressedLength(const char* compressed, size_t compressed_length,
size_t* result);
bool IsValidCompressedBuffer(const char* compressed,
size_t compressed_length);
bool IsValidCompressed(Source* compressed);
static constexpr int kBlockLog = 16;
static constexpr size_t kBlockSize = 1 << kBlockLog;
static constexpr int kMinHashTableBits = 8;
static constexpr size_t kMinHashTableSize = 1 << kMinHashTableBits;
static constexpr int kMaxHashTableBits = 15;
static constexpr size_t kMaxHashTableSize = 1 << kMaxHashTableBits;
}
#endif