memfile.h
Go to the documentation of this file.
/*
* memfile.h
*
* WAV file I/O channel class.
*
* Portable Windows Library
*
* Copyright (c) 2002 Equivalence Pty. Ltd.
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is Portable Windows Library.
*
* The Initial Developer of the Original Code is
* Equivalence Pty Ltd
*
* All Rights Reserved.
*
* Contributor(s): ______________________________________.
*
* $Revision: 26949 $
* $Author: rjongbloed $
* $Date: 2012-02-07 20:27:07 -0600 (Tue, 07 Feb 2012) $
*/
#ifndef PTLIB_PMEMFILE_H
#define PTLIB_PMEMFILE_H
#ifdef P_USE_PRAGMA
#pragma interface
#endif
class PMemoryFile : public PFile
{
PCLASSINFO(PMemoryFile, PFile);
public:
PMemoryFile();
PMemoryFile(
const PBYTEArray & data
);
~PMemoryFile();
Comparison Compare(
const PObject & obj
) const;
virtual PBoolean Open(
OpenMode mode = ReadWrite, // Mode in which to open the file.
int opts = ModeDefault // Options for open operation.
);
virtual PBoolean Open(
const PFilePath & name, // Name of file to open.
OpenMode mode = ReadWrite, // Mode in which to open the file.
int opts = ModeDefault // <code>OpenOptions</code> enum# for open operation.
);
virtual PBoolean Close();
virtual PBoolean Read(
void * buf,
PINDEX len
);
virtual PBoolean Write(
const void * buf,
PINDEX len
);
virtual off_t GetLength() const;
virtual PBoolean SetLength(
off_t len
);
virtual PBoolean SetPosition(
off_t pos,
FilePositionOrigin origin = Start
);
virtual off_t GetPosition() const;
const PBYTEArray & GetData() const { return m_data; }
protected:
PBYTEArray m_data;
off_t m_position;
};
#endif // PTLIB_PMEMFILE_H
// End of File ///////////////////////////////////////////////////////////////
PMemoryFile::Compare
Comparison Compare(const PObject &obj) const
Determine the relative rank of the two objects.
PFile
This class represents a disk file.
Definition: file.h:60
PMemoryFile::Write
virtual PBoolean Write(const void *buf, PINDEX len)
Low level write to the memory file channel.
PMemoryFile::~PMemoryFile
~PMemoryFile()
Destroy the memory file.
PMemoryFile
This class is used to allow a block of memory to substitute for a disk file.
Definition: memfile.h:44
PFilePath
This class describes a full description for a file on the particular platform.
Definition: filepath.h:65
PFile::ReadWrite
File can be both read and written.
Definition: file.h:80
PObject::Comparison
Comparison
Result of the comparison operation performed by the Compare() function.
Definition: object.h:1184
PMemoryFile::GetData
const PBYTEArray & GetData() const
Get the memory data the file has operated with.
Definition: memfile.h:201
PMemoryFile::GetPosition
virtual off_t GetPosition() const
Get the current active position in the file for the next read or write operation. ...
PBoolean
BOOL PBoolean
Definition: object.h:102
PMemoryFile::SetLength
virtual PBoolean SetLength(off_t len)
Set the size of the file, padding with 0 bytes if it would require expanding the file, or truncating it if being made shorter.
PMemoryFile::Read
virtual PBoolean Read(void *buf, PINDEX len)
Low level read from the memory file channel.
PBYTEArray
Array of unsigned characters.
Definition: array.h:670
PMemoryFile::m_position
off_t m_position
Definition: memfile.h:207
PFile::FilePositionOrigin
FilePositionOrigin
Options for the origin in setting the file position.
Definition: file.h:457
PMemoryFile::GetLength
virtual off_t GetLength() const
Get the current size of the file.
PMemoryFile::SetPosition
virtual PBoolean SetPosition(off_t pos, FilePositionOrigin origin=Start)
Set the current active position in the file for the next read or write operation. ...
PFile::ModeDefault
File options depend on the OpenMode parameter.
Definition: file.h:95
PMemoryFile::PMemoryFile
PMemoryFile()
Create a new, empty, memory file.
PMemoryFile::Close
virtual PBoolean Close()
Close the channel, shutting down the link to the data source.
PMemoryFile::m_data
PBYTEArray m_data
Definition: memfile.h:206
PFile::Start
Set position relative to start of file.
Definition: file.h:459
PMemoryFile::Open
virtual PBoolean Open(OpenMode mode=ReadWrite, int opts=ModeDefault)
Open the current file in the specified mode and with the specified options.
PObject
Ultimate parent class for all objects in the class library.
Definition: object.h:1118
PFile::OpenMode
OpenMode
When a file is opened, it may restrict the access available to operations on the object instance...
Definition: file.h:77