-
Notifications
You must be signed in to change notification settings - Fork 38
IterExtensions15C
anna-dodd edited this page Jun 3, 2015
·
1 revision
Removing a TRE without using an iterator:
Walking through an Extensions segment and removing (and re-inserting a TRE)
if ( nitf_Extensions_exists( ext, TRE_NAME ) )
{
nitf_Extensions_removeTREsByName(ext, TRE_NAME);
}
{
nitf_Extensions_removeTREsByName(ext, TRE_NAME);
}
Walking through an Extensions segment and removing (and re-inserting a TRE)
extIter = nitf_Extensions_begin(ext);
endIter = nitf_Extensions_end(ext);
while (nitf_ExtensionsIterator_notEqualTo(&extIter, &endIter) )
{
nitf_TRE* tre = nitf_ExtensionsIterator_get(&extIter);
if ( strcmp( tre->tag, TRE_NAME) == 0 )
{
if ( (tre = nitf_Extensions_remove(ext, &extIter, &lerror)) == NULL)
{
nitf_Error_print(&lerror, stdout, "Couldnt blow away %s!\n", tre->tag);
goto CATCH_ERROR;
}
if (! nitf_Extensions_insert(ext, &extIter, tre, &lerror) )
{
nitf_Error_print(&lerror, stdout, "Couldnt insert %s\n", tre->tag);
goto CATCH_ERROR;
}
}
nitf_ExtensionsIterator_increment(&extIter);
}
endIter = nitf_Extensions_end(ext);
while (nitf_ExtensionsIterator_notEqualTo(&extIter, &endIter) )
{
nitf_TRE* tre = nitf_ExtensionsIterator_get(&extIter);
if ( strcmp( tre->tag, TRE_NAME) == 0 )
{
if ( (tre = nitf_Extensions_remove(ext, &extIter, &lerror)) == NULL)
{
nitf_Error_print(&lerror, stdout, "Couldnt blow away %s!\n", tre->tag);
goto CATCH_ERROR;
}
if (! nitf_Extensions_insert(ext, &extIter, tre, &lerror) )
{
nitf_Error_print(&lerror, stdout, "Couldnt insert %s\n", tre->tag);
goto CATCH_ERROR;
}
}
nitf_ExtensionsIterator_increment(&extIter);
}