Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
actor-incubator
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cpp-libs
actor-incubator
Commits
bddef5ec
Commit
bddef5ec
authored
Oct 11, 2019
by
Jakob Otto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add overload for to_bytes
parent
dff48ceb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
3 deletions
+15
-3
libcaf_net/caf/net/basp/header.hpp
libcaf_net/caf/net/basp/header.hpp
+4
-0
libcaf_net/src/header.cpp
libcaf_net/src/header.cpp
+11
-3
No files found.
libcaf_net/caf/net/basp/header.hpp
View file @
bddef5ec
...
@@ -78,6 +78,10 @@ struct header : detail::comparable<header> {
...
@@ -78,6 +78,10 @@ struct header : detail::comparable<header> {
/// @relates header
/// @relates header
std
::
array
<
byte
,
header_size
>
to_bytes
(
header
x
);
std
::
array
<
byte
,
header_size
>
to_bytes
(
header
x
);
/// Serializes a header to a byte representation.
/// @relates header
void
to_bytes
(
header
x
,
std
::
vector
<
byte
>&
buf
);
/// @relates header
/// @relates header
template
<
class
Inspector
>
template
<
class
Inspector
>
typename
Inspector
::
result_type
inspect
(
Inspector
&
f
,
header
&
x
)
{
typename
Inspector
::
result_type
inspect
(
Inspector
&
f
,
header
&
x
)
{
...
...
libcaf_net/src/header.cpp
View file @
bddef5ec
...
@@ -46,17 +46,25 @@ header header::from_bytes(span<const byte> bytes) {
...
@@ -46,17 +46,25 @@ header header::from_bytes(span<const byte> bytes) {
return
result
;
return
result
;
}
}
std
::
array
<
byte
,
header_size
>
to_bytes
(
header
x
)
{
void
to_bytes_impl
(
const
header
&
x
,
byte
*
ptr
)
{
std
::
array
<
byte
,
header_size
>
result
;
auto
ptr
=
result
.
data
();
*
ptr
=
static_cast
<
byte
>
(
x
.
type
);
*
ptr
=
static_cast
<
byte
>
(
x
.
type
);
auto
payload_len
=
detail
::
to_network_order
(
x
.
payload_len
);
auto
payload_len
=
detail
::
to_network_order
(
x
.
payload_len
);
memcpy
(
ptr
+
1
,
&
payload_len
,
sizeof
(
payload_len
));
memcpy
(
ptr
+
1
,
&
payload_len
,
sizeof
(
payload_len
));
auto
operation_data
=
detail
::
to_network_order
(
x
.
operation_data
);
auto
operation_data
=
detail
::
to_network_order
(
x
.
operation_data
);
memcpy
(
ptr
+
5
,
&
operation_data
,
sizeof
(
operation_data
));
memcpy
(
ptr
+
5
,
&
operation_data
,
sizeof
(
operation_data
));
}
std
::
array
<
byte
,
header_size
>
to_bytes
(
header
x
)
{
std
::
array
<
byte
,
header_size
>
result
{};
to_bytes_impl
(
x
,
result
.
data
());
return
result
;
return
result
;
}
}
void
to_bytes
(
header
x
,
std
::
vector
<
byte
>&
buf
)
{
buf
.
resize
(
header_size
);
to_bytes_impl
(
x
,
buf
.
data
());
}
}
// namespace basp
}
// namespace basp
}
// namespace net
}
// namespace net
}
// namespace caf
}
// namespace caf
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment