-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcppFormatter.cpp
More file actions
73 lines (55 loc) · 2.04 KB
/
cppFormatter.cpp
File metadata and controls
73 lines (55 loc) · 2.04 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
/*****************************************************
Project [approximate_arithmetic]
FileName [formatFUN]
Author [Sina Boroumand]
Affilation [UT DSD Lab]
Date [February 27, 2018]
*****************************************************/
#include "cppFormatter.h"
// template <class TYPE>
// std::string printRed(TYPE data) {
// std::ostringstream s;
// s << "\033[1;31m" << data << "\033[0m";
// return s.str();
// }
// template <class TYPE>
// std::string printYellow(TYPE data) {
// std::ostringstream s;
// s << "\033[1;33m" << data << "\033[0m";
// return s.str();
// }
std::string cppFormatter::printRedLine() {
return printRed("------------------------------------------");
}
std::string cppFormatter::printRedDoubleLine() {
return printRed("==========================================");
}
std::string cppFormatter::printYellowLine() {
return printYellow("------------------------------------------");
}
std::string cppFormatter::printYellowDoubleLine() {
return printYellow("==========================================");
}
std::string cppFormatter::printLine() {
return printRed("------------------------------------------");
}
void cppFormatter::typingPrint(const string &message, unsigned int millis_per_char){
// Range loops are "for each" constructs; here: for each character in the string
for (const char c: message)
{
// flush is used to make sure the buffer is emptied to the terminal immediately
cout << c << flush;
// Ask the thread to sleep for at least n millis.
sleep_for(milliseconds(millis_per_char));
}
}
void cppFormatter::typingPrint(const string &message){
// Range loops are "for each" constructs; here: for each character in the string
for (const char c: message)
{
// flush is used to make sure the buffer is emptied to the terminal immediately
cout << c << flush;
// Ask the thread to sleep for at least n millis.
sleep_for(milliseconds(20));
}
}