pars
0.2.1.99
Loading...
Searching...
No Matches
lib
include
nngxx
opt.h
Go to the documentation of this file.
1
/*
2
Copyright (c) 2025 Giuseppe Roberti.
3
All rights reserved.
4
5
Redistribution and use in source and binary forms, with or without modification,
6
are permitted provided that the following conditions are met:
7
8
1. Redistributions of source code must retain the above copyright notice, this
9
list of conditions and the following disclaimer.
10
11
2. Redistributions in binary form must reproduce the above copyright notice,
12
this list of conditions and the following disclaimer in the documentation and/or
13
other materials provided with the distribution.
14
15
3. Neither the name of the copyright holder nor the names of its contributors
16
may be used to endorse or promote products derived from this software without
17
specific prior written permission.
18
19
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
23
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
26
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
*/
30
#pragma once
31
32
#include <nng/nng.h>
33
#include <nng/protocol/reqrep0/req.h>
34
35
namespace
nngxx
36
{
37
38
enum class
opt
39
{
40
sockname
,
41
raw
,
42
// proto, // deprecated
43
// protoname, // deprecated
44
// peer, // deprecated
45
// peername, // deprecated
46
recvbuf
,
47
sendbuf
,
48
recvfd
,
49
sendfd
,
50
recvtimeo
,
51
sendtimeo
,
52
locaddr
,
53
remaddr
,
54
url
,
55
maxttl
,
56
recvmaxsz
,
57
reconnmint
,
58
reconnmaxt
,
59
peergid
,
60
peerpid
,
61
peeruid
,
62
peerzoneid
,
63
req_resend_time
,
64
req_resend_tick
65
};
66
67
enum class
opt_overload
68
{
69
integer
,
70
boolean
,
71
string
,
72
size
,
73
sockaddr
,
74
duration
,
75
uint64
76
};
77
78
template
<opt o>
79
[[nodiscard]]
static
constexpr
const
char
* opt_to_nng_value() noexcept
80
{
81
if
constexpr
(o ==
opt::sockname
)
82
{
83
return
NNG_OPT_SOCKNAME;
84
}
85
else
if
constexpr
(o ==
opt::raw
)
86
{
87
return
NNG_OPT_RAW;
88
}
89
else
if
constexpr
(o ==
opt::recvbuf
)
90
{
91
return
NNG_OPT_RECVBUF;
92
}
93
else
if
constexpr
(o ==
opt::sendbuf
)
94
{
95
return
NNG_OPT_SENDBUF;
96
}
97
else
if
constexpr
(o ==
opt::recvfd
)
98
{
99
return
NNG_OPT_RECVFD;
100
}
101
else
if
constexpr
(o ==
opt::sendfd
)
102
{
103
return
NNG_OPT_SENDFD;
104
}
105
else
if
constexpr
(o ==
opt::recvtimeo
)
106
{
107
return
NNG_OPT_RECVTIMEO;
108
}
109
else
if
constexpr
(o ==
opt::sendtimeo
)
110
{
111
return
NNG_OPT_SENDTIMEO;
112
}
113
else
if
constexpr
(o ==
opt::locaddr
)
114
{
115
return
NNG_OPT_LOCADDR;
116
}
117
else
if
constexpr
(o ==
opt::remaddr
)
118
{
119
return
NNG_OPT_REMADDR;
120
}
121
else
if
constexpr
(o ==
opt::url
)
122
{
123
return
NNG_OPT_URL;
124
}
125
else
if
constexpr
(o ==
opt::maxttl
)
126
{
127
return
NNG_OPT_MAXTTL;
128
}
129
else
if
constexpr
(o ==
opt::recvmaxsz
)
130
{
131
return
NNG_OPT_RECVMAXSZ;
132
}
133
else
if
constexpr
(o ==
opt::reconnmint
)
134
{
135
return
NNG_OPT_RECONNMINT;
136
}
137
else
if
constexpr
(o ==
opt::reconnmaxt
)
138
{
139
return
NNG_OPT_RECONNMAXT;
140
}
141
else
if
constexpr
(o ==
opt::peergid
)
142
{
143
return
NNG_OPT_PEER_GID;
144
}
145
else
if
constexpr
(o ==
opt::peerpid
)
146
{
147
return
NNG_OPT_PEER_UID;
148
}
149
else
if
constexpr
(o ==
opt::peeruid
)
150
{
151
return
NNG_OPT_PEER_UID;
152
}
153
else
if
constexpr
(o ==
opt::peerzoneid
)
154
{
155
return
NNG_OPT_PEER_ZONEID;
156
}
157
else
if
constexpr
(o ==
opt::req_resend_time
)
158
{
159
return
NNG_OPT_REQ_RESENDTIME;
160
}
161
else
if
constexpr
(o ==
opt::req_resend_tick
)
162
{
163
return
NNG_OPT_REQ_RESENDTICK;
164
}
165
}
166
167
template
<opt o>
168
[[nodiscard]]
static
constexpr
opt_overload
opt_to_nng_overload() noexcept
169
{
170
if
constexpr
(o ==
opt::sockname
)
171
{
172
return
opt_overload::string
;
173
}
174
else
if
constexpr
(o ==
opt::raw
)
175
{
176
return
opt_overload::boolean
;
177
}
178
else
if
constexpr
(o ==
opt::recvbuf
)
179
{
180
return
opt_overload::integer
;
181
}
182
else
if
constexpr
(o ==
opt::sendbuf
)
183
{
184
return
opt_overload::integer
;
185
}
186
else
if
constexpr
(o ==
opt::recvfd
)
187
{
188
return
opt_overload::integer
;
189
}
190
else
if
constexpr
(o ==
opt::sendfd
)
191
{
192
return
opt_overload::integer
;
193
}
194
else
if
constexpr
(o ==
opt::recvtimeo
)
195
{
196
return
opt_overload::duration
;
197
}
198
else
if
constexpr
(o ==
opt::sendtimeo
)
199
{
200
return
opt_overload::duration
;
201
}
202
else
if
constexpr
(o ==
opt::locaddr
)
203
{
204
return
opt_overload::sockaddr
;
205
}
206
else
if
constexpr
(o ==
opt::remaddr
)
207
{
208
return
opt_overload::sockaddr
;
209
}
210
else
if
constexpr
(o ==
opt::url
)
211
{
212
return
opt_overload::string
;
213
}
214
else
if
constexpr
(o ==
opt::maxttl
)
215
{
216
return
opt_overload::integer
;
217
}
218
else
if
constexpr
(o ==
opt::recvmaxsz
)
219
{
220
return
opt_overload::size
;
221
}
222
else
if
constexpr
(o ==
opt::reconnmint
)
223
{
224
return
opt_overload::duration
;
225
}
226
else
if
constexpr
(o ==
opt::reconnmaxt
)
227
{
228
return
opt_overload::duration
;
229
}
230
else
if
constexpr
(o ==
opt::peergid
)
231
{
232
return
opt_overload::uint64
;
233
}
234
else
if
constexpr
(o ==
opt::peerpid
)
235
{
236
return
opt_overload::uint64
;
237
}
238
else
if
constexpr
(o ==
opt::peeruid
)
239
{
240
return
opt_overload::uint64
;
241
}
242
else
if
constexpr
(o ==
opt::peerzoneid
)
243
{
244
return
opt_overload::uint64
;
245
}
246
else
if
constexpr
(o ==
opt::req_resend_time
)
247
{
248
return
opt_overload::duration
;
249
}
250
else
if
constexpr
(o ==
opt::req_resend_tick
)
251
{
252
return
opt_overload::duration
;
253
}
254
}
255
256
template
<opt o>
257
struct
opt_to_nng_type
;
258
259
template
<opt o>
260
using
opt_to_nng_type_t
=
opt_to_nng_type<o>::return_type
;
261
262
template
<>
263
struct
opt_to_nng_type
<
opt
::
sockname
>
264
{
265
using
return_type
=
const
char
*;
266
};
267
268
template
<>
269
struct
opt_to_nng_type
<
opt
::
recvtimeo
>
270
{
271
using
return_type
= nng_duration;
272
};
273
274
template
<>
275
struct
opt_to_nng_type
<
opt
::
sendtimeo
>
276
{
277
using
return_type
= nng_duration;
278
};
279
280
template
<>
281
struct
opt_to_nng_type
<
opt
::
req_resend_time
>
282
{
283
using
return_type
= nng_duration;
284
};
285
286
template
<>
287
struct
opt_to_nng_type
<
opt
::
req_resend_tick
>
288
{
289
using
return_type
= nng_duration;
290
};
291
292
}
// namespace nngxx
nngxx
Definition
aio.h:35
nngxx::opt_overload
opt_overload
Definition
opt.h:68
nngxx::opt_overload::integer
@ integer
Definition
opt.h:69
nngxx::opt_overload::uint64
@ uint64
Definition
opt.h:75
nngxx::opt_overload::sockaddr
@ sockaddr
Definition
opt.h:73
nngxx::opt_overload::boolean
@ boolean
Definition
opt.h:70
nngxx::opt_overload::string
@ string
Definition
opt.h:71
nngxx::opt_overload::duration
@ duration
Definition
opt.h:74
nngxx::opt_overload::size
@ size
Definition
opt.h:72
nngxx::opt
opt
Definition
opt.h:39
nngxx::opt::maxttl
@ maxttl
Definition
opt.h:55
nngxx::opt::remaddr
@ remaddr
Definition
opt.h:53
nngxx::opt::sockname
@ sockname
Definition
opt.h:40
nngxx::opt::req_resend_time
@ req_resend_time
Definition
opt.h:63
nngxx::opt::peerzoneid
@ peerzoneid
Definition
opt.h:62
nngxx::opt::sendtimeo
@ sendtimeo
Definition
opt.h:51
nngxx::opt::peerpid
@ peerpid
Definition
opt.h:60
nngxx::opt::peeruid
@ peeruid
Definition
opt.h:61
nngxx::opt::locaddr
@ locaddr
Definition
opt.h:52
nngxx::opt::reconnmint
@ reconnmint
Definition
opt.h:57
nngxx::opt::url
@ url
Definition
opt.h:54
nngxx::opt::recvbuf
@ recvbuf
Definition
opt.h:46
nngxx::opt::recvtimeo
@ recvtimeo
Definition
opt.h:50
nngxx::opt::recvmaxsz
@ recvmaxsz
Definition
opt.h:56
nngxx::opt::peergid
@ peergid
Definition
opt.h:59
nngxx::opt::recvfd
@ recvfd
Definition
opt.h:48
nngxx::opt::raw
@ raw
Definition
opt.h:41
nngxx::opt::reconnmaxt
@ reconnmaxt
Definition
opt.h:58
nngxx::opt::sendbuf
@ sendbuf
Definition
opt.h:47
nngxx::opt::sendfd
@ sendfd
Definition
opt.h:49
nngxx::opt::req_resend_tick
@ req_resend_tick
Definition
opt.h:64
nngxx::opt_to_nng_type_t
opt_to_nng_type< o >::return_type opt_to_nng_type_t
Definition
opt.h:260
nngxx::opt_to_nng_type< opt::recvtimeo >::return_type
nng_duration return_type
Definition
opt.h:271
nngxx::opt_to_nng_type< opt::req_resend_tick >::return_type
nng_duration return_type
Definition
opt.h:289
nngxx::opt_to_nng_type< opt::req_resend_time >::return_type
nng_duration return_type
Definition
opt.h:283
nngxx::opt_to_nng_type< opt::sendtimeo >::return_type
nng_duration return_type
Definition
opt.h:277
nngxx::opt_to_nng_type< opt::sockname >::return_type
const char * return_type
Definition
opt.h:265
nngxx::opt_to_nng_type
Definition
opt.h:257
Generated by
1.13.2