ircproxy  The Ultimate Cyborg

Matcher_regexp Class Reference

#include <Matcher.h>

Inheritance diagram for Matcher_regexp:

Matcher

List of all members.


Detailed Description

Regular expression matcher.

Definition at line 167 of file Matcher.h.


Public Member Functions

 Matcher_regexp (int param, std::string const &arg, bool single_param)
 Construct a Matcher_regexp instance that matches parameter param (and on if single_param is false) against pattern arg.
 ~Matcher_regexp ()
 Destructor.
virtual void print_type_on (std::ostream &os) const
 For debugging purposes. Write the class name to os.
virtual void print_on (std::ostream &os) const
 For debugging purposes. Write the compiled pattern to os.
virtual int sort_value (void)
 Implementation of pure virtual function Matcher::sort_value().

Protected Member Functions

virtual bool match_impl (ServerSession const &server_session, char const *start, size_t len)
 Match implementation interface filled in by derived classes.

Private Attributes

regex_t M_regex
 Compiled regular expression.

Constructor & Destructor Documentation

Matcher_regexp::Matcher_regexp ( int  param,
std::string const &  arg,
bool  single_param 
) [inline]

Construct a Matcher_regexp instance that matches parameter param (and on if single_param is false) against pattern arg.

Definition at line 173 of file Matcher.h.

References ASSERT, and M_regex.

00173                                                                        :
00174         Matcher(param, single_param)
00175         {
00176 #if defined(CWDEBUG) || defined(DEBUG)
00177           int regcomp_error =
00178 #endif
00179               regcomp(&M_regex, arg.c_str(), REG_ICASE | REG_NOSUB);
00180           ASSERT(regcomp_error == 0); }
    //! Destructor.

Matcher_regexp::~Matcher_regexp (  )  [inline]

Destructor.

Definition at line 182 of file Matcher.h.

References M_regex.

00182 { regfree(&M_regex); }


Member Function Documentation

virtual void Matcher_regexp::print_type_on ( std::ostream &  os  )  const [inline, virtual]

For debugging purposes. Write the class name to os.

Implements Matcher.

Definition at line 186 of file Matcher.h.

00186 { os << "Matcher_regexp"; }

virtual void Matcher_regexp::print_on ( std::ostream &  os  )  const [inline, virtual]

For debugging purposes. Write the compiled pattern to os.

Reimplemented from Matcher.

Definition at line 188 of file Matcher.h.

00188 { os << "regex: " << M_regex; }

bool Matcher_regexp::match_impl ( ServerSession const &  server_session,
char const *  start,
size_t  len 
) [protected, virtual]

Match implementation interface filled in by derived classes.

Implements Matcher.

Definition at line 89 of file Matcher.cc.

References M_regex.

00090 {
00091   char c = start[len];
00092   const_cast<char*>(start)[len] = '\0';
00093   bool success = regexec(&M_regex, start, 0, NULL, 0) == 0;
00094   const_cast<char*>(start)[len] = c;
00095   return success;
00096 }

virtual int Matcher_regexp::sort_value ( void   )  [inline, virtual]

Implementation of pure virtual function Matcher::sort_value().

Implements Matcher.

Definition at line 196 of file Matcher.h.

00196 { return regexp_mt; }


Member Data Documentation

regex_t Matcher_regexp::M_regex [private]

Compiled regular expression.

Definition at line 169 of file Matcher.h.

Referenced by match_impl(), Matcher_regexp(), and ~Matcher_regexp().


The documentation for this class was generated from the following files:

Copyright © 2005-2007 Carlo Wood.  All rights reserved.