Re: [xml] export xmlTextReaderSetup() function



  Can you write an example showing the use then, I'm a bit lost I admit :-)

Sure :) This is pretty long one but ....

xmlTextReaderPtr XmlReaderContext::CreateTextReader(
        xmlParserInputBufferPtr input_buffer,
        const string& uri)
{
    assert(input_buffer);

    xmlParserInputBufferPtr input_buffer2 = input_buffer;
    if(HasEncryptKey()) {
        assert(!m_base64_input_buffer.get());
        assert(!m_encrypt_input_buffer.get());

        // insert base64 input buffer
m_base64_input_buffer.reset(new Base64DecodeInputBuffer(input_buffer2));
        assert(m_base64_input_buffer.get());

        input_buffer2 = xmlParserInputBufferCreateIO(
                                XmlInputReadFromBase64EncodeCallback,
                                XmlInputCloseBase64EncodeCallback,
                                m_base64_input_buffer.get(),
                                XML_CHAR_ENCODING_NONE);

        if (input_buffer2 == NULL) {
C8LOG_THROW(this, LogError, "Failed to create base64 decoder input buffer.") {
                XmlErrorReport(c8log, xmlGetLastError());
            }
        }
        m_input_buffers.push_back(input_buffer2);

        // insert encrypt input buffer
m_encrypt_input_buffer.reset(new EncryptInputBuffer(input_buffer2, GetEncryptKey()));
        assert(m_encrypt_input_buffer.get());

        input_buffer2 = xmlParserInputBufferCreateIO(
                                XmlInputReadFromEncryptCallback,
                                XmlInputCloseEncryptCallback,
                                m_encrypt_input_buffer.get(),
                                XML_CHAR_ENCODING_NONE);

        if (input_buffer2 == NULL) {
C8LOG_THROW(this, LogError, "Failed to create encrypt decoder input buffer.") {
                XmlErrorReport(c8log, xmlGetLastError());
            }
        }
        m_input_buffers.push_back(input_buffer2);
    }

    xmlTextReaderPtr reader = xmlNewTextReader(input_buffer2, uri.c_str());
    if (reader == NULL) {
        return NULL;
    }

    int options = (m_report_warnings ? 0:XML_PARSE_NOWARNING) |
              XML_PARSE_NOENT |
              XML_PARSE_PEDANTIC |
              XML_PARSE_NOCDATA;

    xmlTextReaderSetup(reader, NULL, uri.c_str(), NULL, options);

    return reader;
}

  Yes except that CVs was replaced with SVN (Subversion) and I didn't
yet tried to look how to hook in the new infrastructure. I think there are
pages on gnome.org about it to babystep the process

Oh...


Aleksey




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]