vil_nitf2_scalar_field.h
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 
5 #ifndef VIL_NITF2_SCALAR_FIELD_H
6 #define VIL_NITF2_SCALAR_FIELD_H
7 
8 #include "vil_nitf2_field.h"
9 
12 
13 // An abstract class that represents a scalar field, i.e., one that
14 // is not within a repeat loop. Subclasses store the type-specific
15 // value.
16 
18 {
19  public:
21  : vil_nitf2_field(definition) {}
22 
23  ~vil_nitf2_scalar_field() override = default;
24 
25  int num_dimensions() const override { return 0; }
26 
27  // Sets output argument to the value of field. Subclasses overload the
28  // appropriate method to set out parameter and return true. These methods
29  // are defined here for the convenience of my callers, so they don't
30  // have to downcast to the specific field type.
31 #if VXL_HAS_INT_64
32  virtual bool value(vil_nitf2_long&) const { return false; }
33 #endif
34  virtual bool value(int&) const { return false; }
35  virtual bool value(double&) const { return false; }
36  virtual bool value(char&) const { return false; }
37  virtual bool value(void*&) const { return false; }
38  virtual bool value(std::string&) const { return false; }
39  virtual bool value(vil_nitf2_location*&) const { return false; }
40  virtual bool value(vil_nitf2_date_time&) const { return false; }
41  virtual bool value(vil_nitf2_tagged_record_sequence&) const { return false; }
42 
43  // Attempts to read a scalar field from input stream, using specified
44  // definition. Returns field if successfully created. May set arg
45  // error to true even if field is returned; for example, if it's a
46  // required (non-blank) field that is all blank. If variable_width
47  // is non-negative, it overrides the formatter's field width.
49  vil_nitf2_field_definition* definition,
50  int variable_width = -1,
51  bool* error = nullptr);
52 
53  field_tree* get_tree() const override;
54 
55  // Write to NITF stream. Arg variable_width, if non-negative, overrides
56  // formatter's field_width.
57  bool write(vil_nitf2_ostream& output, int variable_width = -1) const;
58 };
59 
60 #endif // VIL_NITF2_SCALAR_FIELD_H
vil_nitf2_scalar_field(vil_nitf2_field_definition *definition)
vxl_int_32 vil_nitf2_long
Definition: vil_nitf2.h:26
virtual bool value(void *&) const
int num_dimensions() const override
bool write(vil_nitf2_ostream &output, int variable_width=-1) const
virtual bool value(int &) const
Stream interface for VIL image loaders.
Definition: vil_stream.h:21
virtual bool value(std::string &) const
~vil_nitf2_scalar_field() override=default
field_tree * get_tree() const override
virtual bool value(vil_nitf2_tagged_record_sequence &) const
virtual bool value(vil_nitf2_date_time &) const
virtual bool value(vil_nitf2_location *&) const
virtual bool value(char &) const
virtual std::ostream & output(std::ostream &os) const =0
virtual bool value(double &) const
static vil_nitf2_scalar_field * read(vil_nitf2_istream &input, vil_nitf2_field_definition *definition, int variable_width=-1, bool *error=nullptr)