Gromacs  2019
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
List of all members | Public Member Functions | Static Public Member Functions | Friends
gmx::Regex Class Reference

#include <gromacs/utility/gmxregex.h>

Description

Represents a regular expression.

This class provides a simple interface for regular expression construction. regexMatch() is used to match the regular expression against a string. POSIX extended regular expression syntax is used.

Currently, isSupported() will return true if either

  1. POSIX regular expression header <regex.h> is available, or
  2. C++11 header <regex> is available (e.g., new enough MSVC has this).

In other cases, isSupported() returns false and calling other constructors than the default constructor throws an exception.

See Also
regexMatch()

Public Member Functions

 Regex ()
 Constructs a regular expression that matches nothing. More...
 
 Regex (const char *value)
 Constructs a regular expression from a string. More...
 
 Regex (const std::string &value)
 Constructs a regular expression from a string. More...
 
 ~Regex ()
 Frees memory allocated for the regular expression.
 

Static Public Member Functions

static bool isSupported ()
 Returns true if regular expression support has been compiled in. More...
 

Friends

bool regexMatch (const char *str, const Regex &regex)
 Matches a string with a regular expression. More...
 
bool regexMatch (const std::string &str, const Regex &regex)
 Matches a string with a regular expression. More...
 

Constructor & Destructor Documentation

gmx::Regex::Regex ( )

Constructs a regular expression that matches nothing.

Does not throw.

gmx::Regex::Regex ( const char *  value)
explicit

Constructs a regular expression from a string.

Parameters
[in]valueString to compile into a regular expression.
Exceptions
std::bad_allocif out of memory.
InvalidInputErrorif value is not a valid regular expression.
Todo:
Consider whether some other exception type would be better.
gmx::Regex::Regex ( const std::string &  value)
explicit

Constructs a regular expression from a string.

Parameters
[in]valueString to compile into a regular expression.
Exceptions
std::bad_allocif out of memory.
InvalidInputErrorif value is not a valid regular expression.
Todo:
Consider whether some other exception type would be better.

Member Function Documentation

bool gmx::Regex::isSupported ( )
static

Returns true if regular expression support has been compiled in.

Does not throw.

Friends And Related Function Documentation

bool regexMatch ( const char *  str,
const Regex regex 
)
friend

Matches a string with a regular expression.

Parameters
[in]strString to match.
[in]regexRegular expression to match.
Returns
true if regex matches the whole str.

Does not throw currently, but this is subject to change if/when better error handling is implemented (currently, it returns false if the matching fails, e.g., because of out-of-memory).

bool regexMatch ( const std::string &  str,
const Regex regex 
)
friend

Matches a string with a regular expression.

Parameters
[in]strString to match.
[in]regexRegular expression to match.
Returns
true if regex matches the whole str.

Does not throw currently, but this is subject to change if/when better error handling is implemented (currently, it returns false if the matching fails, e.g., because of out-of-memory).


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