CArchive Class

来源:互联网 发布:unity3d ongui 编辑:程序博客网 时间:2024/06/01 19:30

Allows you to save a complex network of objects in a permanent binary form (usually disk storage) that persists after those objects are deleted.

在对象被删除后,允许你将一个复杂的网格对象保存成一个永久的二进制形式。

class CArchive

CArchive 类

Remarks

备注

CArchive does not have a base class.

CArchive没有基类,即不继承于任何MFC类。

Later you can load the objects from persistent storage, reconstituting them in memory. This process of making data persistent is called "serialization."

稍后你可以从永久性存储的二进制文件中加载对象,在内存中重新构造。这个使数据永久性存储的过程叫做串行化。

You can think of an archive object as a kind of binary stream. Like an input/output stream, an archive is associated with a file and permits the buffered writing and reading of data to and from storage. An input/output stream processes sequences of ASCII characters, but an archive processes binary object data in an efficient, nonredundant format.

你可以将一个Archive对象作为一个二进制流。像输入输出流,一个Archive对象和一个文件相关联,并且允许从存储空间缓冲读写数据。输入输出流进程是一组ASCII码字符队列,但一个archive进程是一组有效的,非冗余的二进制对象数据。

You must create a CFile object before you can create a CArchive object. In addition, you must ensure that the archive's load/store status is compatible with the file's open mode. You are limited to one active archive per file.

在创建CArchive对象之前必须创建一个CFile对象。另外,必须确保archive的加载或存取兼容文件的打开格式。一个文件只能对应一个活跃的archive对象。

When you construct a CArchive object, you attach it to an object of classCFile (or a derived class) that represents an open file. You also specify whether the archive will be used for loading or storing. ACArchive object can process not only primitive types but also objects of CObject-derived classes designed for serialization. A serializable class usually has aSerialize member function, and it usually uses the DECLARE_SERIAL and IMPLEMENT_SERIAL macros, as described under classCObject.

当你构造一个CArchive对象时,附加它到一个CFile对象类或派生类中,这个类提供一个打开的文件。同样确定这个archive是否将会被用于加载或存储。一个CArchive对象不仅能够处理原始类型,而且能够处理那些为串行化设计的CObject派生类对象。一个串行化类通常有一个串行化成员函数,并且经常用DECLARE_SERIAL和IMPLEMENT_SERIAL宏查看CObject对象。

The overloaded extraction (>>) and insertion (<<) operators are convenient archive programming interfaces that support both primitive types andCObject-derived classes.

这重载的提取(>>)和插入(<<)操作符是方便的archive工程接口,支持原始类型和CObject的派生类型。

CArchive also supports programming with the MFC Windows Sockets classes CSocket and CSocketFile. The IsBufferEmpty member function supports that usage.

For more information on CArchive, see the articles Serialization and Windows Sockets: Using Sockets with Archives.

同样支持MFC工程的窗口接口类CSocket和CSocketFile类。isBufferEmpty成员函数支持那样使用。关于更多的此类信息,请查看Serialization and Windows Sockets: Using Sockets with Archives文章