<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=iso-8859-1"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";
        mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
span.E-MailFormatvorlage17
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri","sans-serif";
        mso-fareast-language:EN-US;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:70.85pt 70.85pt 2.0cm 70.85pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=DE link="#0563C1" vlink="#954F72"><div class=WordSection1><p class=MsoNormal>Hey,<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><span lang=EN-US>I want to implement file output for a rendering application and want to use C++ file streams using the following callback write function:<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'>    cairo_status_t cairo_write_func (<span style='color:blue'>void</span> *closure, <span style='color:blue'>const</span> <span style='color:blue'>unsigned</span> <span style='color:blue'>char</span> *data, <span style='color:blue'>unsigned</span> <span style='color:blue'>int</span> length)<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'>    {<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'>        <span style='color:blue'>try</span><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'>        {<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'>            <span style='color:blue'>const</span> std::string s(data, length);<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'>            fout << s;<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'>            fout.flush();<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'>        }<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'>        <span style='color:blue'>catch</span> (std::exception &e)<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'>        {<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'>            <span style='color:blue'>return</span> CAIRO_STATUS_WRITE_ERROR;<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.5pt;font-family:Consolas'>        </span><span style='font-size:9.5pt;font-family:Consolas'>}<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.5pt;font-family:Consolas'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.5pt;font-family:Consolas'>        <span style='color:blue'>return</span> CAIRO_STATUS_SUCCESS;<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.5pt;font-family:Consolas'>    }<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>I just can’t figure out what the closure is for.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>Can anyone explain the concept to me?<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>Is it comparable to variable capturing in C++11 closures?<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>Could I just pass nullptr as I do not use it anyway?<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>Thanks,<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;color:black;mso-fareast-language:DE'>--</span><span lang=EN-US style='font-size:10.0pt;color:black;mso-fareast-language:DE'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;color:black;mso-fareast-language:DE'>David Weiß</span><span lang=EN-US style='font-size:10.0pt;color:#E02129;mso-fareast-language:DE'> <o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;color:#E02129;mso-fareast-language:DE'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;color:#E02129;mso-fareast-language:DE'>PTV GROUP</span><span lang=EN-US style='font-size:10.0pt;color:black;mso-fareast-language:DE'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;color:black;mso-fareast-language:DE'>Logistics Software Development<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;color:black;mso-fareast-language:DE'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;color:black;mso-fareast-language:DE'>Haid-und-Neu-Str. 15, 76131 Karlsruhe, Germany<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;color:black;mso-fareast-language:DE'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;mso-fareast-language:DE'><a href="mailto:david.weiss@ptvgroup.com"><span style='color:windowtext;text-decoration:none'>david.weiss</span><span style='color:windowtext;text-decoration:none'>@ptvgroup.com</span></a></span><span style='font-size:10.0pt;mso-fareast-language:DE'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:10.0pt;mso-fareast-language:DE'><a href="http://www.ptvgroup.com/"><span lang=DE style='color:windowtext;text-decoration:none'>www.ptvgroup.com</span></a></span><span style='font-size:10.0pt;mso-fareast-language:DE'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;mso-fareast-language:DE'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;mso-fareast-language:DE'>http://ptv.to/facebook<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:7.0pt;color:black;mso-fareast-language:DE'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:7.0pt;color:black;mso-fareast-language:DE'>PTV Planung Transport Verkehr AG<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:7.0pt;color:black;mso-fareast-language:DE'>Headquarters: Karlsruhe<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:7.0pt;color:black;mso-fareast-language:DE'>Executive Board: Vincent Kobesen (CEO)<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:7.0pt;color:black;mso-fareast-language:DE'>Chairman of the Supervisory Board: Dr. h.c. Frank-Jürgen Weise<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:7.0pt;color:black;mso-fareast-language:DE'>Commercial Register (HRB-Nr): 109262<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:7.0pt;color:black;mso-fareast-language:DE'>Local Court: Mannheim</span><span lang=EN-US style='mso-fareast-language:DE'><o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p></div></body></html>