# HG changeset patch # User František Kučera # Date 1619371603 -7200 # Node ID 59d12eee189f726943a617cb23bb5c93ed179e1b # Parent 25a11859975bbf648e31286d974d50d6ae131f88 streamlet examples: QR: value-pattern option e.g. --option value-pattern "urn:uuid:.*" will look for QR codes containing URIs like „urn:uuid:c3e98a0d-97cf-4348-b46e-2bbb115ceea3“ 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