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
5459caf1
Commit
5459caf1
authored
Feb 15, 2019
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename {pos => current}, add remaining() getter
parent
47538648
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
10 deletions
+18
-10
libcaf_core/caf/binary_deserializer.hpp
libcaf_core/caf/binary_deserializer.hpp
+7
-4
libcaf_core/src/binary_deserializer.cpp
libcaf_core/src/binary_deserializer.cpp
+11
-6
No files found.
libcaf_core/caf/binary_deserializer.hpp
View file @
5459caf1
...
...
@@ -60,8 +60,8 @@ public:
// -- properties -------------------------------------------------------------
/// Returns the current read position.
const
char
*
pos
()
const
{
return
pos
_
;
const
char
*
current
()
const
{
return
current
_
;
}
/// Returns the past-the-end iterator.
...
...
@@ -69,6 +69,9 @@ public:
return
end_
;
}
/// Returns how many bytes are still available to read.
size_t
remaining
()
const
;
protected:
error
apply_impl
(
int8_t
&
)
override
;
...
...
@@ -100,10 +103,10 @@ protected:
private:
bool
range_check
(
size_t
read_size
)
{
return
pos
_
+
read_size
<=
end_
;
return
current
_
+
read_size
<=
end_
;
}
const
char
*
pos
_
;
const
char
*
current
_
;
const
char
*
end_
;
};
...
...
libcaf_core/src/binary_deserializer.cpp
View file @
5459caf1
...
...
@@ -26,6 +26,7 @@
#include "caf/detail/network_order.hpp"
#include "caf/sec.hpp"
namespace
caf
{
namespace
{
...
...
@@ -52,13 +53,13 @@ error apply_float(binary_deserializer& bs, T& x) {
binary_deserializer
::
binary_deserializer
(
actor_system
&
sys
,
const
char
*
buf
,
size_t
buf_size
)
:
super
(
sys
),
pos
_
(
buf
),
end_
(
buf
+
buf_size
)
{
:
super
(
sys
),
current
_
(
buf
),
end_
(
buf
+
buf_size
)
{
// nop
}
binary_deserializer
::
binary_deserializer
(
execution_unit
*
ctx
,
const
char
*
buf
,
size_t
buf_size
)
:
super
(
ctx
),
pos
_
(
buf
),
end_
(
buf
+
buf_size
)
{
:
super
(
ctx
),
current
_
(
buf
),
end_
(
buf
+
buf_size
)
{
// nop
}
...
...
@@ -99,11 +100,15 @@ error binary_deserializer::end_sequence() {
error
binary_deserializer
::
apply_raw
(
size_t
num_bytes
,
void
*
storage
)
{
if
(
!
range_check
(
num_bytes
))
return
sec
::
end_of_stream
;
memcpy
(
storage
,
pos
_
,
num_bytes
);
pos
_
+=
num_bytes
;
memcpy
(
storage
,
current
_
,
num_bytes
);
current
_
+=
num_bytes
;
return
none
;
}
size_t
binary_deserializer
::
remaining
()
const
{
return
static_cast
<
size_t
>
(
end_
-
current_
);
}
error
binary_deserializer
::
apply_impl
(
int8_t
&
x
)
{
return
apply_raw
(
sizeof
(
int8_t
),
&
x
);
}
...
...
@@ -160,8 +165,8 @@ error binary_deserializer::apply_impl(std::string& x) {
return
err
;
if
(
!
range_check
(
str_size
))
return
sec
::
end_of_stream
;
x
.
assign
(
pos_
,
pos
_
+
str_size
);
pos
_
+=
str_size
;
x
.
assign
(
current_
,
current
_
+
str_size
);
current
_
+=
str_size
;
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