common: Put scopeMatch in util, use in highlights
[quassel.git] / src / common / util.h
index 632ba0e..85d7910 100644 (file)
@@ -79,3 +79,17 @@ QByteArray prettyDigest(const QByteArray &digest);
  * @return String with current date/time substituted in via formatting codes
  */
 QString formatCurrentDateTimeInString(const QString &formatStr);
+
+/** Check if a scope rule matches a string
+ *
+ * Checks that the string does NOT match ANY inverted rules (prefixed by '!'), then checks that
+ * it matches AT LEAST one normal (non-inverted) rule.
+ *
+ * If only inverted rules are specified, it'll match so long as the string does not match any
+ * inverted rules (implicit wildcard).
+ *
+ * @param scopeRule  A ';'-separated list of wildcard expressions, prefix of '!' inverts subrule
+ * @param string     String to test, e.g. network/channel name
+ * @return True if matches, otherwise false
+ */
+bool scopeMatch(const QString &scopeRule, const QString &string);