Added list of databases and roles.

Roles works for atleast 9.3 and up.

Reorganizing code for communicating with database.
This commit is contained in:
eelke 2017-02-18 12:05:48 +01:00
parent 8c077b3d5f
commit 2d962334da
28 changed files with 881 additions and 428 deletions

56
src/Pgsql_Value.cpp Normal file
View file

@ -0,0 +1,56 @@
#include "Pgsql_Value.h"
#include <cstdlib>
#include <cstring>
using namespace Pgsql;
Value::Value(const char *val, Oid typ)
: m_val(val), m_typ(typ)
{}
QString Value::asQString() const
{
return QString::fromUtf8(m_val);
}
Value::operator QString() const
{
return QString::fromUtf8(m_val);
}
Value::operator QDateTime() const
{
return QDateTime::fromString(asQString(),
"yyyy-MM-dd hh:mm:ss");
}
Value::operator std::string() const
{
return m_val;
}
Value::operator short() const
{
return (short)std::atoi(m_val);
}
Value::operator int() const
{
return std::atoi(m_val);
}
Value::operator Oid() const
{
return operator int();
}
Value::operator __int64() const
{
return std::strtoull(m_val, nullptr, 10);
}
Value::operator bool() const
{
return std::strcmp(m_val, "t") == 0;
}