SetField15C - mdaus/nitro GitHub Wiki
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
When you are manipulating TREs, you should use the nitf_TRE_setValue function to set a field's value. It works for 1.5 to retrieve a field from the hash, but the setValue() model from you. Future versions will expect that TREs fields are set using only TRE API functions:
/* construct a tre */
tre = nitf_TRE_construct("JITCID", NULL, NITF_TRE_DEFAULT_LENGTH, &error);
if (!tre)
{
nitf_Error_print(&error, stdout, "Exiting...");
exit(EXIT_FAILURE);
}
...
exists = nitf_TRE_setValue(tre, "FILCMT", "fyi", 3, &error);
tre = nitf_TRE_construct("JITCID", NULL, NITF_TRE_DEFAULT_LENGTH, &error);
if (!tre)
{
nitf_Error_print(&error, stdout, "Exiting...");
exit(EXIT_FAILURE);
}
...
exists = nitf_TRE_setValue(tre, "FILCMT", "fyi", 3, &error);