• Main Page
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

/home/pascal/depot/filedata/src/hdffilemetadata.h

00001 /***************************************************************************
00002  *   Copyright (C) 2005 by Nicolas PASCAL                                  *
00003  *   nicolas.pascal@icare.univ-lille1.fr                                   *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
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; // used to know if the Hdf_file has been initialized by this class, or outside of it. If init from outside, at the destruction of the object, the Hdf_file musn't be deleted
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); // elt is a stand alone value or an array element
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 ***  CONSTRUCTORS/DESTRUCTORS  ***
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

Generated on Thu Feb 14 2013 17:59:03 for filedata.kdevelop by  doxygen 1.7.1