userver
C++ Async Framework
Loading...
Searching...
No Matches
cursor.hpp
Go to the documentation of this file.
1
#
pragma
once
2
3
/// @file userver/storages/mongo/cursor.hpp
4
/// @brief @copybrief storages::mongo::Cursor
5
6
#
include
<
iterator
>
7
#
include
<
memory
>
8
9
#
include
<
userver
/
formats
/
bson
/
document
.
hpp
>
10
11
USERVER_NAMESPACE_BEGIN
12
13
namespace
storages::mongo {
14
namespace
impl {
15
class
CursorImpl;
16
}
// namespace impl
17
18
/// Interface for MongoDB query cursors
19
class
Cursor
{
20
public
:
21
explicit
Cursor(std::unique_ptr<impl::CursorImpl>&&);
22
~Cursor();
23
24
Cursor(
Cursor
&&)
noexcept
;
25
Cursor
& operator=(
Cursor
&&)
noexcept
;
26
27
class
Iterator
{
28
public
:
29
using
iterator_category = std::input_iterator_tag;
30
using
difference_type = ptrdiff_t;
31
using
value_type =
formats
::
bson
::
Document
;
32
using
reference =
const
value_type&;
33
using
pointer =
const
value_type*;
34
35
explicit
Iterator() =
default
;
36
explicit
Iterator(
Cursor
*);
37
38
class
DocHolder
{
39
public
:
40
explicit
DocHolder(value_type doc)
41
: doc_(std::move(doc))
42
{}
43
44
value_type& operator*() {
return
doc_; }
45
46
private
:
47
value_type doc_;
48
};
49
DocHolder
operator++(
int
);
50
Iterator
& operator++();
51
reference operator*()
const
;
52
pointer operator->()
const
;
53
54
bool
operator==(
const
Iterator
&)
const
;
55
bool
operator!=(
const
Iterator
&)
const
;
56
57
private
:
58
Cursor
* cursor_;
59
};
60
61
bool
HasMore()
const
;
62
explicit
operator
bool
()
const
{
return
HasMore(); }
63
64
/// Retrieve the cursor batch size; returns zero if the cursor uses the server-defined maximum batch size.
65
std::
uint32_t
GetBatchSize
()
const
;
66
67
/// Set the cursor batch size; set to zero to force the cursor to use the server-defined maximum batch size.
68
void
SetBatchSize
(std::uint32_t);
69
70
Iterator
begin();
71
Iterator
end();
72
73
private
:
74
std::unique_ptr<impl::CursorImpl> impl_;
75
};
76
77
}
// namespace storages::mongo
78
79
USERVER_NAMESPACE_END
userver
storages
mongo
cursor.hpp
Generated on Fri Dec 5 2025 12:22:40 for userver by
Doxygen
1.13.2