Regex.h

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------\
00002 |                          ____ _   __ __ ___                          |
00003 |                         |__  / \ / / . \ . \                         |
00004 |                           / / \ V /|  _/  _/                         |
00005 |                          / /__ | | | | | |                           |
00006 |                         /_____||_| |_| |_|                           |
00007 |                                                                      |
00008 \---------------------------------------------------------------------*/
00012 #ifndef ZYPP_BASE_REGEX_H
00013 #define ZYPP_BASE_REGEX_H
00014 
00015 #include <iosfwd>
00016 #include <string>
00017 
00018 #include <regex.h>
00019 
00020 #include "zypp/base/Exception.h"
00021 
00023 namespace zypp
00024 { 
00025 
00026 
00029   namespace str
00030   { 
00031 
00032     typedef Exception regex_error;
00033     
00034     class smatch;
00035     class regex;
00036     
00037     bool regex_match(const std::string& s, str::smatch& matches, const regex& regex);
00038     bool regex_match(const std::string& s,  const regex& regex);
00039     
00040     class regex {
00041     public:
00042 
00043       enum RegFlags {
00044         optimize = 0,
00045         match_extra = 0,
00046         icase = REG_ICASE,
00047         nosubs = REG_NOSUB,
00048         match_extended = REG_EXTENDED,
00049         normal = 1<<16
00050       };
00051   
00052       regex();
00053       regex(const std::string& s,int flags = match_extended);
00054       ~regex() throw();
00055 
00056       void assign(const std::string& s,int flags = match_extended);
00057       
00058     private:
00059       friend class smatch;
00060       friend bool regex_match(const std::string& s, str::smatch& matches, const regex& regex);
00061       friend bool regex_match(const std::string& s,  const regex& regex);
00062       regex_t m_preg;
00063       bool m_valid;
00064     };
00065 
00066     class smatch {
00067     public:
00068       smatch();
00069 
00070       std::string operator[](unsigned i) const;
00071 
00072       unsigned size() const;
00073 
00074       std::string match_str;
00075       regmatch_t pmatch[12];
00076     };
00077 
00078     
00079 
00081   } // namespace str
00084 } // namespace zypp
00086 #endif // ZYPP_BASE_STRING_H

Generated on Tue Sep 25 19:22:59 2007 for libzypp by  doxygen 1.5.3