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
83057123
Commit
83057123
authored
Mar 13, 2018
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added check_serialized_version().
parent
973f4536
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
0 deletions
+30
-0
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