diff -r 25a11859975b -r 59d12eee189f streamlet-examples/qr-decode.cpp --- a/streamlet-examples/qr-decode.cpp Sun Apr 25 18:47:57 2021 +0200 +++ b/streamlet-examples/qr-decode.cpp Sun Apr 25 19:26:43 2021 +0200 @@ -31,7 +31,11 @@ * - qr: first QR code found (if any) * - qr_count: number of QR codes found * - qr_xml: XML containing all QR cpdes found an additional metadata - * + * + * Options: + * - value-pattern: regular expression describing expected value of QR code; + * if one or more options are given, the "qr" attribute will contain first value matching any of these patterns + * */ class QRStreamlet : public Streamlet { private: @@ -110,6 +114,13 @@ return result; } + bool matchesAny(const std::wstring& value, const std::vector& valuePatterns) { + for (const std::wregex& pattern : valuePatterns) { + if (std::regex_match(value, pattern)) return true; + } + return false; + } + protected: std::vector getOutputAttributesMetadata() override { @@ -137,11 +148,16 @@ validInput = false; } + std::vector