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/CMakeLists.txt | 6 ++++-- utils/aes128ecb_decrypt_file.cpp | 5 ++--- utils/aes128ecb_encrypt_file.cpp | 3 +-- utils/common.hpp | 38 ------------------------------------- utils/cxx/CMakeLists.txt | 3 +++ utils/cxx/include/aesnixx/all.hpp | 11 +++++++++++ utils/cxx/include/aesnixx/error.hpp | 38 +++++++++++++++++++++++++++++++++++++ 7 files changed, 59 insertions(+), 45 deletions(-) delete mode 100644 utils/common.hpp create mode 100644 utils/cxx/CMakeLists.txt create mode 100644 utils/cxx/include/aesnixx/all.hpp create mode 100644 utils/cxx/include/aesnixx/error.hpp diff --git a/utils/CMakeLists.txt b/utils/CMakeLists.txt index a667663..cd7f340 100644 --- a/utils/CMakeLists.txt +++ b/utils/CMakeLists.txt @@ -1,6 +1,8 @@ +add_subdirectory(cxx) + macro(util prefix) - add_executable(util_${prefix} ${prefix}.cpp common.hpp) - target_link_libraries(util_${prefix} libaesni) + add_executable(util_${prefix} ${prefix}.cpp) + target_link_libraries(util_${prefix} libaesnixx libaesni) set_target_properties(util_${prefix} PROPERTIES OUTPUT_NAME ${prefix}) endmacro() diff --git a/utils/aes128ecb_decrypt_file.cpp b/utils/aes128ecb_decrypt_file.cpp index 23545f9..f0811ce 100644 --- a/utils/aes128ecb_decrypt_file.cpp +++ b/utils/aes128ecb_decrypt_file.cpp @@ -5,10 +5,9 @@ * \copyright This file is licensed under the terms of the MIT License. * See LICENSE.txt for details. */ - -#include "common.hpp" - + #include +#include #include diff --git a/utils/aes128ecb_encrypt_file.cpp b/utils/aes128ecb_encrypt_file.cpp index 42e297c..694d8fe 100644 --- a/utils/aes128ecb_encrypt_file.cpp +++ b/utils/aes128ecb_encrypt_file.cpp @@ -6,9 +6,8 @@ * See LICENSE.txt for details. */ -#include "common.hpp" - #include +#include #include diff --git a/utils/common.hpp b/utils/common.hpp deleted file mode 100644 index af61a32..0000000 --- a/utils/common.hpp +++ /dev/null @@ -1,38 +0,0 @@ -/** - * \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; - }; -} 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 + * \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