Cleanup
This commit is contained in:
parent
131520e1ef
commit
a2de37264a
BIN
Hazelnupp.vpp
BIN
Hazelnupp.vpp
Binary file not shown.
@ -35,3 +35,38 @@ FloatValue::operator double() const
|
|||||||
{
|
{
|
||||||
return (double)value;
|
return (double)value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
long long int FloatValue::GetInt64() const
|
||||||
|
{
|
||||||
|
return (long long int)value;
|
||||||
|
}
|
||||||
|
|
||||||
|
int FloatValue::GetInt32() const
|
||||||
|
{
|
||||||
|
return (int)value;
|
||||||
|
}
|
||||||
|
|
||||||
|
long double FloatValue::GetFloat64() const
|
||||||
|
{
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
double FloatValue::GetFloat32() const
|
||||||
|
{
|
||||||
|
return (double)value;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string FloatValue::GetString() const
|
||||||
|
{
|
||||||
|
std::stringstream ss;
|
||||||
|
ss << value;
|
||||||
|
|
||||||
|
return ss.str();
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::vector<Value*>& FloatValue::GetList() const
|
||||||
|
{
|
||||||
|
throw std::bad_cast();
|
||||||
|
}
|
@ -20,6 +20,22 @@ public:
|
|||||||
operator long double () const;
|
operator long double () const;
|
||||||
operator double() const;
|
operator double() const;
|
||||||
|
|
||||||
|
//! Will return the data as a long long int
|
||||||
|
long long int GetInt64() const override;
|
||||||
|
//! Will return the data as an int
|
||||||
|
int GetInt32() const override;
|
||||||
|
|
||||||
|
//! Will return the data as a long double
|
||||||
|
long double GetFloat64() const override;
|
||||||
|
//! Will return the data as a double
|
||||||
|
double GetFloat32() const override;
|
||||||
|
|
||||||
|
//! Will return the data as a string
|
||||||
|
std::string GetString() const override;
|
||||||
|
|
||||||
|
//! Throws std::bad_cast
|
||||||
|
const std::vector<Value*>& GetList() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
long double value;
|
long double value;
|
||||||
};
|
};
|
||||||
|
@ -35,3 +35,38 @@ IntValue::operator int() const
|
|||||||
{
|
{
|
||||||
return (int)value;
|
return (int)value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
long long int IntValue::GetInt64() const
|
||||||
|
{
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
int IntValue::GetInt32() const
|
||||||
|
{
|
||||||
|
return (int)value;
|
||||||
|
}
|
||||||
|
|
||||||
|
long double IntValue::GetFloat64() const
|
||||||
|
{
|
||||||
|
return (long double)value;
|
||||||
|
}
|
||||||
|
|
||||||
|
double IntValue::GetFloat32() const
|
||||||
|
{
|
||||||
|
return (double)value;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string IntValue::GetString() const
|
||||||
|
{
|
||||||
|
std::stringstream ss;
|
||||||
|
ss << value;
|
||||||
|
|
||||||
|
return ss.str();
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::vector<Value*>& IntValue::GetList() const
|
||||||
|
{
|
||||||
|
throw std::bad_cast();
|
||||||
|
}
|
||||||
|
@ -19,6 +19,23 @@ public:
|
|||||||
operator long long int() const;
|
operator long long int() const;
|
||||||
operator int() const;
|
operator int() const;
|
||||||
|
|
||||||
|
|
||||||
|
//! Will return the data as a long long int
|
||||||
|
long long int GetInt64() const override;
|
||||||
|
//! Will return the data as an int
|
||||||
|
int GetInt32() const override;
|
||||||
|
|
||||||
|
//! Will return the data as a long double
|
||||||
|
long double GetFloat64() const override;
|
||||||
|
//! Will return the data as a double
|
||||||
|
double GetFloat32() const override;
|
||||||
|
|
||||||
|
//! Will return the data as a string
|
||||||
|
std::string GetString() const override;
|
||||||
|
|
||||||
|
//! Throws std::bad_cast
|
||||||
|
const std::vector<Value*>& GetList() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
long long int value;
|
long long int value;
|
||||||
};
|
};
|
||||||
|
@ -60,3 +60,35 @@ ListValue::operator std::vector<Value*>() const
|
|||||||
{
|
{
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
long long int ListValue::GetInt64() const
|
||||||
|
{
|
||||||
|
throw std::bad_cast();
|
||||||
|
}
|
||||||
|
|
||||||
|
int ListValue::GetInt32() const
|
||||||
|
{
|
||||||
|
throw std::bad_cast();
|
||||||
|
}
|
||||||
|
|
||||||
|
long double ListValue::GetFloat64() const
|
||||||
|
{
|
||||||
|
throw std::bad_cast();
|
||||||
|
}
|
||||||
|
|
||||||
|
double ListValue::GetFloat32() const
|
||||||
|
{
|
||||||
|
throw std::bad_cast();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string ListValue::GetString() const
|
||||||
|
{
|
||||||
|
throw std::bad_cast();
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::vector<Value*>& ListValue::GetList() const
|
||||||
|
{
|
||||||
|
return value;
|
||||||
|
}
|
@ -22,6 +22,22 @@ public:
|
|||||||
|
|
||||||
operator std::vector<Value*>() const;
|
operator std::vector<Value*>() const;
|
||||||
|
|
||||||
|
//! Throws std::bad_cast
|
||||||
|
long long int GetInt64() const override;
|
||||||
|
//! Throws std::bad_cast
|
||||||
|
int GetInt32() const override;
|
||||||
|
|
||||||
|
//! Throws std::bad_cast
|
||||||
|
long double GetFloat64() const override;
|
||||||
|
//! Throws std::bad_cast
|
||||||
|
double GetFloat32() const override;
|
||||||
|
|
||||||
|
//! Throws std::bad_cast
|
||||||
|
std::string GetString() const override;
|
||||||
|
|
||||||
|
//! Will return this values list
|
||||||
|
const std::vector<Value*>& GetList() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<Value*> value;
|
std::vector<Value*> value;
|
||||||
};
|
};
|
||||||
|
@ -30,3 +30,35 @@ StringValue::operator std::string() const
|
|||||||
{
|
{
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
long long int StringValue::GetInt64() const
|
||||||
|
{
|
||||||
|
throw std::bad_cast();
|
||||||
|
}
|
||||||
|
|
||||||
|
int StringValue::GetInt32() const
|
||||||
|
{
|
||||||
|
throw std::bad_cast();
|
||||||
|
}
|
||||||
|
|
||||||
|
long double StringValue::GetFloat64() const
|
||||||
|
{
|
||||||
|
throw std::bad_cast();
|
||||||
|
}
|
||||||
|
|
||||||
|
double StringValue::GetFloat32() const
|
||||||
|
{
|
||||||
|
throw std::bad_cast();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string StringValue::GetString() const
|
||||||
|
{
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::vector<Value*>& StringValue::GetList() const
|
||||||
|
{
|
||||||
|
throw std::bad_cast();
|
||||||
|
}
|
||||||
|
@ -19,6 +19,22 @@ public:
|
|||||||
|
|
||||||
operator std::string() const;
|
operator std::string() const;
|
||||||
|
|
||||||
|
//! Throws std::bad_cast
|
||||||
|
long long int GetInt64() const override;
|
||||||
|
//! Throws std::bad_cast
|
||||||
|
int GetInt32() const override;
|
||||||
|
|
||||||
|
//! Throws std::bad_cast
|
||||||
|
long double GetFloat64() const override;
|
||||||
|
//! Throws std::bad_cast
|
||||||
|
double GetFloat32() const override;
|
||||||
|
|
||||||
|
//! Will return this value as a string
|
||||||
|
std::string GetString() const override;
|
||||||
|
|
||||||
|
//! Throws std::bad_cast
|
||||||
|
const std::vector<Value*>& GetList() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string value;
|
std::string value;
|
||||||
};
|
};
|
||||||
|
@ -1,8 +1,4 @@
|
|||||||
#include "Value.h"
|
#include "Value.h"
|
||||||
#include "IntValue.h"
|
|
||||||
#include "FloatValue.h"
|
|
||||||
#include "StringValue.h"
|
|
||||||
#include "ListValue.h"
|
|
||||||
|
|
||||||
Value::Value(DATA_TYPE type)
|
Value::Value(DATA_TYPE type)
|
||||||
:
|
:
|
||||||
@ -15,51 +11,51 @@ DATA_TYPE Value::GetDataType() const
|
|||||||
{
|
{
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
//
|
||||||
long long int Value::GetInt64() const
|
//long long int Value::GetInt64() const
|
||||||
{
|
//{
|
||||||
if (type != DATA_TYPE::INT)
|
// if (type != DATA_TYPE::INT)
|
||||||
throw std::bad_cast();
|
// throw std::bad_cast();
|
||||||
|
//
|
||||||
return ((IntValue*)this)->GetValue();
|
// return ((IntValue*)this)->GetValue();
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
int Value::GetInt32() const
|
//int Value::GetInt32() const
|
||||||
{
|
//{
|
||||||
if (type != DATA_TYPE::INT)
|
// if (type != DATA_TYPE::INT)
|
||||||
throw std::bad_cast();
|
// throw std::bad_cast();
|
||||||
|
//
|
||||||
return (int)((IntValue*)this)->GetValue();
|
// return (int)((IntValue*)this)->GetValue();
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
long double Value::GetFloat64() const
|
//long double Value::GetFloat64() const
|
||||||
{
|
//{
|
||||||
if (type != DATA_TYPE::FLOAT)
|
// if (type != DATA_TYPE::FLOAT)
|
||||||
throw std::bad_cast();
|
// throw std::bad_cast();
|
||||||
|
//
|
||||||
return ((FloatValue*)this)->GetValue();
|
// return ((FloatValue*)this)->GetValue();
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
double Value::GetFloat32() const
|
//double Value::GetFloat32() const
|
||||||
{
|
//{
|
||||||
if (type != DATA_TYPE::FLOAT)
|
// if (type != DATA_TYPE::FLOAT)
|
||||||
throw std::bad_cast();
|
// throw std::bad_cast();
|
||||||
|
//
|
||||||
return (double)((FloatValue*)this)->GetValue();
|
// return (double)((FloatValue*)this)->GetValue();
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
const std::string& Value::GetString() const
|
//const std::string& Value::GetString() const
|
||||||
{
|
//{
|
||||||
if (type != DATA_TYPE::STRING)
|
// if (type != DATA_TYPE::STRING)
|
||||||
throw std::bad_cast();
|
// throw std::bad_cast();
|
||||||
|
//
|
||||||
return ((StringValue*)this)->GetValue();
|
// return ((StringValue*)this)->GetValue();
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
const std::vector<Value*>& Value::GetList() const
|
//const std::vector<Value*>& Value::GetList() const
|
||||||
{
|
//{
|
||||||
if (type != DATA_TYPE::LIST)
|
// if (type != DATA_TYPE::LIST)
|
||||||
throw std::bad_cast();
|
// throw std::bad_cast();
|
||||||
|
//
|
||||||
return ((ListValue*)this)->GetValue();
|
// return ((ListValue*)this)->GetValue();
|
||||||
}
|
//}
|
||||||
|
@ -22,21 +22,21 @@ public:
|
|||||||
return os << v.GetAsOsString();
|
return os << v.GetAsOsString();
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Will attempt to return the integer data (long long), if the type matches
|
//! Will attempt to return the integer data (long long)
|
||||||
long long int GetInt64() const;
|
virtual long long int GetInt64() const = 0;
|
||||||
//! Will attempt to return the integer data (int), if the type matches
|
//! Will attempt to return the integer data (int)
|
||||||
int GetInt32() const;
|
virtual int GetInt32() const = 0;
|
||||||
|
|
||||||
//! Will attempt to return the floating-point data (long double), if the type matches
|
//! Will attempt to return the floating-point data (long double)
|
||||||
long double GetFloat64() const;
|
virtual long double GetFloat64() const = 0;
|
||||||
//! Will attempt to return the floating-point data (double), if the type matches
|
//! Will attempt to return the floating-point data (double)
|
||||||
double GetFloat32() const;
|
virtual double GetFloat32() const = 0;
|
||||||
|
|
||||||
//! Will attempt to return the string-data, if the type matches
|
//! Will attempt to return the string-data
|
||||||
const std::string& GetString() const;
|
virtual std::string GetString() const = 0;
|
||||||
|
|
||||||
//! Will attempt to return the list-data, if the type matches
|
//! Will attempt to return the list-data
|
||||||
const std::vector<Value*>& GetList() const;
|
virtual const std::vector<Value*>& GetList() const = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Value(DATA_TYPE type);
|
Value(DATA_TYPE type);
|
||||||
|
@ -16,3 +16,35 @@ std::string VoidValue::GetAsOsString() const
|
|||||||
{
|
{
|
||||||
return "VoidValue";
|
return "VoidValue";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
long long int VoidValue::GetInt64() const
|
||||||
|
{
|
||||||
|
throw std::bad_cast();
|
||||||
|
}
|
||||||
|
|
||||||
|
int VoidValue::GetInt32() const
|
||||||
|
{
|
||||||
|
throw std::bad_cast();
|
||||||
|
}
|
||||||
|
|
||||||
|
long double VoidValue::GetFloat64() const
|
||||||
|
{
|
||||||
|
throw std::bad_cast();
|
||||||
|
}
|
||||||
|
|
||||||
|
double VoidValue::GetFloat32() const
|
||||||
|
{
|
||||||
|
throw std::bad_cast();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string VoidValue::GetString() const
|
||||||
|
{
|
||||||
|
throw std::bad_cast();
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::vector<Value*>& VoidValue::GetList() const
|
||||||
|
{
|
||||||
|
throw std::bad_cast();
|
||||||
|
}
|
||||||
|
@ -12,4 +12,20 @@ public:
|
|||||||
|
|
||||||
//! Will return a string suitable for an std::ostream;
|
//! Will return a string suitable for an std::ostream;
|
||||||
std::string GetAsOsString() const override;
|
std::string GetAsOsString() const override;
|
||||||
|
|
||||||
|
//! Throws std::bad_cast
|
||||||
|
long long int GetInt64() const override;
|
||||||
|
//! Throws std::bad_cast
|
||||||
|
int GetInt32() const override;
|
||||||
|
|
||||||
|
//! Throws std::bad_cast
|
||||||
|
long double GetFloat64() const override;
|
||||||
|
//! Throws std::bad_cast
|
||||||
|
double GetFloat32() const override;
|
||||||
|
|
||||||
|
//! Throws std::bad_cast
|
||||||
|
std::string GetString() const override;
|
||||||
|
|
||||||
|
//! Throws std::bad_cast
|
||||||
|
const std::vector<Value*>& GetList() const;
|
||||||
};
|
};
|
||||||
|
@ -9,7 +9,7 @@ int main(int argc, char** argv)
|
|||||||
std::vector<const char*> testArgv = {
|
std::vector<const char*> testArgv = {
|
||||||
"meinpfad",
|
"meinpfad",
|
||||||
"-w",
|
"-w",
|
||||||
"hallo",
|
"123",
|
||||||
"--alfred",
|
"--alfred",
|
||||||
"apfel",
|
"apfel",
|
||||||
"banane",
|
"banane",
|
||||||
@ -31,7 +31,7 @@ int main(int argc, char** argv)
|
|||||||
|
|
||||||
if (args.HasParam("--word"))
|
if (args.HasParam("--word"))
|
||||||
{
|
{
|
||||||
std::cout << *args["--word"] << std::endl;
|
std::cout << args["--word"]->GetString() << std::endl;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user