PengZheng commented on code in PR #505:
URL: https://github.com/apache/celix/pull/505#discussion_r1160510169


##########
libs/utils/src/filter.c:
##########
@@ -407,6 +418,49 @@ static celix_array_list_t* filter_parseSubstring(char * 
filterString, int * pos)
     return operands;
 }
 
+static bool celix_filter_isCompareOperand(celix_filter_operand_t operand) {
+    return  operand == CELIX_FILTER_OPERAND_EQUAL ||
+            operand == CELIX_FILTER_OPERAND_GREATER ||
+            operand == CELIX_FILTER_OPERAND_LESS ||
+            operand == CELIX_FILTER_OPERAND_GREATEREQUAL ||
+            operand == CELIX_FILTER_OPERAND_LESSEQUAL;
+}
+
+
+static bool celix_filter_hasFilterChildren(celix_filter_t* filter) {
+    return filter->operand == CELIX_FILTER_OPERAND_AND ||
+           filter->operand == CELIX_FILTER_OPERAND_OR ||
+           filter->operand == CELIX_FILTER_OPERAND_NOT;
+}
+
+/**
+ * Compiles the filter, so that the attribute values are converted to the 
typed values if possible.
+ */
+static celix_status_t celix_filter_compile(celix_filter_t* filter) {
+    if (celix_filter_isCompareOperand(filter->operand)) {
+        filter->internal = malloc(sizeof(*filter->internal));
+        if (filter->internal == NULL) {
+            return CELIX_ENOMEM;
+        } else {
+            filter->internal->longValue = 
celix_utils_convertStringToLong(filter->value, 0, 
&filter->internal->convertedToLong);
+            filter->internal->doubleValue = 
celix_utils_convertStringToDouble(filter->value, 0.0, 
&filter->internal->convertedToDouble);
+            filter->internal->versionValue = 
celix_utils_convertStringToVersion(filter->value, NULL, 
&filter->internal->convertedToVersion);

Review Comment:
   `celix_utils_convertStringToVersion` is flawed, see #512 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to