|
jbson
C++11/1y BSON library
|
View on GitHub
BSON document. More...
#include <document.hpp>
Inheritance diagram for jbson::basic_document< Container, ElementContainer >:Public Types | |
| using | const_iterator = typename detail::document_iter< const element_type, typename container_type::const_iterator > |
| Forward iterator for traversal of elements. More... | |
| using | container_type = std::decay_t< Container > |
| Type of underlying storage container/range. | |
| using | element_type = basic_element< ElementContainer > |
| Type of constituent elements. | |
| using | iterator = const_iterator |
| Forward iterator for traversal of elements. More... | |
| using | value_type = element_type |
| Type of constituent elements. Enables usage in STL/Boost algorithms. | |
Public Member Functions | |
| basic_document () | |
| Default constructor. More... | |
| template<typename SomeType > | |
| basic_document (SomeType &&c, std::enable_if_t< std::is_same< container_type, std::decay_t< SomeType >>::value > *=nullptr) | |
| Constructs a document with an existing container of data. More... | |
| template<typename OtherContainer > | |
| basic_document (const basic_document< OtherContainer > &other, std::enable_if_t< std::is_constructible< container_type, OtherContainer >::value > *=nullptr) noexcept(std::is_nothrow_constructible< container_type, OtherContainer >::value) | |
Copy constructor from a basic_document with a different container_type. More... | |
| template<typename OtherContainer > | |
| basic_document (const basic_document< OtherContainer > &other, std::enable_if_t<!std::is_constructible< container_type, OtherContainer >::value &&detail::container_has_push_back< container_type >::value &&std::is_constructible< container_type, typename OtherContainer::const_iterator, typename OtherContainer::const_iterator >::value > *=nullptr) | |
Copy constructor from a basic_document with a different container_type. More... | |
| template<size_t N> | |
| basic_document (std::array< char, N >, std::enable_if_t<(N< 5)> *=nullptr)=delete | |
| Disallows construction from arrays of invalid document size. | |
| template<typename ForwardRange > | |
| basic_document (ForwardRange &&rng, std::enable_if_t< detail::is_range_of_same_value< ForwardRange, char >::value > *=nullptr, std::enable_if_t< std::conditional_t< detail::is_iterator_range< container_type >::value, detail::is_range_of_iterator< ForwardRange, boost::mpl::bind< detail::quote< std::is_constructible >, typename container_type::iterator, boost::mpl::_1 >>, std::true_type >::value > *=nullptr, std::enable_if_t<!std::is_same< container_type, std::decay_t< ForwardRange >>::value &&detail::is_range_of_iterator< ForwardRange, boost::mpl::bind< detail::quote< std::is_constructible >, container_type, boost::mpl::_1, boost::mpl::_1 >>::value > *=nullptr) | |
Constructs a document from a range of char. More... | |
| template<typename ForwardRange > | |
| basic_document (ForwardRange &&rng, std::enable_if_t< boost::mpl::and_< detail::is_range_of_value< ForwardRange, boost::mpl::quote1< detail::is_element >>, detail::container_has_push_back< container_type >, boost::mpl::not_< detail::is_document< std::decay_t< ForwardRange >>>>::type::value > *=nullptr) | |
Constructs a document from a range of basic_element. More... | |
| template<typename ForwardIterator > | |
| basic_document (ForwardIterator first, ForwardIterator last, std::enable_if_t< std::is_constructible< basic_document, boost::iterator_range< ForwardIterator >>::value > *=nullptr) | |
| Constructs a document from two iterators. Forwards to the range-based constructors. | |
| const_iterator | begin () const |
| Returns an iterator to the first element of the container. More... | |
| const container_type & | data () const &noexcept |
| container_type | data () const &&noexcept(std::is_nothrow_copy_constructible< container_type >::value) |
| container_type && | data ()&&noexcept(std::is_nothrow_move_constructible< container_type >::value) |
| template<typename... Args> | |
| const_iterator | emplace (const const_iterator &it, Args &&...args) |
| Inserts an element in-place directly before another. More... | |
| const_iterator | end () const noexcept |
| const_iterator | erase (const const_iterator &it) |
| Removes the element at it. More... | |
| const_iterator | find (boost::string_ref elem_name) const |
| Find an element with the specified name. More... | |
| template<typename EContainer > | |
| const_iterator | insert (const const_iterator &it, const basic_element< EContainer > &el) |
| Inserts an element directly before another. More... | |
| template<typename EContainer > | |
| operator basic_document_set< EContainer > () const | |
| basic_document_set conversion. Allows explicit conversion to document_set and other instantiations. | |
| template<typename C , typename EC > | |
| bool | operator== (const basic_document< C, EC > &other) const |
| Determines equality with another basic_document. | |
| int32_t | size () const noexcept |
| Returns data's size in bytes. More... | |
| void | swap (basic_document &other) noexcept |
| Swaps contents with another basic_document. | |
| bool | valid (const validity_level lvl=validity_level::bson_size, const bool recurse=true) const |
| Validates document/array according to a validity_level. More... | |
Friends | |
| template<typename , typename > | |
| class | basic_document |
| template<typename , typename > | |
| class | basic_array |
BSON document.
basic_document represents a range of BSON elements
| Container | Type of underlying storage container/range. Must be range of char. |
| ElementContainer | Type of underlying storage of constituent elements. |
Definition at line 191 of file document.hpp.
| using jbson::basic_document< Container, ElementContainer >::const_iterator = typename detail::document_iter<const element_type, typename container_type::const_iterator> |
Forward iterator for traversal of elements.
Definition at line 200 of file document.hpp.
| using jbson::basic_document< Container, ElementContainer >::iterator = const_iterator |
Forward iterator for traversal of elements.
Definition at line 202 of file document.hpp.
|
inline |
Default constructor.
Definition at line 211 of file document.hpp.
|
inlineexplicit |
Constructs a document with an existing container of data.
SomeType decays to container_type. | SomeType | Type which decays to container_type. |
| c | Accepts all forms of container_type. |
Forwards c to container_type initialiser.
| invalid_document_size | When the size of c is insufficient. When the size of c differs from the size specified by c's data. |
Definition at line 226 of file document.hpp.
|
inlinenoexcept |
Copy constructor from a basic_document with a different container_type.
| OtherContainer | basic_document container from which container_type can be constructed. |
Definition at line 245 of file document.hpp.
|
inline |
Copy constructor from a basic_document with a different container_type.
| OtherContainer | basic_document container from whose iterator_type container_type can be constructed. |
Definition at line 256 of file document.hpp.
|
inlineexplicit |
Constructs a document from a range of char.
| ForwardRange | Range of char (not container_type) |
Definition at line 272 of file document.hpp.
|
inlineexplicit |
Constructs a document from a range of basic_element.
Other basic_documents are excluded. Only enabled when container_type is an actual container as it needs to be able to own data.
| ForwardRange | Range whose value_type is basic_element<...>. |
Definition at line 295 of file document.hpp.
|
inline |
Returns an iterator to the first element of the container.
| invalid_document_size | When container size is smaller than necessary for iteration. |
Definition at line 331 of file document.hpp.
|
inlinenoexcept |
Returns reference to BSON data.
Definition at line 446 of file document.hpp.
|
inlinenoexcept |
|
inlinenoexcept |
Returns rvalue reference to BSON data.
Definition at line 454 of file document.hpp.
|
inline |
Inserts an element in-place directly before another.
General advice to follow: All iterators and referenced basic_elements are invalidated. Actaul behaviour depends on container_type::insert(pos, elem_data.begin(), elem_data.end()).
| it | Iterator to the location before which the element will be inserted. Can be end(). |
| args | Arguments to construct an element in-place. |
Definition at line 419 of file document.hpp.
|
inlinenoexcept |
Definition at line 342 of file document.hpp.
|
inline |
Removes the element at it.
General advice to follow: All iterators and referenced basic_elements are invalidated. Actaul behaviour depends on container_type::erase(elem_data.begin(), elem_data.end()).
| it | Iterator to the element to remove. Cannot be end(). |
Asserts in debug mode that it != end()
Definition at line 366 of file document.hpp.
|
inline |
Find an element with the specified name.
| elem_name | Name of required element. |
Definition at line 352 of file document.hpp.
|
inline |
Inserts an element directly before another.
General advice to follow: All iterators and referenced basic_elements are invalidated. Actaul behaviour depends on container_type::insert(pos, elem_data.begin(), elem_data.end()).
| it | Iterator to the location before which the element will be inserted. Can be end(). |
| el | Element to be inserted. |
Definition at line 392 of file document.hpp.
|
inlinenoexcept |
Returns data's size in bytes.
Definition at line 442 of file document.hpp.
|
inline |
Validates document/array according to a validity_level.
| lvl | Level of validity to check for. Defaults to validity_level::bson_size. |
| recurse | boolean controlling whether or not to recurse to child documents/arrays. Defaults to true. |
Definition at line 467 of file document.hpp.
1.8.6