4 * @brief Declaration file for FilterList.
10 #include <Poco/RegularExpression.h>
14 * @brief Container for one filtering rule / compiled expression.
15 * This structure holds compiled regular expression and a original expression
16 * as a string. We need the original expression string in case we want to
17 * know which regular expression did match.
21 std::string filterAsString; /** Original regular expression string */
22 Poco::RegularExpression regexp; /**< Compiled regular expression */
23 filter_item(const std::string &filter, int reOpts) : filterAsString(filter), regexp(filter, reOpts) {}
26 typedef std::shared_ptr<filter_item> filter_item_ptr;
29 * @brief Regular expression list.
30 * This class holds a list of regular expressions for matching strings.
31 * The class also provides simple function for matching and remembers the
32 * last matched expression.
40 void AddRegExp(const std::string& regularExpression);
41 void RemoveAllFilters();
42 bool HasRegExps() const;
43 bool Match(const std::string& string, int codepage = ucr::CP_UTF_8);
44 const char * GetLastMatchExpression() const;
47 std::vector <filter_item_ptr> m_list;
48 const std::string *m_lastMatchExpression;
53 * @brief Removes all expressions from the list.
55 inline void FilterList::RemoveAllFilters()
61 * @brief Returns if list has any expressions.
62 * @return true if list contains one or more expressions.
64 inline bool FilterList::HasRegExps() const
66 return !m_list.empty();
70 * @brief Returns the last matched expression (if any).
71 * This function returns the regular expression string that matched last.
72 * @return Last matched expression, or `nullptr` in case no matches yet.
74 inline const char * FilterList::GetLastMatchExpression() const
76 return m_lastMatchExpression->c_str();