vil_nitf2_field_functor.cxx
Go to the documentation of this file.
1 // vil_nitf2: Written by Harry Voorhees (hlv@) and Rob Radtke (rob@) of
2 // Stellar Science Ltd. Co. (stellarscience.com) for
3 // Air Force Research Laboratory, 2005.
4 
7 #include "vil_nitf2_field.h"
9 
12  const vil_nitf2_index_vector& indexes, bool& result)
13 {
14  if (!record->find_field_definition(tag)) {
15  // Invalid tag
16  return false;
17  }
18  vil_nitf2_field* field = record->get_field(tag);
19  if (field != nullptr) {
20  std::string value;
21  bool is_string_value = record->get_value(tag, indexes, value, true);
22  if (is_string_value) {
23  // a blank std::string field actually yields a valid field value (an empty
24  // std::string) so test the value
25  result = !value.empty();
26  } else {
27  // other types of blank fields do not yield a field; since it
28  // was found, it must not be blank
29  result = false;
30  }
31  } else {
32  // field not found; therefore the data was blank
33  result = true;
34  }
35  return true;
36 }
37 
40  const vil_nitf2_index_vector& indexes, int& value)
41 {
42  int value1 = 0;
43  bool found = record->get_value(tag, indexes, value1, true);
44  value1 *= tag_factor;
45  value1 += offset;
46  value = (value1 < min_threshold) ? min_threshold : value1;
47  return found;
48 }
49 
52  const vil_nitf2_index_vector& indexes, int& value) {
53  int value1, value2;
54  bool found = record->get_value(tag_1, indexes, value1, true);
55  found &= record->get_value(tag_2, indexes, value2, true);
56  if (found) {
57  value = value1 * value2;
58  return true;
59  } else {
60  value = 0;
62  }
63 }
bool operator()(vil_nitf2_field_sequence *record, const vil_nitf2_index_vector &indexes, int &value) override
vil_nitf2_field_definition * find_field_definition(const std::string &tag)
vil_nitf2_field * get_field(const std::string &tag) const
bool operator()(vil_nitf2_field_sequence *record, const vil_nitf2_index_vector &indexes, int &value) override
bool operator()(vil_nitf2_field_sequence *record, const vil_nitf2_index_vector &indexes, bool &result) override
bool get_value(std::string tag, int &out_value) const
Functors used by NITF classes.