userver
C++ Async Framework
Toggle main menu visibility
Loading...
Searching...
No Matches
user_scopes.hpp
Go to the documentation of this file.
1
#
pragma
once
2
3
/// @file userver/server/auth/user_scopes.hpp
4
/// @brief User authorization scope types
5
6
#
include
<
functional
>
7
#
include
<
string
>
8
#
include
<
string_view
>
9
#
include
<
vector
>
10
11
#
include
<
userver
/
formats
/
parse
/
to
.
hpp
>
12
13
USERVER_NAMESPACE_BEGIN
14
15
namespace
server::auth {
16
17
class
UserScope
final
{
18
public
:
19
explicit
UserScope(std::string value)
20
: value_(std::move(value))
21
{}
22
23
const
std::string& GetValue()
const
{
return
value_; }
24
25
private
:
26
std::string value_;
27
};
28
29
inline
bool
operator==(
const
UserScope& lhs,
const
UserScope& rhs) {
return
lhs.GetValue() == rhs.GetValue(); }
30
31
inline
bool
operator!=(
const
UserScope& lhs,
const
UserScope& rhs) {
return
lhs.GetValue() != rhs.GetValue(); }
32
33
inline
bool
operator==(
const
UserScope& lhs, std::string_view rhs) {
return
lhs.GetValue() == rhs; }
34
35
inline
bool
operator==(std::string_view lhs,
const
UserScope& rhs) {
return
lhs == rhs.GetValue(); }
36
37
inline
bool
operator!=(
const
UserScope& lhs, std::string_view rhs) {
return
lhs.GetValue() != rhs; }
38
39
inline
bool
operator!=(std::string_view lhs,
const
UserScope& rhs) {
return
lhs != rhs.GetValue(); }
40
41
template
<
class
Value>
42
UserScope Parse(
const
Value& v, formats::
parse
::
To
<UserScope>) {
43
return
UserScope{v.
template
As<std::string>()};
44
}
45
46
using
UserScopes = std::vector<UserScope>;
47
48
}
// namespace server::auth
49
50
USERVER_NAMESPACE_END
51
52
namespace
std {
53
template
<>
54
struct
hash
<USERVER_NAMESPACE::server::auth::UserScope> {
55
std::size_t operator()(
const
USERVER_NAMESPACE::server::auth::UserScope& v)
const
{
56
return
std::hash<std::string>{}(v.GetValue());
57
}
58
};
59
}
// namespace std
userver
server
auth
user_scopes.hpp
Generated on
for userver by
Doxygen
1.17.0