Loading...
Searching...
No Matches
mongocxx::v1::hint Class Reference

`#include <mongocxx/v1/hint.hpp>`

## Description

Options related to a MongoDB query hint.

A document or string that specifies the index to use to support the query predicate.

See also
  - Query Optimization (MongoDB Manual)

## Public Member Functions

| hint ()
| Default initialization.
| hint (bsoncxx::v1::document::value doc)
| Return the current "hint" option as a document.
| hint (hint &&other) noexcept
| Move constructor.
| hint (hint const &other)
| Copy construction.
| hint (std::string str)
| Initialize this "hint" option as a document.
| ~hint ()
| Destroy this object.
bsoncxx::v1::stdx::optional< bsoncxx::v1::document::view > | doc () const
| Return the current "hint" value as a document.
| operator bsoncxx::v1::types::view () const
| Equivalent to to_value() const.
hint & | operator= (hint &&other) noexcept
| Move assignment.
hint & | operator= (hint const &other)
| Copy assignment.
bsoncxx::v1::stdx::optional< bsoncxx::v1::stdx::string_view > | str () const
| Return the current "hint" value as a string.
bsoncxx::v1::types::view | to_value () const
| Return the current "hint" value as a BSON type value.

## Friends

bool | operator== (hint const &lhs, hint const &rhs)
| Compare equal when the underlying "hint" values compare equal.
bool | operator!= (hint const &lhs, hint const &rhs)
| Compare equal when the underlying "hint" values compare equal.
bool | operator== (hint const &h, bsoncxx::v1::stdx::string_view str)
| Equivalent to comparing h.str() with str.
bool | operator!= (hint const &h, bsoncxx::v1::stdx::string_view str)
| Equivalent to comparing h.str() with str.
bool | operator== (bsoncxx::v1::stdx::string_view str, hint const &h)
| Equivalent to comparing h.str() with str.
bool | operator!= (bsoncxx::v1::stdx::string_view str, hint const &h)
| Equivalent to comparing h.str() with str.
bool | operator== (hint const &h, bsoncxx::v1::document::view doc)
| Equivalent to comparing h.doc() and doc.
bool | operator!= (hint const &h, bsoncxx::v1::document::view doc)
| Equivalent to comparing h.doc() and doc.
bool | operator== (bsoncxx::v1::document::view doc, hint const &h)
| Equivalent to comparing h.doc() and doc.
bool | operator!= (bsoncxx::v1::document::view doc, hint const &h)
| Equivalent to comparing h.doc() and doc.

## Constructor & Destructor Documentation

## ~hint()

mongocxx::v1::hint::~hint | ( |  | ) |

Destroy this object.

Warning
  Invalidates all associated views.

## hint() [1/5]

mongocxx::v1::hint::hint | ( | hint && | other | ) |

noexcept

Move constructor.

Postconditions:
  - other is in an assign-or-destroy-only state.

## hint() [2/5]

mongocxx::v1::hint::hint | ( | hint const & | other | ) |

Copy construction.

## hint() [3/5]

mongocxx::v1::hint::hint | ( |  | ) |

Default initialization.

Postconditions:
  - this->str().has_value() == false
  - this->doc().has_value() == false

## hint() [4/5]

mongocxx::v1::hint::hint | ( | std::string | str | ) |

explicit

Initialize this "hint" option as a document.

## hint() [5/5]

mongocxx::v1::hint::hint | ( | bsoncxx::v1::document::value | doc | ) |

explicit

Return the current "hint" option as a document.

## Member Function Documentation

## doc()

bsoncxx::v1::stdx::optional< bsoncxx::v1::document::view > mongocxx::v1::hint::doc | ( |  | ) | const

Return the current "hint" value as a document.

Returns
  Empty when not a document.

## operator bsoncxx::v1::types::view()

mongocxx::v1::hint::operator bsoncxx::v1::types::view | ( |  | ) | const

Equivalent to to_value() const.

## operator=() [1/2]

hint & mongocxx::v1::hint::operator= | ( | hint && | other | ) |

noexcept

Move assignment.

Postconditions:
  - other is in an assign-or-destroy-only state.

## operator=() [2/2]

hint & mongocxx::v1::hint::operator= | ( | hint const & | other | ) |

Copy assignment.

## str()

bsoncxx::v1::stdx::optional< bsoncxx::v1::stdx::string_view > mongocxx::v1::hint::str | ( |  | ) | const

Return the current "hint" value as a string.

Returns
  Empty when not a string.

## to_value()

bsoncxx::v1::types::view mongocxx::v1::hint::to_value | ( |  | ) | const

Return the current "hint" value as a BSON type value.

## Friends And Related Symbol Documentation

## operator!= [1/5]

bool operator!= | ( | bsoncxx::v1::document::view | doc,
|  | hint const & | h )

friend

Equivalent to comparing h.doc() and doc.

## operator!= [2/5]

bool operator!= | ( | bsoncxx::v1::stdx::string_view | str,
|  | hint const & | h )

friend

Equivalent to comparing h.str() with str.

## operator!= [3/5]

bool operator!= | ( | hint const & | h,
|  | bsoncxx::v1::document::view | doc )

friend

Equivalent to comparing h.doc() and doc.

## operator!= [4/5]

bool operator!= | ( | hint const & | h,
|  | bsoncxx::v1::stdx::string_view | str )

friend

Equivalent to comparing h.str() with str.

## operator!= [5/5]

bool operator!= | ( | hint const & | lhs,
|  | hint const & | rhs )

friend

Compare equal when the underlying "hint" values compare equal.

## operator== [1/5]

bool operator== | ( | bsoncxx::v1::document::view | doc,
|  | hint const & | h )

friend

Equivalent to comparing h.doc() and doc.

## operator== [2/5]

bool operator== | ( | bsoncxx::v1::stdx::string_view | str,
|  | hint const & | h )

friend

Equivalent to comparing h.str() with str.

## operator== [3/5]

bool operator== | ( | hint const & | h,
|  | bsoncxx::v1::document::view | doc )

friend

Equivalent to comparing h.doc() and doc.

## operator== [4/5]

bool operator== | ( | hint const & | h,
|  | bsoncxx::v1::stdx::string_view | str )

friend

Equivalent to comparing h.str() with str.

## operator== [5/5]

bool operator== | ( | hint const & | lhs,
|  | hint const & | rhs )

friend

Compare equal when the underlying "hint" values compare equal.

The documentation for this class was generated from the following file:

- mongocxx/v1/hint.hpp