From 3806bb74674f305679efdaa2889d155531bc3643 Mon Sep 17 00:00:00 2001 From: dawidg81 Date: Mon, 26 Jan 2026 17:24:50 +0100 Subject: dir rename --- src/Utils/Utils.hpp | 11 +++++++++++ src/Utils/catchInputInt.cpp | 15 +++++++++++++++ src/Utils/catchReturn.cpp | 11 +++++++++++ 3 files changed, 37 insertions(+) create mode 100644 src/Utils/Utils.hpp create mode 100644 src/Utils/catchInputInt.cpp create mode 100644 src/Utils/catchReturn.cpp (limited to 'src/Utils') diff --git a/src/Utils/Utils.hpp b/src/Utils/Utils.hpp new file mode 100644 index 0000000..7df9e3d --- /dev/null +++ b/src/Utils/Utils.hpp @@ -0,0 +1,11 @@ +#include + +#ifndef UTILS_HPP + +class Utils{ + public: + int catchInputInt(int input); + int catchReturn(int renum); +}; + +#endif \ No newline at end of file diff --git a/src/Utils/catchInputInt.cpp b/src/Utils/catchInputInt.cpp new file mode 100644 index 0000000..dd804b5 --- /dev/null +++ b/src/Utils/catchInputInt.cpp @@ -0,0 +1,15 @@ +#include "Utils.hpp" + +#include +#include + +int Utils::catchInputInt(int input){ + std::cin >> input; + + if (std::cin.fail()) { + std::cout << "error: Input failed" << std::endl; + return 1; + } + + return 0; +} \ No newline at end of file diff --git a/src/Utils/catchReturn.cpp b/src/Utils/catchReturn.cpp new file mode 100644 index 0000000..c3d6722 --- /dev/null +++ b/src/Utils/catchReturn.cpp @@ -0,0 +1,11 @@ +#include "Utils.hpp" + +#include +#include + +int Utils::catchReturn(int renum){ + if (renum != 0) { + std::cout << "Received error signal, sending further" << std::endl; + } + return 0; +} \ No newline at end of file -- cgit v1.2.3