Added Include folder
*facepalm*
This commit is contained in:
@ -1,10 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
|
||||
#include "cmd/args/arg_base.hpp"
|
||||
#include "ast/ast_component.hpp"
|
||||
|
||||
#include "lexer.hpp"
|
||||
#include "util/stringliteral.hpp"
|
||||
|
||||
namespace fsh {
|
||||
|
||||
template <typename T>
|
||||
@ -15,22 +21,33 @@ namespace fsh {
|
||||
Argument() {}
|
||||
|
||||
virtual void svalue(const std::string& val, const Lexer::TokenType& type) override;
|
||||
|
||||
virtual T& gvalue() { return value; }
|
||||
|
||||
private:
|
||||
bool gis_string_literal() { return is_string_literal; }
|
||||
|
||||
protected:
|
||||
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 {
|
||||
|
||||
is_string_literal = type == Lexer::TokenType::STRING_LITERAL;
|
||||
|
||||
if constexpr (std::is_same_v<T, StringLiteral>) {
|
||||
if(type != Lexer::TokenType::STRING_LITERAL) {
|
||||
throw std::invalid_argument("Incorrect type");
|
||||
}
|
||||
}
|
||||
|
||||
if constexpr (!std::is_same_v<T, std::string> && !std::is_base_of_v<std::string, T>) {
|
||||
std::stringstream ss_val(val);
|
||||
if (!(ss_val >> value)) { throw std::invalid_argument("Incorrect type"); }
|
||||
} else {
|
||||
value = val;
|
||||
}
|
||||
is_string_literal = type == Lexer::TokenType::STRING_LITERAL;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user