1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/base/Regex.h
12 #ifndef ZYPP_BASE_REGEX_H
13 #define ZYPP_BASE_REGEX_H
18 #include "zypp/base/Exception.h"
20 ///////////////////////////////////////////////////////////////////
22 { /////////////////////////////////////////////////////////////////
23 ///////////////////////////////////////////////////////////////////
24 /** String related utilities and \ref ZYPP_STR_REGEX.
25 \see \ref ZYPP_STR_REGEX
28 { /////////////////////////////////////////////////////////////////
30 ///////////////////////////////////////////////////////////////////
31 /** \defgroup ZYPP_STR_REGEX Regular expressions
33 * Namespace zypp::str regular expressions \b using the glibc regex library.
35 * \see \ref sat::AttrMatcher string matcher supporing regex, globing, etc.
42 typedef Exception regex_error;
47 bool regex_match(const char * s, str::smatch& matches, const regex& regex);
48 inline bool regex_match(const std::string& s, str::smatch& matches, const regex& regex)
49 { return regex_match( s.c_str(), matches, regex ); }
51 bool regex_match(const char * s, const regex& regex);
52 inline bool regex_match(const std::string& s, const regex& regex)
53 { return regex_match( s.c_str(), regex ); }
56 * \see \ref sat::AttrMatcher string matcher supporing regex, globing, etc.
57 * \ingroup ZYPP_STR_REGEX
67 match_extended = REG_EXTENDED,
72 regex(const std::string& s,int flags = match_extended);
75 regex(const regex & rhs)
76 { assign(rhs.m_str, rhs.m_flags); }
78 regex & operator=(const regex & rhs)
79 { assign(rhs.m_str, rhs.m_flags); return *this; }
82 * string representation of the regular expression
84 std::string asString() const
88 /** Expert backdoor. Returns pointer to the compiled regex for direct use in regexec() */
93 void assign(const std::string& s,int flags = match_extended);
97 friend bool regex_match(const char * s, str::smatch& matches, const regex& regex);
98 friend bool regex_match(const char * s, const regex& regex);
106 * \ingroup ZYPP_STR_REGEX
113 std::string operator[](unsigned i) const;
115 unsigned size() const;
117 std::string match_str;
118 regmatch_t pmatch[12];
123 /////////////////////////////////////////////////////////////////
125 ///////////////////////////////////////////////////////////////////
126 /////////////////////////////////////////////////////////////////
128 ///////////////////////////////////////////////////////////////////
129 #endif // ZYPP_BASE_STRING_H