fix compile error on 32-bit Linux

On 32-bit Linux, time_t is a long. Laminar extensively uses
time_t but provided only int and int64 db access, making the
use of long ambiguous. Since there is no explicit use of int64,
and because on 32-bit Linux long and int are recognized as
different types despite being the same width, replacing the
int64 handlers with long handlers fixes the compile error
pull/27/head
Oliver Giles 6 years ago
parent 3b0efcac9d
commit d7351c0c70

@ -52,11 +52,11 @@ void Database::Statement::bindValue(int i, uint e) {
sqlite3_bind_int(stmt, i, static_cast<int32_t>(e));
}
void Database::Statement::bindValue(int i, int64_t e) {
void Database::Statement::bindValue(int i, long e) {
sqlite3_bind_int64(stmt, i, e);
}
void Database::Statement::bindValue(int i, uint64_t e) {
void Database::Statement::bindValue(int i, ulong e) {
sqlite3_bind_int64(stmt, i, static_cast<int64_t>(e));
}
@ -88,12 +88,12 @@ template<> uint Database::Statement::fetchColumn(int col) {
return static_cast<uint>(sqlite3_column_int(stmt, col));
}
template<> int64_t Database::Statement::fetchColumn(int col) {
return sqlite3_column_int64(stmt, col);
template<> long Database::Statement::fetchColumn(int col) {
return static_cast<long>(sqlite3_column_int64(stmt, col));
}
template<> uint64_t Database::Statement::fetchColumn(int col) {
return static_cast<uint64_t>(sqlite3_column_int64(stmt, col));
template<> ulong Database::Statement::fetchColumn(int col) {
return static_cast<ulong>(sqlite3_column_int64(stmt, col));
}
bool Database::Statement::row() {

@ -120,8 +120,8 @@ private:
// Bind value specializations
void bindValue(int i, int e);
void bindValue(int i, uint e);
void bindValue(int i, int64_t e);
void bindValue(int i, uint64_t e);
void bindValue(int i, long e);
void bindValue(int i, unsigned long e);
void bindValue(int i, const char* e);
void bindValue(int i, const std::string& e);
@ -149,7 +149,7 @@ template<> std::string Database::Statement::fetchColumn(int col);
template<> const char* Database::Statement::fetchColumn(int col);
template<> int Database::Statement::fetchColumn(int col);
template<> uint Database::Statement::fetchColumn(int col);
template<> int64_t Database::Statement::fetchColumn(int col);
template<> uint64_t Database::Statement::fetchColumn(int col);
template<> long Database::Statement::fetchColumn(int col);
template<> ulong Database::Statement::fetchColumn(int col);
#endif // LAMINAR_DATABASE_H_

@ -41,7 +41,7 @@ class Json : public rapidjson::Writer<rapidjson::StringBuffer> {
public:
Json() : rapidjson::Writer<rapidjson::StringBuffer>(buf) { StartObject(); }
template<typename T>
Json& set(const char* key, T value);
Json& set(const char* key, T value) { String(key); Int64(value); return *this; }
Json& startObject(const char* key) { String(key); StartObject(); return *this; }
Json& startArray(const char* key) { String(key); StartArray(); return *this; }
const char* str() { EndObject(); return buf.GetString(); }
@ -50,9 +50,6 @@ private:
};
template<> Json& Json::set(const char* key, const char* value) { String(key); String(value); return *this; }
template<> Json& Json::set(const char* key, std::string value) { String(key); String(value.c_str()); return *this; }
template<> Json& Json::set(const char* key, int value) { String(key); Int(value); return *this; }
template<> Json& Json::set(const char* key, uint value) { String(key); Int(static_cast<int>(value)); return *this; }
template<> Json& Json::set(const char* key, time_t value) { String(key); Int64(value); return *this; }
namespace {
// Default values when none were supplied in $LAMINAR_CONF_FILE (/etc/laminar.conf)

Loading…
Cancel
Save