Geant4 Cross Reference |
1 // Copyright (C) 2010, Guy Barrand. All rights 2 // See the file tools.license for terms. 3 4 #ifndef tools_file_format 5 #define tools_file_format 6 7 #include "S_STRING" 8 9 #include <string> 10 #include <vector> 11 12 namespace tools { 13 namespace file { 14 15 TOOLS_GLOBAL_STRING(format_guessed) 16 TOOLS_GLOBAL_STRING(format_hdf5) 17 TOOLS_GLOBAL_STRING(format_fits) 18 TOOLS_GLOBAL_STRING(format_fog) 19 TOOLS_GLOBAL_STRING(format_dot) 20 TOOLS_GLOBAL_STRING(format_dcm) 21 TOOLS_GLOBAL_STRING(format_iv) 22 TOOLS_GLOBAL_STRING(format_wrl) 23 TOOLS_GLOBAL_STRING(format_jpeg) 24 TOOLS_GLOBAL_STRING(format_png) 25 TOOLS_GLOBAL_STRING(format_root) 26 TOOLS_GLOBAL_STRING(format_dst) //pmx,agora. 27 TOOLS_GLOBAL_STRING(format_csv) 28 TOOLS_GLOBAL_STRING(format_hippo) 29 TOOLS_GLOBAL_STRING(format_scenarios) 30 TOOLS_GLOBAL_STRING(format_slides) 31 TOOLS_GLOBAL_STRING(format_zvid) 32 TOOLS_GLOBAL_STRING(format_exsg) 33 TOOLS_GLOBAL_STRING(format_gdml) 34 TOOLS_GLOBAL_STRING(format_mac) 35 TOOLS_GLOBAL_STRING(format_cmnd) 36 TOOLS_GLOBAL_STRING(format_aida) 37 TOOLS_GLOBAL_STRING(format_bsg) 38 TOOLS_GLOBAL_STRING(format_jive) 39 TOOLS_GLOBAL_STRING(format_heprep) 40 TOOLS_GLOBAL_STRING(format_zheprep) 41 TOOLS_GLOBAL_STRING(format_lua) 42 TOOLS_GLOBAL_STRING(format_py) 43 TOOLS_GLOBAL_STRING(format_kumac) 44 TOOLS_GLOBAL_STRING(format_insh) 45 TOOLS_GLOBAL_STRING(format_shp) 46 TOOLS_GLOBAL_STRING(format_simbad) 47 48 #define TOOLS_GLOBAL_EXT(a_name)\ 49 inline const std::string& s_ext_##a_name() {\ 50 static const std::string s_v("."+std::string 51 return s_v;\ 52 } 53 54 TOOLS_GLOBAL_EXT(hdf5) 55 TOOLS_GLOBAL_EXT(fits) 56 TOOLS_GLOBAL_EXT(fog) 57 TOOLS_GLOBAL_EXT(dot) 58 TOOLS_GLOBAL_EXT(dcm) 59 TOOLS_GLOBAL_EXT(iv) 60 TOOLS_GLOBAL_EXT(hiv) 61 TOOLS_GLOBAL_EXT(wrl) 62 TOOLS_GLOBAL_EXT(jpeg) 63 TOOLS_GLOBAL_EXT(jpg) 64 TOOLS_GLOBAL_EXT(png) 65 TOOLS_GLOBAL_EXT(root) 66 TOOLS_GLOBAL_EXT(dst) 67 TOOLS_GLOBAL_EXT(csv) 68 TOOLS_GLOBAL_EXT(hiptxt) 69 TOOLS_GLOBAL_EXT(tnt) 70 TOOLS_GLOBAL_EXT(scenarios) 71 TOOLS_GLOBAL_EXT(slides) 72 TOOLS_GLOBAL_EXT(zvid) 73 TOOLS_GLOBAL_EXT(exsg) 74 TOOLS_GLOBAL_EXT(gdml) 75 TOOLS_GLOBAL_EXT(mac) 76 TOOLS_GLOBAL_EXT(cmnd) 77 TOOLS_GLOBAL_EXT(aida) 78 TOOLS_GLOBAL_EXT(bsg) 79 TOOLS_GLOBAL_EXT(jive) 80 TOOLS_GLOBAL_EXT(heprep) 81 TOOLS_GLOBAL_EXT(zheprep) 82 TOOLS_GLOBAL_EXT(lua) 83 TOOLS_GLOBAL_EXT(py) 84 TOOLS_GLOBAL_EXT(kumac) 85 TOOLS_GLOBAL_EXT(insh) 86 TOOLS_GLOBAL_EXT(shp) 87 TOOLS_GLOBAL_EXT(simbad) 88 89 #undef TOOLS_GLOBAL_EXT 90 91 inline void formats(std::vector<std::string>& 92 a_v.clear(); 93 a_v.push_back(s_format_guessed()); 94 a_v.push_back(s_format_hdf5()); 95 a_v.push_back(s_format_fits()); 96 a_v.push_back(s_format_fog()); 97 a_v.push_back(s_format_dot()); 98 a_v.push_back(s_format_dcm()); 99 a_v.push_back(s_format_iv()); 100 a_v.push_back(s_format_wrl()); 101 a_v.push_back(s_format_jpeg()); 102 a_v.push_back(s_format_png()); 103 a_v.push_back(s_format_root()); 104 a_v.push_back(s_format_dst()); 105 a_v.push_back(s_format_csv()); 106 a_v.push_back(s_format_hippo()); 107 a_v.push_back(s_format_scenarios()); 108 a_v.push_back(s_format_slides()); 109 a_v.push_back(s_format_zvid()); 110 a_v.push_back(s_format_exsg()); 111 a_v.push_back(s_format_bsg()); 112 a_v.push_back(s_format_gdml()); 113 a_v.push_back(s_format_mac()); 114 a_v.push_back(s_format_cmnd()); 115 a_v.push_back(s_format_aida()); 116 a_v.push_back(s_format_jive()); 117 a_v.push_back(s_format_heprep()); 118 a_v.push_back(s_format_zheprep()); 119 a_v.push_back(s_format_lua()); 120 a_v.push_back(s_format_py()); 121 a_v.push_back(s_format_kumac()); 122 a_v.push_back(s_format_insh()); 123 a_v.push_back(s_format_shp()); 124 a_v.push_back(s_format_simbad()); 125 } 126 127 inline std::string ext_fmt(const std::string& 128 if(a_ext==s_ext_fits()) return s_format_fits 129 if(a_ext==s_ext_aida()) return s_format_aida 130 if(a_ext==s_ext_root()) return s_format_root 131 if(a_ext==s_ext_dst()) return s_format_dst( 132 if(a_ext==s_ext_csv()) return s_format_csv( 133 if(a_ext==s_ext_tnt()) return s_format_hipp 134 if(a_ext==s_ext_hiptxt()) return s_format_hi 135 if(a_ext==s_ext_hdf5()) return s_format_hdf5 136 if(a_ext==s_ext_jpeg()) return s_format_jpeg 137 if(a_ext==s_ext_jpg()) return s_format_jpeg( 138 if(a_ext==s_ext_png()) return s_format_png() 139 if(a_ext==s_ext_fog()) return s_format_fog() 140 if(a_ext==s_ext_dot()) return s_format_dot() 141 if(a_ext==s_ext_dcm()) return s_format_dcm() 142 if(a_ext==s_ext_iv()) return s_format_iv(); 143 if(a_ext==s_ext_hiv()) return s_format_iv(); 144 if(a_ext==s_ext_wrl()) return s_format_wrl() 145 if(a_ext==s_ext_exsg()) return s_format_exsg 146 if(a_ext==s_ext_bsg()) return s_format_bsg() 147 if(a_ext==s_ext_scenarios()) return s_format 148 if(a_ext==s_ext_slides()) return s_format_sl 149 if(a_ext==s_ext_zvid()) return s_format_zvid 150 if(a_ext==s_ext_gdml()) return s_format_gdml 151 if(a_ext==s_ext_mac()) return s_format_mac() 152 if(a_ext==s_ext_cmnd()) return s_format_cmnd 153 if(a_ext==s_ext_jive()) return s_format_jive 154 if(a_ext==s_ext_heprep()) return s_format_he 155 if(a_ext==s_ext_zheprep()) return s_format_z 156 if(a_ext==s_ext_lua()) return s_format_lua() 157 if(a_ext==s_ext_py()) return s_format_py(); 158 if(a_ext==s_ext_kumac()) return s_format_kum 159 if(a_ext==s_ext_insh()) return s_format_insh 160 if(a_ext==s_ext_shp()) return s_format_shp() 161 if(a_ext==s_ext_simbad()) return s_format_si 162 return s_format_guessed(); 163 } 164 165 inline bool need_placement(const std::string& 166 if(a_format==s_format_guessed()) return true 167 //if(a_format==s_format_hdf5()) return true; 168 //if(a_format==s_format_fits()) return true; 169 //if(a_format==s_format_fog()) return true; / 170 //if(a_format==s_format_dot()) return true; 171 //if(a_format==s_format_dcm()) return true; 172 //if(a_format==s_format_iv()) return true; 173 //if(a_format==s_format_wrl()) return true; 174 //if(a_format==s_format_jpeg()) return true; 175 //if(a_format==s_format_png()) return true; 176 //if(a_format==s_format_root()) return true; 177 //if(a_format==s_format_dst()) return true; 178 //if(a_format==s_format_csv()) return true; 179 //if(a_format==s_format_hippo()) return true; 180 //if(a_format==s_format_scenarios()) return tr 181 //if(a_format==s_format_slides()) return true; 182 //if(a_format==s_format_zvid()) return true; 183 if(a_format==s_format_exsg()) return true; 184 //if(a_format==s_format_gdml()) return true; 185 //if(a_format==s_format_mac()) return true; 186 //if(a_format==s_format_cmnd()) return true; 187 //if(a_format==s_format_aida()) return true; 188 if(a_format==s_format_bsg()) return true; 189 //if(a_format==s_format_jive()) return true; 190 //if(a_format==s_format_heprep()) return true; 191 //if(a_format==s_format_zheprep()) return true 192 //if(a_format==s_format_lua()) return true; 193 //if(a_format==s_format_py()) return true; 194 //if(a_format==s_format_kumac()) return true; 195 //if(a_format==s_format_insh()) return true; 196 //if(a_format==s_format_shp()) return true; 197 //if(a_format==s_format_simbad()) return true; 198 return false; 199 } 200 201 // related files : sg/write_paper, paper_forma 202 203 inline bool is_paper_format(const std::string& 204 if(a_format=="gl2ps_eps") return true; 205 if(a_format=="gl2ps_ps") return true; 206 if(a_format=="gl2ps_pdf") return true; 207 if(a_format=="gl2ps_svg") return true; 208 if(a_format=="gl2ps_tex") return true; 209 if(a_format=="gl2ps_pgf") return true; 210 if(a_format=="inzb_ps") return true; 211 if(a_format=="inzb_jpeg") return true; 212 if(a_format=="inzb_png") return true; 213 return false; 214 } 215 216 inline bool is_inzb_format(const std::string& 217 if(a_format=="inzb_ps") return true; 218 if(a_format=="inzb_jpeg") return true; 219 if(a_format=="inzb_png") return true; 220 return false; 221 } 222 223 inline bool paper_format_extension(const std:: 224 if(a_format=="gl2ps_eps") {a_ext = "eps";ret 225 if(a_format=="gl2ps_ps") {a_ext = "ps";retu 226 if(a_format=="gl2ps_pdf") {a_ext = "pdf";ret 227 if(a_format=="gl2ps_svg") {a_ext = "svg";ret 228 if(a_format=="gl2ps_tex") {a_ext = "tex";ret 229 if(a_format=="gl2ps_pgf") {a_ext = "pgf";ret 230 if(a_format=="inzb_ps") {a_ext = "ps";retu 231 if(a_format=="inzb_jpeg") {a_ext = "jpeg";re 232 if(a_format=="inzb_png") {a_ext = "png";ret 233 a_ext.clear(); 234 return false; 235 } 236 237 }} 238 239 #endif