2017-02-18 12:05:48 +01:00
|
|
|
|
#ifndef PGSQL_VALUE_H
|
|
|
|
|
|
#define PGSQL_VALUE_H
|
|
|
|
|
|
|
|
|
|
|
|
#include "Pgsql_declare.h"
|
|
|
|
|
|
#include <QString>
|
|
|
|
|
|
#include <QDateTime>
|
|
|
|
|
|
|
|
|
|
|
|
namespace Pgsql {
|
|
|
|
|
|
|
|
|
|
|
|
/** \brief Class that is returned as value of a cell to facilitate auto conversion.
|
|
|
|
|
|
*/
|
|
|
|
|
|
class Value {
|
|
|
|
|
|
public:
|
|
|
|
|
|
Value(const char *val, Oid typ);
|
|
|
|
|
|
QString asQString() const;
|
2017-08-22 12:45:45 +02:00
|
|
|
|
const char* c_str() const { return m_val; }
|
|
|
|
|
|
|
2017-02-18 12:05:48 +01:00
|
|
|
|
operator QString() const;
|
|
|
|
|
|
operator QDateTime() const;
|
|
|
|
|
|
operator std::string() const;
|
|
|
|
|
|
operator short() const;
|
|
|
|
|
|
operator int() const;
|
|
|
|
|
|
operator Oid() const;
|
2017-08-23 08:10:01 +02:00
|
|
|
|
operator long long() const;
|
2017-02-18 12:05:48 +01:00
|
|
|
|
operator bool() const;
|
|
|
|
|
|
private:
|
|
|
|
|
|
const char *m_val;
|
|
|
|
|
|
Oid m_typ;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2017-08-22 12:45:45 +02:00
|
|
|
|
// void operator<<(QString &s, const Value &v);
|
|
|
|
|
|
// void operator<<(QDateTime &l, const Value &v);
|
|
|
|
|
|
// void operator<<(std::string &l, const Value &v);
|
|
|
|
|
|
// void operator<<(short &l, const Value &v);
|
|
|
|
|
|
// void operator<<(int &l, const Value &v);
|
|
|
|
|
|
// void operator<<(Oid &l, const Value &v);
|
|
|
|
|
|
// void operator<<(__int64 &l, const Value &v);
|
|
|
|
|
|
// void operator<<(bool &l, const Value &v);
|
|
|
|
|
|
template <typename T>
|
|
|
|
|
|
void operator<<(T &s, const Value &v)
|
|
|
|
|
|
{
|
|
|
|
|
|
s = static_cast<T>(v);
|
|
|
|
|
|
}
|
2017-02-18 12:05:48 +01:00
|
|
|
|
|
|
|
|
|
|
} // end namespace Pgsql
|
|
|
|
|
|
|
|
|
|
|
|
#endif // PGSQL_VALUE_H
|