From f73ca0eaecf5341db3101c55169719440c618f96 Mon Sep 17 00:00:00 2001 From: Pimpest <82343504+Pimpest@users.noreply.github.com> Date: Fri, 6 Dec 2024 16:27:19 +0100 Subject: [PATCH] Fixed some windows issues --- .vscode/settings.json | 4 +++- include/cmd/arg.hpp | 8 ++++---- include/util/input.hpp | 11 +++++++++-- src/util/input.cpp | 17 +++++++++++------ 4 files changed, 27 insertions(+), 13 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index efe34a3..cdf3c33 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -55,7 +55,9 @@ "text_encoding": "cpp", "typeinfo": "cpp", "variant": "cpp", - "sstream": "cpp" + "sstream": "cpp", + "fstream": "cpp", + "iomanip": "cpp" }, "C_Cpp.codeAnalysis.clangTidy.checks.disabled": [ "modernize-use-trailing-return-type", diff --git a/include/cmd/arg.hpp b/include/cmd/arg.hpp index 0fe9922..2fc9bad 100644 --- a/include/cmd/arg.hpp +++ b/include/cmd/arg.hpp @@ -95,12 +95,12 @@ class ArgManager { template - std::optional get(const int id) { - if(id < pos_argument.size()) return Argument::get(pos_argument[id]); + std::optional get(const unsigned int id) { + if((unsigned int) id < pos_argument.size()) return Argument::get(pos_argument[id]); return std::make_optional(); } - std::istream& get_input(const int id) { + std::istream& get_input(const unsigned int id) { if(id < pos_argument.size()) return ArgInput::get(pos_argument[id]); return util::cin; } @@ -171,7 +171,7 @@ class ArgFactory { if(flag) { parse_flag(manager, flag); } - int i = 0; + unsigned int i = 0; for(const auto& arg : vec) { std::shared_ptr<_Argument> a; if(i >= pos_arg_rules.size()) throw std::invalid_argument("More arguments then excpected"); diff --git a/include/util/input.hpp b/include/util/input.hpp index 378b1fe..971e250 100644 --- a/include/util/input.hpp +++ b/include/util/input.hpp @@ -3,6 +3,10 @@ #include #include +#ifdef _WIN32 +#include +#endif + namespace fsh::util { @@ -16,7 +20,7 @@ namespace fsh::util */ void prepTerminal(); -#if defined(__unix__) || defined(__APPLE__) +#ifndef _WIN32 class CursorIStreamBuffer : public std::streambuf { public: @@ -52,9 +56,12 @@ public: private: CursorIStreamBuffer buffer; }; - extern CursorIStream cin; +#else + +extern std::istream& cin; + #endif diff --git a/src/util/input.cpp b/src/util/input.cpp index 637703c..880930c 100644 --- a/src/util/input.cpp +++ b/src/util/input.cpp @@ -1,10 +1,14 @@ -#ifdef WIN32 +#ifdef _WIN32 + #include + #else + #include #include #include #include + #endif @@ -15,18 +19,17 @@ namespace fsh::util { -#ifndef WIN32 +#ifndef _WIN32 struct termios prev_attr; void resetTerminal() { tcsetattr(STDIN_FILENO, TCSANOW, &prev_attr); } - #endif void prepTerminal() { -#ifdef WIN32 +#ifdef _WIN32 /* Ovaj deo koda je namenjen da omoguci koriscenje neke ansi-escape sekvence na windows platformi */ #else @@ -52,7 +55,7 @@ void prepTerminal() { } -#if defined(__unix__) || defined(__APPLE__) +#ifndef _WIN32 int CursorIStreamBuffer::underflow() { if(gptr() < egptr()) return traits_type::to_int_type(*gptr()); @@ -138,7 +141,9 @@ int CursorIStreamBuffer::readInputToNewLine(){ } CursorIStream cin; - +#else +std::istream& cin = std::cin; #endif + } \ No newline at end of file