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
82806014
Commit
82806014
authored
May 19, 2015
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add boolean to primitive variant, close #245
parent
51d5d9d3
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
26 additions
and
16 deletions
+26
-16
libcaf_core/caf/primitive_variant.hpp
libcaf_core/caf/primitive_variant.hpp
+1
-1
libcaf_core/src/binary_deserializer.cpp
libcaf_core/src/binary_deserializer.cpp
+5
-0
libcaf_core/src/binary_serializer.cpp
libcaf_core/src/binary_serializer.cpp
+4
-0
libcaf_core/src/string_serialization.cpp
libcaf_core/src/string_serialization.cpp
+5
-1
libcaf_core/src/uniform_type_info_map.cpp
libcaf_core/src/uniform_type_info_map.cpp
+3
-3
libcaf_core/test/serialization.cpp
libcaf_core/test/serialization.cpp
+8
-11
No files found.
libcaf_core/caf/primitive_variant.hpp
View file @
82806014
...
@@ -37,7 +37,7 @@ using primitive_variant = variant<int8_t, int16_t, int32_t, int64_t,
...
@@ -37,7 +37,7 @@ using primitive_variant = variant<int8_t, int16_t, int32_t, int64_t,
uint8_t
,
uint16_t
,
uint32_t
,
uint64_t
,
uint8_t
,
uint16_t
,
uint32_t
,
uint64_t
,
float
,
double
,
long
double
,
float
,
double
,
long
double
,
std
::
string
,
std
::
u16string
,
std
::
u32string
,
std
::
string
,
std
::
u16string
,
std
::
u32string
,
atom_value
>
;
atom_value
,
bool
>
;
}
// namespace caf
}
// namespace caf
...
...
libcaf_core/src/binary_deserializer.cpp
View file @
82806014
...
@@ -135,6 +135,11 @@ struct pt_reader : static_visitor<> {
...
@@ -135,6 +135,11 @@ struct pt_reader : static_visitor<> {
inline
void
operator
()(
none_t
&
)
{
inline
void
operator
()(
none_t
&
)
{
// nop
// nop
}
}
inline
void
operator
()(
bool
&
value
)
{
uint8_t
intval
;
(
*
this
)(
intval
);
value
=
static_cast
<
bool
>
(
intval
);
}
template
<
class
T
>
template
<
class
T
>
inline
void
operator
()(
T
&
value
)
{
inline
void
operator
()(
T
&
value
)
{
begin
=
read_range
(
begin
,
end
,
value
);
begin
=
read_range
(
begin
,
end
,
value
);
...
...
libcaf_core/src/binary_serializer.cpp
View file @
82806014
...
@@ -43,6 +43,10 @@ class binary_writer : public static_visitor<> {
...
@@ -43,6 +43,10 @@ class binary_writer : public static_visitor<> {
f
(
first
,
last
);
f
(
first
,
last
);
}
}
void
operator
()(
const
bool
&
value
)
const
{
write_int
(
m_out
,
static_cast
<
uint8_t
>
(
value
));
}
template
<
class
T
>
template
<
class
T
>
typename
std
::
enable_if
<
std
::
is_integral
<
T
>::
value
>::
type
typename
std
::
enable_if
<
std
::
is_integral
<
T
>::
value
>::
type
operator
()(
const
T
&
value
)
const
{
operator
()(
const
T
&
value
)
const
{
...
...
libcaf_core/src/string_serialization.cpp
View file @
82806014
...
@@ -87,6 +87,10 @@ class string_serializer : public serializer, public dummy_backend {
...
@@ -87,6 +87,10 @@ class string_serializer : public serializer, public dummy_backend {
void
operator
()(
const
T
&
value
)
{
void
operator
()(
const
T
&
value
)
{
out
<<
value
;
out
<<
value
;
}
}
void
operator
()(
const
bool
&
value
)
{
out
<<
(
value
?
"true"
:
"false"
);
}
// make sure char's are treated as int8_t number, not as character
// make sure char's are treated as int8_t number, not as character
inline
void
operator
()(
const
char
&
value
)
{
inline
void
operator
()(
const
char
&
value
)
{
out
<<
static_cast
<
int
>
(
value
);
out
<<
static_cast
<
int
>
(
value
);
...
@@ -141,7 +145,7 @@ class string_serializer : public serializer, public dummy_backend {
...
@@ -141,7 +145,7 @@ class string_serializer : public serializer, public dummy_backend {
m_namespace
(
*
this
),
m_namespace
(
*
this
),
m_after_value
(
false
),
m_after_value
(
false
),
m_obj_just_opened
(
false
)
{
m_obj_just_opened
(
false
)
{
// nop
out
<<
std
::
boolalpha
;
}
}
void
begin_object
(
const
uniform_type_info
*
uti
)
{
void
begin_object
(
const
uniform_type_info
*
uti
)
{
...
...
libcaf_core/src/uniform_type_info_map.cpp
View file @
82806014
...
@@ -306,12 +306,12 @@ inline void deserialize_impl(duration& val, deserializer* source) {
...
@@ -306,12 +306,12 @@ inline void deserialize_impl(duration& val, deserializer* source) {
val
.
count
=
count_val
;
val
.
count
=
count_val
;
}
}
inline
void
serialize_impl
(
bool
val
,
serializer
*
sink
)
{
inline
void
serialize_impl
(
const
bool
&
val
,
serializer
*
sink
)
{
sink
->
write_value
(
static_cast
<
uint8_t
>
(
val
?
1
:
0
)
);
sink
->
write_value
(
val
);
}
}
inline
void
deserialize_impl
(
bool
&
val
,
deserializer
*
source
)
{
inline
void
deserialize_impl
(
bool
&
val
,
deserializer
*
source
)
{
val
=
source
->
read
<
uint8_t
>
()
!=
0
;
val
=
source
->
read
<
bool
>
()
;
}
}
// exit_msg & down_msg have the same fields
// exit_msg & down_msg have the same fields
...
...
libcaf_core/test/serialization.cpp
View file @
82806014
...
@@ -295,17 +295,14 @@ CAF_TEST(test_multiple_messages) {
...
@@ -295,17 +295,14 @@ CAF_TEST(test_multiple_messages) {
CAF_CHECK
(
is_message
(
m2
).
equal
(
i32
,
te
,
str
,
rs
));
CAF_CHECK
(
is_message
(
m2
).
equal
(
i32
,
te
,
str
,
rs
));
}
}
CAF_TEST
(
test_string_serialization
)
{
CAF_TEST
(
strings
)
{
auto
input
=
make_message
(
"hello
\"
actor world
\"
!"
,
atom
(
"foo"
));
auto
m1
=
make_message
(
"hello
\"
actor world
\"
!"
,
atom
(
"foo"
));
auto
s
=
to_string
(
input
);
auto
s1
=
to_string
(
m1
);
CAF_CHECK_EQUAL
(
s
,
R"#(@<>+@str+@atom ( "hello \"actor world\"!", 'foo' ))#"
);
CAF_CHECK_EQUAL
(
s1
,
R"#(@<>+@str+@atom ( "hello \"actor world\"!", 'foo' ))#"
);
auto
m
=
from_string
<
message
>
(
s
);
CAF_CHECK
(
from_string
<
message
>
(
s1
)
==
m1
);
if
(
!
m
)
{
auto
m2
=
make_message
(
true
);
CAF_TEST_ERROR
(
"from_string failed"
);
auto
s2
=
to_string
(
m2
);
return
;
CAF_CHECK_EQUAL
(
s2
,
"@<>+bool ( true )"
);
}
CAF_CHECK
(
*
m
==
input
);
CAF_CHECK_EQUAL
(
to_string
(
*
m
),
to_string
(
input
));
}
}
CAF_TEST_FIXTURE_SCOPE_END
()
CAF_TEST_FIXTURE_SCOPE_END
()
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