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 3 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, see
00015  * <http://www.gnu.org/licenses/>.
00016  *
00017  *********************************************************************/
00018 
00019 #ifndef SBUILD_REGEX_H
00020 #define SBUILD_REGEX_H
00021 
00022 #include <istream>
00023 #include <ostream>
00024 #include <string>
00025 
00026 #include <boost/regex.hpp>
00027 
00028 namespace sbuild
00029 {
00030 
00034   class regex : public boost::regex
00035   {
00036   public:
00038     regex ():
00039       boost::regex()
00040     {}
00041 
00049     regex (std::string const& pattern):
00050       boost::regex(pattern, boost::regex::extended)
00051     {}
00052 
00060     regex (const char *pattern):
00061       boost::regex(pattern, boost::regex::extended)
00062     {}
00063 
00065     ~regex ()
00066     {}
00067 
00077     template <class charT, class traits>
00078     friend
00079     std::basic_istream<charT,traits>&
00080     operator >> (std::basic_istream<charT,traits>& stream,
00081                  regex&                            rhs)
00082     {
00083       std::string regex;
00084 
00085       if (std::getline(stream, regex))
00086         {
00087           rhs.assign(regex, boost::regex::extended);
00088         }
00089 
00090       return stream;
00091     }
00092 
00100     template <class charT, class traits>
00101     friend
00102     std::basic_ostream<charT,traits>&
00103     operator << (std::basic_ostream<charT,traits>& stream,
00104                  regex const&                rhs)
00105     {
00106       return stream << rhs.str();
00107     }
00108   };
00109 
00110 }
00111 
00112 #endif /* SBUILD_REGEX_H */
00113 
00114 /*
00115  * Local Variables:
00116  * mode:C++
00117  * End:
00118  */

Generated on Sat Jul 5 11:58:47 2008 for sbuild by  doxygen 1.5.6