userver: userver/formats/bson/binary.hpp Source File
Loading...
Searching...
No Matches
binary.hpp
Go to the documentation of this file.
1#pragma once
2
3/// @file userver/formats/bson/binary.hpp
4/// @brief Binary representation helpers
5
6#include <string>
7#include <string_view>
8
9#include <userver/formats/bson/document.hpp>
10#include <userver/formats/bson/types.hpp>
11
12USERVER_NAMESPACE_BEGIN
13
14namespace formats::bson {
15
16/// Wraps BSON binary representation
17class BsonString;
18
19/// Recovers a BSON document from its binary form
20Document FromBinaryString(std::string_view binary);
21
22/// Dumps a bson document to a binary string
24
25namespace impl {
26class BsonStringImpl;
27} // namespace impl
28
30public:
31 /// @cond
32 explicit BsonString(impl::BsonHolder);
33 /// @endcond
34
35 /// Implicitly convertible to string
36 /*implicit*/ operator std::string() const { return ToString(); }
37
38 /// Returns a copy of the binary
39 std::string ToString() const;
40
41 /// Returns a view of the binary
43
44 const uint8_t* Data() const;
45 size_t Size() const;
46
47private:
48 impl::BsonHolder impl_;
49};
50
51} // namespace formats::bson
52
53USERVER_NAMESPACE_END