1
0
mirror of https://github.com/ohwgiles/laminar.git synced 2024-10-27 20:34:20 +00:00

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
This commit is contained in:
Oliver Giles 2018-01-04 08:40:10 +02:00
parent 3b0efcac9d
commit d7351c0c70
3 changed files with 11 additions and 14 deletions

View File

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

View File

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

View File

@ -41,7 +41,7 @@ class Json : public rapidjson::Writer<rapidjson::StringBuffer> {
public: public:
Json() : rapidjson::Writer<rapidjson::StringBuffer>(buf) { StartObject(); } Json() : rapidjson::Writer<rapidjson::StringBuffer>(buf) { StartObject(); }
template<typename T> 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& startObject(const char* key) { String(key); StartObject(); return *this; }
Json& startArray(const char* key) { String(key); StartArray(); return *this; } Json& startArray(const char* key) { String(key); StartArray(); return *this; }
const char* str() { EndObject(); return buf.GetString(); } 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, 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, 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 { namespace {
// Default values when none were supplied in $LAMINAR_CONF_FILE (/etc/laminar.conf) // Default values when none were supplied in $LAMINAR_CONF_FILE (/etc/laminar.conf)