forked from CleverRaven/Cataclysm-DDA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
character_id.h
54 lines (40 loc) · 1012 Bytes
/
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 <iosfwd>
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( int );
private:
int value;
};
inline bool operator==( character_id l, character_id r )
{
return l.get_value() == r.get_value();
}
inline bool operator!=( character_id l, character_id r )
{
return l.get_value() != r.get_value();
}
inline bool operator<( character_id l, character_id r )
{
return l.get_value() < r.get_value();
}
std::ostream &operator<<( std::ostream &o, character_id id );
#endif // CATA_SRC_CHARACTER_ID_H