smartmontools SVN Rev 5406
Utility to control and monitor storage systems with "S.M.A.R.T."
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
regular_expression Class Reference

Wrapper class for POSIX regex(3) or std::regex Supports copy & assignment and is compatible with STL containers. More...

#include <utility.h>

Collaboration diagram for regular_expression:
Collaboration graph
[legend]

Public Types

typedef regmatch_t match_range
 

Public Member Functions

 regular_expression ()
 
 ~regular_expression ()
 
 regular_expression (const regular_expression &x)
 
regular_expressionoperator= (const regular_expression &x)
 
 regular_expression (const char *pattern)
 Construct with pattern, throw on error. More...
 
bool compile (const char *pattern)
 Set and compile new pattern, return false on error. More...
 
const char * get_pattern () const
 
const char * get_errmsg () const
 Get error message from last compile(). More...
 
bool empty () const
 
bool full_match (const char *str) const
 Return true if full string matches pattern. More...
 
bool execute (const char *str, unsigned nmatch, match_range *pmatch) const
 Return true if substring matches pattern, fill match_range array. More...
 

Private Member Functions

void free_buf ()
 
void copy_buf (const regular_expression &x)
 
bool compile ()
 

Private Attributes

std::string m_pattern
 
std::string m_errmsg
 
regex_t m_regex_buf
 

Detailed Description

Wrapper class for POSIX regex(3) or std::regex Supports copy & assignment and is compatible with STL containers.

Definition at line 220 of file utility.h.

Member Typedef Documentation

◆ match_range

typedef regmatch_t regular_expression::match_range

Definition at line 261 of file utility.h.

Constructor & Destructor Documentation

◆ regular_expression() [1/3]

regular_expression::regular_expression ( )

Definition at line 471 of file utility.cpp.

◆ ~regular_expression()

regular_expression::~regular_expression ( )

Definition at line 476 of file utility.cpp.

◆ regular_expression() [2/3]

regular_expression::regular_expression ( const regular_expression x)

Definition at line 481 of file utility.cpp.

◆ regular_expression() [3/3]

regular_expression::regular_expression ( const char *  pattern)
explicit

Construct with pattern, throw on error.

Definition at line 519 of file utility.cpp.

Member Function Documentation

◆ compile() [1/2]

bool regular_expression::compile ( )
private

Definition at line 537 of file utility.cpp.

◆ compile() [2/2]

bool regular_expression::compile ( const char *  pattern)

Set and compile new pattern, return false on error.

Definition at line 528 of file utility.cpp.

◆ copy_buf()

void regular_expression::copy_buf ( const regular_expression x)
private

Definition at line 506 of file utility.cpp.

◆ empty()

bool regular_expression::empty ( ) const
inline

Definition at line 252 of file utility.h.

◆ execute()

bool regular_expression::execute ( const char *  str,
unsigned  nmatch,
match_range pmatch 
) const

Return true if substring matches pattern, fill match_range array.

Definition at line 585 of file utility.cpp.

◆ free_buf()

void regular_expression::free_buf ( )
private

Definition at line 498 of file utility.cpp.

◆ full_match()

bool regular_expression::full_match ( const char *  str) const

Return true if full string matches pattern.

Definition at line 574 of file utility.cpp.

◆ get_errmsg()

const char * regular_expression::get_errmsg ( ) const
inline

Get error message from last compile().

Definition at line 248 of file utility.h.

◆ get_pattern()

const char * regular_expression::get_pattern ( ) const
inline

Definition at line 244 of file utility.h.

◆ operator=()

regular_expression & regular_expression::operator= ( const regular_expression x)

Definition at line 489 of file utility.cpp.

Member Data Documentation

◆ m_errmsg

std::string regular_expression::m_errmsg
private

Definition at line 269 of file utility.h.

◆ m_pattern

std::string regular_expression::m_pattern
private

Definition at line 268 of file utility.h.

◆ m_regex_buf

regex_t regular_expression::m_regex_buf
private

Definition at line 274 of file utility.h.


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