13#include "abg-internal.h"
15ABG_BEGIN_EXPORT_DECLARATIONS
19ABG_END_EXPORT_DECLARATIONS
29shared_ptr<xmlTextReader>
67xz_io_match_cb(
const char*filepath)
69 bool does_match =
false;
83 std::unique_ptr<std::ifstream> input_fstream;
85 std::unique_ptr<xz_decompressor_type> decompressor_streambuf;
87 std::unique_ptr<std::istream> decompressed_input_stream;
89 xz_ctxt_type() =
delete;
94 xz_ctxt_type(std::ifstream* is)
97 decompressed_input_stream(
new istream(decompressor_streambuf.get()))
112xz_io_open_cb(
const char* filepath)
114 std::ifstream* s =
new std::ifstream(filepath, ifstream::binary);
121 xz_ctxt_type *ctxt =
new xz_ctxt_type(s);
140xz_io_read_cb(
void* context,
char *buffer,
int len)
142 xz_ctxt_type *ctxt =
static_cast<xz_ctxt_type *
>(context);
143 ctxt->decompressed_input_stream->read(buffer, len);
144 int nb_bytes_read = ctxt->decompressed_input_stream->gcount();
145 return nb_bytes_read;
157xz_io_close_cb(
void* context)
159 xz_ctxt_type *ctxt =
static_cast<xz_ctxt_type*
>(context);
160 ctxt->decompressed_input_stream.reset();
161 ctxt->input_fstream->close();
162 ctxt->input_fstream.reset();
176 xmlRegisterInputCallbacks(xz_io_match_cb, xz_io_open_cb,
177 xz_io_read_cb, xz_io_close_cb);
189 build_sptr(xmlNewTextReaderFilename (path.c_str()));
223xml_istream_input_read(
void* context,
227 istream* in =
reinterpret_cast<istream*
>(context);
228 in->read(buffer, len);
239xml_istream_input_close(
void*)
253 build_sptr(xmlReaderForIO(&xml_istream_input_read,
254 &xml_istream_input_close,
272 bool non_nil =
false;
299 if (n->type == XML_DOCUMENT_NODE || n->parent == NULL)
302 if (n->parent->type == XML_DOCUMENT_NODE)
324 std::string& escaped)
326 for (std::string::const_iterator i = str.begin(); i != str.end(); ++i)
382 std::string& escaped)
384 for (std::string::const_iterator i = str.begin(); i != str.end(); ++i)
425 std::string& escaped)
427 std::string::size_type i = 0;
428 while (i < str.size())
439 else if (str[i+1] ==
'g'
446 else if (str[i+1] ==
'a'
454 else if (str[i+1] ==
'a'
463 else if (str[i+1] ==
'q'
513 std::string& escaped)
515 std::string::size_type i = 0;
516 while (i < str.size())
522 && str[i + 4] ==
';')
shared_ptr< xmlChar > build_sptr< xmlChar >(xmlChar *p)
Build and return a shared_ptr for a pointer to xmlChar.
shared_ptr< T > build_sptr(T *p)
This is to be specialized for the diverse C types that needs wrapping in shared_ptr.
shared_ptr< xmlTextReader > build_sptr< xmlTextReader >(::xmlTextReader *p)
Build and return a shared_ptr for a pointer to xmlTextReader.
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.
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...
void initialize()
The initialization function of libxml2 abstraction layer. This function must be called prior to using...
int get_xml_node_depth(xmlNodePtr n)
Return the depth of an xml element node.
bool xml_char_sptr_to_string(xml_char_sptr ssptr, std::string &s)
Convert a shared pointer to xmlChar into an std::string.
void escape_xml_comment(const std::string &str, std::string &escaped)
Escape the '-' character, to avoid having a '–' in a comment.
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 poi...
shared_ptr< xmlChar > xml_char_sptr
A convenience typedef for a shared pointer of xmlChar.
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,...
reader_sptr new_reader_from_istream(std::istream *in)
Instanciate an xmlTextReader that parses a content coming from an input stream.
shared_ptr< xmlTextReader > reader_sptr
A convenience typedef for a shared pointer of xmlTextReader.
void escape_xml_string(const std::string &str, std::string &escaped)
Escape the 5 characters representing the predefined XML entities.
Toplevel namespace for libabigail.
This functor is used to instantiate a shared_ptr for xmlChar.
This functor is used to instantiate a shared_ptr for the xmlTextReader.