Loading...
Searching...
No Matches
bsoncxx::v1::types::view Class Reference

`#include <bsoncxx/v1/types/view.hpp>`

## Description

A non-owning, read-only union of BSON type values.

Note
  This class only represents the value of a BSON element without its key. bsoncxx::v1::element::view represents a BSON element including its key.

## Public Types

enum class | errc
| Errors codes which may be returned by bsoncxx::v1::types::view. More...

## Public Member Functions

| view ()
| Initialize with bsoncxx::v1::types::b_null.
id | type_id () const
| Return the type of the underlying BSON type value.
| view (b_minkey v)
| Implicitly convert v.
| view (b_double v)
| Implicitly convert v.
| view (b_string v)
| Implicitly convert v.
| view (b_document v)
| Implicitly convert v.
| view (b_array v)
| Implicitly convert v.
| view (b_binary v)
| Implicitly convert v.
| view (b_undefined v)
| Implicitly convert v.
| view (b_oid v)
| Implicitly convert v.
| view (b_bool v)
| Implicitly convert v.
| view (b_date v)
| Implicitly convert v.
| view (b_null v)
| Implicitly convert v.
| view (b_regex v)
| Implicitly convert v.
| view (b_dbpointer v)
| Implicitly convert v.
| view (b_code v)
| Implicitly convert v.
| view (b_symbol v)
| Implicitly convert v.
| view (b_codewscope v)
| Implicitly convert v.
| view (b_int32 v)
| Implicitly convert v.
| view (b_timestamp v)
| Implicitly convert v.
| view (b_int64 v)
| Implicitly convert v.
| view (b_decimal128 v)
| Implicitly convert v.
| view (b_maxkey v)
| Implicitly convert v.
b_minkey | get_minkey () const
| Return the requested underlying BSON type value.
b_double | get_double () const
| Return the requested underlying BSON type value.
b_string | get_string () const
| Return the requested underlying BSON type value.
b_document | get_document () const
| Return the requested underlying BSON type value.
b_array | get_array () const
| Return the requested underlying BSON type value.
b_binary | get_binary () const
| Return the requested underlying BSON type value.
b_undefined | get_undefined () const
| Return the requested underlying BSON type value.
b_oid | get_oid () const
| Return the requested underlying BSON type value.
b_bool | get_bool () const
| Return the requested underlying BSON type value.
b_date | get_date () const
| Return the requested underlying BSON type value.
b_null | get_null () const
| Return the requested underlying BSON type value.
b_regex | get_regex () const
| Return the requested underlying BSON type value.
b_dbpointer | get_dbpointer () const
| Return the requested underlying BSON type value.
b_code | get_code () const
| Return the requested underlying BSON type value.
b_symbol | get_symbol () const
| Return the requested underlying BSON type value.
b_codewscope | get_codewscope () const
| Return the requested underlying BSON type value.
b_int32 | get_int32 () const
| Return the requested underlying BSON type value.
b_timestamp | get_timestamp () const
| Return the requested underlying BSON type value.
b_int64 | get_int64 () const
| Return the requested underlying BSON type value.
b_decimal128 | get_decimal128 () const
| Return the requested underlying BSON type value.
b_maxkey | get_maxkey () const
| Return the requested underlying BSON type value.

## Static Public Member Functions

static std::error_category const & | error_category ()
| The error category for bsoncxx::v1::types::view::errc.

## Friends

std::error_code | make_error_code (errc v)
| Support implicit conversion to std::error_code.
bool | operator!= (view const &lhs, view const &rhs)
| Equivalent to !(lhs == rhs).
bool | operator== (view const &lhs, view const &rhs)
| Compare equal when the underlying BSON type values have the same type and compare equal.
bool | operator== (view const &v, v1::element::view const &e)
| Equivalent to v == e.type_view().
bool | operator== (v1::element::view const &e, view const &v)
| Equivalent to v == e.type_view().
bool | operator!= (view const &v, v1::element::view const &e)
| Equivalent to !(v == e).
bool | operator!= (v1::element::view const &e, view const &v)
| Equivalent to !(v == e).
template<typename T, detail::enable_if_t< is_equality_comparable_with< T >::value > * = nullptr>
bool | operator== (view const &v, T const &value)
| Equivalent to v == bsoncxx::v1::types::view{value}.
template<typename T, detail::enable_if_t< is_equality_comparable_with< T >::value > * = nullptr>
bool | operator== (T const &value, view const &v)
| Equivalent to v == bsoncxx::v1::types::view{value}.
template<typename T, detail::enable_if_t< is_equality_comparable_with< T >::value > * = nullptr>
bool | operator!= (view const &v, T const &value)
| Equivalent to !(v == value).
template<typename T, detail::enable_if_t< is_equality_comparable_with< T >::value > * = nullptr>
bool | operator!= (T const &value, view const &v)
| Equivalent to !(v == value).

## Member Enumeration Documentation

## errc

enum class bsoncxx::v1::types::view::errc

strong

Errors codes which may be returned by bsoncxx::v1::types::view.

Enumerator
zero | Zero.
type_mismatch | Requested type does not match the underlying type.

## Constructor & Destructor Documentation

## view() [1/22]

bsoncxx::v1::types::view::view | ( |  | ) |

inline

Initialize with bsoncxx::v1::types::b_null.

## view() [2/22]

bsoncxx::v1::types::view::view | ( | b_minkey | v | ) |

inline

Implicitly convert v.

## view() [3/22]

bsoncxx::v1::types::view::view | ( | b_double | v | ) |

inline

Implicitly convert v.

## view() [4/22]

bsoncxx::v1::types::view::view | ( | b_string | v | ) |

inline

Implicitly convert v.

## view() [5/22]

bsoncxx::v1::types::view::view | ( | b_document | v | ) |

inline

Implicitly convert v.

## view() [6/22]

bsoncxx::v1::types::view::view | ( | b_array | v | ) |

inline

Implicitly convert v.

## view() [7/22]

bsoncxx::v1::types::view::view | ( | b_binary | v | ) |

inline

Implicitly convert v.

## view() [8/22]

bsoncxx::v1::types::view::view | ( | b_undefined | v | ) |

inline

Implicitly convert v.

## view() [9/22]

bsoncxx::v1::types::view::view | ( | b_oid | v | ) |

inline

Implicitly convert v.

## view() [10/22]

bsoncxx::v1::types::view::view | ( | b_bool | v | ) |

inline

Implicitly convert v.

## view() [11/22]

bsoncxx::v1::types::view::view | ( | b_date | v | ) |

inline

Implicitly convert v.

## view() [12/22]

bsoncxx::v1::types::view::view | ( | b_null | v | ) |

inline

Implicitly convert v.

## view() [13/22]

bsoncxx::v1::types::view::view | ( | b_regex | v | ) |

inline

Implicitly convert v.

## view() [14/22]

bsoncxx::v1::types::view::view | ( | b_dbpointer | v | ) |

inline

Implicitly convert v.

## view() [15/22]

bsoncxx::v1::types::view::view | ( | b_code | v | ) |

inline

Implicitly convert v.

## view() [16/22]

bsoncxx::v1::types::view::view | ( | b_symbol | v | ) |

inline

Implicitly convert v.

## view() [17/22]

bsoncxx::v1::types::view::view | ( | b_codewscope | v | ) |

inline

Implicitly convert v.

## view() [18/22]

bsoncxx::v1::types::view::view | ( | b_int32 | v | ) |

inline

Implicitly convert v.

## view() [19/22]

bsoncxx::v1::types::view::view | ( | b_timestamp | v | ) |

inline

Implicitly convert v.

## view() [20/22]

bsoncxx::v1::types::view::view | ( | b_int64 | v | ) |

inline

Implicitly convert v.

## view() [21/22]

bsoncxx::v1::types::view::view | ( | b_decimal128 | v | ) |

inline

Implicitly convert v.

## view() [22/22]

bsoncxx::v1::types::view::view | ( | b_maxkey | v | ) |

inline

Implicitly convert v.

## Member Function Documentation

## error_category()

std::error_category const & bsoncxx::v1::types::view::error_category | ( |  | ) |

static

The error category for bsoncxx::v1::types::view::errc.

## get_array()

b_array bsoncxx::v1::types::view::get_array | ( |  | ) | const

Return the requested underlying BSON type value.

Exceptions

  bsoncxx::v1::exception | with bsoncxx::v1::types::view::errc::type_mismatch if the underlying BSON type value does not match the requested type.

## get_binary()

b_binary bsoncxx::v1::types::view::get_binary | ( |  | ) | const

Return the requested underlying BSON type value.

Exceptions

  bsoncxx::v1::exception | with bsoncxx::v1::types::view::errc::type_mismatch if the underlying BSON type value does not match the requested type.

## get_bool()

b_bool bsoncxx::v1::types::view::get_bool | ( |  | ) | const

Return the requested underlying BSON type value.

Exceptions

  bsoncxx::v1::exception | with bsoncxx::v1::types::view::errc::type_mismatch if the underlying BSON type value does not match the requested type.

## get_code()

b_code bsoncxx::v1::types::view::get_code | ( |  | ) | const

Return the requested underlying BSON type value.

Exceptions

  bsoncxx::v1::exception | with bsoncxx::v1::types::view::errc::type_mismatch if the underlying BSON type value does not match the requested type.

## get_codewscope()

b_codewscope bsoncxx::v1::types::view::get_codewscope | ( |  | ) | const

Return the requested underlying BSON type value.

Exceptions

  bsoncxx::v1::exception | with bsoncxx::v1::types::view::errc::type_mismatch if the underlying BSON type value does not match the requested type.

## get_date()

b_date bsoncxx::v1::types::view::get_date | ( |  | ) | const

Return the requested underlying BSON type value.

Exceptions

  bsoncxx::v1::exception | with bsoncxx::v1::types::view::errc::type_mismatch if the underlying BSON type value does not match the requested type.

## get_dbpointer()

b_dbpointer bsoncxx::v1::types::view::get_dbpointer | ( |  | ) | const

Return the requested underlying BSON type value.

Exceptions

  bsoncxx::v1::exception | with bsoncxx::v1::types::view::errc::type_mismatch if the underlying BSON type value does not match the requested type.

## get_decimal128()

b_decimal128 bsoncxx::v1::types::view::get_decimal128 | ( |  | ) | const

Return the requested underlying BSON type value.

Exceptions

  bsoncxx::v1::exception | with bsoncxx::v1::types::view::errc::type_mismatch if the underlying BSON type value does not match the requested type.

## get_document()

b_document bsoncxx::v1::types::view::get_document | ( |  | ) | const

Return the requested underlying BSON type value.

Exceptions

  bsoncxx::v1::exception | with bsoncxx::v1::types::view::errc::type_mismatch if the underlying BSON type value does not match the requested type.

## get_double()

b_double bsoncxx::v1::types::view::get_double | ( |  | ) | const

Return the requested underlying BSON type value.

Exceptions

  bsoncxx::v1::exception | with bsoncxx::v1::types::view::errc::type_mismatch if the underlying BSON type value does not match the requested type.

## get_int32()

b_int32 bsoncxx::v1::types::view::get_int32 | ( |  | ) | const

Return the requested underlying BSON type value.

Exceptions

  bsoncxx::v1::exception | with bsoncxx::v1::types::view::errc::type_mismatch if the underlying BSON type value does not match the requested type.

## get_int64()

b_int64 bsoncxx::v1::types::view::get_int64 | ( |  | ) | const

Return the requested underlying BSON type value.

Exceptions

  bsoncxx::v1::exception | with bsoncxx::v1::types::view::errc::type_mismatch if the underlying BSON type value does not match the requested type.

## get_maxkey()

b_maxkey bsoncxx::v1::types::view::get_maxkey | ( |  | ) | const

Return the requested underlying BSON type value.

Exceptions

  bsoncxx::v1::exception | with bsoncxx::v1::types::view::errc::type_mismatch if the underlying BSON type value does not match the requested type.

## get_minkey()

b_minkey bsoncxx::v1::types::view::get_minkey | ( |  | ) | const

Return the requested underlying BSON type value.

Exceptions

  bsoncxx::v1::exception | with bsoncxx::v1::types::view::errc::type_mismatch if the underlying BSON type value does not match the requested type.

## get_null()

b_null bsoncxx::v1::types::view::get_null | ( |  | ) | const

Return the requested underlying BSON type value.

Exceptions

  bsoncxx::v1::exception | with bsoncxx::v1::types::view::errc::type_mismatch if the underlying BSON type value does not match the requested type.

## get_oid()

b_oid bsoncxx::v1::types::view::get_oid | ( |  | ) | const

Return the requested underlying BSON type value.

Exceptions

  bsoncxx::v1::exception | with bsoncxx::v1::types::view::errc::type_mismatch if the underlying BSON type value does not match the requested type.

## get_regex()

b_regex bsoncxx::v1::types::view::get_regex | ( |  | ) | const

Return the requested underlying BSON type value.

Exceptions

  bsoncxx::v1::exception | with bsoncxx::v1::types::view::errc::type_mismatch if the underlying BSON type value does not match the requested type.

## get_string()

b_string bsoncxx::v1::types::view::get_string | ( |  | ) | const

Return the requested underlying BSON type value.

Exceptions

  bsoncxx::v1::exception | with bsoncxx::v1::types::view::errc::type_mismatch if the underlying BSON type value does not match the requested type.

## get_symbol()

b_symbol bsoncxx::v1::types::view::get_symbol | ( |  | ) | const

Return the requested underlying BSON type value.

Exceptions

  bsoncxx::v1::exception | with bsoncxx::v1::types::view::errc::type_mismatch if the underlying BSON type value does not match the requested type.

## get_timestamp()

b_timestamp bsoncxx::v1::types::view::get_timestamp | ( |  | ) | const

Return the requested underlying BSON type value.

Exceptions

  bsoncxx::v1::exception | with bsoncxx::v1::types::view::errc::type_mismatch if the underlying BSON type value does not match the requested type.

## get_undefined()

b_undefined bsoncxx::v1::types::view::get_undefined | ( |  | ) | const

Return the requested underlying BSON type value.

Exceptions

  bsoncxx::v1::exception | with bsoncxx::v1::types::view::errc::type_mismatch if the underlying BSON type value does not match the requested type.

## type_id()

id bsoncxx::v1::types::view::type_id | ( |  | ) | const

inline

Return the type of the underlying BSON type value.

## Friends And Related Symbol Documentation

## make_error_code

std::error_code make_error_code | ( | errc | v | ) |

friend

Support implicit conversion to std::error_code.

## operator!= [1/5]

template<typename T, detail::enable_if_t< is_equality_comparable_with< T >::value > * = nullptr>

bool operator!= | ( | T const & | value,
|  | view const & | v )

friend

Equivalent to !(v == value).

## operator!= [2/5]

bool operator!= | ( | v1::element::view const & | e,
|  | view const & | v )

friend

Equivalent to !(v == e).

## operator!= [3/5]

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

friend

Equivalent to !(lhs == rhs).

## operator!= [4/5]

template<typename T, detail::enable_if_t< is_equality_comparable_with< T >::value > * = nullptr>

bool operator!= | ( | view const & | v,
|  | T const & | value )

friend

Equivalent to !(v == value).

## operator!= [5/5]

bool operator!= | ( | view const & | v,
|  | v1::element::view const & | e )

friend

Equivalent to !(v == e).

## operator== [1/5]

template<typename T, detail::enable_if_t< is_equality_comparable_with< T >::value > * = nullptr>

bool operator== | ( | T const & | value,
|  | view const & | v )

friend

Equivalent to v == bsoncxx::v1::types::view{value}.

Constraints:
  - T is not bsoncxx::v1::types::view.
  - bsoncxx::v1::types::view is constructible with T.

## operator== [2/5]

bool operator== | ( | v1::element::view const & | e,
|  | view const & | v )

friend

Equivalent to v == e.type_view().

## operator== [3/5]

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

friend

Compare equal when the underlying BSON type values have the same type and compare equal.

Equivalent to:

lhs.type_id() == rhs.type_id() && lhs.get_type() == rhs.get_type()

where get_type is the correct name for the underlying BSON type values (e.g. get_double() when type_id() == bsoncxx::v1::types::id::k_double).

When either lhs.type_id() or rhs.type_id() return an unsupported value (not defined by bsoncxx::v1::types::id or handled by BSONCXX_V1_TYPES_XMACRO), the result is unspecified.

## operator== [4/5]

template<typename T, detail::enable_if_t< is_equality_comparable_with< T >::value > * = nullptr>

bool operator== | ( | view const & | v,
|  | T const & | value )

friend

Equivalent to v == bsoncxx::v1::types::view{value}.

Constraints:
  - T is not bsoncxx::v1::types::view.
  - bsoncxx::v1::types::view is constructible with T.

## operator== [5/5]

bool operator== | ( | view const & | v,
|  | v1::element::view const & | e )

friend

Equivalent to v == e.type_view().

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

- bsoncxx/v1/types/view.hpp