Couchbase C++ SDK 1.0.2 (rev. 51f4775)
Loading...
Searching...
No Matches
scan_result.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2/*
3 * Copyright 2024. Couchbase, Inc.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18#pragma once
19
20#include <couchbase/error.hxx>
22
23#include <future>
24#include <iterator>
25#include <memory>
26#include <system_error>
27#include <utility>
28
29namespace couchbase
30{
31#ifndef COUCHBASE_CXX_CLIENT_DOXYGEN
32class internal_scan_result;
33#endif
34
41using scan_item_handler = std::function<void(error, std::optional<scan_result_item>)>;
42
44{
45public:
52 scan_result() = default;
53
62 explicit scan_result(std::shared_ptr<internal_scan_result> internal);
63
72 void next(scan_item_handler&& handler) const;
73
82 auto next() const -> std::future<std::pair<error, std::optional<scan_result_item>>>;
83
90 void cancel();
91
99 {
100 public:
101 auto operator==(const iterator& other) const -> bool;
102 auto operator!=(const iterator& other) const -> bool;
103 auto operator*() -> std::pair<error, scan_result_item>;
105
106 explicit iterator(std::shared_ptr<internal_scan_result> internal);
107 explicit iterator(std::pair<error, scan_result_item> item);
108
109 using difference_type = std::ptrdiff_t;
111 using pointer = const scan_result_item*;
113 using iterator_category = std::input_iterator_tag;
114
115 private:
116 void fetch_item();
117
118 std::shared_ptr<internal_scan_result> internal_{};
119 std::pair<error, scan_result_item> item_{};
120 };
121
130 auto begin() -> iterator;
131
140 auto end() -> iterator;
141
142private:
143 std::shared_ptr<internal_scan_result> internal_{};
144};
145} // namespace couchbase
Definition error.hxx:30
An iterator that can be used to iterate through all the scan_result_items.
Definition scan_result.hxx:99
auto operator++() -> iterator &
auto operator!=(const iterator &other) const -> bool
iterator(std::shared_ptr< internal_scan_result > internal)
iterator(std::pair< error, scan_result_item > item)
std::input_iterator_tag iterator_category
Definition scan_result.hxx:113
auto operator*() -> std::pair< error, scan_result_item >
std::ptrdiff_t difference_type
Definition scan_result.hxx:109
auto operator==(const iterator &other) const -> bool
Definition scan_result_item.hxx:41
Definition scan_result.hxx:44
void cancel()
Cancels the scan.
scan_result(std::shared_ptr< internal_scan_result > internal)
Constructs a scan result from an internal scan result.
auto end() -> iterator
Returns an iterator to the end.
void next(scan_item_handler &&handler) const
Fetches the next scan result item.
scan_result()=default
Constructs an empty scan result.
auto next() const -> std::future< std::pair< error, std::optional< scan_result_item > > >
Fetches the next scan result item.
auto begin() -> iterator
Returns an iterator to the beginning.
Represents a single item from the result of collection::scan()
Definition allow_querying_search_index_options.hxx:28
std::function< void(error, std::optional< scan_result_item >)> scan_item_handler
The signature for the handler of the scan_result::next() operation.
Definition scan_result.hxx:41