Fixed some windows issues

This commit is contained in:
2024-12-06 16:27:19 +01:00
parent fd62fb822d
commit f73ca0eaec
4 changed files with 27 additions and 13 deletions

View File

@ -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",

View File

@ -95,12 +95,12 @@ class ArgManager {
template<typename T>
std::optional<T> get(const int id) {
if(id < pos_argument.size()) return Argument<T>::get(pos_argument[id]);
std::optional<T> get(const unsigned int id) {
if((unsigned int) id < pos_argument.size()) return Argument<T>::get(pos_argument[id]);
return std::make_optional<T>();
}
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");

View File

@ -3,6 +3,10 @@
#include <istream>
#include <streambuf>
#ifdef _WIN32
#include <iostream>
#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

View File

@ -1,10 +1,14 @@
#ifdef WIN32
#ifdef _WIN32
#include <windows.h>
#else
#include <unistd.h>
#include <cstdio>
#include <cstdlib>
#include <termios.h>
#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
}