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
83057123
Commit
83057123
authored
Mar 12, 2018
by
Davis King
Browse files
Added check_serialized_version().
parent
973f4536
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
0 deletions
+30
-0
dlib/serialize.h
dlib/serialize.h
+30
-0
No files found.
dlib/serialize.h
View file @
83057123
...
...
@@ -171,10 +171,27 @@ namespace dlib
class
serialization_error
:
public
error
{
/*!
WHAT THIS OBJECT REPRESENTS
This is the exception object. It is thrown if serialization or
deserialization fails.
!*/
public:
serialization_error
(
const
std
::
string
&
e
)
:
error
(
e
)
{}
};
void
check_serialized_version
(
const
std
::
string
&
expected_version
,
std
::
istream
&
in
);
/*!
ensures
- Deserializes a string from in and if it doesn't match expected_version we
throw serialization_error.
!*/
// ----------------------------------------------------------------------------------------
template
<
typename
T
>
...
...
@@ -1737,6 +1754,19 @@ namespace dlib
}
}
// ----------------------------------------------------------------------------------------
inline
void
check_serialized_version
(
const
std
::
string
&
expected_version
,
std
::
istream
&
in
)
{
std
::
string
version
;
deserialize
(
version
,
in
);
if
(
version
!=
expected_version
)
{
throw
serialization_error
(
"Unexpected version '"
+
version
+
"' found while deserializing object. Expected version to be '"
+
expected_version
+
"'."
);
}
}
// ----------------------------------------------------------------------------------------
}
...
...
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