Well, I sent this earlier this week, but I guess it's stuck in the spam filter, so I'll send it again split up in several parts. First the full source, if this one arrives I'll reply with the patch. Ok, so I ended up creating 2 versions of this. The first one is what I mentioned earlier, pretty much a line-for-line translation of the original example. The c++-style casts made the (already ugly) lines with casts even uglier by the way... -------------- next part -------------- A non-text attachment was scrubbed... Name: main_ver1.cpp Type: text/x-c++src Size: 6065 bytes Desc: not available Url : http://lists.xiph.org/pipermail/flac-dev/attachments/20120915/fff4ee63/attachment.cpp
The patch... ----- Original Message ----- From: Bastiaan Timmer <basjetimmer at yahoo.com> To: "flac-dev at xiph.org" <flac-dev at xiph.org> Cc: Sent: Saturday, September 15, 2012 9:27 AM Subject: [flac-dev] New C++ file encode example Well, I sent this earlier this week, but I guess it's stuck in the spam filter, so I'll send it again split up in several parts. First the full source, if this one arrives I'll reply with the patch. Ok, so I ended up creating 2 versions of this. The first one is what I mentioned earlier, pretty much a line-for-line translation of the original example. The c++-style casts made the (already ugly) lines with casts even uglier by the way... _______________________________________________ flac-dev mailing list flac-dev at xiph.org http://lists.xiph.org/mailman/listinfo/flac-dev -------------- next part -------------- A non-text attachment was scrubbed... Name: encode_example_ver1.patch Type: application/octet-stream Size: 8459 bytes Desc: not available Url : http://lists.xiph.org/pipermail/flac-dev/attachments/20120915/b210f2a6/attachment.obj
Full source of the second version. The difference in the second version is that the metadata objects are no longer heap-allocated. This is more in line with the concept of RAII, and removes the need to keep setting and checking the 'ok' bool, which in the first version needs to be done from the moment the metadata[] is created. The only downside is that users following this example would need to remember to make sure the metadata objects are kept in scope for the duration of encoding. On the other hand, they no longer have to remember to delete all the objects at every point the program returns. -------------- next part -------------- A non-text attachment was scrubbed... Name: main_ver2.cpp Type: application/octet-stream Size: 5932 bytes Desc: not available Url : http://lists.xiph.org/pipermail/flac-dev/attachments/20120915/11909e4a/attachment-0001.obj
And a patch for the 2nd version. -------------- next part -------------- A non-text attachment was scrubbed... Name: encode_example_ver2.patch Type: application/octet-stream Size: 9258 bytes Desc: not available Url : http://lists.xiph.org/pipermail/flac-dev/attachments/20120915/e078b4bf/attachment.obj