Back to home page

EIC code displayed by LXR

 
 

    


Warning, /include/Geant4/toolx/hdf5/group_exists is written in an unsupported language. File is not indexed.

0001 // Copyright (C) 2010, Guy Barrand. All rights reserved.
0002 // See the file tools.license for terms.
0003 
0004 #ifndef toolx_hdf5_group_exists
0005 #define toolx_hdf5_group_exists
0006 
0007 #include "hdf5_h"
0008 
0009 #include <string>
0010 
0011 namespace toolx {
0012 namespace hdf5 {
0013 
0014 class group_exists_struct {
0015 public:
0016   group_exists_struct(const std::string& a_what):m_what(a_what),m_found(false){}
0017   virtual ~group_exists_struct() {}
0018 protected:
0019   group_exists_struct(const group_exists_struct& a_from):m_what(a_from.m_what),m_found(a_from.m_found){}
0020   group_exists_struct& operator=(const group_exists_struct&){return *this;}
0021 public:
0022   std::string m_what;
0023   bool m_found;
0024 };
0025 
0026 inline herr_t group_exists_visit(hid_t a_id,const char* a_name,void* a_tag){ //a_id = parent of a_name object.
0027   group_exists_struct* visitor = (group_exists_struct*)a_tag;
0028   H5G_stat_t statbuf;
0029   ::H5Gget_objinfo(a_id,a_name,0,&statbuf);
0030   switch(statbuf.type) {
0031   case H5G_GROUP:{
0032     if(a_name==visitor->m_what) {visitor->m_found=true;return 0;} //found
0033     //::H5Giterate(a_id,a_name,NULL,group_exists_visit,visitor);
0034   }break;
0035   default:
0036     break;
0037   }
0038   return 0;
0039 }
0040 
0041 inline bool group_exists(hid_t a_file_id,const std::string& a_name) {
0042   group_exists_struct visitor(a_name);
0043   ::H5Giterate(a_file_id,".",NULL,group_exists_visit,&visitor);
0044   return visitor.m_found;
0045 }
0046 
0047 }}
0048 
0049 #endif