GREM 3.12.0
Game/Rendering Engine Modules for C++
Loading...
Searching...
No Matches
xml.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 Ivar Härnqvist
2// SPDX-License-Identifier: MIT
3
4#ifndef GREM_CORE_FORMATS_XML_HPP
5#define GREM_CORE_FORMATS_XML_HPP
6
8
9#include <GREM/core/Error.hpp>
14
15namespace grem::xml {
16
24 StringView::iterator position;
25
29 size_t lineNumber;
30
31 Error(const auto& message, StringView::iterator position, size_t lineNumber)
32 : grem::Error(message)
35};
36
45
56
60struct Document {
73 [[nodiscard]] GREM_API(core) static Document parse(StringView xmlString);
74
77};
78
79} // namespace grem::xml
80
81#endif
Base exception type for runtime errors.
Definition Error.hpp:38
Nullable RAII data pointer with exclusive ownership of an object that is automatically destroyed on p...
Definition UniquePointer.hpp:77
Definition aliases.hpp:22
Definition aliases.hpp:9
StringBase< char, std::char_traits< char >, std::allocator< char > > String
Definition String.hpp:17
StringViewBase< char, std::char_traits< char > > StringView
Definition StringView.hpp:16
Named attribute of an Element with an optional value.
Definition xml.hpp:40
String value
Attribute value, or empty for no value.
Definition xml.hpp:42
UniquePointer< Attribute > next
Next neighboring attribute in the list that this attribute is part of.
Definition xml.hpp:43
String name
Name of the attribute.
Definition xml.hpp:41
Tree of Element nodes defined by an XML file.
Definition xml.hpp:60
UniquePointer< Element > root
Root element of the document tree.
Definition xml.hpp:76
static Document parse(StringView xmlString)
Parse a document from an XML string.
UniquePointer< Element > declaration
Optional XML declaration.
Definition xml.hpp:75
Node in a Document.
Definition xml.hpp:49
UniquePointer< Element > next
Next neighboring element in the list that this element is part of.
Definition xml.hpp:54
String tag
Element tag name.
Definition xml.hpp:50
UniquePointer< Attribute > attributes
Linked list of element attributes.
Definition xml.hpp:52
String content
Raw non-element text content of the element.
Definition xml.hpp:51
UniquePointer< Element > children
Linked list of children of this element.
Definition xml.hpp:53
size_t lineNumber
Line number, starting at 1 for the first line, where the error occured.
Definition xml.hpp:29
Error(const auto &message, StringView::iterator position, size_t lineNumber)
Definition xml.hpp:31
StringView::iterator position
Iterator into the source XML string where the error originated from.
Definition xml.hpp:24