mirror of
https://github.com/NixOS/nix
synced 2025-06-27 16:51:15 +02:00
regex-combinators: fix linter error when adding string_view and string
This commit is contained in:
parent
3392a96901
commit
6848154b2e
1 changed files with 10 additions and 8 deletions
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
namespace nix::regex {
|
namespace nix::regex {
|
||||||
|
|
||||||
|
@ -11,22 +12,23 @@ namespace nix::regex {
|
||||||
|
|
||||||
static inline std::string either(std::string_view a, std::string_view b)
|
static inline std::string either(std::string_view a, std::string_view b)
|
||||||
{
|
{
|
||||||
return std::string { a } + "|" + b;
|
std::stringstream ss;
|
||||||
|
ss << a << "|" << b;
|
||||||
|
return ss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline std::string group(std::string_view a)
|
static inline std::string group(std::string_view a)
|
||||||
{
|
{
|
||||||
return std::string { "(" } + a + ")";
|
std::stringstream ss;
|
||||||
}
|
ss << "(" << a << ")";
|
||||||
|
return ss.str();
|
||||||
static inline std::string many(std::string_view a)
|
|
||||||
{
|
|
||||||
return std::string { "(?:" } + a + ")*";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline std::string list(std::string_view a)
|
static inline std::string list(std::string_view a)
|
||||||
{
|
{
|
||||||
return std::string { a } + many(group("," + a));
|
std::stringstream ss;
|
||||||
|
ss << a << "(," << a << ")*";
|
||||||
|
return ss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue