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

Function serialize

dlib/array2d/serialize_pixel_overloads.h:27–50  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25 typename mem_manager
26 >
27 void serialize (
28 const array2d<rgb_pixel,mem_manager>& item,
29 std::ostream& out
30 )
31 {
32 try
33 {
34 // The reason the serialization is a little funny is because we are trying to
35 // maintain backwards compatibility with an older serialization format used by
36 // dlib while also encoding things in a way that lets the array2d and matrix
37 // objects have compatible serialization formats.
38 serialize(-item.nr(),out);
39 serialize(-item.nc(),out);
40
41 COMPILE_TIME_ASSERT(sizeof(rgb_pixel) == 3);
42
43 if (item.size() != 0)
44 out.write((char*)&item[0][0], sizeof(rgb_pixel)*item.size());
45 }
46 catch (serialization_error& e)
47 {
48 throw serialization_error(e.info + "\n while serializing object of type array2d");
49 }
50 }
51
52 template <
53 typename mem_manager

Callers

nothing calls this directly

Calls 5

serialization_errorClass · 0.85
nrMethod · 0.45
ncMethod · 0.45
sizeMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected