-
Notifications
You must be signed in to change notification settings - Fork 38
SetField20C
anna-dodd edited this page Jun 3, 2015
·
1 revision
Warning: This snippet is subject to change as the 2.0 API has not been finalized
You can set a field as raw data, or as a specialized type.
Raw Data
Set as integer
Set as real
Setting a Field in a TRE (differs from 1.5)
When you are manipulating TREs, you must use the nitf_TRE_setField function to set a field's value. The setField function makes a call to the appropriate
TRE interface handler for this TRE.
You can set a field as raw data, or as a specialized type.
Raw Data
nitf_Int32 int32 = 16801;
/* Setting the BCS-A file header as raw data */
/* If the size is greater than the field width, truncation occurs */
nitf_Field_setRawData(fhdr, "NITF", 4, &error);
/* Setting a BCS-BINARY field with size 4 */
nitf_Field_setRawData(ubin, &int32, 4, &error);
/* Setting the BCS-A file header as raw data */
/* If the size is greater than the field width, truncation occurs */
nitf_Field_setRawData(fhdr, "NITF", 4, &error);
/* Setting a BCS-BINARY field with size 4 */
nitf_Field_setRawData(ubin, &int32, 4, &error);
Set as integer
/* Int field is BCS-N, and will pad with zeroes on the left to the total width */
/* If it was BCS-A, it would pad with empty spaces on the right */
nitf_Field_setInt32(intField, 142, &error);
/* If it was BCS-A, it would pad with empty spaces on the right */
nitf_Field_setInt32(intField, 142, &error);
Set as real
/* realField is BCS-A or BCS-N */
nitf_Field_setReal(realField, "f", 1, 142.56, &error);
nitf_Field_setReal(realField, "f", 1, 142.56, &error);
Setting a Field in a TRE (differs from 1.5)
When you are manipulating TREs, you must use the nitf_TRE_setField function to set a field's value. The setField function makes a call to the appropriate
TRE interface handler for this TRE.
/* construct a tre */
tre = nitf_TRE_construct("JITCID", "JITCID", NITF_TRE_DEFAULT_LENGTH, &error);
if (!tre)
{
nitf_Error_print(&error, stdout, "Exiting...");
exit(EXIT_FAILURE);
}
...
exists = nitf_TRE_setField(tre, "FILCMT", "fyi", 3, &error);
tre = nitf_TRE_construct("JITCID", "JITCID", NITF_TRE_DEFAULT_LENGTH, &error);
if (!tre)
{
nitf_Error_print(&error, stdout, "Exiting...");
exit(EXIT_FAILURE);
}
...
exists = nitf_TRE_setField(tre, "FILCMT", "fyi", 3, &error);