libhext: C++ Library Documentation  1.0.12-3ea013c
ValueTest.h
Go to the documentation of this file.
1 // Copyright 2015, 2016 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 "hext/Visibility.h"
22 
23 #include <memory>
24 
25 
26 namespace hext {
27 
28 
29 /// Abstract base for every ValueTest.
30 /// ValueTests determine whether a string passes a certain test.
31 ///
32 /// Note: You probably don't want to inherit from this class directly, unless
33 /// you want to provide your own ValueTest::clone() method. If your
34 /// subclass has a copy constructor, you can extend from
35 /// hext::Cloneable<YourSubclass, hext::ValueTest> which provides a
36 /// generic clone method.
38 {
39 public:
40  ValueTest() noexcept = default;
41  ValueTest(const ValueTest&) = default;
42  ValueTest(ValueTest&&) noexcept = default;
43  ValueTest& operator=(const ValueTest&) = default;
44  ValueTest& operator=(ValueTest&&) noexcept = default;
45  virtual ~ValueTest() noexcept = default;
46 
47  /// Clones derived object.
48  virtual std::unique_ptr<ValueTest> clone() const = 0;
49 
50  /// Returns true if subject passes this ValueTest.
51  virtual bool test(const char * /* dummy */) const = 0;
52 };
53 
54 
55 } // namespace hext
56 
57 
58 #endif // HEXT_VALUE_TEST_H_INCLUDED
59 
Defines HEXT_PUBLIC and HEXT_PRIVATE.
#define HEXT_PUBLIC
Definition: Visibility.h:26
Abstract base for every ValueTest.
Definition: ValueTest.h:38
ValueTest() noexcept=default