libhext: C++ Library Documentation  1.0.12-3ea013c
Public Member Functions | List of all members
hext::RegexTest Class Referencefinal

Tests whether another string matches a given regex. More...

Inheritance diagram for hext::RegexTest:
Inheritance graph
[legend]
Collaboration diagram for hext::RegexTest:
Collaboration graph
[legend]

Public Member Functions

 RegexTest (boost::regex regex)
 Constructs a RegexTest that succeeds if a subject matches regex. More...
 
bool test (const char *subject) const override
 Returns true if given regex matches subject. More...
 
- Public Member Functions inherited from hext::Cloneable< RegexTest, ValueTest >
virtual std::unique_ptr< ValueTestclone () const override
 Clones objects of template type Derived and returns an owning pointer to the newly allocated Base. More...
 
- Public Member Functions inherited from hext::ValueTest
 ValueTest () noexcept=default
 
 ValueTest (const ValueTest &)=default
 
 ValueTest (ValueTest &&) noexcept=default
 
ValueTestoperator= (const ValueTest &)=default
 
ValueTestoperator= (ValueTest &&) noexcept=default
 
virtual ~ValueTest () noexcept=default
 

Detailed Description

Tests whether another string matches a given regex.

Example:
RegexTest has_number(boost::regex("\\d+"));
assert( has_number.test("Nr. 23!"));
assert( has_number.test("23"));
assert(!has_number.test("foo"));
RegexTest is_date(boost::regex("^\\d{2}-\\d{2}-\\d{4}$"));
assert( is_date.test("01-01-1970"));
assert( is_date.test("19-01-2038"));
assert(!is_date.test("09-09-99"));
assert(!is_date.test("Born on 09-09-1941."));
RegexTest(boost::regex regex)
Constructs a RegexTest that succeeds if a subject matches regex.

Definition at line 46 of file RegexTest.h.

Constructor & Destructor Documentation

◆ RegexTest()

hext::RegexTest::RegexTest ( boost::regex  regex)
explicit

Constructs a RegexTest that succeeds if a subject matches regex.

Member Function Documentation

◆ test()

bool hext::RegexTest::test ( const char *  subject) const
overridevirtual

Returns true if given regex matches subject.

Implements hext::ValueTest.


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