blob: d9941d5fd17c83280e196b5db96c74022f1b9f53 (
plain) (
blame)
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
|
#include "Link.h"
#include <cstring>
void Link::free() {
delete[] textMessage;
delete[] address;
}
void Link::copyFrom(const Link& other) {
this->address = new char[strlen(other.address) + 1];
strcpy(this->address, other.address);
}
Link::Link() : Message() {
this->address = nullptr;
}
Link::~Link() {
free();
}
Link::Link(const Link& other) : Message(other) {
copyFrom(other);
}
Link& Link::operator=(const Link& other) {
if (this != &other) {
Message::operator=(other);
free();
copyFrom(other);
}
return *this;
}
Link::Link(Link&& other) {
Message::operator=(std::move(other));
this->address = other.address;
other.address = nullptr;
}
Link& Link::operator=(Link&& other) {
if (this != &other) {
free();
Message::operator=(std::move(other));
this->address = other.address;
other.address = nullptr;
}
return *this;
}
unsigned Link::size() {
return (Length() + 1) + (strlen(address) + 1);
}
|