Commit c3a862c5b461a046a5c778b242547dc1cab381f5
1 parent
4c0e779c
add inList to IfTransform
Showing
1 changed file
with
8 additions
and
2 deletions
openbr/plugins/imgproc/if.cpp
| 1 | 1 | #include <openbr/plugins/openbr_internal.h> |
| 2 | +#include <openbr/core/qtutils.h> | |
| 2 | 3 | |
| 3 | 4 | namespace br |
| 4 | 5 | { |
| ... | ... | @@ -27,7 +28,7 @@ class IfTransform : public MetaTransform |
| 27 | 28 | bool result, ok1 = true, ok2 = true; |
| 28 | 29 | |
| 29 | 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 | 32 | else if (comparison == "e") |
| 32 | 33 | result = metadata == value; |
| 33 | 34 | else if (comparison == "ne") |
| ... | ... | @@ -42,7 +43,12 @@ class IfTransform : public MetaTransform |
| 42 | 43 | result = metadata.toFloat(&ok1) >= value.toFloat(&ok2); |
| 43 | 44 | else if (comparison == "c") // contains |
| 44 | 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 | 52 | qFatal("Unrecognized comparison string."); |
| 47 | 53 | |
| 48 | 54 | if (!(ok1 && ok2)) | ... | ... |