static bool celix_filter_matchPropertyEntry()

in libs/utils/src/filter.c [747:788]


static bool celix_filter_matchPropertyEntry(const celix_filter_t* filter, const celix_properties_entry_t* entry) {
    if (filter->operand == CELIX_FILTER_OPERAND_SUBSTRING) {
        return celix_filter_matchSubString(filter, entry);
    } else if (filter->operand == CELIX_FILTER_OPERAND_APPROX) {
        return celix_filter_matchApprox(filter, entry);
    }

    assert(filter->operand == CELIX_FILTER_OPERAND_EQUAL || filter->operand == CELIX_FILTER_OPERAND_GREATER ||
           filter->operand == CELIX_FILTER_OPERAND_LESS || filter->operand == CELIX_FILTER_OPERAND_GREATEREQUAL ||
           filter->operand == CELIX_FILTER_OPERAND_LESSEQUAL);


    //match for array types
    if (celix_filter_isPropertyEntryArrayWithElementType(entry, CELIX_ARRAY_LIST_ELEMENT_TYPE_LONG)) {
        return celix_utils_matchLongArrays(filter->operand, entry->typed.arrayValue, filter->internal->longValue);
    } else if (celix_filter_isPropertyEntryArrayWithElementType(entry, CELIX_ARRAY_LIST_ELEMENT_TYPE_DOUBLE)) {
        return celix_utils_matchDoubleArrays(filter->operand, entry->typed.arrayValue, filter->internal->doubleValue);
    } else if (celix_filter_isPropertyEntryArrayWithElementType(entry, CELIX_ARRAY_LIST_ELEMENT_TYPE_BOOL)) {
        return celix_utils_matchBoolArrays(filter->operand, entry->typed.arrayValue, filter->internal->boolValue);
    } else if (celix_filter_isPropertyEntryArrayWithElementType(entry, CELIX_ARRAY_LIST_ELEMENT_TYPE_VERSION)) {
        return celix_utils_matchVersionArrays(filter->operand, entry->typed.arrayValue, filter->internal->versionValue);
    } else if (celix_filter_isPropertyEntryArrayWithElementType(entry, CELIX_ARRAY_LIST_ELEMENT_TYPE_STRING)) {
        return celix_utils_matchStringArrays(filter->operand, entry->typed.arrayValue, filter->value);
    }

    //regular compare -> match
    int cmp;
    if (entry->valueType == CELIX_PROPERTIES_VALUE_TYPE_LONG && filter->internal->convertedToLong) {
        cmp = celix_filter_cmpLong(entry->typed.longValue, filter->internal->longValue);
    } else if (entry->valueType == CELIX_PROPERTIES_VALUE_TYPE_DOUBLE && filter->internal->convertedToDouble) {
        cmp = celix_filter_cmpDouble(entry->typed.doubleValue, filter->internal->doubleValue);
    } else if (entry->valueType == CELIX_PROPERTIES_VALUE_TYPE_BOOL && filter->internal->convertedToBool) {
        cmp = celix_filter_cmpBool(entry->typed.boolValue, filter->internal->boolValue);
    } else if (entry->valueType == CELIX_PROPERTIES_VALUE_TYPE_VERSION && filter->internal->convertedToVersion) {
        cmp = celix_version_compareTo(entry->typed.versionValue, filter->internal->versionValue);
    } else {
        // type string or property type and converted filter attribute value do not match ->
        // fallback on string compare
        cmp = strcmp(entry->value, filter->value);
    }
    return celix_utils_convertCompareToBool(filter->operand, cmp);
}