MongoDB C++ Driver  mongocxx-3.7.0
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 MONGOCXX_INLINE_NAMESPACE_BEGIN
28 
32 class MONGOCXX_API hint {
33  public:
44 
51  explicit hint(bsoncxx::string::view_or_value index);
52 
60  friend MONGOCXX_API bool MONGOCXX_CALL operator==(const hint& index_hint, std::string index);
61 
62  friend MONGOCXX_API bool MONGOCXX_CALL operator==(const hint& index_hint,
67 
75  bsoncxx::types::bson_value::view to_value() const;
76 
84  MONGOCXX_INLINE operator bsoncxx::types::bson_value::view() const;
85 
86  private:
87  stdx::optional<bsoncxx::document::view_or_value> _index_doc;
88  stdx::optional<bsoncxx::string::view_or_value> _index_string;
89 };
90 
98 MONGOCXX_API bool MONGOCXX_CALL operator==(std::string index, const hint& index_hint);
99 
109 MONGOCXX_API bool MONGOCXX_CALL operator!=(const hint& index_hint, std::string index);
110 MONGOCXX_API bool MONGOCXX_CALL operator!=(std::string index, const hint& index_index);
114 
122 MONGOCXX_API bool MONGOCXX_CALL operator==(bsoncxx::document::view index, const hint& index_hint);
123 
134 MONGOCXX_API bool MONGOCXX_CALL operator!=(const hint& index_hint, bsoncxx::document::view index);
135 MONGOCXX_API bool MONGOCXX_CALL operator!=(bsoncxx::document::view index, const hint& index_hint);
139 
140 MONGOCXX_INLINE hint::operator bsoncxx::types::bson_value::view() const {
141  return to_value();
142 }
143 
144 MONGOCXX_INLINE_NAMESPACE_END
145 } // namespace mongocxx
146 
147 #include <mongocxx/config/postlude.hpp>
mongocxx
Top level namespace for the MongoDB C++ driver.
Definition: bulk_write.hpp:24
bsoncxx::view_or_value< document::view, document::value >
bsoncxx::string::view_or_value
Class representing a view-or-value variant type for strings.
Definition: view_or_value.hpp:36
mongocxx::hint
Class representing a hint to be passed to a database operation.
Definition: hint.hpp:32
bsoncxx::document::view
A read-only, non-owning view of a BSON document.
Definition: view.hpp:33
bsoncxx::types::bson_value::view
A view-only variant that can contain any BSON type.
Definition: view.hpp:44