From 42ae34df3c11483a798bfa01a31b9494fc8d8315 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 7 Feb 2024 00:55:30 +0100 Subject: [PATCH] Add cxml::add_child() and cxml::add_text_child(). --- src/cxml.cc | 14 ++++++++++++++ src/cxml.h | 6 ++++++ 2 files changed, 20 insertions(+) diff --git a/src/cxml.cc b/src/cxml.cc index 7096f71..814a558 100644 --- a/src/cxml.cc +++ b/src/cxml.cc @@ -470,3 +470,17 @@ cxml::raw_convert (string v) { return locale_convert (make_local(v)); } + + +xmlpp::Element* +cxml::add_child(xmlpp::Element* parent, string const& name) +{ + return parent->add_child(name); +} + + +void +cxml::add_text_child(xmlpp::Element* parent, string const& name, string const& text) +{ + parent->add_child(name)->add_child_text(text); +} diff --git a/src/cxml.h b/src/cxml.h index 3a8ba14..4176622 100644 --- a/src/cxml.h +++ b/src/cxml.h @@ -36,6 +36,7 @@ namespace xmlpp { class DomParser; + class Element; class Node; } @@ -269,6 +270,11 @@ private: std::string _root_name; }; + +xmlpp::Element* add_child(xmlpp::Element* parent, std::string const& name); +void add_text_child(xmlpp::Element* parent, std::string const& name, std::string const& text); + + } #endif -- 2.30.2