-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathItemType.cpp
80 lines (69 loc) · 1.48 KB
/
ItemType.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#include "ItemType.h"
#include <sstream>
#include <bitset>
#include <string>
// MARK: Stubbed Constructor
ItemType::ItemType()
{
identifier = "n/a";
}
// MARK: Copy Constructor
ItemType::ItemType(const ItemType &origItem)
{
this->identifier = origItem.identifier;
}
// MARK: Copy Assignment Constructor
ItemType ItemType::operator =(const ItemType &rhs)
{
this->identifier = rhs.identifier;
return *this;
}
// MARK: Alternate Copy Assignment Constructor
ItemType ItemType::operator =(string s)
{
this->identifier = s;
return *this;
}
// MARK: 6 Relational Operators
bool ItemType::operator==(ItemType &rhs)
{
return this->identifier==rhs.identifier;
}
bool ItemType::operator!=(ItemType &rhs)
{
return this->identifier!=rhs.identifier;
}
bool ItemType::operator< (ItemType &rhs)
{
return this->identifier<rhs.identifier;
}
bool ItemType::operator> (ItemType &rhs)
{
return this->identifier>rhs.identifier;
}
bool ItemType::operator<=(ItemType &rhs)
{
return this->identifier<=rhs.identifier;
}
bool ItemType::operator>=(ItemType &rhs)
{
return this->identifier>=rhs.identifier;
}
// MARK: Overloaded Insertion Operator
ostream & operator << (ostream &out, const ItemType &item)
{
out.clear();
out << item.identifier;
return out;
}
unsigned long ItemType::getHash()
{
stringstream ss;
unsigned int n;
string s = md5(identifier).substr(0,8);
ss << hex << s;
ss >> n;
bitset<32> b(n);
//???
return b.to_ulong();
}