userver: formats::bson::Oid Class Reference
Loading...
Searching...
No Matches
formats::bson::Oid Class Reference

#include <userver/formats/bson/types.hpp>

Detailed Description

BSON ObjectId.

Definition at line 40 of file types.hpp.

Public Member Functions

 Oid ()
 Generates a new id.
 
 Oid (std::string_view hex_encoded)
 Constructor from hex-encoded form, zero terminator is not required.
 
std::string ToString () const
 Returns hex-encoded value.
 
time_t GetTimestamp () const
 Returns stored unix timestamp.
 
std::chrono::system_clock::time_point GetTimePoint () const
 Returns stored time point.
 
bool operator== (const Oid &) const
 
bool operator!= (const Oid &) const
 
bool operator< (const Oid &) const
 
bool operator> (const Oid &) const
 
bool operator<= (const Oid &) const
 
bool operator>= (const Oid &) const
 

Static Public Member Functions

static Oid MakeMinimalFor (std::chrono::system_clock::time_point time)
 

Raw value access

const uint8_t * Data () const
 
static constexpr size_t Size ()
 

Member Function Documentation

◆ MakeMinimalFor()

static Oid formats::bson::Oid::MakeMinimalFor ( std::chrono::system_clock::time_point time)
static

Creates a minimal Oid with specified time point up to a second precision

Exceptions
formats::bson::BsonExceptionif time is too big to be stored in ObjectId without narrowing.
Examples
samples/mongo_service/mongo_service.cpp.

◆ Size()

static constexpr size_t formats::bson::Oid::Size ( )
inlinestaticconstexpr

Definition at line 66 of file types.hpp.

Friends And Related Symbol Documentation

◆ std::hash< Oid >

friend struct std::hash< Oid >
friend

Definition at line 85 of file types.hpp.


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