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
23b49aab
Commit
23b49aab
authored
Aug 17, 2012
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implemented serialization of floating point numbers
parent
429872ba
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
10 deletions
+18
-10
src/binary_deserializer.cpp
src/binary_deserializer.cpp
+14
-7
src/binary_serializer.cpp
src/binary_serializer.cpp
+4
-3
No files found.
src/binary_deserializer.cpp
View file @
23b49aab
...
@@ -28,8 +28,10 @@
...
@@ -28,8 +28,10 @@
\******************************************************************************/
\******************************************************************************/
#include <string>
#include <cstdint>
#include <cstdint>
#include <cstring>
#include <cstring>
#include <sstream>
#include <iterator>
#include <iterator>
#include <exception>
#include <exception>
#include <stdexcept>
#include <stdexcept>
...
@@ -51,13 +53,6 @@ inline void range_check(iterator begin, iterator end, size_t read_size) {
...
@@ -51,13 +53,6 @@ inline void range_check(iterator begin, iterator end, size_t read_size) {
}
}
}
}
// @returns the next iterator position
template
<
typename
T
>
iterator
read
(
iterator
,
iterator
,
T
&
,
typename
enable_if
<
std
::
is_floating_point
<
T
>::
value
>::
type
*
=
0
)
{
throw
std
::
logic_error
(
"read floating point not implemented yet"
);
}
template
<
typename
T
>
template
<
typename
T
>
iterator
read
(
iterator
begin
,
iterator
end
,
T
&
storage
,
iterator
read
(
iterator
begin
,
iterator
end
,
T
&
storage
,
typename
enable_if
<
std
::
is_integral
<
T
>::
value
>::
type
*
=
0
)
{
typename
enable_if
<
std
::
is_integral
<
T
>::
value
>::
type
*
=
0
)
{
...
@@ -90,6 +85,18 @@ iterator read_unicode_string(iterator begin, iterator end, StringType& str) {
...
@@ -90,6 +85,18 @@ iterator read_unicode_string(iterator begin, iterator end, StringType& str) {
return
begin
;
return
begin
;
}
}
// @returns the next iterator position
template
<
typename
T
>
iterator
read
(
iterator
begin
,
iterator
end
,
T
&
value
,
typename
enable_if
<
std
::
is_floating_point
<
T
>::
value
>::
type
*
=
0
)
{
// floating points are written as strings
std
::
string
str
;
auto
result
=
read_unicode_string
<
char
>
(
begin
,
end
,
str
);
std
::
istringstream
iss
(
str
);
iss
>>
value
;
return
result
;
}
iterator
read
(
iterator
begin
,
iterator
end
,
std
::
u16string
&
storage
)
{
iterator
read
(
iterator
begin
,
iterator
end
,
std
::
u16string
&
storage
)
{
// char16_t is guaranteed to has *at least* 16 bytes,
// char16_t is guaranteed to has *at least* 16 bytes,
// but not to have *exactly* 16 bytes; thus use uint16_t
// but not to have *exactly* 16 bytes; thus use uint16_t
...
...
src/binary_serializer.cpp
View file @
23b49aab
...
@@ -69,10 +69,11 @@ class binary_writer {
...
@@ -69,10 +69,11 @@ class binary_writer {
}
}
template
<
typename
T
>
template
<
typename
T
>
void
operator
()(
const
T
&
,
void
operator
()(
const
T
&
value
,
typename
enable_if
<
std
::
is_floating_point
<
T
>::
value
>::
type
*
=
0
)
{
typename
enable_if
<
std
::
is_floating_point
<
T
>::
value
>::
type
*
=
0
)
{
throw
std
::
logic_error
(
"binary_serializer::write_floating_point "
// write floating points as strings
"not implemented yet"
);
std
::
string
str
=
std
::
to_string
(
value
);
(
*
this
)(
str
);
}
}
void
operator
()(
const
std
::
string
&
str
)
{
void
operator
()(
const
std
::
string
&
str
)
{
...
...
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