Files
geant4/source/externals/g4tools/include/tools/file_format
T
2021-06-25 16:12:29 +02:00

240 lines
8.1 KiB
Plaintext

// Copyright (C) 2010, Guy Barrand. All rights reserved.
// See the file tools.license for terms.
#ifndef tools_file_format
#define tools_file_format
#include "S_STRING"
#include <string>
#include <vector>
namespace tools {
namespace file {
TOOLS_GLOBAL_STRING(format_guessed)
TOOLS_GLOBAL_STRING(format_hdf5)
TOOLS_GLOBAL_STRING(format_fits)
TOOLS_GLOBAL_STRING(format_fog)
TOOLS_GLOBAL_STRING(format_dot)
TOOLS_GLOBAL_STRING(format_dcm)
TOOLS_GLOBAL_STRING(format_iv)
TOOLS_GLOBAL_STRING(format_wrl)
TOOLS_GLOBAL_STRING(format_jpeg)
TOOLS_GLOBAL_STRING(format_png)
TOOLS_GLOBAL_STRING(format_root)
TOOLS_GLOBAL_STRING(format_dst) //pmx,agora.
TOOLS_GLOBAL_STRING(format_csv)
TOOLS_GLOBAL_STRING(format_hippo)
TOOLS_GLOBAL_STRING(format_scenarios)
TOOLS_GLOBAL_STRING(format_slides)
TOOLS_GLOBAL_STRING(format_zvid)
TOOLS_GLOBAL_STRING(format_exsg)
TOOLS_GLOBAL_STRING(format_gdml)
TOOLS_GLOBAL_STRING(format_mac)
TOOLS_GLOBAL_STRING(format_cmnd)
TOOLS_GLOBAL_STRING(format_aida)
TOOLS_GLOBAL_STRING(format_bsg)
TOOLS_GLOBAL_STRING(format_jive)
TOOLS_GLOBAL_STRING(format_heprep)
TOOLS_GLOBAL_STRING(format_zheprep)
TOOLS_GLOBAL_STRING(format_lua)
TOOLS_GLOBAL_STRING(format_py)
TOOLS_GLOBAL_STRING(format_kumac)
TOOLS_GLOBAL_STRING(format_insh)
TOOLS_GLOBAL_STRING(format_shp)
TOOLS_GLOBAL_STRING(format_simbad)
#define TOOLS_GLOBAL_EXT(a_name)\
inline const std::string& s_ext_##a_name() {\
static const std::string s_v("."+std::string(#a_name));\
return s_v;\
}
TOOLS_GLOBAL_EXT(hdf5)
TOOLS_GLOBAL_EXT(fits)
TOOLS_GLOBAL_EXT(fog)
TOOLS_GLOBAL_EXT(dot)
TOOLS_GLOBAL_EXT(dcm)
TOOLS_GLOBAL_EXT(iv)
TOOLS_GLOBAL_EXT(hiv)
TOOLS_GLOBAL_EXT(wrl)
TOOLS_GLOBAL_EXT(jpeg)
TOOLS_GLOBAL_EXT(jpg)
TOOLS_GLOBAL_EXT(png)
TOOLS_GLOBAL_EXT(root)
TOOLS_GLOBAL_EXT(dst)
TOOLS_GLOBAL_EXT(csv)
TOOLS_GLOBAL_EXT(hiptxt)
TOOLS_GLOBAL_EXT(tnt)
TOOLS_GLOBAL_EXT(scenarios)
TOOLS_GLOBAL_EXT(slides)
TOOLS_GLOBAL_EXT(zvid)
TOOLS_GLOBAL_EXT(exsg)
TOOLS_GLOBAL_EXT(gdml)
TOOLS_GLOBAL_EXT(mac)
TOOLS_GLOBAL_EXT(cmnd)
TOOLS_GLOBAL_EXT(aida)
TOOLS_GLOBAL_EXT(bsg)
TOOLS_GLOBAL_EXT(jive)
TOOLS_GLOBAL_EXT(heprep)
TOOLS_GLOBAL_EXT(zheprep)
TOOLS_GLOBAL_EXT(lua)
TOOLS_GLOBAL_EXT(py)
TOOLS_GLOBAL_EXT(kumac)
TOOLS_GLOBAL_EXT(insh)
TOOLS_GLOBAL_EXT(shp)
TOOLS_GLOBAL_EXT(simbad)
#undef TOOLS_GLOBAL_EXT
inline void formats(std::vector<std::string>& a_v) {
a_v.clear();
a_v.push_back(s_format_guessed());
a_v.push_back(s_format_hdf5());
a_v.push_back(s_format_fits());
a_v.push_back(s_format_fog());
a_v.push_back(s_format_dot());
a_v.push_back(s_format_dcm());
a_v.push_back(s_format_iv());
a_v.push_back(s_format_wrl());
a_v.push_back(s_format_jpeg());
a_v.push_back(s_format_png());
a_v.push_back(s_format_root());
a_v.push_back(s_format_dst());
a_v.push_back(s_format_csv());
a_v.push_back(s_format_hippo());
a_v.push_back(s_format_scenarios());
a_v.push_back(s_format_slides());
a_v.push_back(s_format_zvid());
a_v.push_back(s_format_exsg());
a_v.push_back(s_format_bsg());
a_v.push_back(s_format_gdml());
a_v.push_back(s_format_mac());
a_v.push_back(s_format_cmnd());
a_v.push_back(s_format_aida());
a_v.push_back(s_format_jive());
a_v.push_back(s_format_heprep());
a_v.push_back(s_format_zheprep());
a_v.push_back(s_format_lua());
a_v.push_back(s_format_py());
a_v.push_back(s_format_kumac());
a_v.push_back(s_format_insh());
a_v.push_back(s_format_shp());
a_v.push_back(s_format_simbad());
}
inline std::string ext_fmt(const std::string& a_ext) {
if(a_ext==s_ext_fits()) return s_format_fits();
if(a_ext==s_ext_aida()) return s_format_aida();
if(a_ext==s_ext_root()) return s_format_root();
if(a_ext==s_ext_dst()) return s_format_dst();
if(a_ext==s_ext_csv()) return s_format_csv();
if(a_ext==s_ext_tnt()) return s_format_hippo();
if(a_ext==s_ext_hiptxt()) return s_format_hippo();
if(a_ext==s_ext_hdf5()) return s_format_hdf5();
if(a_ext==s_ext_jpeg()) return s_format_jpeg();
if(a_ext==s_ext_jpg()) return s_format_jpeg();
if(a_ext==s_ext_png()) return s_format_png();
if(a_ext==s_ext_fog()) return s_format_fog();
if(a_ext==s_ext_dot()) return s_format_dot();
if(a_ext==s_ext_dcm()) return s_format_dcm();
if(a_ext==s_ext_iv()) return s_format_iv();
if(a_ext==s_ext_hiv()) return s_format_iv();
if(a_ext==s_ext_wrl()) return s_format_wrl();
if(a_ext==s_ext_exsg()) return s_format_exsg();
if(a_ext==s_ext_bsg()) return s_format_bsg();
if(a_ext==s_ext_scenarios()) return s_format_scenarios();
if(a_ext==s_ext_slides()) return s_format_slides();
if(a_ext==s_ext_zvid()) return s_format_zvid();
if(a_ext==s_ext_gdml()) return s_format_gdml();
if(a_ext==s_ext_mac()) return s_format_mac();
if(a_ext==s_ext_cmnd()) return s_format_cmnd();
if(a_ext==s_ext_jive()) return s_format_jive();
if(a_ext==s_ext_heprep()) return s_format_heprep();
if(a_ext==s_ext_zheprep()) return s_format_zheprep();
if(a_ext==s_ext_lua()) return s_format_lua();
if(a_ext==s_ext_py()) return s_format_py();
if(a_ext==s_ext_kumac()) return s_format_kumac();
if(a_ext==s_ext_insh()) return s_format_insh();
if(a_ext==s_ext_shp()) return s_format_shp();
if(a_ext==s_ext_simbad()) return s_format_simbad();
return s_format_guessed();
}
inline bool need_placement(const std::string& a_format) {
if(a_format==s_format_guessed()) return true;
//if(a_format==s_format_hdf5()) return true;
//if(a_format==s_format_fits()) return true;
//if(a_format==s_format_fog()) return true; //load in static_sg.
//if(a_format==s_format_dot()) return true;
//if(a_format==s_format_dcm()) return true;
//if(a_format==s_format_iv()) return true; //load in static_sg.
//if(a_format==s_format_wrl()) return true; //load in static_sg.
//if(a_format==s_format_jpeg()) return true;
//if(a_format==s_format_png()) return true;
//if(a_format==s_format_root()) return true;
//if(a_format==s_format_dst()) return true;
//if(a_format==s_format_csv()) return true;
//if(a_format==s_format_hippo()) return true;
//if(a_format==s_format_scenarios()) return true;
//if(a_format==s_format_slides()) return true;
//if(a_format==s_format_zvid()) return true;
if(a_format==s_format_exsg()) return true;
//if(a_format==s_format_gdml()) return true; //load in static_sg.
//if(a_format==s_format_mac()) return true;
//if(a_format==s_format_cmnd()) return true;
//if(a_format==s_format_aida()) return true;
if(a_format==s_format_bsg()) return true;
//if(a_format==s_format_jive()) return true; //load in dynamic_sg.
//if(a_format==s_format_heprep()) return true; //load in static_sg.
//if(a_format==s_format_zheprep()) return true; //load in static_sg.
//if(a_format==s_format_lua()) return true;
//if(a_format==s_format_py()) return true;
//if(a_format==s_format_kumac()) return true;
//if(a_format==s_format_insh()) return true;
//if(a_format==s_format_shp()) return true; //load in static_sg.
//if(a_format==s_format_simbad()) return true; //load in arg sep.
return false;
}
// related files : sg/write_paper, paper_format.
inline bool is_paper_format(const std::string& a_format) {
if(a_format=="gl2ps_eps") return true;
if(a_format=="gl2ps_ps") return true;
if(a_format=="gl2ps_pdf") return true;
if(a_format=="gl2ps_svg") return true;
if(a_format=="gl2ps_tex") return true;
if(a_format=="gl2ps_pgf") return true;
if(a_format=="inzb_ps") return true;
if(a_format=="inzb_jpeg") return true;
if(a_format=="inzb_png") return true;
return false;
}
inline bool is_inzb_format(const std::string& a_format) {
if(a_format=="inzb_ps") return true;
if(a_format=="inzb_jpeg") return true;
if(a_format=="inzb_png") return true;
return false;
}
inline bool paper_format_extension(const std::string& a_format,std::string& a_ext) {
if(a_format=="gl2ps_eps") {a_ext = "eps";return true;}
if(a_format=="gl2ps_ps") {a_ext = "ps";return true;}
if(a_format=="gl2ps_pdf") {a_ext = "pdf";return true;}
if(a_format=="gl2ps_svg") {a_ext = "svg";return true;}
if(a_format=="gl2ps_tex") {a_ext = "tex";return true;}
if(a_format=="gl2ps_pgf") {a_ext = "pgf";return true;}
if(a_format=="inzb_ps") {a_ext = "ps";return true;}
if(a_format=="inzb_jpeg") {a_ext = "jpeg";return true;}
if(a_format=="inzb_png") {a_ext = "png";return true;}
a_ext.clear();
return false;
}
}}
#endif