MongoDB C++ Driver 4.1.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
value.hpp
Go to the documentation of this file.
1// Copyright 2009-present 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 <iostream>
18#include <memory>
19#include <string>
20#include <vector>
21
24
28
30
31namespace bsoncxx {
32namespace v_noabi {
33namespace types {
34namespace bson_value {
35
48class value {
49 public:
77
82
87
92
97
102
107
112
117
122
126 BSONCXX_ABI_EXPORT_CDECL() value(std::chrono::milliseconds v);
127
132
137
142
152 value(std::vector<unsigned char> v, binary_sub_type const sub_type = {});
153
165 value(uint8_t const* data, size_t size, binary_sub_type const sub_type = {});
166
177 BSONCXX_ABI_EXPORT_CDECL() value(stdx::string_view collection, oid value);
178
188 value(stdx::string_view code, bsoncxx::v_noabi::document::view_or_value scope);
189
198 BSONCXX_ABI_EXPORT_CDECL() value(stdx::string_view regex, stdx::string_view options);
199
217 BSONCXX_ABI_EXPORT_CDECL() value(type const id, stdx::string_view v);
218
232
253 BSONCXX_ABI_EXPORT_CDECL() value(type const id, uint64_t a, uint64_t b);
254
256
258 BSONCXX_ABI_EXPORT_CDECL(value&) operator=(value const&);
259
261 BSONCXX_ABI_EXPORT_CDECL(value&) operator=(value&&) noexcept;
262
267
272
276 BSONCXX_ABI_EXPORT_CDECL() operator bson_value::view() const noexcept;
277
278 private:
279 friend ::bsoncxx::v_noabi::document::element;
280
281 value(std::uint8_t const* raw, std::uint32_t length, std::uint32_t offset, std::uint32_t keylen);
282
283 // Makes a copy of 'internal_value' and owns the copy.
284 // Export is required by mongocxx via make_owning_bson.
285 BSONCXX_ABI_EXPORT_CDECL() value(void* internal_value);
286
287 friend value make_owning_bson(void* internal_value);
288
289 class impl;
290 std::unique_ptr<impl> _impl;
291};
292
297
299inline bool operator==(value const& lhs, value const& rhs) {
300 return (lhs.view() == rhs.view());
301}
302
304inline bool operator!=(value const& lhs, value const& rhs) {
305 return !(lhs == rhs);
306}
307
310
315
317inline bool operator==(value const& lhs, view const& rhs) {
318 return (lhs.view() == rhs);
319}
320
322inline bool operator==(view const& lhs, value const& rhs) {
323 return (rhs == lhs);
324}
325
327inline bool operator!=(value const& lhs, view const& rhs) {
328 return !(lhs == rhs);
329}
330
332inline bool operator!=(view const& lhs, value const& rhs) {
333 return !(lhs == rhs);
334}
335
338
339} // namespace bson_value
340} // namespace types
341} // namespace v_noabi
342} // namespace bsoncxx
343
344namespace bsoncxx {
345namespace types {
346namespace bson_value {
347
348using ::bsoncxx::v_noabi::types::bson_value::operator==;
349using ::bsoncxx::v_noabi::types::bson_value::operator!=;
350
351} // namespace bson_value
352} // namespace types
353} // namespace bsoncxx
354
356
Provides bsoncxx::v_noabi::array::view_or_value.
#define BSONCXX_ABI_EXPORT_CDECL(...)
Equivalent to BSONCXX_ABI_EXPORT with BSONCXX_ABI_CDECL.
Definition export.hpp:52
The bsoncxx v_noabi macro guard postlude header.
The bsoncxx v_noabi macro guard prelude header.
value(b_double v)
Construct a bson_value::value from the provided BSON type.
Represents a MongoDB BSON Decimal128.
Definition decimal128.hpp:40
Represents a MongoDB BSON ObjectId.
Definition oid.hpp:36
bool operator!=(value const &lhs, view const &rhs)
Compares a value with a view for (in)equality.
Definition value.hpp:327
bson_value::view view() const noexcept
Get a view over the bson_value owned by this object.
bool operator!=(view const &lhs, value const &rhs)
Compares a value with a view for (in)equality.
Definition value.hpp:332
bool operator==(value const &lhs, view const &rhs)
Compares a value with a view for (in)equality.
Definition value.hpp:317
bool operator==(view const &lhs, value const &rhs)
Compares a value with a view for (in)equality.
Definition value.hpp:322
value(b_double v)
Construct a bson_value::value from the provided BSON type.
bool operator!=(value const &lhs, value const &rhs)
Compares values for (in)-equality.
Definition value.hpp:304
Declares bsoncxx::v_noabi::document::element.
Provides bsoncxx::v_noabi::document::view_or_value.
Declares entities representing a BSON array.
Declares entities representing a BSON document.
Declares C++17 standard library polyfills.
Declares entities representing any BSON value type.
bsoncxx::v_noabi::view_or_value< view, value > view_or_value
Equivalent to v_noabi::view_or_value<view, value>.
Definition view_or_value.hpp:31
Declares entities representing BSON value types.
Declarations related to the BSON Binary Vector subtype.
Declares entities whose ABI stability is NOT guaranteed.
binary_sub_type
An enumeration of each BSON binary sub type.
Definition types.hpp:72
type
An enumeration of each BSON type.
Definition types.hpp:43
The top-level namespace within which all bsoncxx library entities are declared.
A BSON array value.
Definition types.hpp:202
A BSON binary data value.
Definition types.hpp:227
A BSON boolean value.
Definition types.hpp:284
A BSON JavaScript code value.
Definition types.hpp:434
A BSON JavaScript code with scope value.
Definition types.hpp:504
A BSON date value.
Definition types.hpp:309
A BSON DBPointer (aka DBRef) value.
Definition types.hpp:415
A BSON Decimal128 value.
Definition types.hpp:604
A BSON document value.
Definition types.hpp:170
A BSON double value.
Definition types.hpp:111
A BSON signed 32-bit integer value.
Definition types.hpp:535
A BSON 64-bit signed integer value.
Definition types.hpp:579
A BSON max-key value.
Definition types.hpp:647
A BSON min-key value.
Definition types.hpp:631
A BSON null value.
Definition types.hpp:366
A BSON ObjectId value.
Definition types.hpp:266
A BSON regex value.
Definition types.hpp:382
A BSON UTF-8 encoded string value.
Definition types.hpp:136
A BSON Symbol value.
Definition types.hpp:470
A BSON replication timestamp value.
Definition types.hpp:560
A BSON undefined value.
Definition types.hpp:250
Declares bsoncxx::v_noabi::types::bson_value::value.
Provides bsoncxx::v_noabi::types::bson_value::view.