8#ifndef __ABG_LIBXML_UTILS_H__
9#define __ABG_LIBXML_UTILS_H__
11#include <libxml/xmlreader.h>
39 operator()(xmlTextReaderPtr reader)
40 {xmlFreeTextReader(reader);}
47 operator()(xmlChar* str)
63#define XML_READER_GET_NODE_NAME(reader) \
64 xml::build_sptr(xmlTextReaderName(reader.get()))
68#define XML_READER_GET_NODE_TYPE(reader) \
69 static_cast<xmlReaderTypes> (xmlTextReaderNodeType(reader.get()))
73#define XML_READER_GET_ATTRIBUTE(reader, name) \
74 xml::build_sptr(xmlTextReaderGetAttribute(reader.get(), BAD_CAST(name)))
78#define XML_NODE_GET_ATTRIBUTE(node, name) \
79 xml::build_sptr(xmlGetProp(node, BAD_CAST(name)))
81#define CHAR_STR(xml_char_str) \
82 reinterpret_cast<char*>(xml_char_str.get())
86 std::string& escaped);
93 std::string& escaped);
100 std::string& escaped);
107 std::string& escaped);
Utilities to ease the wrapping of C types into std::shared_ptr.
shared_ptr< xmlChar > build_sptr< xmlChar >(xmlChar *p)
Build and return a shared_ptr for a pointer to xmlChar.
shared_ptr< T > build_sptr(T *p)
This is to be specialized for the diverse C types that needs wrapping in shared_ptr.
shared_ptr< xmlTextReader > build_sptr< xmlTextReader >(::xmlTextReader *p)
Build and return a shared_ptr for a pointer to xmlTextReader.
void unescape_xml_comment(const std::string &str, std::string &escaped)
Read a string, detect the '#&45;' entity and un-escape it into the '-' character.
reader_sptr new_reader_from_file(const std::string &path)
Instantiate an xmlTextReader that parses the content of an on-disk file, wrap it into a smart pointer...
int get_xml_node_depth(xmlNodePtr n)
Return the depth of an xml element node.
bool xml_char_sptr_to_string(xml_char_sptr ssptr, std::string &s)
Convert a shared pointer to xmlChar into an std::string.
void escape_xml_comment(const std::string &str, std::string &escaped)
Escape the '-' character, to avoid having a '–' in a comment.
reader_sptr new_reader_from_buffer(const std::string &buffer)
Instanciate an xmlTextReader that parses the content of an in-memory buffer, wrap it into a smart poi...
shared_ptr< xmlChar > xml_char_sptr
A convenience typedef for a shared pointer of xmlChar.
void unescape_xml_string(const std::string &str, std::string &escaped)
Read a string, detect the 5 predefined XML entities it may contain and un-escape them,...
reader_sptr new_reader_from_istream(std::istream *in)
Instanciate an xmlTextReader that parses a content coming from an input stream.
shared_ptr< xmlTextReader > reader_sptr
A convenience typedef for a shared pointer of xmlTextReader.
void escape_xml_string(const std::string &str, std::string &escaped)
Escape the 5 characters representing the predefined XML entities.
Toplevel namespace for libabigail.
This functor is used to instantiate a shared_ptr for xmlChar.
This functor is used to instantiate a shared_ptr for the xmlTextReader.