core/vil/file_formats/vil_nitf2_field.cxx
Go to the documentation of this file.
00001 // vil_nitf2: Written by Harry Voorhees (hlv@) and Rob Radtke (rob@) of
00002 // Stellar Science Ltd. Co. (stellarscience.com) for 
00003 // Air Force Research Laboratory, 2005.
00004 
00005 #include "vil_nitf2_field.h"
00006 #include "vil_nitf2.h"
00007 #include "vil_nitf2_field_formatter.h"
00008 #include "vil_nitf2_field_definition.h"
00009 #include "vil_nitf2_index_vector.h"
00010 
00011 vil_nitf2::enum_field_type vil_nitf2_field::type() const
00012 { 
00013   if (m_definition && m_definition->formatter) {
00014     return m_definition->formatter->field_type;
00015   }
00016   else { 
00017     return vil_nitf2::type_undefined;
00018   }
00019 }
00020 
00021 vcl_string vil_nitf2_field::tag() const 
00022 {
00023   return m_definition->tag;
00024 }
00025 
00026 vcl_string vil_nitf2_field::pretty_name() const 
00027 {
00028   return m_definition->pretty_name;
00029 }
00030 
00031 vcl_string vil_nitf2_field::description() const 
00032 { 
00033   return m_definition->description; 
00034 }
00035 
00036 vil_nitf2_field::field_tree* vil_nitf2_field::get_tree( ) const
00037 {
00038   field_tree* tr = new field_tree;
00039   tr->columns.push_back( tag() );
00040   tr->columns.push_back( pretty_name() );
00041   return tr;
00042 }
00043 
00044 vil_nitf2_field::field_tree::~field_tree()
00045 {
00046   for ( unsigned int i = 0 ; i < children.size() ; i++ ) {
00047     delete children[i];
00048   }
00049   children.clear();
00050 }
00051 
00052 vil_nitf2_scalar_field* vil_nitf2_field::scalar_field()
00053 {
00054   if (num_dimensions()==0) {
00055     return (vil_nitf2_scalar_field*) this;
00056   } else {
00057     return 0;
00058   }
00059 }
00060 
00061 vil_nitf2_array_field* vil_nitf2_field::array_field()
00062 {
00063   if (num_dimensions()>0) {
00064     return (vil_nitf2_array_field*) this;
00065   } else {
00066     return 0;
00067   }
00068 }
00069 
00070 vcl_ostream& operator << (vcl_ostream& os, const vil_nitf2_field& field) 
00071 {
00072   return field.output(os);
00073 }