Dynamixel  2.9.5
RoadNarrows Robotics Dynamixel Package
RegEx Class Reference

Regular Express Class. More...

#include <dynashell_regex.h>

Public Member Functions

 RegEx ()
 Default constructor.
 
 RegEx (const string &strRegEx)
 String initialization constructor.
 
 RegEx (const char *sRegEx)
 Null-terminated string initialization constructor.
 
 RegEx (const RegEx &src)
 Copy constructor.
 
virtual ~RegEx ()
 Default destructor.
 
bool Match (const string &strPat)
 Match pattern against regular expression. More...
 
bool Match (const char *sPat)
 Match pattern against regular expression. More...
 
const char * GetRegEx () const
 Get this object's regular expression. More...
 
bool IsValid ()
 Test if in valid state. More...
 
RegExoperator= (const RegEx &rhs)
 Assignment copy operator. More...
 
RegExoperator= (const string &rhs)
 Assignment operator. More...
 
RegExoperator= (const char *rhs)
 Assignment operator. More...
 

Protected Member Functions

void Compile ()
 Compile a regular expression.
 

Protected Attributes

bool m_bIsValid
 expression is [not] valid
 
string m_strRegEx
 pre-compiled regular expression string
 
regex_t m_regex
 compiled reqular expression
 

Detailed Description

Regular Express Class.

Definition at line 70 of file dynashell_regex.h.

Member Function Documentation

const char* RegEx::GetRegEx ( ) const
inline

Get this object's regular expression.

Returns
If a regular expressing exist, then the expression string is returned. Else NULL is returned.

Definition at line 163 of file dynashell_regex.h.

164  {
165  return m_strRegEx.length() > 0? m_strRegEx.c_str(): NULL;
166  }
string m_strRegEx
pre-compiled regular expression string
bool RegEx::IsValid ( )
inline

Test if in valid state.

Returns
Returns true or false;

Definition at line 173 of file dynashell_regex.h.

174  {
175  return m_bIsValid;
176  }
bool m_bIsValid
expression is [not] valid
bool RegEx::Match ( const string &  strPat)
inline

Match pattern against regular expression.

Parameters
strPatString pattern.
Returns
Returns true if the pattern matches the expression, false otherwise.

Definition at line 132 of file dynashell_regex.h.

133  {
134  return Match(strPat.c_str());
135  }
bool Match(const string &strPat)
Match pattern against regular expression.
bool RegEx::Match ( const char *  sPat)
inline

Match pattern against regular expression.

Parameters
sPatNull-terminated string pattern.
Returns
Returns true if the pattern matches the expression, false otherwise.

Definition at line 145 of file dynashell_regex.h.

146  {
147  if( m_bIsValid && (regexec(&m_regex, sPat, 0, NULL, 0) == 0) )
148  {
149  return true;
150  }
151  else
152  {
153  return false;
154  }
155  }
regex_t m_regex
compiled reqular expression
bool m_bIsValid
expression is [not] valid
RegEx& RegEx::operator= ( const RegEx rhs)
inline

Assignment copy operator.

Parameters
rhsRegular expression object.
Returns
This regular expression object.

Definition at line 185 of file dynashell_regex.h.

References m_strRegEx.

186  {
187  regfree(&m_regex);
188  m_strRegEx = rhs.m_strRegEx;
189  Compile();
190  return *this;
191  }
regex_t m_regex
compiled reqular expression
string m_strRegEx
pre-compiled regular expression string
void Compile()
Compile a regular expression.
RegEx& RegEx::operator= ( const string &  rhs)
inline

Assignment operator.

Parameters
rhsString regular expression.
Returns
This regular expression object.

Definition at line 200 of file dynashell_regex.h.

201  {
202  regfree(&m_regex);
203  m_strRegEx = rhs;
204  Compile();
205  return *this;
206  }
regex_t m_regex
compiled reqular expression
string m_strRegEx
pre-compiled regular expression string
void Compile()
Compile a regular expression.
RegEx& RegEx::operator= ( const char *  rhs)
inline

Assignment operator.

Parameters
rhsNull-terminated string expression object.
Returns
This regular expression object.

Definition at line 215 of file dynashell_regex.h.

216  {
217  regfree(&m_regex);
218  if( rhs != NULL )
219  {
220  m_strRegEx = rhs;
221  Compile();
222  }
223  else
224  {
225  m_strRegEx.clear();
226  m_bIsValid = false;
227  }
228  return *this;
229  }
regex_t m_regex
compiled reqular expression
string m_strRegEx
pre-compiled regular expression string
bool m_bIsValid
expression is [not] valid
void Compile()
Compile a regular expression.

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