Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
D
dlib
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
钟尚武
dlib
Commits
16d4d5d8
Commit
16d4d5d8
authored
Feb 06, 2016
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added serialization support for std::deque.
parent
a3dad7ac
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
0 deletions
+53
-0
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