MongoDB C++ Driver  mongocxx-3.10.2
hint.hpp
1 // Copyright 2015 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/hint-fwd.hpp>
18 
19 #include <bsoncxx/document/value.hpp>
20 #include <bsoncxx/document/view_or_value.hpp>
21 #include <bsoncxx/stdx/optional.hpp>
22 #include <bsoncxx/string/view_or_value.hpp>
23 #include <bsoncxx/types/bson_value/view.hpp>
24 #include <mongocxx/stdx.hpp>
25 
26 #include <mongocxx/config/prelude.hpp>
27 
28 namespace mongocxx {
29 namespace v_noabi {
30 
34 class hint {
35  public:
46 
54 
62  friend MONGOCXX_API bool MONGOCXX_CALL operator==(const hint& index_hint, std::string index);
63 
64  friend MONGOCXX_API bool MONGOCXX_CALL operator==(const hint& index_hint,
69 
78 
86  MONGOCXX_INLINE operator bsoncxx::v_noabi::types::bson_value::view() const;
87 
88  private:
89  stdx::optional<bsoncxx::v_noabi::document::view_or_value> _index_doc;
90  stdx::optional<bsoncxx::v_noabi::string::view_or_value> _index_string;
91 };
92 
100 MONGOCXX_API bool MONGOCXX_CALL operator==(std::string index, const hint& index_hint);
101 
111 MONGOCXX_API bool MONGOCXX_CALL operator!=(const hint& index_hint, std::string index);
112 MONGOCXX_API bool MONGOCXX_CALL operator!=(std::string index, const hint& index_index);
116 
124 MONGOCXX_API bool MONGOCXX_CALL operator==(bsoncxx::v_noabi::document::view index,
125  const hint& index_hint);
126 
137 MONGOCXX_API bool MONGOCXX_CALL operator!=(const hint& index_hint,
139 MONGOCXX_API bool MONGOCXX_CALL operator!=(bsoncxx::v_noabi::document::view index,
140  const hint& index_hint);
144 
145 MONGOCXX_INLINE hint::operator bsoncxx::v_noabi::types::bson_value::view() const {
146  return to_value();
147 }
148 
149 } // namespace v_noabi
150 } // namespace mongocxx
151 
152 namespace mongocxx {
153 
154 using ::mongocxx::v_noabi::operator==;
155 using ::mongocxx::v_noabi::operator!=;
156 
157 } // namespace mongocxx
158 
159 #include <mongocxx/config/postlude.hpp>
A read-only, non-owning view of a BSON document.
Definition: view.hpp:35
Class representing a view-or-value variant type for strings.
Definition: view_or_value.hpp:38
A view-only variant that can contain any BSON type.
Definition: view.hpp:41
Class representing a hint to be passed to a database operation.
Definition: hint.hpp:34
bsoncxx::v_noabi::types::bson_value::view to_value() const
Returns a types::bson_value::view representing this hint.
friend bool operator==(const hint &index_hint, std::string index)
Compare this hint to a string for (in)-equality.
bool operator!=(const hint &index_hint, bsoncxx::v_noabi::document::view index)
Convenience methods to compare for equality against an index document.
bool operator==(std::string index, const hint &index_hint)
Convenience methods to compare for equality against an index name.
bool operator!=(const hint &index_hint, std::string index)
Convenience methods to compare for inequality against an index name.
friend bool operator==(const hint &index_hint, bsoncxx::v_noabi::document::view index)
Compare this hint to a string for (in)-equality.
hint(bsoncxx::v_noabi::document::view_or_value index)
Constructs a new hint.
bool operator==(bsoncxx::v_noabi::document::view index, const hint &index_hint)
Convenience methods to compare for equality against an index document.
hint(bsoncxx::v_noabi::string::view_or_value index)
Constructs a new hint.
The top-level namespace for mongocxx library entities.
Definition: bulk_write-fwd.hpp:19