#ifndef DB_SELECTCOMMANDUTIL_IMPL_H #define DB_SELECTCOMMANDUTIL_IMPL_H #include "selectcommand.h" #include /// @cond namespace DB { template inline void forEachField(DB::SelectCommand * sel, const Func & func, Args &&... args) { if constexpr (field >= std::tuple_size::value) { (void)sel; func(std::forward(args)...); } else { 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 Row::template FieldType Row::value() const { return get(); } template template inline typename Row::template FieldType Row::get() const { FieldType a; sel->operator[](C) >> a; return a; } } /// @endcond #endif