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_JS_SRC_DIR renamingutility)
set(META_VERSION_MAJOR 3)
set(META_VERSION_MINOR 5)
set(META_VERSION_PATCH 2)
set(META_VERSION_MINOR 6)
set(META_VERSION_PATCH 0)
set(META_ADD_DEFAULT_CPP_UNIT_TEST_APPLICATION ON)
# add project files
@ -199,7 +199,7 @@ if (WIDGETS_GUI OR QUICK_GUI)
endif ()
# 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()
# enable experimental JSON export

View File

@ -579,6 +579,12 @@ FieldDenotations parseFieldDenotations(const Argument &fieldsArg, bool readOnly)
continue;
} else if (applyTargetConfiguration(scope.tagTarget, fieldDenotationString)) {
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)) {
const vector<string> parts = splitString<vector<string>>(fieldDenotationString + 9, ",", EmptyPartsTreat::Omit);
bool allTracks = false;

View File

@ -125,6 +125,7 @@ struct FieldScope {
FieldId field;
TagType tagType;
TagTarget tagTarget;
bool exactTargetMatching;
bool allTracks;
std::vector<std::uint64_t> trackIds;
};
@ -133,13 +134,14 @@ inline FieldScope::FieldScope(KnownField field, TagType tagType, TagTarget tagTa
: field(field)
, tagType(tagType)
, tagTarget(tagTarget)
, exactTargetMatching(true)
, allTracks(false)
{
}
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

View File

@ -663,7 +663,9 @@ void setTagInfo(const SetTagInfoArgs &args)
const FieldScope &denotedScope = fieldDenotation.first;
// skip values which scope does not match the current tag
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;
}
// convert the values to TagValue