Hdf_exceptions.hpp

00001 /***************************************************************************
00002  *   Copyright (C) 2005 by Nicolas PASCAL                                  *
00003  *   pascal@icare-pc15                                                     *
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 
00021 #ifndef HDF_EXCEPTIONS_H
00022 #define HDF_EXCEPTIONS_H 
00023  
00024 #include <string>
00025 #include <iostream>
00026 #include <exception>
00027 
00028 #include "Hdf_common.hpp"
00029 
00030 #include "mfhdf.h"
00031 using namespace std;
00032 
00037 class hdfcpp_exception : public exception
00038 {
00040     string file;
00042     long line;
00044     string msg;
00045 public:
00052     hdfcpp_exception( const char* file, long line, string msg = "" ) :
00053     file(file) , line(line) , msg(msg)
00054     { };
00055 
00059     virtual ~hdfcpp_exception() throw()
00060     { };
00061 
00066     virtual const char * what() const throw()
00067     {
00068       ostringstream oss;
00069       oss << file << "[" << line << "] : " << msg;
00070       return oss.str().c_str();
00071     }
00072 };
00073 
00077 class bad_hdf_file : public exception {
00078 public:
00079     bad_hdf_file(const string & _s) {
00080         s = _s;
00081     };
00082     ~bad_hdf_file() throw() {}
00083     ;
00084     virtual const char* what(void) const throw() {
00085       string m;
00086         if (&s != NULL)
00087             m="bad_hdf_file : The file "+s+" can't be found or invalid HDF file";
00088         else
00089             m="Empty file name";
00090       return m.c_str();
00091     };
00092 private:
00093     string s;
00094 };
00098 class bad_hdf_file_opening_mode : public exception {
00099 public:
00100     bad_hdf_file_opening_mode(const string & _file, const string & _mode= string("r")) {
00101         file = _file;
00102         mode = _mode;
00103     };
00104     ~bad_hdf_file_opening_mode() throw() {}
00105     ;
00106     virtual const char* what(void) const throw() {
00107       string m="The file "+file+" can't be opened in mode "+mode+". Check the file's access rights";
00108       return m.c_str();
00109     };
00110 private:
00111     string file;
00112     string mode;
00113 };
00114 class bad_close_file : public exception {
00115 public:
00116     bad_close_file(const string & file):file(file) {};
00117     ~bad_close_file() throw() {}
00118     ;
00119     virtual const char* what(void) const throw() {
00120       string m="bad_close_file : can't properly close the file "+file;
00121       return m.c_str();
00122     };
00123 private:
00124     string file;
00125 };
00126 class bad_hdf_compression : public exception {
00127 public:
00128   bad_hdf_compression(const char *_file, const char *_sds, const int32 _code) {
00129     file = _file;
00130     sds = _sds;
00131     code = _code;
00132   }
00133   ~bad_hdf_compression() throw() {}
00134   virtual const char* what(void) const throw() {
00135     string m = "bad_hdf_compression : failed to compress dataset "+sds+" using the compression code ";
00136     if (code==COMP_CODE_NONE)
00137       m+=string("COMP_CODE_NONE");
00138     else if (code==COMP_CODE_DEFLATE)
00139       m+=string("COMP_CODE_DEFLATE (gzip)");
00140     else if (code==COMP_CODE_SKPHUFF)
00141       m+=string("COMP_CODE_SKPHUFF (huffman)");
00142     else
00143       m+=string("UNKNOWN");
00144     return m.c_str();
00145   }
00146 private:
00147   string file;
00148   string sds;
00149   int32 code;
00150 };
00151 class bad_chunk_creation : public exception {
00152 public:
00153   bad_chunk_creation(const char *_file, const char *_sds) :file(_file),sds(_sds){}
00154   ~bad_chunk_creation() throw() {}
00155   virtual const char* what(void) const throw() {
00156     string m="bad_chunk_creation  : failed to create chunk for sds "+sds+" in file "+file;
00157     return m.c_str();
00158   }
00159 private:
00160   string file;
00161   string sds;
00162 };
00163 class bad_sd_file_info : public exception {
00164 public:
00165     bad_sd_file_info(const char* _filename) {
00166         filename=_filename;
00167     };
00168     ~bad_sd_file_info() throw() {}
00169     ;
00170     virtual const char* what(void) const throw() {
00171       string m="bad_sd_file_info : Can't read the sd file info for "+filename;
00172       return m.c_str();
00173     };
00174 private:
00175     string filename;
00176 };
00177 
00178 class bad_sd_attr_info : public exception {
00179 public:
00180     bad_sd_attr_info(const char* _attr_name) {
00181         attr_name=_attr_name;
00182     };
00183     ~bad_sd_attr_info() throw() {}
00184     ;
00185     virtual const char* what(void) const throw() {
00186       string m="bad_sd_attr_info : Can't read the sd attribute "+attr_name;
00187       return m.c_str();
00188     };
00189 private:
00190     string attr_name;
00191 };
00192 
00193 class bad_sd_get_info : public exception {
00194 public:
00195     bad_sd_get_info(const char* _sds_name) {
00196         sds_name=_sds_name;
00197     };
00198     ~bad_sd_get_info() throw() {}
00199     ;
00200     virtual const char* what(void) const throw() {
00201       string m="bad_sd_get_info : can't get the info from the sds "+sds_name;
00202       return m.c_str();
00203     };
00204 private:
00205     string sds_name;
00206 };
00207 
00208 class bad_sd_create : public exception {
00209 public:
00210     bad_sd_create(const char* _filename) {
00211         filename=_filename;
00212     };
00213     ~bad_sd_create() throw() {}
00214     ;
00215     virtual const char* what(void) const throw() {
00216       string m="bad_sd_create : can't create the sd for the file "+filename;
00217       return m.c_str();
00218     };
00219 private:
00220     string filename;
00221 };
00222 class bad_hdf_typecode : public exception {
00223 public:
00224     bad_hdf_typecode(const int32& typecode) : typecode(typecode){};
00225     ~bad_hdf_typecode() throw() {};
00226     virtual const char* what(void) const throw() {
00227       string m="bad_hdf_typecode : unknown hdf type code "+Hdf_common::to_string(typecode);
00228       return m.c_str();
00229     };
00230 private:
00231     int32 typecode;
00232 };
00233 class bad_sd_set_fill_mode : public exception {
00234 public:
00235     bad_sd_set_fill_mode(const char* _filename, const int32 _fill_mode) {
00236         filename=_filename;
00237         fill_mode=_fill_mode;
00238     };
00239     ~bad_sd_set_fill_mode() throw() {}
00240     ;
00241     virtual const char* what(void) const throw() {
00242       string m="Can't set the sd fill mode for the file "+filename+" to ";
00243       switch (fill_mode) {
00244           case SD_FILL: m+="SD_FILL";break;
00245           case SD_NOFILL: m+="SD_NOFILL";break;
00246           default: m+="the unknown mode : "+Hdf_common::to_string(fill_mode)+". Must be SD_FILL or SD_NOFILL";break;
00247       }
00248       return m.c_str();
00249     };
00250 private:
00251     string filename;
00252     int32 fill_mode;
00253 };
00254 class bad_sds_name : public exception {
00255 public:
00256     bad_sds_name(const char* _filename, const char* _sds_name) {
00257         filename=_filename;
00258         sds_name=_sds_name;
00259     };
00260     ~bad_sds_name() throw() {}
00261     ;
00262     virtual const char* what(void) const throw() {
00263       string m="bad_sds_name : can't find the sds "+sds_name+" in file "+filename;
00264       return m.c_str();
00265     };
00266 private:
00267     string filename;
00268     string sds_name;
00269 };
00270 class bad_set_file_attribute : public exception {
00271 public:
00272     bad_set_file_attribute(const char* _filename, const char* _attr_name) {
00273         filename=_filename;
00274         attr_name=_attr_name;
00275     };
00276     ~bad_set_file_attribute() throw() {}
00277     ;
00278     virtual const char* what(void) const throw() {
00279       string m="bad_set_file_attribute : can't set the attribute "+attr_name+" in file "+filename;
00280       return m.c_str();
00281     };
00282 private:
00283     string filename;
00284     string attr_name;
00285 };
00286 class bad_set_sds_attribute : public exception {
00287 public:
00288     bad_set_sds_attribute(const char* _filename, const char* _sds_name, const char* _attr_name) {
00289         filename=_filename;
00290         sds_name=_sds_name;
00291         attr_name=_attr_name;
00292     };
00293     ~bad_set_sds_attribute() throw() {}
00294     ;
00295     virtual const char* what(void) const throw() {
00296       string m="bad_set_sds_attribute : in file "+filename+" : can't set the attribute "+attr_name+" for the sds "+sds_name;
00297       return m.c_str();
00298     };
00299 private:
00300     string filename;
00301     string sds_name;
00302     string attr_name;
00303 };
00304 
00305 class bad_get_sds_attribute : public exception {
00306 public:
00307     bad_get_sds_attribute(const char* _filename, const char* _sds_name, const char* _attr_name) {
00308         filename=_filename;
00309         sds_name=_sds_name;
00310         attr_name=_attr_name;
00311     };
00312     ~bad_get_sds_attribute() throw() {}
00313     ;
00314     virtual const char* what(void) const throw() {
00315       string m="bad_get_sds_attribute : in file "+filename+" : can't read the attribute "+attr_name+" for the sds "+sds_name;
00316       return m.c_str();
00317     };
00318 private:
00319     string filename;
00320     string sds_name;
00321     string attr_name;
00322 };
00323 
00324 class bad_sds_attribute : public exception { // thrown inside Hdf_sds, per opposition to bad_get_sds_attribute that is thrown by Hdf_file (higher level)
00325 public:
00326     bad_sds_attribute(const char* _sds_name, const char* _attr_name) {
00327         sds_name=_sds_name;
00328         attr_name=_attr_name;
00329     };
00330     ~bad_sds_attribute() throw() {};
00331     virtual const char* what(void) const throw() {
00332       string m="bad_sds_attribute : the sds "+sds_name+" doesn't have an attribute named "+attr_name;
00333       return m.c_str();
00334     };
00335 private:
00336     string sds_name;
00337     string attr_name;
00338 };
00339 
00340 class bad_sd_select : public exception {
00341 public:
00342     bad_sd_select(const int32 _sds_index) {
00343         sds_index=_sds_index;
00344     };
00345     ~bad_sd_select() throw() {}
00346     ;
00347     virtual const char* what(void) const throw() {
00348       string m="bad_sd_select : can't select the sds "+sds_index;
00349       return m.c_str();
00350     };
00351 private:
00352     int32 sds_index;
00353 };
00354 
00355 class bad_sd_end_access : public exception {
00356 public:
00357     bad_sd_end_access(void) {
00358     };
00359     ~bad_sd_end_access() throw() {}
00360     ;
00361     virtual const char* what(void) const throw() {
00362       string m="bad_sd_end_access : can't end correctly the accessed sd";
00363       return m.c_str();
00364     };
00365 };
00366 
00367 class bad_sd_end : public exception {
00368 public:
00369     bad_sd_end(void) {
00370     };
00371     ~bad_sd_end() throw() {}
00372     ;
00373     virtual const char* what(void) const throw() {
00374       string m="bad_sd_end : Can't close properly the opened sd";
00375       return m.c_str();
00376     };
00377 };
00378 
00379 class sd_create_error : public exception {
00380     string filename;
00381     string sds_name;
00382     string error;
00383 public:
00384     sd_create_error(const string & _filename, const string &_sds_name, const string & _error){
00385         filename=_filename;
00386         sds_name=_sds_name;
00387         error=_error;
00388     };
00389     ~sd_create_error() throw() {}
00390     ;
00391     virtual const char* what(void) const throw() {
00392       string m="sd_create_error : while creating the sds "+sds_name+" in the file "+filename+" : "+error;
00393       return m.c_str();
00394     };
00395 };
00396 
00397 class sd_write_data_error : public exception {
00398     string filename;
00399     string sds_name;
00400     string error;
00401 public:
00402     sd_write_data_error(const string & _filename, const string &_sds_name, const string & _error){
00403         filename=_filename;
00404         sds_name=_sds_name;
00405         error=_error;
00406     };
00407     ~sd_write_data_error() throw() {}
00408     ;
00409     virtual const char* what(void) const throw() {
00410       string m="sd_write_data_error : while writing the sds "+sds_name+" in the file "+filename+" : "+error;
00411       return m.c_str();
00412     };
00413 };
00414 
00415 class sd_get_fill_value_error : public exception {
00416     string sds_name;
00417 public:
00418     sd_get_fill_value_error(const string &_sds_name){
00419         sds_name=_sds_name;
00420     };
00421     ~sd_get_fill_value_error() throw() {}
00422     ;
00423     virtual const char* what(void) const throw() {
00424       string m="sd_get_fill_value_error while reading the sds "+sds_name+". Perhaps : \n- the fill value hasn't been set for this sds\n- has a bad type\n- the fill_value output parametre is NULL";
00425       return m.c_str();
00426     };
00427 };
00428 class sd_set_fill_value_error : public exception {
00429     string sds_name;
00430 public:
00431     sd_set_fill_value_error(const string &_sds_name){
00432         sds_name=_sds_name;
00433     };
00434     ~sd_set_fill_value_error() throw() {}
00435     ;
00436     virtual const char* what(void) const throw() {
00437       string m="sd_set_fill_value_error in the sds "+sds_name+". Perhaps : \n- the fill value has a bad type\n- the fill_value parametre is NULL";
00438       return m.c_str();
00439     };
00440 };
00441 class sd_get_calibration_error : public exception {
00442     string sds_name;
00443 public:
00444     sd_get_calibration_error(const string &_sds_name){
00445         sds_name=_sds_name;
00446     };
00447     ~sd_get_calibration_error() throw() {}
00448     ;
00449     virtual const char* what(void) const throw() {
00450         string m="sd_get_calibration_error while reading the sds "+sds_name;
00451       return m.c_str();;
00452     };
00453 };
00454 class read_sds_error : public exception {
00455     string filename;
00456     int32 sds_index;
00457     string error_code;
00458 public:
00459     read_sds_error(const string &filename,const int32 &sds_index,const string &error_code) : filename(filename),sds_index(sds_index),error_code(error_code){};
00460     ~read_sds_error() throw() {};
00461     virtual const char* what(void) const throw() {
00462       string m="read_sds_error : in "+filename +" at sds index "+ Hdf_common::to_string(sds_index) +" : error "+error_code ;
00463       return m.c_str();
00464     };
00465 };
00466 // class bad_attribute_name : public exception {
00467 // public:
00468 //     bad_attribute_name(const string &filename, const string &attribute_name) : filename(filename),attribute_name(attribute_name){};
00469 //     ~bad_attribute_name() throw() {};
00470 //     virtual const char* what(void) const throw() {
00471 //       string m="bad_attribute_name : can't find the attribute "+attribute_name+" in file "+filename;
00472 //       return m.c_str();
00473 //     };
00474 // private:
00475 //     string filename;
00476 //     string attribute_name;
00477 // };
00478 class bad_vs_initialisation : public exception {
00479 public:
00480     bad_vs_initialisation(const string &filename) : filename(filename){};
00481     ~bad_vs_initialisation() throw() {};
00482     virtual const char* what(void) const throw() {
00483       string m="bad_vs_initialisation : can't initialize the VS interface for file "+filename;
00484       return m.c_str();
00485     };
00486 private:
00487     string filename;
00488 };
00489 
00490 class bad_v_end : public exception {
00491 public:
00492     bad_v_end(const string &filename) : filename(filename){};
00493     ~bad_v_end() throw() {};
00494     virtual const char* what(void) const throw() {
00495       string m="bad_v_end : can't properly terminate the VS interface access the file "+filename;
00496       return m.c_str();
00497     };
00498 private:
00499     string filename;
00500 };
00501 class bad_v_start : public exception {
00502 public:
00503     bad_v_start(const string &filename) : filename(filename){};
00504     ~bad_v_start() throw() {};
00505     virtual const char* what(void) const throw() {
00506       string m="bad_v_start : can't initialize the VS interface for the file "+filename;
00507       return m.c_str();
00508     };
00509 private:
00510     string filename;
00511 };
00512 class bad_vs_lone : public exception {
00513 public:
00514     bad_vs_lone(const string &filename) : filename(filename){};
00515     ~bad_vs_lone() throw() {};
00516     virtual const char* what(void) const throw() {
00517       string m="bad_vs_lone : can't retrieve the lone VD references for file "+filename;
00518       return m.c_str();
00519     };
00520 private:
00521     string filename;
00522 };
00523 class bad_vs_attach : public exception {
00524 public:
00525     bad_vs_attach(const string &filename, const int32& vs_idx, const string& mode) : filename(filename),vs_idx(vs_idx),mode(mode){};
00526     ~bad_vs_attach() throw() {};
00527     virtual const char* what(void) const throw() {
00528       string m="bad_vs_attach : can't attach the vdata of index "+Hdf_common::to_string(vs_idx)+" in mode "+mode+" for file "+filename;
00529       return m.c_str();
00530     };
00531 private:
00532     string filename;
00533     int32 vs_idx;
00534     string mode;
00535 };
00536 class bad_vs_detach : public exception {
00537 public:
00538     bad_vs_detach(const string &filename, const int32& vd_id) : filename(filename),vd_id(vd_id){};
00539     ~bad_vs_detach() throw() {};
00540     virtual const char* what(void) const throw() {
00541       string m="bad_vs_detach : can't detach the vdata with id "+Hdf_common::to_string(vd_id)+" for file "+filename;
00542       return m.c_str();
00543     };
00544 private:
00545     string filename;
00546     int32 vd_id;
00547 };
00548 class bad_vs_inquire : public exception {
00549 public:
00550     bad_vs_inquire(const string &filename, const int32& vs_idx) : filename(filename),vs_id(vs_id){};
00551     ~bad_vs_inquire() throw() {};
00552     virtual const char* what(void) const throw() {
00553       string m="bad_vs_inquire : can't inquire the infos of the VData of id "+Hdf_common::to_string(vs_id)+" in file "+filename;
00554       return m.c_str();
00555     };
00556 private:
00557     string filename;
00558     int32 vs_id;
00559 };
00560 class bad_vs_getclass : public exception {
00561 public:
00562     bad_vs_getclass(const string &filename, const int32& vs_id) : filename(filename),vs_id(vs_id){};
00563     ~bad_vs_getclass() throw() {};
00564     virtual const char* what(void) const throw() {
00565       string m="bad_vs_getclass : can't access the class info in the VData of id "+Hdf_common::to_string(vs_id)+" in file "+filename;
00566       return m.c_str();
00567     };
00568 private:
00569     string filename;
00570     int32 vs_id;
00571 };
00572 class bad_field_type : public exception {
00573 public:
00574     bad_field_type(const string &vd_name,const string &fieldname) : fieldname(fieldname),vd_name(vd_name){};
00575     ~bad_field_type() throw() {};
00576     virtual const char* what(void) const throw() {
00577       string m="bad_field_type : can't read the type of the field named "+fieldname+" in VData "+vd_name;
00578       return m.c_str();
00579     };
00580 private:
00581     string fieldname;
00582     string vd_name;
00583 };
00584 class bad_field_order : public exception {
00585 public:
00586     bad_field_order(const string &vd_name,const string &fieldname) : fieldname(fieldname),vd_name(vd_name){};
00587     ~bad_field_order() throw() {};
00588     virtual const char* what(void) const throw() {
00589       string m="bad_field_order : can't read the order of the field named "+fieldname+" in VData "+vd_name;
00590       return m.c_str();
00591     };
00592 private:
00593     string fieldname;
00594     string vd_name;
00595 };
00596 class bad_field_size : public exception {
00597 public:
00598     bad_field_size(const string &vd_name,const string &fieldname) : fieldname(fieldname),vd_name(vd_name){};
00599     ~bad_field_size() throw() {};
00600     virtual const char* what(void) const throw() {
00601       string m="bad_field_size : can't read the size of the field named "+fieldname+" in VData "+vd_name;
00602       return m.c_str();
00603     };
00604 private:
00605     string fieldname;
00606     string vd_name;
00607 };
00608 class bad_vs_attr_info : public exception {
00609 public:
00610     bad_vs_attr_info(const string &vd_name,const int32 &field_index,const int32 &attr_index) : vd_name(vd_name),field_index(field_index),attr_index(attr_index){};
00611     ~bad_vs_attr_info() throw() {};
00612     virtual const char* what(void) const throw() {
00613       string m="bad_vs_attr_info : can't read the attribute informations in the VData named "+vd_name;
00614       if (field_index!=-1) // infos specific to a given field
00615         m+=" of the field of index "+Hdf_common::to_string(field_index);
00616       if (field_index!=-1) // infos specific to a given attribute
00617         m+=" for the attribute of index "+Hdf_common::to_string(attr_index);
00618       return m.c_str();
00619     };
00620 private:
00621     string vd_name;
00622     int32 field_index;
00623     intn attr_index;
00624 };
00625 class bad_vs_fnattrs : public exception {
00626 public:
00627     bad_vs_fnattrs(const string &vd_name,const int32 &field_index) : vd_name(vd_name),field_index(field_index){};
00628     ~bad_vs_fnattrs() throw() {};
00629     virtual const char* what(void) const throw() {
00630       string m="bad_vs_fnattrs : can't find the number of attributes "+vd_name;
00631       if (field_index!=-1) // infos specific to a given field
00632         m+=" of the field of index "+Hdf_common::to_string(field_index);
00633       return m.c_str();
00634     };
00635 private:
00636     string vd_name;
00637     int32 field_index;
00638 };
00639 class bad_vf_nfields : public exception {
00640 public:
00641     bad_vf_nfields(const string &filename,const string &vd_name) : filename(filename),vd_name(vd_name){};
00642     ~bad_vf_nfields() throw() {};
00643     virtual const char* what(void) const throw() {
00644       string m="bad_vf_nfields : can't find the number of fields for vdata "+vd_name+" in "+filename;
00645       return m.c_str();
00646     };
00647 private:
00648     string filename;
00649     string vd_name;
00650 };
00651 class bad_attribute_index : public exception {
00652 public:
00653     bad_attribute_index(const string &parent_name,const int32 &attr_idx,const attribute_parent& parent) : parent_name(parent_name),attr_idx(attr_idx),parent(parent){};
00654     ~bad_attribute_index() throw() {};
00655     virtual const char* what(void) const throw() {
00656       string m="bad_attribute_index : can't find the attribute of index "+Hdf_common::to_string(attr_idx)+" in ";
00657       if (parent==HDF_FILE)
00658         m+=" the file "+parent_name;
00659       else if (parent==SDS)
00660         m+=" the sds "+parent_name;
00661       else if (parent==VDATA)
00662         m+=" the VData "+parent_name;
00663       else if (parent==VDATA_FIELD)
00664         m+=" the VData Field "+parent_name;
00665       else
00666         m+=" an UNKNOWN parent";
00667       return m.c_str();
00668     };
00669 private:
00670     string parent_name;
00671     int32 attr_idx;
00672     attribute_parent parent;
00673 };
00674 class bad_attribute_name : public exception {
00675 public:
00676     bad_attribute_name(const string &parent_name,const char* &attr_name,const attribute_parent& parent) : parent_name(parent_name),attr_name(attr_name),parent(parent){};
00677     ~bad_attribute_name() throw() {};
00678     virtual const char* what(void) const throw() {
00679       string m="bad_attribute_name : can't find the attribute of name "+attr_name+" in ";
00680       if (parent==HDF_FILE)
00681         m+=" the file "+parent_name;
00682       else if (parent==SDS)
00683         m+=" the sds "+parent_name;
00684       else if (parent==VDATA)
00685         m+=" the VData "+parent_name;
00686       else if (parent==VDATA_FIELD)
00687         m+=" the VData Field "+parent_name;
00688       else
00689         m+=" an UNKNOWN parent";
00690       return m.c_str();
00691     };
00692 private:
00693     string parent_name;
00694     string attr_name;
00695     attribute_parent parent;
00696 };
00697 class bad_vd_index : public exception {
00698 public:
00699     bad_vd_index(const string &filename,const int32 &vd_idx) : filename(filename),vd_idx(vd_idx){};
00700     ~bad_vd_index() throw() {};
00701     virtual const char* what(void) const throw() {
00702       string m="bad_vd_index : can't find the vd of index "+Hdf_common::to_string(vd_idx)+" in "+filename;
00703       return m.c_str();
00704     };
00705 private:
00706     string filename;
00707     int32 vd_idx;
00708 };
00709 class bad_vd_name : public exception {
00710 public:
00711     bad_vd_name(const string &filename,const char* &vd_name) : filename(filename),vd_name(vd_name){};
00712     ~bad_vd_name() throw() {};
00713     virtual const char* what(void) const throw() {
00714       string m="bad_vd_name : can't find the vd of name "+vd_name+" in "+filename;
00715       return m.c_str();
00716     };
00717 private:
00718     string filename;
00719     string vd_name;
00720 };
00721 class bad_field_index : public exception {
00722 public:
00723     bad_field_index(const string &vd_name,const int32 &field_idx) : vd_name(vd_name),field_idx(field_idx){};
00724     ~bad_field_index() throw() {};
00725     virtual const char* what(void) const throw() {
00726       string m="bad_field_index : can't find the field of index "+Hdf_common::to_string(field_idx)+" in VData "+vd_name;
00727       return m.c_str();
00728     };
00729 private:
00730     string vd_name;
00731     int32 field_idx;
00732 };
00733 class bad_field_name : public exception {
00734 public:
00735     bad_field_name(const string &vd_name,const string &field_name) : vd_name(vd_name),field_name(field_name){};
00736     ~bad_field_name() throw() {};
00737     virtual const char* what(void) const throw() {
00738       string m="bad_field_name : can't find the field named "+field_name+" in VData "+vd_name;
00739       return m.c_str();
00740     };
00741 private:
00742     string vd_name;
00743     string field_name;
00744 };
00745 class bad_vs_setfields : public exception {
00746 public:
00747     bad_vs_setfields(const string &filename,const string &vd_name,const string &field_name) : filename(filename),vd_name(vd_name),field_name(field_name){};
00748     ~bad_vs_setfields() throw() {};
00749     virtual const char* what(void) const throw() {
00750       string m="bad_vs_setfields : can't find the field "+field_name+" in VData "+vd_name+" in "+filename;
00751       return m.c_str();
00752     };
00753 private:
00754     string filename;
00755     string vd_name;
00756     string field_name;
00757 };
00758 class bad_vs_seek : public exception {
00759 public:
00760     bad_vs_seek(const string &filename,const string &vd_name,const int32& position) : filename(filename),vd_name(vd_name),position(position){};
00761     ~bad_vs_seek() throw() {};
00762     virtual const char* what(void) const throw() {
00763       string m="bad_vs_seek : can't seek the position "+Hdf_common::to_string(position)+" in VData "+vd_name+" in "+filename;
00764       return m.c_str();
00765     };
00766 private:
00767     string filename;
00768     string vd_name;
00769     int32 position;
00770 };
00771 class bad_vs_read : public exception {
00772 public:
00773     bad_vs_read(const string &filename,const string &vd_name,const int32& nb_values) : filename(filename),vd_name(vd_name),nb_values(nb_values){};
00774     ~bad_vs_read() throw() {};
00775     virtual const char* what(void) const throw() {
00776       string m="bad_vs_read : can't read "+Hdf_common::to_string(nb_values)+" values in VData "+vd_name+" in "+filename;
00777       return m.c_str();
00778     };
00779 private:
00780     string filename;
00781     string vd_name;
00782     int32 nb_values;
00783 };
00784 class bad_vs_fpack : public exception {
00785 public:
00786     bad_vs_fpack(const string &filename,const string &vd_name,const string &field_name) : filename(filename),vd_name(vd_name),field_name(field_name){};
00787     ~bad_vs_fpack() throw() {};
00788     virtual const char* what(void) const throw() {
00789       string m="bad_vs_fpack : can't pack/unpack the datas of the field "+field_name+" in VData "+vd_name+" in "+filename;
00790       return m.c_str();
00791     };
00792 private:
00793     string filename;
00794     string vd_name;
00795     string field_name;
00796 };
00797 class bad_sd_read_attr : public exception {
00798 public:
00799     bad_sd_read_attr(const string &attrname) : attrname(attrname){};
00800     ~bad_sd_read_attr() throw() {};
00801     virtual const char* what(void) const throw() {
00802       string m="bad_sd_read_attr : can't read the SD attribute "+attrname;
00803       return m.c_str();
00804     };
00805 private:
00806     string attrname;
00807 };
00808 class bad_vs_get_attr : public exception {
00809 public:
00810     bad_vs_get_attr(const string &attrname) : attrname(attrname){};
00811     ~bad_vs_get_attr() throw() {};
00812     virtual const char* what(void) const throw() {
00813       string m="bad_vs_get_attr : can't read the VData attribute "+attrname;
00814       return m.c_str();
00815     };
00816 private:
00817     string attrname;
00818 };
00819 #endif