Skip to content

andreiamatuni/zstdpp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

zstdpp

A single file header only C++ convenience wrapper around the libzstd compression/decompression functions.

We use std::string objects as memory containers, and pass them into the zstdpp::compress() and zstd::decompress() functions. These functions return a std::string, who's underlying data is either a compressed or decompressed version of the original.

There are also buffered versions of these functions, which accept a std::string as argument, acting as a preallocated memory buffer to perform compression/decompression (instead of allocating a new buffer on each function call). This helps if you're doing a lot of compression/decompression in a loop.

example usage

#include <string>
#include <iostream>

#include "zstdpp.hpp"

int main() {
  std::string input("this is a string that I want to compress into a smaller\n"
                    "string. Just to make sure there is enough data in the\n"
                    "compression buffer, I'm going to fill this string with a\n"
                    "decent amount of content. Let's hope this works.\n");

  auto compressed = zstdpp::compress(input, 22);

  auto decompressed = zstdpp::decompress(compressed);

}

About

C++ wrapper for libzstd compression functions

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published