mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-14 02:27:39 -04:00
tagtree/tagcache add new clause operators begins/ends _oneof
new operators @^, @$ begins_oneof and ends_oneof albumartist @^ "L|The L" Led Zeppelin, The look albumartist @$ "girls|Boys" spice girls, beasty boys Change-Id: I26ce3d8155d970a55e003f74e2f9478db76204f1
This commit is contained in:
parent
0f2d623216
commit
ddbca125a6
3 changed files with 31 additions and 2 deletions
|
@ -162,6 +162,8 @@ static const char *tag_type_str[] = {
|
||||||
[clause_ends_with] = "clause_ends_with",
|
[clause_ends_with] = "clause_ends_with",
|
||||||
[clause_not_ends_with] = "clause_not_ends_with",
|
[clause_not_ends_with] = "clause_not_ends_with",
|
||||||
[clause_oneof] = "clause_oneof",
|
[clause_oneof] = "clause_oneof",
|
||||||
|
[clause_begins_oneof] = "clause_begins_oneof",
|
||||||
|
[clause_ends_oneof] = "clause_ends_oneof",
|
||||||
[clause_logical_or] = "clause_logical_or"
|
[clause_logical_or] = "clause_logical_or"
|
||||||
};
|
};
|
||||||
#define logf_clauses logf
|
#define logf_clauses logf
|
||||||
|
@ -1052,6 +1054,25 @@ inline static bool str_oneof(const char *str, const char *list)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline static bool str_begins_ends_oneof(const char *str, const char *list, bool begins)
|
||||||
|
{
|
||||||
|
logf_clauses("%s %s (%s) %s", str, __func__, begins ? "begins" : "ends", list);
|
||||||
|
const char *sep;
|
||||||
|
int l, p, len = strlen(str);
|
||||||
|
|
||||||
|
while (*list)
|
||||||
|
{
|
||||||
|
sep = strchr(list, '|');
|
||||||
|
l = sep ? (intptr_t)sep - (intptr_t)list : (int)strlen(list);
|
||||||
|
p = begins ? 0 : len - l;
|
||||||
|
if (l <= len && !strncasecmp(&str[p], list, l))
|
||||||
|
return true;
|
||||||
|
list += sep ? l + 1 : l;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
static bool check_against_clause(long numeric, const char *str,
|
static bool check_against_clause(long numeric, const char *str,
|
||||||
const struct tagcache_search_clause *clause)
|
const struct tagcache_search_clause *clause)
|
||||||
{
|
{
|
||||||
|
@ -1105,6 +1126,10 @@ static bool check_against_clause(long numeric, const char *str,
|
||||||
return !str_ends_with(str, clause->str);
|
return !str_ends_with(str, clause->str);
|
||||||
case clause_oneof:
|
case clause_oneof:
|
||||||
return str_oneof(str, clause->str);
|
return str_oneof(str, clause->str);
|
||||||
|
case clause_begins_oneof:
|
||||||
|
return str_begins_ends_oneof(str, clause->str, true);
|
||||||
|
case clause_ends_oneof:
|
||||||
|
return str_begins_ends_oneof(str, clause->str, false);
|
||||||
default:
|
default:
|
||||||
logf("Incorrect tag: %d", clause->type);
|
logf("Incorrect tag: %d", clause->type);
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,7 +127,9 @@ enum tag_type { tag_artist = 0, tag_album, tag_genre, tag_title,
|
||||||
enum clause { clause_none, clause_is, clause_is_not, clause_gt, clause_gteq,
|
enum clause { clause_none, clause_is, clause_is_not, clause_gt, clause_gteq,
|
||||||
clause_lt, clause_lteq, clause_contains, clause_not_contains,
|
clause_lt, clause_lteq, clause_contains, clause_not_contains,
|
||||||
clause_begins_with, clause_not_begins_with, clause_ends_with,
|
clause_begins_with, clause_not_begins_with, clause_ends_with,
|
||||||
clause_not_ends_with, clause_oneof, clause_logical_or };
|
clause_not_ends_with, clause_oneof,
|
||||||
|
clause_begins_oneof, clause_ends_oneof,
|
||||||
|
clause_logical_or };
|
||||||
|
|
||||||
struct tagcache_stat {
|
struct tagcache_stat {
|
||||||
bool initialized; /* Is tagcache currently busy? */
|
bool initialized; /* Is tagcache currently busy? */
|
||||||
|
|
|
@ -418,6 +418,8 @@ static int get_clause(int *condition)
|
||||||
CLAUSE('!', '^', clause_not_begins_with),
|
CLAUSE('!', '^', clause_not_begins_with),
|
||||||
CLAUSE('$', ' ', clause_ends_with),
|
CLAUSE('$', ' ', clause_ends_with),
|
||||||
CLAUSE('!', '$', clause_not_ends_with),
|
CLAUSE('!', '$', clause_not_ends_with),
|
||||||
|
CLAUSE('@', '^', clause_begins_oneof),
|
||||||
|
CLAUSE('@', '$', clause_ends_oneof),
|
||||||
CLAUSE('@', ' ', clause_oneof)
|
CLAUSE('@', ' ', clause_oneof)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue