13 #include "abg-internal.h"
15 ABG_BEGIN_EXPORT_DECLARATIONS
29 shared_ptr<xmlTextReader>
67 xz_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)
96 decompressor_streambuf(
new xz_decompressor_type(*is)),
97 decompressed_input_stream(
new istream(decompressor_streambuf.get()))
112 xz_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);
140 xz_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;
157 xz_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()));
223 xml_istream_input_read(
void* context,
227 istream* in =
reinterpret_cast<istream*
>(context);
228 in->read(buffer, len);
239 xml_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< T > build_sptr(T *p)
This is to be specialized for the diverse C types that needs wrapping in shared_ptr.
reader_sptr new_reader_from_istream(std::istream *in)
Instanciate an xmlTextReader that parses a content coming from an input stream.
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. ...
shared_ptr< xmlChar > xml_char_sptr
A convenience typedef for a shared pointer of xmlChar.
bool xml_char_sptr_to_string(xml_char_sptr &ssptr, std::string &s)
Convert a shared pointer to xmlChar into an std::string.
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< xmlTextReader > build_sptr< xmlTextReader >(::xmlTextReader *p)
Build and return a shared_ptr for a pointer to xmlTextReader.
shared_ptr< xmlChar > build_sptr< xmlChar >(xmlChar *p)
Build and return a shared_ptr for a pointer to xmlChar.
shared_ptr< xmlTextReader > reader_sptr
A convenience typedef for a shared pointer of xmlTextReader.
This functor is used to instantiate a shared_ptr for the xmlTextReader.
Toplevel namespace for libabigail.
void escape_xml_comment(const std::string &str, std::string &escaped)
Escape the '-' character, to avoid having a '–' in a comment.
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:
void initialize()
The initialization function of libxml2 abstraction layer. This function must be called prior to using...
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_file(const std::string &path)
Instantiate an xmlTextReader that parses the content of an on-disk file, wrap it into a smart pointer...
This functor is used to instantiate a shared_ptr for xmlChar.