-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutilities.h
47 lines (45 loc) · 959 Bytes
/
utilities.h
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
#include <iostream>
void gotoxy(int x, int y)
{
COORD coord;
coord.X = x;
coord.Y = y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
}
void printat(int x, int y, char c){
gotoxy(x,y);
printf( "%c", c );
}
void wipescreen(){
system( "cls" );
}
class talker{
public:
std::string out;
bool enabled;
};
std::ostream& operator<<( std::ostream& os, talker &rhs ){
if( rhs.enabled ){
os << rhs.out;
rhs.out = "";
return os;
}
else{
return os;
}
}
void operator>>( const std::string& input, talker &rhs ){
if( rhs.enabled ){
rhs.out += input;
}
}
void operator>>( const char* input, talker &rhs ){
if ( rhs.enabled ){
rhs.out += std::string( input );
}
}
void operator>>( const char input, talker &rhs ){
if( rhs.enabled ){
rhs.out += std::string(1, input);
}
}