MCPcopy Create free account
hub / github.com/davisking/dlib / load_object_from_file

Function load_object_from_file

dlib/python/pybind_utils.h:84–98  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

82
83 template <typename T>
84 std::shared_ptr<T> load_object_from_file (
85 const std::string& filename
86 )
87 /*!
88 ensures
89 - deserializes an object of type T from the given file and returns it.
90 !*/
91 {
92 std::ifstream fin(filename.c_str(), std::ios::binary);
93 if (!fin)
94 throw dlib::error("Unable to open " + filename);
95 auto obj = std::make_shared<T>();
96 deserialize(*obj, fin);
97 return obj;
98 }
99}
100
101// ----------------------------------------------------------------------------------------

Callers

nothing calls this directly

Calls 2

errorClass · 0.85
deserializeFunction · 0.50

Tested by

no test coverage detected