Some cleanup
This commit is contained in:
parent
6bc30dd295
commit
c5d9a0b871
@ -20,3 +20,13 @@ std::string FloatValue::GetAsOsString() const
|
||||
ss << "FloatValue: " << value;
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
FloatValue::operator long double() const
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
FloatValue::operator double() const
|
||||
{
|
||||
return (double)value;
|
||||
}
|
||||
|
@ -7,15 +7,15 @@ class FloatValue : public Value
|
||||
public:
|
||||
FloatValue(const long double& value);
|
||||
|
||||
//! Will return a deeopopy of this object
|
||||
Value* Deepcopy() const override;
|
||||
|
||||
friend std::ostream& operator<< (std::ostream& os, const FloatValue& v)
|
||||
{
|
||||
return os << v.GetAsOsString();
|
||||
}
|
||||
|
||||
//! Will return a string suitable for an std::ostream;
|
||||
std::string GetAsOsString() const override;
|
||||
|
||||
operator long double () const;
|
||||
operator double() const;
|
||||
|
||||
private:
|
||||
long double value;
|
||||
};
|
||||
|
@ -61,7 +61,7 @@ std::size_t Hazelnupp::ParseNextParameter(const std::size_t parIndex, Parameter*
|
||||
break;
|
||||
}
|
||||
|
||||
Value* parsedVal = EvaluateValues(values);
|
||||
Value* parsedVal = ParseValue(values);
|
||||
out_Par = new Parameter(key, parsedVal);
|
||||
|
||||
delete parsedVal;
|
||||
@ -84,7 +84,7 @@ bool Hazelnupp::HasParam(const std::string& key) const
|
||||
return parameters.find(key) != parameters.end();
|
||||
}
|
||||
|
||||
Value* Hazelnupp::EvaluateValues(const std::vector<std::string>& values)
|
||||
Value* Hazelnupp::ParseValue(const std::vector<std::string>& values)
|
||||
{
|
||||
// Void-type
|
||||
if (values.size() == 0)
|
||||
@ -98,7 +98,7 @@ Value* Hazelnupp::EvaluateValues(const std::vector<std::string>& values)
|
||||
ListValue* newList = new ListValue();
|
||||
for (const std::string& val : values)
|
||||
{
|
||||
Value* tmp = EvaluateValues(std::vector<std::string>({ val }));
|
||||
Value* tmp = ParseValue(std::vector<std::string>({ val }));
|
||||
newList->AddValue(tmp);
|
||||
delete tmp;
|
||||
}
|
||||
|
@ -20,3 +20,18 @@ std::string IntValue::GetAsOsString() const
|
||||
ss << "IntValue: " << value;
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
IntValue::operator long long int() const
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
IntValue::operator long int() const
|
||||
{
|
||||
return (long int)value;
|
||||
}
|
||||
|
||||
IntValue::operator int() const
|
||||
{
|
||||
return (int)value;
|
||||
}
|
||||
|
@ -6,10 +6,16 @@ class IntValue : public Value
|
||||
public:
|
||||
IntValue(const long long int& value);
|
||||
|
||||
//! Will return a deeopopy of this object
|
||||
Value* Deepcopy() const override;
|
||||
|
||||
//! Will return a string suitable for an std::ostream;
|
||||
std::string GetAsOsString() const override;
|
||||
|
||||
operator long long int() const;
|
||||
operator long int() const;
|
||||
operator int() const;
|
||||
|
||||
private:
|
||||
long long int value;
|
||||
};
|
||||
|
@ -51,3 +51,8 @@ std::string ListValue::GetAsOsString() const
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
ListValue::operator std::vector<Value*>() const
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
@ -8,17 +8,16 @@ public:
|
||||
ListValue();
|
||||
~ListValue();
|
||||
|
||||
//! Will return a deeopopy of this object
|
||||
Value* Deepcopy() const override;
|
||||
|
||||
//! Will return a string suitable for an std::ostream;
|
||||
std::string GetAsOsString() const override;
|
||||
|
||||
//! Will add this value to the list
|
||||
void AddValue(const Value* value);
|
||||
|
||||
std::string GetAsOsString() const override;
|
||||
|
||||
friend std::ostream& operator<< (std::ostream& os, const ListValue& v)
|
||||
{
|
||||
return os << v.GetAsOsString();
|
||||
}
|
||||
operator std::vector<Value*>() const;
|
||||
|
||||
private:
|
||||
std::vector<Value*> value;
|
||||
|
@ -20,3 +20,8 @@ std::string StringValue::GetAsOsString() const
|
||||
ss << "StringValue: " << value;
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
StringValue::operator std::string() const
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
@ -7,15 +7,14 @@ class StringValue : public Value
|
||||
public:
|
||||
StringValue(const std::string& value);
|
||||
|
||||
//! Will return a deeopopy of this object
|
||||
Value* Deepcopy() const override;
|
||||
|
||||
friend std::ostream& operator<< (std::ostream& os, const StringValue& v)
|
||||
{
|
||||
return os << v.GetAsOsString();
|
||||
}
|
||||
|
||||
//! Will return a string suitable for an std::ostream;
|
||||
std::string GetAsOsString() const override;
|
||||
|
||||
operator std::string() const;
|
||||
|
||||
private:
|
||||
std::string value;
|
||||
};
|
||||
|
@ -8,14 +8,14 @@ public:
|
||||
//! Will return a deeopopy of this object
|
||||
virtual Value* Deepcopy() const = 0;
|
||||
|
||||
//! Will return a string suitable for an std::ostream;
|
||||
virtual std::string GetAsOsString() const = 0;
|
||||
|
||||
friend std::ostream& operator<< (std::ostream& os, const Value& v)
|
||||
{
|
||||
return os << v.GetAsOsString();
|
||||
}
|
||||
|
||||
//! Will return a string suitable for an std::ostream;
|
||||
virtual std::string GetAsOsString() const = 0;
|
||||
|
||||
protected:
|
||||
Value(DATA_TYPE type);
|
||||
|
||||
|
@ -6,12 +6,9 @@ class VoidValue : public Value
|
||||
public:
|
||||
VoidValue();
|
||||
|
||||
//! Will return a deeopopy of this object
|
||||
Value* Deepcopy() const override;
|
||||
|
||||
friend std::ostream& operator<< (std::ostream& os, const VoidValue& v)
|
||||
{
|
||||
return os << "VoidValue";
|
||||
}
|
||||
|
||||
//! Will return a string suitable for an std::ostream;
|
||||
std::string GetAsOsString() const override;
|
||||
};
|
||||
|
@ -1,12 +1,13 @@
|
||||
#include <iostream>
|
||||
#include <array>
|
||||
#include "Hazelnupp.h"
|
||||
#include "IntValue.h"
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
std::string arg0 = "meinpfad";
|
||||
std::string arg1 = "--word";
|
||||
std::string arg2 = "1";
|
||||
std::string arg2 = "6669";
|
||||
std::string arg3 = "--alfred";
|
||||
std::string arg4 = "banane7";
|
||||
|
||||
@ -21,6 +22,9 @@ int main(int argc, char** argv)
|
||||
Hazelnupp args(testArgv.size(), testArgv.data());
|
||||
//Hazelnupp args(argc, argv);
|
||||
|
||||
int i = *(IntValue*)args["--word"];
|
||||
std::cout << i << std::endl;
|
||||
|
||||
//std::cout << args.GetExecutableName() << std::endl;
|
||||
|
||||
return 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user