libhext: C++ Library Documentation 1.0.13-b24695d
Loading...
Searching...
No Matches
TypeRegexMatch.h
Go to the documentation of this file.
1// Copyright 2024 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_TYPE_REGEX_MATCH_H_INCLUDED
16#define HEXT_TYPE_REGEX_MATCH_H_INCLUDED
17
18/// @file
19/// Declares hext::TypeRegexMatch
20
21#include "hext/Cloneable.h"
22#include "hext/Match.h"
23#include "hext/Visibility.h"
24
25#include <boost/regex.hpp>
26#include <gumbo.h>
27
28
29namespace hext {
30
31
32/// Matches the name of an HTML element against a regular expression.
33class HEXT_PUBLIC TypeRegexMatch final : public Cloneable<TypeRegexMatch, Match>
34{
35public:
36 /// Constructs a TypeRegexMatch.
37 ///
38 /// @param regex: The regular expression that is applied against a tag name.
39 explicit TypeRegexMatch(boost::regex regex);
40
41 /// Returns true if the node has a tag name which matches the given regex.
42 ///
43 /// @param node: A pointer to a GumboNode.
44 bool matches(const GumboNode * node) const override;
45
46private:
47 /// The regex an HTML Elelement's tag name has to match.
48 boost::regex rx_;
49};
50
51
52} // namespace hext
53
54
55#endif // HEXT_TYPE_REGEX_MATCH_H_INCLUDED
56
Defines template hext::Cloneable.
Declares hext::Match.
Defines HEXT_PUBLIC and HEXT_PRIVATE.
#define HEXT_PUBLIC
Definition Visibility.h:26
Curiously recurring template pattern that extends a base class to provide a virtual method Cloneable:...
Definition Cloneable.h:37
Matches the name of an HTML element against a regular expression.
TypeRegexMatch(boost::regex regex)
Constructs a TypeRegexMatch.
bool matches(const GumboNode *node) const override
Returns true if the node has a tag name which matches the given regex.