Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dlib
Commits
16d4d5d8
Commit
16d4d5d8
authored
Feb 06, 2016
by
Davis King
Browse files
Added serialization support for std::deque.
parent
a3dad7ac
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
0 deletions
+53
-0
dlib/serialize.h
dlib/serialize.h
+53
-0
No files found.
dlib/serialize.h
View file @
16d4d5d8
...
...
@@ -62,6 +62,7 @@
- std::string
- std::wstring
- std::vector
- std::deque
- std::map
- std::set
- std::pair
...
...
@@ -79,6 +80,7 @@
- std::string
- std::wstring
- std::vector
- std::deque
- std::map
- std::set
- std::pair
...
...
@@ -143,6 +145,7 @@
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <complex>
#include <map>
#include <set>
...
...
@@ -652,6 +655,18 @@ namespace dlib
std
::
istream
&
in
);
template
<
typename
T
,
typename
alloc
>
void
serialize
(
const
std
::
deque
<
T
,
alloc
>&
item
,
std
::
ostream
&
out
);
template
<
typename
T
,
typename
alloc
>
void
deserialize
(
std
::
deque
<
T
,
alloc
>&
item
,
std
::
istream
&
in
);
inline
void
serialize
(
const
std
::
string
&
item
,
std
::
ostream
&
out
...
...
@@ -1035,6 +1050,44 @@ namespace dlib
{
throw
serialization_error
(
e
.
info
+
"
\n
while deserializing object of type std::vector"
);
}
}
// ----------------------------------------------------------------------------------------
template
<
typename
T
,
typename
alloc
>
void
serialize
(
const
std
::
deque
<
T
,
alloc
>&
item
,
std
::
ostream
&
out
)
{
try
{
const
unsigned
long
size
=
static_cast
<
unsigned
long
>
(
item
.
size
());
serialize
(
size
,
out
);
for
(
unsigned
long
i
=
0
;
i
<
item
.
size
();
++
i
)
serialize
(
item
[
i
],
out
);
}
catch
(
serialization_error
&
e
)
{
throw
serialization_error
(
e
.
info
+
"
\n
while serializing object of type std::deque"
);
}
}
template
<
typename
T
,
typename
alloc
>
void
deserialize
(
std
::
deque
<
T
,
alloc
>&
item
,
std
::
istream
&
in
)
{
try
{
unsigned
long
size
;
deserialize
(
size
,
in
);
item
.
resize
(
size
);
for
(
unsigned
long
i
=
0
;
i
<
size
;
++
i
)
deserialize
(
item
[
i
],
in
);
}
catch
(
serialization_error
&
e
)
{
throw
serialization_error
(
e
.
info
+
"
\n
while deserializing object of type std::deque"
);
}
}
// ----------------------------------------------------------------------------------------
inline
void
serialize
(
...
...
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