#ifndef DB_SELECTCOMMANDUTIL_IMPL_H #define DB_SELECTCOMMANDUTIL_IMPL_H #include "selectcommand.h" #include #include /// @cond namespace DB { template inline typename boost::disable_if_c::value>::type forEachField(DB::SelectCommand *, const Func & func, const Fn & ... args) { func(args...); } template inline typename boost::enable_if_c::value>::type forEachField(DB::SelectCommand * sel, const Func & func, const Args & ... args) { typename std::tuple_element::type a; (*sel)[field] >> a; forEachField(sel, func, args..., a); } template inline void SelectCommand::forEachRow(const Func & func) { while (fetch()) { forEachField, Func, 0>(this, func); } } template inline RowRange SelectCommand::as() { return RowRange(this); } template inline RowRange::RowRange(SelectCommand * s) : sel(s) { } template inline RowRangeIterator RowRange::begin() const { return RowRangeIterator(sel); } template inline RowRangeIterator RowRange::end() const { return RowRangeIterator(nullptr); } template inline RowRangeIterator::RowRangeIterator(SelectCommand * s) : sel(s) { if (sel) { validRow = sel->fetch(); } else { validRow = false; } } template inline bool RowRangeIterator::operator!=(const RowRangeIterator &) const { return validRow; } template inline void RowRangeIterator::operator++() { validRow = sel->fetch(); } template inline Row RowRangeIterator::operator*() const { return Row(sel); } template inline Row::Row(SelectCommand * s) : RowBase(s) { } template template inline typename std::tuple_element>::type Row::value() const { typename std::tuple_element>::type a; sel->operator[](C) >> a; return a; } } /// @endcond #endif