libabigail
Classes | Namespaces | Macros | Typedefs | Functions
abg-libxml-utils.h File Reference
#include <libxml/xmlreader.h>
#include <istream>
#include <memory>
#include "abg-sptr-utils.h"
Include dependency graph for abg-libxml-utils.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  charDeleter
 This functor is used to instantiate a shared_ptr for xmlChar. More...
 
struct  textReaderDeleter
 This functor is used to instantiate a shared_ptr for the xmlTextReader. More...
 

Namespaces

 abigail
 Toplevel namespace for libabigail.
 
 abigail::sptr_utils
 Namespace for the utilities to wrap C types into std::shared_ptr.
 
 abigail::xml
 Internal namespace for xml manipulation utilities.
 

Macros

#define CHAR_STR(xml_char_str)
 
#define XML_NODE_GET_ATTRIBUTE(node, name)
 Get the value of attribute 'name' ont the instance of xmlNodePtr denoted by 'node'. More...
 
#define XML_READER_GET_ATTRIBUTE(reader, name)
 Get the value of attribute 'name' on the current node of 'reader' which is an instance of shared_ptr<xmlTextReader>. More...
 
#define XML_READER_GET_NODE_NAME(reader)
 Get the name of the current element node the reader is pointing to. Note that this macro returns an instance of shared_ptr<xmlChar> so that the caller doesn't have to worry about managing memory itself. Also note that the reader is a shared_ptr<xmlTextReader> More...
 
#define XML_READER_GET_NODE_TYPE(reader)
 Get the type of the current node of the shared_ptr<xmlTextReader> passed in argument. More...
 

Typedefs

typedef shared_ptr< xmlTextReader > reader_sptr
 A convenience typedef for a shared pointer of xmlTextReader. More...
 
typedef shared_ptr< xmlChar > xml_char_sptr
 A convenience typedef for a shared pointer of xmlChar. More...
 

Functions

template<>
shared_ptr< xmlChar > build_sptr< xmlChar > (xmlChar *p)
 Build and return a shared_ptr for a pointer to xmlChar. More...
 
template<>
xml::reader_sptr build_sptr< xmlTextReader > (xmlTextReader *p)
 Specialization of sptr_utils::build_sptr for xmlTextReader. More...
 
std::string escape_xml_comment (const std::string &str)
 Escape the '-' character, to avoid having a '–' in a comment. More...
 
void escape_xml_comment (const std::string &str, std::string &escaped)
 Escape the '-' character, to avoid having a '–' in a comment. More...
 
std::string escape_xml_string (const std::string &str)
 Escape the 5 characters representing the predefined XML entities. More...
 
void escape_xml_string (const std::string &str, std::string &escaped)
 Escape the 5 characters representing the predefined XML entities. More...
 
int get_xml_node_depth (xmlNodePtr n)
 Return the depth of an xml element node. More...
 
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 pointer and return it. More...
 
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 and return it. More...
 
reader_sptr new_reader_from_istream (std::istream *in)
 Instanciate an xmlTextReader that parses a content coming from an input stream. More...
 
std::string unescape_xml_comment (const std::string &str)
 Read a string, detect the '#&45;' entity and un-escape it into the '-' character. More...
 
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. More...
 
std::string unescape_xml_string (const std::string &str)
 Read a string, detect the 5 predefined XML entities it may contain and un-escape them, by writting their corresponding characters back in. The pre-defined entities are: More...
 
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, by writting their corresponding characters back in. The pre-defined entities are: More...
 
bool xml_char_sptr_to_string (xml_char_sptr ssptr, std::string &s)
 Convert a shared pointer to xmlChar into an std::string. More...
 

Macro Definition Documentation

◆ XML_NODE_GET_ATTRIBUTE

#define XML_NODE_GET_ATTRIBUTE (   node,
  name 
)

Get the value of attribute 'name' ont the instance of xmlNodePtr denoted by 'node'.

Definition at line 78 of file abg-libxml-utils.h.

◆ XML_READER_GET_ATTRIBUTE

#define XML_READER_GET_ATTRIBUTE (   reader,
  name 
)

Get the value of attribute 'name' on the current node of 'reader' which is an instance of shared_ptr<xmlTextReader>.

Definition at line 73 of file abg-libxml-utils.h.

◆ XML_READER_GET_NODE_NAME

#define XML_READER_GET_NODE_NAME (   reader)

Get the name of the current element node the reader is pointing to. Note that this macro returns an instance of shared_ptr<xmlChar> so that the caller doesn't have to worry about managing memory itself. Also note that the reader is a shared_ptr<xmlTextReader>

Definition at line 63 of file abg-libxml-utils.h.

◆ XML_READER_GET_NODE_TYPE

#define XML_READER_GET_NODE_TYPE (   reader)

Get the type of the current node of the shared_ptr<xmlTextReader> passed in argument.

Definition at line 68 of file abg-libxml-utils.h.