10 #include <ibrcommon/Logger.h>
18 : _dest(dest), _regex_str(regex), _invalid(false), _expire(0)
20 if ( regcomp(&_regex, regex.c_str(), 0) )
22 IBRCOMMON_LOGGER_TAG(
"StaticRegexRoute", error) <<
"Could not compile regex: " << regex << IBRCOMMON_LOGGER_ENDL;
35 : _dest(obj._dest), _regex_str(obj._regex_str), _invalid(obj._invalid)
37 if ( regcomp(&_regex, _regex_str.c_str(), 0) )
51 _regex_str = obj._regex_str;
52 _invalid = obj._invalid;
56 if ( regcomp(&_regex, obj._regex_str.c_str(), 0) )
58 IBRCOMMON_LOGGER_TAG(
"StaticRegexRoute", error) <<
"Could not compile regex: " << _regex_str << IBRCOMMON_LOGGER_ENDL;
68 if (_invalid)
return false;
73 int reti = regexec(&_regex, dest.c_str(), 0, NULL, 0);
80 else if( reti == REG_NOMATCH )
88 regerror(reti, &_regex, msgbuf,
sizeof(msgbuf));
89 IBRCOMMON_LOGGER_TAG(
"StaticRegexRoute", error) <<
"Regex match failed: " << std::string(msgbuf) << IBRCOMMON_LOGGER_ENDL;
101 std::stringstream ss;
102 ss << _regex_str <<
" => " << _dest.
getString();
120 return (_regex_str == r._regex_str) && (_dest == r._dest);
121 }
catch (
const std::bad_cast&) {
StaticRegexRoute & operator=(const StaticRegexRoute &obj)
const std::string toString() const
bool match(const dtn::data::EID &eid) const
static void raiseEvent(CHANGE_TYPE type)
void raiseExpired() const
const dtn::data::Timestamp & getExpiration() const
virtual ~StaticRegexRoute()
bool equals(const StaticRoute &route) const
std::string getString() const
StaticRegexRoute(const std::string ®ex, const dtn::data::EID &dest)
const dtn::data::EID & getDestination() const