#include "Pgsql_Value.h" #include #include 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 long long() const { return std::strtoull(m_val, nullptr, 10); } Value::operator bool() const { return std::strcmp(m_val, "t") == 0; } //void operator<<(QString &s, const Value &v) //{ // s = v.asQString(); //} //void operator<<(QDateTime &l, const Value &v) //{ // l = QDateTime::fromString(asQString(), // "yyyy-MM-dd hh:mm:ss"); //} //void operator<<(std::string &l, const Value &v) //{ // l = v; //} //void operator<<(short &l, const Value &v) //{ // l = (short)std::atoi(v.c_str()); //} //void operator<<(int &l, const Value &v) //{ // l = std::atoi(v.c_str()); //} //void Pgsql::operator<<(Oid &l, const Value &v) //{ // l = std::atoi(v.c_str()); //} //void operator<<(__int64 &l, const Value &v) //{ // l = std::strtoull(v.c_str(), nullptr, 10); //} //void operator<<(bool &l, const Value &v) //{ // l = std::strcmp(v.c_str(), "t") == 0; //}