MongoDB C++ Driver  mongocxx-3.7.0
element.hpp
1 // Copyright 2014 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 <cstddef>
18 #include <cstdint>
19 
20 #include <bsoncxx/document/element.hpp>
21 
22 #include <bsoncxx/config/prelude.hpp>
23 
24 namespace bsoncxx {
25 BSONCXX_INLINE_NAMESPACE_BEGIN
26 
27 namespace types {
28 namespace bson_value {
29 class view;
30 } // namespace bson_value
31 } // namespace types
32 
33 namespace array {
34 
42 class BSONCXX_API element : private document::element {
43  public:
44  element();
45 
46  using document::element::operator bool;
47 
49 
72 
74 
75  using document::element::operator[];
76 
82 
83  private:
84  friend class view;
85 
86  BSONCXX_PRIVATE explicit element(const std::uint8_t* raw,
87  std::uint32_t length,
88  std::uint32_t offset,
89  std::uint32_t keylen);
90 };
91 
101 BSONCXX_API bool BSONCXX_CALL operator==(const element& elem, const types::bson_value::view& v);
102 BSONCXX_API bool BSONCXX_CALL operator==(const types::bson_value::view& v, const element& elem);
106 
116 BSONCXX_API bool BSONCXX_CALL operator!=(const element& elem, const types::bson_value::view& v);
117 BSONCXX_API bool BSONCXX_CALL operator!=(const types::bson_value::view& v, const element& elem);
121 
122 } // namespace array
123 
124 BSONCXX_INLINE_NAMESPACE_END
125 } // namespace bsoncxx
126 
127 #include <bsoncxx/config/postlude.hpp>
bsoncxx::document::element::get_null
types::b_null get_null() const
Getter for elements of the b_null type.
bsoncxx::document::element::get_bool
types::b_bool get_bool() const
Getter for elements of the b_bool type.
bsoncxx::document::element::get_dbpointer
types::b_dbpointer get_dbpointer() const
Getter for elements of the b_dbpointer type.
bsoncxx::document::element::get_regex
types::b_regex get_regex() const
Getter for elements of the b_regex type.
bsoncxx
Top level namespace for MongoDB C++ BSON functionality.
Definition: element.hpp:24
bsoncxx::document::element::key
stdx::string_view key() const
Getter for the element's key.
bsoncxx::document::element::get_minkey
types::b_minkey get_minkey() const
Getter for elements of the b_minkey type.
bsoncxx::document::element::get_timestamp
types::b_timestamp get_timestamp() const
Getter for elements of the b_timestamp type.
bsoncxx::array::view
A read-only, non-owning view of a BSON document.
Definition: view.hpp:40
bsoncxx::document::element::get_utf8
BSONCXX_DEPRECATED types::b_string get_utf8() const
Getter for elements of the b_string type.
bsoncxx::document::element::length
std::uint32_t length() const
Getter for length of the raw bson bytes the element points to.
bsoncxx::document::element::get_string
types::b_string get_string() const
Getter for elements of the b_string type.
bsoncxx::document::element::get_double
types::b_double get_double() const
Getter for elements of the b_double type.
bsoncxx::document::element::type
bsoncxx::type type() const
Getter for the type of the element.
bsoncxx::document::element::get_int32
types::b_int32 get_int32() const
Getter for elements of the b_int32 type.
bsoncxx::document::element::raw
const std::uint8_t * raw() const
Getter for the raw bson bytes the element points to.
bsoncxx::document::element::get_codewscope
types::b_codewscope get_codewscope() const
Getter for elements of the b_codewscope type.
bsoncxx::document::element::get_symbol
types::b_symbol get_symbol() const
Getter for elements of the b_symbol type.
bsoncxx::document::element::get_maxkey
types::b_maxkey get_maxkey() const
Getter for elements of the b_maxkey type.
bsoncxx::document::element::get_int64
types::b_int64 get_int64() const
Getter for elements of the b_int64 type.
bsoncxx::document::element
A variant view type that accesses values in serialized BSON documents.
Definition: element.hpp:76
bsoncxx::document::element::keylen
std::uint32_t keylen() const
Getter for the element's key length.
bsoncxx::document::element::get_date
types::b_date get_date() const
Getter for elements of the b_date type.
bsoncxx::document::element::get_array
types::b_array get_array() const
Getter for elements of the b_array type.
bsoncxx::document::element::get_document
types::b_document get_document() const
Getter for elements of the b_document type.
bsoncxx::document::element::get_code
types::b_code get_code() const
Getter for elements of the b_code type.
bsoncxx::document::element::get_decimal128
types::b_decimal128 get_decimal128() const
Getter for elements of the b_decimal128 type.
bsoncxx::document::element::get_binary
types::b_binary get_binary() const
Getter for elements of the b_binary type.
bsoncxx::document::element::get_value
types::bson_value::view get_value() const
Getter for a types::bson_value::view variant wrapper of the value portion of the element.
bsoncxx::document::element::get_oid
types::b_oid get_oid() const
Getter for elements of the b_oid type.
bsoncxx::array::element
A variant view type that accesses values in serialized BSON arrays.
Definition: element.hpp:42
bsoncxx::document::element::get_undefined
types::b_undefined get_undefined() const
Getter for elements of the b_undefined type.
bsoncxx::types::bson_value::view
A view-only variant that can contain any BSON type.
Definition: view.hpp:44
bsoncxx::document::element::offset
std::uint32_t offset() const
Getter for the offset into the raw bson bytes the element points to.