userver: userver/utils/boost_uuid4.hpp Source File
Loading...
Searching...
No Matches
boost_uuid4.hpp
Go to the documentation of this file.
1#pragma once
2
3/// @file userver/utils/boost_uuid4.hpp
4/// @brief @copybrief utils::generators::GenerateBoostUuid()
5
6#include <boost/uuid/uuid.hpp>
7
8#include <fmt/core.h>
9#include <userver/utils/fmt_compat.hpp>
10
11USERVER_NAMESPACE_BEGIN
12
13namespace utils {
14
15/// Generators
16namespace generators {
17
18/// Generates UUIDv4
19boost::uuids::uuid GenerateBoostUuid();
20
21} // namespace generators
22
23/// Parse string into boost::uuids::uuid
24boost::uuids::uuid BoostUuidFromString(std::string_view str);
25
26/// Serialize boost::uuids::uuid to string
28
29} // namespace utils
30
31USERVER_NAMESPACE_END
32
33template <>
34struct fmt::formatter<boost::uuids::uuid> {
35 constexpr static auto parse(format_parse_context& ctx)
36 -> decltype(ctx.begin()) {
37 return ctx.begin();
38 }
39
40 template <typename FormatContext>
41 auto format(const boost::uuids::uuid& uuid,
42 FormatContext& ctx) USERVER_FMT_CONST {
43 return fmt::format_to(ctx.out(), "{}",
44 USERVER_NAMESPACE::utils::ToString(uuid));
45 }
46};