g4tools  5.4.0
rcsv_ntuple
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_rcsv_ntuple
5 #define tools_rcsv_ntuple
6 
7 // A simple ntuple class to read at the csv format.
8 // (csv = comma separated value).
9 
10 // This reader can be use to read file at the hippodraw format
11 // which is :
12 // - one header line for the ntuple title.
13 // - one csv line for column names.
14 // - data at csv format.
15 
16 #include "rntuple"
17 
18 #include <istream>
19 #include <sstream>
20 
21 #include "vfind"
22 #include "vmanip"
23 #include "words"
24 #include "snums"
25 #include "sto"
26 #include "s2time"
27 #include "chars"
28 #include "strip"
29 #include "cids"
30 #include "ntuple_binding"
31 #include "sout"
32 #include "num2s"
33 //#include "srep"
34 
35 #ifdef TOOLS_MEM
36 #include "mem"
37 #endif
38 
39 namespace tools {
40 namespace rcsv {
41 
42 class ntuple : public virtual read::intuple {
43  typedef read::intuple parent;
44 public: //read::intuple
45  virtual void start() {
46  m_reader.clear();
47  m_reader.seekg(0,std::ios::beg);
48  if(m_hippo) {
51  }
52  }
53  virtual bool next() {
54  if(!m_sep) return false; //not inited.
55  if(m_reader.tellg()>=m_sz) return false;
56  // first time we are at bol but else we are at eol.
57  char c;
58  m_reader.get(c);
59  if(c==LF()){
60  if(m_reader.tellg()>=m_sz) {
61  //eof. Tell caller to stop looping on ntuple rows.
62  return false;
63  }
64  //eol. Next char read is going to be at bol.
65  } else {
66  m_reader.putback(c);
67  //bol
68  }
69  // ready for a new row :
70 
71  while(skip_comment(m_reader,m_sz)){}
72  if(m_reader.tellg()>=m_sz) return false;
73 
74  return _read_line();
75  }
76 
77  virtual read::icol* find_icol(const std::string& a_name){
78  return find_named<read::icol>(m_cols,a_name);
79  }
80 
81  virtual const std::vector<read::icol*>& columns() const {return m_cols;}
82 
83  virtual const std::string& title() const {return m_title;}
84 
85  virtual bool number_of_entries(tools::uint64 & a_value) const {
86  if(!m_sep) {a_value = 0;return false;} //not inited.
87  ntuple& self = const_cast<ntuple&>(*this);
88  if(m_rows==(-1)) {
89  self.m_rows = 0;
90  self.start();
91  while(self.next()) {self.m_rows++;}
92  }
93  a_value = (uint64)m_rows;
94  return true;
95  }
96 public:
97  template <class T>
98  class column : public virtual read::icolumn<T> {
99  typedef read::icolumn<T> parent;
100  public:
101  static cid id_class() {
102  static const T s_v = T(); //do that for T = std::string.
103  return 200+_cid(s_v);
104  }
105  public: //icol
106  virtual void* cast(cid a_class) const {
107  if(void* p = cmp_cast<column>(this,a_class)) {return p;}
108  return parent::cast(a_class);
109  }
110  virtual cid id_cls() const {return id_class();}
111  public: //icol
112  virtual const std::string& name() const {return m_name;}
113  virtual bool fetch_entry() const {
114  if(m_user_var) *m_user_var = m_tmp;
115  return true;
116  }
117  public: //icolumn<T>
118  virtual bool get_entry(T& a_v) const {
119  a_v = m_tmp;
120  return true;
121  }
122  public:
123  column(const std::string& a_name,T* a_user_var = 0)
124  :m_name(a_name)
125  ,m_tmp(T())
126  ,m_user_var(a_user_var) //not owner
127  {}
128  virtual ~column(){}
129  protected:
130  column(const column& a_from)
131  :read::icol(a_from)
132  ,parent(a_from)
133  ,m_name(a_from.m_name)
134  ,m_tmp(a_from.m_tmp)
135  ,m_user_var(a_from.m_user_var)
136  {}
137  column& operator=(const column& a_from){
138  m_name = a_from.m_name;
139  m_tmp = a_from.m_tmp;
140  m_user_var = a_from.m_user_var;
141  return *this;
142  }
143  public:
144  // should be used in ntuple _read_line only :
145  void set_value(const T& a_v){m_tmp = a_v;}
146  protected:
147  std::string m_name;
148  T m_tmp;
150  };
151 
152 #ifdef TOOLS_MEM
153 public:
154  static const std::string& s_class() {
155  static const std::string s_v("tools::rcsv::ntuple");
156  return s_v;
157  }
158 #endif
159 public:
160  ntuple(std::istream& a_reader)
161  :m_reader(a_reader)
162  ,m_title()
163  ,m_sep(0)
164  ,m_vec_sep(';')
165  ,m_sz(0)
166  ,m_rows(-1)
167  ,m_hippo(false)
168  {
169 #ifdef TOOLS_MEM
170  mem::increment(s_class().c_str());
171 #endif
172  }
173  virtual ~ntuple() {
174  safe_clear<read::icol>(m_cols);
175 #ifdef TOOLS_MEM
176  mem::decrement(s_class().c_str());
177 #endif
178  }
179 protected:
180  ntuple(const ntuple& a_from)
181  :parent(a_from)
182  ,m_reader(a_from.m_reader)
183  ,m_title(a_from.m_title)
184  ,m_sep(a_from.m_sep)
185  ,m_vec_sep(a_from.m_vec_sep)
186  ,m_sz(a_from.m_sz)
187  ,m_rows(-1)
188  ,m_hippo(a_from.m_hippo)
189  {
190 #ifdef TOOLS_MEM
191  mem::increment(s_class().c_str());
192 #endif
193  }
194  ntuple& operator=(const ntuple& a_from){
195  m_title = a_from.m_title;
196  m_sep = a_from.m_sep;
197  m_vec_sep = a_from.m_vec_sep;
198  m_hippo = a_from.m_hippo;
199  m_rows = a_from.m_rows;
200  return *this;
201  }
202 public:
203  void set_vec_sep(char a_c) {m_vec_sep = a_c;}
204  void set_sep(char a_c) {m_sep = a_c;}
205  void set_hippo(bool a_hippo) {m_hippo = a_hippo;}
206 
207  std::istream& istrm() {return m_reader;}
208 
209 /* use file::is_hippo for that.
210  static bool is_hippo(std::ostream& a_out,std::istream& a_reader) {
211  // analyse two first data line.
212 
213  a_reader.clear();
214  a_reader.seekg(0,std::ios::end);
215  std::streampos sz = a_reader.tellg();
216  a_reader.seekg(0,std::ios::beg);
217  if(!sz) {
218  a_out << "tools::rcsv::ntuple::is_hippo :"
219  << " stream is empty."
220  << std::endl;
221  return false;
222  } //file empty.
223 
224  std::string _title;
225  if(!read_line(a_reader,sz,_title)) return false;
226  std::string s;
227  if(!read_line(a_reader,sz,s)) return false;
228  if(s.find('\t')==std::string::npos) return false;
229 
230  //std::vector<std::string> labels;
231  //words(s,"\t",false,labels);
232  //return labels.size()?true:false;
233 
234  return true;
235  }
236 */
237  static bool find_sep(std::ostream& a_out,
238  std::istream& a_reader,bool a_hippo,
239  bool a_verbose,
240  char& a_sep){
241  // analyse first data line to find the char separator.
242 
243  a_reader.clear();
244  a_reader.seekg(0,std::ios::end);
245  std::streampos sz = a_reader.tellg();
246  a_reader.seekg(0,std::ios::beg);
247  if(!sz) {
248  a_out << "tools::rcsv::ntuple::find_sep :"
249  << " stream is empty."
250  << std::endl;
251  a_sep = 0;
252  return false;
253  } //file empty.
254  if(a_verbose) a_out << "file size " << sz << std::endl;
255 
256  if(a_hippo) { //skip first two lines :
257  if(!skip_line(a_reader,sz)) {a_sep = 0;return false;}
258  if(!skip_line(a_reader,sz)) {a_sep = 0;return false;}
259  } else {
260  while(skip_comment(a_reader,sz)){}
261  }
262  if(a_reader.tellg()>=sz) {a_sep=0;return false;} //no data line.
263 
264  // get first data line :
265  std::string sfirst;
266  {char c;
267  while(true) {
268  if(a_reader.tellg()>=sz) break;
269  a_reader.get(c);
270  if((c==CR())||(c==LF())) break;
271  sfirst += c;
272  }}
273  if(sfirst.empty()) {
274  a_out << "tools::rcsv::ntuple::find_set :"
275  << " first datat line is empty."
276  << std::endl;
277  a_sep = 0;
278  return false;
279  }
280  if(a_verbose) a_out << "first data line \"" << sfirst << "\"" << std::endl;
281 
282  //guess sep from first data line :
283  std::istringstream strm(sfirst.c_str());
284  double d;
285  strm >> d;
286  std::streampos pos = strm.tellg();
287  if(pos==std::streampos(-1)) {
288  a_out << "tools::rcsv::ntuple::find_sep :"
289  << " first line does not start with a number."
290  << std::endl;
291  a_sep = 0;
292  return false;
293  } //not a number.
294  if(a_verbose) a_out << "first number " << d
295  << " ending at pos " << pos << std::endl;
296  if(pos>=(std::streampos)sfirst.size()) {
297  a_out << "tools::rcsv::ntuple::find_sep :"
298  << " no separator found in first line."
299  << " pos " << pos
300  << " sfirst.size() " << sfirst.size()
301  << std::endl;
302  a_sep = 0;
303  return false;
304  } //no sep.
305 
306  strm.get(a_sep);
307 
308  return true;
309  }
310 
311 public:
312  bool initialize(std::ostream& a_out,
313  char a_sep = 0, //guessed
314  const std::string& a_suffix = "x", //col suffix
315  bool a_verbose = false) {
316  safe_clear<read::icol>(m_cols);
317  m_sep = 0;
318  m_sz = 0;
319  m_rows = -1;
320 
321  if(a_suffix.empty()) {
322  a_out << "tools::rcsv::ntuple::initialize : expect a column suffix." << std::endl;
323  return false;
324  }
325 
326  m_reader.clear();
327  m_reader.seekg(0,std::ios::end);
328  m_sz = m_reader.tellg();
329  m_reader.seekg(0,std::ios::beg);
330  if(!m_sz) {
331  a_out << "tools::rcsv::ntuple::initialize :"
332  << " stream is empty."
333  << std::endl;
334  return false; //file empty.
335  }
336  if(a_verbose) a_out << "file size " << m_sz << std::endl;
337 
338  std::vector<std::string> labels;
339  if(m_hippo) { //skip first two lines :
340  std::string _title;
341  if(!read_line(m_reader,m_sz,_title)) {
342  a_out << "tools::rcsv::ntuple::initialize : read_line() failed." << std::endl;
343  m_sz = 0;
344  m_rows = -1;
345  return false;
346  }
347  std::string s;
348  if(!read_line(m_reader,m_sz,s)) {
349  a_out << "tools::rcsv::ntuple::initialize : (2) read_line() failed." << std::endl;
350  m_sz = 0;
351  m_rows = -1;
352  return false;
353  }
354  words(s,"\t",false,labels); //false for glast.tnt that has a trailing \t.
355  } else {
356  while(skip_comment(m_reader,m_sz)){}
357  }
358  if(m_reader.tellg()>=m_sz) {
359  a_out << "tools::rcsv::ntuple::initialize : tellg() >= sz." << std::endl;
360  m_sz = 0;
361  m_rows = -1;
362  return false;
363  }
364 
365  // get first data line :
366  std::string sfirst;
367  {{char c;
368  while(true) {
369  if(m_reader.tellg()>=m_sz) break;
370  m_reader.get(c);
371  if((c==CR())||(c==LF())) break;
372  sfirst += c;
373  }}
374  if(sfirst.empty()) {
375  a_out << "tools::rcsv::ntuple::initialize :"
376  << " first datat line is empty."
377  << std::endl;
378  m_sz = 0;
379  m_rows = -1;
380  return false;
381  }}
382  if(a_verbose) a_out << "first data line \"" << sfirst << "\"" << std::endl;
383 
384  if(a_sep) {
385  m_sep = a_sep;
386  } else {
387  //guess sep from first data line :
388  std::istringstream strm(sfirst.c_str());
389  double d;
390  strm >> d;
391  std::streampos pos = strm.tellg();
392  if(pos==std::streampos(-1)) {
393  a_out << "tools::rcsv::ntuple::initialize :"
394  << " first line does not start with a number."
395  << std::endl;
396  m_sz = 0;
397  m_rows = -1;
398  return false;
399  }
400  if(a_verbose) a_out << "first number " << d << " ending at pos " << pos << std::endl;
401  if(pos>=(std::streampos)sfirst.size()) {
402  a_out << "tools::rcsv::ntuple::initialize :"
403  << " no separator found in first line."
404  << std::endl;
405  m_sz = 0;
406  m_rows = -1;
407  return false;
408  }
409  strm.get(m_sep);
410  }
411  if(a_verbose) a_out << "sep " << (int)m_sep << std::endl;
412 
413  // in case sep is ' ', there is an ambiguity with some leading
414  // space in front of first number.
415  if(m_sep==' ') strip(sfirst,leading,' ');
416 
417  std::vector<std::string> ws;
418  {std::string sep;
419  sep += m_sep;
420  words(sfirst,sep,m_hippo?false:true,ws);}
421 
422  // look if words are numbers :
423  if(a_verbose) a_out << "words " << ws.size() << std::endl;
424  unsigned int index = 0;
425  std::vector<std::string>::iterator it;
426  for(it=ws.begin();it!=ws.end();++it,index++) {
427  if(a_verbose) a_out << "word " << sout(*it) << "" << std::endl;
428 /* with glast.tnt there is trailing \t that will induce an extra empty column.
429  if((*it).empty()) {
430  // do not accept :
431  // <num><sep><num><sep><sep><num>...
432  // but accept a trailing <sep> (glast.tnt) :
433  // <num><sep><num>....<sep><num><sep>
434  if(index==(ws.size()-1)) {
435  break;
436  } else {
437  a_out << "tools::rcsv::ntuple::initialize :"
438  << " empty word."
439  << std::endl;
440  safe_clear<read::icol>(m_cols);
441  m_sep = 0;
442  m_sz = 0;
443  m_rows = -1;
444  return false;
445  }
446  }
447 */
448  std::string name = a_suffix;
449  if(!numas<uint64>(m_cols.size(),name)){}
450  if(m_hippo) {
451  if(index>=labels.size()) {
452  a_out << "tools::rcsv::ntuple::initialize :"
453  << " warning : not enough labels."
454  << std::endl;
455  } else {
456  name = labels[index];
457  }
458  }
459  double d;
460  if(to<double>(*it,d)) {
461  if(a_verbose) a_out << "number " << d << std::endl;
462  create_column<double>(name);
463  } else {
464  time_t time;
465  if(s2time(*it,time)) {
466  create_column<csv_time>(name);
467  } else {
468  std::vector<double> v;
469  std::string vec_sep;vec_sep += m_vec_sep;
470  if(snums<double>(*it,vec_sep,v)&&v.size()) {
471  create_column< std::vector<double> >(name);
472  } else {
473  create_column<std::string>(name);
474  }
475  }
476  }
477  }
478  size_t num = m_cols.size();
479  if(!num) {
480  a_out << "tools::rcsv::ntuple::initialize :"
481  << " zero columns."
482  << std::endl;
483  m_sep = 0;
484  m_sz = 0;
485  m_rows = -1;
486  return false;
487  }
488 
489  return true;
490  }
491 
492  static const std::string& s_cid(cid a_id) {
493 
494 #define TOOLS_RCSV_NTUPLE_IF_CID(a__name,a__type) \
495  if(a_id==column<a__type>::id_class()) {\
496  static const std::string s_v(#a__name);\
497  return s_v;\
498  }
499 
500 #define TOOLS_RCSV_NTUPLE_IF_VEC_CID(a__name,a__type) \
501  if(a_id==column< std::vector<a__type> >::id_class()) {\
502  static const std::string s_v(#a__name+std::string("[]"));\
503  return s_v;\
504  }
505 
506  TOOLS_RCSV_NTUPLE_IF_CID(char,char)
507  else TOOLS_RCSV_NTUPLE_IF_CID(short,short)
508  else TOOLS_RCSV_NTUPLE_IF_CID(int,int)
510 
511  else TOOLS_RCSV_NTUPLE_IF_CID(float,float)
512  else TOOLS_RCSV_NTUPLE_IF_CID(double,double)
513 
516  else TOOLS_RCSV_NTUPLE_IF_CID(uint,uint32) //WARNING
518 
519  else TOOLS_RCSV_NTUPLE_IF_CID(bool,bool)
520  else if(a_id==column<std::string>::id_class()) {
521  static const std::string s_v("string");
522  return s_v;
523  }
524 
525  else if(a_id==column<csv_time>::id_class()) {
526  static const std::string s_v("time");
527  return s_v;
528  }
529 
530  else TOOLS_RCSV_NTUPLE_IF_VEC_CID(char,char)
531  else TOOLS_RCSV_NTUPLE_IF_VEC_CID(short,short)
532  else TOOLS_RCSV_NTUPLE_IF_VEC_CID(int,int)
534 
535  else TOOLS_RCSV_NTUPLE_IF_VEC_CID(float,float)
536  else TOOLS_RCSV_NTUPLE_IF_VEC_CID(double,double)
537 
540  else TOOLS_RCSV_NTUPLE_IF_VEC_CID(uint,uint32) //WARNING
542 
543  else TOOLS_RCSV_NTUPLE_IF_VEC_CID(bool,bool)
544  else if(a_id==column< std::vector<std::string> >::id_class()) {
545  static const std::string s_v("string[]");
546  return s_v;
547  }
548 
549 #undef TOOLS_RCSV_NTUPLE_IF_CID
550 #undef TOOLS_RCSV_NTUPLE_IF_VEC_CID
551 
552  else {
553  static const std::string s_v("unknown");
554  return s_v;
555  }
556  }
557 
558  void dump_columns(std::ostream& a_out) const {
559  if((m_sep>=32)&&(m_sep<=126)) { //printable
560  a_out << "separator is '" << m_sep << "'" << std::endl;
561  } else {
562  a_out << "separator is " << (unsigned int)m_sep << std::endl;
563  }
564  a_out << "number of columns " << m_cols.size() << std::endl;
565  std::vector<read::icol*>::const_iterator it;
566  for(it=m_cols.begin();it!=m_cols.end();++it) {
567  a_out << sout((*it)->name())
568  << " " << s_cid((*it)->id_cls())
569  << std::endl;
570  }
571  }
572 public:
573  typedef std::pair<std::string,std::string> col_desc;
574 
575  bool initialize(std::ostream& a_out,const ntuple_binding& a_bd = ntuple_binding()) {
576  // it assumes a "commented header".
577 
578  safe_clear<read::icol>(m_cols);
579  m_sep = 0;
580  m_sz = 0;
581  m_rows = -1;
582  m_hippo = false;
583 
584  m_reader.clear();
585  m_reader.seekg(0,std::ios::end);
586  m_sz = m_reader.tellg();
587  m_reader.seekg(0,std::ios::beg);
588  if(!m_sz) {
589  a_out << "tools::rcsv::ntuple::initialize(booking) :"
590  << " stream is empty."
591  << std::endl;
592  return false; //file empty.
593  }
594  //if(a_verbose) a_out << "file size " << m_sz << std::endl;
595 
596  std::string _title;
597  char _sep,_vec_sep;
598  std::vector<col_desc> _cols;
599  if(!read_commented_header(a_out,m_reader,_title,_sep,_vec_sep,_cols)) return false;
600 
601  m_sep = _sep;
602  m_title = _title;
603 
604  tools_vforcit(col_desc,_cols,it) {
605  const std::string& type = (*it).first;
606  const std::string& name = (*it).second;
607 
608 #define TOOLS_RCSV_NTUPLE_CREATE_VEC_COL(a__name,a__type) \
609  if(type==(std::string(#a__name)+"[]")) {\
610  create_column< std::vector<a__type> >(name,a_bd.find_variable< std::vector<a__type> >(name));\
611  }
612 
613  // see cid2s() for string types.
614 
615  if(type=="char") create_column<char>(name,a_bd.find_variable<char>(name));
616  else if(type=="short") create_column<short>(name,a_bd.find_variable<short>(name));
617  else if(type=="int") create_column<int>(name,a_bd.find_variable<int>(name));
618  else if(type=="float") create_column<float>(name,a_bd.find_variable<float>(name));
619  else if(type=="double") create_column<double>(name,a_bd.find_variable<double>(name));
620  else if(type=="string") create_column<std::string>(name,a_bd.find_variable<std::string>(name));
621 
622  else if(type=="uchar") create_column<unsigned char>(name,a_bd.find_variable<unsigned char>(name));
623  else if(type=="ushort") create_column<unsigned short>(name,a_bd.find_variable<unsigned short>(name));
624  else if(type=="uint") create_column<uint32>(name,a_bd.find_variable<uint32>(name)); //WARNING
625  else if(type=="bool") create_column<bool>(name,a_bd.find_variable<bool>(name));
626  else if(type=="int64") create_column<int64>(name,a_bd.find_variable<int64>(name));
627  else if(type=="uint64") create_column<uint64>(name,a_bd.find_variable<uint64>(name));
628 
629  else TOOLS_RCSV_NTUPLE_CREATE_VEC_COL(char,char)
630  else TOOLS_RCSV_NTUPLE_CREATE_VEC_COL(short,short)
632  else TOOLS_RCSV_NTUPLE_CREATE_VEC_COL(float,float)
633  else TOOLS_RCSV_NTUPLE_CREATE_VEC_COL(double,double)
634 
635  else if(type=="string[]") create_column< std::vector<std::string> >(name,a_bd.find_variable< std::vector<std::string> >(name));
636 
639  else TOOLS_RCSV_NTUPLE_CREATE_VEC_COL(uint,uint32) //WARNING
640  else TOOLS_RCSV_NTUPLE_CREATE_VEC_COL(bool,bool)
643 
644  else {
645  a_out << "tools::rcsv::ntuple::initialize(booking) :"
646  << " unhandled column type " << sout(type)
647  << std::endl;
648  safe_clear<read::icol>(m_cols);
649  m_sep = 0;
650  m_sz = 0;
651  m_rows = -1;
652  m_hippo = false;
653  return false;
654  }
655 
656 #undef TOOLS_RCSV_NTUPLE_CREATE_VEC_COL
657 
658  }
659 
660  size_t num = m_cols.size();
661  if(!num) {
662  a_out << "tools::rcsv::ntuple::initialize(booking) :"
663  << " zero columns."
664  << std::endl;
665  return false;
666  }
667 
668  //a_out << "tools::rroot::ntuple::initialize :"
669  // << " number of columns " << num << "."
670  // << std::endl;
671 
672  return true;
673  }
674 
675  bool initialize_from_commented_header(std::ostream& a_out) { // it assumes a "commented header".
676  std::string _title;
677  char _sep,_vec_sep;
678  std::vector<col_desc> _cols;
679  if(!read_commented_header(a_out,m_reader,_title,_sep,_vec_sep,_cols)) return false;
680  ntuple_binding nbd;
681  {tools_vforcit(col_desc,_cols,it) nbd.add_column_no_var((*it).second);} //user_var is 0.
682  return initialize(a_out,nbd);
683  }
684 
685  bool get_row() const {
686  bool status = true;
688  if(!(*it)->fetch_entry()) status = false;
689  }
690  return status;
691  }
692 
693 protected:
694  bool read_commented_header(std::ostream& a_out,std::istream& a_reader,
695  std::string& a_title,char& a_sep,char& a_vec_sep,std::vector<col_desc>& a_cols) {
696  // analyse first lines starting with '#'.
697  a_title.clear();
698  a_sep = 0;
699  a_cols.clear();
700 
701  a_reader.clear();
702  a_reader.seekg(0,std::ios::end);
703  std::streampos sz = a_reader.tellg();
704  a_reader.seekg(0,std::ios::beg);
705  if(!sz) {
706  a_out << "tools::rcsv::ntuple::read_commented_header :"
707  << " stream is empty."
708  << std::endl;
709  return false;
710  } //file empty.
711 
712 
713  std::string _class;
714 
715  while(true) {
716  if(a_reader.tellg()>=sz) break;
717  //we should be at bol :
718  char c;
719  a_reader.get(c);
720  a_reader.putback(c);
721  if(c!='#') break; //finished, probably a data line now.
722  std::string line;
723  if(!read_line(a_reader,sz,line)) break; //or return false ?
724 
725  std::vector<std::string> _words;
726  words(line," ",false,_words);
727  if(!_words.size()) {
728  a_out << "tools::rcsv::ntuple::read_commented_header :"
729  << " syntax error : empty header line."
730  << std::endl;
731  return false;
732  }
733  if((_words[0]=="#class")) {
734  if(_words.size()!=2) {
735  a_out << "tools::rcsv::ntuple::read_commented_header :"
736  << " syntax error in " << sout(line)
737  << std::endl;
738  return false;
739  }
740  _class = _words[1];
741  } else if(_words[0]=="#title") {
742  if(_words.size()<1) {
743  a_out << "tools::rcsv::ntuple::read_commented_header :"
744  << " syntax error in " << sout(line)
745  << std::endl;
746  return false;
747  }
748  if(_words.size()==1) {
749  a_title.clear();
750  } else {
751  std::string::size_type pos = line.find(_words[0]);
752  pos += _words[0].size()+1;
753  a_title = line.substr(pos,line.size()-pos);
754  }
755  } else if((_words[0]=="#separator")) {
756  if(_words.size()!=2) {
757  a_out << "tools::rcsv::ntuple::read_commented_header :"
758  << " syntax error in " << sout(line)
759  << std::endl;
760  return false;
761  }
762  unsigned int uisep;
763  if(!to(_words[1],uisep)) {
764  a_out << "tools::rcsv::ntuple::read_commented_header :"
765  << " syntax error in " << sout(line)
766  << std::endl;
767  return false;
768  }
769  a_sep = (char)uisep;
770  } else if((_words[0]=="#vector_separator")) {
771  if(_words.size()!=2) {
772  a_out << "tools::rcsv::ntuple::read_commented_header :"
773  << " syntax error in " << sout(line)
774  << std::endl;
775  return false;
776  }
777  unsigned int uisep;
778  if(!to(_words[1],uisep)) {
779  a_out << "tools::rcsv::ntuple::read_commented_header :"
780  << " syntax error in " << sout(line)
781  << std::endl;
782  return false;
783  }
784  a_vec_sep = (char)uisep;
785  } else if((_words[0]=="#column")) {
786  if(_words.size()<2) {
787  a_out << "tools::rcsv::ntuple::read_commented_header :"
788  << " syntax error in " << sout(line)
789  << std::endl;
790  return false;
791  }
792  std::string stype = _words[1];
793  std::string label;
794  if(_words.size()==2) {
795  label.clear();
796  } else {
797  std::string::size_type pos = line.find(_words[1]);
798  pos += _words[1].size()+1;
799  label = line.substr(pos,line.size()-pos);
800  }
801  //a_out << "column " << stype << " " << sout(label) << std::endl;
802  a_cols.push_back(col_desc(stype,label));
803  } else {
804  a_out << "tools::rcsv::ntuple::read_commented_header :"
805  << " syntax error in " << sout(line)
806  << ", unknown keyword " << sout(_words[0])
807  << std::endl;
808  //return false;
809  }
810  }
811 
812 /*
813  a_out << "class " << _class << std::endl;
814  a_out << "title " << _title << std::endl;
815  a_out << "separator " << _separator << std::endl;
816 */
817 
818  return true;
819  }
820 
821 protected:
822  template <class T>
823  column<T>* create_column(const std::string& a_name,T* a_user_var = 0){
824  if(find_named<read::icol>(m_cols,a_name)) return 0;
825  column<T>* col = new column<T>(a_name,a_user_var);
826  if(!col) return 0;
827  m_cols.push_back(col);
828  return col;
829  }
830 
831 protected:
832  static bool read_line(std::istream& a_reader,std::streampos a_sz,std::string& a_s){
833  a_s.clear();
834  char c;
835  while(true) {
836  if(a_reader.tellg()>=a_sz) {a_s.clear();return false;}
837  a_reader.get(c);
838  if(c==CR()) continue;
839  if(c==LF()) break; //eol.
840  a_s += c;
841  }
842  return true;
843  }
844 
845  static bool skip_line(std::istream& a_reader,std::streampos a_sz){
846  char c;
847  while(true) {
848  if(a_reader.tellg()>=a_sz) return false;
849  a_reader.get(c);
850  if(c==LF()) break;
851  }
852  return true;
853  }
854 
855  static bool skip_comment(std::istream& a_reader,std::streampos a_sz){
856  //ret true = we had a commented line, false : a data line or nothing.
857  if(a_reader.tellg()>=a_sz) return false;
858  //we should be at bol :
859  char c;
860  a_reader.get(c);
861  if(c=='#') {
862  return skip_line(a_reader,a_sz);
863  //eol. Next char should be bol.
864  } else {
865  a_reader.putback(c);
866  return false;
867  }
868  }
869 
870  template <class T>
871  static bool _read(std::istream& a_reader,std::streampos,char,T& a_v) {
872  a_reader >> a_v;
873  if(a_reader.tellg()==std::streampos(-1)) {a_v = 0;return false;}
874  //std::cout << "debug : _read(double) " << a_v << std::endl;
875  return true;
876  }
877  static bool _read_time(std::istream& a_reader,std::streampos a_sz,char a_sep,time_t& a_v) {
878  std::string s;
879  char c;
880  while(true){
881  if(a_reader.tellg()>=a_sz) break;
882  a_reader.get(c);
883  if((c==a_sep)||(c==CR())||(c==LF())) {
884  a_reader.putback(c);
885  break;
886  }
887  s += c;
888  }
889  if(!s2time(s,a_v)) return false;
890  return true;
891  }
892  static bool _read(std::istream& a_reader,std::streampos a_sz,char a_sep,std::string& a_v) {
893  a_v.clear();
894  char c;
895  while(true){
896  if(a_reader.tellg()>=a_sz) break;
897  a_reader.get(c);
898  if((c==a_sep)||(c==CR())||(c==LF())) {
899  a_reader.putback(c);
900  break;
901  }
902  a_v += c;
903  }
904  return true;
905  }
906 
907  static bool _vec_read(std::istream& a_reader,std::streampos a_sz,
908  std::istringstream&,std::vector<std::string>&,
909  char a_sep,const std::string& a_vec_sep,
910  std::vector<std::string>& a_v) {
911  std::string _s;
912  if(!_read(a_reader,a_sz,a_sep,_s)) return false;
913  //replace(_s,"\\"+a_vec_sep,"@@");
914  words(_s,a_vec_sep,true,a_v);
915  //tools_vforit(std::string,a_v,it) replace(*it,"@@",a_vec_sep);
916  return true;
917  }
918 
919  template <class T>
920  static bool _vec_read(std::istream& a_reader,std::streampos a_sz,
921  std::istringstream& a_iss,std::vector<std::string>& a_tmp,
922  char a_sep,const std::string& a_vec_sep,
923  std::vector<T>& a_v) {
924  std::string _s;
925  if(!_read(a_reader,a_sz,a_sep,_s)) return false;
926  if(!snums<T>(_s,a_iss,a_tmp,a_vec_sep,a_v)) return false;
927  return true;
928  }
929 
930 protected:
931  bool _read_line() {
932  // have to loop on all columns !
933  typedef read::icol icol_t;
934 
935  typedef ntuple::column<char> col_char;
936  typedef ntuple::column<short> col_short;
937  typedef ntuple::column<int> col_int;
938  typedef ntuple::column<float> col_float;
939  typedef ntuple::column<double> col_double;
940  typedef std::string string_t;
941  typedef ntuple::column<string_t> col_string_t;
942 
943  typedef ntuple::column<uchar> col_uchar;
944  typedef ntuple::column<ushort> col_ushort;
945  typedef ntuple::column<uint32> col_uint32;
946  typedef ntuple::column<bool> col_bool;
947  typedef ntuple::column<int64> col_int64;
948  typedef ntuple::column<uint64> col_uint64;
949 
950  typedef ntuple::column<csv_time> col_time;
951 
952  typedef ntuple::column< std::vector<char> > col_vec_char;
953  typedef ntuple::column< std::vector<short> > col_vec_short;
954  typedef ntuple::column< std::vector<int32> > col_vec_int;
955  typedef ntuple::column< std::vector<float> > col_vec_float;
956  typedef ntuple::column< std::vector<double> > col_vec_double;
957  typedef ntuple::column< std::vector<std::string> > col_vec_string_t;
958 
959  typedef ntuple::column< std::vector<uchar> > col_vec_uchar;
960  typedef ntuple::column< std::vector<ushort> > col_vec_ushort;
961  typedef ntuple::column< std::vector<uint32> > col_vec_uint32;
962  typedef ntuple::column< std::vector<bool> > col_vec_bool;
963  typedef ntuple::column< std::vector<int64> > col_vec_int64;
964  typedef ntuple::column< std::vector<uint64> > col_vec_uint64;
965 
966  std::string vec_sep;vec_sep += m_vec_sep;
967  std::istringstream iss;
968  std::vector<std::string> tmp;
969 
970  size_t index = 0;
971  size_t num = m_cols.size();
972  std::vector<icol_t*>::const_iterator it;
973  for(it=m_cols.begin();it!=m_cols.end();++it,index++) {
974 
975 #define TOOLS_RCSV_NTUPLE_IF_COL(a__type) \
976  if(col_##a__type* _col_##a__type = id_cast<icol_t,col_##a__type>(*(*it))) {\
977  a__type v;\
978  if(!_read(m_reader,m_sz,m_sep,v)) return false;\
979  _col_##a__type->set_value(v);\
980  }
981 
982 #define TOOLS_RCSV_NTUPLE_IF_VEC_COL(a__type) \
983  if(col_vec_##a__type* _col_vec_##a__type = id_cast<icol_t,col_vec_##a__type>(*(*it))) {\
984  std::vector<a__type> v;\
985  if(!_vec_read(m_reader,m_sz,iss,tmp,m_sep,vec_sep,v)) return false;\
986  _col_vec_##a__type->set_value(v);\
987  }
988 
990  else TOOLS_RCSV_NTUPLE_IF_COL(short)
991  else TOOLS_RCSV_NTUPLE_IF_COL(int)
992  else TOOLS_RCSV_NTUPLE_IF_COL(float)
993  else TOOLS_RCSV_NTUPLE_IF_COL(double)
994  else TOOLS_RCSV_NTUPLE_IF_COL(string_t)
995 
999  else TOOLS_RCSV_NTUPLE_IF_COL(bool)
1002 
1003  else if(col_time* _col_time = id_cast<icol_t,col_time>(*(*it))) {
1004  time_t v;
1005  if(!_read_time(m_reader,m_sz,m_sep,v)) return false;
1006  csv_time ct;ct.m_l = long(v);
1007  _col_time->set_value(ct);
1008  }
1009 
1010  else TOOLS_RCSV_NTUPLE_IF_VEC_COL(char)
1011  else TOOLS_RCSV_NTUPLE_IF_VEC_COL(short)
1013  else TOOLS_RCSV_NTUPLE_IF_VEC_COL(float)
1014  else TOOLS_RCSV_NTUPLE_IF_VEC_COL(double)
1015  else TOOLS_RCSV_NTUPLE_IF_VEC_COL(string_t)
1016 
1020  else TOOLS_RCSV_NTUPLE_IF_VEC_COL(bool)
1023 
1024 #undef TOOLS_RCSV_NTUPLE_IF_COL
1025 #undef TOOLS_RCSV_NTUPLE_IF_VEC_COL
1026 
1027  else {
1028  //std::cout << "column cast failed." << std::endl;
1029  return false;
1030  }
1031 
1032  if(index==(num-1)) { //read up to LF()
1033  char c;
1034  while(true){
1035  if(m_reader.tellg()>=m_sz) break;
1036  m_reader.get(c);
1037  if(c==LF()) break;
1038  }
1039  } else { //read sep :
1040  char sep;
1041  m_reader.get(sep);
1042  }
1043  }
1044  return true;
1045  }
1046 protected:
1047  std::istream& m_reader;
1048  std::string m_title;
1049  char m_sep;
1051  std::vector<read::icol*> m_cols;
1052  std::streampos m_sz;
1053  int m_rows; //to optimize number_of_entries().
1054  bool m_hippo;
1055 };
1056 
1057 }}
1058 
1059 
1060 #include <fstream>
1061 
1062 namespace tools {
1063 namespace rcsv {
1064 
1065 class fntuple : public ntuple {
1066  typedef ntuple parent;
1067 public:
1068  static const std::string& s_class() {
1069  static const std::string s_v("tools::rcsv::fntuple");
1070  return s_v;
1071  }
1072 public:
1073  fntuple(const std::string& a_file)
1074  :parent(m_freader)
1075  ,m_file(a_file)
1076  {}
1077  virtual ~fntuple() {m_freader.close();}
1078 protected:
1079  fntuple(const fntuple& a_from)
1080  :read::intuple(a_from)
1081  ,parent(a_from)
1082  ,m_file(a_from.m_file)
1083  {}
1084  fntuple& operator=(const fntuple& a_from){
1085  parent::operator=(a_from);
1086  m_file = a_from.m_file;
1087  return *this;
1088  }
1089 public:
1090  bool open(){
1091  m_freader.open(m_file.c_str());
1092  return m_freader.fail()?false:true;
1093  }
1094  bool initialize(std::ostream& a_out,
1095  char a_sep = 0, //guessed
1096  const std::string& a_suffix = "x", //col suffix
1097  bool a_verbose = false) {
1098  if(!m_freader.is_open()) {
1099  m_freader.open(m_file.c_str());
1100  if(m_freader.fail()) {
1101  a_out << "tools::rcsv::fntuple::initialize :"
1102  << " can't open " << m_file << "."
1103  << std::endl;
1104  return false;
1105  }
1106  }
1107  return parent::initialize(a_out,a_sep,a_suffix,a_verbose);
1108  }
1109 protected:
1110  std::string m_file;
1111  std::ifstream m_freader;
1112 };
1113 
1114 }}
1115 
1116 #endif
TOOLS_RCSV_NTUPLE_IF_VEC_COL
#define TOOLS_RCSV_NTUPLE_IF_VEC_COL(a__type)
tools::read::intuple
Definition: rntuple:55
tools::read::intuple::s_class
static const std::string & s_class()
Definition: rntuple:57
tools::rcsv::ntuple::column::get_entry
virtual bool get_entry(T &a_v) const
Definition: rcsv_ntuple:118
tools::rcsv::ntuple::m_cols
std::vector< read::icol * > m_cols
Definition: rcsv_ntuple:1051
tools::uint64
unsigned long long uint64
Definition: typedefs:72
tools::rcsv::ntuple::find_sep
static bool find_sep(std::ostream &a_out, std::istream &a_reader, bool a_hippo, bool a_verbose, char &a_sep)
Definition: rcsv_ntuple:237
tools::int64
long long int64
Definition: typedefs:67
tools::rcsv::ntuple::m_rows
int m_rows
Definition: rcsv_ntuple:1053
tools::leading
@ leading
Definition: strip:12
tools::_cid
cid _cid(byte)
Definition: cids:14
tools::rcsv::ntuple::set_vec_sep
void set_vec_sep(char a_c)
Definition: rcsv_ntuple:203
tools::rcsv::fntuple::s_class
static const std::string & s_class()
Definition: rcsv_ntuple:1068
tools::rcsv::ntuple::column::m_user_var
T * m_user_var
Definition: rcsv_ntuple:149
tools::rcsv::ntuple::m_hippo
bool m_hippo
Definition: rcsv_ntuple:1054
tools::csv_time
Definition: typedefs:108
tools::rcsv::ntuple::next
virtual bool next()
Definition: rcsv_ntuple:53
tools::ntuple_binding::add_column_no_var
void add_column_no_var(const std::string &a_name)
Definition: ntuple_binding:83
num2s
tools::rcsv::ntuple::column::operator=
column & operator=(const column &a_from)
Definition: rcsv_ntuple:137
tools::ntuple_binding
Definition: ntuple_binding:48
tools::rcsv::ntuple::col_desc
std::pair< std::string, std::string > col_desc
Definition: rcsv_ntuple:573
tools::rcsv::ntuple::m_sep
char m_sep
Definition: rcsv_ntuple:1049
tools::rcsv::ntuple::find_icol
virtual read::icol * find_icol(const std::string &a_name)
Definition: rcsv_ntuple:77
tools::rcsv::ntuple::column::~column
virtual ~column()
Definition: rcsv_ntuple:128
tools::rcsv::ntuple
Definition: rcsv_ntuple:42
tools::rcsv::ntuple::_read_line
bool _read_line()
Definition: rcsv_ntuple:931
TOOLS_RCSV_NTUPLE_IF_COL
#define TOOLS_RCSV_NTUPLE_IF_COL(a__type)
s2time
tools::rcsv::ntuple::ntuple
ntuple(std::istream &a_reader)
Definition: rcsv_ntuple:160
tools::rcsv::ntuple::_vec_read
static bool _vec_read(std::istream &a_reader, std::streampos a_sz, std::istringstream &, std::vector< std::string > &, char a_sep, const std::string &a_vec_sep, std::vector< std::string > &a_v)
Definition: rcsv_ntuple:907
tools::rcsv::ntuple::dump_columns
void dump_columns(std::ostream &a_out) const
Definition: rcsv_ntuple:558
tools::rcsv::ntuple::column::id_cls
virtual cid id_cls() const
Definition: rcsv_ntuple:110
vfind
tools::read::icol
Definition: rntuple:21
tools::rcsv::ntuple::column::name
virtual const std::string & name() const
Definition: rcsv_ntuple:112
tools::rcsv::ntuple::column::set_value
void set_value(const T &a_v)
Definition: rcsv_ntuple:145
tools::rcsv::ntuple::set_sep
void set_sep(char a_c)
Definition: rcsv_ntuple:204
tools::rcsv::fntuple::fntuple
fntuple(const fntuple &a_from)
Definition: rcsv_ntuple:1079
tools::rcsv::ntuple::column::m_name
std::string m_name
Definition: rcsv_ntuple:147
tools::rcsv::ntuple::column::column
column(const column &a_from)
Definition: rcsv_ntuple:130
strip
ntuple_binding
tools::rcsv::fntuple::fntuple
fntuple(const std::string &a_file)
Definition: rcsv_ntuple:1073
chars
tools::rcsv::fntuple::initialize
bool initialize(std::ostream &a_out, char a_sep=0, const std::string &a_suffix="x", bool a_verbose=false)
Definition: rcsv_ntuple:1094
TOOLS_RCSV_NTUPLE_CREATE_VEC_COL
#define TOOLS_RCSV_NTUPLE_CREATE_VEC_COL(a__name, a__type)
tools::rcsv::ntuple::_read_time
static bool _read_time(std::istream &a_reader, std::streampos a_sz, char a_sep, time_t &a_v)
Definition: rcsv_ntuple:877
tools::rcsv::ntuple::~ntuple
virtual ~ntuple()
Definition: rcsv_ntuple:173
mem
rntuple
tools::rcsv::ntuple::s_cid
static const std::string & s_cid(cid a_id)
Definition: rcsv_ntuple:492
tools::read::icolumn::cast
virtual void * cast(cid a_class) const
Definition: rntuple:44
tools::rcsv::ntuple::m_vec_sep
char m_vec_sep
Definition: rcsv_ntuple:1050
tools::file::read
bool read(FILE *a_FILE, std::vector< std::string > &a_text)
Definition: file:89
tools::rcsv::fntuple::operator=
fntuple & operator=(const fntuple &a_from)
Definition: rcsv_ntuple:1084
tools::uchar
unsigned char uchar
Definition: typedefs:99
sto
tools::sout
Definition: sout:17
tools::rcsv::fntuple
Definition: rcsv_ntuple:1065
TOOLS_RCSV_NTUPLE_IF_VEC_CID
#define TOOLS_RCSV_NTUPLE_IF_VEC_CID(a__name, a__type)
tools::rcsv::ntuple::initialize
bool initialize(std::ostream &a_out, char a_sep=0, const std::string &a_suffix="x", bool a_verbose=false)
Definition: rcsv_ntuple:312
tools::rcsv::ntuple::_vec_read
static bool _vec_read(std::istream &a_reader, std::streampos a_sz, std::istringstream &a_iss, std::vector< std::string > &a_tmp, char a_sep, const std::string &a_vec_sep, std::vector< T > &a_v)
Definition: rcsv_ntuple:920
snums
tools::to
std::vector< std::string > to(int a_argc, char **a_argv)
Definition: args:507
tools::rcsv::ntuple::get_row
bool get_row() const
Definition: rcsv_ntuple:685
tools::csv_time::m_l
long m_l
Definition: typedefs:108
tools::rcsv::fntuple::m_file
std::string m_file
Definition: rcsv_ntuple:1110
tools::rcsv::fntuple::open
bool open()
Definition: rcsv_ntuple:1090
tools::CR
char CR()
Definition: chars:17
tools::rcsv::ntuple::skip_comment
static bool skip_comment(std::istream &a_reader, std::streampos a_sz)
Definition: rcsv_ntuple:855
tools
inlined C code : ///////////////////////////////////
Definition: aida_ntuple:26
vmanip
tools::rcsv::ntuple::m_sz
std::streampos m_sz
Definition: rcsv_ntuple:1052
tools::words
void words(const std::string &a_string, const std::string &a_sep, bool a_take_empty, std::vector< std::string > &a_words, bool a_clear=true)
Definition: words:12
tools::rcsv::ntuple::number_of_entries
virtual bool number_of_entries(tools::uint64 &a_value) const
Definition: rcsv_ntuple:85
tools::rcsv::ntuple::read_commented_header
bool read_commented_header(std::ostream &a_out, std::istream &a_reader, std::string &a_title, char &a_sep, char &a_vec_sep, std::vector< col_desc > &a_cols)
Definition: rcsv_ntuple:694
words
tools::rcsv::ntuple::start
virtual void start()
Definition: rcsv_ntuple:45
tools::waxml::end
void end(std::ostream &a_writer)
Definition: begend:31
tools::rcsv::ntuple::title
virtual const std::string & title() const
Definition: rcsv_ntuple:83
tools::rcsv::ntuple::column
Definition: rcsv_ntuple:98
tools::s2time
bool s2time(const std::string &a_string, time_t &a_time)
Definition: s2time:13
tools::rcsv::ntuple::_read
static bool _read(std::istream &a_reader, std::streampos a_sz, char a_sep, std::string &a_v)
Definition: rcsv_ntuple:892
tools::rcsv::ntuple::column::id_class
static cid id_class()
Definition: rcsv_ntuple:101
tools::rcsv::ntuple::istrm
std::istream & istrm()
Definition: rcsv_ntuple:207
tools::rcsv::ntuple::m_title
std::string m_title
Definition: rcsv_ntuple:1048
tools::rcsv::ntuple::set_hippo
void set_hippo(bool a_hippo)
Definition: rcsv_ntuple:205
tools::rcsv::fntuple::~fntuple
virtual ~fntuple()
Definition: rcsv_ntuple:1077
tools::rcsv::ntuple::skip_line
static bool skip_line(std::istream &a_reader, std::streampos a_sz)
Definition: rcsv_ntuple:845
tools::rcsv::ntuple::create_column
column< T > * create_column(const std::string &a_name, T *a_user_var=0)
Definition: rcsv_ntuple:823
tools::strip
bool strip(std::string &a_string, what a_type=both, char a_char=' ')
Definition: strip:14
tools::line
Definition: line:13
TOOLS_RCSV_NTUPLE_IF_CID
#define TOOLS_RCSV_NTUPLE_IF_CID(a__name, a__type)
tools::sep
const std::string & sep()
Definition: sep:11
cids
tools::rcsv::ntuple::read_line
static bool read_line(std::istream &a_reader, std::streampos a_sz, std::string &a_s)
Definition: rcsv_ntuple:832
tools_vforcit
#define tools_vforcit(a__T, a__v, a__it)
Definition: forit:7
tools::rcsv::ntuple::initialize
bool initialize(std::ostream &a_out, const ntuple_binding &a_bd=ntuple_binding())
Definition: rcsv_ntuple:575
tools::rcsv::ntuple::ntuple
ntuple(const ntuple &a_from)
Definition: rcsv_ntuple:180
tools::stype
const std::string & stype(const mat4f &)
Definition: mat4f:73
tools::ushort
unsigned short ushort
Definition: typedefs:101
tools::LF
char LF()
Definition: chars:16
tools::uint32
unsigned int uint32
Definition: typedefs:71
tools::rcsv::ntuple::initialize_from_commented_header
bool initialize_from_commented_header(std::ostream &a_out)
Definition: rcsv_ntuple:675
tools::rcsv::ntuple::column::cast
virtual void * cast(cid a_class) const
Definition: rcsv_ntuple:106
tools::rcsv::fntuple::m_freader
std::ifstream m_freader
Definition: rcsv_ntuple:1111
tools::read::icolumn
Definition: rntuple:35
tools::rcsv::ntuple::column::fetch_entry
virtual bool fetch_entry() const
Definition: rcsv_ntuple:113
tools::rcsv::ntuple::column::m_tmp
T m_tmp
Definition: rcsv_ntuple:148
tools::rcsv::ntuple::_read
static bool _read(std::istream &a_reader, std::streampos, char, T &a_v)
Definition: rcsv_ntuple:871
tools::rcsv::ntuple::operator=
ntuple & operator=(const ntuple &a_from)
Definition: rcsv_ntuple:194
sout
tools::rcsv::ntuple::columns
virtual const std::vector< read::icol * > & columns() const
Definition: rcsv_ntuple:81
tools::rcsv::ntuple::m_reader
std::istream & m_reader
Definition: rcsv_ntuple:1047
tools::cid
unsigned short cid
Definition: cid:9
tools::rcsv::ntuple::column::column
column(const std::string &a_name, T *a_user_var=0)
Definition: rcsv_ntuple:123