8#include <userver/storages/postgres/detail/typed_rows.hpp>
9#include <userver/storages/postgres/result_set.hpp>
11USERVER_NAMESPACE_BEGIN
150template <
typename T,
typename ExtractionTag>
151class TypedResultSet {
154 using difference_type =
ResultSet::difference_type;
155 static constexpr size_type npos =
ResultSet::npos;
156 static constexpr ExtractionTag kExtractTag{};
160 using const_iterator = detail::ConstTypedRowIterator<T, ExtractionTag, detail::IteratorDirection::kForward>;
161 using const_reverse_iterator = detail::ConstTypedRowIterator<T, ExtractionTag, detail::IteratorDirection::kReverse>;
163 using value_type = T;
164 using pointer = const_iterator;
169 using reference = value_type;
171 using reference = std::add_const_t<value_type>;
175 explicit TypedResultSet(
ResultSet result) : result_{std::move(result)} {}
178 size_type
Size()
const {
return result_.Size(); }
179 bool IsEmpty()
const {
return Size() == 0; }
186 const_iterator cbegin()
const& {
return const_iterator{result_.pimpl_, 0}; }
187 const_iterator begin()
const& {
return cbegin(); }
188 const_iterator cend()
const& {
return const_iterator{result_.pimpl_, Size()}; }
189 const_iterator end()
const& {
return cend(); }
190 const_iterator cbegin()
const&& { ReportMisuse(); }
191 const_iterator begin()
const&& { ReportMisuse(); }
192 const_iterator cend()
const&& { ReportMisuse(); }
193 const_iterator end()
const&& { ReportMisuse(); }
197 const_reverse_iterator crbegin()
const& {
return const_reverse_iterator(result_.pimpl_, Size() - 1); }
198 const_reverse_iterator rbegin()
const& {
return crbegin(); }
199 const_reverse_iterator crend()
const& {
return const_reverse_iterator(result_.pimpl_, npos); }
200 const_reverse_iterator rend()
const& {
return crend(); }
201 const_reverse_iterator crbegin()
const&& { ReportMisuse(); }
202 const_reverse_iterator rbegin()
const&& { ReportMisuse(); }
203 const_reverse_iterator crend()
const&& { ReportMisuse(); }
204 const_reverse_iterator rend()
const&& { ReportMisuse(); }
211 reference operator[](size_type)
const&& { ReportMisuse(); }
214 [[noreturn]]
static void ReportMisuse() {
215 static_assert(!
sizeof(T),
"keep the TypedResultSet before using, please");