00001
00002
00003
00004
00005 #ifndef VIL_NITF2_FIELD_SEQUENCE_H
00006 #define VIL_NITF2_FIELD_SEQUENCE_H
00007
00008 #include <vcl_map.h>
00009
00010 #include <vcl_string.h>
00011 #include <vcl_vector.h>
00012
00013 #include "vil_nitf2.h"
00014 #include "vil_nitf2_index_vector.h"
00015 #include "vil_nitf2_field.h"
00016
00017 class vil_nitf2_field_definition;
00018 class vil_nitf2_field_definitions;
00019 class vil_nitf2_location;
00020 class vil_nitf2_date_time;
00021 class vil_nitf2_tagged_record_sequence;
00022
00023
00024
00025
00026
00027 class vil_nitf2_field_sequence
00028 {
00029 public:
00030
00031 vil_nitf2_field_sequence(const vil_nitf2_field_definitions& field_definitions)
00032 : m_field_definitions(&field_definitions) {}
00033
00034
00035 virtual ~vil_nitf2_field_sequence();
00036
00037
00038
00039 bool get_value(vcl_string tag, int& out_value) const;
00040 bool get_value(vcl_string tag, double& out_value) const;
00041 bool get_value(vcl_string tag, char& out_value) const;
00042 bool get_value(vcl_string tag, void*& out_value) const;
00043 bool get_value(vcl_string tag, vcl_string& out_value) const;
00044 bool get_value(vcl_string tag, vil_nitf2_location*& out_value) const;
00045 bool get_value(vcl_string tag, vil_nitf2_date_time& out_value) const;
00046 bool get_value(vcl_string tag, vil_nitf2_tagged_record_sequence& out_value) const;
00047 #if VXL_HAS_INT_64
00048 bool get_value(vcl_string tag, vil_nitf2_long& out_value) const;
00049 #endif
00050
00051
00052
00053
00054
00055
00056
00057 bool get_value(vcl_string tag, const vil_nitf2_index_vector& indexes,
00058 int& out_value, bool ignore_extra_indexes = false) const;
00059 bool get_value(vcl_string tag, const vil_nitf2_index_vector& indexes,
00060 double& out_value, bool ignore_extra_indexes = false) const;
00061 bool get_value(vcl_string tag, const vil_nitf2_index_vector& indexes,
00062 char& out_value, bool ignore_extra_indexes = false) const;
00063 bool get_value(vcl_string tag, const vil_nitf2_index_vector& indexes,
00064 void*& out_value, bool ignore_extra_indexes = false) const;
00065 bool get_value(vcl_string tag, const vil_nitf2_index_vector& indexes,
00066 vcl_string& out_value, bool ignore_extra_indexes = false) const;
00067 bool get_value(vcl_string tag, const vil_nitf2_index_vector& indexes,
00068 vil_nitf2_location*& out_value, bool ignore_extra_indexes = false) const;
00069 bool get_value(vcl_string tag, const vil_nitf2_index_vector& indexes,
00070 vil_nitf2_date_time& out_value, bool ignore_extra_indexes = false) const;
00071 #if VXL_HAS_INT_64
00072 bool get_value(vcl_string tag, const vil_nitf2_index_vector& indexes,
00073 vil_nitf2_long& out_value, bool ignore_extra_indexes = false) const;
00074 #endif
00075
00076
00077
00078
00079
00080
00081
00082 bool get_values(vcl_string tag, const vil_nitf2_index_vector& indexes,
00083 vcl_vector<int>& out_values, bool clear_out_values = true) const;
00084 bool get_values(vcl_string tag, const vil_nitf2_index_vector& indexes,
00085 vcl_vector<double>& out_values, bool clear_out_values = true) const;
00086 bool get_values(vcl_string tag, const vil_nitf2_index_vector& indexes,
00087 vcl_vector<char>& out_values, bool clear_out_values = true) const;
00088 bool get_values(vcl_string tag, const vil_nitf2_index_vector& indexes,
00089 vcl_vector<void*>& out_values, bool clear_out_values = true) const;
00090 bool get_values(vcl_string tag, const vil_nitf2_index_vector& indexes,
00091 vcl_vector<vcl_string>& out_values, bool clear_out_values = true) const;
00092 bool get_values(vcl_string tag, const vil_nitf2_index_vector& indexes,
00093 vcl_vector<vil_nitf2_location*>& out_values, bool clear_out_values = true) const;
00094 bool get_values(vcl_string tag, const vil_nitf2_index_vector& indexes,
00095 vcl_vector<vil_nitf2_date_time>& out_values, bool clear_out_values = true) const;
00096 #if VXL_HAS_INT_64
00097 bool get_values(vcl_string tag, const vil_nitf2_index_vector& indexes,
00098 vcl_vector<vil_nitf2_long>& out_values, bool clear_out_values = true) const;
00099 #endif
00100
00101
00102
00103 bool get_values(vcl_string tag, vcl_vector<int>& out_values) const;
00104 bool get_values(vcl_string tag, vcl_vector<double>& out_values) const;
00105 bool get_values(vcl_string tag, vcl_vector<char>& out_values) const;
00106 bool get_values(vcl_string tag, vcl_vector<void*>& out_values) const;
00107 bool get_values(vcl_string tag, vcl_vector<vcl_string>& out_values) const;
00108 bool get_values(vcl_string tag, vcl_vector<vil_nitf2_location*>& out_values) const;
00109 bool get_values(vcl_string tag, vcl_vector<vil_nitf2_date_time>& out_values) const;
00110 #if VXL_HAS_INT_64
00111 bool get_values(vcl_string tag, vcl_vector<vil_nitf2_long>& out_values) const;
00112 #endif
00113
00114 #if 0 //Not yet implemented.
00115
00116 bool set_value(vcl_string tag, int value) { return false; }
00117 #endif // 0
00118
00119
00120 vil_nitf2_field* get_field(vcl_string tag) const;
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130 bool read(vil_nitf2_istream& input,
00131 const vil_nitf2_field_definitions* field_defs = 0,
00132 vil_nitf2_index_vector indexes = vil_nitf2_index_vector());
00133
00134
00135
00136 virtual bool write(vil_nitf2_ostream&,
00137 const vil_nitf2_field_definitions* field_defs = 0,
00138 vil_nitf2_index_vector indexes = vil_nitf2_index_vector());
00139
00140
00141
00142 bool create_array_fields(const vil_nitf2_field_definitions* field_defs,
00143 int num_dimensions);
00144
00145
00146 void set_array_fields_dimension(const vil_nitf2_field_definitions* field_defs,
00147 const vil_nitf2_index_vector& index, int repeat_count);
00148
00149
00150 vil_nitf2_field_definition* find_field_definition(vcl_string tag);
00151
00152
00153
00154
00155 virtual vil_nitf2_field::field_tree* get_tree( vil_nitf2_field::field_tree* tr = 0 ) const;
00156
00157 private:
00158 void insert_field( const vcl_string& str, vil_nitf2_field* field);
00159
00160
00161 typedef vcl_map<vcl_string, vil_nitf2_field*> field_map;
00162 field_map fields;
00163
00164
00165 vcl_vector<vil_nitf2_field*> fields_vector;
00166
00167 const vil_nitf2_field_definitions* m_field_definitions;
00168 };
00169
00170 #endif // VIL_NITF2_FIELD_SEQUENCE_H