DDNet documentation
Loading...
Searching...
No Matches
types.h
Go to the documentation of this file.
1#ifndef BASE_TYPES_H
2#define BASE_TYPES_H
3
4#include <base/detect.h>
5
6#include <cstdint>
7#include <ctime>
8#include <functional>
9
10#if defined(CONF_FAMILY_UNIX)
11#include <sys/types.h> // pid_t
12#endif
13
14enum class TRISTATE
15{
19};
20
26inline constexpr auto IO_MAX_PATH_LENGTH = 512;
27
33typedef void *IOHANDLE;
34
40typedef struct ASYNCIO ASYNCIO;
41
56typedef int (*FS_LISTDIR_CALLBACK)(const char *name, int is_dir, int dir_type, void *user);
57
65{
66public:
70 const char *m_pName;
71
76
81};
82
97typedef int (*FS_LISTDIR_CALLBACK_FILEINFO)(const CFsFileInfo *info, int is_dir, int dir_type, void *user);
98
104inline constexpr auto UTF8_BYTE_LENGTH = 4;
105
110
114inline constexpr auto NETTYPE_INVALID = 0;
115
119inline constexpr auto NETTYPE_IPV4 = 1 << 0;
120
124inline constexpr auto NETTYPE_IPV6 = 1 << 1;
125
129inline constexpr auto NETTYPE_WEBSOCKET_IPV4 = 1 << 2;
130
134inline constexpr auto NETTYPE_WEBSOCKET_IPV6 = 1 << 3;
135
139inline constexpr auto NETTYPE_LINK_BROADCAST = 1 << 4;
140
147inline constexpr auto NETTYPE_TW7 = 1 << 5;
148
153
158
162inline constexpr auto NETADDR_MAXSTRSIZE = 1 + (8 * 4 + 7) + 1 + 1 + 5 + 1; // [XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX]:XXXXX
163
167typedef struct NETADDR
168{
169 unsigned int type;
170 unsigned char ip[16];
171 unsigned short port;
172
173 bool operator==(const NETADDR &other) const;
174 bool operator!=(const NETADDR &other) const;
175 bool operator<(const NETADDR &other) const;
177
181template<>
182struct std::hash<NETADDR>
183{
184 size_t operator()(const NETADDR &Addr) const noexcept;
185};
186
190typedef struct NETSTATS
191{
192 uint64_t sent_packets;
193 uint64_t sent_bytes;
194 uint64_t recv_packets;
195 uint64_t recv_bytes;
197
198#if defined(CONF_FAMILY_WINDOWS)
204typedef void *PROCESS;
210constexpr PROCESS INVALID_PROCESS = nullptr; // NOLINT(misc-misplaced-const)
211#else
217typedef pid_t PROCESS;
224#endif
225
226#endif // BASE_TYPES_H
Definition types.h:65
time_t m_TimeCreated
Definition types.h:75
time_t m_TimeModified
Definition types.h:80
const char * m_pName
Definition types.h:70
constexpr auto IO_MAX_PATH_LENGTH
Definition types.h:26
int(* FS_LISTDIR_CALLBACK_FILEINFO)(const CFsFileInfo *info, int is_dir, int dir_type, void *user)
Definition types.h:97
int(* FS_LISTDIR_CALLBACK)(const char *name, int is_dir, int dir_type, void *user)
Definition types.h:56
constexpr auto NETADDR_MAXSTRSIZE
Definition types.h:162
constexpr auto NETTYPE_TW7
Definition types.h:147
constexpr auto NETTYPE_WEBSOCKET_IPV6
Definition types.h:134
constexpr auto NETTYPE_LINK_BROADCAST
Definition types.h:139
constexpr auto NETTYPE_INVALID
Definition types.h:114
constexpr auto NETTYPE_IPV6
Definition types.h:124
constexpr auto NETTYPE_IPV4
Definition types.h:119
constexpr auto NETTYPE_ALL
Definition types.h:152
constexpr auto NETTYPE_WEBSOCKET_IPV4
Definition types.h:129
struct NETSOCKET_INTERNAL * NETSOCKET
Definition types.h:109
constexpr auto NETTYPE_MASK
Definition types.h:157
constexpr PROCESS INVALID_PROCESS
Definition types.h:223
pid_t PROCESS
Definition types.h:217
constexpr auto UTF8_BYTE_LENGTH
Definition types.h:104
void * IOHANDLE
Definition logger.h:12
Definition aio.cpp:15
Definition types.h:168
bool operator<(const NETADDR &other) const
Definition net.cpp:185
bool operator==(const NETADDR &other) const
Definition net.cpp:175
unsigned char ip[16]
Definition types.h:170
bool operator!=(const NETADDR &other) const
Definition net.cpp:180
unsigned short port
Definition types.h:171
unsigned int type
Definition types.h:169
Definition net.cpp:104
Definition types.h:191
uint64_t recv_packets
Definition types.h:194
uint64_t recv_bytes
Definition types.h:195
uint64_t sent_packets
Definition types.h:192
uint64_t sent_bytes
Definition types.h:193
size_t operator()(const NETADDR &Addr) const noexcept
Definition net.cpp:190
TRISTATE
Definition types.h:15
@ ALL
Definition types.h:18
@ SOME
Definition types.h:17
@ NONE
Definition types.h:16