-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOutputResult.hpp
More file actions
76 lines (61 loc) · 1.9 KB
/
Copy pathOutputResult.hpp
File metadata and controls
76 lines (61 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
//
// OutputResult.hpp
//
#ifndef OutputResult_hpp
#define OutputResult_hpp
#include <string>
#include <vector>
#include <fstream>
#include <iomanip>
#include <eigen3/Eigen/Dense>
#include <sstream>
#include "ConsolePrint.hpp"
class OutputResult {
public:
enum class OutputType {SCREEN, JSON_FILE};
OutputResult(OutputType outType, std::string fileName = "");
~OutputResult();
void SetCoutKeyWidth(unsigned int width);
void StartResult();
void EndResult();
template<typename T>
void Write(const std::string &key, const T &value) {
switch (outType) {
case OutputType::SCREEN:
CoutWrite(key, value);
break;
case OutputType::JSON_FILE:
JsonWrite(key, value);
break;
}
};
private:
OutputType outType;
unsigned int keyWidth;
std::ofstream outStream;
std::ostringstream tOut;
bool firstJsonItm;
bool firstDataItm;
void CoutStartResult();
void JsonStartResult();
void CoutEndResult();
void JsonEndResult();
void CoutWrite(std::string key, std::string value);
void JsonWrite(std::string key, std::string value);
void CoutWrite(std::string key, double value);
void JsonWrite(std::string key, double value);
void CoutWrite(std::string key, int value);
void JsonWrite(std::string key, int value);
void CoutWrite(std::string key, bool value);
void JsonWrite(std::string key, bool value);
void CoutWrite(std::string key, std::vector<double> value);
void JsonWrite(std::string key, std::vector<double> value);
void CoutWrite(std::string key, Eigen::ArrayXd value);
void JsonWrite(std::string key, Eigen::ArrayXd value);
void CoutWrite(std::string key, std::vector<unsigned int> value);
void JsonWrite(std::string key, std::vector<unsigned int> value);
void CoutWrite(std::string key, std::vector<std::pair<double, double>> value);
void JsonWrite(std::string key, std::vector<std::pair<double, double>> value);
void JsonCheckFirst();
};
#endif /* OutputResult_hpp */