Coverage Report

Created: 2026-10-28 07:05

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/serenity/Userland/Libraries/LibXML/DOM/Node.h
Line
Count
Source
1
/*
2
 * Copyright (c) 2022, Ali Mohammad Pur <mpfard@serenityos.org>
3
 *
4
 * SPDX-License-Identifier: BSD-2-Clause
5
 */
6
7
#pragma once
8
9
#include <AK/ByteString.h>
10
#include <AK/GenericLexer.h>
11
#include <AK/HashMap.h>
12
#include <AK/Variant.h>
13
#include <AK/Vector.h>
14
#include <LibXML/FundamentalTypes.h>
15
16
namespace XML {
17
18
struct Attribute {
19
    Name name;
20
    ByteString value;
21
};
22
23
struct Node {
24
    struct Text {
25
        StringBuilder builder;
26
    };
27
    struct Comment {
28
        ByteString text;
29
    };
30
    struct Element {
31
        Name name;
32
        HashMap<Name, ByteString> attributes;
33
        Vector<NonnullOwnPtr<Node>> children;
34
    };
35
36
    bool operator==(Node const&) const;
37
38
    LineTrackingLexer::Position offset;
39
    Variant<Text, Comment, Element> content;
40
    Node* parent { nullptr };
41
42
0
    bool is_text() const { return content.has<Text>(); }
43
0
    Text const& as_text() const { return content.get<Text>(); }
44
45
0
    bool is_comment() const { return content.has<Comment>(); }
46
0
    Comment const& as_comment() const { return content.get<Comment>(); }
47
48
0
    bool is_element() const { return content.has<Element>(); }
49
0
    Element const& as_element() const { return content.get<Element>(); }
50
};
51
}