Skip to content

matcher

Mario Bielert edited this page Jun 29, 2017 · 2 revisions

The matcher is a helper class, which provides a very simplified regular expression matching for channel names. Actually it only supports the usage of * as a wildcard.

Usage

The class can be used as follows. First you create an instance of the class with the pattern as only argument. Then the operator() can be used to check, if a given string matches the pattern, set in the constructor.

scorep::plugin::util::matcher starts_with_smurf("Smurf*");

std::cout << simple_pattern_matcher("SmurfHouse") << std::endl; // returns true
std::cout << simple_pattern_matcher("Smurf") << std::endl; // returns true
std::cout << simple_pattern_matcher("House") << std::endl; // returns false

Methods

matcher(std::string pattern)

Construct with pattern. The given pattern will be used to match against it.

Arguments:

  • pattern - the used pattern to match

bool operator()(std::string input)

Tries to match input against the set pattern.

Arguments:

  • input - the string, which will be matched against the pattern

Returns:

  • bool - true, if input matches the pattern, otherwise false
Clone this wiki locally