[sixtp-dom-parsers.cpp] introduce dom_node_to_text for solo text node

allocation-free
returns const char* or nullptr
pull/2153/head
Christopher Lam 6 months ago
parent 2f7e51cf2a
commit a63a3e3ce3

@ -35,6 +35,15 @@
static QofLogModule log_module = GNC_MOD_IO;
const char*
dom_node_to_text (xmlNodePtr node) noexcept
{
if (node && node->children && node->children->type == XML_TEXT_NODE
&& !node->children->next)
return reinterpret_cast<const char*>(node->children->content);
return nullptr;
}
std::optional<GncGUID>
dom_tree_to_guid (xmlNodePtr node)
{

@ -45,6 +45,7 @@ gboolean dom_tree_valid_time64 (time64 ts, const xmlChar* name);
GDate* dom_tree_to_gdate (xmlNodePtr node);
gnc_numeric dom_tree_to_gnc_numeric (xmlNodePtr node);
gchar* dom_tree_to_text (xmlNodePtr tree);
const char* dom_node_to_text (xmlNodePtr node) noexcept;
gboolean string_to_binary (const gchar* str, void** v, guint64* data_len);
gboolean dom_tree_create_instance_slots (xmlNodePtr node, QofInstance* inst);

Loading…
Cancel
Save