QMemoryFile(3qt)

NAME
QMemoryFile - Provide means to map a file info memory or refere to a block or memory by name

#include <qmemoryfile_p.h>

  Public Members
enum Flags { Write = 0x00000001, Shared = 0x00000002, Create = 0x00000004, }
QMemoryFile ( const QString & fileName, int flags=-1, uint size=0 )
~QMemoryFile ()
bool isShared ()
bool isWritable ()
uint size ()
char* data ()

DESCRIPTION
The QMemoryFile class provide means to map a file info memory or refere to a block or memory by name.

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.

MEMBER FUNCTION DOCUMENTATION

QMemoryFile::QMemoryFile ( const QString & fileName, int flags=-1, uint size=0 )
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);

QMemoryFile::~QMemoryFile ()
Destructs the memory mapped file.

char* QMemoryFile::data ()
Returns a pointer to memory that this QMemoryFile is associated with.

bool QMemoryFile::isShared ()
Returns true if memory is shared.

bool QMemoryFile::isWritable ()
Returns true if memory is writable.

SEE ALSO
http://doc.trolltech.com/qmemoryfile.html http://www.trolltech.com/faq/tech.html

COPYRIGHT
Copyright 1992-2001 Trolltech AS, http://www.trolltech.com. See the license file included in the distribution for a complete license statement.

AUTHOR
Generated automatically from the source code.

BUGS
If you find a bug in Qt, please report it as described in http://doc.trolltech.com/bughowto.html. Good bug reports make our job much simpler. Thank you.

In case of content or formattting problems with this manual page, please report them to qt-bugs@trolltech.com. Please include the name of the manual page (qmemoryfile.3qt) and the Qt version (2.3.7).