MongoDB C++ Driver 4.3.0
Loading...
Searching...
No Matches
bsoncxx::types::bson_value::value Class Reference

#include <bsoncxx/v_noabi/bsoncxx/types/bson_value/value.hpp>

Description

An owning variant type that represents any BSON type.

Owns its underlying buffer. When a bson_value::value goes out of scope, its underlying buffer is freed.

For accessors into this type and to extract the various BSON types out, please use bson_value::view.

Deprecated
Use bsoncxx::v_noabi::types::value instead (renamed).
See also

Public Member Functions

 value ()=default
 Initialize with bsoncxx::v1::types::b_null.
 value (bool v)
 Constructs a BSON boolean value.
 value (char const *v)
 Constructs a BSON UTF-8 string value.
 value (double v)
 Constructs a BSON double value.
 value (std::chrono::milliseconds v)
 Constructs a BSON date value.
 value (std::int32_t v)
 Constructs a BSON 32-bit signed integer value.
 value (std::int64_t v)
 Constructs a BSON 64-bit signed integer value.
 value (std::nullptr_t)
 Constructs a BSON null value.
 value (std::string v)
 Constructs a BSON UTF-8 string value.
 value (std::uint8_t const *data, std::size_t size, v_noabi::binary_sub_type const sub_type={})
 Constructs a BSON binary data value.
 value (std::vector< unsigned char > v, v_noabi::binary_sub_type const sub_type={})
 Constructs a BSON binary data value.
template<typename T, detail::enable_if_t< has_from_v1< T >::value > * = nullptr>
 value (T v)
 Construct with the bsoncxx::v1 equivalent.
 value (v1::stdx::string_view code, v_noabi::document::view_or_value scope)
 Constructs a BSON JavaScript code with scope value.
 value (v1::stdx::string_view collection, v_noabi::oid value)
 Constructs a BSON DBPointer value.
 value (v1::stdx::string_view regex, v1::stdx::string_view options)
 Constructs a BSON regex value with options.
 value (v1::stdx::string_view v)
 Constructs a BSON UTF-8 string value.
 value (v1::types::value v)
 Construct with the bsoncxx::v1 equivalent.
 value (v_noabi::array::view v)
 Constructs a BSON array value.
 value (v_noabi::decimal128 v)
 Constructs a BSON Decimal128 value.
 value (v_noabi::document::view v)
 Constructs a BSON document value.
 value (v_noabi::oid v)
 Constructs a BSON ObjectId value.
 value (v_noabi::type const id)
 Constructs one of the following BSON values (each specified by the parenthesized type):
 value (v_noabi::type const id, std::uint64_t a, std::uint64_t b)
 Constructs one of the following BSON values (each specified by the parenthesized type):
 value (v_noabi::type const id, v1::stdx::string_view v)
 Constructs one of the following BSON values (each specified by the parenthesized type):
 value (v_noabi::types::bson_value::view const &v)
 Create an owning copy of a bson_value::view.
 operator v1::types::value () &&
 Convert to the bsoncxx::v1 equivalent.
 operator v1::types::value () const &
 Convert to the bsoncxx::v1 equivalent.
 operator v_noabi::types::bson_value::view () const noexcept
 Conversion operator that provides a bson_value::view given a bson_value::value.
v_noabi::type type () const
 Returns the type of the underlying BSON value stored in this object.
v_noabi::type type_id () const
 Equivalent to type() const.
v_noabi::types::bson_value::view view () const noexcept
 Get a view over the bson_value owned by this object.
 value (v_noabi::types::b_minkey v)
 Construct a bson_value::value from the provided BSON type.
 value (v_noabi::types::b_double v)
 Construct a bson_value::value from the provided BSON type.
 value (v_noabi::types::b_string v)
 Construct a bson_value::value from the provided BSON type.
 value (v_noabi::types::b_document v)
 Construct a bson_value::value from the provided BSON type.
 value (v_noabi::types::b_array v)
 Construct a bson_value::value from the provided BSON type.
 value (v_noabi::types::b_binary v)
 Construct a bson_value::value from the provided BSON type.
 value (v_noabi::types::b_undefined v)
 Construct a bson_value::value from the provided BSON type.
 value (v_noabi::types::b_oid v)
 Construct a bson_value::value from the provided BSON type.
 value (v_noabi::types::b_bool v)
 Construct a bson_value::value from the provided BSON type.
 value (v_noabi::types::b_date v)
 Construct a bson_value::value from the provided BSON type.
 value (v_noabi::types::b_null v)
 Construct a bson_value::value from the provided BSON type.
 value (v_noabi::types::b_regex v)
 Construct a bson_value::value from the provided BSON type.
 value (v_noabi::types::b_dbpointer v)
 Construct a bson_value::value from the provided BSON type.
 value (v_noabi::types::b_code v)
 Construct a bson_value::value from the provided BSON type.
 value (v_noabi::types::b_symbol v)
 Construct a bson_value::value from the provided BSON type.
 value (v_noabi::types::b_codewscope v)
 Construct a bson_value::value from the provided BSON type.
 value (v_noabi::types::b_int32 v)
 Construct a bson_value::value from the provided BSON type.
 value (v_noabi::types::b_timestamp v)
 Construct a bson_value::value from the provided BSON type.
 value (v_noabi::types::b_int64 v)
 Construct a bson_value::value from the provided BSON type.
 value (v_noabi::types::b_decimal128 v)
 Construct a bson_value::value from the provided BSON type.
 value (v_noabi::types::b_maxkey v)
 Construct a bson_value::value from the provided BSON type.
v_noabi::types::b_minkey const & get_minkey () const
 Return the underlying BSON type value.
v_noabi::types::b_double const & get_double () const
 Return the underlying BSON type value.
v_noabi::types::b_string const & get_string () const
 Return the underlying BSON type value.
v_noabi::types::b_document const & get_document () const
 Return the underlying BSON type value.
v_noabi::types::b_array const & get_array () const
 Return the underlying BSON type value.
v_noabi::types::b_binary const & get_binary () const
 Return the underlying BSON type value.
v_noabi::types::b_undefined const & get_undefined () const
 Return the underlying BSON type value.
v_noabi::types::b_oid const & get_oid () const
 Return the underlying BSON type value.
v_noabi::types::b_bool const & get_bool () const
 Return the underlying BSON type value.
v_noabi::types::b_date const & get_date () const
 Return the underlying BSON type value.
v_noabi::types::b_null const & get_null () const
 Return the underlying BSON type value.
v_noabi::types::b_regex const & get_regex () const
 Return the underlying BSON type value.
v_noabi::types::b_dbpointer const & get_dbpointer () const
 Return the underlying BSON type value.
v_noabi::types::b_code const & get_code () const
 Return the underlying BSON type value.
v_noabi::types::b_symbol const & get_symbol () const
 Return the underlying BSON type value.
v_noabi::types::b_codewscope const & get_codewscope () const
 Return the underlying BSON type value.
v_noabi::types::b_int32 const & get_int32 () const
 Return the underlying BSON type value.
v_noabi::types::b_timestamp const & get_timestamp () const
 Return the underlying BSON type value.
v_noabi::types::b_int64 const & get_int64 () const
 Return the underlying BSON type value.
v_noabi::types::b_decimal128 const & get_decimal128 () const
 Return the underlying BSON type value.
v_noabi::types::b_maxkey const & get_maxkey () const
 Return the underlying BSON type value.

(Note that these are not member symbols.)

bool operator== (value const &lhs, value const &rhs)
 Compares values for (in)-equality.
bool operator!= (value const &lhs, value const &rhs)
 Compares values for (in)-equality.
bool operator== (value const &lhs, view const &rhs)
 Compares a value with a view for (in)equality.
bool operator== (view const &lhs, value const &rhs)
 Compares a value with a view for (in)equality.
bool operator!= (value const &lhs, view const &rhs)
 Compares a value with a view for (in)equality.
bool operator!= (view const &lhs, value const &rhs)
 Compares a value with a view for (in)equality.

Constructor & Destructor Documentation

◆ value() [1/46]

◆ value() [2/46]

◆ value() [3/46]

template<typename T, detail::enable_if_t< has_from_v1< T >::value > * = nullptr>
bsoncxx::v_noabi::types::bson_value::value::value ( T v)
inline

Construct with the bsoncxx::v1 equivalent.

Constraints:
  • from_v1(v) is found via ADL.

◆ value() [4/46]

◆ value() [5/46]

◆ value() [6/46]

◆ value() [7/46]

◆ value() [8/46]

◆ value() [9/46]

◆ value() [10/46]

◆ value() [11/46]

◆ value() [12/46]

◆ value() [13/46]

◆ value() [14/46]

◆ value() [15/46]

◆ value() [16/46]

◆ value() [17/46]

◆ value() [18/46]

◆ value() [19/46]

◆ value() [20/46]

◆ value() [21/46]

◆ value() [22/46]

◆ value() [23/46]

◆ value() [24/46]

◆ value() [25/46]

Constructs a BSON UTF-8 string value.

◆ value() [26/46]

Constructs a BSON UTF-8 string value.

◆ value() [27/46]

Constructs a BSON UTF-8 string value.

◆ value() [28/46]

Constructs a BSON 32-bit signed integer value.

◆ value() [29/46]

Constructs a BSON 64-bit signed integer value.

◆ value() [30/46]

Constructs a BSON double value.

◆ value() [31/46]

Constructs a BSON boolean value.

◆ value() [32/46]

Constructs a BSON ObjectId value.

◆ value() [33/46]

Constructs a BSON Decimal128 value.

◆ value() [34/46]

bsoncxx::v_noabi::types::bson_value::value::value ( std::chrono::milliseconds v)
inline

Constructs a BSON date value.

◆ value() [35/46]

Constructs a BSON null value.

◆ value() [36/46]

Constructs a BSON document value.

◆ value() [37/46]

Constructs a BSON array value.

◆ value() [38/46]

bsoncxx::v_noabi::types::bson_value::value::value ( std::vector< unsigned char > v,
v_noabi::binary_sub_type const sub_type = {} )
inline

Constructs a BSON binary data value.

Parameters
va stream of bytes
sub_typean optional binary sub type. Defaults to type::k_binary

◆ value() [39/46]

bsoncxx::v_noabi::types::bson_value::value::value ( std::uint8_t const * data,
std::size_t size,
v_noabi::binary_sub_type const sub_type = {} )
inline

Constructs a BSON binary data value.

Parameters
datapointer to a stream of bytes
sizethe size of the stream of bytes
sub_typean optional binary sub type. Defaults to type::k_binary

◆ value() [40/46]

Constructs a BSON DBPointer value.

Parameters
collectionthe collection name
valuethe object id
Warning
The DBPointer (aka DBRef) BSON type is deprecated. Usage is discouraged.

◆ value() [41/46]

Constructs a BSON JavaScript code with scope value.

Parameters
codethe JavaScript code
scopea bson document view holding the scope environment

◆ value() [42/46]

Constructs a BSON regex value with options.

Parameters
regexThe regex pattern
optionsThe regex options

◆ value() [43/46]

Constructs one of the following BSON values (each specified by the parenthesized type):

Parameters
idthe type of BSON value to construct.
vthe symbol, JavaScript code, or regex pattern for the BSON symbol, code, or regex value respectively.
Exceptions
bsoncxx::v_noabi::exceptionif the type's value is not k_code, k_regex, or k_symbol.
Warning
The Symbol BSON type is deprecated. Usage is discouraged.
The Undefined BSON type is deprecated. Usage is discouraged.

◆ value() [44/46]

Constructs one of the following BSON values (each specified by the parenthesized type):

Parameters
idthe type of BSON value to construct.
Exceptions
bsoncxx::v_noabi::exceptionif the type's value is not k_maxkey, k_minkey, or k_undefined.

◆ value() [45/46]

bsoncxx::v_noabi::types::bson_value::value::value ( v_noabi::type const id,
std::uint64_t a,
std::uint64_t b )

Constructs one of the following BSON values (each specified by the parenthesized type):

Parameters
idthe type of the BSON value to construct.
aIf a BSON decimal128 value is to be constructed, this is the high value. If a BSON timestamp value is to be constructed, this is the increment.
bIf a BSON decimal128 value is to be constructed, this is the low value. If a BSON timestamp value is to be constructed, this is the timestamp.
Exceptions
bsoncxx::v_noabi::exceptionif the specified type is missing its required arguments.
Warning
The BSON timestamp type is used internally by the MongoDB server - use by clients is discouraged.

◆ value() [46/46]

Member Function Documentation

◆ get_array()

Return the underlying BSON type value.

Warning
Calling the wrong get_<type> method will cause an exception to be thrown.

◆ get_binary()

Return the underlying BSON type value.

Warning
Calling the wrong get_<type> method will cause an exception to be thrown.

◆ get_bool()

Return the underlying BSON type value.

Warning
Calling the wrong get_<type> method will cause an exception to be thrown.

◆ get_code()

Return the underlying BSON type value.

Warning
Calling the wrong get_<type> method will cause an exception to be thrown.

◆ get_codewscope()

Return the underlying BSON type value.

Warning
Calling the wrong get_<type> method will cause an exception to be thrown.

◆ get_date()

Return the underlying BSON type value.

Warning
Calling the wrong get_<type> method will cause an exception to be thrown.

◆ get_dbpointer()

Return the underlying BSON type value.

Warning
Calling the wrong get_<type> method will cause an exception to be thrown.

◆ get_decimal128()

Return the underlying BSON type value.

Warning
Calling the wrong get_<type> method will cause an exception to be thrown.

◆ get_document()

Return the underlying BSON type value.

Warning
Calling the wrong get_<type> method will cause an exception to be thrown.

◆ get_double()

Return the underlying BSON type value.

Warning
Calling the wrong get_<type> method will cause an exception to be thrown.

◆ get_int32()

Return the underlying BSON type value.

Warning
Calling the wrong get_<type> method will cause an exception to be thrown.

◆ get_int64()

Return the underlying BSON type value.

Warning
Calling the wrong get_<type> method will cause an exception to be thrown.

◆ get_maxkey()

Return the underlying BSON type value.

Warning
Calling the wrong get_<type> method will cause an exception to be thrown.

◆ get_minkey()

Return the underlying BSON type value.

Warning
Calling the wrong get_<type> method will cause an exception to be thrown.

◆ get_null()

Return the underlying BSON type value.

Warning
Calling the wrong get_<type> method will cause an exception to be thrown.

◆ get_oid()

Return the underlying BSON type value.

Warning
Calling the wrong get_<type> method will cause an exception to be thrown.

◆ get_regex()

Return the underlying BSON type value.

Warning
Calling the wrong get_<type> method will cause an exception to be thrown.

◆ get_string()

Return the underlying BSON type value.

Warning
Calling the wrong get_<type> method will cause an exception to be thrown.

◆ get_symbol()

Return the underlying BSON type value.

Warning
Calling the wrong get_<type> method will cause an exception to be thrown.

◆ get_timestamp()

Return the underlying BSON type value.

Warning
Calling the wrong get_<type> method will cause an exception to be thrown.

◆ get_undefined()

Return the underlying BSON type value.

Warning
Calling the wrong get_<type> method will cause an exception to be thrown.

◆ operator v1::types::value() [1/2]

bsoncxx::v_noabi::types::bson_value::value::operator v1::types::value ( ) &&
inlineexplicit

Convert to the bsoncxx::v1 equivalent.

◆ operator v1::types::value() [2/2]

bsoncxx::v_noabi::types::bson_value::value::operator v1::types::value ( ) const &
inlineexplicit

Convert to the bsoncxx::v1 equivalent.

◆ operator v_noabi::types::bson_value::view()

bsoncxx::v_noabi::types::bson_value::value::operator v_noabi::types::bson_value::view ( ) const
inlinenoexcept

Conversion operator that provides a bson_value::view given a bson_value::value.

◆ type()

Returns the type of the underlying BSON value stored in this object.

Deprecated
Use type_id() const instead (renamed).

◆ type_id()

Equivalent to type() const.

To support incremental migration to bsoncxx::v1::types::value.

◆ view()

Get a view over the bson_value owned by this object.

◆ operator!=() [1/3]

bool operator!= ( value const & lhs,
value const & rhs )
related

Compares values for (in)-equality.

◆ operator!=() [2/3]

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

Compares a value with a view for (in)equality.

◆ operator!=() [3/3]

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

Compares a value with a view for (in)equality.

◆ operator==() [1/3]

bool operator== ( value const & lhs,
value const & rhs )
related

Compares values for (in)-equality.

◆ operator==() [2/3]

bool operator== ( value const & lhs,
view const & rhs )
related

Compares a value with a view for (in)equality.

◆ operator==() [3/3]

bool operator== ( view const & lhs,
value const & rhs )
related

Compares a value with a view for (in)equality.


The documentation for this class was generated from the following file:
  • bsoncxx/v_noabi/bsoncxx/types/bson_value/value.hpp