View on GitHub
jbson
C++11/1y BSON library
Namespaces | Classes | Typedefs | Enumerations | Functions
jbson Namespace Reference

The jbson namespace contains the main classes and functions for viewing, creating and manipulating BSON data. More...

Namespaces

 detail
 namespace detail contains internal functions and classes
 

Classes

struct  array_builder
 array_builder provides a simple interface for array construction More...
 
class  basic_array
 BSON array. More...
 
class  basic_document
 BSON document. More...
 
struct  basic_element
 BSON element. More...
 
struct  builder
 builder provides a simple interface for document construction. More...
 
struct  incompatible_element_conversion
 Exception type thrown when a call to get<element_type>() has an incorrect type parameter. More...
 
struct  incompatible_type_conversion
 Exception thrown when an element has a value not convertible to that requested. More...
 
struct  invalid_document_size
 Exception thrown when an document's data size differs from that reported. More...
 
struct  invalid_element_size
 Exception thrown when an element's data size differs from that reported. More...
 
struct  invalid_element_type
 Exception type thrown when an element has a type value not represented by element_type. More...
 
struct  jbson_error
 Exception type. Base class of all exceptions thrown directly by jbson. More...
 
struct  json_parse_error
 
struct  json_reader
 

Typedefs

using array = basic_array< std::vector< char >>
 Default basic_array type alias for owned BSON data.
 
template<typename Container >
using basic_document_set = std::multiset< basic_element< Container >, detail::elem_compare >
 BSON document in the form of a std::set for ease of manipulation.
 
using current_line_string = boost::error_info< struct line_, std::string >
 
using document = basic_document< std::vector< char >>
 Default basic_document type alias for owned BSON data.
 
using document_set = basic_document_set< std::vector< char >>
 Default basic_document_set type alias.
 
using element = basic_element< std::vector< char >>
 Default basic_element type alias for owned BSON data.
 
using expected_token = boost::error_info< struct token_, std::string >
 
using line_number = boost::error_info< struct line_num_, size_t >
 
using line_position = boost::error_info< struct line_pos_, size_t >
 
using parse_error = boost::error_info< struct err_val_, json_error_num >
 

Enumerations

enum  element_type : uint8_t {
  element_type::double_element = 0x01, element_type::string_element = 0x02, element_type::document_element = 0x03, element_type::array_element = 0x04,
  element_type::binary_element = 0x05, element_type::undefined_element = 0x06, element_type::oid_element = 0x07, element_type::boolean_element = 0x08,
  element_type::date_element = 0x09, element_type::null_element = 0x0A, element_type::regex_element = 0x0B, element_type::db_pointer_element = 0x0C,
  element_type::javascript_element = 0x0D, element_type::symbol_element = 0x0E, element_type::scoped_javascript_element = 0x0F, element_type::int32_element = 0x10,
  element_type::timestamp_element = 0x11, element_type::int64_element = 0x12, element_type::min_key = 0xFF, element_type::max_key = 0x7F
}
 The element_type enum represents a BSON data type. More...
 
enum  json_error_num { invalid_root_element, unexpected_end_of_range, unexpected_token }
 
enum  validity_level : uint8_t {
  validity_level::data_size = 0, validity_level::bson_size = 0b0001, validity_level::element_construct = 0b0010, validity_level::unicode_valid = 0b0100,
  validity_level::array_indices = 0b1000
}
 Level of validity to test for with basic_document::valid. More...
 

Functions

std::string error_message (json_parse_error &err)
 
template<element_type EType, typename Container >
auto get (const basic_element< Container > &elem) -> detail::ElementTypeMap< EType, Container >
 Access element value of specific element_type. More...
 
template<typename ReturnT , typename Container >
ReturnT get (const basic_element< Container > &elem)
 Get value of specific type from a basic_element. More...
 
validity_level operator& (validity_level a, validity_level b)
 Allow bitwise-and (&) for validity_level.
 
bool operator< (validity_level a, validity_level b)
 Allow less than (<) comparison for validity_level.
 
template<typename CharT , typename TraitsT >
std::basic_ostream< CharT,
TraitsT > & 
operator<< (std::basic_ostream< CharT, TraitsT > &os, json_error_num err)
 
template<typename CharT , typename TraitsT >
std::basic_ostream< CharT,
TraitsT > & 
operator<< (std::basic_ostream< CharT, TraitsT > &os, element_type e)
 Stream operator for getting a string representation of an element_type.
 
bool operator> (validity_level a, validity_level b)
 Allow more than (>) comparison for validity_level.
 
validity_level operator| (validity_level a, validity_level b)
 Allow bitwise-or (|) for validity_level.
 
template<typename Container , typename EContainer , typename StrRngT >
auto path_select (basic_document< Container, EContainer > &&doc, StrRngT &&path_rng)
 
template<typename ElemRangeT , typename StrRngT >
auto path_select (ElemRangeT &&doc, StrRngT &&path_rng, std::enable_if_t< detail::is_range_of_value< ElemRangeT, boost::mpl::quote1< detail::is_element >>::value > *=nullptr)
 
template<typename DocRangeT , typename StrRngT >
auto path_select (DocRangeT &&docs, StrRngT &&path_rng, std::enable_if_t< detail::is_range_of_value< DocRangeT, boost::mpl::bind< boost::mpl::quote2< detail::is_range_of_value >, boost::mpl::arg< 1 >, boost::mpl::quote1< detail::is_element >>>::value > *=nullptr)
 
template<typename Container >
void swap (basic_element< Container > &a, basic_element< Container > &b) noexcept(noexcept(a.swap(b)))
 Non-member swap. Calls member swap.
 
template<typename Container , typename EContainer >
void swap (basic_document< Container, EContainer > &a, basic_document< Container, EContainer > &b) noexcept(noexcept(a.swap(b)))
 Non-member swap for basic_document. Calls basic_document::swap.
 
template<typename Container , typename EContainer >
void swap (basic_array< Container, EContainer > &a, basic_array< Container, EContainer > &b) noexcept(noexcept(a.swap(b)))
 Non-member swap for basic_document. Calls basic_document::swap.
 
std::string to_string (const json_parse_error &)
 
template<typename Container >
void value_get (const basic_element< Container > &,...)
 
template<typename Container >
void value_get (const basic_element< Container > &elem, std::string &str)
 
template<typename Container >
void value_set (basic_element< Container > &,...)
 
template<typename Container >
void value_set (basic_element< Container > &c, builder val)
 
template<typename Container , typename IteratorT >
void value_set (basic_element< Container > &c, array_builder val)
 
template<typename Container , typename SetContainer >
void value_set (basic_element< Container > &c, const basic_document_set< SetContainer > &val)
 
template<typename OutputIterator , typename Container >
std::decay_t< OutputIterator > write_json (const basic_array< Container > &, OutputIterator)
 
template<typename OutputIterator , typename Container >
std::decay_t< OutputIterator > write_json (const basic_document< Container > &, OutputIterator)
 

Detailed Description

The jbson namespace contains the main classes and functions for viewing, creating and manipulating BSON data.

The jbson projects defines nothing outside of this namespace

Enumeration Type Documentation

enum jbson::element_type : uint8_t
strong

The element_type enum represents a BSON data type.

Enumerator
double_element 

double

string_element 

std::string or boost::string_ref (string_type)

document_element 

basic_document<boost::iterator_range<...>> (document_type)

array_element 

basic_array<boost::iterator_range<...>>

binary_element 
Unimplemented:
binary data storage
undefined_element 

void

Deprecated:
use null_element instead
oid_element 

std::array<char, 12>

boolean_element 

bool

date_element 

int64_t

null_element 

void

regex_element 

std::tuple<string_type, string_type>

db_pointer_element 

std::tuple<string_type, std::array<char, 12>>

Deprecated:
use a string_element + oid_element
javascript_element 

string_type

symbol_element 

string_type

Deprecated:
use a string_element or javascript_element
scoped_javascript_element 

std::tuple<string_type, document_type>

int32_element 

int32_t

timestamp_element 

int64_t

int64_element 

int64_t

min_key 

void

max_key 

void

Definition at line 36 of file element_fwd.hpp.

enum jbson::validity_level : uint8_t
strong

Level of validity to test for with basic_document::valid.

Enumerator
data_size 

Basic test for the size of the data.

bson_size 

Basic test for the equality of the data size with that reported by the data. Includes above.

element_construct 

Tests that each element can be constructed without error. Includes above.

unicode_valid 

Tests for valid unicode in elements with type element_type::string_element. Includes above.

array_indices 

Tests that array elements are integers named consecutively from 0 (zero). Includes above except unicode_valid.

Definition at line 153 of file document.hpp.

Function Documentation

template<element_type EType, typename Container >
auto jbson::get ( const basic_element< Container > &  elem) -> detail::ElementTypeMap<EType, Container>

Access element value of specific element_type.

Parameters
elembasic_element to fetch value from.
Template Parameters
ETypeelement_type which maps to the type to fetch.
Exceptions
incompatible_element_conversionWhen EType does not match the element_type of elem.
invalid_element_sizeWhen the size of the element's data is invalid for the return type.

Definition at line 875 of file element.hpp.

template<typename ReturnT , typename Container >
ReturnT jbson::get ( const basic_element< Container > &  elem)

Get value of specific type from a basic_element.

Template Parameters
ReturnTSpecified return type.
Exceptions
invalid_element_sizeWhen the size of the element's data is invalid for the chosen type ReturnT.
See also
basic_element::value

Definition at line 890 of file element.hpp.