11#ifndef XMLCoreParser_XMLParserUtilities_H
12#define XMLCoreParser_XMLParserUtilities_H
17#include <source_location>
25 xmlFileName(
const std::string & fname,
const std::string & prefix=
"");
30 static const bool enabled = (std::getenv(
"XMLDEBUG") !=
nullptr);
36 label(
const std::source_location loc = std::source_location::current()){
37 return loc.function_name();
53 XML_Parser p = XML_ParserCreate(
nullptr);
55 std::cout <<
"ExpatCoreParser::Couldn't allocate memory for parser" << std::endl;
62 rtrim(
const XML_Char* s,
int len){
63 while (len > 0 && s[len - 1] ==
'\n') {
66 return (len > 0) ? std::string{s,
static_cast<std::size_t
>(len)} : std::string{};
std::string xmlFileName(const std::string &fname, const std::string &prefix)
find the xml file locally or on the datapath, return the full filename
bool debug_enabled()
true if XML debug mode is enabled in the environment
XMLParserPtr make_parser()
Create an RAII XMLParser pointer.
std::unique_ptr< std::remove_pointer_t< XML_Parser >, XMLParserDeleter > XMLParserPtr
RAII XMLParser pointer.
std::string label(const std::source_location loc=std::source_location::current())
report function name in a string, for debugging
std::string rtrim(const XML_Char *s, int len)
Trim newline from end of a XML_Char * , return the trimmed string as std::string.
deleter for a unique_ptr<XML_Parser>
void operator()(XML_Parser p) const noexcept