order by refactoring
This commit is contained in:
46
row.h
46
row.h
@@ -11,16 +11,24 @@ namespace usql {
|
||||
struct ColValue {
|
||||
|
||||
virtual bool isNull() { return false; };
|
||||
virtual long getIntValue() { throw Exception("Not supported"); };
|
||||
virtual double getDoubleValue() { throw Exception("Not supported"); };
|
||||
virtual std::string getStringValue() { throw Exception("Not supported"); };
|
||||
virtual long getIntValue() = 0;
|
||||
virtual double getDoubleValue() = 0;
|
||||
virtual std::string getStringValue() = 0;
|
||||
|
||||
virtual int compare(ColValue * other) = 0;
|
||||
|
||||
virtual ~ColValue() = default;
|
||||
};
|
||||
|
||||
|
||||
struct ColNullValue : ColValue {
|
||||
|
||||
virtual bool isNull() { return true; };
|
||||
virtual std::string getStringValue() { return "null"; };
|
||||
bool isNull() override { return true; };
|
||||
long getIntValue() override { throw Exception("Not supported"); };
|
||||
double getDoubleValue() override { throw Exception("Not supported"); };
|
||||
std::string getStringValue() override { return "null"; };
|
||||
|
||||
int compare(ColValue * other) override;
|
||||
};
|
||||
|
||||
|
||||
@@ -29,11 +37,13 @@ namespace usql {
|
||||
ColIntegerValue(long value) : m_integer(value) {};
|
||||
ColIntegerValue(const ColIntegerValue &other) : m_integer(other.m_integer) {};
|
||||
|
||||
virtual long getIntValue() { return m_integer; };
|
||||
virtual double getDoubleValue() { return (double) m_integer; };
|
||||
virtual std::string getStringValue() { return std::to_string(m_integer); };
|
||||
long getIntValue() override { return m_integer; };
|
||||
double getDoubleValue() override { return (double) m_integer; };
|
||||
std::string getStringValue() override { return std::to_string(m_integer); };
|
||||
|
||||
int m_integer;
|
||||
int compare(ColValue * other) override;
|
||||
|
||||
long m_integer;
|
||||
};
|
||||
|
||||
|
||||
@@ -42,9 +52,11 @@ namespace usql {
|
||||
ColDoubleValue(double value) : m_double(value) {};
|
||||
ColDoubleValue(const ColDoubleValue &other) : m_double(other.m_double) {}
|
||||
|
||||
virtual long getIntValue() { return (long) m_double; };
|
||||
virtual double getDoubleValue() { return m_double; };
|
||||
virtual std::string getStringValue() { return std::to_string(m_double); };
|
||||
long getIntValue() override { return (long) m_double; };
|
||||
double getDoubleValue() override { return m_double; };
|
||||
std::string getStringValue() override { return std::to_string(m_double); };
|
||||
|
||||
int compare(ColValue * other) override;
|
||||
|
||||
double m_double;
|
||||
};
|
||||
@@ -52,12 +64,14 @@ namespace usql {
|
||||
|
||||
struct ColStringValue : ColValue {
|
||||
|
||||
ColStringValue(const std::string value) : m_string(value) {};
|
||||
ColStringValue(const std::string &value) : m_string(value) {};
|
||||
ColStringValue(const ColStringValue &other) : m_string(other.m_string) {};
|
||||
|
||||
virtual long getIntValue() { return std::stoi(m_string); };
|
||||
virtual double getDoubleValue() { return std::stod(m_string); };
|
||||
virtual std::string getStringValue() { return m_string; };
|
||||
long getIntValue() override { return std::stoi(m_string); };
|
||||
double getDoubleValue() override { return std::stod(m_string); };
|
||||
std::string getStringValue() override { return m_string; };
|
||||
|
||||
int compare(ColValue * other) override;
|
||||
|
||||
std::string m_string;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user