usql update
usql is still very primitive..it just barely works
This commit is contained in:
63
usql/row.h
63
usql/row.h
@@ -10,67 +10,54 @@ namespace usql {
|
||||
|
||||
struct ColValue {
|
||||
|
||||
virtual bool isNull() { return false; };;;;
|
||||
|
||||
virtual int integerValue() { throw Exception("Not supported"); };
|
||||
|
||||
virtual double floatValue() { throw Exception("Not supported"); };
|
||||
|
||||
virtual std::string stringValue() { throw Exception("Not supported"); };
|
||||
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"); };
|
||||
};
|
||||
|
||||
|
||||
struct ColNullValue : ColValue {
|
||||
|
||||
virtual bool isNull() { return true; };
|
||||
|
||||
virtual std::string stringValue() { return "null"; };
|
||||
virtual std::string getStringValue() { return "null"; };
|
||||
};
|
||||
|
||||
|
||||
struct ColIntegerValue : ColValue {
|
||||
|
||||
ColIntegerValue(int value) : m_integer(value) {};
|
||||
|
||||
ColIntegerValue(long value) : m_integer(value) {};
|
||||
ColIntegerValue(const ColIntegerValue &other) : m_integer(other.m_integer) {};
|
||||
|
||||
virtual int integerValue() { return m_integer; };
|
||||
|
||||
virtual double floatValue() { return (double) m_integer; };
|
||||
|
||||
virtual std::string stringValue() { return std::to_string(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); };
|
||||
|
||||
int m_integer;
|
||||
};
|
||||
|
||||
|
||||
struct ColFloatValue : ColValue {
|
||||
struct ColDoubleValue : ColValue {
|
||||
|
||||
ColFloatValue(double value) : m_float(value) {};
|
||||
ColDoubleValue(double value) : m_double(value) {};
|
||||
ColDoubleValue(const ColDoubleValue &other) : m_double(other.m_double) {}
|
||||
|
||||
ColFloatValue(const ColFloatValue &other) : m_float(other.m_float) {}
|
||||
virtual long getIntValue() { return (long) m_double; };
|
||||
virtual double getDoubleValue() { return m_double; };
|
||||
virtual std::string getStringValue() { return std::to_string(m_double); };
|
||||
|
||||
virtual int integerValue() { return (int) m_float; };
|
||||
|
||||
virtual double floatValue() { return m_float; };
|
||||
|
||||
virtual std::string stringValue() { return std::to_string(m_float); };
|
||||
|
||||
double m_float;
|
||||
double m_double;
|
||||
};
|
||||
|
||||
|
||||
struct ColStringValue : ColValue {
|
||||
|
||||
ColStringValue(const std::string value) : m_string(value) {};
|
||||
|
||||
ColStringValue(const ColStringValue &other) : m_string(other.m_string) {};
|
||||
|
||||
virtual int integerValue() { return std::stoi(m_string); };
|
||||
|
||||
virtual double floatValue() { return std::stod(m_string); };
|
||||
|
||||
virtual std::string stringValue() { return 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; };
|
||||
|
||||
std::string m_string;
|
||||
};
|
||||
@@ -80,22 +67,22 @@ namespace usql {
|
||||
|
||||
public:
|
||||
Row(int cols_count);
|
||||
|
||||
Row(const Row &other);
|
||||
|
||||
Row &operator=(Row other);
|
||||
|
||||
void setColumnValue(int col_index, int value);
|
||||
|
||||
void setColumnNull(int col_index);
|
||||
void setColumnValue(int col_index, long value);
|
||||
void setColumnValue(int col_index, double value);
|
||||
|
||||
void setColumnValue(int col_index, const std::string &value);
|
||||
void setColumnValue(ColDefNode *col_def, ColValue *col_value);
|
||||
void setColumnValue(ColDefNode *col_def, ValueNode *col_value);
|
||||
|
||||
ColValue &operator[](int i) {
|
||||
return *m_columns[i];
|
||||
}
|
||||
|
||||
ColValue *ithColumn(int i) {
|
||||
ColValue * ithColumn(int i) const {
|
||||
return m_columns[i].get();
|
||||
}
|
||||
|
||||
@@ -105,4 +92,4 @@ namespace usql {
|
||||
std::vector<std::unique_ptr<ColValue>> m_columns;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace
|
||||
Reference in New Issue
Block a user