Files
mrw-cxx/mrw/regexp.cpp

37 lines
715 B
C++
Raw Normal View History

2004-12-14 20:20:30 +00:00
/** @file
$Id$
$Date$
$Author$
@copy © Marc Wäckerlin
@license LGPL, see file <a href="license.html">COPYING</a>
$Log$
Revision 1.1 2004/12/14 20:20:30 marc
initial version
*/
#include <mrw/regexp.hpp>
#include <mrw/exception.hpp>
namespace mrw {
RegExp::RegExp(const std::string& pattern, int flags)
throw(std::exception, std::bad_exception) {
if (regcomp(&_regex, pattern.c_str(), flags|nosub))
throw(mrw::invalid_argument(pattern));
}
RegExp::~RegExp() throw() {
regfree(&_regex);
}
bool RegExp::operator()(const std::string& text) const throw() {
return !regexec(const_cast<regex_t*>(&_regex), text.c_str(), 0, 0, 0);
}
}