userver
C++ Async Framework
Loading...
Searching...
No Matches
user_id.hpp
Go to the documentation of this file.
1
#
pragma
once
2
3
/// @file userver/server/auth/user_id.hpp
4
/// @brief @copybrief server::auth::UserId
5
6
#
include
<
cstdint
>
7
#
include
<
iosfwd
>
8
#
include
<
string
>
9
#
include
<
vector
>
10
11
#
include
<
userver
/
formats
/
parse
/
to
.
hpp
>
12
13
USERVER_NAMESPACE_BEGIN
14
15
namespace
logging {
16
class
LogHelper;
17
}
18
19
namespace
server::auth {
20
21
/// @brief Strongly typed user identifier (uid)
22
///
23
/// Type that represents a yandex uid and has all the comparison and hashing
24
/// operators. It is not implicitly convertible to/from integers and provides
25
/// better type safety.
26
enum
class
UserId
:
std
::
uint64_t
{};
27
28
using
UserIds = std::vector<
UserId
>;
29
30
template
<
class
Value>
31
UserId
Parse(
const
Value& v, formats::
parse
::To<
UserId
>) {
32
return
UserId
{v.
template
As<std::uint64_t>()};
33
}
34
35
inline
std::uint64_t ToUInt64(
UserId
v)
noexcept
{
return
static_cast
<std::uint64_t>(v); }
36
37
std::string ToString(
UserId
v);
38
39
template
<
class
Char>
40
std::basic_ostream<Char>& operator<<(std::basic_ostream<Char>& os,
UserId
v) {
41
return
os << ToUInt64(v);
42
}
43
44
// Optimized output for LogHelper
45
logging::LogHelper& operator<<(logging::LogHelper& os,
UserId
v);
46
47
}
// namespace server::auth
48
49
USERVER_NAMESPACE_END
userver
server
auth
user_id.hpp
Generated on Thu May 21 2026 16:19:08 for userver by
Doxygen
1.13.2