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

namespace  abigail
 Toplevel namespace for libabigail.
 
namespace  abigail::sptr_utils
 Namespace for the utilities to wrap C types into std::shared_ptr.
 
namespace  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<>
xml::xml_char_sptr build_sptr< xmlChar > (xmlChar *p)
 Specialization of build_str for 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...
 
void initialize ()
 The initialization function of libxml2 abstraction layer. This function must be called prior to using any of the libxml2 capabilities. 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

◆ CHAR_STR

#define CHAR_STR (   xml_char_str)

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

◆ 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 79 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 74 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 64 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 69 of file abg-libxml-utils.h.