MongoDB C++ Driver mongocxx-3.0.3
Loading...
Searching...
No Matches
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/builder/stream/document.hpp>
20#include <bsoncxx/builder/stream/helpers.hpp>
21#include <bsoncxx/builder/stream/key_context.hpp>
22#include <bsoncxx/stdx/optional.hpp>
23#include <bsoncxx/string/view_or_value.hpp>
24#include <bsoncxx/types/value.hpp>
25#include <mongocxx/stdx.hpp>
26
27#include <mongocxx/config/prelude.hpp>
28
29namespace mongocxx {
30MONGOCXX_INLINE_NAMESPACE_BEGIN
31
35class MONGOCXX_API hint {
36 public:
47
55
63 friend MONGOCXX_API bool MONGOCXX_CALL operator==(const hint& index_hint, std::string index);
64
65 friend MONGOCXX_API bool MONGOCXX_CALL
66 operator==(const hint& index_hint, bsoncxx::document::view index);
70
78
88
92 MONGOCXX_INLINE operator bsoncxx::types::value() const;
93
100 MONGOCXX_INLINE operator bsoncxx::document::value() const;
101
102 private:
103 stdx::optional<bsoncxx::document::view_or_value> _index_doc;
104 stdx::optional<bsoncxx::string::view_or_value> _index_string;
105};
106
114MONGOCXX_API bool MONGOCXX_CALL operator==(std::string index, const hint& index_hint);
115
125MONGOCXX_API bool MONGOCXX_CALL operator!=(const hint& index_hint, std::string index);
126MONGOCXX_API bool MONGOCXX_CALL operator!=(std::string index, const hint& index_index);
130
138MONGOCXX_API bool MONGOCXX_CALL operator==(bsoncxx::document::view index, const hint& index_hint);
139
150MONGOCXX_API bool MONGOCXX_CALL operator!=(const hint& index_hint, bsoncxx::document::view index);
151MONGOCXX_API bool MONGOCXX_CALL operator!=(bsoncxx::document::view index, const hint& index_hint);
155
156MONGOCXX_INLINE hint::operator bsoncxx::types::value() const {
157 return to_value();
158}
159
160MONGOCXX_INLINE hint::operator bsoncxx::document::value() const {
161 return to_document();
162}
163
164MONGOCXX_INLINE_NAMESPACE_END
165} // namespace mongocxx
166
167#include <mongocxx/config/postlude.hpp>
A read-only BSON document that owns its underlying buffer.
Definition value.hpp:33
A read-only, non-owning view of a BSON document.
Definition view.hpp:33
Class representing a view-or-value variant type for strings.
Definition view_or_value.hpp:36
A variant that can contain any BSON type.
Definition value.hpp:37
Class representing a hint to be passed to a database operation.
Definition hint.hpp:35
bool operator==(bsoncxx::document::view index, const hint &index_hint)
Convenience methods to compare for equality against an index document.
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.
hint(bsoncxx::document::view_or_value index)
Constructs a new hint.
bsoncxx::document::value to_document() const
Return a bson document representing this hint.
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.
bsoncxx::types::value to_value() const
Returns a types::value representing this hint.
hint(bsoncxx::string::view_or_value index)
Constructs a new hint.