g4tools  5.4.0
file_format
Go to the documentation of this file.
1 // Copyright (C) 2010, Guy Barrand. All rights reserved.
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(#a_name));\
51  return s_v;\
52 }
53 
54 TOOLS_GLOBAL_EXT(hdf5)
55 TOOLS_GLOBAL_EXT(fits)
62 TOOLS_GLOBAL_EXT(jpeg)
65 TOOLS_GLOBAL_EXT(root)
68 TOOLS_GLOBAL_EXT(hiptxt)
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)
76 TOOLS_GLOBAL_EXT(cmnd)
77 TOOLS_GLOBAL_EXT(aida)
79 TOOLS_GLOBAL_EXT(jive)
80 TOOLS_GLOBAL_EXT(heprep)
81 TOOLS_GLOBAL_EXT(zheprep)
84 TOOLS_GLOBAL_EXT(kumac)
85 TOOLS_GLOBAL_EXT(insh)
87 TOOLS_GLOBAL_EXT(simbad)
88 
89 #undef TOOLS_GLOBAL_EXT
90 
91 inline void formats(std::vector<std::string>& a_v) {
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& a_ext) {
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_hippo();
134  if(a_ext==s_ext_hiptxt()) return s_format_hippo();
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_scenarios();
148  if(a_ext==s_ext_slides()) return s_format_slides();
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_heprep();
155  if(a_ext==s_ext_zheprep()) return s_format_zheprep();
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_kumac();
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_simbad();
162  return s_format_guessed();
163 }
164 
165 inline bool need_placement(const std::string& a_format) {
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; //load in static_sg.
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; //load in static_sg.
173 //if(a_format==s_format_wrl()) return true; //load in static_sg.
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 true;
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; //load in static_sg.
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; //load in dynamic_sg.
190 //if(a_format==s_format_heprep()) return true; //load in static_sg.
191 //if(a_format==s_format_zheprep()) return true; //load in static_sg.
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; //load in static_sg.
197 //if(a_format==s_format_simbad()) return true; //load in arg sep.
198  return false;
199 }
200 
201 // related files : sg/write_paper, paper_format.
202 
203 inline bool is_paper_format(const std::string& a_format) {
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& a_format) {
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::string& a_format,std::string& a_ext) {
224  if(a_format=="gl2ps_eps") {a_ext = "eps";return true;}
225  if(a_format=="gl2ps_ps") {a_ext = "ps";return true;}
226  if(a_format=="gl2ps_pdf") {a_ext = "pdf";return true;}
227  if(a_format=="gl2ps_svg") {a_ext = "svg";return true;}
228  if(a_format=="gl2ps_tex") {a_ext = "tex";return true;}
229  if(a_format=="gl2ps_pgf") {a_ext = "pgf";return true;}
230  if(a_format=="inzb_ps") {a_ext = "ps";return true;}
231  if(a_format=="inzb_jpeg") {a_ext = "jpeg";return true;}
232  if(a_format=="inzb_png") {a_ext = "png";return true;}
233  a_ext.clear();
234  return false;
235 }
236 
237 }}
238 
239 #endif
tools::file::is_inzb_format
bool is_inzb_format(const std::string &a_format)
Definition: file_format:216
TOOLS_GLOBAL_EXT
#define TOOLS_GLOBAL_EXT(a_name)
tools::file::need_placement
bool need_placement(const std::string &a_format)
Definition: file_format:165
tools::file::TOOLS_GLOBAL_STRING
TOOLS_GLOBAL_STRING(format_dst) inline void formats(std
Definition: file_format:26
tools::file::is_paper_format
bool is_paper_format(const std::string &a_format)
Definition: file_format:203
tools::file::ext_fmt
std::string ext_fmt(const std::string &a_ext)
Definition: file_format:127
tools::file::paper_format_extension
bool paper_format_extension(const std::string &a_format, std::string &a_ext)
Definition: file_format:223
tools
inlined C code : ///////////////////////////////////
Definition: aida_ntuple:26
S_STRING