FastBSON
A BSON library that will hopefully be faster and more robust than the one built into mongo-cxx-driver
 All Classes Files Functions Friends
bson::Document Class Reference

Public Member Functions

 Document (std::initializer_list< std::pair< std::string, Element >> list)
 Initialization list constructor. More...
 
const Elementoperator[] (const std::string &index) const
 accessor More...
 
Elementoperator[] (const std::string &index)
 
void add (const std::string name, const Element &data)
 element addition More...
 
template<class T >
void add (const std::string name, const T &data, const TypeInfo ti=_UNKNOWN)
 element addition More...
 
void set (const std::string name, const Element &data)
 element modification More...
 
template<class T >
void set (const std::string &name, const T &data, const TypeInfo ti=_UNKNOWN)
 element modification More...
 
auto begin () -> decltype(m_data.begin())
 iterator functions More...
 
auto end () -> decltype(m_data.end())
 
auto rbegin () -> decltype(m_data.rbegin())
 
auto rend () -> decltype(m_data.rend())
 
auto cbegin () -> decltype(m_data.cbegin())
 
auto cend () -> decltype(m_data.cend())
 
auto crbegin () -> decltype(m_data.crbegin())
 
auto crend () -> decltype(m_data.crend())
 
std::set< std::string > field_names () const
 returns the set of field names More...
 

Friends

class Element
 
std::ostream & operator<< (std::ostream &o, const Document &d)
 insertion operator overloading More...
 

Constructor & Destructor Documentation

bson::Document::Document ( std::initializer_list< std::pair< std::string, Element >>  list)
inline

Initialization list constructor.

Precondition
None
Postcondition
Constructs the dictionary using the init list of key/value pairs

Member Function Documentation

void bson::Document::add ( const std::string  name,
const Element data 
)
inline

element addition

Precondition
None
Postcondition
creates the element in the map. If name already exists in the document the value is overwritten
template<class T >
void bson::Document::add ( const std::string  name,
const T &  data,
const TypeInfo  ti = _UNKNOWN 
)
inline

element addition

Precondition
T must be template specialized for the Element class
if ti is not defaulted, it and type T must be compatible
Postcondition
creates the element in the map. If name already exists in the document the value is overwritten
auto bson::Document::begin ( ) -> decltype(m_data.begin())
inline

iterator functions

Precondition
None
Postcondition
None
Returns
iterators pointing at the beginning and end of the data in the document
std::set<std::string> bson::Document::field_names ( ) const
inline

returns the set of field names

Precondition
None
Postcondition
None
Returns
the set of field names
const Element& bson::Document::operator[] ( const std::string &  index) const
inline

accessor

Precondition
None
Postcondition
None
Returns
the Element at the specified field name
Exceptions
std::out_of_rangeif index is not in the dictionary
void bson::Document::set ( const std::string  name,
const Element data 
)
inline

element modification

Precondition
name exists as an index in the document
Postcondition
changes the element at index name
Exceptions
std::out_of_rangeif name is not in the Document
template<class T >
void bson::Document::set ( const std::string &  name,
const T &  data,
const TypeInfo  ti = _UNKNOWN 
)
inline

element modification

Precondition
name exists as an index in the document
T must be template specialized for the Element class
if ti is not defaulted, it and type T must be compatible
Postcondition
changes the element at index name
Exceptions
std::out_of_rangeif name is not in the Document

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  o,
const Document d 
)
friend

insertion operator overloading

Precondition
None
Postcondition
inserts document d into the stream (using the string conversion for insertion)

The documentation for this class was generated from the following file: