Skip to content

Use raw INode* for node children - #21

Merged
XenoSnowFox merged 3 commits into
mainfrom
feature/updated-xml-nodes
Sep 12, 2026
Merged

XenoSnowFox merged 3 commits into
mainfrom
feature/updated-xml-nodes

Conversation

@XenoSnowFox

Copy link
Copy Markdown
Contributor

Replace std::shared_ptr with raw INode* in NodeContainer and TagNode. NodeContainer now owns child pointers and deletes them in its destructor; append() accepts INode* (with null-check and existing cycle detection preserved); children() returns a vector<INode*>. operator<< overloads were updated to take INode* and TextNode instances are allocated with new. This change simplifies the ownership model by removing shared_ptr usage for XML node children.

Replace std::shared_ptr<INode> with raw INode* in NodeContainer and TagNode. NodeContainer now owns child pointers and deletes them in its destructor; append() accepts INode* (with null-check and existing cycle detection preserved); children() returns a vector<INode*>. operator<< overloads were updated to take INode* and TextNode instances are allocated with new. This change simplifies the ownership model by removing shared_ptr usage for XML node children.
Delete copy ctor/assignment for DeclarationNode, TagNode and NodeContainer to enforce move-only ownership of child nodes; keep/default move semantics on NodeContainer. Wrap operator<< overloads for TagNode and NodeContainer in try/catch to delete the temporary TextNode on failure and prevent leaks. Changes improve ownership safety (avoid shallow copies) and exception-safety when appending text nodes.
Introduce convenience append overloads and improve exception safety.

- include/xtrpg/xml/node/NodeContainer.hpp: add append(const std::string&) to create and append a TextNode (with RAII-style cleanup on error).
- include/xtrpg/xml/node/TagNode.hpp: add template append(tagname, consumer) to construct a TagNode, allow caller configuration via a consumer, and append it safely (cleanup on exception). Includes example usage.
- Qualify calls in operator<< to NodeContainer::append to avoid overload ambiguity.

Enables fluent, nested XML construction and better error safety.
@XenoSnowFox
XenoSnowFox merged commit 0e2c7fc into main Sep 12, 2026
4 checks passed
@XenoSnowFox
XenoSnowFox deleted the feature/updated-xml-nodes branch September 12, 2026 09:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant