From c7365d80063dc7270ea5685ae65094a5af62acaf Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Thu, 11 Jun 2015 17:31:30 +0300 Subject: add utils/cxx --- utils/cxx/include/aesnixx/all.hpp | 11 +++++++++++ utils/cxx/include/aesnixx/error.hpp | 38 +++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 utils/cxx/include/aesnixx/all.hpp create mode 100644 utils/cxx/include/aesnixx/error.hpp (limited to 'utils/cxx/include/aesnixx') 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 + * \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 + * \date 2015 + * \copyright This file is licensed under the terms of the MIT License. + * See LICENSE.txt for details. + */ + +#pragma once + +#include + +#include + +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; + }; +} -- cgit v1.2.3