some methods marked const

This commit is contained in:
2021-12-18 12:21:34 +01:00
parent 40fa78dd2a
commit c9c4f0fba3
8 changed files with 376 additions and 395 deletions

20
row.cpp
View File

@@ -4,16 +4,16 @@
namespace usql {
int ColNullValue::compare(ColValue &other) {
int ColNullValue::compare(ColValue &other) const {
return other.isNull() ? 0 : -1; // null goes to end
}
int ColIntegerValue::compare(ColValue &other) {
long r = m_integer - other.getIntValue();
int ColIntegerValue::compare(ColValue &other) const {
long r = m_integer - other.getIntegerValue();
return other.isNull() ? 1 : r > 0 ? 1 : r == 0 ? 0 : -1;
}
int ColDoubleValue::compare(ColValue &other) {
int ColDoubleValue::compare(ColValue &other) const {
if (other.isNull()) return 1; // null goes to end
double c = m_double - other.getDoubleValue();
@@ -25,16 +25,16 @@ ColStringValue & ColStringValue::operator=(ColStringValue other) {
return *this;
}
int ColStringValue::compare(ColValue &other) {
int ColStringValue::compare(ColValue &other) const {
return other.isNull() ? 1 : m_string->compare(other.getStringValue()); // null goes to end
}
int ColDateValue::compare(ColValue &other) {
long r = m_date - other.getIntValue();
int ColDateValue::compare(ColValue &other) const {
long r = m_date - other.getIntegerValue();
return other.isNull() ? 1 : r > 0 ? 1 : r == 0 ? 0 : -1;
}
int ColBooleanValue::compare(ColValue &other) {
int ColBooleanValue::compare(ColValue &other) const {
if (other.isNull()) return 1; // null goes to end
return m_bool == other.getBoolValue() ? 0 : m_bool && !other.getBoolValue() ? -1 : 1; // true first
@@ -48,7 +48,7 @@ Row::Row(const Row &other) : m_columns(other.m_columns.size()), m_visible(other.
ColumnType col_type = other[i].getColType();
switch (col_type) {
case ColumnType::integer_type :
setIntColumnValue(i, other[i].getIntValue());
setIntColumnValue(i, other[i].getIntegerValue());
break;
case ColumnType::float_type :
setFloatColumnValue(i, other[i].getDoubleValue());
@@ -110,7 +110,7 @@ void Row::setBoolColumnValue(int col_index, const std::string &value) {
void Row::setColumnValue(ColDefNode *col_def, ColValue &col_value) {
if (!col_value.isNull()) {
if (col_def->type == ColumnType::integer_type)
setIntColumnValue(col_def->order, col_value.getIntValue());
setIntColumnValue(col_def->order, col_value.getIntegerValue());
else if (col_def->type == ColumnType::float_type)
setFloatColumnValue(col_def->order, col_value.getDoubleValue());
else if (col_def->type == ColumnType::varchar_type)