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

Commit

Permalink
(#18) Added function to return the version string
Browse files Browse the repository at this point in the history
Added a VERSION_STRING() function that gives the version string in
the standard format.
  • Loading branch information
leandor committed Jul 1, 2017
1 parent 8590470 commit 66d4361
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/papi/lz4/api.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define __CINT_LZ4_API__
#pragma once

#include <string>
#include <gsl/gsl>
#include "module.h"
#include "api_detail.h"
Expand Down Expand Up @@ -35,6 +36,11 @@ namespace lz4 { namespace api {
return _detail::VERSION_RELEASE;
};

constexpr auto VERSION_STRING()
{
return _detail::VERSION_STRING;
};

/**
Provides the maximum size that LZ4 compression may output in a "worst case" scenario (input data not compressible)
This function is primarily useful for memory allocation purposes (destination buffer size).
Expand Down
1 change: 1 addition & 0 deletions src/papi/lz4/api_detail.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ namespace lz4 { namespace api {
constexpr auto VERSION_MAJOR = LZ4_VERSION_MAJOR;
constexpr auto VERSION_MINOR = LZ4_VERSION_MINOR;
constexpr auto VERSION_RELEASE = LZ4_VERSION_RELEASE;
constexpr const char VERSION_STRING[] = LZ4_VERSION_STRING;

template<int Size>
constexpr auto COMPRESSBOUND = LZ4_COMPRESSBOUND(Size);
Expand Down
6 changes: 5 additions & 1 deletion src/papi/lz4/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,9 @@ static test_initializer modules([](py::module &m) {
.def("versionNumber", lz4::api::VERSION_NUMBER)
.def("version", [](){
return py::make_tuple(lz4::api::VERSION_MAJOR(), lz4::api::VERSION_MINOR(), lz4::api::VERSION_RELEASE());
});
})
.def("versionString", [](){
return py::str(lz4::api::VERSION_STRING());
})
;
});
1 change: 1 addition & 0 deletions tests/papi/test_lz4.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ def lz4():
def testVersion(lz4):
assert lz4.versionNumber() == 10702
assert lz4.version() == (1, 7, 2)
assert lz4.versionString() == "1.7.2"

0 comments on commit 66d4361

Please sign in to comment.