userver: userver/formats/serialize/boost_uuid.hpp Source File
Loading...
Searching...
No Matches
boost_uuid.hpp
Go to the documentation of this file.
1#pragma once
2
3/// @file userver/formats/serialize/boost_uuid.hpp
4/// @brief boost::uuids::uuid serializer to any format
5/// @ingroup userver_universal userver_formats_serialize
6
7#include <boost/uuid/uuid.hpp>
8#include <string>
9
10#include <userver/formats/serialize/to.hpp>
11
12USERVER_NAMESPACE_BEGIN
13
14namespace formats::serialize {
15
16namespace detail {
17
18std::string ToString(const boost::uuids::uuid& value);
19
20} // namespace detail
21
22/// Outputs UUID in format: 12345678-1234-1234-1234-123412345678
23template <typename Value>
24Value Serialize(const boost::uuids::uuid& value, To<Value>) {
25 return typename Value::Builder(detail::ToString(value)).ExtractValue();
26}
27
28template <typename StringBuilder>
29void WriteToStream(const boost::uuids::uuid& value, StringBuilder& sw) {
30 WriteToStream(detail::ToString(value), sw);
31}
32
33} // namespace formats::serialize
34
35USERVER_NAMESPACE_END