2 * this file is part of libxml++
4 * copyright (C) 2003 by libxml++ developer's team
6 * this file is covered by the GNU Lesser General Public License,
7 * which should be included with libxml++ as the file COPYING.
10 #include <libxml++/io/parserinputbuffer.h>
11 #include <libxml++/exceptions/internal_error.h>
13 #include <libxml/globals.h> //Needed by libxml/xmlIO.h
14 #include <libxml/xmlIO.h>
19 struct ParserInputBufferCallback
21 static int on_read(void * context, char * buffer, int len)
23 ParserInputBuffer * tmp = static_cast<ParserInputBuffer*>(context);
24 return tmp->do_read(buffer, len);
27 static int on_close(void * context)
29 ParserInputBuffer * tmp = static_cast<ParserInputBuffer*>(context);
30 return tmp->do_close();
35 ParserInputBuffer::ParserInputBuffer()
37 impl_ = xmlParserInputBufferCreateIO(
38 &ParserInputBufferCallback::on_read,
39 &ParserInputBufferCallback::on_close,
40 static_cast<void*>(this),
41 XML_CHAR_ENCODING_NONE);
44 throw internal_error("Cannot initialise underlying xmlParserInputBuffer");
48 ParserInputBuffer::~ParserInputBuffer()
52 bool ParserInputBuffer::on_close()
54 bool result = do_close();
55 // the underlying structure is being freed by libxml, the pointer will soon be
62 int ParserInputBuffer::on_read(
66 return do_read(buffer, len);
69 bool ParserInputBuffer::do_close()
74 _xmlParserInputBuffer* ParserInputBuffer::cobj()
79 const _xmlParserInputBuffer* ParserInputBuffer::cobj() const