[flac-dev] New C++ file encode example

Bastiaan Timmer basjetimmer at yahoo.com
Wed Sep 12 13:05:18 PDT 2012


Ok, so I ended up creating 2 versions of this, I hope the attachments aren't too big.

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...

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.

Bas
-------------- 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/20120912/6f94ce1c/attachment-0004.obj 
-------------- 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/20120912/6f94ce1c/attachment-0005.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: main_ver1.cpp
Type: application/octet-stream
Size: 6065 bytes
Desc: not available
Url : http://lists.xiph.org/pipermail/flac-dev/attachments/20120912/6f94ce1c/attachment-0006.obj 
-------------- 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/20120912/6f94ce1c/attachment-0007.obj 


More information about the flac-dev mailing list