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.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

  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)
 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>& 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