7 #ifndef VIL_NITF2_TYPED_ARRAY_FIELD_H 8 #define VIL_NITF2_TYPED_ARRAY_FIELD_H 13 # include <vcl_msvc_warnings.h> 48 int variable_width)
override;
56 int variable_width)
const override;
60 std::ostream&
output(std::ostream& os)
const override;
70 bool& output_yet)
const;
95 if ((
int)indexes.size() != m_num_dimensions) {
96 std::cerr <<
"vil_nitf2_typed_array_field index vector wrong length\n";
99 typename std::map<vil_nitf2_index_vector, T>::const_iterator element = m_value_map.find(indexes);
100 if (element != m_value_map.end()) {
101 out_value = element->second;
112 VIL_NITF2_LOG(log_debug) <<
"Reading " << tag() << indexes <<
": ";
114 if (!check_index(indexes)) {
122 int saved_field_width = typed_formatter->
field_width;
123 if (variable_width > 0) {
127 bool value_read = typed_formatter->
read(input, val, is_blank);
131 m_value_map[indexes] = val;
133 else if (is_blank && !m_definition->blanks_ok) {
134 VIL_NITF2_LOG(log_debug) <<
"not specified, but required!" << std::endl;
149 int variable_width)
const 151 VIL_NITF2_LOG(log_debug) <<
"Writing tag " << tag() << indexes <<
' ';
152 if (!check_index(indexes)) {
160 if (variable_width > 0) typed_formatter->
field_width = variable_width;
161 bool value_defined = value(indexes, val);
164 return typed_formatter->
write(output, val);
167 if (!m_definition->blanks_ok) {
168 VIL_NITF2_LOG(log_debug) <<
": required value undefined at this index; writing blanks." << std::endl;
177 bool output_yet =
false;
186 if ((
int)indexes.size()==m_num_dimensions) {
188 if (value(indexes, val)) {
197 os << indexes <<
' ' << val;
201 int dim = next_dimension(indexes);
202 for (
int i=0; i < dim; ++i) {
204 next_indexes.push_back(i);
205 output_dimension_iterate(os, next_indexes, output_yet);
222 for (
auto & it : m_value_map)
225 delete[] (
char*) it.second;
233 for (
auto & it : m_value_map)
246 #endif // VIL_NITF2_TYPED_ARRAY_FIELD_H
bool write_vector_element(vil_nitf2_ostream &output, const vil_nitf2_index_vector &indexes, int variable_width) const override
Writes to output stream the scalar value at specified index.
void output_dimension_iterate(std::ostream &os, vil_nitf2_index_vector indexes, bool &output_yet) const
std::ostream & operator<<(std::ostream &os, const vil_nitf2_typed_array_field< T > &field)
bool read_vector_element(vil_nitf2_istream &input, const vil_nitf2_index_vector &indexes, int variable_width) override
Reads from input stream the scalar value at specified index.
#define VIL_NITF2_LOG(LEVEL)
vil_nitf2_typed_array_field(int num_dimensions, vil_nitf2_field_definition *field_definition)
vil_nitf2: Written by Harry Voorhees (hlv@) and Rob Radtke (rob@) of Stellar Science Ltd.
Stream interface for VIL image loaders.
~vil_nitf2_typed_array_field() override
Destructor (overridden below for instantiations where T is a pointer).
Typed concrete class for array fields.
std::ostream & output(std::ostream &os) const override
Output in human-readable form.
std::map< vil_nitf2_index_vector, T > m_value_map
bool value(const vil_nitf2_index_vector &indexes, T &out_value) const override
Set out_value to the scalar value at the specified index vector, and returns whether specified elemen...
Abstract class for array fields, i.e., fields that occur within a repeat loop.
int num_dimensions() const override
Number of dimensions.