MongoDB C++ Driver 4.2.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
47class hint {
48 private:
49 class impl;
50 void* _impl;
51
52 public:
59
66 MONGOCXX_ABI_EXPORT_CDECL() hint(hint&& other) noexcept;
67
74 MONGOCXX_ABI_EXPORT_CDECL(hint&) operator=(hint&& other) noexcept;
75
80
84 MONGOCXX_ABI_EXPORT_CDECL(hint&) operator=(hint const& other);
85
94
98 explicit MONGOCXX_ABI_EXPORT_CDECL() hint(std::string str);
99
103 explicit MONGOCXX_ABI_EXPORT_CDECL() hint(bsoncxx::v1::document::value doc);
104
110 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v1::stdx::optional<bsoncxx::v1::stdx::string_view>) str() const;
111
117 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v1::stdx::optional<bsoncxx::v1::document::view>) doc() const;
118
123
127 /* explicit(false) */ MONGOCXX_ABI_EXPORT_CDECL() operator bsoncxx::v1::types::view() const;
128
133 friend bool operator==(hint const& lhs, hint const& rhs) {
134 return lhs.str() == rhs.str() && lhs.doc() == rhs.doc();
135 }
136
137 friend bool operator!=(hint const& lhs, hint const& rhs) {
138 return !(lhs == rhs);
139 }
140
142
148 return h.str() == str;
149 }
150
152 return h.str() != str;
153 }
154
156 return str == h.str();
157 }
158
160 return str != h.str();
161 }
162
164
170 return h.doc() == doc;
171 }
172
174 return h.doc() != doc;
175 }
176
178 return doc == h.doc();
179 }
180
182 return doc != h.doc();
183 }
184
186
187 class internal;
188};
189
190} // namespace v1
191} // namespace mongocxx
192
194
A non-owning, read-only BSON document.
Definition view.hpp:54
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:181
friend bool operator!=(bsoncxx::v1::stdx::string_view str, hint const &h)
Equivalent to comparing h.str() with str.
Definition hint.hpp:159
friend bool operator!=(hint const &h, bsoncxx::v1::stdx::string_view str)
Equivalent to comparing h.str() with str.
Definition hint.hpp:151
friend bool operator==(hint const &h, bsoncxx::v1::document::view doc)
Equivalent to comparing h.doc() and doc.
Definition hint.hpp:169
friend bool operator==(bsoncxx::v1::document::view doc, hint const &h)
Equivalent to comparing h.doc() and doc.
Definition hint.hpp:177
friend bool operator!=(hint const &h, bsoncxx::v1::document::view doc)
Equivalent to comparing h.doc() and doc.
Definition hint.hpp:173
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:155
friend bool operator!=(hint const &lhs, hint const &rhs)
Compare equal when the underlying "hint" values compare equal.
Definition hint.hpp:137
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:147
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.