11#include <userver/formats/parse/to.hpp>
13USERVER_NAMESPACE_BEGIN
15namespace server::auth {
17class UserScope
final {
19 explicit UserScope(std::string value)
20 : value_(std::move(value))
23 const std::string& GetValue()
const {
return value_; }
29inline bool operator==(
const UserScope& lhs,
const UserScope& rhs) {
return lhs.GetValue() == rhs.GetValue(); }
31inline bool operator!=(
const UserScope& lhs,
const UserScope& rhs) {
return lhs.GetValue() != rhs.GetValue(); }
33inline bool operator==(
const UserScope& lhs, std::string_view rhs) {
return lhs.GetValue() == rhs; }
35inline bool operator==(std::string_view lhs,
const UserScope& rhs) {
return lhs == rhs.GetValue(); }
37inline bool operator!=(
const UserScope& lhs, std::string_view rhs) {
return lhs.GetValue() != rhs; }
39inline bool operator!=(std::string_view lhs,
const UserScope& rhs) {
return lhs != rhs.GetValue(); }
42UserScope Parse(
const Value& v, formats::
parse::To<UserScope>) {
43 return UserScope{v.
template As<std::string>()};
46using UserScopes = std::vector<UserScope>;
54struct 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());