Loading...
Searching...
No Matches
cursor.hpp
Go to the documentation of this file.
// Copyright 2009-present MongoDB, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#pragma once
#include <mongocxx/v1/cursor-fwd.hpp> // IWYU pragma: export
//
#include <mongocxx/v1/detail/prelude.hpp>
#include <bsoncxx/v1/document/view-fwd.hpp>
#include <mongocxx/v1/config/export.hpp>
#include <cstddef>
#include <iterator>
namespace mongocxx {
namespace v1 {
class cursor {
private:
class impl;
void* _impl;
public:
enum class type {
k_non_tailable,
k_tailable,
k_tailable_await,
};
class iterator;
MONGOCXX_ABI_EXPORT_CDECL() ~cursor();
MONGOCXX_ABI_EXPORT_CDECL() cursor(cursor&& other) noexcept;
MONGOCXX_ABI_EXPORT_CDECL(cursor&) operator=(cursor&& other) noexcept;
cursor(cursor const&) = delete;
cursor& operator=(cursor const&) = delete;
MONGOCXX_ABI_EXPORT_CDECL(iterator) begin();
iterator end() const;
class internal;
private:
/* explicit(false) */ cursor(void* impl);
};
class cursor::iterator {
private:
void* _impl; // v1::cursor
public:
using iterator_category = std::input_iterator_tag;
using value_type = bsoncxx::v1::document::view;
using difference_type = std::ptrdiff_t;
using pointer = value_type const*;
using reference = value_type;
MONGOCXX_ABI_EXPORT_CDECL() ~iterator();
MONGOCXX_ABI_EXPORT_CDECL() iterator(iterator&& other) noexcept;
MONGOCXX_ABI_EXPORT_CDECL(iterator&) operator=(iterator&& other) noexcept;
MONGOCXX_ABI_EXPORT_CDECL() iterator(iterator const& other);
MONGOCXX_ABI_EXPORT_CDECL(iterator&) operator=(iterator const& other);
MONGOCXX_ABI_EXPORT_CDECL() iterator();
MONGOCXX_ABI_EXPORT_CDECL(value_type) operator*() const;
MONGOCXX_ABI_EXPORT_CDECL(pointer) operator->() const;
MONGOCXX_ABI_EXPORT_CDECL(iterator&) operator++();
iterator& operator++(int) {
return this->operator++();
}
friend MONGOCXX_ABI_EXPORT_CDECL(bool) operator==(iterator const& lhs, iterator const& rhs);
friend bool operator!=(iterator const& lhs, iterator const& rhs) {
return !(lhs == rhs);
}
class internal;
private:
/* explicit(false) */ iterator(void* impl);
};
inline cursor::iterator cursor::end() const {
return {};
}
} // namespace v1
} // namespace mongocxx
#include <mongocxx/v1/detail/postlude.hpp>
bsoncxx::v1::document::view
A non-owning, read-only BSON document.
Definition view.hpp:52
mongocxx::v1::cursor::iterator
An iterator over the results of an associated cursor.
Definition cursor.hpp:147
mongocxx::v1::cursor::iterator::operator!=
friend bool operator!=(iterator const &lhs, iterator const &rhs)
Equivalent to !(lhs == rhs).
Definition cursor.hpp:263
mongocxx::v1::cursor::iterator::operator++
iterator & operator++()
Increment this iterator.
mongocxx::v1::cursor::iterator::iterator
iterator(iterator &&other) noexcept
Move construction.
mongocxx::v1::cursor::iterator::pointer
value_type const * pointer
Provide std::iterator_traits<T>::pointer.
Definition cursor.hpp:170
mongocxx::v1::cursor::iterator::~iterator
~iterator()
Destroy this object.
mongocxx::v1::cursor::iterator::value_type
bsoncxx::v1::document::view value_type
Provide std::iterator_traits<T>::value_type.
Definition cursor.hpp:160
mongocxx::v1::cursor::iterator::difference_type
std::ptrdiff_t difference_type
Provide std::iterator_traits<T>::difference_type.
Definition cursor.hpp:165
mongocxx::v1::cursor::iterator::iterator_category
std::input_iterator_tag iterator_category
Provide std::iterator_traits<T>::iterator_category.
Definition cursor.hpp:155
mongocxx::v1::cursor::iterator::operator==
friend bool operator==(iterator const &lhs, iterator const &rhs)
Equality comparison.
mongocxx::v1::cursor::iterator::reference
value_type reference
Provide std::iterator_traits<T>::reference.
Definition cursor.hpp:175
mongocxx::v1::cursor::cursor
cursor(cursor &&other) noexcept
Move constructor.
mongocxx::v1::cursor::type
type
Enumeration identifying the type of the cursor.
Definition cursor.hpp:48
mongocxx::v1::cursor::type::k_tailable_await
@ k_tailable_await
A tailable "awaitData" cursor.
Definition cursor.hpp:65
mongocxx::v1::cursor::type::k_non_tailable
@ k_non_tailable
A non-tailable cursor.
Definition cursor.hpp:53
mongocxx::v1::cursor::type::k_tailable
@ k_tailable
A tailable cursor.
Definition cursor.hpp:59
mongocxx::v1::cursor::end
iterator end() const
Return an end iterator.
Definition cursor.hpp:273
mongocxx::v1::cursor::begin
iterator begin()
Return an iterator over the results of the associated cursor.
mongocxx::v1::cursor::~cursor
~cursor()
Destroy this object.
export.hpp
Provides macros to control the set of symbols exported in the ABI.
MONGOCXX_ABI_EXPORT_CDECL
#define MONGOCXX_ABI_EXPORT_CDECL(...)
Equivalent to MONGOCXX_ABI_EXPORT with MONGOCXX_ABI_CDECL.
Definition export.hpp:52
postlude.hpp
The mongocxx v1 macro guard postlude header.
prelude.hpp
The mongocxx v1 macro guard prelude header.
mongocxx::v1
Declares entities whose ABI stability is guaranteed for documented symbols.
mongocxx
The top-level namespace within which all mongocxx library entities are declared.
cursor-fwd.hpp
Declares mongocxx::v1::cursor.
view-fwd.hpp
Declares bsoncxx::v1::document::view.