Back to home page

EIC code displayed by LXR

 
 

    


Warning, /include/Geant4/toolx/hdf5/atb 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_atb
0005 #define toolx_hdf5_atb
0006 
0007 // The below is internal methods in the HDF5 lib.
0008 
0009 #include "hdf5_h"
0010 
0011 #include <cstring>
0012 
0013 namespace toolx {
0014 namespace hdf5 {
0015 
0016 inline herr_t H5LT_get_attribute_mem(hid_t obj_id,const char *attr_name,hid_t mem_type_id,void *data ) {
0017   hid_t attr_id;
0018   if ( ( attr_id = ::H5Aopen_name( obj_id, attr_name ) ) < 0 )  return -1;
0019   if ( ::H5Aread( attr_id, mem_type_id, data ) < 0 ) {
0020     ::H5Aclose( attr_id );
0021     return -1;
0022   }
0023   if ( ::H5Aclose( attr_id ) < 0 )  return -1;
0024   return 0;
0025 }
0026 
0027 inline herr_t find_attr( hid_t loc_id, const char *name, void *op_data) {
0028   int ret = 0;
0029   char *attr_name = (char*)op_data;
0030   if( ::strcmp( name, attr_name ) == 0 ) ret = 1;
0031   (void)loc_id;
0032   return ret;
0033 }
0034 
0035 inline herr_t H5LT_find_attribute( hid_t loc_id, const char* attr_name ) {
0036   unsigned int attr_num;
0037   attr_num = 0;
0038   return toolx_H5Aiterate( loc_id, &attr_num, find_attr, (void *)attr_name );
0039 }
0040 
0041 inline herr_t H5LT_get_attribute_disk( hid_t loc_id,const char *attr_name,void *attr_out ) {
0042   hid_t      attr_id;
0043   if ( ( attr_id = ::H5Aopen_name( loc_id, attr_name ) ) < 0 )  return -1;
0044 
0045   hid_t      attr_type;
0046   if ( (attr_type = ::H5Aget_type( attr_id )) < 0 ) {
0047     ::H5Tclose( attr_type );
0048     ::H5Aclose( attr_id );
0049     return -1;
0050   }
0051 
0052   if ( ::H5Aread( attr_id, attr_type, attr_out ) < 0 ) {
0053     ::H5Tclose( attr_type );
0054     ::H5Aclose( attr_id );
0055     return -1;
0056   }
0057 
0058   if ( ::H5Tclose( attr_type )  < 0 ) {
0059     ::H5Tclose( attr_type );
0060     ::H5Aclose( attr_id );
0061     return -1;
0062   }
0063 
0064   if ( ::H5Aclose( attr_id ) < 0 )  return -1;
0065 
0066   return 0;
0067 
0068 }
0069 
0070 }}
0071 
0072 #endif