FACT++  1.0
Keys fits::Table::ParseBlock ( const std::vector< std::string > &  vec) const
inline

Definition at line 177 of file fits.h.

References i, Tools::Trim(), and type.

178  {
179  Keys rc;
180 
181  for (unsigned int i=0; i<vec.size(); i++)
182  {
183  const std::string key = Trim(vec[i].substr(0,8));
184  // Keywords without a value, like COMMENT / HISTORY
185  if (vec[i].substr(8,2)!="= ")
186  continue;
187 
188  char type = 0;
189 
190  std::string com;
191  std::string val = Trim(vec[i].substr(10));
192 
193  if (val[0]=='\'')
194  {
195  // First skip all '' in the string
196  size_t p = 1;
197  while (1)
198  {
199  const size_t pp = val.find_first_of('\'', p);
200  if (pp==std::string::npos)
201  break;
202 
203  p = val[pp+1]=='\'' ? pp+2 : pp+1;
204  }
205 
206  // Now find the comment
207  const size_t ppp = val.find_first_of('/', p);
208 
209  // Set value, comment and type
210  // comments could be just spaces. take care of this.
211  if (ppp!=std::string::npos && val.size()!=ppp+1)
212  com = Trim(val.substr(ppp+1));
213 
214  val = Trim(val.substr(1, p-2));
215  type = 'T';
216  }
217  else
218  {
219  const size_t p = val.find_first_of('/');
220 
221  if (p!=std::string::npos && val.size()!=p+1)
222  com = Trim(val.substr(p+2));
223 
224  val = Trim(val.substr(0, p));
225 
226  if (val.empty() || val.find_first_of('T')!=std::string::npos || val.find_first_of('F')!=std::string::npos)
227  type = 'B';
228  else
229  type = val.find_last_of('.')==std::string::npos ? 'I' : 'F';
230  }
231 
232  const Entry e = { type, val, com, vec[i] };
233 
234  rc[key] = e;
235  }
236 
237  return rc;
238  }
int i
Definition: db_dim_client.c:21
int type
std::map< std::string, Entry > Keys
Definition: fits.h:112
std::string Trim(const std::string &str, char c=' ') const
Definition: fits.h:122

+ Here is the call graph for this function: