libhext: C++ Library Documentation  1.0.8-3ad0ae4
Builtins.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_BUILTINS_H_INCLUDED
16 #define HEXT_BUILTINS_H_INCLUDED
17 
18 /// @file
19 /// Contains every predefined CaptureFunction.
20 
21 #include "hext/CaptureFunction.h"
22 #include "hext/Visibility.h"
23 
24 
25 namespace hext {
26 
27 
28 /// A CaptureFunction that returns the text of an HTML element.
29 /// The intent is to mimic functions like jQuery's text(), IE's innerText() or
30 /// textContent().
31 ///
32 /// @par Example:
33 /// ~~~~~~~~~~~~~
34 /// GumboNode * node = ...; // <div> like<div>a</div>rolling stone</div>
35 /// assert(TextBuiltin(node) == "like a rolling stone");
36 /// ~~~~~~~~~~~~~
37 ///
38 /// @param node: A pointer to a GumboNode.
39 /// @returns A string containing the HTML element's text.
41 
42 
43 /// A CaptureFunction that returns the inner HTML of an HTML element.
44 /// The intent is to mimic innerHtml().
45 ///
46 /// @par Example:
47 /// ~~~~~~~~~~~~~
48 /// GumboNode * node = ...; // <div> like<div>a</div>rolling stone</div>
49 /// assert(InnerHtmlBuiltin(node) == " like<div>a</div>rolling stone");
50 /// ~~~~~~~~~~~~~
51 ///
52 /// @param node: A pointer to a GumboNode.
53 /// @returns A string containing the HTML element's inner HTML.
55 
56 
57 /// A CaptureFunction that returns the inner HTML of an HTML element without
58 /// tags.
59 ///
60 /// @par Example:
61 /// ~~~~~~~~~~~~~
62 /// GumboNode * node = ...; // <div> like<div>a</div>rolling stone</div>
63 /// assert(StripTagsBuiltin(node) == " likearolling stone");
64 /// ~~~~~~~~~~~~~
65 ///
66 /// @param node: A pointer to a GumboNode.
67 /// @returns A string containing the HTML element's inner HTML without tags.
69 
70 
71 } // namespace hext
72 
73 
74 #endif // HEXT_BUILTINS_H_INCLUDED
75 
Declares hext::CaptureFunction.
Defines HEXT_PUBLIC and HEXT_PRIVATE.
#define HEXT_PUBLIC
Definition: Visibility.h:26
HEXT_PUBLIC const CaptureFunction StripTagsBuiltin
A CaptureFunction that returns the inner HTML of an HTML element without tags.
HEXT_PUBLIC const CaptureFunction InnerHtmlBuiltin
A CaptureFunction that returns the inner HTML of an HTML element.
std::function< std::string(const GumboNode *)> CaptureFunction
A type of std::function that receives an HTML element and returns a string.
HEXT_PUBLIC const CaptureFunction TextBuiltin
A CaptureFunction that returns the text of an HTML element.