00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef HDFFILEMETADATA_H
00021 #define HDFFILEMETADATA_H
00022
00023 #define TAB_INCREMENT " "
00024
00025 #include <string>
00026 #include <vector>
00027 #include <fstream>
00028 #include <iostream>
00029 #include <cstdio>
00030 #include "Hdf_file.hpp"
00031 #include "file_tools.h"
00032 #include "tools.h"
00033 #include "hdfmetadatanode.h"
00034
00039 class HDFFileMetaData{
00040 Hdf_file *hdf_file;
00041 ofstream output_file;
00042 string output_filename;
00043 vector <string> input_file_lines;
00044 HDFMetadataNode* root_node;
00045
00046 bool stand_alone_read;
00047 bool persistent_xml_file;
00048 static string xml_header;
00049 string tab_increment;
00053 void init_output_file( const string _output_filename="", const bool overwrite=false, const bool create_temp_file=true );
00054 void write_xml_file( const string _output_filename="", const bool overwrite=false, const bool create_temp_file=true );
00055 void parse_string_to_xml(vector <string>::iterator start,vector <string>::iterator end, int rank=1);
00056 HDFMetadataNode* parse_string(vector <string>::iterator start,vector <string>::iterator end);
00057 vector <string>::iterator find_end_tag(vector <string>::iterator start,const string &tag, const string &val);
00058 void extract_tag_val(string &tag, string &val,vector< string >::iterator &line);
00059 void load_input_file_metadata();
00060 void load_metadata_named(const char *meta_name = "coremetadata");
00061 void init_input_hdf_file(const char * input_file_name = NULL);
00062 void init();
00063 void parse_xml_file();
00064 const HDFMetadataNode::value_type get_val_type(const string &s);
00065 const HDFMetadataNode::value_type get_elt_type(const string &s_val);
00066 const HDFMetadataNode::value_type get_array_type(const string &s_val);
00067 void build_array_value(void* val, const string &s_val);
00068 void build_tree();
00069 void view_node(const HDFMetadataNode* node, const int rank = 0);
00077 const bool get_node_value( HDFMetadataNode* node, void* val, const string & tag_name);
00078
00079 const bool get_node_value_string( HDFMetadataNode* node, string &val, const string & tag_name);
00080 public:
00081
00082
00083
00084
00089 HDFFileMetaData(const Hdf_file *_hdf_file = NULL);
00094 HDFFileMetaData(const char *_hdf_file_name = NULL);
00099 HDFFileMetaData(const std::string &_hdf_file_name = NULL);
00103 ~HDFFileMetaData();
00109 void to_xml(const char* output_filename = NULL, const bool overwrite = false);
00115 void get_value(void* val, const char * tag_name = "GRANULEID");
00122 const bool get_tree_value( void* val, const string & tag_name);
00123
00130 const bool get_tree_value_string( string &val, const string & tag_name);
00131
00135 void view_tree();
00136 };
00137
00138 #endif