libabigail
Loading...
Searching...
No Matches
abigail::xml Namespace Reference

Internal namespace for xml manipulation utilities. More...

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...
class  xz_decompressor_type
 This is a custom std::streambuf that knows how to decompress an input stream that was compressed using xz. More...

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.

Enumerations

enum  file_type
 The different types of files understood the bi* suite of tools. More...

Functions

template<class T>
shared_ptr< T > build_sptr (T *p)
 This is to be specialized for the diverse C types that needs wrapping in shared_ptr.
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.
file_type guess_file_type (istream &in)
 Guess the type of the content of an input stream.
void initialize ()
 The initialization function of libxml2 abstraction layer. This function must be called prior to using any of the libxml2 capabilities.
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.

Detailed Description

Internal namespace for xml manipulation utilities.

Typedef Documentation

◆ reader_sptr

typedef shared_ptr<xmlTextReader> reader_sptr

A convenience typedef for a shared pointer of xmlTextReader.

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

◆ xml_char_sptr

typedef shared_ptr<xmlChar> xml_char_sptr

A convenience typedef for a shared pointer of xmlChar.

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

Enumeration Type Documentation

◆ file_type

enum file_type

The different types of files understood the bi* suite of tools.

Definition at line 218 of file abg-tools-utils.h.

Function Documentation

◆ build_sptr()

template<class T>
shared_ptr< T > build_sptr ( T * p)

This is to be specialized for the diverse C types that needs wrapping in shared_ptr.

Template Parameters
Tthe type of the C type to wrap in a shared_ptr.
Parameters
pa pointer to wrap in a shared_ptr.
Returns
then newly created shared_ptr<T>

◆ escape_xml_comment() [1/2]

std::string escape_xml_comment ( const std::string & str)

Escape the '-' character, to avoid having a '–' in a comment.

The resulting entity for '-' is '&#45;'.

/

Parameters
strthe input string to read to search for the characters / to escape. / /
Returns
the resulting string that contains the pre-defined / characters escaped as predefined entitites.

Definition at line 409 of file abg-libxml-utils.cc.

◆ escape_xml_comment() [2/2]

void escape_xml_comment ( const std::string & str,
std::string & escaped )

Escape the '-' character, to avoid having a '–' in a comment.

The resulting entity for '-' is '&#45;'.

/

Parameters
strthe input string to read to search for the characters / to escape. / /
escapedthe output string where to write the resulting / string that contains the pre-defined characters escaped as / predefined entitites.

Definition at line 385 of file abg-libxml-utils.cc.

◆ escape_xml_string() [1/2]

std::string escape_xml_string ( const std::string & str)

Escape the 5 characters representing the predefined XML entities.

The resulting entities and their matching characters are:

< for the character '<', > for the character '>', ' for the character ''', " for the character '"', and & for the character '&'.

/

Parameters
strthe input string to read to search for the characters / to escape. / /
Returns
the resulting string that contains the pre-defined / characters escaped as predefined entitites.

Definition at line 367 of file abg-libxml-utils.cc.

◆ escape_xml_string() [2/2]

void escape_xml_string ( const std::string & str,
std::string & escaped )

Escape the 5 characters representing the predefined XML entities.

The resulting entities and their matching characters are:

< for the character '<', > for the character '>', ' for the character ''', " for the character '"', and & for the character '&'.

/

Parameters
strthe input string to read to search for the characters / to escape. / /
escapedthe output string where to write the resulting / string that contains the pre-defined characters escaped as / predefined entitites.

Definition at line 327 of file abg-libxml-utils.cc.

◆ get_xml_node_depth()

int get_xml_node_depth ( xmlNodePtr n)

Return the depth of an xml element node.

Note that the node must be attached to an XML document.

Parameters
nthe xml to consider.
Returns
a positive or zero number for an XML node properly attached to an xml document, -1 otherwise. Note that the function returns -1 if passed an xml document as well.

Definition at line 301 of file abg-libxml-utils.cc.

◆ guess_file_type()

file_type guess_file_type ( istream & in)

Guess the type of the content of an input stream.

Parameters
inthe input stream to guess the content type for.
Returns
the type of content guessed.

Definition at line 1706 of file abg-tools-utils.cc.

◆ initialize()

void initialize ( )

The initialization function of libxml2 abstraction layer. This function must be called prior to using any of the libxml2 capabilities.

Definition at line 172 of file abg-libxml-utils.cc.

◆ new_reader_from_buffer()

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.

Parameters
bufferthe in-memory buffer to be parsed by the returned instance of xmlTextReader.

Definition at line 201 of file abg-libxml-utils.cc.

◆ new_reader_from_file()

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.

Parameters
paththe path to the file to be parsed by the returned instance of xmlTextReader.

Definition at line 186 of file abg-libxml-utils.cc.

◆ new_reader_from_istream()

reader_sptr new_reader_from_istream ( std::istream * in)

Instanciate an xmlTextReader that parses a content coming from an input stream.

Parameters
inthe input stream to consider.
Returns
reader_sptr a pointer to the newly instantiated xml reader.

Definition at line 252 of file abg-libxml-utils.cc.

◆ unescape_xml_comment() [1/2]

std::string unescape_xml_comment ( const std::string & str)

Read a string, detect the '#&45;' entity and un-escape it into the '-' character.

Parameters
strthe input XML string to consider.
Returns
escaped where to write the resulting un-escaped string.

Definition at line 546 of file abg-libxml-utils.cc.

◆ unescape_xml_comment() [2/2]

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.

Parameters
strthe input XML string to consider.
escapedwhere to write the resulting un-escaped string.

Definition at line 516 of file abg-libxml-utils.cc.

◆ unescape_xml_string() [1/2]

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:

< for the character '<', > for the character '>', ' for the character ''', " for the character '"', and & for the character '&'.

Parameters
strthe input XML string to consider.
Returns
escaped where to write the resulting un-escaped string.

Definition at line 502 of file abg-libxml-utils.cc.

◆ unescape_xml_string() [2/2]

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:

< for the character '<', > for the character '>', ' for the character ''', " for the character '"', and & for the character '&'.

Parameters
strthe input XML string to consider.
escapedwhere to write the resulting un-escaped string.

Definition at line 428 of file abg-libxml-utils.cc.

◆ xml_char_sptr_to_string()

bool xml_char_sptr_to_string ( xml_char_sptr & ssptr,
std::string & s )

Convert a shared pointer to xmlChar into an std::string.

If the xmlChar is NULL, set "" to the string.

Parameters
ssptrthe shared point to xmlChar to convert.
sthe output string.
Returns
true if the shared pointer to xmlChar contained a non NULL string, false otherwise.

Definition at line 274 of file abg-libxml-utils.cc.