Allow relaxed target matching

This commit is contained in:
Martchus 2021-12-31 00:40:36 +01:00
parent 34282ebbe9
commit c71fde86ec
4 changed files with 15 additions and 5 deletions

View File

@ -13,8 +13,8 @@ set(META_APP_DESCRIPTION
set(META_GUI_OPTIONAL true) set(META_GUI_OPTIONAL true)
set(META_JS_SRC_DIR renamingutility) set(META_JS_SRC_DIR renamingutility)
set(META_VERSION_MAJOR 3) set(META_VERSION_MAJOR 3)
set(META_VERSION_MINOR 5) set(META_VERSION_MINOR 6)
set(META_VERSION_PATCH 2) set(META_VERSION_PATCH 0)
set(META_ADD_DEFAULT_CPP_UNIT_TEST_APPLICATION ON) set(META_ADD_DEFAULT_CPP_UNIT_TEST_APPLICATION ON)
# add project files # add project files
@ -199,7 +199,7 @@ if (WIDGETS_GUI OR QUICK_GUI)
endif () endif ()
# find tagparser # find tagparser
find_package(tagparser${CONFIGURATION_PACKAGE_SUFFIX} 10.1.0 REQUIRED) find_package(tagparser${CONFIGURATION_PACKAGE_SUFFIX} 10.4.0 REQUIRED)
use_tag_parser() use_tag_parser()
# enable experimental JSON export # enable experimental JSON export

View File

@ -579,6 +579,12 @@ FieldDenotations parseFieldDenotations(const Argument &fieldsArg, bool readOnly)
continue; continue;
} else if (applyTargetConfiguration(scope.tagTarget, fieldDenotationString)) { } else if (applyTargetConfiguration(scope.tagTarget, fieldDenotationString)) {
continue; continue;
} else if (!strcmp(fieldDenotationString, "target-matching=exact")) {
scope.exactTargetMatching = true;
continue;
} else if (!strcmp(fieldDenotationString, "target-matching=relaxed")) {
scope.exactTargetMatching = false;
continue;
} else if (!strncmp(fieldDenotationString, "track-id=", 9)) { } else if (!strncmp(fieldDenotationString, "track-id=", 9)) {
const vector<string> parts = splitString<vector<string>>(fieldDenotationString + 9, ",", EmptyPartsTreat::Omit); const vector<string> parts = splitString<vector<string>>(fieldDenotationString + 9, ",", EmptyPartsTreat::Omit);
bool allTracks = false; bool allTracks = false;

View File

@ -125,6 +125,7 @@ struct FieldScope {
FieldId field; FieldId field;
TagType tagType; TagType tagType;
TagTarget tagTarget; TagTarget tagTarget;
bool exactTargetMatching;
bool allTracks; bool allTracks;
std::vector<std::uint64_t> trackIds; std::vector<std::uint64_t> trackIds;
}; };
@ -133,13 +134,14 @@ inline FieldScope::FieldScope(KnownField field, TagType tagType, TagTarget tagTa
: field(field) : field(field)
, tagType(tagType) , tagType(tagType)
, tagTarget(tagTarget) , tagTarget(tagTarget)
, exactTargetMatching(true)
, allTracks(false) , allTracks(false)
{ {
} }
inline bool FieldScope::operator==(const FieldScope &other) const inline bool FieldScope::operator==(const FieldScope &other) const
{ {
return field == other.field && tagType == other.tagType && tagTarget == other.tagTarget; return field == other.field && tagType == other.tagType && tagTarget == other.tagTarget && exactTargetMatching == other.exactTargetMatching;
} }
inline bool FieldScope::isTrack() const inline bool FieldScope::isTrack() const

View File

@ -663,7 +663,9 @@ void setTagInfo(const SetTagInfoArgs &args)
const FieldScope &denotedScope = fieldDenotation.first; const FieldScope &denotedScope = fieldDenotation.first;
// skip values which scope does not match the current tag // skip values which scope does not match the current tag
if (denotedScope.isTrack() || !(denotedScope.tagType == TagType::Unspecified || (denotedScope.tagType & tagType)) if (denotedScope.isTrack() || !(denotedScope.tagType == TagType::Unspecified || (denotedScope.tagType & tagType))
|| !(!targetSupported || denotedScope.tagTarget == tagTarget)) { || !(!targetSupported
|| (denotedScope.exactTargetMatching ? denotedScope.tagTarget == tagTarget
: denotedScope.tagTarget.matches(tagTarget)))) {
continue; continue;
} }
// convert the values to TagValue // convert the values to TagValue