+
+ /**
+ * Gets if this is a regular expression rule
+ *
+ * @return True if regular expression, otherwise false
+ */
+ inline bool isRegEx() const { return _isRegEx; }
+ /**
+ * Sets if this rule is a regular expression rule
+ *
+ * @param isRegEx True if regular expression, otherwise false
+ */
+ inline void setIsRegEx(bool isRegEx)
+ {
+ _isRegEx = isRegEx;
+ _cacheInvalid = true;
+ }
+
+ /**
+ * Gets if this rule is case sensitive
+ *
+ * @return True if case sensitive, otherwise false
+ */
+ inline bool isCaseSensitive() const { return _isCaseSensitive; }
+ /**
+ * Sets if this rule is case sensitive
+ *
+ * @param isCaseSensitive True if case sensitive, otherwise false
+ */
+ inline void setIsCaseSensitive(bool isCaseSensitive)
+ {
+ _isCaseSensitive = isCaseSensitive;
+ _cacheInvalid = true;
+ }
+
+ /**
+ * Gets if this rule is enabled and active
+ *
+ * @return True if enabled, otherwise false
+ */
+ inline bool isEnabled() const { return _isEnabled; }
+ /**
+ * Sets if this rule is enabled and active
+ *
+ * @param isEnabled True if enabled, otherwise false
+ */
+ inline void setIsEnabled(bool isEnabled) { _isEnabled = isEnabled; }
+
+ /**
+ * Gets if this rule is a highlight ignore rule
+ *
+ * @return True if rule is treated as highlight ignore, otherwise false
+ */
+ inline bool isInverse() const { return _isInverse; }
+ /**
+ * Sets if this rule is a highlight ignore rule
+ *
+ * @param isInverse True if rule is treated as highlight ignore, otherwise false
+ */
+ inline void setIsInverse(bool isInverse) { _isInverse = isInverse; }
+
+ /**
+ * Gets the message sender this rule matches
+ *
+ * NOTE: Use HighlightRule::senderMatcher() for performing matches
+ *
+ * @return String representing a phrase or expression to match
+ */
+ inline QString sender() const { return _sender; }
+ /**
+ * Sets the message sender this rule matches
+ *
+ * @param sender String representing a phrase or expression to match
+ */
+ inline void setSender(const QString& sender)
+ {
+ _sender = sender;
+ _cacheInvalid = true;
+ }
+
+ /**
+ * Gets the channel name this rule matches
+ *
+ * NOTE: Use HighlightRule::chanNameMatcher() for performing matches
+ *
+ * @return String representing a phrase or expression to match
+ */
+ inline QString chanName() const { return _chanName; }
+ /**
+ * Sets the channel name this rule matches
+ *
+ * @param chanName String representing a phrase or expression to match
+ */
+ inline void setChanName(const QString& chanName)
+ {
+ _chanName = chanName;
+ _cacheInvalid = true;
+ }
+
+ /**
+ * Gets the expression matcher for the message contents, caching if needed
+ *
+ * @return Expression matcher to compare with message contents
+ */
+ inline ExpressionMatch contentsMatcher() const
+ {
+ if (_cacheInvalid) {
+ determineExpressions();
+ }
+ return _contentsMatch;
+ }
+
+ /**
+ * Gets the expression matcher for the message sender, caching if needed
+ *
+ * @return Expression matcher to compare with message sender
+ */
+ inline ExpressionMatch senderMatcher() const
+ {
+ if (_cacheInvalid) {
+ determineExpressions();
+ }
+ return _senderMatch;
+ }
+
+ /**
+ * Gets the expression matcher for the channel name, caching if needed
+ *
+ * @return Expression matcher to compare with channel name
+ */
+ inline ExpressionMatch chanNameMatcher() const
+ {
+ if (_cacheInvalid) {
+ determineExpressions();
+ }
+ return _chanNameMatch;
+ }
+
+ bool operator!=(const HighlightRule& other) const;
+
+ private:
+ /**
+ * Update internal cache of expression matching if needed
+ */
+ void determineExpressions() const;
+
+ int _id = -1;
+ QString _contents = {};
+ bool _isRegEx = false;
+ bool _isCaseSensitive = false;
+ bool _isEnabled = true;
+ bool _isInverse = false;
+ QString _sender = {};
+ QString _chanName = {};
+
+ // These represent internal cache and should be safe to mutate in 'const' functions
+ // See https://stackoverflow.com/questions/3141087/what-is-meant-with-const-at-end-of-function-declaration
+ mutable bool _cacheInvalid = true; ///< If true, match cache needs redone
+ mutable ExpressionMatch _contentsMatch = {}; ///< Expression match cache for message content
+ mutable ExpressionMatch _senderMatch = {}; ///< Expression match cache for sender
+ mutable ExpressionMatch _chanNameMatch = {}; ///< Expression match cache for channel name