15 #ifndef HEXT_RULE_H_INCLUDED
16 #define HEXT_RULE_H_INCLUDED
104 bool optional =
false,
105 bool greedy =
false) noexcept;
121 bool optional = false,
122 bool greedy = false) noexcept;
131 const
Rule * child() const noexcept;
134 const
Rule * next() const noexcept;
137 const std::vector<
Rule>& nested() const noexcept;
146 std::vector<
Rule>& nested() noexcept;
176 template<typename MatchType, typename... Args>
177 Rule& append_match(Args&&... arg)
179 return this->append_match(
180 std::make_unique<MatchType>(std::forward<Args>(arg)...));
193 template<
typename CaptureType,
typename... Args>
196 return this->append_capture(
197 std::make_unique<CaptureType>(std::forward<Args>(arg)...));
209 bool is_optional() const noexcept;
214 Rule& set_optional(
bool optional) noexcept;
217 bool is_greedy() const noexcept;
222 Rule& set_greedy(
bool greedy) noexcept;
227 std::optional<std::
string> get_tagname() const;
234 Rule& set_tagname(const std::
string& tagname);
244 std::uint64_t max_searches = 0) const;
254 std::uint64_t max_searches = 0) const;
259 bool matches(const GumboNode * node) const;
264 std::vector<
ResultPair> capture(const GumboNode * node) const;
269 std::unique_ptr<
Rule> first_child_;
270 std::unique_ptr<
Rule> next_;
271 std::vector<
Rule> nested_;
272 std::vector<std::unique_ptr<
Match>> matches_;
273 std::vector<std::unique_ptr<
Capture>> captures_;
278 std::optional<std::
string> tagname_;
Typedefs for results returned from capturing HTML.
Defines HEXT_PUBLIC and HEXT_PRIVATE.
Abstract base for every Capture.
A RAII wrapper for Gumbo.
Abstract base for every Match.
Extracts values from HTML.
Rule & append_capture(Args &&... arg)
Emplaces a Capture.
Rule(HtmlTag tag=HtmlTag::ANY, bool optional=false, bool greedy=false) noexcept
Constructs a Rule with a known HTML tag.
HtmlTag get_tag() const noexcept
Returns the HtmlTag this rule matches.
Rule & append_capture(std::unique_ptr< Capture > cap)
Appends a Capture.
HtmlTag
An enum containing all valid HTML tags.
std::pair< std::string, std::string > ResultPair
A string-pair containing a name and a value.
std::vector< ResultMap > Result
A vector containing ResultMap.