BSON C++ API  2.5.1
uma::bson
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
uma::bson Namespace Reference

Classes that present a DOM style view of a BSON document. More...

Namespaces

namespace  io
 Classes that provide IO support for BSON data.
 

Classes

class  Array
 A class that represents a BSON array type document. More...
 
class  BinaryData
 A POD that represents a BSON element of type binary data. More...
 
class  Boolean
 A POD that represents a boolean type BSON element value. More...
 
class  Code
 A POD that represents a code type BSON element value. More...
 
class  CodeWithScope
 A POD that represents a code with document scope BSON element value. More...
 
class  DatabaseReference
 A POD that represents a database reference type BSON element value. *. More...
 
class  Date
 A POD that represents a BSON element value of type date. More...
 
class  Document
 A class that represents a BSON Object. More...
 
class  Double
 A POD that represents a double value in a BSON element. More...
 
class  Element
 A class that represents a BSON element. Stores the name-value mapping for a BSON element in a PIMPL. This enables efficient copy-by-value semantics at the cost of shared data across the various copies of the element. More...
 
class  EOO
 A POD that represents a EOO value. More...
 
class  Integer
 A POD that represents an integer type BSON element value. More...
 
class  Long
 A POD that represents a long (64 bit integer) type BSON element value. More...
 
class  Null
 A POD that represents a null BSON element value. More...
 
class  Object
 Abstract base class that represents a BSON Object type. More...
 
class  ObjectId
 A POD that represents a MongoDB OID type. More...
 
class  ODMObject
 Abstract class that presents a more friendly ODM interface than uma::bson::Object. More...
 
class  PrimitiveValue
 A base value class used to represent primitive type values. More...
 
class  RegularExpression
 A POD that represents a regular expression type BSON element value. More...
 
class  String
 A POD that represents a string value in a BSON element. More...
 
class  Symbol
 A POD that represents a programming language symbol type BSON element value. More...
 
class  Text
 A class that holds a string. BSON string/text values can be large, hence take care when copy constructing or assigning text instances. More...
 
class  Timestamp
 A POD that represents a database timestamp BSON element value. More...
 
class  Undefined
 
class  Value
 

Functions

UMA_BSON_API bool operator== (const Array &lhs, const Array &rhs)
 Compare two arrays for equality. Arrays are considered equal if they have the same size and the same elements at the same indices in the array.
 
bool operator!= (const Array &lhs, const Array &rhs)
 Just the reverse of operator ==.
 
UMA_BSON_API std::ofstream & operator<< (std::ofstream &os, const BinaryData &element)
 Writes the contents of the binary data to the specified file output stream.
 
std::ostream & operator<< (std::ostream &os, const BinaryData::DataType &type)
 Writes the contents of the binary data to the specified output stream.
 
bool operator== (const BinaryData &lhs, const BinaryData &rhs)
 Compare two binary data instances for equality. Compares the data stored in each instance and their types for equality.
 
bool operator!= (const BinaryData &lhs, const BinaryData &rhs)
 Just the reverse of operator ==.
 
bool operator== (const CodeWithScope &lhs, const CodeWithScope &rhs)
 Compare two code with scope instances for equality. Compares the code and scope values of each instance.
 
bool operator!= (const CodeWithScope &lhs, const CodeWithScope &rhs)
 Just the reverse of operator ==.
 
bool operator== (const DatabaseReference &lhs, const DatabaseReference &rhs)
 Compare two database references for equality. Compares the names of the collections and the object id values.
 
bool operator!= (const DatabaseReference &lhs, const DatabaseReference &rhs)
 Just the reverse of operator ==.
 
bool operator< (const Date &lhs, const Date &rhs)
 Compare the two data values for less-than operator.
 
bool operator> (const Date &lhs, const Date &rhs)
 Compare the two data values for greater-than operator.
 
bool operator== (const Date &lhs, const Date &rhs)
 Compare two date values for equality.
 
bool operator!= (const Date &lhs, const Date &rhs)
 Just the reverse of operator ==.
 
UMA_BSON_API bool operator== (const Document &lhs, const Document &rhs)
 Compare two documents for equality.
 
bool operator!= (const Document &lhs, const Document &rhs)
 Just the reverse of operator ==.
 
template<>
UMA_BSON_API std::string Element::getSimple< std::string > () const
 Specialised method for getting the value of uma::bson::String.
 
template<>
UMA_BSON_API ElementElement::setValue< std::string > (const std::string &v)
 Specialised method for setting the value to uma::bson::String.
 
bool operator< (const Element &lhs, const Element &rhs)
 Comparison operator for ordering element instances.
 
UMA_BSON_API bool operator== (const Element &lhs, const Element &rhs)
 Compare two elements for equality. Compares the names and held values of the elements.
 
bool operator!= (const Element &lhs, const Element &rhs)
 Just the reverse of operator ==.
 
bool operator== (const EOO &, const EOO &)
 Compare two EOO values for equality. Always returns true.
 
bool operator!= (const EOO &lhs, const EOO &rhs)
 Just the reverse of operator ==.
 
bool operator== (const Null &, const Null &)
 Compare two null values for equality. Always returns true.
 
bool operator!= (const Null &lhs, const Null &rhs)
 Just the reverse of operator ==.
 
UMA_BSON_API bool operator== (const Object &lhs, const Object &rhs)
 Compare two objects for equality.
 
bool operator!= (const Object &lhs, const Object &rhs)
 Just the reverse of operator ==.
 
bool operator< (const ObjectId &lhs, const ObjectId &rhs)
 Less than operator for comparing ObjectId instances.
 
bool operator> (const ObjectId &lhs, const ObjectId &rhs)
 Greater than operator for comparing ObjectId instances.
 
UMA_BSON_API bool operator== (const ObjectId &lhs, const ObjectId &rhs)
 Compare two object id values for equality. Compares the data in each instance.
 
bool operator!= (const ObjectId &lhs, const ObjectId &rhs)
 Just the reverse of operator ==.
 
template<typename T >
bool operator== (const PrimitiveValue< T > &lhs, const PrimitiveValue< T > &rhs)
 Compare the encapsulated values in the specified instances for equality;.
 
template<typename T >
bool operator== (const PrimitiveValue< T > &lhs, const T rhs)
 Compare the encapsulated value in the specified instance for equality with the specified primitive value.
 
template<typename T >
bool operator!= (const PrimitiveValue< T > &lhs, const PrimitiveValue< T > &rhs)
 Just the reverse of operator ==.
 
template<typename T >
bool operator!= (const PrimitiveValue< T > &lhs, const T rhs)
 Just the reverse of operator ==.
 
template<typename T >
bool operator< (const PrimitiveValue< T > &lhs, const PrimitiveValue< T > &rhs)
 Check to see if the value encapsulated in the left hand instance is less than the value in the right hand instance.
 
template<typename T >
bool operator< (const PrimitiveValue< T > &lhs, const T rhs)
 Compare the encapsulated value in the left hand instance with the primitive value specified.
 
template<typename T >
bool operator> (const PrimitiveValue< T > &lhs, const PrimitiveValue< T > &rhs)
 Compare the encapsulated values of the two instances.
 
template<typename T >
bool operator> (const PrimitiveValue< T > &lhs, const T rhs)
 Compare the encapsulated value in the left hand instance with the primitive value in the right hand instance.
 
bool operator== (const RegularExpression &lhs, const RegularExpression &rhs)
 Compare two regular expressions for equality. Compares the regex and flags values for equality.
 
bool operator!= (const RegularExpression &lhs, const RegularExpression &rhs)
 Just the reverse of operator ==.
 
bool operator== (const Text &lhs, const Text &rhs)
 Compare the two text instances for equality.
 
bool operator== (const Text &text, const std::string &str)
 Compare the held value with the specified value.
 
bool operator< (const Text &lhs, const Text &rhs)
 Compare the two text instances. Compares the held values of both instances.
 
bool operator< (const Text &text, const std::string &str)
 Compares the value held in the specified text with the specified string value.
 
bool operator!= (const Text &lhs, const Text &rhs)
 Just the reverse of operator ==.
 
bool operator== (const Timestamp &lhs, const Timestamp &rhs)
 Compare two timestamps for equality. Compares the timestamp and increment values of both instances for equality.
 
bool operator!= (const Timestamp &lhs, const Timestamp &rhs)
 Just the reverse of operator ==.
 
bool operator== (const Undefined &, const Undefined &)
 Compare two undefined values for equality. Always returns true.
 
bool operator!= (const Undefined &lhs, const Undefined &rhs)
 Just the reverse of operator ==.
 
std::ostream & operator<< (std::ostream &os, const Value::Type &type)
 Write integer representation of the value type to the specified output stream. This is primarily intended for use while debugging/logging. Note that this cannot be used to write to BSON, since types are written as single byte char values.
 
UMA_BSON_API bool operator== (const Value &lhs, const Value &rhs)
 Compare two values for equality. Default implementation performs a true comparison of the standard value type implementations provided by this API.
 
bool operator!= (const Value &lhs, const Value &rhs)
 Just the reverse of operator ==.
 

Detailed Description

Classes that present a DOM style view of a BSON document.

Namespace with classes that present a DOM style view of a BSON document. Unlike the MongoDB C++ API, a uma::bson::Document and uma::bson::Array are not related. A Document presents a std::map style interface while an array presents a std::vector type interface.

All the value objects used to encapsulate BSON data types use shared pointers to store its data where appropriate, making them easy to pass by value. This also makes them harder to clone. Callers must keep this in mind and treat shared memory with the usual care.

Function Documentation

template<>
UMA_BSON_API std::string uma::bson::Element::getSimple< std::string > ( ) const

Specialised method for getting the value of uma::bson::String.

template<>
UMA_BSON_API Element& uma::bson::Element::setValue< std::string > ( const std::string &  v)

Specialised method for setting the value to uma::bson::String.

bool uma::bson::operator!= ( const Null &  lhs,
const Null &  rhs 
)
inline

Just the reverse of operator ==.

bool uma::bson::operator!= ( const EOO &  lhs,
const EOO &  rhs 
)
inline

Just the reverse of operator ==.

bool uma::bson::operator!= ( const Undefined &  lhs,
const Undefined &  rhs 
)
inline

Just the reverse of operator ==.

bool uma::bson::operator!= ( const Value &  lhs,
const Value &  rhs 
)
inline

Just the reverse of operator ==.

template<typename T >
bool uma::bson::operator!= ( const PrimitiveValue< T > &  lhs,
const PrimitiveValue< T > &  rhs 
)
inline

Just the reverse of operator ==.

bool uma::bson::operator!= ( const CodeWithScope &  lhs,
const CodeWithScope &  rhs 
)
inline

Just the reverse of operator ==.

template<typename T >
bool uma::bson::operator!= ( const PrimitiveValue< T > &  lhs,
const T  rhs 
)
inline

Just the reverse of operator ==.

bool uma::bson::operator!= ( const DatabaseReference &  lhs,
const DatabaseReference &  rhs 
)
inline

Just the reverse of operator ==.

bool uma::bson::operator!= ( const RegularExpression &  lhs,
const RegularExpression &  rhs 
)
inline

Just the reverse of operator ==.

bool uma::bson::operator!= ( const Date &  lhs,
const Date &  rhs 
)
inline

Just the reverse of operator ==.

bool uma::bson::operator!= ( const Timestamp &  lhs,
const Timestamp &  rhs 
)
inline

Just the reverse of operator ==.

bool uma::bson::operator!= ( const Text &  lhs,
const Text &  rhs 
)
inline

Just the reverse of operator ==.

bool uma::bson::operator!= ( const ObjectId &  lhs,
const ObjectId &  rhs 
)
inline

Just the reverse of operator ==.

bool uma::bson::operator!= ( const Object &  lhs,
const Object &  rhs 
)
inline

Just the reverse of operator ==.

bool uma::bson::operator!= ( const BinaryData &  lhs,
const BinaryData &  rhs 
)
inline

Just the reverse of operator ==.

bool uma::bson::operator!= ( const Array &  lhs,
const Array &  rhs 
)
inline

Just the reverse of operator ==.

bool uma::bson::operator!= ( const Element &  lhs,
const Element &  rhs 
)
inline

Just the reverse of operator ==.

bool uma::bson::operator!= ( const Document &  lhs,
const Document &  rhs 
)
inline

Just the reverse of operator ==.

bool uma::bson::operator< ( const Date &  lhs,
const Date &  rhs 
)
inline

Compare the two data values for less-than operator.

Parameters
lhsThe left hand date to compare against
rhsThe right hand date to compare against
Returns
Return true if the datetime in the left hand instance is lower than the datetime in the right hand instance.
bool uma::bson::operator< ( const Text &  lhs,
const Text &  rhs 
)
inline

Compare the two text instances. Compares the held values of both instances.

Parameters
lhsThe left hand text instance to compare
rhsThe right hand text instance to compare
Returns
Return true if the value held in the left hand instance is lexically less than the value held in the right hand instance.
bool uma::bson::operator< ( const ObjectId &  lhs,
const ObjectId &  rhs 
)
inline

Less than operator for comparing ObjectId instances.

Returns
Return true if the left hand object id is considered less (earlier) than the right hand object id.
template<typename T >
bool uma::bson::operator< ( const PrimitiveValue< T > &  lhs,
const PrimitiveValue< T > &  rhs 
)
inline

Check to see if the value encapsulated in the left hand instance is less than the value in the right hand instance.

Template Parameters
TThe primitive type encapsulated by this class.
Parameters
lhsThe left hand instance to compare.
rhsThe right hand instance to compare.
Returns
Return true if the value in the left hand instance is less than the value in the right hand instance.
bool uma::bson::operator< ( const Text &  text,
const std::string &  str 
)
inline

Compares the value held in the specified text with the specified string value.

Parameters
textThe text value to compare with the string.
strThe string value to compare against
Returns
Return true if the value encapsulated in this instance is lexically lower than the value specified.
template<typename T >
bool uma::bson::operator< ( const PrimitiveValue< T > &  lhs,
const T  rhs 
)
inline

Compare the encapsulated value in the left hand instance with the primitive value specified.

Template Parameters
TThe primitive type encapsulated by this class.
Parameters
lhsThe left hand instance to compare.
rhsThe primitive alue to compare
Returns
Return true if the value in the left hand instance is less than the right hand value.
bool uma::bson::operator< ( const Element &  lhs,
const Element &  rhs 
)
inline

Comparison operator for ordering element instances.

Compares the names of the two elements. May be used by hash containers to order the elements by name.

Parameters
lhsThe left hand element to compare
rhsThe right hand element to compare
Returns
Returns true if the name of the left hand element is lexically less than the name of the right hand element.
std::ostream& uma::bson::operator<< ( std::ostream &  os,
const Value::Type &  type 
)
inline

Write integer representation of the value type to the specified output stream. This is primarily intended for use while debugging/logging. Note that this cannot be used to write to BSON, since types are written as single byte char values.

Parameters
osThe output stream to write to
typeThe value to write as an integer to the stream
Returns
The output stream for chaining calls.
UMA_BSON_API std::ofstream& uma::bson::operator<< ( std::ofstream &  os,
const BinaryData &  element 
)

Writes the contents of the binary data to the specified file output stream.

Parameters
osThe file output stream to write the binary data to.
elementThe binary data instance to serialise to file.
Returns
The output stream for method chaining.
std::ostream& uma::bson::operator<< ( std::ostream &  os,
const BinaryData::DataType &  type 
)
inline

Writes the contents of the binary data to the specified output stream.

Parameters
osThe output stream to write the binary data to.
elementThe binary data instance to serialise to the stream.
Returns
The output stream for method chaining.
bool uma::bson::operator== ( const Null &  ,
const Null &   
)
inline

Compare two null values for equality. Always returns true.

Since
2.0
Parameters
lhsThe left hand value to compare
rhsThe right hand value to compare
Returns
Return true
bool uma::bson::operator== ( const EOO &  ,
const EOO &   
)
inline

Compare two EOO values for equality. Always returns true.

Since
2.0
Parameters
lhsThe left hand value to compare
rhsThe right hand value to compare
Returns
Return true
bool uma::bson::operator== ( const Undefined &  ,
const Undefined &   
)
inline

Compare two undefined values for equality. Always returns true.

Since
2.0
Parameters
lhsThe left hand value to compare
rhsThe right hand value to compare
Returns
Return true
UMA_BSON_API bool uma::bson::operator== ( const Value &  lhs,
const Value &  rhs 
)

Compare two values for equality. Default implementation performs a true comparison of the standard value type implementations provided by this API.

Since
2.2
Parameters
lhsThe left hand value to compare
rhsThe right hand value to compare
Returns
Return true if the two instances are the same.
template<typename T >
bool uma::bson::operator== ( const PrimitiveValue< T > &  lhs,
const PrimitiveValue< T > &  rhs 
)
inline

Compare the encapsulated values in the specified instances for equality;.

Template Parameters
TThe primitive type encapsulated by this class.
Parameters
lhsThe left hand instance to compare.
rhsThe right hand instance to compare.
Returns
Return true if the values are equal
bool uma::bson::operator== ( const Text &  lhs,
const Text &  rhs 
)
inline

Compare the two text instances for equality.

Parameters
lhsThe left hand text instance to compare
rhsThe right hand text instance to compare
Returns
Return true if the held values are the same
template<typename T >
bool uma::bson::operator== ( const PrimitiveValue< T > &  lhs,
const T  rhs 
)
inline

Compare the encapsulated value in the specified instance for equality with the specified primitive value.

Template Parameters
TThe primitive type encapsulated by this class.
Parameters
lhsThe primitive instance to compare.
rhsThe primitive value to compare against
Returns
Return true if the values are equal
bool uma::bson::operator== ( const CodeWithScope &  lhs,
const CodeWithScope &  rhs 
)
inline

Compare two code with scope instances for equality. Compares the code and scope values of each instance.

Since
2.0
Parameters
lhsThe left hand value to compare
rhsThe right hand value to compare
Returns
Return true if the two instances are equivalent
bool uma::bson::operator== ( const DatabaseReference &  lhs,
const DatabaseReference &  rhs 
)
inline

Compare two database references for equality. Compares the names of the collections and the object id values.

Since
2.0
Parameters
lhsThe left hand value to compare
rhsThe right hand value to compare
Returns
Return true if the two instances are equivalent.
bool uma::bson::operator== ( const Text &  text,
const std::string &  str 
)
inline

Compare the held value with the specified value.

Parameters
textThe text value to compare with the string.
strThe string value to compare with
Returns
Return true if the held value is same as the specified value.
bool uma::bson::operator== ( const RegularExpression &  lhs,
const RegularExpression &  rhs 
)
inline

Compare two regular expressions for equality. Compares the regex and flags values for equality.

Since
2.0
Parameters
lhsThe left hand value to compare
rhsThe right hand value to compare
Returns
Return true if the two instances are equivalent.
bool uma::bson::operator== ( const Date &  lhs,
const Date &  rhs 
)
inline

Compare two date values for equality.

Parameters
lhsThe left hand date to compare against
rhsThe right hand date to compare against
Returns
Return true if the datetime values represented are equal.
bool uma::bson::operator== ( const Timestamp &  lhs,
const Timestamp &  rhs 
)
inline

Compare two timestamps for equality. Compares the timestamp and increment values of both instances for equality.

Since
2.0
Parameters
lhsThe left hand value to compare
rhsThe right hand value to compare
Returns
Return true if the two instances have the same values.
UMA_BSON_API bool uma::bson::operator== ( const ObjectId &  lhs,
const ObjectId &  rhs 
)

Compare two object id values for equality. Compares the data in each instance.

Since
2.0
Parameters
lhsThe left hand value to compare
rhsThe right hand value to compare
Returns
Return true if the two id values are equivalent.
UMA_BSON_API bool uma::bson::operator== ( const Object &  lhs,
const Object &  rhs 
)

Compare two objects for equality.

Ensures that both objects have same number of elements, and compares each element for equality. Objects are considered equal only if they have equivalent elements at the same positions (index) within the object, or which have the same ordering of elements.

Warning
This method performs a true deep comparison and may be quite heavy weight depending upon the data in the documents being compared.
Parameters
lhsThe left hand value to compare
rhsThe right hand value to compare
Returns
Return true if the two instances are equal.
bool uma::bson::operator== ( const BinaryData &  lhs,
const BinaryData &  rhs 
)
inline

Compare two binary data instances for equality. Compares the data stored in each instance and their types for equality.

Warning
Performance of this method will depend upon the size of the binary data held in the instances.
Since
2.0
Parameters
lhsThe left hand value to compare
rhsThe right hand value to compare
Returns
Return true if the two instances are equivalent.
UMA_BSON_API bool uma::bson::operator== ( const Array &  lhs,
const Array &  rhs 
)

Compare two arrays for equality. Arrays are considered equal if they have the same size and the same elements at the same indices in the array.

Warning
This method performs a true deep comparison and will not be efficient.
Since
2.0
Parameters
lhsThe left hand value to compare
rhsThe right hand value to compare
Returns
Return true if the two instances have equivalent elements.
UMA_BSON_API bool uma::bson::operator== ( const Element &  lhs,
const Element &  rhs 
)

Compare two elements for equality. Compares the names and held values of the elements.

Since
2.0
Parameters
lhsThe left hand value to compare
rhsThe right hand value to compare
Returns
Return true if the two elements have the same name and value.
UMA_BSON_API bool uma::bson::operator== ( const Document &  lhs,
const Document &  rhs 
)

Compare two documents for equality.

Ensures that both documents have same number of elements, and compares each element for equality. Documents are considered equal only if they have equivalent elements at the same positions (index) within the document, or which have the same ordering of elements.

Warning
This method performs a true deep comparison and may be quite heavy weight depending upon the data in the documents being compared.
Since
2.0
Parameters
lhsThe left hand value to compare
rhsThe right hand value to compare
Returns
Return true if the two instances are equal.
bool uma::bson::operator> ( const Date &  lhs,
const Date &  rhs 
)
inline

Compare the two data values for greater-than operator.

Parameters
lhsThe left hand date to compare against
rhsThe right hand date to compare against
Returns
Return true if the left hand datetime instance is greater than the datetime in the right hand instance.
bool uma::bson::operator> ( const ObjectId &  lhs,
const ObjectId &  rhs 
)
inline

Greater than operator for comparing ObjectId instances.

Returns
Return true if the left hand object id is considered greater (newer) than the right hand object id.
template<typename T >
bool uma::bson::operator> ( const PrimitiveValue< T > &  lhs,
const PrimitiveValue< T > &  rhs 
)
inline

Compare the encapsulated values of the two instances.

Template Parameters
TThe primitive type encapsulated by this class.
Parameters
lhsThe left hand instance to compare against
rhsThe right hand instance to compare against
Returns
Return true if the left hand instance is greater than the right hand instance.
template<typename T >
bool uma::bson::operator> ( const PrimitiveValue< T > &  lhs,
const T  rhs 
)
inline

Compare the encapsulated value in the left hand instance with the primitive value in the right hand instance.

Template Parameters
TThe primitive type encapsulated by this class.
Parameters
lhsThe left instance to compare
rhsThe primitivate value to compare
Returns
Return true if the encapsulated value is greater than the primitive value.