Skip to content
This repository has been archived by the owner on Sep 5, 2020. It is now read-only.

Commit

Permalink
(#18) Moved inline functions to a separate header
Browse files Browse the repository at this point in the history
Moved a bunch of inline function to a separate `api_impl.h` header to
avoid polluting too much the main header.
  • Loading branch information
leandor committed Jul 1, 2017
1 parent 65fd9f7 commit 8590470
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 54 deletions.
55 changes: 1 addition & 54 deletions src/papi/lz4/api.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,59 +78,6 @@ namespace lz4 { namespace api {
};
};

namespace lz4 { namespace api {

inline int compressBound(int inputSize)
{
return _detail::LZ4_compressBound(inputSize);
};

inline int compressBound(const span<char> input)
{
return _detail::LZ4_compressBound(input.length());
};

inline int compress_default(const span<char> source, span<char> dest)
{
return _detail::LZ4_compress_default(source.data(), dest.data(), source.length(), dest.length());
};

inline int decompress_safe (const span<char> source, span<char> dest)
{
return _detail::LZ4_decompress_safe(source.data(), dest.data(), source.length(), dest.length());
};

inline int sizeofState()
{
return _detail::LZ4_sizeofState();
};

inline int compress_fast_extState(span<byte> state, const span<char> source, span<char> dest, int acceleration)
{
return _detail::LZ4_compress_fast_extState(state.data(), source.data(), dest.data(), source.length(), dest.length(), acceleration);
};

inline int compress_destSize (span<char>& source, span<char> dest)
{
auto sourceSize = source.length();
volatile int sourceUsed = sourceSize;
auto atExit = finally([&](){
source = source.subspan(sourceSize - sourceUsed);
});

return _detail::LZ4_compress_destSize(source.data(), dest.data(), const_cast<int*>(&sourceUsed), dest.length());
};

inline int decompress_fast (const span<char> source, span<char> dest, int uncompressedSize)
{
return _detail::LZ4_decompress_fast(source.data(), dest.data(), uncompressedSize);
};

inline int decompress_safe_partial (const span<char> source, span<char> dest, int targetOutputSize)
{
return _detail::LZ4_decompress_safe_partial (source.data(), dest.data(), source.length(), targetOutputSize, dest.length());
};
};
};
#include "api_impl.h"

#endif // __CINT_LZ4_API__
57 changes: 57 additions & 0 deletions src/papi/lz4/api_impl.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#pragma once


namespace lz4 { namespace api {

inline int compressBound(int inputSize)
{
return _detail::LZ4_compressBound(inputSize);
};

inline int compressBound(const span<char> input)
{
return _detail::LZ4_compressBound(input.length());
};

inline int compress_default(const span<char> source, span<char> dest)
{
return _detail::LZ4_compress_default(source.data(), dest.data(), source.length(), dest.length());
};

inline int decompress_safe (const span<char> source, span<char> dest)
{
return _detail::LZ4_decompress_safe(source.data(), dest.data(), source.length(), dest.length());
};

inline int sizeofState()
{
return _detail::LZ4_sizeofState();
};

inline int compress_fast_extState(span<byte> state, const span<char> source, span<char> dest, int acceleration)
{
return _detail::LZ4_compress_fast_extState(state.data(), source.data(), dest.data(), source.length(), dest.length(), acceleration);
};

inline int compress_destSize (span<char>& source, span<char> dest)
{
auto sourceSize = source.length();
volatile int sourceUsed = sourceSize;
auto atExit = finally([&](){
source = source.subspan(sourceSize - sourceUsed);
});

return _detail::LZ4_compress_destSize(source.data(), dest.data(), const_cast<int*>(&sourceUsed), dest.length());
};

inline int decompress_fast (const span<char> source, span<char> dest, int uncompressedSize)
{
return _detail::LZ4_decompress_fast(source.data(), dest.data(), uncompressedSize);
};

inline int decompress_safe_partial (const span<char> source, span<char> dest, int targetOutputSize)
{
return _detail::LZ4_decompress_safe_partial (source.data(), dest.data(), source.length(), targetOutputSize, dest.length());
};
};
};

0 comments on commit 8590470

Please sign in to comment.