sbuild-regex.h

Go to the documentation of this file.
00001 /* Copyright © 2006-2007  Roger Leigh <rleigh@debian.org>
00002  *
00003  * schroot is free software; you can redistribute it and/or modify it
00004  * under the terms of the GNU General Public License as published by
00005  * the Free Software Foundation; either version 2 of the License, or
00006  * (at your option) any later version.
00007  *
00008  * schroot is distributed in the hope that it will be useful, but
00009  * WITHOUT ANY WARRANTY; without even the implied warranty of
00010  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011  * General Public License for more details.
00012  *
00013  * You should have received a copy of the GNU General Public License
00014  * along with this program; if not, write to the Free Software
00015  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
00016  * MA  02111-1307  USA
00017  *
00018  *********************************************************************/
00019 
00020 #ifndef SBUILD_REGEX_H
00021 #define SBUILD_REGEX_H
00022 
00023 #include <istream>
00024 #include <ostream>
00025 #include <string>
00026 
00027 #include <boost/regex.hpp>
00028 
00029 namespace sbuild
00030 {
00031 
00035   class regex : public boost::regex
00036   {
00037   public:
00039     regex ():
00040       boost::regex()
00041     {}
00042 
00050     regex (std::string const& pattern):
00051       boost::regex(pattern, boost::regex::extended)
00052     {}
00053 
00061     regex (const char *pattern):
00062       boost::regex(pattern, boost::regex::extended)
00063     {}
00064 
00066     ~regex ()
00067     {}
00068 
00078     template <class charT, class traits>
00079     friend
00080     std::basic_istream<charT,traits>&
00081     operator >> (std::basic_istream<charT,traits>& stream,
00082                  regex&                            rhs)
00083     {
00084       std::string regex;
00085 
00086       if (std::getline(stream, regex))
00087         {
00088           rhs.assign(regex, boost::regex::extended);
00089         }
00090 
00091       return stream;
00092     }
00093 
00101     template <class charT, class traits>
00102     friend
00103     std::basic_ostream<charT,traits>&
00104     operator << (std::basic_ostream<charT,traits>& stream,
00105                  regex const&                rhs)
00106     {
00107       return stream << rhs.str();
00108     }
00109   };
00110 
00111 }
00112 
00113 #endif /* SBUILD_REGEX_H */
00114 
00115 /*
00116  * Local Variables:
00117  * mode:C++
00118  * End:
00119  */

Generated on Sun Jul 8 21:23:22 2007 for sbuild by  doxygen 1.5.2