MongoDB C++ Driver  mongocxx-3.9.0
All Classes Namespaces Functions Typedefs Enumerations Enumerator Friends Pages
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 <bsoncxx/document/value.hpp>
18 #include <bsoncxx/document/view_or_value.hpp>
19 #include <bsoncxx/stdx/optional.hpp>
20 #include <bsoncxx/string/view_or_value.hpp>
21 #include <bsoncxx/types/bson_value/view.hpp>
22 #include <mongocxx/stdx.hpp>
23 
24 #include <mongocxx/config/prelude.hpp>
25 
26 namespace mongocxx {
27 inline namespace v_noabi {
31 class MONGOCXX_API hint {
32  public:
42  hint(bsoncxx::document::view_or_value index);
43 
50  explicit hint(bsoncxx::string::view_or_value index);
51 
59  friend MONGOCXX_API bool MONGOCXX_CALL operator==(const hint& index_hint, std::string index);
60 
61  friend MONGOCXX_API bool MONGOCXX_CALL operator==(const hint& index_hint,
62  bsoncxx::document::view index);
66 
75 
83  MONGOCXX_INLINE operator bsoncxx::types::bson_value::view() const;
84 
85  private:
86  stdx::optional<bsoncxx::document::view_or_value> _index_doc;
87  stdx::optional<bsoncxx::string::view_or_value> _index_string;
88 };
89 
97 MONGOCXX_API bool MONGOCXX_CALL operator==(std::string index, const hint& index_hint);
98 
108 MONGOCXX_API bool MONGOCXX_CALL operator!=(const hint& index_hint, std::string index);
109 MONGOCXX_API bool MONGOCXX_CALL operator!=(std::string index, const hint& index_index);
113 
121 MONGOCXX_API bool MONGOCXX_CALL operator==(bsoncxx::document::view index, const hint& index_hint);
122 
133 MONGOCXX_API bool MONGOCXX_CALL operator!=(const hint& index_hint, bsoncxx::document::view index);
134 MONGOCXX_API bool MONGOCXX_CALL operator!=(bsoncxx::document::view index, const hint& index_hint);
138 
139 MONGOCXX_INLINE hint::operator bsoncxx::types::bson_value::view() const {
140  return to_value();
141 }
142 
143 } // namespace v_noabi
144 } // namespace mongocxx
145 
146 #include <mongocxx/config/postlude.hpp>
A view-only variant that can contain any BSON type.
Definition: view.hpp:44
Class representing a hint to be passed to a database operation.
Definition: hint.hpp:31
bool operator==(bsoncxx::document::view index, const hint &index_hint)
Convenience methods to compare for equality against an index document.
bsoncxx::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.
friend bool operator==(const hint &index_hint, bsoncxx::document::view index)
Compare this hint to a string for (in)-equality.
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.
bool operator!=(const hint &index_hint, bsoncxx::document::view index)
Convenience methods to compare for equality against an index document.
hint(bsoncxx::document::view_or_value index)
Constructs a new hint.
hint(bsoncxx::string::view_or_value index)
Constructs a new hint.
The top-level namespace for mongocxx library entities.
Definition: bulk_write.hpp:24