![]() ![]() |
The QMemoryFile class provide means to map a file info memory or refere to a block or memory by name. More...
#include <qmemoryfile_p.h>
Warning: This class is not part of the Qt APi and subject to change. This file file may change from version to version without notice, or even be removed.
Currently this class supports read only access on all platforms; and read plus write accces provided on unix and windows based plaforms. The size of mapped file can not be changed.
Construct a memory mapped to an actual file or named memory block. If fileName is not preceeded by an \\ then it is treated as a real file name. Otherwise the characters after the \\ are used as the name for the memory block required. nb: You will need to escape the \'s so it you need to use \\\\ within a literal string A value for size should always be provided, though if the size is not provided it will be determined if possible.
If a file is being mapped to be written to, then the flags of subsequent QMemoryFiles mapped to the same file should include QMemoryFile::Write.
Example:
// Open a maping to file text.dat QMemoryFile memoryFile("text.dat", QMemoryFile:Read, 20); char *data = memoryFile.data(); int sum = 0; for (int i = 0; i < 20; i++){ sum = sum + data[i]; } qDebug("Sum =%d", sum);
Example for creating named memory block:
QMemoryFile block1("\\\\block1", QMemoryFile::Create | QMemoryFile::Write, 20); char *dataBlock = block.data(); for (int i = 0; i < 19; i++){ dataBlock[i] = i +'a'; } dataBlock[20] = '\0'; qDebug("Data block is %s", dataBlock);
Destructs the memory mapped file.
Returns a pointer to memory that this QMemoryFile is associated with.
Returns true if memory is shared.
Returns true if memory is writable.
Search the documentation, FAQ, qt-interest archive and more (uses
www.trolltech.com):
This file is part of the Qt toolkit, copyright © 1995-2001 Trolltech, all rights reserved.
Copyright © 2001 Trolltech | Trademarks | Qt version 2.3.7
|