userver: formats::bson Namespace Reference
Loading...
Searching...
No Matches
formats::bson Namespace Reference

Detailed Description

BSON support.

Classes

class  Binary
 BSON Binary. More...
 
class  BsonException
 Generic BSON-related exception. More...
 
class  BsonString
 
class  ConversionException
 Conversion error. More...
 
class  Decimal128
 BSON Decimal128. More...
 
class  Document
 BSON document. More...
 
class  ExceptionWithPath
 
class  Iterator
 Iterator for BSON values. More...
 
class  JsonString
 
class  MaxKey
 BSON MaxKey. More...
 
class  MemberMissingException
 BSON nonexisting member access error. More...
 
class  MinKey
 BSON MinKey. More...
 
class  Oid
 BSON ObjectId. More...
 
class  OutOfBoundsException
 BSON array indexing error. More...
 
class  ParseException
 BSON parsing error. More...
 
class  Timestamp
 BSON Timestamp. More...
 
class  TypeMismatchException
 BSON types mismatch error. More...
 
class  Value
 Non-mutable BSON value representation. More...
 
class  ValueBuilder
 Builder for BSON. More...
 

Functions

Document FromBinaryString (std::string_view binary)
 Recovers a BSON document from its binary form.
 
BsonString ToBinaryString (const formats::bson::Document &)
 Dumps a bson document to a binary string.
 
template<typename... Args>
Document MakeDoc (Args &&...)
 Constructs a Document from provided key-value pairs.
 
template<typename... Args>
Value MakeArray (Args &&...)
 Constructs an array Value from provided element list.
 
Document FromJsonString (std::string_view json)
 
Value ArrayFromJsonString (std::string_view json)
 
JsonString ToCanonicalJsonString (const formats::bson::Document &)
 
JsonString ToRelaxedJsonString (const formats::bson::Document &)
 
JsonString ToLegacyJsonString (const formats::bson::Document &)
 
JsonString ToArrayJsonString (const formats::bson::Value &)
 
std::ostream & operator<< (std::ostream &, const JsonString &)
 
logging::LogHelperoperator<< (logging::LogHelper &, const JsonString &)
 
logging::LogHelperoperator<< (logging::LogHelper &, const Document &)
 Uses formats::bson::ToRelaxedJsonString representation by default.
 

Variables

constexpr auto kNull = nullptr
 

Function Documentation

◆ ArrayFromJsonString()

Value formats::bson::ArrayFromJsonString ( std::string_view json)

Applies heuristics to convert JSON string to BSON array. As JSON have rather lax typing, some heuristics are applied to guess correct BSON types for values. It is strongly recommended to write your own conversion routines matching your schemas.

Warning
Stability of heuristics is not guaranteed, this is provided as-is.

◆ FromJsonString()

Document formats::bson::FromJsonString ( std::string_view json)

Applies heuristics to convert JSON string to BSON document. As JSON have rather lax typing, some heuristics are applied to guess correct BSON types for values. It is strongly recommended to write your own conversion routines matching your schemas.

Warning
Stability of heuristics is not guaranteed, this is provided as-is.

◆ ToArrayJsonString()

JsonString formats::bson::ToArrayJsonString ( const formats::bson::Value & )

Converts BSON array to a legacy libbson's JSON format, except the outermost element is encoded as a JSON array, rather than a JSON document.

◆ ToCanonicalJsonString()

JsonString formats::bson::ToCanonicalJsonString ( const formats::bson::Document & )

Converts BSON to a canonical MongoDB Extended JSON format.

See also
https://github.com/mongodb/specifications/blob/master/source/extended-json.rst

◆ ToLegacyJsonString()

JsonString formats::bson::ToLegacyJsonString ( const formats::bson::Document & )

Converts BSON to a legacy libbson's JSON format. Notable differences from other formats:

  • all numbers are not wrapped;
  • non-standard tokens for special floating point values;
  • dates are milliseconds since epoch;
  • different format for binaries.

◆ ToRelaxedJsonString()

JsonString formats::bson::ToRelaxedJsonString ( const formats::bson::Document & )

Converts BSON to a relaxed MongoDB Extended JSON format. Notable differences from canonical format are:

Variable Documentation

◆ kNull

constexpr auto formats::bson::kNull = nullptr
inlineconstexpr

Definition at line 37 of file types.hpp.