PTLib  Version 2.18.8
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
memfile.h
Go to the documentation of this file.
1 /*
2  * memfile.h
3  *
4  * WAV file I/O channel class.
5  *
6  * Portable Windows Library
7  *
8  * Copyright (c) 2002 Equivalence Pty. Ltd.
9  *
10  * The contents of this file are subject to the Mozilla Public License
11  * Version 1.0 (the "License"); you may not use this file except in
12  * compliance with the License. You may obtain a copy of the License at
13  * http://www.mozilla.org/MPL/
14  *
15  * Software distributed under the License is distributed on an "AS IS"
16  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
17  * the License for the specific language governing rights and limitations
18  * under the License.
19  *
20  * The Original Code is Portable Windows Library.
21  *
22  * The Initial Developer of the Original Code is
23  * Equivalence Pty Ltd
24  *
25  * All Rights Reserved.
26  *
27  * Contributor(s): ______________________________________.
28  */
29 
30 #ifndef PTLIB_PMEMFILE_H
31 #define PTLIB_PMEMFILE_H
32 
33 #ifdef P_USE_PRAGMA
34 #pragma interface
35 #endif
36 
37 
40 class PMemoryFile : public PFile
41 {
42  PCLASSINFO(PMemoryFile, PFile);
43  public:
48  PMemoryFile();
49 
53  const PBYTEArray & data
54  );
55 
58  ~PMemoryFile();
60 
61 
71  const PObject & obj
72  ) const;
74 
75 
82  virtual PBoolean Close();
83 
95  virtual PBoolean Read(
96  void * buf,
97  PINDEX len
98  );
99 
109  virtual PBoolean Write(
110  const void * buf,
111  PINDEX len
112  );
114 
115 
124  virtual off_t GetLength() const;
125 
132  virtual PBoolean SetLength(
133  off_t len
134  );
135 
146  virtual PBoolean SetPosition(
147  off_t pos,
148  FilePositionOrigin origin = Start
149  );
150 
157  virtual off_t GetPosition() const;
159 
160 
165  const PBYTEArray & GetData() const { return m_data; }
167 
168 
169  protected:
170  virtual bool InternalOpen(OpenMode mode, OpenOptions opts, PFileInfo::Permissions permissions);
171 
173  off_t m_position;
174 };
175 
176 
177 #endif // PTLIB_PMEMFILE_H
178 
179 
180 // End of File ///////////////////////////////////////////////////////////////
const PBYTEArray & GetData() const
Get the memory data the file has operated with.
Definition: memfile.h:165
This class represents a disk file.
Definition: file.h:57
virtual bool InternalOpen(OpenMode mode, OpenOptions opts, PFileInfo::Permissions permissions)
virtual PBoolean Write(const void *buf, PINDEX len)
Low level write to the memory file channel.
virtual off_t GetPosition() const
Get the current active position in the file for the next read or write operation. ...
~PMemoryFile()
Destroy the memory file.
This class is used to allow a block of memory to substitute for a disk file.
Definition: memfile.h:40
Comparison
Result of the comparison operation performed by the Compare() function.
Definition: object.h:2251
virtual off_t GetLength() const
Get the current size of the file.
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.
virtual PBoolean Read(void *buf, PINDEX len)
Low level read from the memory file channel.
Array of unsigned characters.
Definition: array.h:605
off_t m_position
Definition: memfile.h:173
Comparison Compare(const PObject &obj) const
Determine the relative rank of the two objects.
FilePositionOrigin
Options for the origin in setting the file position.
Definition: file.h:500
bool PBoolean
Definition: object.h:174
virtual PBoolean SetPosition(off_t pos, FilePositionOrigin origin=Start)
Set the current active position in the file for the next read or write operation. ...
PMemoryFile()
Create a new, empty, memory file.
virtual PBoolean Close()
Close the channel, shutting down the link to the data source.
PBYTEArray m_data
Definition: memfile.h:172
Set position relative to start of file.
Definition: file.h:501
Ultimate parent class for all objects in the class library.
Definition: object.h:2204
OpenMode
When a file is opened, it may restrict the access available to operations on the object instance...
Definition: file.h:74