MongoDB C++ Driver 4.1.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
bsoncxx Namespace Reference

Description

The top-level namespace within which all bsoncxx library entities are declared.

In addition to declaring ABI namespaces (v_noabi, v1, etc.), this namespace also provides "redeclarations" of entities within ABI namespaces. These redeclarations are intended to be the preferred method for using bsoncxx library entities when ABI stability of the bsoncxx library is NOT a requirement by the user. See Root Namespace Redeclarations.

Namespaces

namespace  array
 Declares entities representing a BSON array.
 
namespace  builder
 Declares entities used to build BSON documents.
 
namespace  document
 Declares entities representing a BSON document.
 
namespace  stdx
 Declares C++17 standard library polyfills.
 
namespace  string
 Declares entities related to handling string types.
 
namespace  types
 Declares entities representing BSON value types.
 
namespace  v1
 Declares entities whose ABI stability is guaranteed for documented symbols.
 
namespace  v_noabi
 Declares entities whose ABI stability is NOT guaranteed.
 
namespace  vector
 Declarations related to the BSON Binary Vector subtype.
 

Classes

class  decimal128
 Represents a MongoDB BSON Decimal128. More...
 
class  exception
 Base class for all exceptions thrown by the bsoncxx library unless otherwise specified. More...
 
class  oid
 Represents a MongoDB BSON ObjectId. More...
 
class  validator
 Used to toggle checks which may be performed during BSON validation. More...
 
class  view_or_value
 A view-or-value variant type. More...
 

Enumerations

enum class  binary_sub_type
 An enumeration of each BSON binary sub type. More...
 
enum class  error_code
 Enum representing the various error types that can occur while operating on BSON values. More...
 
enum class  ExtendedJsonMode
 An enumeration of the types of Extended JSON that the to_json function accepts. More...
 
enum class  type
 An enumeration of each BSON type. More...
 

Functions

std::error_category const & error_category ()
 Get the error_category for exceptions originating from the bsoncxx library.
 
document::value from_json (stdx::string_view json)
 Constructs a new document::value from the provided JSON text.
 
std::error_code make_error_code (error_code error)
 Translate a bsoncxx::v_noabi::error_code into a std::error_code.
 
template<typename View, typename Value>
bool operator== (view_or_value< View, Value > const &lhs, view_or_value< View, Value > const &rhs)
 Compare view_or_value objects for (in)equality.
 
std::string to_json (document::view view, ExtendedJsonMode mode=ExtendedJsonMode::k_legacy)
 Converts a BSON document to a JSON string, in extended format.
 
std::string to_string (type rhs)
 Returns a stringification of the given type.
 
stdx::optional< document::viewvalidate (std::uint8_t const *data, std::size_t length)
 Validates a BSON document. This is a simplified overload that will only do the bare minimum validation of document structure, and does not provide any further information if the document is found to be invalid.
 

Enumeration Type Documentation

◆ binary_sub_type

enum class bsoncxx::v_noabi::binary_sub_type : std::uint8_t
strong

An enumeration of each BSON binary sub type.

◆ error_code

enum class bsoncxx::v_noabi::error_code : std::int32_t
strong

Enum representing the various error types that can occur while operating on BSON values.

Note
std::is_error_code_enum is specialized for this type.

◆ ExtendedJsonMode

enum class bsoncxx::v_noabi::ExtendedJsonMode : std::uint8_t
strong

An enumeration of the types of Extended JSON that the to_json function accepts.

◆ type

enum class bsoncxx::v_noabi::type : std::uint8_t
strong

An enumeration of each BSON type.

Function Documentation

◆ error_category()

std::error_category const & bsoncxx::v_noabi::error_category ( )

Get the error_category for exceptions originating from the bsoncxx library.

Returns
The bsoncxx error_category

◆ from_json()

document::value bsoncxx::v_noabi::from_json ( stdx::string_view json)

Constructs a new document::value from the provided JSON text.

Parameters
jsonA string_view into a JSON document.
Returns
A document::value if conversion worked.
Exceptions
bsoncxx::v_noabi::exceptionwith error details if the conversion failed.

◆ make_error_code()

std::error_code bsoncxx::v_noabi::make_error_code ( error_code error)
inline

Translate a bsoncxx::v_noabi::error_code into a std::error_code.

Parameters
errorAn error from bsoncxx
Returns
An error_code

◆ operator==()

template<typename View, typename Value>
bool operator== ( view_or_value< View, Value > const & lhs,
view_or_value< View, Value > const & rhs )
related

Compare view_or_value objects for (in)equality.

◆ to_json()

std::string bsoncxx::v_noabi::to_json ( document::view view,
ExtendedJsonMode mode = ExtendedJsonMode::k_legacy )

Converts a BSON document to a JSON string, in extended format.

Parameters
viewA valid BSON document or array.
modeAn optional JSON representation mode.
Exceptions
bsoncxx::v_noabi::exceptionwith error details if the conversion failed.
Returns
An extended JSON string.

◆ to_string()

std::string bsoncxx::v_noabi::to_string ( type rhs)

Returns a stringification of the given type.

Parameters
rhsThe type to stringify.
Returns
a std::string representation of the type.

◆ validate()

stdx::optional< document::view > bsoncxx::v_noabi::validate ( std::uint8_t const * data,
std::size_t length )

Validates a BSON document. This is a simplified overload that will only do the bare minimum validation of document structure, and does not provide any further information if the document is found to be invalid.

Parameters
dataA buffer containing a BSON document to validate.
lengthThe size of the buffer.
Returns
An engaged optional containing a view if the document is valid, or an unengaged optional if the document is invalid.