What is the closure in stream output to file based surfaces for?

David Weiß <[email protected]>
Newsgroups gmane.comp.lib.cairo
Message-ID <E8D289FB71C3004B832D1702922D3A200313C1D704@SKA-WN-E25CEX.ptvag.ptv.de>
Hey,

I want to implement file output for a rendering application and want to use C++ file streams using the following callback write function:

    cairo_status_t cairo_write_func (void *closure, const unsigned char *data, unsigned int length)
    {
        try
        {
            const std::string s(data, length);
            fout << s;
            fout.flush();
        }
        catch (std::exception &e)
        {
            return CAIRO_STATUS_WRITE_ERROR;
        }

        return CAIRO_STATUS_SUCCESS;
    }

I just can't figure out what the closure is for.
Can anyone explain the concept to me?
Is it comparable to variable capturing in C++11 closures?
Could I just pass nullptr as I do not use it anyway?

Thanks,
--
David Weiß

PTV GROUP
Logistics Software Development

Haid-und-Neu-Str. 15, 76131 Karlsruhe, Germany

[email protected]<mailto:[email protected]>
www.ptvgroup.com<http://www.ptvgroup.com/>

http://ptv.to/facebook

PTV Planung Transport Verkehr AG
Headquarters: Karlsruhe
Executive Board: Vincent Kobesen (CEO)
Chairman of the Supervisory Board: Dr. h.c. Frank-Jürgen Weise
Commercial Register (HRB-Nr): 109262
Local Court: Mannheim

-- 
cairo mailing list
[email protected]
http://lists.cairographics.org/mailman/listinfo/cairo
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.