8#include <userver/formats/parse/to.hpp>
10USERVER_NAMESPACE_BEGIN
12namespace server::auth {
14class UserScope
final {
16 explicit UserScope(std::string value) : value_(std::move(value)) {}
18 const std::string& GetValue()
const {
return value_; }
24inline bool operator==(
const UserScope& lhs,
const UserScope& rhs) {
25 return lhs.GetValue() == rhs.GetValue();
28inline bool operator!=(
const UserScope& lhs,
const UserScope& rhs) {
29 return lhs.GetValue() != rhs.GetValue();
32inline bool operator==(
const UserScope& lhs, std::string_view rhs) {
33 return lhs.GetValue() == rhs;
36inline bool operator==(std::string_view lhs,
const UserScope& rhs) {
37 return lhs == rhs.GetValue();
40inline bool operator!=(
const UserScope& lhs, std::string_view rhs) {
41 return lhs.GetValue() != rhs;
44inline bool operator!=(std::string_view lhs,
const UserScope& rhs) {
45 return lhs != rhs.GetValue();
49UserScope Parse(
const Value& v, formats::
parse::
To<UserScope>) {
50 return UserScope{v.
template As<std::string>()};
53using UserScopes = std::vector<UserScope>;
61struct hash<USERVER_NAMESPACE::server::auth::UserScope> {
62 std::size_t operator()(
63 const USERVER_NAMESPACE::server::auth::UserScope& v)
const {
64 return std::hash<std::string>{}(v.GetValue());