#include "EventArgs.h"
#include <vector>
#include <string>
using namespace std;
class EventArgs {
public:
static const EventArgs Empty;
};
const EventArgs EventArgs::Empty = EventArgs();
class CmdEventArgs : public EventArgs
{
public:
enum ReturnTypes{
Nothing,
Args
};
ReturnTypes content_type;
vector<string> args;
CmdEventArgs(ReturnTypes type)
{
content_type = type;
}
CmdEventArgs(ReturnTypes type, vector<string> args)
{
content_type = type;
this->args = args;
}
static const CmdEventArgs Empty;
};
const CmdEventArgs CmdEventArgs::Empty = CmdEventArgs(CmdEventArgs::Nothing);
я понимаю, но там банальщина. гуглится за 3 минуты. оно не стоит сего. теги сразу исправил
//
// Created by SavvaNasyrov on 14.12.2023.
//
#ifndef TERMINALHELPER_EVENTARGS_H
#define TERMINALHELPER_EVENTARGS_H
#include <vector>
#include <string>
using namespace std;
class EventArgs {
public:
static const EventArgs Empty;
virtual ~EventArgs();
};
class CmdEventArgs : public EventArgs
{
public:
enum ReturnTypes{
Nothing,
Args
};
ReturnTypes content_type;
vector<string> args;
CmdEventArgs(ReturnTypes type);
CmdEventArgs(ReturnTypes type, vector<string> args);
static const CmdEventArgs Empty;
};
#endif //TERMINALHELPER_EVENTARGS_H
#include "Terminal.h"
#include "Types/EventArgs.h"
#include "string"
using namespace std;
void BasicTerminal::AddNewCommand(string command, TFunction exe_function, string description)
{
functions.push_back(exe_function);
commands.push_back(command);
descriptions.push_back(description);
}
EventArgs BasicTerminal::Execute(string input_command, CmdEventArgs args)
{
int index;
for(int i = 0; i < commands.size(); i++)
{
if (input_command == commands[i]) index = i;
}
return functions[index](args);
}
BasicTerminal term;
EventArgs Hello(CmdEventArgs args)
{
cout << "hello" << endl;
return EventArgs::Empty;
}
int main()
{
term.AddNewCommand("hello", Hello, "prints hello");
term.Execute("hello", CmdEventArgs::Empty);
}
class EventArgs {
public:
static const EventArgs Empty;
virtual ~EventArgs();
};
const EventArgs EventArgs::Empty = EventArgs();