MongoDB C++ Driver 4.4.0
Loading...
Searching...
No Matches
hint.hpp
Go to the documentation of this file.
1// Copyright 2009-present MongoDB, Inc.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#pragma once
16
17#include <mongocxx/v1/hint-fwd.hpp> // IWYU pragma: export
18
19//
20
22
25
29
31
32#include <string>
33
34namespace mongocxx {
35namespace v1 {
36
45class hint {
46 private:
47 class impl;
48 void* _impl;
49
50 public:
57
64 MONGOCXX_ABI_EXPORT_CDECL() hint(hint&& other) noexcept;
65
72 MONGOCXX_ABI_EXPORT_CDECL(hint&) operator=(hint&& other) noexcept;
73
78
82 MONGOCXX_ABI_EXPORT_CDECL(hint&) operator=(hint const& other);
83
92
96 explicit MONGOCXX_ABI_EXPORT_CDECL() hint(std::string str);
97
101 explicit MONGOCXX_ABI_EXPORT_CDECL() hint(bsoncxx::v1::document::value doc);
102
108 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v1::stdx::optional<bsoncxx::v1::stdx::string_view>) str() const;
109
115 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v1::stdx::optional<bsoncxx::v1::document::view>) doc() const;
116
121
125 /* explicit(false) */ MONGOCXX_ABI_EXPORT_CDECL() operator bsoncxx::v1::types::view() const;
126
131 friend bool operator==(hint const& lhs, hint const& rhs) {
132 return lhs.str() == rhs.str() && lhs.doc() == rhs.doc();
133 }
134
135 friend bool operator!=(hint const& lhs, hint const& rhs) {
136 return !(lhs == rhs);
137 }
138
140
146 return h.str() == str;
147 }
148
150 return h.str() != str;
151 }
152
154 return str == h.str();
155 }
156
158 return str != h.str();
159 }
160
162
168 return h.doc() == doc;
169 }
170
172 return h.doc() != doc;
173 }
174
176 return doc == h.doc();
177 }
178
180 return doc != h.doc();
181 }
182
184
185 class internal;
186};
187
188} // namespace v1
189} // namespace mongocxx
190
192
A non-owning, read-only BSON document.
Definition view.hpp:52
A polyfill for std::string_view.
Definition string_view.hpp:412
friend bool operator!=(bsoncxx::v1::document::view doc, hint const &h)
Equivalent to comparing h.doc() and doc.
Definition hint.hpp:179
friend bool operator!=(bsoncxx::v1::stdx::string_view str, hint const &h)
Equivalent to comparing h.str() with str.
Definition hint.hpp:157
friend bool operator!=(hint const &h, bsoncxx::v1::stdx::string_view str)
Equivalent to comparing h.str() with str.
Definition hint.hpp:149
friend bool operator==(hint const &h, bsoncxx::v1::document::view doc)
Equivalent to comparing h.doc() and doc.
Definition hint.hpp:167
friend bool operator==(bsoncxx::v1::document::view doc, hint const &h)
Equivalent to comparing h.doc() and doc.
Definition hint.hpp:175
friend bool operator!=(hint const &h, bsoncxx::v1::document::view doc)
Equivalent to comparing h.doc() and doc.
Definition hint.hpp:171
hint(hint &&other) noexcept
Move constructor.
friend bool operator==(bsoncxx::v1::stdx::string_view str, hint const &h)
Equivalent to comparing h.str() with str.
Definition hint.hpp:153
friend bool operator!=(hint const &lhs, hint const &rhs)
Compare equal when the underlying "hint" values compare equal.
Definition hint.hpp:135
bsoncxx::v1::stdx::optional< bsoncxx::v1::stdx::string_view > str() const
Return the current "hint" value as a string.
friend bool operator==(hint const &h, bsoncxx::v1::stdx::string_view str)
Equivalent to comparing h.str() with str.
Definition hint.hpp:145
bsoncxx::v1::types::view to_value() const
Return the current "hint" value as a BSON type value.
operator bsoncxx::v1::types::view() const
Equivalent to to_value() const.
bsoncxx::v1::stdx::optional< bsoncxx::v1::document::view > doc() const
Return the current "hint" value as a document.
~hint()
Destroy this object.
Provides macros to control the set of symbols exported in the ABI.
#define MONGOCXX_ABI_EXPORT_CDECL(...)
Equivalent to MONGOCXX_ABI_EXPORT with MONGOCXX_ABI_CDECL.
Definition export.hpp:52
The mongocxx v1 macro guard postlude header.
The mongocxx v1 macro guard prelude header.
The top-level namespace within which all bsoncxx library entities are declared.
Declares entities whose ABI stability is guaranteed for documented symbols.
The top-level namespace within which all mongocxx library entities are declared.
Declares bsoncxx::v1::document::value.
Provides bsoncxx::v1::document::view.
Declares mongocxx::v1::hint.
Provides std::optional-related polyfills for library API usage.
Provides std::string_view-related polyfills for library API usage.
Declares non-owning, read-only entities representing a BSON type value.