cannam@86: The flow through the iterator in the C++ layer is similar to the C layer:
cannam@86:
Create a Chain instance
Check Chain::is_valid()
Call Chain::read() and check the return
Traverse and/or edit with an Iterator or with Chain::merge_padding() or Chain::sort_padding()
Write changes back to FLAC file with Chain::write()
Destroy the Chain instance
cannam@86:
cannam@86: The ownership of pointers in the C++ layer is slightly different than in the C layer, i.e.
cannam@86:
The objects returned by Iterator::get_block() are NOT owned by the iterator and should be deleted by the caller when finished, BUT, when you modify the block, it will directly edit what's in the chain and you do not need to call Iterator::set_block(). However the changes will not be reflected in the FLAC file until the chain is written with Chain::write().
When you pass an object to Iterator::set_block(), Iterator::insert_block_before(), or Iterator::insert_block_after(), the iterator takes ownership of the block and it will be deleted by the chain.