Massive reformating and cleanup

This commit is contained in:
2024-12-06 21:07:54 +01:00
parent 79390b94b7
commit d2cbdc2910
33 changed files with 1030 additions and 1100 deletions

View File

@ -5,35 +5,32 @@
#include "cmd/args/arg_base.hpp"
#include "ast/ast_component.hpp"
namespace fsh{
namespace fsh {
template<typename T>
class Argument : public _Argument {
public:
static T& get(std::shared_ptr<_Argument> a) {
return std::dynamic_pointer_cast<Argument<T> >(a)->gvalue();
}
template <typename T>
class Argument : public _Argument {
public:
static T& get(std::shared_ptr<_Argument> a) { return std::dynamic_pointer_cast<Argument<T> >(a)->gvalue(); }
Argument() {}
Argument() {}
virtual void svalue(const std::string& val, const Lexer::TokenType& type) override;
virtual T& gvalue() {return value;}
private:
bool is_string_literal; // Currently no getter
T value;
};
virtual void svalue(const std::string& val, const Lexer::TokenType& type) override;
virtual T& gvalue() { return value; }
template<class T>
void Argument<T>::svalue(const std::string& val, const Lexer::TokenType& type) {
if constexpr (std::is_same_v<T, std::string>) {
value = val;
} else {
std::stringstream ss_val(val);
if(!(ss_val >> value)) {
throw std::invalid_argument("Incorrect type");
private:
bool is_string_literal; // Currently no getter
T value;
};
template <class T>
void Argument<T>::svalue(const std::string& val, const Lexer::TokenType& type) {
if constexpr (std::is_same_v<T, std::string>) {
value = val;
} else {
std::stringstream ss_val(val);
if (!(ss_val >> value)) { throw std::invalid_argument("Incorrect type"); }
}
is_string_literal = type == Lexer::TokenType::STRING_LITERAL;
}
is_string_literal = type == Lexer::TokenType::STRING_LITERAL;
}
}