PugiXML.xs

filter: Statementstmt 96.3% 574 / 596 Branchbran 51.8% 735 / 1418 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 65.0% 1309 / 2014 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
↑ Summary blib/lib/XML/PugiXML.pm »
1 /* C++ headers before Perl to avoid macro conflicts (do_open/do_close vs <locale>) */
2 #include <pugixml.hpp>
3  
4 /* Hard floor: the binding references format_no_empty_element_tags, added in
5 pugixml 1.8 (PUGIXML_VERSION 180). Fail the build with a clear message rather
6 than a cryptic C++ error if compiled against an older header (e.g. a system
7 lib whose pkg-config over-reported its version). ensure_child / ensure_attr
8 transparently emulate the 1.16 API below 1160. */
9 #if PUGIXML_VERSION < 180
10 # error "XML::PugiXML requires pugixml >= 1.8 (format_no_empty_element_tags)"
11 #endif
12  
13 #include <sstream>
14 #include <string>
15 #include <vector>
16 #include <cerrno>
17 #include <cstring>
18  
19 #define PERL_NO_GET_CONTEXT
20 #include "EXTERN.h"
21 #include "perl.h"
22 #include "XSUB.h"
23  
24 using namespace pugi;
25  
26 /* A const char* whose typemap rejects an embedded NUL byte. Plain const char*
27 args use SvPV_nolen and would silently truncate a name/value at the first
28 NUL (storing a different string than was passed); NUL is invalid in XML 1.0
29 anyway. Used for the string arguments of the tree-mutation methods. */
30 typedef const char* nul_safe_pv;
31  
32 /* SvPV with an embedded-NUL guard, used by the nul_safe_pv typemap. Keep it a
33 function (not inline typemap code): an inline INPUT block with a quoted
34 croak() breaks ExtUtils::ParseXS template interpolation on some versions
35 (the '"' ends the interpolated string), which mis-emits the argument and
36 then crashes pugixml on a NULL. The typemap INPUT just calls this. */
37 16752 static const char* ng_check_nul(pTHX_ SV* sv) {
38 STRLEN len;
39 16752 const char* p = SvPV(sv, len);
40 16752 ▶ if (strlen(p) != len)
Branch: 1 branch
BranchTrueFalseTotal
if (strlen(p) != len) 23 16729 16752
41 23 croak("XML::PugiXML: string argument contains an embedded NUL byte (invalid in XML)");
42 16729 return p;
43 }
44  
45 /* Compiled XPath wrapper */
46 struct PugiXPath {
47 xpath_query* query;
48 };
49  
50 /* Wrapper structures.
51  
52 A handle is invalidated by either of two independent mechanisms:
53  
54 * generation -- bumped by reset()/load_file()/load_string(), which replace
55 the whole tree at once. Each wrapper snapshots it at creation.
56 * the `dead` flag -- set by remove_child()/remove_attr() on exactly those
57 wrappers that point into the removed subtree. pugixml's remove_* really
58 do free the storage (destroy_tree -> deallocate_memory; a fully-freed
59 non-top page is handed back to the system with free()), so a surviving
60 Perl handle into a removed subtree is a dangling pointer rather than a
61 harmless orphan. Finding those wrappers needs a registry.
62  
63 The registry is a per-document hash index keyed by the pugixml pointer each
64 wrapper holds, with the chain links stored inside the wrapper (no per-entry
65 allocation). Keying it that way is what keeps removal cheap: invalidation
66 walks the subtree being destroyed and probes the index for each node and
67 attribute in it, so it costs O(removed subtree) -- the same order pugixml
68 already pays in destroy_tree -- rather than O(live handles). A flat list
69 would instead make the ordinary idiom
70  
71 $root->remove_child($_) for $root->children;
72  
73 quadratic, because every removal would rescan every retained handle.
74  
75 Note the index is probed by pointer VALUE and never dereferences a stored
76 pugixml pointer, so entries left behind by a reset/reload (whose pointers
77 dangle) are safe to walk past; the gen_snap guard skips them anyway.
78  
79 Removed handles leave the index once removal succeeds, so reused addresses
80 do not accumulate dead entries. `owner` is then NULL, as it is after the
81 document's DESTROY detaches handles during global destruction. */
82  
83 struct PugiNode;
84 struct PugiAttr;
85  
86 struct PugiDoc {
87 xml_document* doc;
88 unsigned int generation; /* Incremented on reset/load to detect stale handles */
89 PugiNode** node_buckets; /* Hash index of live node wrappers */
90 size_t node_nbuckets; /* Always a power of two, never 0 after new() */
91 size_t node_count;
92 PugiAttr** attr_buckets; /* Hash index of live attribute wrappers */
93 size_t attr_nbuckets;
94 size_t attr_count;
95 };
96  
97 /* hnext/hprev are the intrusive hash chain. hprev is the address of the link
98 pointing AT this wrapper (a bucket slot, or the previous entry's hnext),
99 which makes unlinking O(1) without a back-pointer to the entry itself. */
100 struct PugiNode {
101 xml_node node;
102 SV* doc_sv; /* Reference to document to keep it alive */
103 PugiDoc* owner; /* NULL once detached from the index */
104 unsigned int gen_snap; /* owner->generation at creation time */
105 bool dead; /* Removed from the tree: storage is gone */
106 PugiNode* hnext;
107 PugiNode** hprev;
108 };
109  
110 struct PugiAttr {
111 xml_attribute attr;
112 xml_node parent_node; /* Element owning this attribute */
113 SV* doc_sv; /* Reference to document to keep it alive */
114 PugiDoc* owner; /* NULL once detached from the index */
115 unsigned int gen_snap; /* owner->generation at creation time */
116 bool dead; /* Removed from its element: storage is gone */
117 PugiAttr* hnext;
118 PugiAttr** hprev;
119 };
120  
121 typedef PugiDoc* XML__PugiXML;
122 typedef PugiNode* XML__PugiXML__Node;
123 typedef PugiAttr* XML__PugiXML__Attr;
124 typedef PugiXPath* XML__PugiXML__XPath;
125  
126  
127 #define CHECK_DOC_ALIVE(self) STMT_START { \
128 if (!(self) || !(self)->doc) \
129 croak("Document handle is uninitialized or has been destroyed"); \
130 } STMT_END
131  
132 #define CHECK_XPATH_ALIVE(self) STMT_START { \
133 if (!(self) || !(self)->query) \
134 croak("XPath handle is uninitialized or has been destroyed"); \
135 } STMT_END
136  
137 /* True once the whole tree the handle was taken from has been replaced. */
138 #define HANDLE_STALE(self) \
139 (!(self) || !(self)->owner || (self)->gen_snap != (self)->owner->generation)
140  
141 #define CHECK_NODE_ALIVE(self) STMT_START { \
142 if (!(self)) \
143 croak("Node handle is uninitialized or has been destroyed"); \
144 if (HANDLE_STALE(self)) \
145 croak("Stale node handle: %s", (self)->dead \
146 ? "node has been removed from the document" \
147 : "document has been reset or reloaded"); \
148 } STMT_END
149  
150 #define CHECK_ATTR_ALIVE(self) STMT_START { \
151 if (!(self)) \
152 croak("Attribute handle is uninitialized or has been destroyed"); \
153 if (HANDLE_STALE(self)) \
154 croak("Stale attribute handle: %s", (self)->dead \
155 ? "attribute has been removed from its element" \
156 : "document has been reset or reloaded"); \
157 } STMT_END
158  
159 /* Two handles share a document iff they name the same PugiDoc. insert_child_*
160 / remove_child require the ref/child argument to live in the same document
161 as self; pugixml otherwise silently returns a null node. Only used after
162 CHECK_*_ALIVE, so neither owner is NULL. */
163 #define CHECK_SAME_DOC(a, b) \
164 if ((a)->owner != (b)->owner) \
165 croak("Node belongs to a different document")
166  
167 /* croak() longjmps out of a catch block, skipping __cxa_end_catch and leaking
168 the caught C++ exception object (kept reachable on the EH chain, ~150 bytes
169 each) on every caught exception. So stash the message in the catch and croak
170 only AFTER it has unwound. XPATH_GUARDED opens the guarded block;
171 END_XPATH_GUARDED closes it with the standard XPath-error handlers. */
172 #define XPATH_GUARDED char xpath_err[256]; xpath_err[0] = '\0'; try
173 #define END_XPATH_GUARDED \
174 catch (const xpath_exception& e) { snprintf(xpath_err, sizeof(xpath_err), "XPath error: %s", e.what()); } \
175 catch (const std::exception& e) { snprintf(xpath_err, sizeof(xpath_err), "Internal XPath error: %s", e.what()); } \
176 if (xpath_err[0]) croak("%s", xpath_err)
177  
178 /* Helper functions */
179  
180 /* --- Hash index of live wrappers -------------------------------------- */
181  
182 #define PUGI_HIDX_MIN 16 /* initial bucket count, power of two */
183  
184 23938 static size_t ptr_hash(const void* p) {
185 23938 size_t x = (size_t)p;
186 23938 x >>= 4; /* pugixml structs are at least 16-byte aligned */
187 23938 x ^= x >> 16;
188 23938 return x;
189 }
190  
191 /* Both wrapper types expose the same hnext/hprev members, so one set of
192 templates serves both indexes. */
193  
194 1248 static const void* wrapper_key(PugiNode* n) { return n->node.internal_object(); }
195 240 static const void* wrapper_key(PugiAttr* a) { return a->attr.internal_object(); }
196  
197 template <typename W>
198 15910 static void hidx_insert(W** buckets, size_t nbuckets, W* w, const void* key) {
199 15910 W** head = &buckets[ptr_hash(key) & (nbuckets - 1)];
200 15910 w->hnext = *head;
201 15910 ▶ if (*head) (*head)->hprev = &w->hnext;
Branch: 2 branches
BranchTrueFalseTotal
if (*head) (*head)->hprev = &w->hnext; 72 440 512
if (*head) (*head)->hprev = &w->hnext; 2246 13152 15398
202 15910 w->hprev = head;
203 15910 *head = w;
204 15910 }
205  
206 template <typename W>
207 14418 static void hidx_erase(W* w) {
208 14418 ▶ if (!w->hprev) return;
Branch: 2 branches
BranchTrueFalseTotal
if (!w->hprev) return; 0 270 270
if (!w->hprev) return; 0 14148 14148
209 14418 *(w->hprev) = w->hnext;
210 14418 ▶ if (w->hnext) w->hnext->hprev = w->hprev;
Branch: 2 branches
BranchTrueFalseTotal
if (w->hnext) w->hnext->hprev = w->hprev; 14 256 270
if (w->hnext) w->hnext->hprev = w->hprev; 1173 12975 14148
211 14418 w->hnext = NULL;
212 14418 w->hprev = NULL;
213 }
214  
215 /* Double the table. Best-effort: on allocation failure the old table stays
216 valid and simply carries longer chains, so this never has to fail loudly. */
217 template <typename W>
218 14 static void hidx_grow(W*** pbuckets, size_t* pnbuckets) {
219 14 size_t newn = *pnbuckets * 2;
220 14 W** nb = (W**)calloc(newn, sizeof(W*));
221 14 ▶ if (!nb) return;
Branch: 2 branches
BranchTrueFalseTotal
if (!nb) return; 0 4 4
if (!nb) return; 0 10 10
222 1502 ▶ for (size_t i = 0; i < *pnbuckets; i++)
Branch: 2 branches
BranchTrueFalseTotal
for (size_t i = 0; i < *pnbuckets; i++) 240 4 244
for (size_t i = 0; i < *pnbuckets; i++) 1248 10 1258
223 2976 ▶ for (W* w = (*pbuckets)[i]; w; ) {
Branch: 2 branches
BranchTrueFalseTotal
for (W* w = (*pbuckets)[i]; w; ) { 240 240 480
for (W* w = (*pbuckets)[i]; w; ) { 1248 1248 2496
224 1488 W* next = w->hnext;
225 1488 hidx_insert(nb, newn, w, wrapper_key(w));
226 1488 w = next;
227 }
228 14 free(*pbuckets);
229 14 *pbuckets = nb;
230 14 *pnbuckets = newn;
231 }
232  
233 14150 static void doc_register_node(PugiDoc* doc, PugiNode* n) {
234 14150 ▶ if (doc->node_count + 1 > doc->node_nbuckets)
Branch: 1 branch
BranchTrueFalseTotal
if (doc->node_count + 1 > doc->node_nbuckets) 10 14140 14150
235 10 hidx_grow(&doc->node_buckets, &doc->node_nbuckets);
236 14150 n->owner = doc;
237 14150 hidx_insert(doc->node_buckets, doc->node_nbuckets, n, n->node.internal_object());
238 14150 doc->node_count++;
239 14150 }
240  
241 14169 static void doc_unregister_node(PugiNode* n) {
242 14169 ▶ if (!n->owner) return;
Branch: 1 branch
BranchTrueFalseTotal
if (!n->owner) return; 21 14148 14169
243 14148 hidx_erase(n);
244 14148 n->owner->node_count--;
245 14148 n->owner = NULL;
246 }
247  
248 272 static void doc_register_attr(PugiDoc* doc, PugiAttr* a) {
249 272 ▶ if (doc->attr_count + 1 > doc->attr_nbuckets)
Branch: 1 branch
BranchTrueFalseTotal
if (doc->attr_count + 1 > doc->attr_nbuckets) 4 268 272
250 4 hidx_grow(&doc->attr_buckets, &doc->attr_nbuckets);
251 272 a->owner = doc;
252 272 hidx_insert(doc->attr_buckets, doc->attr_nbuckets, a, a->attr.internal_object());
253 272 doc->attr_count++;
254 272 }
255  
256 278 static void doc_unregister_attr(PugiAttr* a) {
257 278 ▶ if (!a->owner) return;
Branch: 1 branch
BranchTrueFalseTotal
if (!a->owner) return; 8 270 278
258 270 hidx_erase(a);
259 270 a->owner->attr_count--;
260 270 a->owner = NULL;
261 }
262  
263 /* --- Invalidation ------------------------------------------------------ */
264  
265 /* Kill every live handle to `n` itself and to its attributes, recording what
266 was killed so a removal that pugixml then refuses can be undone exactly.
267 Only wrappers this call marks are recorded, so undoing can never resurrect
268 a handle that was already dead. */
269 8022 static void kill_handles_for(PugiDoc* doc, xml_node n,
270 std::vector<PugiNode*>& killed_nodes,
271 std::vector<PugiAttr*>& killed_attrs) {
272 8022 const void* nkey = n.internal_object();
273 8022 for (PugiNode* p = doc->node_buckets[ptr_hash(nkey) & (doc->node_nbuckets - 1)];
274 10045 ▶ p; p = p->hnext)
Branch: 1 branch
BranchTrueFalseTotal
p; p = p->hnext) 2023 8022 10045
275 2023 ▶ if (!p->dead && p->gen_snap == doc->generation && p->node == n) {
Branch: 5 branches
BranchTrueFalseTotal
if (!p->dead && p->gen_snap == doc->generation && p->node == n) { 1276 747 2023
if (!p->dead && p->gen_snap == doc->generation && p->node == n) { 1276 0 1276
if (!p->dead && p->gen_snap == doc->generation && p->node == n) { 1276 0 1276
if (!p->dead && p->gen_snap == doc->generation && p->node == n) { 19 1257 1276
if (!p->dead && p->gen_snap == doc->generation && p->node == n) { 19 2004 2023
276 19 ▶ killed_nodes.push_back(p);
Branch: 1 branch
BranchTrueFalseTotal
killed_nodes.push_back(p); 19 0 19
277 19 p->dead = true;
278 }
279  
280 8030 ▶ for (xml_attribute a = n.first_attribute(); a; a = a.next_attribute()) {
Branch: 4 branches
BranchTrueFalseTotal
for (xml_attribute a = n.first_attribute(); a; a = a.next_attribute()) { 8022 0 8022
for (xml_attribute a = n.first_attribute(); a; a = a.next_attribute()) { 4 0 4
for (xml_attribute a = n.first_attribute(); a; a = a.next_attribute()) { 8026 0 8026
for (xml_attribute a = n.first_attribute(); a; a = a.next_attribute()) { 4 8022 8026
281 4 ▶ const void* akey = a.internal_object();
Branch: 1 branch
BranchTrueFalseTotal
const void* akey = a.internal_object(); 4 0 4
282 4 for (PugiAttr* q = doc->attr_buckets[ptr_hash(akey) & (doc->attr_nbuckets - 1)];
283 8 ▶ q; q = q->hnext)
Branch: 1 branch
BranchTrueFalseTotal
q; q = q->hnext) 4 4 8
284 4 ▶ if (!q->dead && q->gen_snap == doc->generation && q->attr == a) {
Branch: 5 branches
BranchTrueFalseTotal
if (!q->dead && q->gen_snap == doc->generation && q->attr == a) { 4 0 4
if (!q->dead && q->gen_snap == doc->generation && q->attr == a) { 4 0 4
if (!q->dead && q->gen_snap == doc->generation && q->attr == a) { 4 0 4
if (!q->dead && q->gen_snap == doc->generation && q->attr == a) { 4 0 4
if (!q->dead && q->gen_snap == doc->generation && q->attr == a) { 4 0 4
285 4 ▶ killed_attrs.push_back(q);
Branch: 1 branch
BranchTrueFalseTotal
killed_attrs.push_back(q); 4 0 4
286 4 q->dead = true;
287 }
288 }
289 8022 }
290  
291 struct KillWalker : public xml_tree_walker {
292 PugiDoc* doc;
293 std::vector<PugiNode*>* killed_nodes;
294 std::vector<PugiAttr*>* killed_attrs;
295 8009 virtual bool for_each(xml_node& n) {
296 8009 kill_handles_for(doc, n, *killed_nodes, *killed_attrs);
297 8009 return true;
298 }
299 };
300  
301 /* Mark every live handle pointing into the subtree rooted at `victim` dead.
302 MUST run before pugixml frees that subtree, while it is still walkable. */
303 13 static void invalidate_subtree(PugiDoc* doc, xml_node victim,
304 std::vector<PugiNode*>& killed_nodes,
305 std::vector<PugiAttr*>& killed_attrs) {
306 13 ▶ kill_handles_for(doc, victim, killed_nodes, killed_attrs); /* traverse() starts below victim */
Branch: 1 branch
BranchTrueFalseTotal
kill_handles_for(doc, victim, killed_nodes, killed_attrs); /* traverse() starts below victim */ 13 0 13
307 13 ▶ KillWalker w;
Branch: 1 branch
BranchTrueFalseTotal
KillWalker w; 13 0 13
308 13 w.doc = doc;
309 13 w.killed_nodes = &killed_nodes;
310 13 w.killed_attrs = &killed_attrs;
311 13 ▶ victim.traverse(w);
Branch: 1 branch
BranchTrueFalseTotal
victim.traverse(w); 13 0 13
312 13 }
313  
314 2 static void invalidate_attribute(PugiDoc* doc, xml_attribute victim,
315 std::vector<PugiAttr*>& killed_attrs) {
316 2 const void* key = victim.internal_object();
317 2 for (PugiAttr* q = doc->attr_buckets[ptr_hash(key) & (doc->attr_nbuckets - 1)];
318 4 ▶ q; q = q->hnext)
Branch: 1 branch
BranchTrueFalseTotal
q; q = q->hnext) 2 2 4
319 2 ▶ if (!q->dead && q->gen_snap == doc->generation && q->attr == victim) {
Branch: 5 branches
BranchTrueFalseTotal
if (!q->dead && q->gen_snap == doc->generation && q->attr == victim) { 2 0 2
if (!q->dead && q->gen_snap == doc->generation && q->attr == victim) { 2 0 2
if (!q->dead && q->gen_snap == doc->generation && q->attr == victim) { 2 0 2
if (!q->dead && q->gen_snap == doc->generation && q->attr == victim) { 2 0 2
if (!q->dead && q->gen_snap == doc->generation && q->attr == victim) { 2 0 2
320 2 ▶ killed_attrs.push_back(q);
Branch: 1 branch
BranchTrueFalseTotal
killed_attrs.push_back(q); 2 0 2
321 2 q->dead = true;
322 }
323 2 }
324  
325 /* pugixml's remove_child/remove_attribute re-check an allocator reserve AFTER
326 the ownership check and can still return false, leaving the subtree alive.
327 Undo the invalidation in that case so the handles are not falsely stale. */
328 2 static void revive_handles(std::vector<PugiNode*>& nodes, std::vector<PugiAttr*>& attrs) {
329 2 ▶ for (size_t i = 0; i < nodes.size(); i++) nodes[i]->dead = false;
Branch: 1 branch
BranchTrueFalseTotal
for (size_t i = 0; i < nodes.size(); i++) nodes[i]->dead = false; 0 2 2
330 2 ▶ for (size_t i = 0; i < attrs.size(); i++) attrs[i]->dead = false;
Branch: 1 branch
BranchTrueFalseTotal
for (size_t i = 0; i < attrs.size(); i++) attrs[i]->dead = false; 0 2 2
331 2 }
332  
333 15 static void retire_handles(std::vector<PugiNode*>& nodes, std::vector<PugiAttr*>& attrs) {
334 34 ▶ for (size_t i = 0; i < nodes.size(); i++) doc_unregister_node(nodes[i]);
Branch: 1 branch
BranchTrueFalseTotal
for (size_t i = 0; i < nodes.size(); i++) doc_unregister_node(nodes[i]); 19 15 34
335 21 ▶ for (size_t i = 0; i < attrs.size(); i++) doc_unregister_attr(attrs[i]);
Branch: 1 branch
BranchTrueFalseTotal
for (size_t i = 0; i < attrs.size(); i++) doc_unregister_attr(attrs[i]); 6 15 21
336 15 }
337  
338 14162 static SV* wrap_node(pTHX_ xml_node node, SV* doc_sv) {
339 14162 ▶ if (!node) {
Branch: 1 branch
BranchTrueFalseTotal
if (!node) { 12 14150 14162
340 12 return &PL_sv_undef;
341 }
342  
343 14150 ▶ if (!doc_sv || !SvROK(doc_sv)) {
Branch: 2 branches
BranchTrueFalseTotal
if (!doc_sv || !SvROK(doc_sv)) { 14150 0 14150
if (!doc_sv || !SvROK(doc_sv)) { 0 14150 14150
344 0 croak("Document reference is invalid");
345 }
346 14150 PugiDoc* doc = INT2PTR(PugiDoc*, SvIV(SvRV(doc_sv)));
347 14150 ▶ if (!doc || !doc->doc) {
Branch: 2 branches
BranchTrueFalseTotal
if (!doc || !doc->doc) { 14150 0 14150
if (!doc || !doc->doc) { 0 14150 14150
348 0 croak("Document handle is uninitialized or has been destroyed");
349 }
350 14150 ▶ PugiNode* wrapper = new (std::nothrow) PugiNode;
Branch: 4 branches
BranchTrueFalseTotal
PugiNode* wrapper = new (std::nothrow) PugiNode; 14150 0 14150
PugiNode* wrapper = new (std::nothrow) PugiNode; 14150 0 14150
PugiNode* wrapper = new (std::nothrow) PugiNode; 0 0 0
PugiNode* wrapper = new (std::nothrow) PugiNode; 0 0 0
351 14150 ▶ if (!wrapper) {
Branch: 1 branch
BranchTrueFalseTotal
if (!wrapper) { 0 14150 14150
352 0 croak("Out of memory allocating node wrapper");
353 }
354 14150 wrapper->node = node;
355 14150 wrapper->doc_sv = newRV_inc(SvRV(doc_sv));
356 14150 wrapper->gen_snap = doc->generation;
357 14150 wrapper->dead = false;
358 14150 doc_register_node(doc, wrapper);
359  
360 14150 SV* sv = newSV(0);
361 14150 sv_setref_pv(sv, "XML::PugiXML::Node", (void*)wrapper);
362 14150 return sv;
363 }
364  
365 275 static SV* wrap_attr(pTHX_ xml_attribute attr, xml_node parent, SV* doc_sv) {
366 275 ▶ if (!attr) {
Branch: 1 branch
BranchTrueFalseTotal
if (!attr) { 3 272 275
367 3 return &PL_sv_undef;
368 }
369  
370 272 ▶ if (!doc_sv || !SvROK(doc_sv)) {
Branch: 2 branches
BranchTrueFalseTotal
if (!doc_sv || !SvROK(doc_sv)) { 272 0 272
if (!doc_sv || !SvROK(doc_sv)) { 0 272 272
371 0 croak("Document reference is invalid");
372 }
373 272 PugiDoc* doc = INT2PTR(PugiDoc*, SvIV(SvRV(doc_sv)));
374 272 ▶ if (!doc || !doc->doc) {
Branch: 2 branches
BranchTrueFalseTotal
if (!doc || !doc->doc) { 272 0 272
if (!doc || !doc->doc) { 0 272 272
375 0 croak("Document handle is uninitialized or has been destroyed");
376 }
377 272 ▶ PugiAttr* wrapper = new (std::nothrow) PugiAttr;
Branch: 4 branches
BranchTrueFalseTotal
PugiAttr* wrapper = new (std::nothrow) PugiAttr; 272 0 272
PugiAttr* wrapper = new (std::nothrow) PugiAttr; 272 0 272
PugiAttr* wrapper = new (std::nothrow) PugiAttr; 0 0 0
PugiAttr* wrapper = new (std::nothrow) PugiAttr; 0 0 0
378 272 ▶ if (!wrapper) {
Branch: 1 branch
BranchTrueFalseTotal
if (!wrapper) { 0 272 272
379 0 croak("Out of memory allocating attr wrapper");
380 }
381 272 wrapper->attr = attr;
382 272 wrapper->parent_node = parent;
383 272 wrapper->doc_sv = newRV_inc(SvRV(doc_sv));
384 272 wrapper->gen_snap = doc->generation;
385 272 wrapper->dead = false;
386 272 doc_register_attr(doc, wrapper);
387  
388 272 SV* sv = newSV(0);
389 272 sv_setref_pv(sv, "XML::PugiXML::Attr", (void*)wrapper);
390 272 return sv;
391 }
392  
393 /* Wrap an XPath result -- returns Node or Attr depending on what matched */
394 38 static SV* wrap_xpath_result(pTHX_ const xpath_node& xnode, SV* doc_sv) {
395 38 ▶ if (xnode.attribute()) {
Branch: 3 branches
BranchTrueFalseTotal
if (xnode.attribute()) { 38 0 38
if (xnode.attribute()) { 38 0 38
if (xnode.attribute()) { 14 24 38
396 14 return wrap_attr(aTHX_ xnode.attribute(), xnode.parent(), doc_sv);
397 }
398 24 return wrap_node(aTHX_ xnode.node(), doc_sv);
399 }
400  
401 /* Helpers to return UTF-8 strings */
402 104 static SV* newSVpv_utf8(pTHX_ const char* str) {
403 104 SV* sv = newSVpv(str, 0);
404 104 SvUTF8_on(sv);
405 104 return sv;
406 }
407  
408 24 static SV* new_utf8_svpvn(pTHX_ const char* str, STRLEN len) {
409 24 SV* sv = newSVpvn(str, len);
410 24 SvUTF8_on(sv);
411 24 return sv;
412 }
413  
414 155 static void set_parse_result(pTHX_ xml_parse_result& result) {
415 155 ▶ if (!result) {
Branch: 1 branch
BranchTrueFalseTotal
if (!result) { 6 149 155
416 6 sv_setpvf(get_sv("@", GV_ADD), "XML parse error: %s at offset %" IVdf,
417 result.description(), (IV)result.offset);
418 } else {
419 149 sv_setpvs(get_sv("@", GV_ADD), "");
420 }
421 155 }
422  
423 MODULE = XML::PugiXML PACKAGE = XML::PugiXML
424  
425 PROTOTYPES: DISABLE
426  
427 XML::PugiXML
428 new(const char* CLASS)
429 CODE:
430 {
431 PERL_UNUSED_VAR(CLASS);
432 142 PugiDoc* doc = new (std::nothrow) PugiDoc;
433 142 ▶ if (!doc) {
Branch: 1 branch
BranchTrueFalseTotal
if (!doc) { 0 142 142
434 0 croak("Out of memory allocating document");
435 }
436 142 ▶ doc->doc = new (std::nothrow) xml_document();
Branch: 4 branches
BranchTrueFalseTotal
doc->doc = new (std::nothrow) xml_document(); 142 0 142
doc->doc = new (std::nothrow) xml_document(); 142 0 142
doc->doc = new (std::nothrow) xml_document(); 0 0 0
doc->doc = new (std::nothrow) xml_document(); 0 0 0
437 142 ▶ if (!doc->doc) {
Branch: 1 branch
BranchTrueFalseTotal
if (!doc->doc) { 0 142 142
438 0 ▶ delete doc;
Branch: 1 branch
BranchTrueFalseTotal
delete doc; 0 0 0
439 0 croak("Out of memory allocating xml_document");
440 }
441 142 doc->generation = 0;
442 /* Allocate both indexes up front so registration can never fail and leave
443 an unindexed (hence never-invalidated) wrapper behind. */
444 142 doc->node_buckets = (PugiNode**)calloc(PUGI_HIDX_MIN, sizeof(PugiNode*));
445 142 doc->attr_buckets = (PugiAttr**)calloc(PUGI_HIDX_MIN, sizeof(PugiAttr*));
446 142 ▶ if (!doc->node_buckets || !doc->attr_buckets) {
Branch: 2 branches
BranchTrueFalseTotal
if (!doc->node_buckets || !doc->attr_buckets) { 142 0 142
if (!doc->node_buckets || !doc->attr_buckets) { 0 142 142
447 0 free(doc->node_buckets);
448 0 free(doc->attr_buckets);
449 0 ▶ delete doc->doc;
Branch: 1 branch
BranchTrueFalseTotal
delete doc->doc; 0 0 0
450 0 ▶ delete doc;
Branch: 1 branch
BranchTrueFalseTotal
delete doc; 0 0 0
451 0 croak("Out of memory allocating document handle index");
452 }
453 142 doc->node_nbuckets = PUGI_HIDX_MIN;
454 142 doc->attr_nbuckets = PUGI_HIDX_MIN;
455 142 doc->node_count = 0;
456 142 doc->attr_count = 0;
457 142 RETVAL = doc;
458 }
459 OUTPUT:
460 RETVAL
461  
462 void
463 DESTROY(XML::PugiXML self)
464 CODE:
465 {
466 146 ▶ if (!self) XSRETURN_EMPTY;
Branch: 1 branch
BranchTrueFalseTotal
if (!self) XSRETURN_EMPTY; 4 142 146
467 /* Global destruction calls DESTROY in arbitrary order and may free the
468 document before the nodes that reference it. Detach every live handle
469 so their own DESTROY does not dereference this struct. */
470 3662 ▶ for (size_t i = 0; i < self->node_nbuckets; i++)
Branch: 1 branch
BranchTrueFalseTotal
for (size_t i = 0; i < self->node_nbuckets; i++) 3520 142 3662
471 3522 ▶ for (PugiNode* p = self->node_buckets[i]; p; ) {
Branch: 1 branch
BranchTrueFalseTotal
for (PugiNode* p = self->node_buckets[i]; p; ) { 2 3520 3522
472 2 PugiNode* next = p->hnext;
473 2 p->owner = NULL; p->hnext = NULL; p->hprev = NULL;
474 2 p = next;
475 }
476 2654 ▶ for (size_t i = 0; i < self->attr_nbuckets; i++)
Branch: 1 branch
BranchTrueFalseTotal
for (size_t i = 0; i < self->attr_nbuckets; i++) 2512 142 2654
477 2514 ▶ for (PugiAttr* a = self->attr_buckets[i]; a; ) {
Branch: 1 branch
BranchTrueFalseTotal
for (PugiAttr* a = self->attr_buckets[i]; a; ) { 2 2512 2514
478 2 PugiAttr* next = a->hnext;
479 2 a->owner = NULL; a->hnext = NULL; a->hprev = NULL;
480 2 a = next;
481 }
482 142 free(self->node_buckets);
483 142 free(self->attr_buckets);
484 142 ▶ delete self->doc;
Branch: 1 branch
BranchTrueFalseTotal
delete self->doc; 142 0 142
485 142 ▶ delete self;
Branch: 1 branch
BranchTrueFalseTotal
delete self; 142 0 142
486 142 ▶ if (SvROK(ST(0))) sv_setiv(SvRV(ST(0)), 0);
Branch: 1 branch
BranchTrueFalseTotal
if (SvROK(ST(0))) sv_setiv(SvRV(ST(0)), 0); 142 0 142
487 }
488  
489 bool
490 load_file(XML::PugiXML self, nul_safe_pv path, unsigned int parse_options = parse_default)
491 CODE:
492 {
493 5 ▶ CHECK_DOC_ALIVE(self);
Branch: 2 branches
BranchTrueFalseTotal
CHECK_DOC_ALIVE(self); 4 1 5
CHECK_DOC_ALIVE(self); 0 4 4
494 4 self->generation++;
495 4 ▶ xml_parse_result result = self->doc->load_file(path, parse_options);
Branch: 1 branch
BranchTrueFalseTotal
xml_parse_result result = self->doc->load_file(path, parse_options); 4 0 4
496 4 ▶ set_parse_result(aTHX_ result);
Branch: 1 branch
BranchTrueFalseTotal
set_parse_result(aTHX_ result); 4 0 4
497 4 ▶ RETVAL = (bool)result;
Branch: 2 branches
BranchTrueFalseTotal
RETVAL = (bool)result; 4 0 4
RETVAL = (bool)result; 2 2 4
498 }
499 OUTPUT:
500 RETVAL
501  
502 bool
503 load_string(XML::PugiXML self, SV* xml_sv, unsigned int parse_options = parse_default)
504 CODE:
505 {
506 153 ▶ CHECK_DOC_ALIVE(self);
Branch: 2 branches
BranchTrueFalseTotal
CHECK_DOC_ALIVE(self); 152 1 153
CHECK_DOC_ALIVE(self); 0 152 152
507 STRLEN xml_len;
508 152 const char* xml = SvPV(xml_sv, xml_len);
509 /* load_string takes a C string, so an embedded NUL would silently
510 truncate the document and parse a different (shorter) one than was
511 passed. NUL is invalid in XML 1.0 anyway -- reject it with a clear
512 error rather than succeed on the truncated prefix. */
513 152 ▶ if (strlen(xml) != xml_len)
Branch: 1 branch
BranchTrueFalseTotal
if (strlen(xml) != xml_len) 1 151 152
514 1 croak("load_string: XML contains an embedded NUL byte (invalid XML)");
515 151 self->generation++;
516 151 ▶ xml_parse_result result = self->doc->load_string(xml, parse_options);
Branch: 1 branch
BranchTrueFalseTotal
xml_parse_result result = self->doc->load_string(xml, parse_options); 151 0 151
517 151 ▶ set_parse_result(aTHX_ result);
Branch: 1 branch
BranchTrueFalseTotal
set_parse_result(aTHX_ result); 151 0 151
518 151 ▶ RETVAL = (bool)result;
Branch: 2 branches
BranchTrueFalseTotal
RETVAL = (bool)result; 151 0 151
RETVAL = (bool)result; 147 4 151
519 }
520 OUTPUT:
521 RETVAL
522  
523 void
524 reset(XML::PugiXML self)
525 CODE:
526 {
527 10 ▶ CHECK_DOC_ALIVE(self);
Branch: 2 branches
BranchTrueFalseTotal
CHECK_DOC_ALIVE(self); 9 1 10
CHECK_DOC_ALIVE(self); 0 9 9
528 9 self->generation++;
529 9 self->doc->reset();
530 }
531  
532 bool
533 save_file(XML::PugiXML self, nul_safe_pv path, nul_safe_pv indent = NULL, unsigned int flags = format_default)
534 CODE:
535 {
536 6 ▶ CHECK_DOC_ALIVE(self);
Branch: 2 branches
BranchTrueFalseTotal
CHECK_DOC_ALIVE(self); 5 1 6
CHECK_DOC_ALIVE(self); 0 5 5
537 5 ▶ if (!indent) indent = "\t"; /* default: avoid ParseXS mangling "\t" in the signature */
Branch: 1 branch
BranchTrueFalseTotal
if (!indent) indent = "\t"; /* default: avoid ParseXS mangling "\t" in the signature */ 4 1 5
538 5 RETVAL = self->doc->save_file(path, indent, flags);
539 5 ▶ if (!RETVAL) {
Branch: 1 branch
BranchTrueFalseTotal
if (!RETVAL) { 1 4 5
540 /* capture errno before get_sv(), whose evaluation order relative to
541 strerror(errno) is otherwise unspecified and could clobber it */
542 1 int saved_errno = errno;
543 1 sv_setpvf(get_sv("@", GV_ADD), "Failed to save XML file: %s", strerror(saved_errno));
544 } else {
545 4 sv_setpvs(get_sv("@", GV_ADD), "");
546 }
547 }
548 OUTPUT:
549 RETVAL
550  
551 SV*
552 to_string(XML::PugiXML self, nul_safe_pv indent = NULL, unsigned int flags = format_default)
553 CODE:
554 {
555 19 ▶ CHECK_DOC_ALIVE(self);
Branch: 2 branches
BranchTrueFalseTotal
CHECK_DOC_ALIVE(self); 18 1 19
CHECK_DOC_ALIVE(self); 0 18 18
556 18 ▶ if (!indent) indent = "\t"; /* default: avoid ParseXS mangling "\t" in the signature */
Branch: 1 branch
BranchTrueFalseTotal
if (!indent) indent = "\t"; /* default: avoid ParseXS mangling "\t" in the signature */ 9 9 18
557 18 RETVAL = 0;
558 18 XPATH_GUARDED {
559 18 ▶ std::ostringstream oss;
Branch: 1 branch
BranchTrueFalseTotal
std::ostringstream oss; 18 0 18
560 18 ▶ self->doc->save(oss, indent, flags);
Branch: 1 branch
BranchTrueFalseTotal
self->doc->save(oss, indent, flags); 18 0 18
561 18 ▶ std::string str = oss.str();
Branch: 1 branch
BranchTrueFalseTotal
std::string str = oss.str(); 18 0 18
562 18 ▶ RETVAL = new_utf8_svpvn(aTHX_ str.c_str(), str.length());
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = new_utf8_svpvn(aTHX_ str.c_str(), str.length()); 18 0 18
563 18 ▶ } catch (const std::exception& e) {
Branch: 1 branch
BranchTrueFalseTotal
} catch (const std::exception& e) { 0 0 0
564 snprintf(xpath_err, sizeof(xpath_err), "to_string error: %s", e.what());
565 }
566 18 ▶ if (xpath_err[0]) croak("%s", xpath_err);
Branch: 1 branch
BranchTrueFalseTotal
if (xpath_err[0]) croak("%s", xpath_err); 0 18 18
567 }
568 OUTPUT:
569 RETVAL
570  
571 SV*
572 root(XML::PugiXML self)
573 CODE:
574 {
575 4178 ▶ CHECK_DOC_ALIVE(self);
Branch: 2 branches
BranchTrueFalseTotal
CHECK_DOC_ALIVE(self); 4177 1 4178
CHECK_DOC_ALIVE(self); 0 4177 4177
576 4177 ▶ xml_node root = self->doc->document_element();
Branch: 1 branch
BranchTrueFalseTotal
xml_node root = self->doc->document_element(); 4177 0 4177
577 4177 ▶ RETVAL = wrap_node(aTHX_ root, ST(0));
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = wrap_node(aTHX_ root, ST(0)); 4177 0 4177
578 }
579 OUTPUT:
580 RETVAL
581  
582 SV*
583 child(XML::PugiXML self, nul_safe_pv name)
584 CODE:
585 {
586 4 ▶ CHECK_DOC_ALIVE(self);
Branch: 2 branches
BranchTrueFalseTotal
CHECK_DOC_ALIVE(self); 3 1 4
CHECK_DOC_ALIVE(self); 0 3 3
587 3 ▶ xml_node child = self->doc->child(name);
Branch: 1 branch
BranchTrueFalseTotal
xml_node child = self->doc->child(name); 3 0 3
588 3 ▶ RETVAL = wrap_node(aTHX_ child, ST(0));
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = wrap_node(aTHX_ child, ST(0)); 3 0 3
589 }
590 OUTPUT:
591 RETVAL
592  
593 SV*
594 select_node(XML::PugiXML self, nul_safe_pv xpath)
595 CODE:
596 {
597 7 ▶ CHECK_DOC_ALIVE(self);
Branch: 2 branches
BranchTrueFalseTotal
CHECK_DOC_ALIVE(self); 6 1 7
CHECK_DOC_ALIVE(self); 0 6 6
598 6 RETVAL = 0;
599 6 XPATH_GUARDED {
600 6 ▶ xpath_node result = self->doc->select_node(xpath);
Branch: 1 branch
BranchTrueFalseTotal
xpath_node result = self->doc->select_node(xpath); 5 1 6
601 5 ▶ RETVAL = wrap_xpath_result(aTHX_ result, ST(0));
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = wrap_xpath_result(aTHX_ result, ST(0)); 5 0 5
602 6 ▶ } END_XPATH_GUARDED;
Branch: 2 branches
BranchTrueFalseTotal
} END_XPATH_GUARDED; 1 5 6
} END_XPATH_GUARDED; 1 0 1
603 }
604 OUTPUT:
605 RETVAL
606  
607 void
608 select_nodes(XML::PugiXML self, nul_safe_pv xpath)
609 PPCODE:
610 {
611 13 ▶ CHECK_DOC_ALIVE(self);
Branch: 2 branches
BranchTrueFalseTotal
CHECK_DOC_ALIVE(self); 12 1 13
CHECK_DOC_ALIVE(self); 0 12 12
612 /* xsubpp emits "SP -= items" before this body, so the first PUSHs below
613 overwrites the ST(0) slot. Cache the invocant before pushing anything:
614 reading ST(0) inside the loop would hand every result after the first
615 the preceding result's RV in place of the document. */
616 12 SV* doc_sv = ST(0);
617 12 XPATH_GUARDED {
618 12 ▶ xpath_node_set nodes = self->doc->select_nodes(xpath);
Branch: 1 branch
BranchTrueFalseTotal
xpath_node_set nodes = self->doc->select_nodes(xpath); 11 1 12
619 11 ▶ EXTEND(SP, (SSize_t)nodes.size());
Branch: 7 branches
BranchTrueFalseTotal
EXTEND(SP, (SSize_t)nodes.size()); 11 0 11
EXTEND(SP, (SSize_t)nodes.size()); 11 0 11
EXTEND(SP, (SSize_t)nodes.size()); 11 0 11
EXTEND(SP, (SSize_t)nodes.size()); 0 11 11
EXTEND(SP, (SSize_t)nodes.size()); 0 11 11
EXTEND(SP, (SSize_t)nodes.size()); 0 0 0
EXTEND(SP, (SSize_t)nodes.size()); 0 0 0
620 34 ▶ for (xpath_node_set::const_iterator it = nodes.begin(); it != nodes.end(); ++it) {
Branch: 3 branches
BranchTrueFalseTotal
for (xpath_node_set::const_iterator it = nodes.begin(); it != nodes.end(); ++it) { 11 0 11
for (xpath_node_set::const_iterator it = nodes.begin(); it != nodes.end(); ++it) { 34 0 34
for (xpath_node_set::const_iterator it = nodes.begin(); it != nodes.end(); ++it) { 23 11 34
621 23 ▶ SV* sv = wrap_xpath_result(aTHX_ *it, doc_sv);
Branch: 1 branch
BranchTrueFalseTotal
SV* sv = wrap_xpath_result(aTHX_ *it, doc_sv); 23 0 23
622 23 ▶ PUSHs(sv_2mortal(sv));
Branch: 1 branch
BranchTrueFalseTotal
PUSHs(sv_2mortal(sv)); 23 0 23
623 }
624 23 ▶ } END_XPATH_GUARDED;
Branch: 2 branches
BranchTrueFalseTotal
} END_XPATH_GUARDED; 1 11 12
} END_XPATH_GUARDED; 1 0 1
625 }
626  
627 SV*
628 compile_xpath(XML::PugiXML self, nul_safe_pv xpath)
629 CODE:
630 {
631 13 ▶ CHECK_DOC_ALIVE(self);
Branch: 2 branches
BranchTrueFalseTotal
CHECK_DOC_ALIVE(self); 12 1 13
CHECK_DOC_ALIVE(self); 0 12 12
632 PERL_UNUSED_VAR(self);
633 12 RETVAL = 0;
634 12 XPATH_GUARDED {
635 12 ▶ xpath_query* query = new (std::nothrow) xpath_query(xpath);
Branch: 4 branches
BranchTrueFalseTotal
xpath_query* query = new (std::nothrow) xpath_query(xpath); 12 0 12
xpath_query* query = new (std::nothrow) xpath_query(xpath); 11 1 12
xpath_query* query = new (std::nothrow) xpath_query(xpath); 1 0 1
xpath_query* query = new (std::nothrow) xpath_query(xpath); 1 0 1
636 11 ▶ if (!query) {
Branch: 1 branch
BranchTrueFalseTotal
if (!query) { 0 11 11
637 0 croak("Out of memory allocating xpath_query");
638 }
639 11 PugiXPath* wrapper = new (std::nothrow) PugiXPath;
640 11 ▶ if (!wrapper) {
Branch: 1 branch
BranchTrueFalseTotal
if (!wrapper) { 0 11 11
641 0 ▶ delete query;
Branch: 1 branch
BranchTrueFalseTotal
delete query; 0 0 0
642 0 croak("Out of memory allocating XPath wrapper");
643 }
644 11 wrapper->query = query;
645  
646 11 ▶ SV* sv = newSV(0);
Branch: 1 branch
BranchTrueFalseTotal
SV* sv = newSV(0); 11 0 11
647 11 ▶ sv_setref_pv(sv, "XML::PugiXML::XPath", (void*)wrapper);
Branch: 1 branch
BranchTrueFalseTotal
sv_setref_pv(sv, "XML::PugiXML::XPath", (void*)wrapper); 11 0 11
648 11 RETVAL = sv;
649 1 } catch (const xpath_exception& e) {
650 1 snprintf(xpath_err, sizeof(xpath_err), "XPath compilation error: %s", e.what());
651 1 ▶ } catch (const std::exception& e) {
Branch: 1 branch
BranchTrueFalseTotal
} catch (const std::exception& e) { 1 0 1
652 snprintf(xpath_err, sizeof(xpath_err), "Internal XPath compilation error: %s", e.what());
653 }
654 12 ▶ if (xpath_err[0]) croak("%s", xpath_err);
Branch: 1 branch
BranchTrueFalseTotal
if (xpath_err[0]) croak("%s", xpath_err); 1 11 12
655 }
656 OUTPUT:
657 RETVAL
658  
659 BOOT:
660 {
661 11 HV* stash = gv_stashpv("XML::PugiXML", GV_ADD);
662 #define PUGI_CONST(name, val) \
663 newCONSTSUB(stash, name, newSVuv((UV)(val)))
664 11 PUGI_CONST("PUGIXML_VERSION", PUGIXML_VERSION);
665 11 PUGI_CONST("FORMAT_DEFAULT", format_default);
666 11 PUGI_CONST("FORMAT_INDENT", format_indent);
667 11 PUGI_CONST("FORMAT_NO_DECLARATION", format_no_declaration);
668 11 PUGI_CONST("FORMAT_RAW", format_raw);
669 11 PUGI_CONST("FORMAT_WRITE_BOM", format_write_bom);
670 11 PUGI_CONST("FORMAT_INDENT_ATTRIBUTES", format_indent_attributes);
671 11 PUGI_CONST("FORMAT_NO_EMPTY_ELEMENT_TAGS", format_no_empty_element_tags);
672 11 PUGI_CONST("PARSE_DEFAULT", parse_default);
673 11 PUGI_CONST("PARSE_MINIMAL", parse_minimal);
674 11 PUGI_CONST("PARSE_PI", parse_pi);
675 11 PUGI_CONST("PARSE_COMMENTS", parse_comments);
676 11 PUGI_CONST("PARSE_CDATA", parse_cdata);
677 11 PUGI_CONST("PARSE_WS_PCDATA", parse_ws_pcdata);
678 11 PUGI_CONST("PARSE_WS_PCDATA_SINGLE", parse_ws_pcdata_single);
679 11 PUGI_CONST("PARSE_ESCAPES", parse_escapes);
680 11 PUGI_CONST("PARSE_EOL", parse_eol);
681 11 PUGI_CONST("PARSE_DECLARATION", parse_declaration);
682 11 PUGI_CONST("PARSE_DOCTYPE", parse_doctype);
683 11 PUGI_CONST("PARSE_FULL", parse_full);
684 11 PUGI_CONST("NODE_NULL", node_null);
685 11 PUGI_CONST("NODE_DOCUMENT", node_document);
686 11 PUGI_CONST("NODE_ELEMENT", node_element);
687 11 PUGI_CONST("NODE_PCDATA", node_pcdata);
688 11 PUGI_CONST("NODE_CDATA", node_cdata);
689 11 PUGI_CONST("NODE_COMMENT", node_comment);
690 11 PUGI_CONST("NODE_PI", node_pi);
691 11 PUGI_CONST("NODE_DECLARATION", node_declaration);
692 11 PUGI_CONST("NODE_DOCTYPE", node_doctype);
693 #undef PUGI_CONST
694 }
695  
696  
697 MODULE = XML::PugiXML PACKAGE = XML::PugiXML::Node
698  
699 void
700 DESTROY(XML::PugiXML::Node self)
701 CODE:
702 {
703 14156 ▶ if (!self) XSRETURN_EMPTY;
Branch: 1 branch
BranchTrueFalseTotal
if (!self) XSRETURN_EMPTY; 6 14150 14156
704 14150 doc_unregister_node(self);
705 14150 SvREFCNT_dec(self->doc_sv);
706 14150 ▶ delete self;
Branch: 1 branch
BranchTrueFalseTotal
delete self; 14150 0 14150
707 14150 ▶ if (SvROK(ST(0))) sv_setiv(SvRV(ST(0)), 0);
Branch: 1 branch
BranchTrueFalseTotal
if (SvROK(ST(0))) sv_setiv(SvRV(ST(0)), 0); 14150 0 14150
708 }
709  
710 SV*
711 name(XML::PugiXML::Node self)
712 CODE:
713 {
714 55 ▶ CHECK_NODE_ALIVE(self);
Branch: 5 branches
BranchTrueFalseTotal
CHECK_NODE_ALIVE(self); 1 54 55
CHECK_NODE_ALIVE(self); 54 0 54
CHECK_NODE_ALIVE(self); 52 2 54
CHECK_NODE_ALIVE(self); 7 45 52
CHECK_NODE_ALIVE(self); 2 7 9
715 45 RETVAL = newSVpv_utf8(aTHX_ self->node.name());
716 }
717 OUTPUT:
718 RETVAL
719  
720 SV*
721 value(XML::PugiXML::Node self)
722 CODE:
723 {
724 4 ▶ CHECK_NODE_ALIVE(self);
Branch: 5 branches
BranchTrueFalseTotal
CHECK_NODE_ALIVE(self); 0 4 4
CHECK_NODE_ALIVE(self); 4 0 4
CHECK_NODE_ALIVE(self); 4 0 4
CHECK_NODE_ALIVE(self); 0 4 4
CHECK_NODE_ALIVE(self); 0 0 0
725 4 RETVAL = newSVpv_utf8(aTHX_ self->node.value());
726 }
727 OUTPUT:
728 RETVAL
729  
730 SV*
731 text(XML::PugiXML::Node self)
732 CODE:
733 {
734 25 ▶ CHECK_NODE_ALIVE(self);
Branch: 5 branches
BranchTrueFalseTotal
CHECK_NODE_ALIVE(self); 1 24 25
CHECK_NODE_ALIVE(self); 24 0 24
CHECK_NODE_ALIVE(self); 23 1 24
CHECK_NODE_ALIVE(self); 1 22 23
CHECK_NODE_ALIVE(self); 1 1 2
735 22 ▶ RETVAL = newSVpv_utf8(aTHX_ self->node.text().get());
Branch: 3 branches
BranchTrueFalseTotal
RETVAL = newSVpv_utf8(aTHX_ self->node.text().get()); 22 0 22
RETVAL = newSVpv_utf8(aTHX_ self->node.text().get()); 22 0 22
RETVAL = newSVpv_utf8(aTHX_ self->node.text().get()); 22 0 22
736 }
737 OUTPUT:
738 RETVAL
739  
740 SV*
741 parent(XML::PugiXML::Node self)
742 CODE:
743 {
744 1 ▶ CHECK_NODE_ALIVE(self);
Branch: 5 branches
BranchTrueFalseTotal
CHECK_NODE_ALIVE(self); 0 1 1
CHECK_NODE_ALIVE(self); 1 0 1
CHECK_NODE_ALIVE(self); 1 0 1
CHECK_NODE_ALIVE(self); 0 1 1
CHECK_NODE_ALIVE(self); 0 0 0
745 1 RETVAL = wrap_node(aTHX_ self->node.parent(), self->doc_sv);
746 }
747 OUTPUT:
748 RETVAL
749  
750 SV*
751 child(XML::PugiXML::Node self, nul_safe_pv name)
752 CODE:
753 {
754 59 ▶ CHECK_NODE_ALIVE(self);
Branch: 5 branches
BranchTrueFalseTotal
CHECK_NODE_ALIVE(self); 0 59 59
CHECK_NODE_ALIVE(self); 59 0 59
CHECK_NODE_ALIVE(self); 59 0 59
CHECK_NODE_ALIVE(self); 0 59 59
CHECK_NODE_ALIVE(self); 0 0 0
755 59 RETVAL = wrap_node(aTHX_ self->node.child(name), self->doc_sv);
756 }
757 OUTPUT:
758 RETVAL
759  
760 SV*
761 first_child(XML::PugiXML::Node self)
762 CODE:
763 {
764 110 ▶ CHECK_NODE_ALIVE(self);
Branch: 5 branches
BranchTrueFalseTotal
CHECK_NODE_ALIVE(self); 0 110 110
CHECK_NODE_ALIVE(self); 110 0 110
CHECK_NODE_ALIVE(self); 110 0 110
CHECK_NODE_ALIVE(self); 0 110 110
CHECK_NODE_ALIVE(self); 0 0 0
765 110 RETVAL = wrap_node(aTHX_ self->node.first_child(), self->doc_sv);
766 }
767 OUTPUT:
768 RETVAL
769  
770 SV*
771 next_sibling(XML::PugiXML::Node self, nul_safe_pv name = NULL)
772 CODE:
773 {
774 4 ▶ CHECK_NODE_ALIVE(self);
Branch: 5 branches
BranchTrueFalseTotal
CHECK_NODE_ALIVE(self); 0 4 4
CHECK_NODE_ALIVE(self); 4 0 4
CHECK_NODE_ALIVE(self); 4 0 4
CHECK_NODE_ALIVE(self); 0 4 4
CHECK_NODE_ALIVE(self); 0 0 0
775 4 ▶ if (name) {
Branch: 1 branch
BranchTrueFalseTotal
if (name) { 3 1 4
776 3 RETVAL = wrap_node(aTHX_ self->node.next_sibling(name), self->doc_sv);
777 } else {
778 1 RETVAL = wrap_node(aTHX_ self->node.next_sibling(), self->doc_sv);
779 }
780 }
781 OUTPUT:
782 RETVAL
783  
784 SV*
785 previous_sibling(XML::PugiXML::Node self, nul_safe_pv name = NULL)
786 CODE:
787 {
788 5 ▶ CHECK_NODE_ALIVE(self);
Branch: 5 branches
BranchTrueFalseTotal
CHECK_NODE_ALIVE(self); 0 5 5
CHECK_NODE_ALIVE(self); 5 0 5
CHECK_NODE_ALIVE(self); 5 0 5
CHECK_NODE_ALIVE(self); 0 5 5
CHECK_NODE_ALIVE(self); 0 0 0
789 5 ▶ if (name) {
Branch: 1 branch
BranchTrueFalseTotal
if (name) { 2 3 5
790 2 RETVAL = wrap_node(aTHX_ self->node.previous_sibling(name), self->doc_sv);
791 } else {
792 3 RETVAL = wrap_node(aTHX_ self->node.previous_sibling(), self->doc_sv);
793 }
794 }
795 OUTPUT:
796 RETVAL
797  
798 SV*
799 last_child(XML::PugiXML::Node self)
800 CODE:
801 {
802 4 ▶ CHECK_NODE_ALIVE(self);
Branch: 5 branches
BranchTrueFalseTotal
CHECK_NODE_ALIVE(self); 0 4 4
CHECK_NODE_ALIVE(self); 4 0 4
CHECK_NODE_ALIVE(self); 4 0 4
CHECK_NODE_ALIVE(self); 0 4 4
CHECK_NODE_ALIVE(self); 0 0 0
803 4 RETVAL = wrap_node(aTHX_ self->node.last_child(), self->doc_sv);
804 }
805 OUTPUT:
806 RETVAL
807  
808 void
809 children(XML::PugiXML::Node self, nul_safe_pv name = NULL)
810 PPCODE:
811 {
812 24 ▶ CHECK_NODE_ALIVE(self);
Branch: 5 branches
BranchTrueFalseTotal
CHECK_NODE_ALIVE(self); 0 24 24
CHECK_NODE_ALIVE(self); 24 0 24
CHECK_NODE_ALIVE(self); 24 0 24
CHECK_NODE_ALIVE(self); 0 24 24
CHECK_NODE_ALIVE(self); 0 0 0
813 24 ▶ if (name) {
Branch: 1 branch
BranchTrueFalseTotal
if (name) { 2 22 24
814 4 ▶ for (xml_node child = self->node.child(name); child; child = child.next_sibling(name))
Branch: 3 branches
BranchTrueFalseTotal
for (xml_node child = self->node.child(name); child; child = child.next_sibling(name)) 2 0 2
for (xml_node child = self->node.child(name); child; child = child.next_sibling(name)) 4 0 4
for (xml_node child = self->node.child(name); child; child = child.next_sibling(name)) 2 2 4
815 2 ▶ XPUSHs(sv_2mortal(wrap_node(aTHX_ child, self->doc_sv)));
Branch: 5 branches
BranchTrueFalseTotal
XPUSHs(sv_2mortal(wrap_node(aTHX_ child, self->doc_sv))); 0 2 2
XPUSHs(sv_2mortal(wrap_node(aTHX_ child, self->doc_sv))); 0 0 0
XPUSHs(sv_2mortal(wrap_node(aTHX_ child, self->doc_sv))); 2 0 2
XPUSHs(sv_2mortal(wrap_node(aTHX_ child, self->doc_sv))); 2 0 2
XPUSHs(sv_2mortal(wrap_node(aTHX_ child, self->doc_sv))); 2 0 2
816 } else {
817 1261 ▶ for (xml_node child = self->node.first_child(); child; child = child.next_sibling())
Branch: 3 branches
BranchTrueFalseTotal
for (xml_node child = self->node.first_child(); child; child = child.next_sibling()) 22 0 22
for (xml_node child = self->node.first_child(); child; child = child.next_sibling()) 1261 0 1261
for (xml_node child = self->node.first_child(); child; child = child.next_sibling()) 1239 22 1261
818 1239 ▶ XPUSHs(sv_2mortal(wrap_node(aTHX_ child, self->doc_sv)));
Branch: 5 branches
BranchTrueFalseTotal
XPUSHs(sv_2mortal(wrap_node(aTHX_ child, self->doc_sv))); 0 1239 1239
XPUSHs(sv_2mortal(wrap_node(aTHX_ child, self->doc_sv))); 0 0 0
XPUSHs(sv_2mortal(wrap_node(aTHX_ child, self->doc_sv))); 1239 0 1239
XPUSHs(sv_2mortal(wrap_node(aTHX_ child, self->doc_sv))); 1239 0 1239
XPUSHs(sv_2mortal(wrap_node(aTHX_ child, self->doc_sv))); 1239 0 1239
819 }
820 }
821  
822 void
823 attrs(XML::PugiXML::Node self)
824 PPCODE:
825 {
826 207 ▶ CHECK_NODE_ALIVE(self);
Branch: 5 branches
BranchTrueFalseTotal
CHECK_NODE_ALIVE(self); 0 207 207
CHECK_NODE_ALIVE(self); 207 0 207
CHECK_NODE_ALIVE(self); 207 0 207
CHECK_NODE_ALIVE(self); 0 207 207
CHECK_NODE_ALIVE(self); 0 0 0
827 421 ▶ for (xml_attribute attr = self->node.first_attribute(); attr; attr = attr.next_attribute())
Branch: 3 branches
BranchTrueFalseTotal
for (xml_attribute attr = self->node.first_attribute(); attr; attr = attr.next_attribute()) 207 0 207
for (xml_attribute attr = self->node.first_attribute(); attr; attr = attr.next_attribute()) 421 0 421
for (xml_attribute attr = self->node.first_attribute(); attr; attr = attr.next_attribute()) 214 207 421
828 214 ▶ XPUSHs(sv_2mortal(wrap_attr(aTHX_ attr, self->node, self->doc_sv)));
Branch: 5 branches
BranchTrueFalseTotal
XPUSHs(sv_2mortal(wrap_attr(aTHX_ attr, self->node, self->doc_sv))); 0 214 214
XPUSHs(sv_2mortal(wrap_attr(aTHX_ attr, self->node, self->doc_sv))); 0 0 0
XPUSHs(sv_2mortal(wrap_attr(aTHX_ attr, self->node, self->doc_sv))); 214 0 214
XPUSHs(sv_2mortal(wrap_attr(aTHX_ attr, self->node, self->doc_sv))); 214 0 214
XPUSHs(sv_2mortal(wrap_attr(aTHX_ attr, self->node, self->doc_sv))); 214 0 214
829 }
830  
831 SV*
832 attr(XML::PugiXML::Node self, nul_safe_pv name)
833 CODE:
834 {
835 39 ▶ CHECK_NODE_ALIVE(self);
Branch: 5 branches
BranchTrueFalseTotal
CHECK_NODE_ALIVE(self); 0 39 39
CHECK_NODE_ALIVE(self); 39 0 39
CHECK_NODE_ALIVE(self); 39 0 39
CHECK_NODE_ALIVE(self); 0 39 39
CHECK_NODE_ALIVE(self); 0 0 0
836 39 RETVAL = wrap_attr(aTHX_ self->node.attribute(name), self->node, self->doc_sv);
837 }
838 OUTPUT:
839 RETVAL
840  
841 SV*
842 append_child(XML::PugiXML::Node self, nul_safe_pv name)
843 CODE:
844 {
845 8504 ▶ CHECK_NODE_ALIVE(self);
Branch: 5 branches
BranchTrueFalseTotal
CHECK_NODE_ALIVE(self); 0 8504 8504
CHECK_NODE_ALIVE(self); 8504 0 8504
CHECK_NODE_ALIVE(self); 8504 0 8504
CHECK_NODE_ALIVE(self); 0 8504 8504
CHECK_NODE_ALIVE(self); 0 0 0
846 8504 ▶ xml_node child = self->node.append_child(name);
Branch: 1 branch
BranchTrueFalseTotal
xml_node child = self->node.append_child(name); 8504 0 8504
847 8504 ▶ RETVAL = wrap_node(aTHX_ child, self->doc_sv);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = wrap_node(aTHX_ child, self->doc_sv); 8504 0 8504
848 }
849 OUTPUT:
850 RETVAL
851  
852 SV*
853 prepend_child(XML::PugiXML::Node self, nul_safe_pv name)
854 CODE:
855 {
856 1 ▶ CHECK_NODE_ALIVE(self);
Branch: 5 branches
BranchTrueFalseTotal
CHECK_NODE_ALIVE(self); 0 1 1
CHECK_NODE_ALIVE(self); 1 0 1
CHECK_NODE_ALIVE(self); 1 0 1
CHECK_NODE_ALIVE(self); 0 1 1
CHECK_NODE_ALIVE(self); 0 0 0
857 1 ▶ xml_node child = self->node.prepend_child(name);
Branch: 1 branch
BranchTrueFalseTotal
xml_node child = self->node.prepend_child(name); 1 0 1
858 1 ▶ RETVAL = wrap_node(aTHX_ child, self->doc_sv);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = wrap_node(aTHX_ child, self->doc_sv); 1 0 1
859 }
860 OUTPUT:
861 RETVAL
862  
863 SV*
864 ensure_child(XML::PugiXML::Node self, nul_safe_pv name)
865 CODE:
866 {
867 2 ▶ CHECK_NODE_ALIVE(self);
Branch: 5 branches
BranchTrueFalseTotal
CHECK_NODE_ALIVE(self); 0 2 2
CHECK_NODE_ALIVE(self); 2 0 2
CHECK_NODE_ALIVE(self); 2 0 2
CHECK_NODE_ALIVE(self); 0 2 2
CHECK_NODE_ALIVE(self); 0 0 0
868 /* get-or-create the first child element of this name. pugixml 1.16 added a
869 native ensure_child; emulate it on older libraries (child-or-append) so
870 the binding still builds against a system pugixml < 1.16. */
871 #if PUGIXML_VERSION >= 1160
872 2 ▶ xml_node child = self->node.ensure_child(name);
Branch: 1 branch
BranchTrueFalseTotal
xml_node child = self->node.ensure_child(name); 2 0 2
873 #else
874 xml_node child = self->node.child(name);
875 if (!child) child = self->node.append_child(name);
876 #endif
877 2 ▶ RETVAL = wrap_node(aTHX_ child, self->doc_sv);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = wrap_node(aTHX_ child, self->doc_sv); 2 0 2
878 }
879 OUTPUT:
880 RETVAL
881  
882 SV*
883 insert_child_before(XML::PugiXML::Node self, nul_safe_pv name, XML::PugiXML::Node ref_node)
884 CODE:
885 {
886 5 ▶ CHECK_NODE_ALIVE(self);
Branch: 5 branches
BranchTrueFalseTotal
CHECK_NODE_ALIVE(self); 0 5 5
CHECK_NODE_ALIVE(self); 5 0 5
CHECK_NODE_ALIVE(self); 5 0 5
CHECK_NODE_ALIVE(self); 0 5 5
CHECK_NODE_ALIVE(self); 0 0 0
887 5 ▶ CHECK_NODE_ALIVE(ref_node);
Branch: 5 branches
BranchTrueFalseTotal
CHECK_NODE_ALIVE(ref_node); 0 5 5
CHECK_NODE_ALIVE(ref_node); 5 0 5
CHECK_NODE_ALIVE(ref_node); 5 0 5
CHECK_NODE_ALIVE(ref_node); 1 4 5
CHECK_NODE_ALIVE(ref_node); 0 1 1
888 4 ▶ CHECK_SAME_DOC(self, ref_node);
Branch: 1 branch
BranchTrueFalseTotal
CHECK_SAME_DOC(self, ref_node); 1 3 4
889 3 ▶ xml_node child = self->node.insert_child_before(name, ref_node->node);
Branch: 1 branch
BranchTrueFalseTotal
xml_node child = self->node.insert_child_before(name, ref_node->node); 3 0 3
890 3 ▶ RETVAL = wrap_node(aTHX_ child, self->doc_sv);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = wrap_node(aTHX_ child, self->doc_sv); 3 0 3
891 }
892 OUTPUT:
893 RETVAL
894  
895 SV*
896 insert_child_after(XML::PugiXML::Node self, nul_safe_pv name, XML::PugiXML::Node ref_node)
897 CODE:
898 {
899 3 ▶ CHECK_NODE_ALIVE(self);
Branch: 5 branches
BranchTrueFalseTotal
CHECK_NODE_ALIVE(self); 0 3 3
CHECK_NODE_ALIVE(self); 3 0 3
CHECK_NODE_ALIVE(self); 3 0 3
CHECK_NODE_ALIVE(self); 0 3 3
CHECK_NODE_ALIVE(self); 0 0 0
900 3 ▶ CHECK_NODE_ALIVE(ref_node);
Branch: 5 branches
BranchTrueFalseTotal
CHECK_NODE_ALIVE(ref_node); 0 3 3
CHECK_NODE_ALIVE(ref_node); 3 0 3
CHECK_NODE_ALIVE(ref_node); 3 0 3
CHECK_NODE_ALIVE(ref_node); 1 2 3
CHECK_NODE_ALIVE(ref_node); 0 1 1
901 2 ▶ CHECK_SAME_DOC(self, ref_node);
Branch: 1 branch
BranchTrueFalseTotal
CHECK_SAME_DOC(self, ref_node); 1 1 2
902 1 ▶ xml_node child = self->node.insert_child_after(name, ref_node->node);
Branch: 1 branch
BranchTrueFalseTotal
xml_node child = self->node.insert_child_after(name, ref_node->node); 1 0 1
903 1 ▶ RETVAL = wrap_node(aTHX_ child, self->doc_sv);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = wrap_node(aTHX_ child, self->doc_sv); 1 0 1
904 }
905 OUTPUT:
906 RETVAL
907  
908 SV*
909 append_cdata(XML::PugiXML::Node self, nul_safe_pv content)
910 CODE:
911 {
912 1 ▶ CHECK_NODE_ALIVE(self);
Branch: 5 branches
BranchTrueFalseTotal
CHECK_NODE_ALIVE(self); 0 1 1
CHECK_NODE_ALIVE(self); 1 0 1
CHECK_NODE_ALIVE(self); 1 0 1
CHECK_NODE_ALIVE(self); 0 1 1
CHECK_NODE_ALIVE(self); 0 0 0
913 1 ▶ xml_node cdata = self->node.append_child(node_cdata);
Branch: 1 branch
BranchTrueFalseTotal
xml_node cdata = self->node.append_child(node_cdata); 1 0 1
914 1 ▶ if (cdata) {
Branch: 2 branches
BranchTrueFalseTotal
if (cdata) { 1 0 1
if (cdata) { 1 0 1
915 1 ▶ cdata.set_value(content);
Branch: 1 branch
BranchTrueFalseTotal
cdata.set_value(content); 1 0 1
916 }
917 1 ▶ RETVAL = wrap_node(aTHX_ cdata, self->doc_sv);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = wrap_node(aTHX_ cdata, self->doc_sv); 1 0 1
918 }
919 OUTPUT:
920 RETVAL
921  
922 SV*
923 append_comment(XML::PugiXML::Node self, nul_safe_pv content)
924 CODE:
925 {
926 1 ▶ CHECK_NODE_ALIVE(self);
Branch: 5 branches
BranchTrueFalseTotal
CHECK_NODE_ALIVE(self); 0 1 1
CHECK_NODE_ALIVE(self); 1 0 1
CHECK_NODE_ALIVE(self); 1 0 1
CHECK_NODE_ALIVE(self); 0 1 1
CHECK_NODE_ALIVE(self); 0 0 0
927 1 ▶ xml_node comment = self->node.append_child(node_comment);
Branch: 1 branch
BranchTrueFalseTotal
xml_node comment = self->node.append_child(node_comment); 1 0 1
928 1 ▶ if (comment) {
Branch: 2 branches
BranchTrueFalseTotal
if (comment) { 1 0 1
if (comment) { 1 0 1
929 1 ▶ comment.set_value(content);
Branch: 1 branch
BranchTrueFalseTotal
comment.set_value(content); 1 0 1
930 }
931 1 ▶ RETVAL = wrap_node(aTHX_ comment, self->doc_sv);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = wrap_node(aTHX_ comment, self->doc_sv); 1 0 1
932 }
933 OUTPUT:
934 RETVAL
935  
936 int
937 type(XML::PugiXML::Node self)
938 CODE:
939 {
940 31 ▶ CHECK_NODE_ALIVE(self);
Branch: 5 branches
BranchTrueFalseTotal
CHECK_NODE_ALIVE(self); 0 31 31
CHECK_NODE_ALIVE(self); 31 0 31
CHECK_NODE_ALIVE(self); 31 0 31
CHECK_NODE_ALIVE(self); 0 31 31
CHECK_NODE_ALIVE(self); 0 0 0
941 31 ▶ RETVAL = (int)self->node.type();
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = (int)self->node.type(); 10 21 31
942 }
943 OUTPUT:
944 RETVAL
945  
946 SV*
947 path(XML::PugiXML::Node self, nul_safe_pv delimiter = NULL)
948 CODE:
949 {
950 9 ▶ CHECK_NODE_ALIVE(self);
Branch: 5 branches
BranchTrueFalseTotal
CHECK_NODE_ALIVE(self); 0 9 9
CHECK_NODE_ALIVE(self); 9 0 9
CHECK_NODE_ALIVE(self); 9 0 9
CHECK_NODE_ALIVE(self); 0 9 9
CHECK_NODE_ALIVE(self); 0 0 0
951 /* pugixml's path() takes a single char. Taking this as a string and
952 checking the length beats the T_CHAR typemap, which quietly turned
953 path('::') into ':' and path('') into a NUL delimiter. */
954 9 char delim = '/';
955 9 ▶ if (delimiter) {
Branch: 1 branch
BranchTrueFalseTotal
if (delimiter) { 7 2 9
956 7 ▶ if (strlen(delimiter) != 1)
Branch: 1 branch
BranchTrueFalseTotal
if (strlen(delimiter) != 1) 4 3 7
957 4 croak("path: delimiter must be a single character");
958 3 delim = delimiter[0];
959 }
960 5 RETVAL = 0;
961 5 XPATH_GUARDED {
962 5 ▶ std::string p = self->node.path(delim);
Branch: 1 branch
BranchTrueFalseTotal
std::string p = self->node.path(delim); 5 0 5
963 5 ▶ RETVAL = new_utf8_svpvn(aTHX_ p.c_str(), p.length());
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = new_utf8_svpvn(aTHX_ p.c_str(), p.length()); 5 0 5
964 5 ▶ } catch (const std::exception& e) {
Branch: 1 branch
BranchTrueFalseTotal
} catch (const std::exception& e) { 0 0 0
965 snprintf(xpath_err, sizeof(xpath_err), "path error: %s", e.what());
966 }
967 5 ▶ if (xpath_err[0]) croak("%s", xpath_err);
Branch: 1 branch
BranchTrueFalseTotal
if (xpath_err[0]) croak("%s", xpath_err); 0 5 5
968 }
969 OUTPUT:
970 RETVAL
971  
972 SV*
973 find_child_by_attribute(XML::PugiXML::Node self, nul_safe_pv name, nul_safe_pv attr_name, nul_safe_pv attr_value)
974 CODE:
975 {
976 2 ▶ CHECK_NODE_ALIVE(self);
Branch: 5 branches
BranchTrueFalseTotal
CHECK_NODE_ALIVE(self); 0 2 2
CHECK_NODE_ALIVE(self); 2 0 2
CHECK_NODE_ALIVE(self); 2 0 2
CHECK_NODE_ALIVE(self); 0 2 2
CHECK_NODE_ALIVE(self); 0 0 0
977 2 ▶ xml_node child = self->node.find_child_by_attribute(name, attr_name, attr_value);
Branch: 1 branch
BranchTrueFalseTotal
xml_node child = self->node.find_child_by_attribute(name, attr_name, attr_value); 2 0 2
978 2 ▶ RETVAL = wrap_node(aTHX_ child, self->doc_sv);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = wrap_node(aTHX_ child, self->doc_sv); 2 0 2
979 }
980 OUTPUT:
981 RETVAL
982  
983 SV*
984 root(XML::PugiXML::Node self)
985 CODE:
986 {
987 4 ▶ CHECK_NODE_ALIVE(self);
Branch: 5 branches
BranchTrueFalseTotal
CHECK_NODE_ALIVE(self); 0 4 4
CHECK_NODE_ALIVE(self); 4 0 4
CHECK_NODE_ALIVE(self); 4 0 4
CHECK_NODE_ALIVE(self); 0 4 4
CHECK_NODE_ALIVE(self); 0 0 0
988 /* Document element (consistent with $doc->root). CHECK_NODE_ALIVE has
989 already established that owner is non-NULL. */
990 4 RETVAL = wrap_node(aTHX_ self->owner->doc->document_element(), self->doc_sv);
991 }
992 OUTPUT:
993 RETVAL
994  
995 bool
996 set_name(XML::PugiXML::Node self, nul_safe_pv name)
997 CODE:
998 {
999 2 ▶ CHECK_NODE_ALIVE(self);
Branch: 5 branches
BranchTrueFalseTotal
CHECK_NODE_ALIVE(self); 0 2 2
CHECK_NODE_ALIVE(self); 2 0 2
CHECK_NODE_ALIVE(self); 2 0 2
CHECK_NODE_ALIVE(self); 0 2 2
CHECK_NODE_ALIVE(self); 0 0 0
1000 2 ▶ RETVAL = self->node.set_name(name);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = self->node.set_name(name); 1 1 2
1001 }
1002 OUTPUT:
1003 RETVAL
1004  
1005 bool
1006 set_value(XML::PugiXML::Node self, nul_safe_pv value)
1007 CODE:
1008 {
1009 1 ▶ CHECK_NODE_ALIVE(self);
Branch: 5 branches
BranchTrueFalseTotal
CHECK_NODE_ALIVE(self); 0 1 1
CHECK_NODE_ALIVE(self); 1 0 1
CHECK_NODE_ALIVE(self); 1 0 1
CHECK_NODE_ALIVE(self); 0 1 1
CHECK_NODE_ALIVE(self); 0 0 0
1010 1 ▶ RETVAL = self->node.set_value(value);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = self->node.set_value(value); 0 1 1
1011 }
1012 OUTPUT:
1013 RETVAL
1014  
1015 bool
1016 set_text(XML::PugiXML::Node self, nul_safe_pv text)
1017 CODE:
1018 {
1019 8004 ▶ CHECK_NODE_ALIVE(self);
Branch: 5 branches
BranchTrueFalseTotal
CHECK_NODE_ALIVE(self); 0 8004 8004
CHECK_NODE_ALIVE(self); 8004 0 8004
CHECK_NODE_ALIVE(self); 8004 0 8004
CHECK_NODE_ALIVE(self); 0 8004 8004
CHECK_NODE_ALIVE(self); 0 0 0
1020 8004 ▶ RETVAL = self->node.text().set(text);
Branch: 3 branches
BranchTrueFalseTotal
RETVAL = self->node.text().set(text); 8004 0 8004
RETVAL = self->node.text().set(text); 8004 0 8004
RETVAL = self->node.text().set(text); 8004 0 8004
1021 }
1022 OUTPUT:
1023 RETVAL
1024  
1025 SV*
1026 select_node(XML::PugiXML::Node self, nul_safe_pv xpath)
1027 CODE:
1028 {
1029 3 ▶ CHECK_NODE_ALIVE(self);
Branch: 5 branches
BranchTrueFalseTotal
CHECK_NODE_ALIVE(self); 0 3 3
CHECK_NODE_ALIVE(self); 3 0 3
CHECK_NODE_ALIVE(self); 3 0 3
CHECK_NODE_ALIVE(self); 0 3 3
CHECK_NODE_ALIVE(self); 0 0 0
1030 3 RETVAL = 0;
1031 3 XPATH_GUARDED {
1032 3 ▶ xpath_node result = self->node.select_node(xpath);
Branch: 1 branch
BranchTrueFalseTotal
xpath_node result = self->node.select_node(xpath); 2 1 3
1033 2 ▶ RETVAL = wrap_xpath_result(aTHX_ result, self->doc_sv);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = wrap_xpath_result(aTHX_ result, self->doc_sv); 2 0 2
1034 3 ▶ } END_XPATH_GUARDED;
Branch: 2 branches
BranchTrueFalseTotal
} END_XPATH_GUARDED; 1 2 3
} END_XPATH_GUARDED; 1 0 1
1035 }
1036 OUTPUT:
1037 RETVAL
1038  
1039 void
1040 select_nodes(XML::PugiXML::Node self, nul_safe_pv xpath)
1041 PPCODE:
1042 {
1043 1 ▶ CHECK_NODE_ALIVE(self);
Branch: 5 branches
BranchTrueFalseTotal
CHECK_NODE_ALIVE(self); 0 1 1
CHECK_NODE_ALIVE(self); 1 0 1
CHECK_NODE_ALIVE(self); 1 0 1
CHECK_NODE_ALIVE(self); 0 1 1
CHECK_NODE_ALIVE(self); 0 0 0
1044 1 XPATH_GUARDED {
1045 1 ▶ xpath_node_set nodes = self->node.select_nodes(xpath);
Branch: 1 branch
BranchTrueFalseTotal
xpath_node_set nodes = self->node.select_nodes(xpath); 0 1 1
1046 0 ▶ EXTEND(SP, (SSize_t)nodes.size());
Branch: 7 branches
BranchTrueFalseTotal
EXTEND(SP, (SSize_t)nodes.size()); 0 0 0
EXTEND(SP, (SSize_t)nodes.size()); 0 0 0
EXTEND(SP, (SSize_t)nodes.size()); 0 0 0
EXTEND(SP, (SSize_t)nodes.size()); 0 0 0
EXTEND(SP, (SSize_t)nodes.size()); 0 0 0
EXTEND(SP, (SSize_t)nodes.size()); 0 0 0
EXTEND(SP, (SSize_t)nodes.size()); 0 0 0
1047 0 ▶ for (xpath_node_set::const_iterator it = nodes.begin(); it != nodes.end(); ++it) {
Branch: 3 branches
BranchTrueFalseTotal
for (xpath_node_set::const_iterator it = nodes.begin(); it != nodes.end(); ++it) { 0 0 0
for (xpath_node_set::const_iterator it = nodes.begin(); it != nodes.end(); ++it) { 0 0 0
for (xpath_node_set::const_iterator it = nodes.begin(); it != nodes.end(); ++it) { 0 0 0
1048 0 ▶ SV* sv = wrap_xpath_result(aTHX_ *it, self->doc_sv);
Branch: 1 branch
BranchTrueFalseTotal
SV* sv = wrap_xpath_result(aTHX_ *it, self->doc_sv); 0 0 0
1049 0 ▶ PUSHs(sv_2mortal(sv));
Branch: 1 branch
BranchTrueFalseTotal
PUSHs(sv_2mortal(sv)); 0 0 0
1050 }
1051 1 ▶ } END_XPATH_GUARDED;
Branch: 2 branches
BranchTrueFalseTotal
} END_XPATH_GUARDED; 1 0 1
} END_XPATH_GUARDED; 1 0 1
1052 }
1053  
1054 bool
1055 valid(XML::PugiXML::Node self)
1056 CODE:
1057 {
1058 /* valid() deliberately skips CHECK_NODE_ALIVE -- returns false for stale handles */
1059 235 ▶ RETVAL = (self != NULL) && !HANDLE_STALE(self) && !self->dead && (bool)self->node;
Branch: 7 branches
BranchTrueFalseTotal
RETVAL = (self != NULL) && !HANDLE_STALE(self) && !self->dead && (bool)self->node; 233 2 235
RETVAL = (self != NULL) && !HANDLE_STALE(self) && !self->dead && (bool)self->node; 233 0 233
RETVAL = (self != NULL) && !HANDLE_STALE(self) && !self->dead && (bool)self->node; 220 13 233
RETVAL = (self != NULL) && !HANDLE_STALE(self) && !self->dead && (bool)self->node; 213 7 220
RETVAL = (self != NULL) && !HANDLE_STALE(self) && !self->dead && (bool)self->node; 213 0 213
RETVAL = (self != NULL) && !HANDLE_STALE(self) && !self->dead && (bool)self->node; 213 0 213
RETVAL = (self != NULL) && !HANDLE_STALE(self) && !self->dead && (bool)self->node; 213 22 235
1060 }
1061 OUTPUT:
1062 RETVAL
1063  
1064 SV*
1065 append_attr(XML::PugiXML::Node self, nul_safe_pv name)
1066 CODE:
1067 {
1068 1 ▶ CHECK_NODE_ALIVE(self);
Branch: 5 branches
BranchTrueFalseTotal
CHECK_NODE_ALIVE(self); 0 1 1
CHECK_NODE_ALIVE(self); 1 0 1
CHECK_NODE_ALIVE(self); 1 0 1
CHECK_NODE_ALIVE(self); 0 1 1
CHECK_NODE_ALIVE(self); 0 0 0
1069 1 ▶ xml_attribute attr = self->node.append_attribute(name);
Branch: 1 branch
BranchTrueFalseTotal
xml_attribute attr = self->node.append_attribute(name); 1 0 1
1070 1 ▶ RETVAL = wrap_attr(aTHX_ attr, self->node, self->doc_sv);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = wrap_attr(aTHX_ attr, self->node, self->doc_sv); 1 0 1
1071 }
1072 OUTPUT:
1073 RETVAL
1074  
1075 SV*
1076 prepend_attr(XML::PugiXML::Node self, nul_safe_pv name)
1077 CODE:
1078 {
1079 1 ▶ CHECK_NODE_ALIVE(self);
Branch: 5 branches
BranchTrueFalseTotal
CHECK_NODE_ALIVE(self); 0 1 1
CHECK_NODE_ALIVE(self); 1 0 1
CHECK_NODE_ALIVE(self); 1 0 1
CHECK_NODE_ALIVE(self); 0 1 1
CHECK_NODE_ALIVE(self); 0 0 0
1080 1 ▶ xml_attribute attr = self->node.prepend_attribute(name);
Branch: 1 branch
BranchTrueFalseTotal
xml_attribute attr = self->node.prepend_attribute(name); 1 0 1
1081 1 ▶ RETVAL = wrap_attr(aTHX_ attr, self->node, self->doc_sv);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = wrap_attr(aTHX_ attr, self->node, self->doc_sv); 1 0 1
1082 }
1083 OUTPUT:
1084 RETVAL
1085  
1086 SV*
1087 ensure_attr(XML::PugiXML::Node self, nul_safe_pv name)
1088 CODE:
1089 {
1090 2 ▶ CHECK_NODE_ALIVE(self);
Branch: 5 branches
BranchTrueFalseTotal
CHECK_NODE_ALIVE(self); 0 2 2
CHECK_NODE_ALIVE(self); 2 0 2
CHECK_NODE_ALIVE(self); 2 0 2
CHECK_NODE_ALIVE(self); 0 2 2
CHECK_NODE_ALIVE(self); 0 0 0
1091 /* get-or-create the attribute of this name. pugixml 1.16 added a native
1092 ensure_attribute; emulate it on older libraries (find-or-append) so the
1093 binding still builds against a system pugixml < 1.16. */
1094 #if PUGIXML_VERSION >= 1160
1095 2 ▶ xml_attribute attr = self->node.ensure_attribute(name);
Branch: 1 branch
BranchTrueFalseTotal
xml_attribute attr = self->node.ensure_attribute(name); 2 0 2
1096 #else
1097 xml_attribute attr = self->node.attribute(name);
1098 if (!attr) attr = self->node.append_attribute(name);
1099 #endif
1100 2 ▶ RETVAL = wrap_attr(aTHX_ attr, self->node, self->doc_sv);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = wrap_attr(aTHX_ attr, self->node, self->doc_sv); 2 0 2
1101 }
1102 OUTPUT:
1103 RETVAL
1104  
1105 bool
1106 remove_child(XML::PugiXML::Node self, XML::PugiXML::Node child)
1107 CODE:
1108 {
1109 17 ▶ CHECK_NODE_ALIVE(self);
Branch: 5 branches
BranchTrueFalseTotal
CHECK_NODE_ALIVE(self); 0 17 17
CHECK_NODE_ALIVE(self); 17 0 17
CHECK_NODE_ALIVE(self); 17 0 17
CHECK_NODE_ALIVE(self); 0 17 17
CHECK_NODE_ALIVE(self); 0 0 0
1110 17 ▶ CHECK_NODE_ALIVE(child);
Branch: 5 branches
BranchTrueFalseTotal
CHECK_NODE_ALIVE(child); 0 17 17
CHECK_NODE_ALIVE(child); 17 0 17
CHECK_NODE_ALIVE(child); 17 0 17
CHECK_NODE_ALIVE(child); 1 16 17
CHECK_NODE_ALIVE(child); 0 1 1
1111 16 ▶ CHECK_SAME_DOC(self, child);
Branch: 1 branch
BranchTrueFalseTotal
CHECK_SAME_DOC(self, child); 1 15 16
1112 /* pugixml frees the subtree's storage here, so every handle into it must
1113 be killed first, while the subtree is still walkable. The condition
1114 mirrors pugixml's own precondition, so a removal that is going to fail
1115 for the usual reason invalidates nothing; pugixml can still refuse on
1116 an allocator reserve after that check, which revive_handles undoes. */
1117 15 char err[256] = "";
1118 15 RETVAL = false;
1119 {
1120 15 std::vector<PugiNode*> killed_nodes;
1121 15 std::vector<PugiAttr*> killed_attrs;
1122 try {
1123 15 ▶ if (child->node && child->node.parent() == self->node)
Branch: 6 branches
BranchTrueFalseTotal
if (child->node && child->node.parent() == self->node) 15 0 15
if (child->node && child->node.parent() == self->node) 15 0 15
if (child->node && child->node.parent() == self->node) 15 0 15
if (child->node && child->node.parent() == self->node) 15 0 15
if (child->node && child->node.parent() == self->node) 13 2 15
if (child->node && child->node.parent() == self->node) 13 2 15
1124 13 ▶ invalidate_subtree(self->owner, child->node, killed_nodes, killed_attrs);
Branch: 1 branch
BranchTrueFalseTotal
invalidate_subtree(self->owner, child->node, killed_nodes, killed_attrs); 13 0 13
1125 15 ▶ RETVAL = self->node.remove_child(child->node);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = self->node.remove_child(child->node); 15 0 15
1126 15 ▶ if (RETVAL) retire_handles(killed_nodes, killed_attrs);
Branch: 2 branches
BranchTrueFalseTotal
if (RETVAL) retire_handles(killed_nodes, killed_attrs); 13 2 15
if (RETVAL) retire_handles(killed_nodes, killed_attrs); 13 0 13
1127 2 ▶ else revive_handles(killed_nodes, killed_attrs);
Branch: 1 branch
BranchTrueFalseTotal
else revive_handles(killed_nodes, killed_attrs); 0 0 0
1128 } catch (const std::exception& e) {
1129 revive_handles(killed_nodes, killed_attrs);
1130 snprintf(err, sizeof(err), "remove_child error: %s", e.what());
1131 }
1132 15 }
1133 15 ▶ if (err[0]) croak("%s", err);
Branch: 1 branch
BranchTrueFalseTotal
if (err[0]) croak("%s", err); 0 15 15
1134 }
1135 OUTPUT:
1136 RETVAL
1137  
1138 bool
1139 remove_attr(XML::PugiXML::Node self, nul_safe_pv name)
1140 CODE:
1141 {
1142 5 ▶ CHECK_NODE_ALIVE(self);
Branch: 5 branches
BranchTrueFalseTotal
CHECK_NODE_ALIVE(self); 0 5 5
CHECK_NODE_ALIVE(self); 5 0 5
CHECK_NODE_ALIVE(self); 5 0 5
CHECK_NODE_ALIVE(self); 0 5 5
CHECK_NODE_ALIVE(self); 0 0 0
1143 /* Same reasoning as remove_child: the attribute's storage is freed, so
1144 handles to it must be killed while it is still readable. */
1145 5 ▶ xml_attribute victim = self->node.attribute(name);
Branch: 1 branch
BranchTrueFalseTotal
xml_attribute victim = self->node.attribute(name); 5 0 5
1146 5 char err[256] = "";
1147 5 RETVAL = false;
1148 5 ▶ if (victim) {
Branch: 2 branches
BranchTrueFalseTotal
if (victim) { 5 0 5
if (victim) { 2 3 5
1149 2 std::vector<PugiNode*> killed_nodes;
1150 2 std::vector<PugiAttr*> killed_attrs;
1151 try {
1152 2 ▶ invalidate_attribute(self->owner, victim, killed_attrs);
Branch: 1 branch
BranchTrueFalseTotal
invalidate_attribute(self->owner, victim, killed_attrs); 2 0 2
1153 2 ▶ RETVAL = self->node.remove_attribute(victim);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = self->node.remove_attribute(victim); 2 0 2
1154 2 ▶ if (RETVAL) retire_handles(killed_nodes, killed_attrs);
Branch: 2 branches
BranchTrueFalseTotal
if (RETVAL) retire_handles(killed_nodes, killed_attrs); 2 0 2
if (RETVAL) retire_handles(killed_nodes, killed_attrs); 2 0 2
1155 0 ▶ else revive_handles(killed_nodes, killed_attrs);
Branch: 1 branch
BranchTrueFalseTotal
else revive_handles(killed_nodes, killed_attrs); 0 0 0
1156 } catch (const std::exception& e) {
1157 revive_handles(killed_nodes, killed_attrs);
1158 snprintf(err, sizeof(err), "remove_attr error: %s", e.what());
1159 }
1160 2 }
1161 5 ▶ if (err[0]) croak("%s", err);
Branch: 1 branch
BranchTrueFalseTotal
if (err[0]) croak("%s", err); 0 5 5
1162 }
1163 OUTPUT:
1164 RETVAL
1165  
1166 SV*
1167 append_copy(XML::PugiXML::Node self, XML::PugiXML::Node source)
1168 CODE:
1169 {
1170 3 ▶ CHECK_NODE_ALIVE(self);
Branch: 5 branches
BranchTrueFalseTotal
CHECK_NODE_ALIVE(self); 0 3 3
CHECK_NODE_ALIVE(self); 3 0 3
CHECK_NODE_ALIVE(self); 3 0 3
CHECK_NODE_ALIVE(self); 0 3 3
CHECK_NODE_ALIVE(self); 0 0 0
1171 3 ▶ CHECK_NODE_ALIVE(source);
Branch: 5 branches
BranchTrueFalseTotal
CHECK_NODE_ALIVE(source); 0 3 3
CHECK_NODE_ALIVE(source); 3 0 3
CHECK_NODE_ALIVE(source); 3 0 3
CHECK_NODE_ALIVE(source); 1 2 3
CHECK_NODE_ALIVE(source); 0 1 1
1172 2 ▶ xml_node copy = self->node.append_copy(source->node);
Branch: 1 branch
BranchTrueFalseTotal
xml_node copy = self->node.append_copy(source->node); 2 0 2
1173 2 ▶ RETVAL = wrap_node(aTHX_ copy, self->doc_sv);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = wrap_node(aTHX_ copy, self->doc_sv); 2 0 2
1174 }
1175 OUTPUT:
1176 RETVAL
1177  
1178 SV*
1179 prepend_copy(XML::PugiXML::Node self, XML::PugiXML::Node source)
1180 CODE:
1181 {
1182 2 ▶ CHECK_NODE_ALIVE(self);
Branch: 5 branches
BranchTrueFalseTotal
CHECK_NODE_ALIVE(self); 0 2 2
CHECK_NODE_ALIVE(self); 2 0 2
CHECK_NODE_ALIVE(self); 2 0 2
CHECK_NODE_ALIVE(self); 0 2 2
CHECK_NODE_ALIVE(self); 0 0 0
1183 2 ▶ CHECK_NODE_ALIVE(source);
Branch: 5 branches
BranchTrueFalseTotal
CHECK_NODE_ALIVE(source); 0 2 2
CHECK_NODE_ALIVE(source); 2 0 2
CHECK_NODE_ALIVE(source); 2 0 2
CHECK_NODE_ALIVE(source); 1 1 2
CHECK_NODE_ALIVE(source); 0 1 1
1184 1 ▶ xml_node copy = self->node.prepend_copy(source->node);
Branch: 1 branch
BranchTrueFalseTotal
xml_node copy = self->node.prepend_copy(source->node); 1 0 1
1185 1 ▶ RETVAL = wrap_node(aTHX_ copy, self->doc_sv);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = wrap_node(aTHX_ copy, self->doc_sv); 1 0 1
1186 }
1187 OUTPUT:
1188 RETVAL
1189  
1190 SV*
1191 insert_copy_before(XML::PugiXML::Node self, XML::PugiXML::Node source, XML::PugiXML::Node ref_node)
1192 CODE:
1193 {
1194 5 ▶ CHECK_NODE_ALIVE(self);
Branch: 5 branches
BranchTrueFalseTotal
CHECK_NODE_ALIVE(self); 0 5 5
CHECK_NODE_ALIVE(self); 5 0 5
CHECK_NODE_ALIVE(self); 5 0 5
CHECK_NODE_ALIVE(self); 0 5 5
CHECK_NODE_ALIVE(self); 0 0 0
1195 5 ▶ CHECK_NODE_ALIVE(source);
Branch: 5 branches
BranchTrueFalseTotal
CHECK_NODE_ALIVE(source); 0 5 5
CHECK_NODE_ALIVE(source); 5 0 5
CHECK_NODE_ALIVE(source); 5 0 5
CHECK_NODE_ALIVE(source); 1 4 5
CHECK_NODE_ALIVE(source); 0 1 1
1196 4 ▶ CHECK_NODE_ALIVE(ref_node);
Branch: 5 branches
BranchTrueFalseTotal
CHECK_NODE_ALIVE(ref_node); 0 4 4
CHECK_NODE_ALIVE(ref_node); 4 0 4
CHECK_NODE_ALIVE(ref_node); 4 0 4
CHECK_NODE_ALIVE(ref_node); 1 3 4
CHECK_NODE_ALIVE(ref_node); 0 1 1
1197 3 ▶ CHECK_SAME_DOC(self, ref_node);
Branch: 1 branch
BranchTrueFalseTotal
CHECK_SAME_DOC(self, ref_node); 1 2 3
1198 2 ▶ xml_node copy = self->node.insert_copy_before(source->node, ref_node->node);
Branch: 1 branch
BranchTrueFalseTotal
xml_node copy = self->node.insert_copy_before(source->node, ref_node->node); 2 0 2
1199 2 ▶ RETVAL = wrap_node(aTHX_ copy, self->doc_sv);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = wrap_node(aTHX_ copy, self->doc_sv); 2 0 2
1200 }
1201 OUTPUT:
1202 RETVAL
1203  
1204 SV*
1205 insert_copy_after(XML::PugiXML::Node self, XML::PugiXML::Node source, XML::PugiXML::Node ref_node)
1206 CODE:
1207 {
1208 4 ▶ CHECK_NODE_ALIVE(self);
Branch: 5 branches
BranchTrueFalseTotal
CHECK_NODE_ALIVE(self); 0 4 4
CHECK_NODE_ALIVE(self); 4 0 4
CHECK_NODE_ALIVE(self); 4 0 4
CHECK_NODE_ALIVE(self); 0 4 4
CHECK_NODE_ALIVE(self); 0 0 0
1209 4 ▶ CHECK_NODE_ALIVE(source);
Branch: 5 branches
BranchTrueFalseTotal
CHECK_NODE_ALIVE(source); 0 4 4
CHECK_NODE_ALIVE(source); 4 0 4
CHECK_NODE_ALIVE(source); 4 0 4
CHECK_NODE_ALIVE(source); 1 3 4
CHECK_NODE_ALIVE(source); 0 1 1
1210 3 ▶ CHECK_NODE_ALIVE(ref_node);
Branch: 5 branches
BranchTrueFalseTotal
CHECK_NODE_ALIVE(ref_node); 0 3 3
CHECK_NODE_ALIVE(ref_node); 3 0 3
CHECK_NODE_ALIVE(ref_node); 3 0 3
CHECK_NODE_ALIVE(ref_node); 1 2 3
CHECK_NODE_ALIVE(ref_node); 0 1 1
1211 2 ▶ CHECK_SAME_DOC(self, ref_node);
Branch: 1 branch
BranchTrueFalseTotal
CHECK_SAME_DOC(self, ref_node); 1 1 2
1212 1 ▶ xml_node copy = self->node.insert_copy_after(source->node, ref_node->node);
Branch: 1 branch
BranchTrueFalseTotal
xml_node copy = self->node.insert_copy_after(source->node, ref_node->node); 1 0 1
1213 1 ▶ RETVAL = wrap_node(aTHX_ copy, self->doc_sv);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = wrap_node(aTHX_ copy, self->doc_sv); 1 0 1
1214 }
1215 OUTPUT:
1216 RETVAL
1217  
1218 SV*
1219 set_attr(XML::PugiXML::Node self, nul_safe_pv name, nul_safe_pv value)
1220 CODE:
1221 {
1222 4 ▶ CHECK_NODE_ALIVE(self);
Branch: 5 branches
BranchTrueFalseTotal
CHECK_NODE_ALIVE(self); 0 4 4
CHECK_NODE_ALIVE(self); 4 0 4
CHECK_NODE_ALIVE(self); 4 0 4
CHECK_NODE_ALIVE(self); 0 4 4
CHECK_NODE_ALIVE(self); 0 0 0
1223 4 ▶ xml_attribute attr = self->node.attribute(name);
Branch: 1 branch
BranchTrueFalseTotal
xml_attribute attr = self->node.attribute(name); 4 0 4
1224 4 ▶ if (!attr) {
Branch: 2 branches
BranchTrueFalseTotal
if (!attr) { 4 0 4
if (!attr) { 3 1 4
1225 3 ▶ attr = self->node.append_attribute(name);
Branch: 1 branch
BranchTrueFalseTotal
attr = self->node.append_attribute(name); 3 0 3
1226 }
1227 4 ▶ if (attr) {
Branch: 2 branches
BranchTrueFalseTotal
if (attr) { 4 0 4
if (attr) { 4 0 4
1228 4 ▶ attr.set_value(value);
Branch: 1 branch
BranchTrueFalseTotal
attr.set_value(value); 4 0 4
1229 }
1230 4 ▶ RETVAL = wrap_attr(aTHX_ attr, self->node, self->doc_sv);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = wrap_attr(aTHX_ attr, self->node, self->doc_sv); 4 0 4
1231 }
1232 OUTPUT:
1233 RETVAL
1234  
1235 SV*
1236 append_pi(XML::PugiXML::Node self, nul_safe_pv target, nul_safe_pv data = NULL)
1237 CODE:
1238 {
1239 2 ▶ CHECK_NODE_ALIVE(self);
Branch: 5 branches
BranchTrueFalseTotal
CHECK_NODE_ALIVE(self); 0 2 2
CHECK_NODE_ALIVE(self); 2 0 2
CHECK_NODE_ALIVE(self); 2 0 2
CHECK_NODE_ALIVE(self); 0 2 2
CHECK_NODE_ALIVE(self); 0 0 0
1240 2 ▶ xml_node pi = self->node.append_child(node_pi);
Branch: 1 branch
BranchTrueFalseTotal
xml_node pi = self->node.append_child(node_pi); 2 0 2
1241 2 ▶ if (pi) {
Branch: 2 branches
BranchTrueFalseTotal
if (pi) { 2 0 2
if (pi) { 2 0 2
1242 2 ▶ pi.set_name(target);
Branch: 1 branch
BranchTrueFalseTotal
pi.set_name(target); 2 0 2
1243 2 ▶ if (data) {
Branch: 1 branch
BranchTrueFalseTotal
if (data) { 1 1 2
1244 1 ▶ pi.set_value(data);
Branch: 1 branch
BranchTrueFalseTotal
pi.set_value(data); 1 0 1
1245 }
1246 }
1247 2 ▶ RETVAL = wrap_node(aTHX_ pi, self->doc_sv);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = wrap_node(aTHX_ pi, self->doc_sv); 2 0 2
1248 }
1249 OUTPUT:
1250 RETVAL
1251  
1252 size_t
1253 hash(XML::PugiXML::Node self)
1254 CODE:
1255 {
1256 3 ▶ CHECK_NODE_ALIVE(self);
Branch: 5 branches
BranchTrueFalseTotal
CHECK_NODE_ALIVE(self); 0 3 3
CHECK_NODE_ALIVE(self); 3 0 3
CHECK_NODE_ALIVE(self); 3 0 3
CHECK_NODE_ALIVE(self); 0 3 3
CHECK_NODE_ALIVE(self); 0 0 0
1257 3 ▶ RETVAL = self->node.hash_value();
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = self->node.hash_value(); 0 3 3
1258 }
1259 OUTPUT:
1260 RETVAL
1261  
1262 IV
1263 offset_debug(XML::PugiXML::Node self)
1264 CODE:
1265 {
1266 2 ▶ CHECK_NODE_ALIVE(self);
Branch: 5 branches
BranchTrueFalseTotal
CHECK_NODE_ALIVE(self); 0 2 2
CHECK_NODE_ALIVE(self); 2 0 2
CHECK_NODE_ALIVE(self); 2 0 2
CHECK_NODE_ALIVE(self); 0 2 2
CHECK_NODE_ALIVE(self); 0 0 0
1267 2 ▶ RETVAL = (IV)self->node.offset_debug();
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = (IV)self->node.offset_debug(); 0 2 2
1268 }
1269 OUTPUT:
1270 RETVAL
1271  
1272  
1273 MODULE = XML::PugiXML PACKAGE = XML::PugiXML::Attr
1274  
1275 void
1276 DESTROY(XML::PugiXML::Attr self)
1277 CODE:
1278 {
1279 278 ▶ if (!self) XSRETURN_EMPTY;
Branch: 1 branch
BranchTrueFalseTotal
if (!self) XSRETURN_EMPTY; 6 272 278
1280 272 doc_unregister_attr(self);
1281 272 SvREFCNT_dec(self->doc_sv);
1282 272 ▶ delete self;
Branch: 1 branch
BranchTrueFalseTotal
delete self; 272 0 272
1283 272 ▶ if (SvROK(ST(0))) sv_setiv(SvRV(ST(0)), 0);
Branch: 1 branch
BranchTrueFalseTotal
if (SvROK(ST(0))) sv_setiv(SvRV(ST(0)), 0); 272 0 272
1284 }
1285  
1286 SV*
1287 name(XML::PugiXML::Attr self)
1288 CODE:
1289 {
1290 5 ▶ CHECK_ATTR_ALIVE(self);
Branch: 5 branches
BranchTrueFalseTotal
CHECK_ATTR_ALIVE(self); 1 4 5
CHECK_ATTR_ALIVE(self); 4 0 4
CHECK_ATTR_ALIVE(self); 4 0 4
CHECK_ATTR_ALIVE(self); 0 4 4
CHECK_ATTR_ALIVE(self); 0 0 0
1291 4 RETVAL = newSVpv_utf8(aTHX_ self->attr.name());
1292 }
1293 OUTPUT:
1294 RETVAL
1295  
1296 SV*
1297 value(XML::PugiXML::Attr self)
1298 CODE:
1299 {
1300 34 ▶ CHECK_ATTR_ALIVE(self);
Branch: 5 branches
BranchTrueFalseTotal
CHECK_ATTR_ALIVE(self); 1 33 34
CHECK_ATTR_ALIVE(self); 33 0 33
CHECK_ATTR_ALIVE(self); 31 2 33
CHECK_ATTR_ALIVE(self); 2 29 31
CHECK_ATTR_ALIVE(self); 2 2 4
1301 29 RETVAL = newSVpv_utf8(aTHX_ self->attr.value());
1302 }
1303 OUTPUT:
1304 RETVAL
1305  
1306 int
1307 as_int(XML::PugiXML::Attr self)
1308 CODE:
1309 {
1310 1 ▶ CHECK_ATTR_ALIVE(self);
Branch: 5 branches
BranchTrueFalseTotal
CHECK_ATTR_ALIVE(self); 0 1 1
CHECK_ATTR_ALIVE(self); 1 0 1
CHECK_ATTR_ALIVE(self); 1 0 1
CHECK_ATTR_ALIVE(self); 0 1 1
CHECK_ATTR_ALIVE(self); 0 0 0
1311 1 ▶ RETVAL = self->attr.as_int();
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = self->attr.as_int(); 0 1 1
1312 }
1313 OUTPUT:
1314 RETVAL
1315  
1316 double
1317 as_double(XML::PugiXML::Attr self)
1318 CODE:
1319 {
1320 1 ▶ CHECK_ATTR_ALIVE(self);
Branch: 5 branches
BranchTrueFalseTotal
CHECK_ATTR_ALIVE(self); 0 1 1
CHECK_ATTR_ALIVE(self); 1 0 1
CHECK_ATTR_ALIVE(self); 1 0 1
CHECK_ATTR_ALIVE(self); 0 1 1
CHECK_ATTR_ALIVE(self); 0 0 0
1321 1 ▶ RETVAL = self->attr.as_double();
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = self->attr.as_double(); 0 1 1
1322 }
1323 OUTPUT:
1324 RETVAL
1325  
1326 bool
1327 as_bool(XML::PugiXML::Attr self)
1328 CODE:
1329 {
1330 1 ▶ CHECK_ATTR_ALIVE(self);
Branch: 5 branches
BranchTrueFalseTotal
CHECK_ATTR_ALIVE(self); 0 1 1
CHECK_ATTR_ALIVE(self); 1 0 1
CHECK_ATTR_ALIVE(self); 1 0 1
CHECK_ATTR_ALIVE(self); 0 1 1
CHECK_ATTR_ALIVE(self); 0 0 0
1331 1 ▶ RETVAL = self->attr.as_bool();
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = self->attr.as_bool(); 1 0 1
1332 }
1333 OUTPUT:
1334 RETVAL
1335  
1336 unsigned int
1337 as_uint(XML::PugiXML::Attr self)
1338 CODE:
1339 {
1340 1 ▶ CHECK_ATTR_ALIVE(self);
Branch: 5 branches
BranchTrueFalseTotal
CHECK_ATTR_ALIVE(self); 0 1 1
CHECK_ATTR_ALIVE(self); 1 0 1
CHECK_ATTR_ALIVE(self); 1 0 1
CHECK_ATTR_ALIVE(self); 0 1 1
CHECK_ATTR_ALIVE(self); 0 0 0
1341 1 ▶ RETVAL = self->attr.as_uint();
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = self->attr.as_uint(); 0 1 1
1342 }
1343 OUTPUT:
1344 RETVAL
1345  
1346 SV*
1347 as_llong(XML::PugiXML::Attr self)
1348 CODE:
1349 {
1350 2 ▶ CHECK_ATTR_ALIVE(self);
Branch: 5 branches
BranchTrueFalseTotal
CHECK_ATTR_ALIVE(self); 0 2 2
CHECK_ATTR_ALIVE(self); 2 0 2
CHECK_ATTR_ALIVE(self); 2 0 2
CHECK_ATTR_ALIVE(self); 0 2 2
CHECK_ATTR_ALIVE(self); 0 0 0
1351 #if IVSIZE >= 8
1352 2 RETVAL = newSViv((IV)self->attr.as_llong());
1353 #else
1354 long long val = self->attr.as_llong();
1355 char buf[32];
1356 snprintf(buf, sizeof(buf), "%lld", val);
1357 RETVAL = newSVpv(buf, 0);
1358 #endif
1359 }
1360 OUTPUT:
1361 RETVAL
1362  
1363 SV*
1364 as_ullong(XML::PugiXML::Attr self)
1365 CODE:
1366 {
1367 2 ▶ CHECK_ATTR_ALIVE(self);
Branch: 5 branches
BranchTrueFalseTotal
CHECK_ATTR_ALIVE(self); 0 2 2
CHECK_ATTR_ALIVE(self); 2 0 2
CHECK_ATTR_ALIVE(self); 2 0 2
CHECK_ATTR_ALIVE(self); 0 2 2
CHECK_ATTR_ALIVE(self); 0 0 0
1368 #if IVSIZE >= 8
1369 2 RETVAL = newSVuv((UV)self->attr.as_ullong());
1370 #else
1371 unsigned long long val = self->attr.as_ullong();
1372 char buf[32];
1373 snprintf(buf, sizeof(buf), "%llu", val);
1374 RETVAL = newSVpv(buf, 0);
1375 #endif
1376 }
1377 OUTPUT:
1378 RETVAL
1379  
1380 bool
1381 set_value(XML::PugiXML::Attr self, nul_safe_pv value)
1382 CODE:
1383 {
1384 3 ▶ CHECK_ATTR_ALIVE(self);
Branch: 5 branches
BranchTrueFalseTotal
CHECK_ATTR_ALIVE(self); 0 3 3
CHECK_ATTR_ALIVE(self); 3 0 3
CHECK_ATTR_ALIVE(self); 3 0 3
CHECK_ATTR_ALIVE(self); 0 3 3
CHECK_ATTR_ALIVE(self); 0 0 0
1385 3 ▶ RETVAL = self->attr.set_value(value);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = self->attr.set_value(value); 3 0 3
1386 }
1387 OUTPUT:
1388 RETVAL
1389  
1390 bool
1391 set_name(XML::PugiXML::Attr self, nul_safe_pv name)
1392 CODE:
1393 {
1394 1 ▶ CHECK_ATTR_ALIVE(self);
Branch: 5 branches
BranchTrueFalseTotal
CHECK_ATTR_ALIVE(self); 0 1 1
CHECK_ATTR_ALIVE(self); 1 0 1
CHECK_ATTR_ALIVE(self); 1 0 1
CHECK_ATTR_ALIVE(self); 0 1 1
CHECK_ATTR_ALIVE(self); 0 0 0
1395 1 ▶ RETVAL = self->attr.set_name(name);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = self->attr.set_name(name); 1 0 1
1396 }
1397 OUTPUT:
1398 RETVAL
1399  
1400 SV*
1401 element(XML::PugiXML::Attr self)
1402 CODE:
1403 {
1404 7 ▶ CHECK_ATTR_ALIVE(self);
Branch: 5 branches
BranchTrueFalseTotal
CHECK_ATTR_ALIVE(self); 0 7 7
CHECK_ATTR_ALIVE(self); 7 0 7
CHECK_ATTR_ALIVE(self); 7 0 7
CHECK_ATTR_ALIVE(self); 0 7 7
CHECK_ATTR_ALIVE(self); 0 0 0
1405 7 RETVAL = wrap_node(aTHX_ self->parent_node, self->doc_sv);
1406 }
1407 OUTPUT:
1408 RETVAL
1409  
1410 bool
1411 valid(XML::PugiXML::Attr self)
1412 CODE:
1413 {
1414 /* valid() deliberately skips CHECK_ATTR_ALIVE -- returns false for stale handles */
1415 220 ▶ RETVAL = (self != NULL) && !HANDLE_STALE(self) && !self->dead && (bool)self->attr;
Branch: 7 branches
BranchTrueFalseTotal
RETVAL = (self != NULL) && !HANDLE_STALE(self) && !self->dead && (bool)self->attr; 218 2 220
RETVAL = (self != NULL) && !HANDLE_STALE(self) && !self->dead && (bool)self->attr; 218 0 218
RETVAL = (self != NULL) && !HANDLE_STALE(self) && !self->dead && (bool)self->attr; 212 6 218
RETVAL = (self != NULL) && !HANDLE_STALE(self) && !self->dead && (bool)self->attr; 207 5 212
RETVAL = (self != NULL) && !HANDLE_STALE(self) && !self->dead && (bool)self->attr; 207 0 207
RETVAL = (self != NULL) && !HANDLE_STALE(self) && !self->dead && (bool)self->attr; 207 0 207
RETVAL = (self != NULL) && !HANDLE_STALE(self) && !self->dead && (bool)self->attr; 207 13 220
1416 }
1417 OUTPUT:
1418 RETVAL
1419  
1420  
1421 MODULE = XML::PugiXML PACKAGE = XML::PugiXML::XPath
1422  
1423 void
1424 DESTROY(XML::PugiXML::XPath self)
1425 CODE:
1426 {
1427 15 ▶ if (!self) XSRETURN_EMPTY;
Branch: 1 branch
BranchTrueFalseTotal
if (!self) XSRETURN_EMPTY; 4 11 15
1428 11 ▶ delete self->query;
Branch: 1 branch
BranchTrueFalseTotal
delete self->query; 11 0 11
1429 11 ▶ delete self;
Branch: 1 branch
BranchTrueFalseTotal
delete self; 11 0 11
1430 11 ▶ if (SvROK(ST(0))) sv_setiv(SvRV(ST(0)), 0);
Branch: 1 branch
BranchTrueFalseTotal
if (SvROK(ST(0))) sv_setiv(SvRV(ST(0)), 0); 11 0 11
1431 }
1432  
1433 SV*
1434 evaluate_node(XML::PugiXML::XPath self, XML::PugiXML::Node node)
1435 CODE:
1436 {
1437 4 ▶ CHECK_XPATH_ALIVE(self);
Branch: 2 branches
BranchTrueFalseTotal
CHECK_XPATH_ALIVE(self); 3 1 4
CHECK_XPATH_ALIVE(self); 0 3 3
1438 3 ▶ CHECK_NODE_ALIVE(node);
Branch: 5 branches
BranchTrueFalseTotal
CHECK_NODE_ALIVE(node); 0 3 3
CHECK_NODE_ALIVE(node); 3 0 3
CHECK_NODE_ALIVE(node); 3 0 3
CHECK_NODE_ALIVE(node); 0 3 3
CHECK_NODE_ALIVE(node); 0 0 0
1439 3 RETVAL = 0;
1440 3 XPATH_GUARDED {
1441 3 ▶ xpath_node result = self->query->evaluate_node(node->node);
Branch: 2 branches
BranchTrueFalseTotal
xpath_node result = self->query->evaluate_node(node->node); 3 0 3
xpath_node result = self->query->evaluate_node(node->node); 3 0 3
1442 3 ▶ RETVAL = wrap_xpath_result(aTHX_ result, node->doc_sv);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = wrap_xpath_result(aTHX_ result, node->doc_sv); 3 0 3
1443 3 ▶ } END_XPATH_GUARDED;
Branch: 2 branches
BranchTrueFalseTotal
} END_XPATH_GUARDED; 0 3 3
} END_XPATH_GUARDED; 0 0 0
1444 }
1445 OUTPUT:
1446 RETVAL
1447  
1448 void
1449 evaluate_nodes(XML::PugiXML::XPath self, XML::PugiXML::Node node)
1450 PPCODE:
1451 {
1452 5 ▶ CHECK_XPATH_ALIVE(self);
Branch: 2 branches
BranchTrueFalseTotal
CHECK_XPATH_ALIVE(self); 4 1 5
CHECK_XPATH_ALIVE(self); 0 4 4
1453 4 ▶ CHECK_NODE_ALIVE(node);
Branch: 5 branches
BranchTrueFalseTotal
CHECK_NODE_ALIVE(node); 0 4 4
CHECK_NODE_ALIVE(node); 4 0 4
CHECK_NODE_ALIVE(node); 4 0 4
CHECK_NODE_ALIVE(node); 1 3 4
CHECK_NODE_ALIVE(node); 0 1 1
1454 3 XPATH_GUARDED {
1455 3 ▶ xpath_node_set nodes = self->query->evaluate_node_set(node->node);
Branch: 2 branches
BranchTrueFalseTotal
xpath_node_set nodes = self->query->evaluate_node_set(node->node); 3 0 3
xpath_node_set nodes = self->query->evaluate_node_set(node->node); 3 0 3
1456 3 ▶ EXTEND(SP, (SSize_t)nodes.size());
Branch: 7 branches
BranchTrueFalseTotal
EXTEND(SP, (SSize_t)nodes.size()); 3 0 3
EXTEND(SP, (SSize_t)nodes.size()); 3 0 3
EXTEND(SP, (SSize_t)nodes.size()); 3 0 3
EXTEND(SP, (SSize_t)nodes.size()); 0 3 3
EXTEND(SP, (SSize_t)nodes.size()); 0 3 3
EXTEND(SP, (SSize_t)nodes.size()); 0 0 0
EXTEND(SP, (SSize_t)nodes.size()); 0 0 0
1457 8 ▶ for (xpath_node_set::const_iterator it = nodes.begin(); it != nodes.end(); ++it) {
Branch: 3 branches
BranchTrueFalseTotal
for (xpath_node_set::const_iterator it = nodes.begin(); it != nodes.end(); ++it) { 3 0 3
for (xpath_node_set::const_iterator it = nodes.begin(); it != nodes.end(); ++it) { 8 0 8
for (xpath_node_set::const_iterator it = nodes.begin(); it != nodes.end(); ++it) { 5 3 8
1458 5 ▶ SV* sv = wrap_xpath_result(aTHX_ *it, node->doc_sv);
Branch: 1 branch
BranchTrueFalseTotal
SV* sv = wrap_xpath_result(aTHX_ *it, node->doc_sv); 5 0 5
1459 5 ▶ PUSHs(sv_2mortal(sv));
Branch: 1 branch
BranchTrueFalseTotal
PUSHs(sv_2mortal(sv)); 5 0 5
1460 }
1461 6 ▶ } END_XPATH_GUARDED;
Branch: 2 branches
BranchTrueFalseTotal
} END_XPATH_GUARDED; 0 3 3
} END_XPATH_GUARDED; 0 0 0
1462 }
1463  
1464 SV*
1465 evaluate_string(XML::PugiXML::XPath self, XML::PugiXML::Node node)
1466 CODE:
1467 {
1468 2 ▶ CHECK_XPATH_ALIVE(self);
Branch: 2 branches
BranchTrueFalseTotal
CHECK_XPATH_ALIVE(self); 1 1 2
CHECK_XPATH_ALIVE(self); 0 1 1
1469 1 ▶ CHECK_NODE_ALIVE(node);
Branch: 5 branches
BranchTrueFalseTotal
CHECK_NODE_ALIVE(node); 0 1 1
CHECK_NODE_ALIVE(node); 1 0 1
CHECK_NODE_ALIVE(node); 1 0 1
CHECK_NODE_ALIVE(node); 0 1 1
CHECK_NODE_ALIVE(node); 0 0 0
1470 1 RETVAL = 0;
1471 1 XPATH_GUARDED {
1472 1 ▶ std::string result = self->query->evaluate_string(node->node);
Branch: 2 branches
BranchTrueFalseTotal
std::string result = self->query->evaluate_string(node->node); 1 0 1
std::string result = self->query->evaluate_string(node->node); 1 0 1
1473 1 ▶ RETVAL = new_utf8_svpvn(aTHX_ result.c_str(), result.length());
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = new_utf8_svpvn(aTHX_ result.c_str(), result.length()); 1 0 1
1474 2 ▶ } END_XPATH_GUARDED;
Branch: 2 branches
BranchTrueFalseTotal
} END_XPATH_GUARDED; 0 1 1
} END_XPATH_GUARDED; 0 0 0
1475 }
1476 OUTPUT:
1477 RETVAL
1478  
1479 double
1480 evaluate_number(XML::PugiXML::XPath self, XML::PugiXML::Node node)
1481 CODE:
1482 {
1483 2 ▶ CHECK_XPATH_ALIVE(self);
Branch: 2 branches
BranchTrueFalseTotal
CHECK_XPATH_ALIVE(self); 1 1 2
CHECK_XPATH_ALIVE(self); 0 1 1
1484 1 ▶ CHECK_NODE_ALIVE(node);
Branch: 5 branches
BranchTrueFalseTotal
CHECK_NODE_ALIVE(node); 0 1 1
CHECK_NODE_ALIVE(node); 1 0 1
CHECK_NODE_ALIVE(node); 1 0 1
CHECK_NODE_ALIVE(node); 0 1 1
CHECK_NODE_ALIVE(node); 0 0 0
1485 1 RETVAL = 0;
1486 1 XPATH_GUARDED {
1487 1 ▶ RETVAL = self->query->evaluate_number(node->node);
Branch: 2 branches
BranchTrueFalseTotal
RETVAL = self->query->evaluate_number(node->node); 1 0 1
RETVAL = self->query->evaluate_number(node->node); 1 0 1
1488 1 ▶ } END_XPATH_GUARDED;
Branch: 2 branches
BranchTrueFalseTotal
} END_XPATH_GUARDED; 0 1 1
} END_XPATH_GUARDED; 0 0 0
1489 }
1490 OUTPUT:
1491 RETVAL
1492  
1493 bool
1494 evaluate_boolean(XML::PugiXML::XPath self, XML::PugiXML::Node node)
1495 CODE:
1496 {
1497 2 ▶ CHECK_XPATH_ALIVE(self);
Branch: 2 branches
BranchTrueFalseTotal
CHECK_XPATH_ALIVE(self); 1 1 2
CHECK_XPATH_ALIVE(self); 0 1 1
1498 1 ▶ CHECK_NODE_ALIVE(node);
Branch: 5 branches
BranchTrueFalseTotal
CHECK_NODE_ALIVE(node); 0 1 1
CHECK_NODE_ALIVE(node); 1 0 1
CHECK_NODE_ALIVE(node); 1 0 1
CHECK_NODE_ALIVE(node); 0 1 1
CHECK_NODE_ALIVE(node); 0 0 0
1499 1 RETVAL = 0;
1500 1 XPATH_GUARDED {
1501 1 ▶ RETVAL = self->query->evaluate_boolean(node->node);
Branch: 2 branches
BranchTrueFalseTotal
RETVAL = self->query->evaluate_boolean(node->node); 1 0 1
RETVAL = self->query->evaluate_boolean(node->node); 1 0 1
1502 1 ▶ } END_XPATH_GUARDED;
Branch: 2 branches
BranchTrueFalseTotal
} END_XPATH_GUARDED; 0 1 1
} END_XPATH_GUARDED; 0 0 0
1503 }
1504 OUTPUT:
1505 RETVAL
↑ Summary blib/lib/XML/PugiXML.pm »