use unique_ptr<string> in ColStringValue to save space in variant
This commit is contained in:
18
row.h
18
row.h
@@ -73,19 +73,21 @@ namespace usql {
|
||||
|
||||
|
||||
struct ColStringValue : ColValue {
|
||||
explicit ColStringValue(const std::string &value) : m_string(value) {};
|
||||
ColStringValue(const ColStringValue &other) : m_string(other.m_string) {};
|
||||
explicit ColStringValue(const std::string &value) : m_string(std::make_unique<std::string>(value)) {};
|
||||
ColStringValue(const ColStringValue &other) : m_string(std::make_unique<std::string>(*other.m_string)) {};
|
||||
|
||||
ColStringValue & operator=(ColStringValue other);
|
||||
|
||||
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); };
|
||||
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 on ColStringValue"); };
|
||||
|
||||
int compare(ColValue &other) override;
|
||||
|
||||
std::string m_string;
|
||||
std::unique_ptr<std::string> m_string;
|
||||
};
|
||||
|
||||
struct ColDateValue : ColValue {
|
||||
@@ -125,7 +127,7 @@ namespace usql {
|
||||
class Row {
|
||||
|
||||
public:
|
||||
explicit Row(int cols_count);
|
||||
explicit Row(int cols_count) : m_columns(cols_count, ColNullValue()) {};
|
||||
Row(const Row &other);
|
||||
|
||||
Row &operator=(Row other);
|
||||
|
||||
Reference in New Issue
Block a user