View on GitHub
jbson
C++11/1y BSON library
element_fwd.hpp
1 // Copyright Christian Manning 2013.
2 // Distributed under the Boost Software License, Version 1.0.
3 // (See accompanying file LICENSE_1_0.txt or copy at
4 // http://www.boost.org/LICENSE_1_0.txt)
5 
6 #ifndef JBSON_ELEMENT_FWD_HPP
7 #define JBSON_ELEMENT_FWD_HPP
8 
9 #include <vector>
10 #include <set>
11 
12 #include "detail/config.hpp"
13 
21 namespace jbson {
22 
26 template <class Container> struct basic_element;
27 
32 
36 enum class element_type : uint8_t {
37  double_element = 0x01,
38  string_element = 0x02,
39  document_element = 0x03,
40  array_element = 0x04,
41  binary_element = 0x05,
42  undefined_element JBSON_DEPRECATED = 0x06,
43  oid_element = 0x07,
44  boolean_element = 0x08,
45  date_element = 0x09,
46  null_element = 0x0A,
47  regex_element = 0x0B,
48  db_pointer_element JBSON_DEPRECATED = 0x0C,
49  javascript_element = 0x0D,
51  symbol_element JBSON_DEPRECATED = 0x0E,
54  int32_element = 0x10,
55  timestamp_element = 0x11,
56  int64_element = 0x12,
57  min_key = 0xFF,
58  max_key = 0x7F
59 };
60 
61 namespace detail {
62 inline bool valid_type(element_type etype) {
63  return ((uint8_t)etype >= 0x01 && (uint8_t)etype <= 0x12) || (uint8_t)etype == 0xFF || (uint8_t)etype == 0x7F;
64 }
65 } // namespace detail
66 
72 namespace detail {
73 
74 struct elem_compare;
75 
79 template <typename> struct is_element : std::false_type {};
80 
81 #ifndef DOXYGEN_SHOULD_SKIP_THIS
82 template <typename Container> struct is_element<basic_element<Container>> : std::true_type {};
83 #endif
84 
85 } // namespace detail
86 
90 template <typename Container> using basic_document_set = std::multiset<basic_element<Container>, detail::elem_compare>;
91 
96 
97 struct jbson_error;
101 struct invalid_element_size;
102 
103 } // namespace jbson
104 
105 #endif // JBSON_ELEMENT_FWD_HPP
element_type
The element_type enum represents a BSON data type.
Definition: element_fwd.hpp:36
std::string or boost::string_ref (string_type)
std::multiset< basic_element< Container >, detail::elem_compare > basic_document_set
BSON document in the form of a std::set for ease of manipulation.
Definition: element_fwd.hpp:90
BSON element.
Definition: element.hpp:69
Exception thrown when an element has a value not convertible to that requested.
Definition: error.hpp:47
basic_document_set< std::vector< char >> document_set
Default basic_document_set type alias.
Definition: element_fwd.hpp:95
Exception type. Base class of all exceptions thrown directly by jbson.
Definition: error.hpp:23
Exception thrown when an element's data size differs from that reported.
Definition: error.hpp:55
Exception type thrown when a call to get() has an incorrect type parameter.
Definition: error.hpp:39
basic_document> (document_type)
Exception type thrown when an element has a type value not represented by element_type.
Definition: error.hpp:31
Type trait to determine whether a type is a basic_element.
Definition: element_fwd.hpp:79
Functor for basic_element comparison.
Definition: element.hpp:819