source: trunk/Mars/mfileio/MMatrix.h@ 20051

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