Commit c3a862c5b461a046a5c778b242547dc1cab381f5

Authored by bhklein
1 parent 4c0e779c

add inList to IfTransform

Showing 1 changed file with 8 additions and 2 deletions
openbr/plugins/imgproc/if.cpp
1 #include <openbr/plugins/openbr_internal.h> 1 #include <openbr/plugins/openbr_internal.h>
  2 +#include <openbr/core/qtutils.h>
2 3
3 namespace br 4 namespace br
4 { 5 {
@@ -27,7 +28,7 @@ class IfTransform : public MetaTransform @@ -27,7 +28,7 @@ class IfTransform : public MetaTransform
27 bool result, ok1 = true, ok2 = true; 28 bool result, ok1 = true, ok2 = true;
28 29
29 if (comparison == "empty") 30 if (comparison == "empty")
30 - result = metadata.isNull() || (metadata.canConvert<QString>() && metadata.toString().isEmpty()); 31 + result = metadata.isNull() || (metadata.canConvert<QString>() && metadata.toString().isEmpty());
31 else if (comparison == "e") 32 else if (comparison == "e")
32 result = metadata == value; 33 result = metadata == value;
33 else if (comparison == "ne") 34 else if (comparison == "ne")
@@ -42,7 +43,12 @@ class IfTransform : public MetaTransform @@ -42,7 +43,12 @@ class IfTransform : public MetaTransform
42 result = metadata.toFloat(&ok1) >= value.toFloat(&ok2); 43 result = metadata.toFloat(&ok1) >= value.toFloat(&ok2);
43 else if (comparison == "c") // contains 44 else if (comparison == "c") // contains
44 result = metadata.toString().contains(value); 45 result = metadata.toString().contains(value);
45 - else 46 + else if (comparison == "inList") {
  47 + QString value_ = value;
  48 + value_.replace("[", "").replace("]", "");
  49 + const QStringList values = value_.split(",");
  50 + result = values.contains(metadata.toString());
  51 + } else
46 qFatal("Unrecognized comparison string."); 52 qFatal("Unrecognized comparison string.");
47 53
48 if (!(ok1 && ok2)) 54 if (!(ok1 && ok2))