libabigail
Loading...
Searching...
No Matches
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'.
 
#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>.
 
#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>
 
#define XML_READER_GET_NODE_TYPE(reader)
 Get the type of the current node of the shared_ptr<xmlTextReader> passed in argument.
 

Typedefs

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

Functions

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

Macro Definition Documentation

◆ CHAR_STR

#define CHAR_STR ( xml_char_str)

Definition at line 81 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 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.