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

namespace detail contains internal functions and classes More...

Classes

struct  codecvt
 
struct  codecvt< char >
 
struct  codecvt< char16_t >
 
struct  container_has_push_back_impl
 
struct  document_iter
 Forward traversal iterator type for traversing basic_document and basic_array. More...
 
struct  elem_compare
 Functor for basic_element comparison. More...
 
struct  element_visitor
 Helper class to implement basic_element::visit with detail::visit. More...
 
struct  is_constructible
 
struct  is_constructible< A, B, std::enable_if_t< std::is_arithmetic< std::decay_t< A > >::value||std::is_arithmetic< std::decay_t< B > >::value > >
 
struct  is_convertible
 
struct  is_convertible< A, B, std::enable_if_t< std::is_integral< std::decay_t< A > >::value &&std::is_floating_point< std::decay_t< B > >::value > >
 
struct  is_convertible< A, B, std::enable_if_t< std::is_integral< std::decay_t< A > >::value &&std::is_integral< std::decay_t< B > >::value > >
 
struct  is_convertible< A, B, std::enable_if_t< std::is_integral< std::decay_t< B > >::value &&std::is_floating_point< std::decay_t< A > >::value > >
 
struct  is_document
 Type trait to determine whether a type is a basic_document (or basic_array) More...
 
struct  is_element
 Type trait to determine whether a type is a basic_element. More...
 
struct  is_iterator_pointer
 Trait to determine if an iterator is a pointer, or pointer in disguise. More...
 
struct  is_iterator_range
 Type trait to determine whether a type is a boost::iterator_range. More...
 
struct  is_nothrow_swappable
 Type trait to determine if a type is nothrow/noexcept swappable. More...
 
struct  is_valid_func
 Wrapper for type validity checking visitors. More...
 
struct  json_element_visitor
 
struct  make_string
 
struct  make_string< boost::string_ref >
 
struct  quote
 Variadic version of boost::mpl::quoteN. More...
 
struct  set_visitor
 
struct  typeid_visitor
 Visitor for obtaining std::type_index of a mapped element_type. More...
 
class  TypeMap
 Compile-time map. Maps element_types to C++ type for serialisation/deserialisation. More...
 

Typedefs

using actual_element_type = boost::error_info< struct actual_element_type_, element_type >
 
using actual_size = boost::error_info< struct actual_size_, ptrdiff_t >
 
using actual_type = boost::error_info< struct actual_type_, std::type_index >
 
template<typename CharT >
using codecvt_t = typename codecvt< CharT >::type
 
template<typename Container >
using container_has_push_back = typename mpl::eval_if< has_iterator< std::decay_t< Container >>, container_has_push_back_impl< std::decay_t< Container >>, std::false_type >::type
 Type trait to determine if type is a container with a push_back() function. More...
 
template<element_type EType>
using element_type_c = std::integral_constant< element_type, EType >
 Turns an element_type into a boost::mpl constant.
 
template<element_type EType, typename Container >
using ElementTypeMap = typename mpl::at< typename TypeMap< Container >::map_type, element_type_c< EType >>::type
 Type alias to perform boost::mpl::at on TypeMap::map_type. More...
 
template<element_type EType, typename Container >
using ElementTypeMapSet = typename mpl::at< typename TypeMap< Container, true >::map_type, element_type_c< EType >>::type
 Type alias to perform boost::mpl::at on TypeMap::map_type. More...
 
using expected_element_type = boost::error_info< struct expected_element_type_, element_type >
 
using expected_size = boost::error_info< struct expected_size_, ptrdiff_t >
 
using expected_type = boost::error_info< struct expected_type_, std::type_index >
 
template<typename MapT , typename FunT >
using find_if_second = typename mpl::find_if< MapT, mpl::bind< mpl::protect< FunT >, mpl::bind< mpl::quote1< mpl::second >, mpl::_1 >>>::type
 
template<typename MapT , typename T >
using find_second = typename mpl::find_if< MapT, mpl::bind< quote< std::is_same >, T, mpl::bind< mpl::quote1< mpl::second >, mpl::_1 >>>::type
 
template<typename RangeT , typename ElementTrait , typename RangeTrait >
using is_range_of = typename mpl::apply< typename mpl::eval_if< is_range< RangeT >, mpl::identity< ElementTrait >, mpl::identity< mpl::always< mpl::false_ >>>::type, typename mpl::eval_if< is_range< RangeT >, mpl::apply< RangeTrait, std::decay_t< RangeT >>, mpl::identity< void >>::type >::type
 Type trait to apply a unary metafunction to the result of a Range trait in a SFINAE safe manner. More...
 
template<typename RangeT , typename ElementTrait >
using is_range_of_iterator = is_range_of< RangeT, ElementTrait, mpl::quote1< boost::range_mutable_iterator >>
 Type trait to apply a unary metafunction trait to the iterator type of a Range. More...
 
template<typename RangeT , typename ElementT >
using is_range_of_same_value = is_range_of_value< RangeT, mpl::bind2< mpl::quote2< std::is_same >, ElementT, mpl::_1 >>
 Type trait to determine equivalence of the value_type of a Range. More...
 
template<typename RangeT , typename ElementTrait >
using is_range_of_value = is_range_of< RangeT, ElementTrait, mpl::quote1< boost::range_value >>
 Type trait to apply a unary metafunction trait to the value_type of a Range. More...
 
template<typename Container , typename T >
using is_valid_element_set_type = typename mpl::not_< std::is_same< typename mpl::end< typename TypeMap< Container, true >::map_type >::type, find_if_second< typename TypeMap< Container, true >::map_type, mpl::bind< quote< is_constructible >, mpl::_1, T >>>>::type
 
template<typename Container , typename T >
using is_valid_element_value_type = typename mpl::not_< std::is_same< typename mpl::end< typename TypeMap< Container >::map_type >::type, find_if_second< typename TypeMap< Container >::map_type, mpl::bind< quote< is_convertible >, T, mpl::_1 >>>>::type
 

Functions

template<typename RangeT , typename ArithT >
void deserialise (const RangeT &data, ArithT &num, std::enable_if_t< std::is_arithmetic< ArithT >::value > *=nullptr)
 
template<typename RangeT , typename StringT >
void deserialise (const RangeT &data, StringT &str, std::enable_if_t< std::is_convertible< std::decay_t< StringT >, boost::string_ref >::value > *=nullptr)
 
template<typename RangeT , typename Container , typename EContainer >
void deserialise (const RangeT &data, basic_document< Container, EContainer > &doc)
 
template<typename RangeT , typename Container , typename EContainer >
void deserialise (const RangeT &data, basic_array< Container, EContainer > &arr)
 
template<typename RangeT >
void deserialise (const RangeT &data, std::vector< char > &vec)
 
template<typename RangeT >
void deserialise (const RangeT &data, RangeT &vec)
 
template<typename RangeT >
void deserialise (const RangeT &data, std::array< char, 12 > &oid)
 
template<typename RangeT , typename StringT >
void deserialise (const RangeT &data, std::tuple< StringT, StringT > &tuple, std::enable_if_t< std::is_constructible< std::string, std::decay_t< StringT >>::value > *=nullptr)
 
template<typename RangeT , typename StringT >
void deserialise (const RangeT &data, std::tuple< StringT, std::array< char, 12 >> &tuple, std::enable_if_t< std::is_constructible< std::string, std::decay_t< StringT >>::value > *=nullptr)
 
template<typename RangeT , typename StringT , typename DocContainerT , typename DocEContainerT >
void deserialise (const RangeT &data, std::tuple< StringT, basic_document< DocContainerT, DocEContainerT >> &tuple, std::enable_if_t< std::is_constructible< std::string, std::decay_t< StringT >>::value > *=nullptr)
 
template<typename Container >
void init_empty (Container &c)
 Initialises a container or range for a valid empty basic_document or basic_array.
 
template<typename CharT >
constexpr bool iscntrl (CharT c)
 
template<typename CharT >
constexpr bool isdigit (CharT c)
 
template<typename CharT >
constexpr bool isspace (CharT c)
 
template<typename CharT >
constexpr bool isxdigit (CharT c)
 
template<typename T , typename ForwardIterator >
little_endian_to_native (ForwardIterator first, ForwardIterator last)
 
template<typename T >
std::array< char, sizeof(T)> native_to_little_endian (T val)
 
template<typename ElemRangeT , typename StrRngT , typename OutIterator >
void select (ElemRangeT &&doc, StrRngT path, OutIterator out)
 
template<typename ElemRangeT , typename StrRngT , typename OutIterator >
void select_expr (ElemRangeT &&doc, StrRngT path, StrRngT expr, OutIterator out)
 
template<typename ElemRangeT , typename StrRngT , typename OutIterator >
void select_name (ElemRangeT &&doc, StrRngT path, StrRngT name, OutIterator out)
 
template<typename ElemRangeT , typename StrRngT , typename OutIterator >
void select_sub (ElemRangeT &&doc, StrRngT path, StrRngT subscript, OutIterator out)
 
template<typename Container , typename IteratorT , typename T >
void serialise (Container &c, IteratorT &it, T val, std::enable_if_t< std::is_arithmetic< T >::value > *=nullptr)
 
template<typename Container , typename IteratorT >
void serialise (Container &c, IteratorT &it, boost::string_ref val)
 
template<typename Container , typename IteratorT , typename DocContainer , typename DocEContainer >
void serialise (Container &c, IteratorT &it, const basic_document< DocContainer, DocEContainer > &val)
 
template<typename Container , typename IteratorT , typename DocContainer , typename DocEContainer >
void serialise (Container &c, IteratorT &it, const basic_array< DocContainer, DocEContainer > &val)
 
template<typename Container , typename IteratorT >
void serialise (Container &c, IteratorT &it, const std::array< char, 12 > &val)
 
template<typename Container , typename IteratorT , typename StringT >
void serialise (Container &c, IteratorT &it, const std::tuple< StringT, StringT > &val, std::enable_if_t< std::is_convertible< StringT, boost::string_ref >::value > *=nullptr)
 
template<typename Container , typename IteratorT , typename StringT >
void serialise (Container &c, IteratorT &it, const std::tuple< StringT, std::array< char, 12 >> &val)
 
template<typename Container , typename IteratorT , typename StringT , typename DocContainer , typename DocEContainer >
void serialise (Container &, IteratorT &, const std::tuple< StringT, basic_document< DocContainer, DocEContainer >> &, std::enable_if_t< std::is_convertible< StringT, boost::string_ref >::value > *=nullptr)
 
bool valid_type (element_type etype)
 
template<template< element_type EType, typename...VArgs > class Visitor, typename... Args>
std::enable_if_t< std::is_void
< decltype(std::declval
< Visitor
< element_type::int64_element,
Args...>>()(std::declval< Args && >
)...))>::value > 
visit (element_type type, Args &&...args)
 void visit. More...
 
template<template< element_type EType, typename...VArgs > class Visitor, typename... Args>
std::enable_if_t<!std::is_void
< decltype(std::declval
< Visitor
< element_type::int64_element,
Args...>>()(std::declval< Args && >
)...))>::value, decltype(std::declval
< Visitor
< element_type::int64_element,
Args...>>()(std::declval< Args && >)...))> 
visit (element_type type, Args &&...args)
 Non-void visit. More...
 

Detailed Description

namespace detail contains internal functions and classes

Typedef Documentation

template<typename Container >
using jbson::detail::container_has_push_back = typedef typename mpl::eval_if<has_iterator<std::decay_t<Container>>, container_has_push_back_impl<std::decay_t<Container>>, std::false_type>::type

Type trait to determine if type is a container with a push_back() function.

Evaluates to std::false_type for all incompatible types (SFINAE friendly).

See also
has_iterator has_const_iterator

Definition at line 183 of file traits.hpp.

template<element_type EType, typename Container >
using jbson::detail::ElementTypeMap = typedef typename mpl::at<typename TypeMap<Container>::map_type, element_type_c<EType>>::type

Type alias to perform boost::mpl::at on TypeMap::map_type.

See also
TypeMap ElementTypeMapSet

Maps an element_type to a type for deserialisation.

Definition at line 137 of file traits.hpp.

template<element_type EType, typename Container >
using jbson::detail::ElementTypeMapSet = typedef typename mpl::at<typename TypeMap<Container, true>::map_type, element_type_c<EType>>::type

Type alias to perform boost::mpl::at on TypeMap::map_type.

See also
TypeMap ElementTypeMap

Same as ElementTypeMap, but for serialising types rather than deserialising.

Definition at line 146 of file traits.hpp.

template<typename RangeT , typename ElementTrait , typename RangeTrait >
using jbson::detail::is_range_of = typedef typename mpl::apply< typename mpl::eval_if<is_range<RangeT>, mpl::identity<ElementTrait>, mpl::identity<mpl::always<mpl::false_>>>::type, typename mpl::eval_if<is_range<RangeT>, mpl::apply<RangeTrait, std::decay_t<RangeT>>, mpl::identity<void>>::type>::type

Type trait to apply a unary metafunction to the result of a Range trait in a SFINAE safe manner.

See also
is_range_of_value is_range_of_same_value is_range_of_iterator

Definition at line 198 of file traits.hpp.

template<typename RangeT , typename ElementTrait >
using jbson::detail::is_range_of_iterator = typedef is_range_of<RangeT, ElementTrait, mpl::quote1<boost::range_mutable_iterator>>

Type trait to apply a unary metafunction trait to the iterator type of a Range.

See also
is_range_of_same_value is_range_of

Definition at line 219 of file traits.hpp.

template<typename RangeT , typename ElementT >
using jbson::detail::is_range_of_same_value = typedef is_range_of_value<RangeT, mpl::bind2<mpl::quote2<std::is_same>, ElementT, mpl::_1>>

Type trait to determine equivalence of the value_type of a Range.

See also
is_range_of_value is_range_of

Definition at line 212 of file traits.hpp.

template<typename RangeT , typename ElementTrait >
using jbson::detail::is_range_of_value = typedef is_range_of<RangeT, ElementTrait, mpl::quote1<boost::range_value>>

Type trait to apply a unary metafunction trait to the value_type of a Range.

See also
is_range_of_same_value is_range_of

Definition at line 205 of file traits.hpp.

Function Documentation

template<template< element_type EType, typename...VArgs > class Visitor, typename... Args>
std::enable_if_t<std::is_void< decltype(std::declval<Visitor<element_type::int64_element, Args...>>()(std::declval<Args&&>)...))>::value> jbson::detail::visit ( element_type  type,
Args &&...  args 
)

void visit.

Exceptions
invalid_element_typeWhen type is invalid.

Definition at line 24 of file visit.hpp.

template<template< element_type EType, typename...VArgs > class Visitor, typename... Args>
std::enable_if_t<!std::is_void<decltype( std::declval<Visitor<element_type::int64_element, Args...>>()(std::declval<Args&&>)...))>::value, decltype(std::declval<Visitor<element_type::int64_element, Args...>>()(std::declval<Args&&>)...))> jbson::detail::visit ( element_type  type,
Args &&...  args 
)

Non-void visit.

Exceptions
invalid_element_typeWhen type is invalid.

Definition at line 120 of file visit.hpp.