All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
ValueTest.h
Go to the documentation of this file.
1 // Copyright 2015 Thomas Trapp
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef HEXT_VALUE_TEST_H_INCLUDED
16 #define HEXT_VALUE_TEST_H_INCLUDED
17 
18 /// @file
19 /// Declares hext::ValueTest
20 
21 #include <memory>
22 
23 
24 namespace hext {
25 
26 
27 /// Abstract base for every ValueTest.
28 /// ValueTests determine whether a string passes a certain test.
29 ///
30 /// Note: You probably don't want to inherit from this class directly, unless
31 /// you want to provide your own ValueTest::clone() method. If your
32 /// subclass has a copy constructor, you can extend from
33 /// hext::Cloneable<YourSubclass, hext::ValueTest> which provides a
34 /// generic clone method.
35 class ValueTest
36 {
37 public:
38  ValueTest() noexcept = default;
39  ValueTest(const ValueTest&) = default;
40  ValueTest(ValueTest&&) noexcept = default;
41  ValueTest& operator=(const ValueTest&) = default;
42  ValueTest& operator=(ValueTest&&) noexcept = default;
43  virtual ~ValueTest() noexcept = default;
44 
45  /// Clones derived object.
46  virtual std::unique_ptr<ValueTest> clone() const = 0;
47 
48  /// Returns true if subject passes this ValueTest.
49  virtual bool test(const char * /* dummy */) const = 0;
50 };
51 
52 
53 } // namespace hext
54 
55 
56 #endif // HEXT_VALUE_TEST_H_INCLUDED
57 
virtual bool test(const char *) const =0
Returns true if subject passes this ValueTest.
ValueTest & operator=(const ValueTest &)=default
Abstract base for every ValueTest.
Definition: ValueTest.h:35
virtual std::unique_ptr< ValueTest > clone() const =0
Clones derived object.
virtual ~ValueTest() noexcept=default
ValueTest() noexcept=default