Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jackoalan committed Dec 24, 2018
0 parents commit f7da328
Show file tree
Hide file tree
Showing 6 changed files with 841 additions and 0 deletions.
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
cmake_minimum_required(VERSION 3.10)
project(lzokay)
add_library(lzokay lzokay.hpp lzokay.cpp)
set(LZOKAY_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR} CACHE PATH "lzokay include path" FORCE)
add_executable(lzokaytest test.cpp)
target_link_libraries(lzokaytest lzokay)
22 changes: 22 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
The MIT License

Copyright (c) 2018 Jack Andersen

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

60 changes: 60 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
LZ👌
===

A minimal, C++14 implementation of the
[LZO compression format](http://www.oberhumer.com/opensource/lzo/).

Objective
---------

The implementation provides compression behavior similar to the
`lzo1x_999_compress` function in `lzo2` (i.e. higher compression, lower speed).
The implementation is fixed to the default parameters of the original and
provides no facilities for various compression "levels" or an initialization
dictionary.

The decompressor is compatible with data compressed by other LZO1X
implementations.

Usage
-----

```cpp
#include <lzokay.hpp>
#include <cstring>

int compress_and_decompress(const uint8_t* data, std::size_t length) {
lzokay::EResult error;

/* This variable and 5th parameter of compress() is optional, but may
* be reused across multiple compression runs; avoiding repeat
* allocation/deallocation of the work memory used by the compressor.
*/
lzokay::Dict<> dict;

std::size_t compressed_size = lzokay::compress_worst_size(length);
std::unique_ptr<uint8_t[]> compressed(new uint8_t[compressed_size]);
error = lzokay::compress(data, length, compressed.get(), compressed_size, dict);
if (error < lzokay::EResult::Success)
return 1;

std::unique_ptr<uint8_t[]> decompressed(new uint8_t[length]);
std::size_t decompressed_size = length;
error = lzokay::decompress(compressed.get(), compressed_size,
decompressed.get(), decompressed_size);
if (error < lzokay::EResult::Success)
return 1;

if (std::memcmp(data, decompressed.get(), decompressed_size) != 0)
return 1;

return 0;
}
```
License
-------
LZ👌 is available under the
[MIT License](https://github.com/jackoalan/lzokay/blob/master/LICENSE)
and has no external dependencies.

0 comments on commit f7da328

Please sign in to comment.