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.
40 typedef Exception regex_error;
45 bool regex_match(const char * s, str::smatch& matches, const regex& regex);
46 inline bool regex_match(const std::string& s, str::smatch& matches, const regex& regex)
47 { return regex_match( s.c_str(), matches, regex ); }
49 bool regex_match(const char * s, const regex& regex);
50 inline bool regex_match(const std::string& s, const regex& regex)
51 { return regex_match( s.c_str(), regex ); }
61 match_extended = REG_EXTENDED,
66 regex(const std::string& s,int flags = match_extended);
69 regex(const regex & rhs)
70 { assign(rhs.m_str, rhs.m_flags); }
72 regex & operator=(const regex & rhs)
73 { assign(rhs.m_str, rhs.m_flags); return *this; }
76 * string representation of the regular expression
78 std::string asString() const
82 /** Expert backdoor. Returns pointer to the compiled regex for direct use in regexec() */
87 void assign(const std::string& s,int flags = match_extended);
91 friend bool regex_match(const char * s, str::smatch& matches, const regex& regex);
92 friend bool regex_match(const char * s, const regex& regex);
103 std::string operator[](unsigned i) const;
105 unsigned size() const;
107 std::string match_str;
108 regmatch_t pmatch[12];
113 /////////////////////////////////////////////////////////////////
115 ///////////////////////////////////////////////////////////////////
116 /////////////////////////////////////////////////////////////////
118 ///////////////////////////////////////////////////////////////////
119 #endif // ZYPP_BASE_STRING_H