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