Serialization vs. Archiving?

前端 未结 3 2115
你的背包
你的背包 2020-12-19 08:33

The iOS docs differentiate between \"serializing\" and \"archiving.\" Is this a general distinction (i.e., holds in other languages) or is it specific to Objective-C? Also,

3条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-19 09:33

    Generally speaking, Serialization is concerned with converting your program data types into architecture independent byte streams. Archiving is specialized serialization in that you could store type and other relationship based information that allow you to unserialize/unmarshall easily. So archival can be thought of as a specialization and subset of Serialization. For Objective-C

    Serialization converts Objective-C types to and from an architecture-independent byte stream. In contrast to archiving, basic serialization does not record the data type of the values nor the relationships between them; only the values themselves are recorded. It is your responsibility to deserialize the data in the proper order. Several convenience classes, however, do provide the ability to serialize property lists, recording their structure along with their values.

    With C++ boost serialization --

    http://www.boost.org/doc/libs/1_45_0/libs/serialization/doc/index.html

    Here, we use the term "serialization" to mean the reversible deconstruction of an arbitrary set of C++ data structures to a sequence of bytes. Such a system can be used to reconstitute an equivalent structure in another program context. Depending on the context, this might used implement object persistence, remote parameter passing or other facility. In this system we use the term "archive" to refer to a specific rendering of this stream of bytes. This could be a file of binary data, text data, XML, or some other created by the user of this library.

提交回复
热议问题