add xml_node_type_str function for debugging and application logging
schulzer opened this issue · 3 comments
Hi, thanks for a great lib!
could something like this added to your header? Or such a helper function considered too much bloat? I know I could simply write a wrapping header which includes your lib as well as contains this function which I could include anywhere else.
inline const char* xml_node_type_str(xml_node_type arg)
{
switch (arg)
{
case node_null: return "null";
case node_document: return "document";
case node_element: return "element";
case node_pcdata: return "pcdata";
case node_cdata: return "cdata";
case node_comment: return "comment";
case node_pi: return "pi";
case node_declaration: return "declaration";
case node_doctype: return "doctype";
}
return "unknown";
}
Do you need this often? This seems like it's not something that should be useful super frequently because you either know the expected type of a given node or, if you're writing a function that expects arbitrary node types, you'd need to process the rest of the node data in a way that depend on the type (eg elements have names, pcdata nodes have values) in which case I'm not sure a function like the above is super helpful.
Yes and no. I use it mainly for tracing/debugging during development and think it is very handy. If I would write generic function I would use direct xml_node_type
for switching/ifelse instead of the text based version, agreed anything else wouldn't be very plausible.
Ok - this feels like something that's very easy to provide in a separate header, and doesn't obviously match any other existing functionality in pugixml so it would probably make sense to keep it separate.