pgLab/pgsql/Pgsql_Col.h

64 lines
1.1 KiB
C
Raw Normal View History

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