-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMessage.h
More file actions
66 lines (52 loc) · 1.19 KB
/
Message.h
File metadata and controls
66 lines (52 loc) · 1.19 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
#ifndef MESSAGE_H_GUARD
#define MESSAGE_H_GUARD
#include <Windows.h>
#include <chrono>
typedef std::chrono::time_point<std::chrono::system_clock> CurrentTime;
class Message
{
private:
char* m_Message;
COORD m_Position;
CurrentTime m_Start;
public:
Message(const char* message, const COORD& position, const CurrentTime& startTime)
:m_Position(position), m_Start(startTime)
{
size_t size = std::strlen(message) + 1;
m_Message = new char[size];
strcpy_s(m_Message, size, message);
}
Message(const Message& other) : m_Position(other.m_Position), m_Start(other.m_Start)
{
size_t size = std::strlen(other.m_Message) + 1;
m_Message = new char[size];
strcpy_s(m_Message, size, other.m_Message);
}
Message& operator=(const Message& rhs)
{
if (this != &rhs)
{
delete[] m_Message;
size_t size = std::strlen(rhs.m_Message) + 1;
m_Message = new char[size];
strcpy_s(m_Message, size, rhs.m_Message);
m_Position = rhs.m_Position;
m_Start = rhs.m_Start;
}
return *this;
}
const char* GetAlert() const
{
return m_Message;
}
const COORD& GetPosition() const
{
return m_Position;
}
const CurrentTime& GetStartingTime() const
{
return m_Start;
}
};
#endif