source: branches/Corsika7405Compatibility/mfileio/MMatrix.h@ 19979

Last change on this file since 19979 was 18089, checked in by smueller, 10 years ago
solving ticket #23, build tests have been performed on La Palma newdaq.
File size: 2.2 KB
Line 
1#ifndef MARS_MMatrix
2#define MARS_MMatrix
3
4#ifndef MARS_MParContainer
5#include "MParContainer.h"
6#endif
7
8#include <iostream> // std::cout
9#include <sstream>
10#include <fstream> // std::ifstream
11#include <iomanip>
12#include <algorithm>
13#include <cctype>
14#include <locale>
15#include "MLog.h"
16#include "MLogManip.h"
17
18class MMatrix : public MParContainer
19{
20public:
21 MMatrix(const char *name, const char *title);
22 ~MMatrix();
23
24 Int_t ReadEnv(const TEnv &env, TString prefix, Bool_t print=kFALSE);
25 void print()const;
26
27 // The floating point data stored in this object has an arbitrary number of
28 // rows and each row can have a unique number of floating numbers.
29 // M[row i][column j]
30 std::vector< std::vector< double > > fM;
31private:
32 // The deilimiter symbol which seperates the data chunks in the file to be
33 // parsed.
34 char fDelimiter;
35
36 // The data text file to be parsed may have comment lines which are
37 // indicated with the comment character.
38 // Leading whitespaces in front of the comment symbol are fine/ are ignored.
39 char fComment;
40
41 // The fFileName can only be set using ReadFile( filename ). This is to make
42 // sure that the fFileName is always the one of the actual file parsed in.
43 TString fFileName;
44
45 // the line number worked on is stored here by the ReadFile( fileneam )
46 // function so that other functions as the pedantic_strtod() can provide
47 // an additional information in case they have to throw exceptions.
48 unsigned int fLineNumber;
49
50 void initialize();
51
52 // a more pedantic version of std::strtod()
53 double pedantic_strtod(std::string text)const;
54
55 // deleting all information stored in the Matrix fM
56 void clear();
57
58 // the text file parser
59 void ReadFile(const TString path_to_text_file );
60
61 // text parsing helpers
62 bool is_empty_or_has_only_white_spaces(std::string line)const;
63 bool is_comment(std::string line)const;
64 std::string remove_leading_white_spaces(std::string &s)const;
65 std::string remove_tailing_white_spaces(std::string &s)const;
66
67 ClassDef(MMatrix, 1) // generic parameter container with text file parser
68};
69
70#endif //MMatrix
Note: See TracBrowser for help on using the repository browser.