Last change
on this file since eb94c1 was eb94c1, checked in by Saskia Metzler <metzler@…>, 16 years ago |
Work-in-progress commit of change tracker and parser
|
-
Property mode
set to
100644
|
File size:
1.5 KB
|
Line | |
---|
1 | /*
|
---|
2 | * Matrix.hpp
|
---|
3 | *
|
---|
4 | * Created on: Mar 2, 2010
|
---|
5 | * Author: metzler
|
---|
6 | */
|
---|
7 |
|
---|
8 | #ifndef MATRIX_HPP_
|
---|
9 | #define MATRIX_HPP_
|
---|
10 |
|
---|
11 | #include "memoryallocator.hpp"
|
---|
12 | #include <vector>
|
---|
13 |
|
---|
14 | using namespace std;
|
---|
15 |
|
---|
16 | /**
|
---|
17 | * "Generic" field content type. Holds a value as its string representation as
|
---|
18 | * to use in a text file.
|
---|
19 | */
|
---|
20 | class FieldContent {
|
---|
21 | public:
|
---|
22 | string getAsString();
|
---|
23 | int getAsInt();
|
---|
24 | double getAsDouble();
|
---|
25 | void set(string valueToSet);
|
---|
26 | void set(int valueToSet);
|
---|
27 | void set(double valueToSet);
|
---|
28 | private:
|
---|
29 | string value;
|
---|
30 | };
|
---|
31 |
|
---|
32 | /**
|
---|
33 | * Holds the data of a matrix.
|
---|
34 | */
|
---|
35 | class Matrix {
|
---|
36 | public:
|
---|
37 | Matrix(int rows, int columns);
|
---|
38 | ~Matrix();
|
---|
39 | void setHeader(const string text);
|
---|
40 | string getHeader();
|
---|
41 | int getNumberOfRows();
|
---|
42 | int getNumberOfColumns();
|
---|
43 | void setField(int rowIndex, int columnIndex, FieldContent value);
|
---|
44 | FieldContent getField(int rowIndex, int columnIndex);
|
---|
45 |
|
---|
46 | private:
|
---|
47 | string header;
|
---|
48 | vector<vector<FieldContent> > fields;
|
---|
49 | };
|
---|
50 |
|
---|
51 | /**
|
---|
52 | * Reads matrix with any formatting from a file.
|
---|
53 | */
|
---|
54 | class MatrixReader {
|
---|
55 | public:
|
---|
56 | MatrixReader();
|
---|
57 | MatrixReader(char columnSep, char rowInitializer, char rowTerminator, char skipInitiator, char skipTerminator);
|
---|
58 | Matrix* read(char* fileName, int rowOffset, int columnOffset);
|
---|
59 |
|
---|
60 | private:
|
---|
61 | int determineNumberOfColumns();
|
---|
62 | char skipBegin;
|
---|
63 | char skipEnd;
|
---|
64 | char columnSeparator;
|
---|
65 | char rowBegin;
|
---|
66 | char rowEnd;
|
---|
67 | };
|
---|
68 |
|
---|
69 | /**
|
---|
70 | * Writes a matrix with any formatting to a file.
|
---|
71 | */
|
---|
72 | class MatrixWriter {
|
---|
73 | public:
|
---|
74 | void write(char* fileName, Matrix* matrix, char columnSeparator, char rowInitializer, char rowTerminator);
|
---|
75 | };
|
---|
76 |
|
---|
77 | #endif /* MATRIX_HPP_ */
|
---|
Note:
See
TracBrowser
for help on using the repository browser.