some TODOs removed..

This commit is contained in:
2021-08-14 11:33:02 +02:00
parent 6921421a65
commit 4665705c3d
10 changed files with 113 additions and 78 deletions

25
row.h
View File

@@ -10,6 +10,7 @@ namespace usql {
struct ColValue {
virtual bool isNull() { return false; };
virtual ColumnType getColType() = 0;
virtual long getIntValue() = 0;
virtual double getDoubleValue() = 0;
virtual std::string getStringValue() = 0;
@@ -25,11 +26,12 @@ namespace usql {
struct ColNullValue : ColValue {
bool isNull() override { return true; };
long getIntValue() override { throw Exception("Not supported"); };
double getDoubleValue() override { throw Exception("Not supported"); };
ColumnType getColType() override { throw Exception("getColType not supported on ColNullValue"); }
long getIntValue() override { throw Exception("getIntValue not supported on ColNullValue"); };
double getDoubleValue() override { throw Exception("getDoubleValue not supported on ColNullValue"); };
std::string getStringValue() override { return "null"; };
long getDateValue() override { throw Exception("Not supported"); };
bool getBoolValue() override { throw Exception("Not supported"); };
long getDateValue() override { throw Exception("getDateValue not supported on ColNullValue"); };
bool getBoolValue() override { throw Exception("getDateValue not supported on ColNullValue"); };
int compare(ColValue * other) override;
};
@@ -39,11 +41,12 @@ namespace usql {
ColIntegerValue(long value) : m_integer(value) {};
ColIntegerValue(const ColIntegerValue &other) : m_integer(other.m_integer) {};
ColumnType getColType() override { return ColumnType::integer_type; };
long getIntValue() override { return m_integer; };
double getDoubleValue() override { return (double) m_integer; };
std::string getStringValue() override { return std::to_string(m_integer); };
long getDateValue() override { return m_integer; };
bool getBoolValue() override { throw Exception("Not supported"); };
bool getBoolValue() override { throw Exception("Not supported on ColIntegerValue"); };
int compare(ColValue * other) override;
@@ -55,11 +58,12 @@ namespace usql {
ColDoubleValue(double value) : m_double(value) {};
ColDoubleValue(const ColDoubleValue &other) : m_double(other.m_double) {}
ColumnType getColType() override { return ColumnType::float_type; };
long getIntValue() override { return (long) m_double; };
double getDoubleValue() override { return m_double; };
std::string getStringValue() override { return std::to_string(m_double); };
long getDateValue() override { return (long) m_double; };
bool getBoolValue() override { throw Exception("Not supported"); };
bool getBoolValue() override { throw Exception("Not supported on ColDoubleValue"); };
int compare(ColValue * other) override;
@@ -71,11 +75,12 @@ namespace usql {
ColStringValue(const std::string &value) : m_string(value) {};
ColStringValue(const ColStringValue &other) : m_string(other.m_string) {};
ColumnType getColType() override { return ColumnType::varchar_type; };
long getIntValue() override { return std::stoi(m_string); };
double getDoubleValue() override { return std::stod(m_string); };
std::string getStringValue() override { return m_string; };
long getDateValue() override { return std::stoi(m_string); };
bool getBoolValue() override { throw Exception("Not supported"); };
bool getBoolValue() override { throw Exception("Not supported on ColStringValue"); };
int compare(ColValue * other) override;
@@ -86,11 +91,12 @@ namespace usql {
ColDateValue(long value) : m_date(value) {};
ColDateValue(const ColDateValue &other) : m_date(other.m_date) {};
ColumnType getColType() override { return ColumnType::date_type; };
long getIntValue() override { return m_date; };
double getDoubleValue() override { return (double) m_date; };
std::string getStringValue() override { return Settings::date_to_string(m_date); };
long getDateValue() override { return m_date; };
bool getBoolValue() override { throw Exception("Not supported"); };
bool getBoolValue() override { throw Exception("Not supported on ColDateValue"); };
int compare(ColValue * other) override;
@@ -101,10 +107,11 @@ namespace usql {
ColBooleanValue(bool value) : m_bool(value) {};
ColBooleanValue(const ColBooleanValue &other) : m_bool(other.m_bool) {};
ColumnType getColType() override { return ColumnType::bool_type; };
long getIntValue() override { return (long) m_bool; };
double getDoubleValue() override { return (double) m_bool; };
std::string getStringValue() override { return m_bool ? "Y" : "N"; };
long getDateValue() override { throw Exception("Not supported"); };
long getDateValue() override { throw Exception("Not supported on ColBooleanValue"); };
bool getBoolValue() override { return m_bool; };
int compare(ColValue * other) override;