libabigail
Classes | Typedefs | Functions
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...
 

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

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...
 

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.

Function Documentation

◆ 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 272 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 248 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 230 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 190 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 164 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 67 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 53 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 117 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 409 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 379 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 365 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 291 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 137 of file abg-libxml-utils.cc.