mirror of
https://github.com/Relintai/rcpp_framework.git
synced 2025-02-20 15:14:26 +01:00
Added get_cell_float and get_cell_double helpers to QueryResult.
This commit is contained in:
parent
1bd90ceb4a
commit
4393c60e5f
@ -33,6 +33,35 @@ const int QueryResult::get_cell_int(const int index) {
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const float QueryResult::get_cell_float(const int index) {
|
||||||
|
if (is_cell_null(index)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//todo better way
|
||||||
|
std::stringstream ss;
|
||||||
|
ss.str(get_cell(index));
|
||||||
|
|
||||||
|
float r;
|
||||||
|
ss >> r;
|
||||||
|
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
const double QueryResult::get_cell_double(const int index) {
|
||||||
|
if (is_cell_null(index)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//todo better way
|
||||||
|
std::stringstream ss;
|
||||||
|
ss.str(get_cell(index));
|
||||||
|
|
||||||
|
double r;
|
||||||
|
ss >> r;
|
||||||
|
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
bool QueryResult::is_cell_null(const int index) {
|
bool QueryResult::is_cell_null(const int index) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,8 @@ public:
|
|||||||
virtual const String get_cell_str(const int index);
|
virtual const String get_cell_str(const int index);
|
||||||
virtual const bool get_cell_bool(const int index);
|
virtual const bool get_cell_bool(const int index);
|
||||||
virtual const int get_cell_int(const int index);
|
virtual const int get_cell_int(const int index);
|
||||||
|
virtual const float get_cell_float(const int index);
|
||||||
|
virtual const double get_cell_double(const int index);
|
||||||
|
|
||||||
virtual bool is_cell_null(const int index);
|
virtual bool is_cell_null(const int index);
|
||||||
|
|
||||||
|
@ -162,6 +162,25 @@ QueryBuilder *SQLite3QueryBuilder::val(const bool param) {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QueryBuilder *SQLite3QueryBuilder::valf(const float param) {
|
||||||
|
//todo add a better way
|
||||||
|
std::stringstream ss;
|
||||||
|
ss << param;
|
||||||
|
|
||||||
|
query_result += ss.str() + ", ";
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
QueryBuilder *SQLite3QueryBuilder::vald(const double param) {
|
||||||
|
//todo add a better way
|
||||||
|
std::stringstream ss;
|
||||||
|
ss << param;
|
||||||
|
|
||||||
|
query_result += ss.str() + ", ";
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
QueryBuilder *SQLite3QueryBuilder::nlike(const String &str) {
|
QueryBuilder *SQLite3QueryBuilder::nlike(const String &str) {
|
||||||
query_result += "LIKE '" + str + "' ";
|
query_result += "LIKE '" + str + "' ";
|
||||||
|
|
||||||
@ -205,6 +224,24 @@ QueryBuilder *SQLite3QueryBuilder::setp(const String &col, const bool param) {
|
|||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
QueryBuilder *SQLite3QueryBuilder::setpf(const String &col, const float param) {
|
||||||
|
//todo add a better way
|
||||||
|
std::stringstream ss;
|
||||||
|
ss << param;
|
||||||
|
|
||||||
|
query_result += col + "=" + ss.str() + ", ";
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
QueryBuilder *SQLite3QueryBuilder::setpd(const String &col, const double param) {
|
||||||
|
//todo add a better way
|
||||||
|
std::stringstream ss;
|
||||||
|
ss << param;
|
||||||
|
|
||||||
|
query_result += col + "=" + ss.str() + ", ";
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
QueryBuilder *SQLite3QueryBuilder::nwp(const String &col, const String ¶m) {
|
QueryBuilder *SQLite3QueryBuilder::nwp(const String &col, const String ¶m) {
|
||||||
query_result += col + "='" + param + "' ";
|
query_result += col + "='" + param + "' ";
|
||||||
|
@ -43,6 +43,8 @@ public:
|
|||||||
QueryBuilder *val(const char *param);
|
QueryBuilder *val(const char *param);
|
||||||
QueryBuilder *val(const int param);
|
QueryBuilder *val(const int param);
|
||||||
QueryBuilder *val(const bool param);
|
QueryBuilder *val(const bool param);
|
||||||
|
QueryBuilder *valf(const float param);
|
||||||
|
QueryBuilder *vald(const double param);
|
||||||
|
|
||||||
QueryBuilder *nlike(const String &str);
|
QueryBuilder *nlike(const String &str);
|
||||||
|
|
||||||
@ -52,6 +54,8 @@ public:
|
|||||||
QueryBuilder *setp(const String &col, const char *param);
|
QueryBuilder *setp(const String &col, const char *param);
|
||||||
QueryBuilder *setp(const String &col, const int param);
|
QueryBuilder *setp(const String &col, const int param);
|
||||||
QueryBuilder *setp(const String &col, const bool param);
|
QueryBuilder *setp(const String &col, const bool param);
|
||||||
|
QueryBuilder *setpf(const String &col, const float param);
|
||||||
|
QueryBuilder *setpd(const String &col, const double param);
|
||||||
|
|
||||||
QueryBuilder *nwp(const String &col, const String ¶m);
|
QueryBuilder *nwp(const String &col, const String ¶m);
|
||||||
QueryBuilder *wp(const String &col, const char *param);
|
QueryBuilder *wp(const String &col, const char *param);
|
||||||
|
Loading…
Reference in New Issue
Block a user