#ifndef PGSQL_COL_H #define PGSQL_COL_H #include "Pgsql_Row.h" #include namespace Pgsql { class Col { public: explicit Col(const Pgsql::Row &r) : row(r) {} void reset() { col = -1; } Pgsql::Value nextValue() { return row.get(++col); } void skip(int n = 1) { col += n; } template Col& getAsArray(I insert_iter, NullHandling nullhandling = NullHandling::Throw) { nextValue().getAsArray(insert_iter, nullhandling); return *this; } template Col& getAsArray(I insert_iter, const E &value_for_nulls) { nextValue().getAsArray(insert_iter, value_for_nulls); return *this; } template Col& getAsArrayOfOptional(I insert_iter) { nextValue().getAsArrayOfOptional(insert_iter); return *this; } template Col& getAsVector(I insert_iter) { nextValue().getAsVector(insert_iter); return *this; } private: const Pgsql::Row &row; int col = -1; }; template Col& operator>>(Col &c, std::vector &s) { return c.getAsArray(std::back_inserter(s)); } template Col& operator>>(Col &c, boost::container::small_vector &s) { return c.getAsArray(std::back_inserter(s)); } template Col& operator>>(Col &c, T &s) { s << c.nextValue(); return c; } } // end namespace Pgsql #endif // PGSQL_COL_H