31 #ifndef MESSAGETOOLS_H
32 #define MESSAGETOOLS_H
38 #include "ANSIColors.h"
40 #define __MODULE__ __PRETTY_FUNCTION__ // Options: __FUNCTION__ | __PRETTY_FUNCTION___
41 #define __OFFSET__ 50 // Options: __FUNCTION__ | __PRETTY_FUNCTION___
43 #define FATAL(MSG, COLOR) \
45 std::stringstream msg_; \
46 std::stringstream PFs_; \
47 std::string PF_ = __MODULE__; \
48 int PFSize = PF_.size(); \
50 if(PFSize > __OFFSET__) \
52 PFSize = __OFFSET__; \
54 for(int i = 0; i < PFSize; ++i) \
58 if(PFSize < __OFFSET__) \
60 for(int i = 0; i < __OFFSET__ + 3 - PFSize; ++i) \
65 if(PFSize < (int)PF_.size()) \
68 PFs_ << ACRed << "..."; \
70 msg_ << ACCyan << ACBold << __LINE__ << ACPlain << ACYellow << "\t] [" << ACRed << ACBold << ACReverse << "FATAL:" << ACPlain << ACWhite << ACBold \
71 << " " << PFs_.str() << ACPlain << ACYellow << "]"; \
72 int blankSize = maxL - msg_.str().size() + 1; \
75 std::string blanks = ""; \
76 for(int i = 0; i < blankSize; ++i) \
80 std::cout << msg_.str() << blanks << COLOR << ACBold << MSG << ACPlain << std::endl; \
83 #define STDLINE(MSG, COLOR) \
85 std::stringstream msg_; \
86 std::stringstream PFs_; \
87 std::string PF_ = __MODULE__; \
88 int PFSize = PF_.size(); \
90 if(PFSize > __OFFSET__) \
92 PFSize = __OFFSET__; \
94 for(int i = 0; i < PFSize; ++i) \
98 if(PFSize < __OFFSET__) \
100 for(int i = 0; i < __OFFSET__ + 3 - PFSize; ++i) \
105 if(PFSize < (int)PF_.size()) \
108 PFs_ << ACRed << "..."; \
112 PFs_ << ACPlain << ACPlain << ACPlain << ACPlain; \
114 msg_ << ACCyan << ACBold << __LINE__ << ACPlain << ACYellow << "\t] [" << ACPlain << ACWhite << ACBold << PFs_.str() << ACPlain << ACYellow << "]"; \
115 int msgS = msg_.str().size() + 1; \
116 if(msgS < __OFFSET__) \
118 int blankSize = maxL - msgS; \
121 std::string blanks = ""; \
122 for(int i = 0; i < blankSize; ++i) \
126 std::cout << msg_.str() << blanks << COLOR << ACBold << MSG << ACPlain << std::endl; \
129 #define STDSNAP(MSG, COLOR) \
131 std::stringstream msg_; \
132 std::stringstream PFs_; \
133 std::string PF_ = __MODULE__; \
134 int PFSize = PF_.size(); \
136 if(PFSize > __OFFSET__) \
138 PFSize = __OFFSET__; \
140 for(int i = 0; i < PFSize; ++i) \
144 if(PFSize <= __OFFSET__) \
146 for(int i = 0; i < __OFFSET__ + 3 - PFSize; ++i) \
151 if(PFSize < (int)PF_.size()) \
154 PFs_ << ACRed << "..."; \
156 msg_ << ACCR << ACCyan << ACBold << __LINE__ << ACPlain << ACYellow << "\t] [" << ACPlain << ACWhite << ACBold << PFs_.str() << ACPlain << ACYellow \
158 int blankSize = maxL - msg_.str().size() + 1; \
161 std::string blanks = ""; \
162 for(int i = 0; i < blankSize; ++i) \
166 std::cout << msg_.str() << blanks << COLOR << ACBold << MSG << ACPlain << std::flush; \
174 inline static int toInt(std::string inputString)
176 std::istringstream iss_;
177 iss_.str(inputString);
184 inline static double toDouble(std::string inputString)
186 std::istringstream iss_;
187 iss_.str(inputString);
194 inline static int toDec(
unsigned long long inputBinary)
196 std::stringstream ss;
200 n = Utils::toInt(ss.str());
206 #endif // MESSAGETOOLS_H