57 lines
803 B
C++
57 lines
803 B
C++
|
|
#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;
|
|||
|
|
}
|
|||
|
|
|