Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
Actor Framework
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
Operations
Operations
Metrics
Environments
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 Framework
Commits
aa1dee57
Commit
aa1dee57
authored
Aug 14, 2019
by
Jakob Otto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rework constructors of binary_serializer
parent
7290e438
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
21 deletions
+15
-21
libcaf_core/caf/binary_deserializer.hpp
libcaf_core/caf/binary_deserializer.hpp
+13
-19
libcaf_core/src/binary_deserializer.cpp
libcaf_core/src/binary_deserializer.cpp
+2
-2
No files found.
libcaf_core/caf/binary_deserializer.hpp
View file @
aa1dee57
...
@@ -24,6 +24,7 @@
...
@@ -24,6 +24,7 @@
#include "caf/byte.hpp"
#include "caf/byte.hpp"
#include "caf/deserializer.hpp"
#include "caf/deserializer.hpp"
#include "caf/span.hpp"
namespace
caf
{
namespace
caf
{
...
@@ -36,32 +37,25 @@ public:
...
@@ -36,32 +37,25 @@ public:
// -- constructors, destructors, and assignment operators --------------------
// -- constructors, destructors, and assignment operators --------------------
template
<
class
ValueType
>
binary_deserializer
(
actor_system
&
sys
,
span
<
const
byte
>
bytes
)
binary_deserializer
(
actor_system
&
sys
,
const
ValueType
*
buf
,
size_t
buf_size
)
:
super
(
sys
),
current_
(
bytes
.
begin
()),
end_
(
bytes
.
end
())
{
:
super
(
sys
),
// nop
current_
(
reinterpret_cast
<
const
byte
*>
(
buf
)),
end_
(
reinterpret_cast
<
const
byte
*>
(
buf
)
+
buf_size
)
{
static_assert
(
sizeof
(
ValueType
)
==
1
,
"sizeof(Value type) > 1"
);
}
}
template
<
class
ValueType
>
binary_deserializer
(
execution_unit
*
ctx
,
span
<
const
byte
>
bytes
)
binary_deserializer
(
execution_unit
*
ctx
,
const
ValueType
*
buf
,
:
super
(
ctx
),
current_
(
bytes
.
begin
()),
end_
(
bytes
.
end
())
{
size_t
buf_size
)
// nop
:
super
(
ctx
),
current_
(
reinterpret_cast
<
const
byte
*>
(
buf
)),
end_
(
reinterpret_cast
<
const
byte
*>
(
buf
)
+
buf_size
)
{
static_assert
(
sizeof
(
ValueType
)
==
1
,
"sizeof(Value type) > 1"
);
}
}
template
<
class
BufferType
>
template
<
class
T
>
binary_deserializer
(
actor_system
&
sys
,
const
BufferType
&
buf
)
binary_deserializer
(
actor_system
&
sys
,
const
std
::
vector
<
T
>
&
buf
)
:
binary_deserializer
(
sys
,
buf
.
data
(),
buf
.
size
(
))
{
:
binary_deserializer
(
sys
,
as_bytes
(
make_span
(
buf
.
data
(),
buf
.
size
())
))
{
// nop
// nop
}
}
template
<
class
BufferType
>
template
<
class
T
>
binary_deserializer
(
execution_unit
*
ctx
,
const
BufferType
&
buf
)
binary_deserializer
(
execution_unit
*
ctx
,
const
std
::
vector
<
T
>
&
buf
)
:
binary_deserializer
(
ctx
,
buf
.
data
(),
buf
.
size
(
))
{
:
binary_deserializer
(
ctx
,
as_bytes
(
make_span
(
buf
.
data
(),
buf
.
size
())
))
{
// nop
// nop
}
}
...
...
libcaf_core/src/binary_deserializer.cpp
View file @
aa1dee57
...
@@ -149,8 +149,8 @@ error binary_deserializer::apply_impl(std::string& x) {
...
@@ -149,8 +149,8 @@ error binary_deserializer::apply_impl(std::string& x) {
return
err
;
return
err
;
if
(
!
range_check
(
str_size
))
if
(
!
range_check
(
str_size
))
return
sec
::
end_of_stream
;
return
sec
::
end_of_stream
;
x
.
assign
(
reinterpret_cast
<
c
har
*>
(
const_cast
<
byte
*>
(
current_
)
),
x
.
assign
(
reinterpret_cast
<
c
onst
char
*>
(
current_
),
reinterpret_cast
<
c
har
*>
(
const_cast
<
byte
*>
(
current_
)
)
+
str_size
);
reinterpret_cast
<
c
onst
char
*>
(
current_
)
+
str_size
);
current_
+=
str_size
;
current_
+=
str_size
;
return
end_sequence
();
return
end_sequence
();
}
}
...
...
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