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