From 20a1477209e1fd28b0f19dbca263508d5c0b9af1 Mon Sep 17 00:00:00 2001 From: Davis King Date: Sat, 19 Sep 2020 07:21:52 -0400 Subject: [PATCH] update docs --- dlib/serialize.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/dlib/serialize.h b/dlib/serialize.h index 9754e91d3..85599f210 100644 --- a/dlib/serialize.h +++ b/dlib/serialize.h @@ -49,9 +49,19 @@ For convenience, you can also serialize to a file using this syntax: serialize("your_file.dat") << some_object << another_object; + // or to a memory buffer. + std::vector memory_buffer; + serialize(memory_buffer) << some_object << another_object; + + // or some other stream + std::ostringstream memory_buffer2; + serialize(memory_buffer2) << some_object << another_object; + That overwrites the contents of your_file.dat with the serialized data from some_object and another_object. Then to recall the objects from the file you can do: deserialize("your_file.dat") >> some_object >> another_object; + // or from a memory buffer or another stream called memory_buffer. + deserialize(memory_buffer) >> some_object >> another_object; Finally, you can chain as many objects together using the << and >> operators as you like.