Skip to content

IterTres20C

anna-dodd edited this page Jun 3, 2015 · 2 revisions
This API is subject to change

Iterating Tagged Record Extension (2.0)


Though the model is still accessible using the HashTable functions, the only recommended traversal mechanism is to use the TREEnumerators. These provide the data fields back in order for legacy TREs, the same as the cursor does in our 1.5 example. In fact it uses the cursor underneath, but it hides that from you. This allows us to handle non-linear data such as XML where the ordering is not preserved in the hash model, but in the user data for that TRE. The bottom line: use the TREEnumerator, that's what its there for.

nitf_TREEnumerator* it;
                               
for (it = nitf_TRE_begin(tre, error); it != NULL; it->next(&it, error) )
{
    nitf_Pair* fieldPair;
    fieldPair = it->get(it, error);
    printf("%s = [", fieldPair->key);
    nitf_Field_print((nitf_Field *) fieldPair->data);
    printf("]\n");
}