Permission: use std::string_view instead of StringView
This commit is contained in:
parent
04c924ae3b
commit
c7d2cb855a
@ -27,7 +27,7 @@
|
|||||||
#include "net/ToString.hxx"
|
#include "net/ToString.hxx"
|
||||||
#include "util/IterableSplitString.hxx"
|
#include "util/IterableSplitString.hxx"
|
||||||
#include "util/RuntimeError.hxx"
|
#include "util/RuntimeError.hxx"
|
||||||
#include "util/StringView.hxx"
|
#include "util/StringSplit.hxx"
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <map>
|
#include <map>
|
||||||
@ -62,14 +62,14 @@ static std::map<std::string, unsigned> host_passwords;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
static unsigned
|
static unsigned
|
||||||
ParsePermission(StringView s)
|
ParsePermission(std::string_view s)
|
||||||
{
|
{
|
||||||
for (auto i = permission_names; i->name != nullptr; ++i)
|
for (auto i = permission_names; i->name != nullptr; ++i)
|
||||||
if (s.Equals(i->name))
|
if (s == i->name)
|
||||||
return i->value;
|
return i->value;
|
||||||
|
|
||||||
throw FormatRuntimeError("unknown permission \"%.*s\"",
|
throw FormatRuntimeError("unknown permission \"%.*s\"",
|
||||||
int(s.size), s.data);
|
int(s.size()), s.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned
|
static unsigned
|
||||||
@ -99,10 +99,10 @@ initPermissions(const ConfigData &config)
|
|||||||
for (const auto ¶m : config.GetParamList(ConfigOption::PASSWORD)) {
|
for (const auto ¶m : config.GetParamList(ConfigOption::PASSWORD)) {
|
||||||
permission_default = 0;
|
permission_default = 0;
|
||||||
|
|
||||||
param.With([](const StringView value){
|
param.With([](const std::string_view value){
|
||||||
const auto [password, permissions] =
|
const auto [password, permissions] =
|
||||||
value.Split(PERMISSION_PASSWORD_CHAR);
|
Split(value, PERMISSION_PASSWORD_CHAR);
|
||||||
if (permissions == nullptr)
|
if (permissions.data() == nullptr)
|
||||||
throw FormatRuntimeError("\"%c\" not found in password string",
|
throw FormatRuntimeError("\"%c\" not found in password string",
|
||||||
PERMISSION_PASSWORD_CHAR);
|
PERMISSION_PASSWORD_CHAR);
|
||||||
|
|
||||||
@ -128,8 +128,8 @@ initPermissions(const ConfigData &config)
|
|||||||
for (const auto ¶m : config.GetParamList(ConfigOption::HOST_PERMISSIONS)) {
|
for (const auto ¶m : config.GetParamList(ConfigOption::HOST_PERMISSIONS)) {
|
||||||
permission_default = 0;
|
permission_default = 0;
|
||||||
|
|
||||||
param.With([](StringView value){
|
param.With([](std::string_view value){
|
||||||
auto [host_sv, permissions_s] = value.Split(' ');
|
auto [host_sv, permissions_s] = Split(value, ' ');
|
||||||
unsigned permissions = parsePermissions(permissions_s);
|
unsigned permissions = parsePermissions(permissions_s);
|
||||||
|
|
||||||
const std::string host_s{host_sv};
|
const std::string host_s{host_sv};
|
||||||
|
Loading…
Reference in New Issue
Block a user