-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDBentry.cpp
57 lines (47 loc) · 1.32 KB
/
DBentry.cpp
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
#include "DBentry.h"
DBentry::DBentry() {
//the default constructor
}
//constructor with data passed in
DBentry::DBentry(string _name, unsigned int _IPaddress, bool _active) {
this -> name = _name;
this -> IPaddress = _IPaddress;
this -> active = _active;
}
DBentry::~DBentry() {
//destructor
}
// sets the domain name, which we will use as a key.
void DBentry::setName(string _name) {
this -> name = _name;
}
// sets the IPaddress data.
void DBentry::setIPaddress (unsigned int _IPaddress) {
this -> IPaddress = _IPaddress;
}
// sets whether or not this entry is active.
void DBentry::setActive(bool _active) {
this -> active = _active;
}
// returns the name.
string DBentry::getName() const {
return name;
}
// returns the IPaddress data.
unsigned int DBentry::getIPaddress() const {
return IPaddress;
}
// returns whether or not this entry is active.
bool DBentry::getActive() const {
return active;
}
// prints the entry in the format
// name : IPaddress : active followed by newline
// active is printed as a string (active or inactive)
ostream& operator<< (ostream& out, const DBentry& rhs) {
if (rhs.active)
out << rhs.name << " : " << rhs.IPaddress << " : active" << endl;
else
out << rhs.name << " : " << rhs.IPaddress << " : inactive" << endl;
return (out);
}