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
f351fad5
"...git@developer.sourcefind.cn:renzhc/diffusers_dcu.git" did not exist on "747f42d0e907e22a95241aecab41f68718422848"
Commit
f351fad5
authored
Aug 18, 2012
by
Davis King
Browse files
Added serialization support for std::set.
parent
8a843211
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
62 additions
and
0 deletions
+62
-0
dlib/serialize.h
dlib/serialize.h
+62
-0
No files found.
dlib/serialize.h
View file @
f351fad5
...
@@ -54,6 +54,7 @@
...
@@ -54,6 +54,7 @@
- std::wstring
- std::wstring
- std::vector
- std::vector
- std::map
- std::map
- std::set
- std::pair
- std::pair
- std::complex
- std::complex
- dlib::uint64
- dlib::uint64
...
@@ -69,6 +70,7 @@
...
@@ -69,6 +70,7 @@
- std::wstring
- std::wstring
- std::vector
- std::vector
- std::map
- std::map
- std::set
- std::pair
- std::pair
- std::complex
- std::complex
- dlib::uint64
- dlib::uint64
...
@@ -123,6 +125,7 @@
...
@@ -123,6 +125,7 @@
#include <vector>
#include <vector>
#include <complex>
#include <complex>
#include <map>
#include <map>
#include <set>
#include <limits>
#include <limits>
#include "uintn.h"
#include "uintn.h"
#include "interfaces/enumerable.h"
#include "interfaces/enumerable.h"
...
@@ -565,6 +568,18 @@ namespace dlib
...
@@ -565,6 +568,18 @@ namespace dlib
std
::
istream
&
in
std
::
istream
&
in
);
);
template
<
typename
domain
,
typename
compare
,
typename
alloc
>
void
serialize
(
const
std
::
set
<
domain
,
compare
,
alloc
>&
item
,
std
::
ostream
&
out
);
template
<
typename
domain
,
typename
compare
,
typename
alloc
>
void
deserialize
(
std
::
set
<
domain
,
compare
,
alloc
>&
item
,
std
::
istream
&
in
);
template
<
typename
T
,
typename
alloc
>
template
<
typename
T
,
typename
alloc
>
void
serialize
(
void
serialize
(
const
std
::
vector
<
T
,
alloc
>&
item
,
const
std
::
vector
<
T
,
alloc
>&
item
,
...
@@ -744,6 +759,53 @@ namespace dlib
...
@@ -744,6 +759,53 @@ namespace dlib
{
throw
serialization_error
(
e
.
info
+
"
\n
while deserializing object of type std::map"
);
}
{
throw
serialization_error
(
e
.
info
+
"
\n
while deserializing object of type std::map"
);
}
}
}
// ----------------------------------------------------------------------------------------
template
<
typename
domain
,
typename
compare
,
typename
alloc
>
void
serialize
(
const
std
::
set
<
domain
,
compare
,
alloc
>&
item
,
std
::
ostream
&
out
)
{
try
{
const
unsigned
long
size
=
static_cast
<
unsigned
long
>
(
item
.
size
());
serialize
(
size
,
out
);
typename
std
::
set
<
domain
,
compare
,
alloc
>::
const_iterator
i
;
for
(
i
=
item
.
begin
();
i
!=
item
.
end
();
++
i
)
{
serialize
(
*
i
,
out
);
}
}
catch
(
serialization_error
&
e
)
{
throw
serialization_error
(
e
.
info
+
"
\n
while serializing object of type std::set"
);
}
}
template
<
typename
domain
,
typename
compare
,
typename
alloc
>
void
deserialize
(
std
::
set
<
domain
,
compare
,
alloc
>&
item
,
std
::
istream
&
in
)
{
try
{
item
.
clear
();
unsigned
long
size
;
deserialize
(
size
,
in
);
domain
d
;
for
(
unsigned
long
i
=
0
;
i
<
size
;
++
i
)
{
deserialize
(
d
,
in
);
item
.
insert
(
d
);
}
}
catch
(
serialization_error
&
e
)
{
throw
serialization_error
(
e
.
info
+
"
\n
while deserializing object of type std::set"
);
}
}
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
template
<
typename
T
,
typename
alloc
>
template
<
typename
T
,
typename
alloc
>
...
...
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