MongoDB C++ Driver mongocxx-4.0.0
Loading...
Searching...
No Matches
bsoncxx::v_noabi::oid Class Reference

#include <bsoncxx/v_noabi/bsoncxx/oid.hpp>

Description

Represents a MongoDB ObjectId. As this BSON type is used within the MongoDB server as a primary key for each document, it is useful for representing a 'pointer' to another document.

Note
we use 'oid' to refer to this concrete class. We use 'ObjectId' to refer to the BSON type.
See also

Public Member Functions

 oid ()
 Constructs an oid and initializes it to a newly generated ObjectId.
 
 oid (const char *bytes, std::size_t len)
 Constructs an oid initializes it to the contents of the provided buffer.
 
 oid (const stdx::string_view &str)
 Constructs an oid and initializes it from the provided hex string.
 
const char * bytes () const
 An accessor for the internal data buffer in the oid.
 
std::time_t get_time_t () const
 Extracts the timestamp portion of the underlying ObjectId.
 
std::string to_string () const
 Converts this oid to a hexadecimal string.
 

Static Public Member Functions

static std::size_t size ()
 Returns the number of bytes in this ObjectId.
 

Related Symbols

(Note that these are not member symbols.)

bool operator< (const oid &lhs, const oid &rhs)
 Relational operators for OIDs.
 
bool operator> (const oid &lhs, const oid &rhs)
 Relational operators for OIDs.
 
bool operator<= (const oid &lhs, const oid &rhs)
 Relational operators for OIDs.
 
bool operator>= (const oid &lhs, const oid &rhs)
 Relational operators for OIDs.
 
bool operator== (const oid &lhs, const oid &rhs)
 Relational operators for OIDs.
 
bool operator!= (const oid &lhs, const oid &rhs)
 Relational operators for OIDs.
 

Constructor & Destructor Documentation

◆ oid() [1/3]

bsoncxx::v_noabi::oid::oid ( )

Constructs an oid and initializes it to a newly generated ObjectId.

◆ oid() [2/3]

bsoncxx::v_noabi::oid::oid ( const char * bytes,
std::size_t len )
explicit

Constructs an oid initializes it to the contents of the provided buffer.

Parameters
bytesA pointer a buffer containing a valid ObjectId.
lenThe length of the buffer. Should be equal to oid::size().
Exceptions
bsoncxx::v_noabi::exceptionif the length is not equal to oid::size().

◆ oid() [3/3]

bsoncxx::v_noabi::oid::oid ( const stdx::string_view & str)
explicit

Constructs an oid and initializes it from the provided hex string.

Parameters
strA string of a hexadecimal representation of a valid ObjectId.
Exceptions
bsoncxx::v_noabi::exceptionif the string isn't an OID-sized hex string.

Member Function Documentation

◆ bytes()

const char * bsoncxx::v_noabi::oid::bytes ( ) const

An accessor for the internal data buffer in the oid.

Returns
A pointer to the internal buffer holding the oid bytes.

◆ get_time_t()

std::time_t get_time_t ( ) const

Extracts the timestamp portion of the underlying ObjectId.

Returns
A std::time_t initialized to the timestamp.

◆ size()

static std::size_t bsoncxx::v_noabi::oid::size ( )
inlinestatic

Returns the number of bytes in this ObjectId.

Returns
The length of this oid's buffer.

◆ to_string()

std::string bsoncxx::v_noabi::oid::to_string ( ) const

Converts this oid to a hexadecimal string.

Returns
A hexadecimal string representation of this ObjectId.

Friends And Related Symbol Documentation

◆ operator!=

bool operator!= ( const oid & lhs,
const oid & rhs )
friend

Relational operators for OIDs.

◆ operator<

bool operator< ( const oid & lhs,
const oid & rhs )
friend

Relational operators for OIDs.

◆ operator<=

bool operator<= ( const oid & lhs,
const oid & rhs )
friend

Relational operators for OIDs.

◆ operator==

bool operator== ( const oid & lhs,
const oid & rhs )
friend

Relational operators for OIDs.

◆ operator>

bool operator> ( const oid & lhs,
const oid & rhs )
friend

Relational operators for OIDs.

◆ operator>=

bool operator>= ( const oid & lhs,
const oid & rhs )
friend

Relational operators for OIDs.


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