Data Members
Points to the CDocument object being serialized. |
Construction
Closes an archive without throwing an exception. | |
Creates a CArchive object. | |
Flushes unwritten data and disconnects from the CFile. |
Basic Input/Output
Flushes unwritten data from the archive buffer. | |
Stores objects and primitive types to the archive. | |
Loads objects and primitive types from the archive. | |
Reads raw bytes. | |
Reads a single line of text. | |
Writes raw bytes. | |
Writes a single line of text. |
Status
Gets the CFile object pointer for this archive. | |
Called from the Serialize function to determine the version of the object that is being deserialized. | |
Determines whether the buffer has been emptied during a Windows Sockets receive process. | |
| |
Determines whether the archive is loading. | |
Determines whether the archive is storing. | |
Sets the object schema stored in the archive object. |
Object Input/Output
Places objects in the map that are not serialized to the file, but that are available for subobjects to reference. | |
Reads a class reference previously stored with WriteClass. | |
Calls an object's Serialize function for loading. | |
Reads or writes the class reference to the CArchive object depending on the direction of the CArchive. | |
Sets the size to which the load array grows. Must be called before any object is loaded or before MapObject or ReadObject is called. | |
Sets the hash table size and the block size of the map used to identify unique objects during the serialization process. | |
Writes a reference to the CRuntimeClass to the CArchive. | |
Calls an object's |
CArchive(
CFile* pFile,
UINT nMode,
int nBufSize = 4096,
void* lpBuf = NULL
);
Parameters
pFile
A pointer to the CFile object that is the ultimate source or destination of the persistent data.
nMode
A flag that specifies whether objects will be loaded from or stored to the archive. The nMode parameter must have one of the following values:
· CArchive::load Loads data from the archive. Requires only CFile read permission.
· CArchive::store Saves data to the archive. Requires CFile write permission.
· CArchive::bNoFlushOnDelete Prevents the archive from automatically calling Flush when the archive destructor is called. If you set this flag, you are responsible for explicitly calling Close before the destructor is called. If you do not, your data will be corrupted.
nBufSize
An integer that specifies the size of the internal file buffer, in bytes. Note that the default buffer size is 4,096 bytes. If you routinely archive large objects, you will improve performance if you use a larger buffer size that is a multiple of the file buffer size.
lpBuf
An optional pointer to a user-supplied buffer of size nBufSize. If you do not specify this parameter, the archive allocates a buffer from the local heap and frees it when the object is destroyed. The archive does not free a user-supplied buffer.
Remarks
You cannot change this specification after you have created the archive.
You may not use CFile operations to alter the state of the file until you have closed the archive. Any such operation will damage the integrity of the archive. You may access the position of the file pointer at any time during serialization by obtaining the archive's file object from the GetFile member function and then using the CFile::GetPosition function. You should call CArchive::Flush before obtaining the position of the file pointer.
Example
extern char* pFileName;
CFile f;
char buf[512];
if( !f.Open( pFileName, CFile::modeCreate | CFile::modeWrite ) ) {
#ifdef _DEBUG
afxDump << "Unable to open file" << "\n";
exit( 1 );
#endif
}
CArchive ar( &f, CArchive::store, 512, buf );
댓글
댓글 쓰기