diff options
Diffstat (limited to 'utils/cxx')
-rw-r--r-- | utils/cxx/CMakeLists.txt | 3 | ||||
-rw-r--r-- | utils/cxx/include/aesnixx/all.hpp | 11 | ||||
-rw-r--r-- | utils/cxx/include/aesnixx/error.hpp | 38 |
3 files changed, 52 insertions, 0 deletions
diff --git a/utils/cxx/CMakeLists.txt b/utils/cxx/CMakeLists.txt new file mode 100644 index 0000000..14b7700 --- /dev/null +++ b/utils/cxx/CMakeLists.txt @@ -0,0 +1,3 @@ +add_library(libaesnixx INTERFACE) +target_include_directories(libaesnixx INTERFACE include/) +target_link_libraries(libaesnixx INTERFACE libaesni) diff --git a/utils/cxx/include/aesnixx/all.hpp b/utils/cxx/include/aesnixx/all.hpp new file mode 100644 index 0000000..cf00535 --- /dev/null +++ b/utils/cxx/include/aesnixx/all.hpp @@ -0,0 +1,11 @@ +/** + * \file + * \author Egor Tensin <Egor.Tensin@gmail.com> + * \date 2015 + * \copyright This file is licensed under the terms of the MIT License. + * See LICENSE.txt for details. + */ + +#pragma once + +#include "error.hpp" diff --git a/utils/cxx/include/aesnixx/error.hpp b/utils/cxx/include/aesnixx/error.hpp new file mode 100644 index 0000000..af61a32 --- /dev/null +++ b/utils/cxx/include/aesnixx/error.hpp @@ -0,0 +1,38 @@ +/** + * \file + * \author Egor Tensin <Egor.Tensin@gmail.com> + * \date 2015 + * \copyright This file is licensed under the terms of the MIT License. + * See LICENSE.txt for details. + */ + +#pragma once + +#include <aesni/all.h> + +#include <stdexcept> + +namespace aesni +{ + class ErrorDetailsThrowsInDestructor + { + public: + ErrorDetailsThrowsInDestructor() + { + aesni_make_error_success(get()); + } + + ~ErrorDetailsThrowsInDestructor() + { + if (m_impl.ec != AESNI_ERROR_SUCCESS) + throw std::runtime_error(aesni_strerror(m_impl.ec)); + } + + AesNI_ErrorDetails* get() { return &m_impl; } + + operator AesNI_ErrorDetails*() { return get(); } + + private: + AesNI_ErrorDetails m_impl; + }; +} |