forked from cataclysmbnteam/Cataclysm-BN
-
Notifications
You must be signed in to change notification settings - Fork 0
/
character_id.h
54 lines (41 loc) · 1.19 KB
/
character_id.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#pragma once
#ifndef CATA_SRC_CHARACTER_ID_H
#define CATA_SRC_CHARACTER_ID_H
#include <cassert>
#include <ostream>
class JsonIn;
class JsonOut;
class character_id
{
public:
character_id() : value( -1 ) {}
explicit character_id( int i ) : value( i ) {
}
bool is_valid() const {
return value > 0;
}
int get_value() const {
return value;
}
character_id &operator++() {
++value;
return *this;
}
void serialize( JsonOut & ) const;
void deserialize( JsonIn & );
friend inline bool operator==( character_id l, character_id r ) {
return l.get_value() == r.get_value();
}
friend inline bool operator!=( character_id l, character_id r ) {
return l.get_value() != r.get_value();
}
friend inline bool operator<( character_id l, character_id r ) {
return l.get_value() < r.get_value();
}
friend inline std::ostream &operator<<( std::ostream &o, character_id id ) {
return o << id.get_value();
}
private:
int value;
};
#endif // CATA_SRC_CHARACTER_ID_H