MongoDB C++ Driver 4.1.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
view.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 <cstddef>
18#include <cstdint>
19#include <iterator>
20
23
26
28
29namespace bsoncxx {
30namespace v_noabi {
31namespace array {
32
36class view {
37 public:
38 class const_iterator;
39 using iterator = const_iterator;
40
45
50
55
60
72
84
90
100 BSONCXX_ABI_EXPORT_CDECL() view(std::uint8_t const* data, std::size_t length);
101
107 BSONCXX_ABI_EXPORT_CDECL(std::uint8_t const*) data() const;
108
117 BSONCXX_ABI_EXPORT_CDECL(std::size_t) length() const;
118
126
131
138 friend BSONCXX_ABI_EXPORT_CDECL(bool) operator==(view, view);
139 friend BSONCXX_ABI_EXPORT_CDECL(bool) operator!=(view, view);
142
143 private:
144 document::view _view;
145};
146
153class view::const_iterator {
154 public:
159 using reference = element&;
160 using pointer = element*;
161 using iterator_category = std::forward_iterator_tag;
162 using difference_type = std::ptrdiff_t;
163
164 BSONCXX_ABI_EXPORT_CDECL() const_iterator();
165 BSONCXX_ABI_EXPORT_CDECL(explicit) const_iterator(element const& element);
166
167 BSONCXX_ABI_EXPORT_CDECL(reference) operator*();
168 BSONCXX_ABI_EXPORT_CDECL(pointer) operator->();
169
170 BSONCXX_ABI_EXPORT_CDECL(const_iterator&) operator++();
171 BSONCXX_ABI_EXPORT_CDECL(const_iterator) operator++(int);
172
179 friend BSONCXX_ABI_EXPORT_CDECL(bool) operator==(const_iterator const&, const_iterator const&);
180 friend BSONCXX_ABI_EXPORT_CDECL(bool) operator!=(const_iterator const&, const_iterator const&);
183
184 private:
185 element _element;
186};
187
188} // namespace array
189} // namespace v_noabi
190} // namespace bsoncxx
191
192#include <bsoncxx/config/postlude.hpp>
193
Provides bsoncxx::v_noabi::array::element.
Declares bsoncxx::v_noabi::array::view.
#define BSONCXX_ABI_EXPORT_CDECL(...)
Equivalent to BSONCXX_ABI_EXPORT with BSONCXX_ABI_CDECL.
Definition export.hpp:52
The bsoncxx v_noabi macro guard prelude header.
A const iterator over the contents of an array view.
Definition view.hpp:153
view()
Default constructs a view. The resulting view will be initialized to point at an empty BSON array.
A variant view type that accesses values in serialized BSON arrays.
Definition element.hpp:39
A const iterator over the contents of an array view.
Definition view.hpp:153
element value_type
std::iterator_traits
Definition view.hpp:158
bool empty() const
Checks if the underlying buffer is empty, i.e. it is equivalent to the trivial array '[]'.
std::size_t length() const
Gets the length of the underlying buffer.
const_iterator find(std::uint32_t i) const
Indexes into this BSON array. If the index is out-of-bounds, a past-the-end iterator will be returned...
const_iterator end() const
const_iterator begin() const
const_iterator cend() const
const_iterator cbegin() const
view()
Default constructs a view. The resulting view will be initialized to point at an empty BSON array.
std::uint8_t const * data() const
Access the raw bytes of the underlying array.
element operator[](std::uint32_t i) const
Indexes into this BSON array. If the index is out-of-bounds, the invalid array::element will be retur...
Provides bsoncxx::v_noabi::document::view.
Declares entities representing a BSON array.
Declares entities representing a BSON document.
Declares entities whose ABI stability is NOT guaranteed.
The top-level namespace within which all bsoncxx library entities are declared.
Declares bsoncxx::v_noabi::types::bson_value::view.