vil_nitf2_compound_field_value.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_COMPOUND_FIELD_VALUE_H
6 #define VIL_NITF2_COMPOUND_FIELD_VALUE_H
7 
8 #include <iostream>
9 #include <string>
10 #include <istream>
11 #include <ostream>
12 #ifdef _MSC_VER
13 # include <vcl_msvc_warnings.h>
14 #endif
15 
16 //-----------------------------------------------------------------------------
17 // NITF compound field types
18 //
19 // NITF fields can represent built-in types like integer or std::string, and
20 // compound types like date_time. Subclasses of vil_nitf2_compound_field_value, along with
21 // built-in types, represent all the types of values that are passed back to
22 // clients. These types implement operator << (ostream&) to output themselves
23 // in human-readable form. Some compound fields keep track of their precision.
24 // By contrast, NITF file i/o is handled by corresponding Formatter classes,
25 // which clients should not need to know about.
26 
27 // Base class for NITF compound field types.
28 // Each class is expected to define operator << which should call output().
29 //
31 {
32 public:
33  // To be called by operator << to pretty-print field to stream
34  virtual std::ostream& output(std::ostream&) const = 0;
35 
36  // Returns true iff all members lie within their expected ranges
37  virtual bool is_valid() const = 0;
38 
39  virtual ~vil_nitf2_compound_field_value() = default;
40 };
41 
42 // A date and time, down to the second or decimal fraction thereof.
43 //
45 {
47 public:
48  int year;
49  int month; // 1-12
50  int day; // 1-31
51  int hour; // 0-23
52  int minute; // 0-59
53  double second; // 0-59.999...
54  int sec_precision; // second's significant decimal places
55  vil_nitf2_date_time() : year(0), month(0), day(0), hour(0), minute(0), second(0), sec_precision(0) {}
56  vil_nitf2_date_time(std::string format);
57  ~vil_nitf2_date_time() override = default;
58  bool is_valid() const override;
59  bool read(std::istream& input, int field_width, bool& out_blank);
60  bool write(std::ostream& output, int field_width) const;
61  std::ostream& output(std::ostream& os) const override;
62 };
63 
64 std::ostream& operator << (std::ostream& os, const vil_nitf2_date_time& dateTime);
65 
66 // Base class for geodetic location field type
67 
69 {
71 public:
75  ~vil_nitf2_location() override = default;
76  virtual bool read(std::istream& input, int field_width, bool& out_blank) = 0;
77  virtual bool write(std::ostream& output, int field_width) = 0;
78 };
79 
80 // Geodetic location represented as a pair of signed degrees, with a
81 // specified precision.
82 
84 {
85 public:
88  bool read(std::istream& input, int field_width, bool& out_blank) override;
89  bool write(std::ostream& output, int field_width) override;
90  double lat_degrees;
91  double lon_degrees;
92  int precision;
93  std::ostream& output(std::ostream&) const override;
94  bool is_valid() const override;
95 };
96 
97 std::ostream& operator << (std::ostream& os, const vil_nitf2_location& loc);
98 
99 // Geodetic location represented as unsigned degrees, minutes, seconds, and
100 // hemisphere, to a specified precision. (Currently this class assumes that
101 // the coarsest precision is integer seconds, although that restriction
102 // could easily be lifted.)
103 
105 {
106 public:
109  bool read(std::istream& input, int field_width, bool& out_blank) override;
110  bool write(std::ostream& output, int field_width) override;
113  int sec_precision; // second's significant decimal places
114  std::ostream& output(std::ostream&) const override;
115  bool is_valid() const override;
116 };
117 
118 std::ostream& operator << (std::ostream& os, const vil_nitf2_location_dmsh& loc);
119 
120 #endif // VIL_NITF2_COMPOUND_FIELD_VALUE_H
virtual ~vil_nitf2_compound_field_value()=default
~vil_nitf2_date_time() override=default
bool read(std::istream &input, int field_width, bool &out_blank) override
~vil_nitf2_location() override=default
bool write(std::ostream &output, int field_width) const
bool read(std::istream &input, int field_width, bool &out_blank)
vil_nitf2_location(format_type format)
virtual std::ostream & output(std::ostream &) const =0
virtual bool is_valid() const =0
bool read(std::istream &input, int field_width, bool &out_blank) override
virtual bool write(std::ostream &output, int field_width)=0
virtual bool read(std::istream &input, int field_width, bool &out_blank)=0
bool write(std::ostream &output, int field_width) override
bool write(std::ostream &output, int field_width) override
std::ostream & output(std::ostream &) const override
std::ostream & operator<<(std::ostream &os, const vil_nitf2_date_time &dateTime)
std::ostream & output(std::ostream &os) const override
std::ostream & output(std::ostream &) const override