///////////////////////////////////////////////////////////////////////////
| 919 | |
| 920 | //////////////////////////////////////////////////////////////////////////////// |
| 921 | bool Variant::operator_match(const Variant& other, const Task& task) const { |
| 922 | // Simple matching case first. |
| 923 | Variant left(*this); |
| 924 | Variant right(other); |
| 925 | |
| 926 | if (left._type == type_string) Lexer::dequote(left._string); |
| 927 | |
| 928 | if (right._type == type_string) Lexer::dequote(right._string); |
| 929 | |
| 930 | left.cast(type_string); |
| 931 | right.cast(type_string); |
| 932 | |
| 933 | std::string pattern = right._string; |
| 934 | Lexer::dequote(pattern); |
| 935 | |
| 936 | if (searchUsingRegex) { |
| 937 | RX r(pattern, searchCaseSensitive); |
| 938 | if (r.match(left._string)) return true; |
| 939 | |
| 940 | // If the above did not match, and the left source is "description", then |
| 941 | // in the annotations. |
| 942 | if (left.source() == "description") { |
| 943 | for (auto& a : task.getAnnotations()) |
| 944 | if (r.match(a.second)) return true; |
| 945 | } |
| 946 | } else { |
| 947 | // If pattern starts with '^', look for a leftmost compare only. |
| 948 | if (pattern[0] == '^' && find(left._string, pattern.substr(1), searchCaseSensitive) == 0) { |
| 949 | return true; |
| 950 | } |
| 951 | |
| 952 | // If pattern ends with '$', look for a rightmost compare only. |
| 953 | else if (pattern[pattern.length() - 1] == '$' && |
| 954 | find(left._string, pattern.substr(0, pattern.length() - 1), searchCaseSensitive) == |
| 955 | (left._string.length() - pattern.length() + 1)) { |
| 956 | return true; |
| 957 | } |
| 958 | |
| 959 | else if (find(left._string, pattern, searchCaseSensitive) != std::string::npos) |
| 960 | return true; |
| 961 | |
| 962 | // If the above did not match, and the left source is "description", then |
| 963 | // in the annotations. |
| 964 | if (left.source() == "description") { |
| 965 | for (auto& a : task.getAnnotations()) |
| 966 | if (find(a.second, pattern, searchCaseSensitive) != std::string::npos) return true; |
| 967 | } |
| 968 | } |
| 969 | |
| 970 | return false; |
| 971 | } |
| 972 | |
| 973 | //////////////////////////////////////////////////////////////////////////////// |
| 974 | bool Variant::operator_nomatch(const Variant& other, const Task& task) const { |