MongoDB C++ Driver mongocxx-3.11.0
Loading...
Searching...
No Matches
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
29
31
32namespace bsoncxx {
33namespace v_noabi {
34namespace types {
35namespace bson_value {
36
48class value {
49 public:
77
82
87
91 BSONCXX_ABI_EXPORT_CDECL() value(stdx::string_view v);
92
97
102
107
112
117
122
126 BSONCXX_ABI_EXPORT_CDECL() value(std::chrono::milliseconds v);
127
132
136 BSONCXX_ABI_EXPORT_CDECL() value(bsoncxx::v_noabi::document::view v);
137
142
152 value(std::vector<unsigned char> v, const binary_sub_type sub_type = {});
153
165 value(const uint8_t* data, size_t size, const binary_sub_type 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(const type id, stdx::string_view v);
218
232
253 BSONCXX_ABI_EXPORT_CDECL() value(const type id, uint64_t a, uint64_t b);
254
256
258 BSONCXX_ABI_EXPORT_CDECL(value&) operator=(const value&);
259
261 BSONCXX_ABI_EXPORT_CDECL(value&) operator=(value&&) noexcept;
262
267
271 BSONCXX_ABI_EXPORT_CDECL(bson_value::view) view() const noexcept;
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(const std::uint8_t* raw,
282 std::uint32_t length,
283 std::uint32_t offset,
284 std::uint32_t keylen);
285
286 // Makes a copy of 'internal_value' and owns the copy.
287 // Export is required by mongocxx via make_owning_bson.
288 BSONCXX_ABI_EXPORT_CDECL() value(void* internal_value);
289
290 friend value make_owning_bson(void* internal_value);
291
292 class impl;
293 std::unique_ptr<impl> _impl;
294};
295
300
302inline bool operator==(const value& lhs, const value& rhs) {
303 return (lhs.view() == rhs.view());
304}
305
307inline bool operator!=(const value& lhs, const value& rhs) {
308 return !(lhs == rhs);
309}
310
313
318
320inline bool operator==(const value& lhs, const view& rhs) {
321 return (lhs.view() == rhs);
322}
323
325inline bool operator==(const view& lhs, const value& rhs) {
326 return (rhs == lhs);
327}
328
330inline bool operator!=(const value& lhs, const view& rhs) {
331 return !(lhs == rhs);
332}
333
335inline bool operator!=(const view& lhs, const value& rhs) {
336 return !(lhs == rhs);
337}
338
341
342} // namespace bson_value
343} // namespace types
344} // namespace v_noabi
345} // namespace bsoncxx
346
347namespace bsoncxx {
348namespace types {
349namespace bson_value {
350
351using ::bsoncxx::v_noabi::types::bson_value::operator==;
352using ::bsoncxx::v_noabi::types::bson_value::operator!=;
353
354} // namespace bson_value
355} // namespace types
356} // namespace bsoncxx
357
359
364
365#if defined(BSONCXX_PRIVATE_DOXYGEN_PREPROCESSOR)
366
367namespace bsoncxx {
368namespace types {
369namespace bson_value {
370
374
378
382
386
390
394
395} // namespace bson_value
396} // namespace types
397} // namespace bsoncxx
398
399#endif // defined(BSONCXX_PRIVATE_DOXYGEN_PREPROCESSOR)
Provides bsoncxx::v_noabi::array::view_or_value.
The bsoncxx macro guard postlude header.
The bsoncxx macro guard prelude header.
Represents an IEEE 754-2008 BSON Decimal128 value in a platform-independent way.
Definition decimal128.hpp:32
Represents a MongoDB ObjectId. As this BSON type is used within the MongoDB server as a primary key f...
Definition oid.hpp:41
A variant owning type that represents any BSON type. Owns its underlying buffer. When a bson_value::v...
Definition value.hpp:48
bool operator==(const view &lhs, const value &rhs)
Compares a value with a view for (in)equality.
Definition value.hpp:325
bool operator!=(const view &lhs, const value &rhs)
Compares a value with a view for (in)equality.
Definition value.hpp:335
bool operator!=(const value &lhs, const value &rhs)
Compares values for (in)-equality.
Definition value.hpp:307
bson_value::view view() const noexcept
Get a view over the bson_value owned by this object.
bool operator==(const value &lhs, const view &rhs)
Compares a value with a view for (in)equality.
Definition value.hpp:320
bool operator!=(const value &lhs, const view &rhs)
Compares a value with a view for (in)equality.
Definition value.hpp:330
A view-only variant that can contain any BSON type.
Definition view.hpp:41
Declares bsoncxx::v_noabi::document::element.
Provides bsoncxx::v_noabi::document::view_or_value.
#define BSONCXX_ABI_EXPORT_CDECL(...)
Equivalent to BSONCXX_ABI_EXPORT with BSONCXX_ABI_CDECL.
Definition fwd.hpp:225
Provides std::make_unique-related polyfills for internal use.
bool operator==(const v_noabi::types::bson_value::value &lhs, const v_noabi::types::bson_value::value &rhs)
bsoncxx::v_noabi::types::bson_value::operator==(const v_noabi::types::bson_value::value& lhs,...
bool operator!=(const v_noabi::types::bson_value::value &lhs, const v_noabi::types::bson_value::value &rhs)
bsoncxx::v_noabi::types::bson_value::operator!=(const v_noabi::types::bson_value::value& lhs,...
binary_sub_type
An enumeration of each BSON binary sub type.
Definition types.hpp:73
type
An enumeration of each BSON type.
Definition types.hpp:43
The top-level namespace within which all bsoncxx library entities are declared.
The top-level namespace reserved for the C++ standard library.
A BSON array value.
Definition types.hpp:209
A BSON binary data value.
Definition types.hpp:234
A BSON boolean value.
Definition types.hpp:291
A BSON JavaScript code value.
Definition types.hpp:444
A BSON JavaScript code with scope value.
Definition types.hpp:514
A BSON date value.
Definition types.hpp:316
A BSON DBPointer (aka DBRef) value.
Definition types.hpp:425
A BSON Decimal128 value.
Definition types.hpp:617
A BSON document value.
Definition types.hpp:177
A BSON double value.
Definition types.hpp:111
A BSON signed 32-bit integer value.
Definition types.hpp:548
A BSON 64-bit signed integer value.
Definition types.hpp:592
A BSON max-key value.
Definition types.hpp:660
A BSON min-key value.
Definition types.hpp:644
A BSON null value.
Definition types.hpp:373
A BSON ObjectId value.
Definition types.hpp:273
A BSON regex value.
Definition types.hpp:389
A BSON UTF-8 encoded string value.
Definition types.hpp:136
A BSON Symbol value.
Definition types.hpp:480
A BSON replication timestamp value.
Definition types.hpp:573
A BSON undefined value.
Definition types.hpp:257
Declares bsoncxx::v_noabi::types::bson_value::value.
Provides bsoncxx::v_noabi::types::bson_value::view.