-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathNameType.h
39 lines (37 loc) · 1.22 KB
/
NameType.h
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
#ifndef INC_NAMETYPE_H
#define INC_NAMETYPE_H
#include <string>
class NameType {
static const unsigned int NameSize_ = 6;
public:
NameType();
NameType(const NameType&);
NameType(const char*);
NameType(std::string const&);
NameType& operator=(const NameType&);
void ToBuffer(char*) const;
bool Match(NameType const&) const;
bool operator==(const NameType&) const;
bool operator==(const char*) const;
bool operator!=(const NameType&) const;
bool operator!=(const char*) const;
const char* operator*() const { return c_array_; }
char operator[](int) const;
std::string Truncated() const;
void ReplaceAsterisk();
bool operator<(NameType const& rhs) const {
for (unsigned int i = 0; i != NameSize_; i++)
{
if (c_array_[i] == '\0' && rhs.c_array_[i] == '\0') return false;
else if (c_array_[i] == '\0' && rhs.c_array_[i] != '\0') return true;
else if (c_array_[i] != '\0' && rhs.c_array_[i] == '\0') return false;
else if (c_array_[i] < rhs.c_array_[i]) return true;
else if (c_array_[i] > rhs.c_array_[i]) return false;
}
return false;
}
private:
char c_array_[NameSize_];
void FormatName();
};
#endif