-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCompactStringRelease.h
More file actions
74 lines (61 loc) · 1.65 KB
/
CompactStringRelease.h
File metadata and controls
74 lines (61 loc) · 1.65 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
67
68
69
70
71
72
73
74
// Copyright 2006-12 HumaNature Studios Inc.
#pragma once
namespace core {
class CompactStringRelease
{
protected:
const static int s_UninitializedCRC = 0xFFFFFFFF;
int m_CRC;
void Calc(const char* pString);
public:
CompactStringRelease() : m_CRC(s_UninitializedCRC) { }
explicit CompactStringRelease(int crc) : m_CRC(crc) { }
CompactStringRelease(const char* pString)
{
Calc(pString);
}
CompactStringRelease(const std::string& s)
{
Calc(s.c_str());
}
CompactStringRelease& operator=(const char* pString)
{
Calc(pString);
return *this;
}
CompactStringRelease& operator=(int crc)
{
m_CRC = crc;
return *this;
}
CompactStringRelease& operator=(const std::string& s)
{
Calc(s.c_str());
return *this;
}
bool operator==(const CompactStringRelease& rhs) const
{
return m_CRC == rhs.m_CRC;
}
bool operator<(const CompactStringRelease& rhs) const
{
return m_CRC < rhs.m_CRC;
}
bool operator!=(const CompactStringRelease& rhs) const
{
return !(*this == rhs);
}
bool empty() const
{
return m_CRC == s_UninitializedCRC;
}
void clear()
{
m_CRC = s_UninitializedCRC;
}
int crc() const
{
return m_CRC;
}
};
} // namespace core