diff options
-rw-r--r-- | CMakeLists.txt | 2 | ||||
-rw-r--r-- | CommandFailedException.cpp | 5 | ||||
-rw-r--r-- | NK_C_API.cc | 2 | ||||
-rw-r--r-- | NitrokeyManager.cc | 3 | ||||
-rw-r--r-- | TooLongStringException.cpp | 5 | ||||
-rw-r--r-- | include/InvalidSlotException.h | 31 | ||||
-rw-r--r-- | include/LibraryException.h | 45 | ||||
-rw-r--r-- | include/TooLongStringException.h | 34 |
8 files changed, 44 insertions, 83 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 265e737..39c0c34 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,6 +22,6 @@ set(SOURCE_FILES log.cc misc.cc NitrokeyManager.cc - NK_C_API.cc CommandFailedException.cpp include/CommandFailedException.h TooLongStringException.cpp include/TooLongStringException.h include/InvalidSlotException.h include/LibraryException.h) + NK_C_API.cc include/CommandFailedException.h include/LibraryException.h) add_executable(libnitrokey ${SOURCE_FILES})
\ No newline at end of file diff --git a/CommandFailedException.cpp b/CommandFailedException.cpp deleted file mode 100644 index ccc780c..0000000 --- a/CommandFailedException.cpp +++ /dev/null @@ -1,5 +0,0 @@ -// -// Created by sz on 23.07.16. -// - -#include "include/CommandFailedException.h" diff --git a/NK_C_API.cc b/NK_C_API.cc index ea63f36..b755c70 100644 --- a/NK_C_API.cc +++ b/NK_C_API.cc @@ -1,6 +1,6 @@ #include <cstring> #include "NK_C_API.h" -#include "include/TooLongStringException.h" +#include "include/LibraryException.h" using namespace nitrokey; diff --git a/NitrokeyManager.cc b/NitrokeyManager.cc index 81d27aa..161f7aa 100644 --- a/NitrokeyManager.cc +++ b/NitrokeyManager.cc @@ -1,8 +1,7 @@ #include <cstring> #include <iostream> #include "include/NitrokeyManager.h" -#include "include/TooLongStringException.h" -#include "include/InvalidSlotException.h" +#include "include/LibraryException.h" namespace nitrokey{ diff --git a/TooLongStringException.cpp b/TooLongStringException.cpp deleted file mode 100644 index 96c5132..0000000 --- a/TooLongStringException.cpp +++ /dev/null @@ -1,5 +0,0 @@ -// -// Created by sz on 09.08.16. -// - -#include "include/TooLongStringException.h" diff --git a/include/InvalidSlotException.h b/include/InvalidSlotException.h deleted file mode 100644 index e97d993..0000000 --- a/include/InvalidSlotException.h +++ /dev/null @@ -1,31 +0,0 @@ -// -// Created by sz on 09.08.16. -// - -#ifndef LIBNITROKEY_INVALIDSLOTEXCEPTION_H -#define LIBNITROKEY_INVALIDSLOTEXCEPTION_H - - -#include <cstdint> -#include <string> -#include "LibraryException.h" - - -class InvalidSlotException : public LibraryException { -public: - virtual uint8_t exception_id() override { - return 201; - } - -public: - uint8_t slot_selected; - - InvalidSlotException(uint8_t slot_selected) : slot_selected(slot_selected) {} - - virtual const char *what() const throw() override { - return "Wrong slot selected"; - } - -}; - -#endif //LIBNITROKEY_INVALIDSLOTEXCEPTION_H diff --git a/include/LibraryException.h b/include/LibraryException.h index ef81624..5036320 100644 --- a/include/LibraryException.h +++ b/include/LibraryException.h @@ -1,12 +1,9 @@ -// -// Created by sz on 09.08.16. -// - #ifndef LIBNITROKEY_LIBRARYEXCEPTION_H #define LIBNITROKEY_LIBRARYEXCEPTION_H #include <exception> #include <cstdint> +#include <string> class LibraryException: std::exception { public: @@ -14,4 +11,44 @@ public: }; + +class InvalidSlotException : public LibraryException { +public: + virtual uint8_t exception_id() override { + return 201; + } + +public: + uint8_t slot_selected; + + InvalidSlotException(uint8_t slot_selected) : slot_selected(slot_selected) {} + + virtual const char *what() const throw() override { + return "Wrong slot selected"; + } + +}; + + + +class TooLongStringException : public LibraryException { +public: + virtual uint8_t exception_id() override { + return 200; + } + + std::size_t size_source; + std::size_t size_destination; + std::string message; + + TooLongStringException(size_t size_source, size_t size_destination, const std::string &message = "") : size_source( + size_source), size_destination(size_destination), message(message) {} + + virtual const char *what() const throw() override { + //TODO add sizes and message data to final message + return "Too long string has been supplied as an argument"; + } + +}; + #endif //LIBNITROKEY_LIBRARYEXCEPTION_H diff --git a/include/TooLongStringException.h b/include/TooLongStringException.h deleted file mode 100644 index 58f5801..0000000 --- a/include/TooLongStringException.h +++ /dev/null @@ -1,34 +0,0 @@ -// -// Created by sz on 09.08.16. -// - -#ifndef LIBNITROKEY_TOOLONGSTRINGEXCEPTION_H -#define LIBNITROKEY_TOOLONGSTRINGEXCEPTION_H - - -#include <cstdint> -#include <string> -#include "LibraryException.h" - -class TooLongStringException : public LibraryException { -public: - virtual uint8_t exception_id() override { - return 200; - } - - std::size_t size_source; - std::size_t size_destination; - std::string message; - - TooLongStringException(size_t size_source, size_t size_destination, const std::string &message = "") : size_source( - size_source), size_destination(size_destination), message(message) {} - - virtual const char *what() const throw() override { - //TODO add sizes and message data to final message - return "Too long string has been supplied as an argument"; - } - -}; - - -#endif //LIBNITROKEY_TOOLONGSTRINGEXCEPTION_H |