8#include <userver/formats/parse/to.hpp>
10USERVER_NAMESPACE_BEGIN
12namespace server::auth {
14class UserScope
final {
16 explicit UserScope(std::string value)
17 : value_(std::move(value))
20 const std::string& GetValue()
const {
return value_; }
26inline bool operator==(
const UserScope& lhs,
const UserScope& rhs) {
return lhs.GetValue() == rhs.GetValue(); }
28inline bool operator!=(
const UserScope& lhs,
const UserScope& rhs) {
return lhs.GetValue() != rhs.GetValue(); }
30inline bool operator==(
const UserScope& lhs, std::string_view rhs) {
return lhs.GetValue() == rhs; }
32inline bool operator==(std::string_view lhs,
const UserScope& rhs) {
return lhs == rhs.GetValue(); }
34inline bool operator!=(
const UserScope& lhs, std::string_view rhs) {
return lhs.GetValue() != rhs; }
36inline bool operator!=(std::string_view lhs,
const UserScope& rhs) {
return lhs != rhs.GetValue(); }
40 return UserScope{v.
template As<std::string>()};
43using UserScopes = std::vector<UserScope>;
51struct hash<USERVER_NAMESPACE::server::auth::UserScope> {
52 std::size_t operator()(
const USERVER_NAMESPACE::server::auth::UserScope& v)
const {
53 return std::hash<std::string>{}(v.GetValue());