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::Element Class Reference

Public Member Functions

 Element ()
 Default Constructor. More...
 
template<typename T >
 Element (const T &data, const TypeInfo type=_UNKNOWN)
 Constructor. More...
 
 Element (const char *data, const TypeInfo type=_UNKNOWN)
 
 Element (const unsigned char *data, const TypeInfo &type)
 decoding constructor More...
 
unsigned decode (const unsigned char *data, const TypeInfo m_type)
 decodes a byte string into the calling object More...
 
void encode (std::ostringstream &oss) const
 encodes this object ias a bytestring More...
 
TypeInfo get_type () const
 type accessor More...
 
template<typename T >
const T & data () const
 data accessor More...
 
template<typename T >
void data (T &t) const
 data accessor More...
 
 operator std::string () const
 std::string conversion operator More...
 

Static Public Member Functions

static void encode (std::ostringstream &oss, const Element &e)
 static encoders and decoders More...
 
static void decode (const unsigned char *data, const TypeInfo type, Element &e)
 

Friends

class Document
 

Constructor & Destructor Documentation

bson::Element::Element ( )
inline

Default Constructor.

Precondition
None
Postcondition
Constructs an empty element with no data or type
template<typename T >
bson::Element::Element ( const T &  data,
const TypeInfo  type = _UNKNOWN 
)

Constructor.

Precondition
Related template functions are specialized for type T
Type t has been configured such that it is compatible with type
Postcondition
Constructs the object using the template specialization
bson::Element::Element ( const unsigned char *  data,
const TypeInfo &  type 
)
inline

decoding constructor

Precondition
type is compatible with the kind of data in the char*
Postcondition
constructs the object by calling the associated decode functions

Member Function Documentation

template<typename T >
const T & bson::Element::data ( ) const

data accessor

Precondition
None
Postcondition
None
Returns
the data held in the calling object.
Exceptions
bson::type_error
template<typename T >
void bson::Element::data ( T &  t) const
inline

data accessor

Precondition
None
Postcondition
changes the parameter to be the data held in the calling object
Exceptions
bson::type_error
unsigned bson::Element::decode ( const unsigned char *  data,
const TypeInfo  m_type 
)

decodes a byte string into the calling object

Precondition
m_type reflects the object type that is BSON encoded in data
Postcondition
the calling object contains the data that is BSON encoded in data
Returns
the number of bytes consumed while decoding
void bson::Element::encode ( std::ostringstream &  oss) const

encodes this object ias a bytestring

Precondition
None
Postcondition
encodes this object in BSON into the output string stream
static void bson::Element::encode ( std::ostringstream &  oss,
const Element e 
)
inlinestatic

static encoders and decoders

Precondition
m_type reflects the object type that is BSON encoded in data
Postcondition
calls the member functions encode/decode on the passed objects
TypeInfo bson::Element::get_type ( ) const
inline

type accessor

Precondition
None
Postcondition
None
Returns
the type of the object
bson::Element::operator std::string ( ) const

std::string conversion operator

Precondition
_to_std_str is template specialized
Postcondition
converts this object to a string

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