11#include <unordered_map>
16#include <userver/formats/common/path.hpp>
18USERVER_NAMESPACE_BEGIN
20namespace formats::
bson {
23#pragma GCC diagnostic push
24#pragma GCC diagnostic ignored "-Wignored-attributes"
25using BsonHolder = std::shared_ptr<
const bson_t>;
26#pragma GCC diagnostic pop
29using ValueImplPtr = std::shared_ptr<ValueImpl>;
31using ParsedArray = std::vector<ValueImplPtr>;
32using ParsedDocument = std::unordered_map<std::string, ValueImplPtr>;
35using formats::
common::Path;
37inline constexpr auto kNull =
nullptr;
46 explicit Oid(std::string_view hex_encoded);
56 Oid(
const bson_oid_t&);
64 const uint8_t* Data()
const;
66 constexpr static size_t Size() {
return 12; }
77 const bson_oid_t* GetNative()
const;
80 bool operator==(
const Oid&)
const;
81 bool operator!=(
const Oid&)
const;
82 bool operator<(
const Oid&)
const;
83 bool operator>(
const Oid&)
const;
84 bool operator<=(
const Oid&)
const;
85 bool operator>=(
const Oid&)
const;
88 friend struct std::hash<
Oid>;
97 explicit Binary(std::string data) : data_(std::move(data)) {}
101 const std::string& ToString()
const& {
return data_; }
102 std::string&& ToString() && {
return std::move(data_); }
104 const uint8_t* Data()
const {
105 return reinterpret_cast<
const uint8_t*>(data_.data());
107 size_t Size()
const {
return data_.size(); }
110 bool operator==(
const Binary& rhs)
const {
return data_ == rhs.data_; }
111 bool operator!=(
const Binary& rhs)
const {
return data_ != rhs.data_; }
112 bool operator<(
const Binary& rhs)
const {
return data_ < rhs.data_; }
113 bool operator>(
const Binary& rhs)
const {
return data_ > rhs.data_; }
114 bool operator<=(
const Binary& rhs)
const {
return data_ <= rhs.data_; }
115 bool operator>=(
const Binary& rhs)
const {
return data_ >= rhs.data_; }
118 friend struct std::hash<
Binary>;
147 const bson_decimal128_t* GetNative()
const;
154 bson_decimal128_t decimal_;
195 uint32_t timestamp_{0};
196 uint32_t increment_{0};
206struct hash<USERVER_NAMESPACE::formats::
bson::
Oid> {
207 size_t operator()(
const USERVER_NAMESPACE::formats::
bson::
Oid&)
const;
213 const USERVER_NAMESPACE::formats::
bson::
Binary& binary)
const {
214 return hash<string>()(binary.data_);
221 const USERVER_NAMESPACE::formats::
bson::
Timestamp& timestamp)
const;