Loading...
Searching...
No Matches
bsoncxx::oid Class Reference

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

## Description

Represents a MongoDB BSON ObjectId.

See also
  - BSON Types (MongoDB Manual)

## Public Member Functions

| oid ()
| Constructs an oid and initializes it to a newly generated ObjectId.
| oid (char const *bytes, std::size_t len)
| Constructs an oid initializes it to the contents of the provided buffer.
| oid (v1::oid const &oid) noexcept
| Construct with the bsoncxx::v1 equivalent.
| oid (v1::stdx::string_view const &str)
| Constructs an oid and initializes it from the provided hex string.
char const * | bytes () const
| An accessor for the internal data buffer in the oid.
int | compare (oid const &other) const
| Equivalent to bson_oid_compare.
std::time_t | get_time_t () const
| Extracts the timestamp portion of the underlying ObjectId.
| operator v1::oid () const noexcept
| Convert to the bsoncxx::v1 equivalent.
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< (oid const &lhs, oid const &rhs)
| Relational comparison operator.
bool | operator> (oid const &lhs, oid const &rhs)
| Relational comparison operator.
bool | operator<= (oid const &lhs, oid const &rhs)
| Relational comparison operator.
bool | operator>= (oid const &lhs, oid const &rhs)
| Relational comparison operator.
bool | operator== (oid const &lhs, oid const &rhs)
| Relational comparison operator.
bool | operator!= (oid const &lhs, oid const &rhs)
| Relational comparison operator.

## Constructor & Destructor Documentation

## oid() [1/4]

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

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

## oid() [2/4]

bsoncxx::v_noabi::oid::oid | ( | v1::oid const & | oid | ) |

inline noexcept

Construct with the bsoncxx::v1 equivalent.

## oid() [3/4]

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

explicit

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

Parameters

  bytes | A pointer a buffer containing a valid ObjectId.
  len | The length of the buffer. Should be equal to oid::size().

Exceptions

  bsoncxx::v_noabi::exception | if the length is not equal to oid::size().

## oid() [4/4]

bsoncxx::v_noabi::oid::oid | ( | v1::stdx::string_view const & | str | ) |

explicit

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

Parameters

  str | A string of a hexadecimal representation of a valid ObjectId.

Exceptions

  bsoncxx::v_noabi::exception | if the string isn't an OID-sized hex string.

## Member Function Documentation

## bytes()

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

inline

An accessor for the internal data buffer in the oid.

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

## compare()

int bsoncxx::v_noabi::oid::compare | ( | oid const & | other | ) | const

inline

Equivalent to bson_oid_compare.

## get_time_t()

std::time_t get_time_t | ( |  | ) | const

inline

Extracts the timestamp portion of the underlying ObjectId.

Returns
  A std::time_t initialized to the timestamp.

## operator v1::oid()

bsoncxx::v_noabi::oid::operator v1::oid | ( |  | ) | const

inline explicit noexcept

Convert to the bsoncxx::v1 equivalent.

## size()

std::size_t bsoncxx::v_noabi::oid::size | ( |  | ) |

inline static

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

inline

Converts this oid to a hexadecimal string.

Returns
  A hexadecimal string representation of this ObjectId.

## Friends And Related Symbol Documentation

## operator!=

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

friend

Relational comparison operator.

## operator<

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

friend

Relational comparison operator.

## operator<=

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

friend

Relational comparison operator.

## operator==

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

friend

Relational comparison operator.

## operator>

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

friend

Relational comparison operator.

## operator>=

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

friend

Relational comparison operator.

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

- bsoncxx/v_noabi/bsoncxx/oid.hpp