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
15207aad
Commit
15207aad
authored
Feb 23, 2014
by
Davis King
Browse files
Added another python utility. This one deserializes objects.
parent
7edb820b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
0 deletions
+20
-0
dlib/python/boost_python_utils.h
dlib/python/boost_python_utils.h
+20
-0
No files found.
dlib/python/boost_python_utils.h
View file @
15207aad
...
...
@@ -6,6 +6,7 @@
#include <boost/python.hpp>
#include <vector>
#include <string>
#include <dlib/serialize.h>
inline
bool
hasattr
(
boost
::
python
::
object
obj
,
...
...
@@ -58,6 +59,25 @@ boost::python::list vector_to_python_list (
// ----------------------------------------------------------------------------------------
template
<
typename
T
>
boost
::
shared_ptr
<
T
>
load_object_from_file
(
const
std
::
string
&
filename
)
/*!
ensures
- deserializes an object of type T from the given file and returns it.
!*/
{
std
::
ifstream
fin
(
filename
.
c_str
(),
std
::
ios
::
binary
);
if
(
!
fin
)
throw
dlib
::
error
(
"Unable to open "
+
filename
);
boost
::
shared_ptr
<
T
>
obj
(
new
T
());
deserialize
(
*
obj
,
fin
);
return
obj
;
}
// ----------------------------------------------------------------------------------------
#endif // DLIB_BOOST_PYTHON_UtILS_H__
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