song/Filter: use std::span instead of ConstBuffer
This commit is contained in:
parent
6c107443d3
commit
4fb8b45111
@ -30,7 +30,6 @@
|
|||||||
#include "tag/ParseName.hxx"
|
#include "tag/ParseName.hxx"
|
||||||
#include "time/ISO8601.hxx"
|
#include "time/ISO8601.hxx"
|
||||||
#include "util/CharUtil.hxx"
|
#include "util/CharUtil.hxx"
|
||||||
#include "util/ConstBuffer.hxx"
|
|
||||||
#include "util/RuntimeError.hxx"
|
#include "util/RuntimeError.hxx"
|
||||||
#include "util/StringCompare.hxx"
|
#include "util/StringCompare.hxx"
|
||||||
#include "util/StringStrip.hxx"
|
#include "util/StringStrip.hxx"
|
||||||
@ -410,14 +409,15 @@ SongFilter::Parse(const char *tag_string, const char *value, bool fold_case)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SongFilter::Parse(ConstBuffer<const char *> args, bool fold_case)
|
SongFilter::Parse(std::span<const char *const> args, bool fold_case)
|
||||||
{
|
{
|
||||||
if (args.empty())
|
if (args.empty())
|
||||||
throw std::runtime_error("Incorrect number of filter arguments");
|
throw std::runtime_error("Incorrect number of filter arguments");
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if (*args.front() == '(') {
|
if (*args.front() == '(') {
|
||||||
const char *s = args.shift();
|
const char *s = args.front();
|
||||||
|
args = args.subspan(1);
|
||||||
const char *end = s;
|
const char *end = s;
|
||||||
auto f = ParseExpression(end, fold_case);
|
auto f = ParseExpression(end, fold_case);
|
||||||
if (*end != 0)
|
if (*end != 0)
|
||||||
@ -427,11 +427,12 @@ SongFilter::Parse(ConstBuffer<const char *> args, bool fold_case)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.size < 2)
|
if (args.size() < 2)
|
||||||
throw std::runtime_error("Incorrect number of filter arguments");
|
throw std::runtime_error("Incorrect number of filter arguments");
|
||||||
|
|
||||||
const char *tag = args.shift();
|
const char *tag = args[0];
|
||||||
const char *value = args.shift();
|
const char *value = args[1];
|
||||||
|
args = args.subspan(2);
|
||||||
Parse(tag, value, fold_case);
|
Parse(tag, value, fold_case);
|
||||||
} while (!args.empty());
|
} while (!args.empty());
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include "AndSongFilter.hxx"
|
#include "AndSongFilter.hxx"
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#include <span>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
|
|
||||||
@ -36,7 +37,6 @@
|
|||||||
*/
|
*/
|
||||||
#define SORT_TAG_PRIO (TAG_NUM_OF_ITEM_TYPES + 4)
|
#define SORT_TAG_PRIO (TAG_NUM_OF_ITEM_TYPES + 4)
|
||||||
|
|
||||||
template<typename T> struct ConstBuffer;
|
|
||||||
enum TagType : uint8_t;
|
enum TagType : uint8_t;
|
||||||
struct LightSong;
|
struct LightSong;
|
||||||
|
|
||||||
@ -68,7 +68,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Throws on error.
|
* Throws on error.
|
||||||
*/
|
*/
|
||||||
void Parse(ConstBuffer<const char *> args, bool fold_case=false);
|
void Parse(std::span<const char *const> args, bool fold_case=false);
|
||||||
|
|
||||||
void Optimize() noexcept;
|
void Optimize() noexcept;
|
||||||
|
|
||||||
|
@ -23,7 +23,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "song/Filter.hxx"
|
#include "song/Filter.hxx"
|
||||||
#include "util/ConstBuffer.hxx"
|
|
||||||
#include "util/PrintException.hxx"
|
#include "util/PrintException.hxx"
|
||||||
|
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
@ -39,7 +38,7 @@ try {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SongFilter filter;
|
SongFilter filter;
|
||||||
filter.Parse(ConstBuffer<const char *>(argv + 1, argc - 1));
|
filter.Parse({argv + 1, std::size_t(argc - 1)});
|
||||||
filter.Optimize();
|
filter.Optimize();
|
||||||
|
|
||||||
puts(filter.ToExpression().c_str());
|
puts(filter.ToExpression().c_str());
|
||||||
|
Loading…
Reference in New Issue
Block a user