All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
Match.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_MATCH_H_INCLUDED
16 #define HEXT_MATCH_H_INCLUDED
17 
18 /// @file
19 /// Declares hext::Match
20 
21 #include <memory>
22 
23 #include <gumbo.h>
24 
25 
26 namespace hext {
27 
28 
29 /// Abstract base for every Match.
30 ///
31 /// Matches are applied to HTML nodes with Match::matches() which will
32 /// return true if the HTML node matches.
33 ///
34 /// Note: You probably don't want to inherit from this class directly, unless
35 /// you want to provide your own Match::clone() method. If your subclass
36 /// has a copy constructor, you can extend from
37 /// hext::Cloneable<YourSubclass, hext::Match> which provides a generic
38 /// clone method.
39 class Match
40 {
41 public:
42  Match() noexcept = default;
43  Match(const Match&) = default;
44  Match(Match&&) noexcept = default;
45  Match& operator=(const Match&) = default;
46  Match& operator=(Match&&) noexcept = default;
47  virtual ~Match() noexcept = default;
48 
49  /// Clones derived object.
50  virtual std::unique_ptr<Match> clone() const = 0;
51 
52  /// Returns true if this Match matches node.
53  virtual bool matches(const GumboNode * node) const = 0;
54 };
55 
56 
57 } // namespace hext
58 
59 
60 #endif // HEXT_MATCH_H_INCLUDED
61 
Match() noexcept=default
Abstract base for every Match.
Definition: Match.h:39
virtual std::unique_ptr< Match > clone() const =0
Clones derived object.
Match & operator=(const Match &)=default
virtual bool matches(const GumboNode *node) const =0
Returns true if this Match matches node.
virtual ~Match() noexcept=default