GWOLLUM  4.2.0
Tools for gravitational-wave analyses
ReadAscii.h
Go to the documentation of this file.
1 
6 #ifndef __ReadAscii__
7 #define __ReadAscii__
8 
9 #include "CUtils.h"
10 
11 #define NCOLMAX 50
12 
13 using namespace std;
14 
20 class ReadAscii{
21 
22  public:
23 
58  ReadAscii(const string afilename, const string aformat="UNKNOWN");
59 
63  virtual ~ReadAscii(void);
64 
72  inline unsigned int GetNLine(void){ return mylines.size(); };
73 
77  inline unsigned int GetNRow(void){ return mylines.size(); };
78 
82  inline unsigned int GetNCol(void){ return Vformat.size(); };
83 
93  bool SetFormat(const unsigned int co, const char aformat);
94 
101  bool GetLine(string &line, const unsigned int li);
102 
109  bool GetCol(vector<int> &col, const unsigned int co);
110 
117  bool GetCol(vector<unsigned int> &col, const unsigned int co);
118 
125  bool GetCol(vector<double> &col, const unsigned int co);
126 
133  bool GetCol(vector<string> &col, const unsigned int co);
134 
142  bool GetElement(int &element, const unsigned int li, const unsigned int co);
143 
151  bool GetElement(unsigned int &element, const unsigned int li, const unsigned int co);
152 
160  bool GetElement(double &element, const unsigned int li, const unsigned int co);
161 
169  bool GetElement(string &element, const unsigned int li, const unsigned int co);
170 
171  private:
172 
173  // extract the elements of the files
174  void ExtractFormat(void);
175  void ExtractLines(void);
176  void ExtractCol(void);
177  void GetMinMax(const unsigned int co);
178 
179  string ffilename;
180  string fformat;
181  vector<string> Vformat;
182  vector <string> mylines;
183  vector <string> scol[NCOLMAX];
184  vector <double> dcol[NCOLMAX];
185  vector <int> icol[NCOLMAX];
186  vector <unsigned int> ucol[NCOLMAX];
187  double colmin[NCOLMAX];
188  double colmax[NCOLMAX];
189 };
190 
191 #endif
192 
193 
194 
195 
196 
197 
198 
199 
200 
Generic C utility functions.
#define NCOLMAX
Definition: ReadAscii.h:11
Parse text files with columns.
Definition: ReadAscii.h:20
vector< string > Vformat
Vector of formats.
Definition: ReadAscii.h:181
vector< string > mylines
Lines of the files.
Definition: ReadAscii.h:182
string ffilename
Input file name.
Definition: ReadAscii.h:179
unsigned int GetNLine(void)
Returns the number of rows/lines.
Definition: ReadAscii.h:72
string fformat
Input format string.
Definition: ReadAscii.h:180
unsigned int GetNRow(void)
Returns the number of rows/lines.
Definition: ReadAscii.h:77
unsigned int GetNCol(void)
Returns the number of columns.
Definition: ReadAscii.h:82