#ifndef PGSQL_VALUE_H #define PGSQL_VALUE_H #include "Pgsql_declare.h" #include "ArrayParser.h" #include #include #include 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; const char* c_str() const { return m_val; } operator QString() const; operator QDateTime() const; operator QDate() const; operator QTime() const; operator std::string() const; operator short() const; operator int() const; operator Oid() const; operator long long() const; operator bool() const; operator float() const; operator double() const; bool isString() const; /** * * \param insert_iter An insert_iterator which is used to add the elements of the array to a container. */ template void getAsArray(I insert_iter) const { using value_type = E; ArrayParser parser(m_val); for (;;) { auto res = parser.GetNextElem(); if (res.ok) { std::string str(res.value->data(), res.value->length()); // std::istringstream iss(str); Value val(str.c_str(), ANYOID); value_type v; // iss >> v; v << val; insert_iter = v; } else break; } } private: const char *m_val; Oid m_typ; }; template void operator<<(T &s, const Value &v) { s = static_cast(v); } } // end namespace Pgsql #endif // PGSQL_VALUE_H