util/StringVerify: new library
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
#include "Partition.hxx"
|
||||
#include "IdleFlags.hxx"
|
||||
#include "util/CharUtil.hxx"
|
||||
#include "util/StringVerify.hxx"
|
||||
|
||||
CommandResult
|
||||
handle_enableoutput(Client &client, Request args, Response &r)
|
||||
@@ -62,22 +63,16 @@ handle_toggleoutput(Client &client, Request args, Response &r)
|
||||
return CommandResult::OK;
|
||||
}
|
||||
|
||||
static bool
|
||||
static constexpr bool
|
||||
IsValidAttributeNameChar(char ch) noexcept
|
||||
{
|
||||
return IsAlphaNumericASCII(ch) || ch == '_';
|
||||
}
|
||||
|
||||
[[gnu::pure]]
|
||||
static bool
|
||||
static constexpr bool
|
||||
IsValidAttributeName(const char *s) noexcept
|
||||
{
|
||||
do {
|
||||
if (!IsValidAttributeNameChar(*s))
|
||||
return false;
|
||||
} while (*++s);
|
||||
|
||||
return true;
|
||||
return CheckCharsNonEmpty(s, IsValidAttributeNameChar);
|
||||
}
|
||||
|
||||
CommandResult
|
||||
|
@@ -10,6 +10,7 @@
|
||||
#include "client/Client.hxx"
|
||||
#include "client/Response.hxx"
|
||||
#include "util/CharUtil.hxx"
|
||||
#include "util/StringVerify.hxx"
|
||||
|
||||
#include <fmt/format.h>
|
||||
|
||||
@@ -39,21 +40,15 @@ handle_listpartitions(Client &client, Request, Response &r)
|
||||
}
|
||||
|
||||
static constexpr bool
|
||||
IsValidPartitionChar(char ch)
|
||||
IsValidPartitionChar(char ch) noexcept
|
||||
{
|
||||
return IsAlphaNumericASCII(ch) || ch == '-' || ch == '_';
|
||||
}
|
||||
|
||||
[[gnu::pure]]
|
||||
static bool
|
||||
static constexpr bool
|
||||
IsValidPartitionName(const char *name) noexcept
|
||||
{
|
||||
do {
|
||||
if (!IsValidPartitionChar(*name))
|
||||
return false;
|
||||
} while (*++name != 0);
|
||||
|
||||
return true;
|
||||
return CheckCharsNonEmpty(name, IsValidPartitionChar);
|
||||
}
|
||||
|
||||
[[gnu::pure]]
|
||||
|
Reference in New Issue
Block a user